@versini/auth0-react-thin 2.25.0 → 2.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -111,7 +111,7 @@
111
111
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
112
112
  };
113
113
 
114
- function e(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]]);}return n}function t(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return "m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function n(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return "a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}function o(e,t){this.v=e,this.k=t;}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function r(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function s(e){return new o(e,0)}function a(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function c(e,t){return e.get(r(e,t))}function u(e,t,n){a(e,t),t.set(e,n);}function l(e,t,n){return e.set(r(e,t),n),n}function d(e,t){a(e,t),t.add(e);}function h(e,t,n){return (t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o);}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach(function(t){h(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e}function m(e,t){if(null==e)return {};var n,o,i=function(e,t){if(null==e)return {};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==t.indexOf(o))continue;n[o]=e[o];}return n}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);}return i}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,i,r,s,a=[],c=!0,u=!1;try{if(r=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1;}else for(;!(c=(o=r.call(n)).done)&&(a.push(o.value),a.length!==t);c=!0);}catch(e){u=!0,i=e;}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.toString.call(e).slice(8,-1);return "Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e){return function(){return new g(e.apply(this,arguments))}}function g(e){var t,n;function i(t,n){try{var s=e[t](n),a=s.value,c=a instanceof o;Promise.resolve(c?a.v:a).then(function(n){if(c){var o="return"===t&&a.k?t:"next";if(!a.k||n.done)return i(o,n);n=e[o](n).value;}r(!!s.done,n);},function(e){i("throw",e);});}catch(e){r(2,e);}}function r(e,o){2===e?t.reject(o):t.resolve({value:o,done:e}),(t=t.next)?i(t.key,t.arg):n=null;}this._invoke=function(e,o){return new Promise(function(r,s){var a={key:e,arg:o,resolve:r,reject:s,next:null};n?n=n.next=a:(t=n=a,i(e,o));})},"function"!=typeof e.return&&(this.return=void 0);}"function"==typeof SuppressedError&&SuppressedError,g.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},g.prototype.next=function(e){return this._invoke("next",e)},g.prototype.throw=function(e){return this._invoke("throw",e)},g.prototype.return=function(e){return this._invoke("return",e)};const v={timeoutInSeconds:60},b=1e4,_="memory",k="online_access",S={name:"auth0-spa-js",version:"2.25.0"},T=()=>Date.now(),P="default";class E extends Error{constructor(e,t){super(t),this.error=e,this.error_description=t,Object.setPrototypeOf(this,E.prototype);}static fromPayload(e){let t=e.error,n=e.error_description;return new E(t,n)}}class R extends E{constructor(e,t){super("invalid_configuration","".concat(e," ").concat(t)),this.suggestion=t,Object.setPrototypeOf(this,R.prototype);}}class C extends E{constructor(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;super(e,t),this.state=n,this.appState=o,Object.setPrototypeOf(this,C.prototype);}}class x extends E{constructor(e,t,n,o){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;super(e,t),this.connection=n,this.state=o,this.appState=i,Object.setPrototypeOf(this,x.prototype);}}class I extends E{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,I.prototype);}}class A extends I{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,A.prototype);}}class O extends E{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,O.prototype);}}class j extends E{constructor(){super("popup_open","Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,j.prototype);}}class W extends E{constructor(e,t,n,o){super(e,t),this.mfa_token=n,this.mfa_requirements=o,Object.setPrototypeOf(this,W.prototype);}}class N extends E{constructor(e,t){super("missing_refresh_token","Missing Refresh Token (audience: '".concat(L(e,["default"]),"', scope: '").concat(L(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,N.prototype);}}class U extends E{constructor(e,t){super("missing_scopes","Missing requested scopes after refresh (audience: '".concat(L(e,["default"]),"', missing scope: '").concat(L(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,U.prototype);}}class K extends E{constructor(e){super("use_dpop_nonce","Server rejected DPoP proof: wrong nonce"),this.newDpopNonce=e,Object.setPrototypeOf(this,K.prototype);}}function L(e){return e&&!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).includes(e)?e:""}const M=()=>window.crypto,z=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";for(;t.length<43;){const n=M().getRandomValues(new Uint8Array(43-t.length));for(const o of n)t.length<43&&o<198&&(t+=e[o%66]);}return t},J=e=>btoa(e),D=[{key:"name",type:["string"]},{key:"version",type:["string","number"]},{key:"env",type:["object"]}],Z=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Object.keys(e).reduce((n,o)=>{if(t&&"env"===o)return n;const i=D.find(e=>e.key===o);return i&&i.type.includes(typeof e[o])&&(n[o]=e[o]),n},{})},H=t=>{var n=t.clientId,o=e(t,["clientId"]);return new URLSearchParams((e=>Object.keys(e).filter(t=>void 0!==e[t]).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{}))(Object.assign({client_id:n},o))).toString()},F=async e=>{const t=M().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e));return await t},V=e=>(e=>decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))(e.replace(/_/g,"/").replace(/-/g,"+")),X=e=>{const t=new Uint8Array(e);return (e=>{const t={"+":"-","/":"_","=":""};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))};var G="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Y={},q={};Object.defineProperty(q,"__esModule",{value:!0});var B=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var o=e.locked.get(t);void 0===o?void 0===n?e.locked.set(t,[]):e.locked.set(t,[n]):void 0!==n&&(o.unshift(n),e.locked.set(t,o));},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise(function(n,o){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n());})},this.unlock=function(t){var n=e.locked.get(t);if(void 0!==n&&0!==n.length){var o=n.pop();e.locked.set(t,n),void 0!==o&&setTimeout(o,0);}else e.locked.delete(t);};}return e.getInstance=function(){return void 0===e.instance&&(e.instance=new e),e.instance},e}();q.default=function(){return B.getInstance()};var Q=G&&G.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(i,r){function s(e){try{c(o.next(e));}catch(e){r(e);}}function a(e){try{c(o.throw(e));}catch(e){r(e);}}function c(e){e.done?i(e.value):new n(function(t){t(e.value);}).then(s,a);}c((o=o.apply(e,t||[])).next());})},$=G&&G.__generator||function(e,t){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=t.call(e,s);}catch(e){r=[6,e],o=0;}finally{n=i=0;}if(5&r[0])throw r[1];return {value:r[0]?r[1]:void 0,done:!0}}([r,a])}}},ee=G;Object.defineProperty(Y,"__esModule",{value:!0});var te=q,ne="browser-tabs-lock-key",oe={key:function(e){return Q(ee,void 0,void 0,function(){return $(this,function(e){throw new Error("Unsupported")})})},getItem:function(e){return Q(ee,void 0,void 0,function(){return $(this,function(e){throw new Error("Unsupported")})})},clear:function(){return Q(ee,void 0,void 0,function(){return $(this,function(e){return [2,window.localStorage.clear()]})})},removeItem:function(e){return Q(ee,void 0,void 0,function(){return $(this,function(e){throw new Error("Unsupported")})})},setItem:function(e,t){return Q(ee,void 0,void 0,function(){return $(this,function(e){throw new 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 re(e){for(var t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="",o=0;o<e;o++){n+=t[Math.floor(61*Math.random())];}return n}var se=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+re(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,void 0===e.waiters&&(e.waiters=[]);}return e.prototype.acquireLock=function(t,n){return void 0===n&&(n=5e3),Q(this,void 0,void 0,function(){var o,i,r,s,a,c,u;return $(this,function(l){switch(l.label){case 0:o=Date.now()+re(4),i=Date.now()+n,r=ne+"-"+t,s=void 0===this.storageHandler?oe:this.storageHandler,l.label=1;case 1:return Date.now()<i?[4,ie(30)]:[3,8];case 2:return l.sent(),null!==s.getItemSync(r)?[3,5]:(a=this.id+"-"+t+"-"+o,[4,ie(Math.floor(25*Math.random()))]);case 3:return l.sent(),s.setItemSync(r,JSON.stringify({id:this.id,iat:o,timeoutKey:a,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,ie(30)];case 4:return l.sent(),null!==(c=s.getItemSync(r))&&(u=JSON.parse(c)).id===this.id&&u.iat===o?(this.acquiredIatSet.add(o),this.refreshLockWhileAcquired(r,o),[2,!0]):[3,7];case 5:return e.lockCorrector(void 0===this.storageHandler?oe:this.storageHandler),[4,this.waitForSomethingToChange(i)];case 6:l.sent(),l.label=7;case 7:return o=Date.now()+re(4),[3,1];case 8:return [2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(e,t){return Q(this,void 0,void 0,function(){var n=this;return $(this,function(o){return setTimeout(function(){return Q(n,void 0,void 0,function(){var n,o,i;return $(this,function(r){switch(r.label){case 0:return [4,te.default().lock(t)];case 1:return r.sent(),this.acquiredIatSet.has(t)?(n=void 0===this.storageHandler?oe:this.storageHandler,null===(o=n.getItemSync(e))?(te.default().unlock(t),[2]):((i=JSON.parse(o)).timeRefreshed=Date.now(),n.setItemSync(e,JSON.stringify(i)),te.default().unlock(t),this.refreshLockWhileAcquired(e,t),[2])):(te.default().unlock(t),[2])}})})},1e3),[2]})})},e.prototype.waitForSomethingToChange=function(t){return Q(this,void 0,void 0,function(){return $(this,function(n){switch(n.label){case 0:return [4,new Promise(function(n){var o=!1,i=Date.now(),r=!1;function s(){if(r||(window.removeEventListener("storage",s),e.removeFromWaiting(s),clearTimeout(a),r=!0),!o){o=!0;var t=50-(Date.now()-i);t>0?setTimeout(n,t):n(null);}}window.addEventListener("storage",s),e.addToWaiting(s);var a=setTimeout(s,Math.max(0,t-Date.now()));})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),void 0!==e.waiters&&e.waiters.push(t);},e.removeFromWaiting=function(t){void 0!==e.waiters&&(e.waiters=e.waiters.filter(function(e){return e!==t}));},e.notifyWaiters=function(){void 0!==e.waiters&&e.waiters.slice().forEach(function(e){return e()});},e.prototype.releaseLock=function(e){return Q(this,void 0,void 0,function(){return $(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 Q(this,void 0,void 0,function(){var n,o,i,r;return $(this,function(s){switch(s.label){case 0:return n=void 0===this.storageHandler?oe:this.storageHandler,o=ne+"-"+t,null===(i=n.getItemSync(o))?[2]:(r=JSON.parse(i)).id!==this.id?[3,2]:[4,te.default().lock(r.iat)];case 1:s.sent(),this.acquiredIatSet.delete(r.iat),n.removeItemSync(o),te.default().unlock(r.iat),e.notifyWaiters(),s.label=2;case 2:return [2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,o=t,i=[],r=0;;){var s=o.keySync(r);if(null===s)break;i.push(s),r++;}for(var a=!1,c=0;c<i.length;c++){var u=i[c];if(u.includes(ne)){var l=o.getItemSync(u);if(null!==l){var d=JSON.parse(l);(void 0===d.timeRefreshed&&d.timeAcquired<n||void 0!==d.timeRefreshed&&d.timeRefreshed<n)&&(o.removeItemSync(u),a=!0);}}}a&&e.notifyWaiters();},e.waiters=void 0,e}(),ae=Y.default=se;class ce{async runWithLock(e,t,n){const o=new AbortController,i=setTimeout(()=>o.abort(),t);try{return await navigator.locks.request(e,{mode:"exclusive",signal:o.signal},async e=>{if(clearTimeout(i),!e)throw new Error("Lock not available");return await n()})}catch(e){if(clearTimeout(i),"AbortError"===(null==e?void 0:e.name))throw new I;throw e}}}class ue{constructor(){this.activeLocks=new Set,this.lock=new ae,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear();};}async runWithLock(e,t,n){let o=!1;for(let n=0;n<10&&!o;n++)o=await this.lock.acquireLock(e,t);if(!o)throw new I;this.activeLocks.add(e),1===this.activeLocks.size&&"undefined"!=typeof window&&window.addEventListener("pagehide",this.pagehideHandler);try{return await n()}finally{this.activeLocks.delete(e),await this.lock.releaseLock(e),0===this.activeLocks.size&&"undefined"!=typeof window&&window.removeEventListener("pagehide",this.pagehideHandler);}}}function le(){return "undefined"!=typeof navigator&&"function"==typeof(null===(e=navigator.locks)||void 0===e?void 0:e.request)?new ce:new ue;var e;}let de=null;const he=new TextEncoder,pe=new TextDecoder;function fe(e){return "string"==typeof e?he.encode(e):pe.decode(e)}function me(e){if("number"!=typeof e.modulusLength||e.modulusLength<2048)throw new be(`${e.name} modulusLength must be at least 2048 bits`)}async function ye(e,t,n){if(!1===n.usages.includes("sign"))throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');const o=`${ge(fe(JSON.stringify(e)))}.${ge(fe(JSON.stringify(t)))}`;return `${o}.${ge(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return {name:e.algorithm.name,hash:"SHA-256"};case"RSA-PSS":return me(e.algorithm),{name:e.algorithm.name,saltLength:32};case"RSASSA-PKCS1-v1_5":return me(e.algorithm),{name:e.algorithm.name};case"Ed25519":return {name:e.algorithm.name}}throw new ve}(n),n,fe(o)))}`}let we;if(Uint8Array.prototype.toBase64)we=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0}));else {const e=32768;we=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));const n=[];for(let o=0;o<t.byteLength;o+=e)n.push(String.fromCharCode.apply(null,t.subarray(o,o+e)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};}function ge(e){return we(e)}class ve extends Error{constructor(e){var t;super(null!=e?e:"operation not supported"),this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor);}}class be extends Error{constructor(e){var t;super(e),this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor);}}function _e(e){switch(e.algorithm.name){case"RSA-PSS":return function(e){if("SHA-256"===e.algorithm.hash.name)return "PS256";throw new ve("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"RSASSA-PKCS1-v1_5":return function(e){if("SHA-256"===e.algorithm.hash.name)return "RS256";throw new ve("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"ECDSA":return function(e){if("P-256"===e.algorithm.namedCurve)return "ES256";throw new ve("unsupported EcKeyAlgorithm namedCurve")}(e);case"Ed25519":return "Ed25519";default:throw new ve("unsupported CryptoKey algorithm name")}}function ke(e){return e instanceof CryptoKey}function Se(e){return ke(e)&&"public"===e.type}async function Te(e,t,n,o,i,r){const s=null==e?void 0:e.privateKey,a=null==e?void 0:e.publicKey;if(!ke(c=s)||"private"!==c.type)throw new TypeError('"keypair.privateKey" must be a private CryptoKey');var c;if(!Se(a))throw new TypeError('"keypair.publicKey" must be a public CryptoKey');if(!0!==a.extractable)throw new TypeError('"keypair.publicKey.extractable" must be true');if("string"!=typeof t)throw new TypeError('"htu" must be a string');if("string"!=typeof n)throw new TypeError('"htm" must be a string');if(void 0!==o&&"string"!=typeof o)throw new TypeError('"nonce" must be a string or undefined');if(void 0!==i&&"string"!=typeof i)throw new TypeError('"accessToken" must be a string or undefined');if(void 0!==r&&("object"!=typeof r||null===r||Array.isArray(r)))throw new TypeError('"additional" must be an object');const u=Object.assign(Object.create(null),r,{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:o,htu:t,ath:i?ge(await crypto.subtle.digest("SHA-256",fe(i))):void 0});return ye({alg:_e(s),typ:"dpop+jwt",jwk:await Pe(a)},u,s)}async function Pe(e){const{kty:t,e:n,n:o,x:i,y:r,crv:s}=await crypto.subtle.exportKey("jwk",e);return {kty:t,crv:s,e:n,n:o,x:i,y:r}}const Ee="dpop-nonce",Re=["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:token-exchange","urn:okta:params:oauth:grant-type:webauthn","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 Ce(){return async function(e,t){var n;let o;if("string"!=typeof e||0===e.length)throw new TypeError('"alg" must be a non-empty string');switch(e){case"PS256":o={name:"RSA-PSS",hash:"SHA-256",modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case"RS256":o={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case"ES256":o={name:"ECDSA",namedCurve:"P-256"};break;case"Ed25519":o={name:"Ed25519"};break;default:throw new ve}return crypto.subtle.generateKey(o,null!==(n=null==t?void 0:t.extractable)&&void 0!==n&&n,["sign","verify"])}("ES256",{extractable:!1})}function xe(e){return async function(e){if(!Se(e))throw new TypeError('"publicKey" must be a public CryptoKey');if(!0!==e.extractable)throw new TypeError('"publicKey.extractable" must be true');const t=await Pe(e);let 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 ve("unsupported JWK kty")}return ge(await crypto.subtle.digest({name:"SHA-256"},fe(JSON.stringify(n))))}(e.publicKey)}function Ie(e){let t=e.keyPair,n=e.url,o=e.method,i=e.nonce,r=e.accessToken;const s=function(e){const t=new URL(e);return t.search="",t.hash="",t.href}(n);return Te(t,s,o,i,r)}const Ae=(e,t)=>new Promise(function(n,o){const i=new MessageChannel;i.port1.onmessage=function(e){e.data.error?o(new Error(e.data.error)):n(e.data),i.port1.close();},t.postMessage(e,[i.port2]);}),Oe=(e,t,n)=>{const o=new AbortController;let i;return t.signal=o.signal,Promise.race([fetch(e,t),new Promise((e,t)=>{i=setTimeout(()=>{o.abort(),t(new Error("Timeout when executing 'fetch'"));},n);})]).finally(()=>{clearTimeout(i);})},je=async function(e,t,n,o,i,r){let s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:b;return i?(async(e,t,n,o,i,r,s,a,c,u)=>Ae({type:"refresh",auth:{audience:t,scope:n},timeout:i,fetchUrl:e,fetchOptions:o,useFormData:s,useMrrt:a,skipTokenStorage:c,preserveRefreshToken:u},r))(e,t,n,o,s,i,r,arguments.length>7?arguments[7]:void 0,arguments.length>8?arguments[8]:void 0,arguments.length>9?arguments[9]:void 0):(async(e,t,n)=>{const o=await Oe(e,t,n);return {ok:o.ok,json:await o.json(),headers:(i=o.headers,[...i].reduce((e,t)=>{let n=y(t,2),o=n[0],i=n[1];return e[o]=i,e},{}))};var i;})(e,o,s)};async function We(t,n,o,i,r,s,a,c,u,l,d,h){if(u){const e=await u.generateProof({url:t,method:r.method||"GET",nonce:await u.getNonce()});r.headers=Object.assign(Object.assign({},r.headers),{dpop:e});}let p,f=null;for(let e=0;e<3;e++)try{p=await je(t,o,i,r,s,a,n,c,d,h),f=null;break}catch(e){f=e;}if(f)throw f;const m=p.json,y=m.error,w=m.error_description,g=e(m,["error","error_description"]),v=p,b=v.headers,_=v.ok;let k;if(u&&(k=b[Ee],k&&await u.setNonce(k)),!_){const e=w||"HTTP error. Unable to fetch ".concat(t);if("mfa_required"===y)throw new W(y,e,g.mfa_token,g.mfa_requirements);if("missing_refresh_token"===y)throw new N(o,i);if("use_dpop_nonce"===y){if(!u||!k||l)throw new K(k);return We(t,n,o,i,r,s,a,c,u,!0,d,h)}throw new E(y||"request_error",e)}return g}async function Ne(t,n,o){var i=t.baseUrl,r=t.timeout,s=t.audience,a=t.scope,c=t.auth0Client,u=t.useFormData,l=t.useMrrt,d=t.dpop,h=t.preserveRefreshToken,p=e(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData","useMrrt","dpop","preserveRefreshToken"]);const f="urn:ietf:params:oauth:grant-type:token-exchange"===p.grant_type,m="urn:okta:params:oauth:grant-type:webauthn"===p.grant_type,y="refresh_token"===p.grant_type&&l,w=f||m||y,g=Object.assign(Object.assign(Object.assign({},p),w&&s&&{audience:s}),w&&a&&{scope:a}),v=m||!u,b=v?JSON.stringify(g):H(g),_=(k=p.grant_type,Re.includes(k));var k;return await We("".concat(i,"/oauth/token"),r,s||P,a,{method:"POST",body:b,headers:{"Content-Type":v?"application/json":"application/x-www-form-urlencoded","Auth0-Client":btoa(JSON.stringify(Z(c||S)))}},n,u,l,_?d:void 0,void 0,o,h)}const Ue=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return (o=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(o))).join(" ");var o;},Ke=(e,t,n)=>{let o;return n&&(o=e[n]),o||(o=e[P]),Ue(o,t)},Le="@@auth0spajs@@",Me="@@user@@";class ze{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Le,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(e){const t=y(e.split("::"),4),n=t[0],o=t[1],i=t[2],r=t[3];return new ze({clientId:o,scope:r,audience:i},n)}static fromCacheEntry(e){const t=e.scope,n=e.audience,o=e.client_id;return new ze({scope:t,audience:n,clientId:o})}}class Je{set(e,t){localStorage.setItem(e,JSON.stringify(t));}get(e){const t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(e){return}}remove(e){localStorage.removeItem(e);}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith(Le))}}class De{constructor(){this.enclosedCache=function(){let e={};return {set(t,n){e[t]=n;},get(t){const n=e[t];if(n)return n},remove(t){delete e[t];},allKeys:()=>Object.keys(e)}}();}}class Ze{constructor(e,t,n){this.cache=e,this.keyManifest=t,this.nowProvider=n||T;}async setIdToken(e,t,n){var o;const i=this.getIdTokenCacheKey(e);await this.cache.set(i,{id_token:t,decodedToken:n}),await(null===(o=this.keyManifest)||void 0===o?void 0:o.add(i));}async getIdToken(e){const t=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!t&&e.scope&&e.audience){const t=await this.get(e);if(!t)return;if(!t.id_token||!t.decodedToken)return;return {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&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3?arguments[3]:void 0;var i;let r=await this.cache.get(e.toKey()),s=e;if(!r){const t=await this.getCacheKeys();if(!t)return;const i=this.matchExistingCacheKey(e,t);if(i&&(r=await this.cache.get(i),s=ze.fromKey(i)),!r&&n&&"cache-only"!==o)return this.getEntryWithRefreshToken(e,t)}if(!r)return;const a=await this.nowProvider(),c=Math.floor(a/1e3);return r.expiresAt-t<c?r.body.refresh_token?this.modifiedCachedEntry(r,s):(await this.cache.remove(s.toKey()),void await(null===(i=this.keyManifest)||void 0===i?void 0:i.remove(s.toKey()))):r.body}async modifiedCachedEntry(e,t){const n={refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope},o={body:n,expiresAt:e.expiresAt};return await this.cache.set(t.toKey(),o),{refresh_token:n.refresh_token,audience:n.audience,scope:n.scope}}async set(e){var t;const n=new ze({clientId:e.client_id,scope:e.scope,audience:e.audience}),o=await this.wrapCacheEntry(e);await this.cache.set(n.toKey(),o),await(null===(t=this.keyManifest)||void 0===t?void 0:t.add(n.toKey()));}async remove(e,t,n){const o=new ze({clientId:e,scope:n,audience:t});await this.cache.remove(o.toKey());}async stripRefreshToken(e){var t;const n=await this.getCacheKeys();if(n)for(const o of n){const n=await this.cache.get(o);(null===(t=null==n?void 0:n.body)||void 0===t?void 0:t.refresh_token)===e&&(delete n.body.refresh_token,await this.cache.set(o,n));}}async clear(e){var t;const n=await this.getCacheKeys();n&&(await n.filter(t=>!e||t.includes(e)).reduce(async(e,t)=>{await e,await this.cache.remove(t);},Promise.resolve()),await(null===(t=this.keyManifest)||void 0===t?void 0:t.clear()));}async wrapCacheEntry(e){const t=await this.nowProvider();return {body:e,expiresAt:Math.floor(t/1e3)+e.expires_in}}async getCacheKeys(){var e;return this.keyManifest?null===(e=await this.keyManifest.get())||void 0===e?void 0:e.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new ze({clientId:e},Le,Me).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{var n;const o=ze.fromKey(t),i=new Set(o.scope&&o.scope.split(" ")),r=(null===(n=e.scope)||void 0===n?void 0:n.split(" "))||[],s=o.scope&&r.reduce((e,t)=>e&&i.has(t),!0);return o.prefix===Le&&o.clientId===e.clientId&&o.audience===e.audience&&s})[0]}async getEntryWithRefreshToken(e,t){var n;for(const o of t){const t=ze.fromKey(o);if(t.prefix===Le&&t.clientId===e.clientId){const e=await this.cache.get(o);if(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.refresh_token)return {refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope}}}}async getRefreshTokensByAudience(e,t){var n;const o=await this.getCacheKeys();if(!o)return [];const i=new Set;for(const r of o){const o=ze.fromKey(r);if(o.prefix===Le&&o.clientId===t&&o.audience===e){const e=await this.cache.get(r);(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.refresh_token)&&i.add(e.body.refresh_token);}}return Array.from(i)}async updateEntry(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=await this.getCacheKeys();if(i)for(const r of i){if(ze.fromKey(r).clientId!==n)continue;const i=await this.cache.get(r);if(!(null==i?void 0:i.body))continue;const s=i.body.refresh_token;s&&(o||s===e)&&(i.body.refresh_token=t,await this.cache.set(r,i));}}}class He{constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,this.storageKey="".concat("a0.spajs.txs",".").concat(this.clientId);}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain});}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain});}}const Fe=e=>"number"==typeof e,Ve=["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"],Xe=e=>{if(!e.id_token)throw new Error("ID token is required but missing");const t=(e=>{const t=e.split("."),n=y(t,3),o=n[0],i=n[1],r=n[2];if(3!==t.length||!o||!i||!r)throw new Error("ID token could not be decoded");const s=JSON.parse(V(i)),a={__raw:e},c={};return Object.keys(s).forEach(e=>{a[e]=s[e],Ve.includes(e)||(c[e]=s[e]);}),{encoded:{header:o,payload:i,signature:r},header:JSON.parse(V(o)),claims:a,user:c}})(e.id_token);if(!t.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(t.claims.iss!==e.iss)throw new Error('Issuer (iss) claim mismatch in the ID token; expected "'.concat(e.iss,'", found "').concat(t.claims.iss,'"'));if(!t.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if("RS256"!==t.header.alg)throw new Error('Signature algorithm of "'.concat(t.header.alg,'" is not supported. Expected the ID token to be signed with "RS256".'));if(!t.claims.aud||"string"!=typeof t.claims.aud&&!Array.isArray(t.claims.aud))throw new 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 new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but was not one of "').concat(t.claims.aud.join(", "),'"'));if(t.claims.aud.length>1){if(!t.claims.azp)throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");if(t.claims.azp!==e.aud)throw new Error('Authorized Party (azp) claim mismatch in the ID token; expected "'.concat(e.aud,'", found "').concat(t.claims.azp,'"'))}}else if(t.claims.aud!==e.aud)throw new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but found "').concat(t.claims.aud,'"'));if(e.nonce){if(!t.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(t.claims.nonce!==e.nonce)throw new Error('Nonce (nonce) claim mismatch in the ID token; expected "'.concat(e.nonce,'", found "').concat(t.claims.nonce,'"'))}if(e.max_age&&!Fe(t.claims.auth_time))throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");if(null==t.claims.exp||!Fe(t.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Fe(t.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const n=e.leeway||60,o=new Date(e.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(t.claims.exp+n),o>i)throw new Error("Expiration Time (exp) claim error in the ID token; current time (".concat(o,") is after expiration time (").concat(i,")"));if(null!=t.claims.nbf&&Fe(t.claims.nbf)){const e=new Date(0);if(e.setUTCSeconds(t.claims.nbf-n),o<e)throw new Error("Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (".concat(o,") is before ").concat(e))}if(null!=t.claims.auth_time&&Fe(t.claims.auth_time)){const i=new Date(0);if(i.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),o>i)throw new Error("Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (".concat(o,") is after last auth at ").concat(i))}if(e.organization){const n=e.organization.trim();if(n.startsWith("org_")){const e=n;if(!t.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(e!==t.claims.org_id)throw new Error('Organization ID (org_id) claim mismatch in the ID token; expected "'.concat(e,'", found "').concat(t.claims.org_id,'"'))}else {const e=n.toLowerCase();if(!t.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(e!==t.claims.org_name)throw new Error('Organization Name (org_name) claim mismatch in the ID token; expected "'.concat(e,'", found "').concat(t.claims.org_name,'"'))}}return t};var Ge=G&&G.__assign||function(){return Ge=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ge.apply(this,arguments)};function Ye(e,t){if(!t)return "";var n="; "+e;return !0===t?n:n+"="+t}function qe(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("number"==typeof e.expires){var t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t;}return Ye("Expires",e.expires?e.expires.toUTCString():"")+Ye("Domain",e.domain)+Ye("Path",e.path)+Ye("Secure",e.secure)+Ye("SameSite",e.sameSite)}(n)}function Be(){return function(e){for(var t={},n=e?e.split("; "):[],o=/(%[\dA-F]{2})+/gi,i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");'"'===s.charAt(0)&&(s=s.slice(1,-1));try{t[r[0].replace(o,decodeURIComponent)]=s.replace(o,decodeURIComponent);}catch(e){}}return t}(document.cookie)}var Qe=function(e){return Be()[e]};function $e(e,t,n){document.cookie=qe(e,t,Ge({path:"/"},n));}var et=$e;var tt=function(e,t){$e(e,"",Ge(Ge({},t),{expires:-1}));};const nt={get(e){const t=Qe(e);if(void 0!==t)return JSON.parse(t)},save(e,t,n){let o={};"https:"===window.location.protocol&&(o={secure:!0,sameSite:"none"}),(null==n?void 0:n.daysUntilExpire)&&(o.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(o.domain=n.cookieDomain),et(e,JSON.stringify(t),o);},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),tt(e,n);}},ot="_legacy_",it={get(e){const t=nt.get(e);return t||nt.get("".concat(ot).concat(e))},save(e,t,n){let o={};"https:"===window.location.protocol&&(o={secure:!0}),(null==n?void 0:n.daysUntilExpire)&&(o.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(o.domain=n.cookieDomain),et("".concat(ot).concat(e),JSON.stringify(t),o),nt.save(e,t,n);},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),tt(e,n),nt.remove(e,t),nt.remove("".concat(ot).concat(e),t);}},rt={get(e){if("undefined"==typeof sessionStorage)return;const t=sessionStorage.getItem(e);return null!=t?JSON.parse(t):void 0},save(e,t){sessionStorage.setItem(e,JSON.stringify(t));},remove(e){sessionStorage.removeItem(e);}},st={Offline:"offline",Online:"online"};exports.ResponseType = void 0;!function(e){e.Code="code",e.ConnectCode="connect_code";}(exports.ResponseType||(exports.ResponseType={}));class ct{}function ut(e,t,n){var o=void 0===t?null:t,i=function(e,t){var n=atob(e);if(t){for(var o=new Uint8Array(n.length),i=0,r=n.length;i<r;++i)o[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(o.buffer))}return n}(e,void 0!==n&&n),r=i.indexOf("\n",10)+1,s=i.substring(r)+(o?"//# sourceMappingURL="+o:""),a=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(a)}var lt,dt,ht,pt,ft=(lt="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7ZnVuY3Rpb24gZShlLHQpeyhudWxsPT10fHx0PmUubGVuZ3RoKSYmKHQ9ZS5sZW5ndGgpO2Zvcih2YXIgcj0wLG89QXJyYXkodCk7cjx0O3IrKylvW3JdPWVbcl07cmV0dXJuIG99ZnVuY3Rpb24gdCh0LHIpe3JldHVybiBmdW5jdGlvbihlKXtpZihBcnJheS5pc0FycmF5KGUpKXJldHVybiBlfSh0KXx8ZnVuY3Rpb24oZSx0KXt2YXIgcj1udWxsPT1lP251bGw6InVuZGVmaW5lZCIhPXR5cGVvZiBTeW1ib2wmJmVbU3ltYm9sLml0ZXJhdG9yXXx8ZVsiQEBpdGVyYXRvciJdO2lmKG51bGwhPXIpe3ZhciBvLG4scyxhLGk9W10sYz0hMCxsPSExO3RyeXtpZihzPShyPXIuY2FsbChlKSkubmV4dCwwPT09dCl7aWYoT2JqZWN0KHIpIT09cilyZXR1cm47Yz0hMX1lbHNlIGZvcig7IShjPShvPXMuY2FsbChyKSkuZG9uZSkmJihpLnB1c2goby52YWx1ZSksaS5sZW5ndGghPT10KTtjPSEwKTt9Y2F0Y2goZSl7bD0hMCxuPWV9ZmluYWxseXt0cnl7aWYoIWMmJm51bGwhPXIucmV0dXJuJiYoYT1yLnJldHVybigpLE9iamVjdChhKSE9PWEpKXJldHVybn1maW5hbGx5e2lmKGwpdGhyb3cgbn19cmV0dXJuIGl9fSh0LHIpfHxmdW5jdGlvbih0LHIpe2lmKHQpe2lmKCJzdHJpbmciPT10eXBlb2YgdClyZXR1cm4gZSh0LHIpO3ZhciBvPXt9LnRvU3RyaW5nLmNhbGwodCkuc2xpY2UoOCwtMSk7cmV0dXJuIk9iamVjdCI9PT1vJiZ0LmNvbnN0cnVjdG9yJiYobz10LmNvbnN0cnVjdG9yLm5hbWUpLCJNYXAiPT09b3x8IlNldCI9PT1vP0FycmF5LmZyb20odCk6IkFyZ3VtZW50cyI9PT1vfHwvXig/OlVpfEkpbnQoPzo4fDE2fDMyKSg/OkNsYW1wZWQpP0FycmF5JC8udGVzdChvKT9lKHQscik6dm9pZCAwfX0odCxyKXx8ZnVuY3Rpb24oKXt0aHJvdyBuZXcgVHlwZUVycm9yKCJJbnZhbGlkIGF0dGVtcHQgdG8gZGVzdHJ1Y3R1cmUgbm9uLWl0ZXJhYmxlIGluc3RhbmNlLlxuSW4gb3JkZXIgdG8gYmUgaXRlcmFibGUsIG5vbi1hcnJheSBvYmplY3RzIG11c3QgaGF2ZSBhIFtTeW1ib2wuaXRlcmF0b3JdKCkgbWV0aG9kLiIpfSgpfWNsYXNzIHIgZXh0ZW5kcyBFcnJvcntjb25zdHJ1Y3RvcihlLHQpe3N1cGVyKHQpLHRoaXMuZXJyb3I9ZSx0aGlzLmVycm9yX2Rlc2NyaXB0aW9uPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsci5wcm90b3R5cGUpfXN0YXRpYyBmcm9tUGF5bG9hZChlKXtsZXQgdD1lLmVycm9yLG89ZS5lcnJvcl9kZXNjcmlwdGlvbjtyZXR1cm4gbmV3IHIodCxvKX19Y2xhc3MgbyBleHRlbmRzIHJ7Y29uc3RydWN0b3IoZSx0KXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIiwiTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyIuY29uY2F0KG4oZSxbImRlZmF1bHQiXSksIicsIHNjb3BlOiAnIikuY29uY2F0KG4odCksIicpIikpLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsby5wcm90b3R5cGUpfX1mdW5jdGlvbiBuKGUpe3JldHVybiBlJiYhKGFyZ3VtZW50cy5sZW5ndGg+MSYmdm9pZCAwIT09YXJndW1lbnRzWzFdP2FyZ3VtZW50c1sxXTpbXSkuaW5jbHVkZXMoZSk/ZToiIn0iZnVuY3Rpb24iPT10eXBlb2YgU3VwcHJlc3NlZEVycm9yJiZTdXBwcmVzc2VkRXJyb3I7Y29uc3Qgcz1lPT57dmFyIHQ9ZS5jbGllbnRJZCxyPWZ1bmN0aW9uKGUsdCl7dmFyIHI9e307Zm9yKHZhciBvIGluIGUpT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKGUsbykmJnQuaW5kZXhPZihvKTwwJiYocltvXT1lW29dKTtpZihudWxsIT1lJiYiZnVuY3Rpb24iPT10eXBlb2YgT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scyl7dmFyIG49MDtmb3Iobz1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO248by5sZW5ndGg7bisrKXQuaW5kZXhPZihvW25dKTwwJiZPYmplY3QucHJvdG90eXBlLnByb3BlcnR5SXNFbnVtZXJhYmxlLmNhbGwoZSxvW25dKSYmKHJbb1tuXV09ZVtvW25dXSl9cmV0dXJuIHJ9KGUsWyJjbGllbnRJZCJdKTtyZXR1cm4gbmV3IFVSTFNlYXJjaFBhcmFtcygoZT0+T2JqZWN0LmtleXMoZSkuZmlsdGVyKHQ9PnZvaWQgMCE9PWVbdF0pLnJlZHVjZSgodCxyKT0+T2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHQpLHtbcl06ZVtyXX0pLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IGE9e30saT1udWxsO2NvbnN0IGM9KGUsdCk9PiIiLmNvbmNhdChlLCJ8IikuY29uY2F0KHQpLGw9KGUsdCk9PnQuc3RhcnRzV2l0aCgiIi5jb25jYXQoZSwifCIpKSx1PShlLHQpPT5hW2MoZSx0KV0sZj1lPT57T2JqZWN0LmVudHJpZXMoYSkuZm9yRWFjaChyPT57bGV0IG89dChyLDIpLG49b1swXTtvWzFdPT09ZSYmZGVsZXRlIGFbbl19KX0saD1lPT57Y29uc3QgdD1uZXcgVVJMU2VhcmNoUGFyYW1zKGUpLHI9e307cmV0dXJuIHQuZm9yRWFjaCgoZSx0KT0+e3JbdF09ZX0pLHJ9LGQ9YXN5bmMgZT0+e2xldCByLG4saT1lLmRhdGEsZj1pLnRpbWVvdXQsZD1pLmF1dGgscD1pLmZldGNoVXJsLHk9aS5mZXRjaE9wdGlvbnMsZz1pLnVzZUZvcm1EYXRhLGI9aS51c2VNcnJ0LE89aS5za2lwVG9rZW5TdG9yYWdlLGs9aS5wcmVzZXJ2ZVJlZnJlc2hUb2tlbixtPXQoZS5wb3J0cywxKVswXSxqPXt9O2NvbnN0IHY9ZHx8e30sXz12LmF1ZGllbmNlLHc9di5zY29wZTt0cnl7Y29uc3QgZT1nP2goeS5ib2R5KTpKU09OLnBhcnNlKHkuYm9keSk7aWYoZS5yZWZyZXNoX3Rva2VufHwicmVmcmVzaF90b2tlbiIhPT1lLmdyYW50X3R5cGUpZS5tZmFfdG9rZW4mJihuPXUoXyx3KSwhbiYmYiYmKG49YS5sYXRlc3RfcmVmcmVzaF90b2tlbikpO2Vsc2V7aWYobj11KF8sdyksIW4mJmIpe2NvbnN0IGU9YS5sYXRlc3RfcmVmcmVzaF90b2tlbix0PSgoZSx0KT0+ISFPYmplY3Qua2V5cyhhKS5maW5kKHI9PntpZigibGF0ZXN0X3JlZnJlc2hfdG9rZW4iIT09cil7Y29uc3Qgbz1sKHQsciksbj1yLnNwbGl0KCJ8IilbMV0uc3BsaXQoIiAiKSxzPWUuc3BsaXQoIiAiKS5ldmVyeShlPT5uLmluY2x1ZGVzKGUpKTtyZXR1cm4gbyYmc319KSkodyxfKTtlJiYhdCYmKG49ZSl9aWYoIW4pdGhyb3cgbmV3IG8oXyx3KTt5LmJvZHk9Zz9zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpufSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpufSkpfWxldCBpLGQ7ImZ1bmN0aW9uIj09dHlwZW9mIEFib3J0Q29udHJvbGxlciYmKGk9bmV3IEFib3J0Q29udHJvbGxlcix5LnNpZ25hbD1pLnNpZ25hbCk7dHJ5e2Q9YXdhaXQgUHJvbWlzZS5yYWNlKFsoUD1mLG5ldyBQcm9taXNlKGU9PnNldFRpbWVvdXQoZSxQKSkpLGZldGNoKHAsT2JqZWN0LmFzc2lnbih7fSx5KSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBtLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZClyZXR1cm4gaSYmaS5hYm9ydCgpLHZvaWQgbS5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtpZihVPWQuaGVhZGVycyxqPVsuLi5VXS5yZWR1Y2UoKGUscik9PntsZXQgbz10KHIsMiksbj1vWzBdLHM9b1sxXTtyZXR1cm4gZVtuXT1zLGV9LHt9KSxyPWF3YWl0IGQuanNvbigpLE8pcmV0dXJuIGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4sdm9pZCBtLnBvc3RNZXNzYWdlKHtvazpkLm9rLGpzb246cixoZWFkZXJzOmp9KTtyLnJlZnJlc2hfdG9rZW4/KGImJihhLmxhdGVzdF9yZWZyZXNoX3Rva2VuPXIucmVmcmVzaF90b2tlbixTPW4sTT1yLnJlZnJlc2hfdG9rZW4sT2JqZWN0LmVudHJpZXMoYSkuZm9yRWFjaChlPT57bGV0IHI9dChlLDIpLG89clswXTtyWzFdPT09UyYmKGFbb109TSl9KSksKChlLHQscik9PnthW2ModCxyKV09ZX0pKHIucmVmcmVzaF90b2tlbixfLHcpLGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4pOmt8fCgoZSx0KT0+e2RlbGV0ZSBhW2MoZSx0KV19KShfLHcpLG0ucG9zdE1lc3NhZ2Uoe29rOmQub2ssanNvbjpyLGhlYWRlcnM6an0pfWNhdGNoKGUpe20ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOmUuZXJyb3IsZXJyb3JfZGVzY3JpcHRpb246ZS5tZXNzYWdlfSxoZWFkZXJzOmp9KX12YXIgUyxNLFUsUH0scD1hc3luYyBlPT57bGV0IHI9ZS5kYXRhLG89ci50aW1lb3V0LG49ci5hdXRoLGk9ci5mZXRjaFVybCxjPXIuZmV0Y2hPcHRpb25zLHU9ci51c2VGb3JtRGF0YSxkPXQoZS5wb3J0cywxKVswXTtjb25zdCBwPShufHx7fSkuYXVkaWVuY2U7dHJ5e2NvbnN0IGU9KGU9Pntjb25zdCByPW5ldyBTZXQ7cmV0dXJuIE9iamVjdC5lbnRyaWVzKGEpLmZvckVhY2gobz0+e2xldCBuPXQobywyKSxzPW5bMF0sYT1uWzFdO2woZSxzKSYmci5hZGQoYSl9KSxBcnJheS5mcm9tKHIpfSkocCk7aWYoMD09PWUubGVuZ3RoKXJldHVybiB2b2lkIGQucG9zdE1lc3NhZ2Uoe29rOiEwfSk7Y29uc3Qgcj11P2goYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7Zm9yKGNvbnN0IHQgb2YgZSl7Y29uc3QgZT11P3MoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHIpLHt0b2tlbjp0fSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxyKSx7dG9rZW46dH0pKTtsZXQgbixhLGwsaDsiZnVuY3Rpb24iPT10eXBlb2YgQWJvcnRDb250cm9sbGVyJiYobj1uZXcgQWJvcnRDb250cm9sbGVyLGE9bi5zaWduYWwpO3RyeXtoPWF3YWl0IFByb21pc2UucmFjZShbbmV3IFByb21pc2UoZT0+e2w9c2V0VGltZW91dChlLG8pfSksZmV0Y2goaSxPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sYykse2JvZHk6ZSxzaWduYWw6YX0pKV0pLmZpbmFsbHkoKCk9PmNsZWFyVGltZW91dChsKSl9Y2F0Y2goZSl7cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZS5tZXNzYWdlfSl9aWYoIWgpcmV0dXJuIG4mJm4uYWJvcnQoKSx2b2lkIGQucG9zdE1lc3NhZ2Uoe2Vycm9yOiJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCcifSk7aWYoIWgub2spe2xldCBlO3RyeXtjb25zdCB0PUpTT04ucGFyc2UoYXdhaXQgaC50ZXh0KCkpO2U9dC5lcnJvcl9kZXNjcmlwdGlvbn1jYXRjaChlKXt9cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZXx8IkhUVFAgZXJyb3IgIi5jb25jYXQoaC5zdGF0dXMpfSl9Zih0KX1kLnBvc3RNZXNzYWdlKHtvazohMH0pfWNhdGNoKGUpe2QucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZXx8IlVua25vd24gZXJyb3IgZHVyaW5nIHRva2VuIHJldm9jYXRpb24ifSl9fSx5PShlLHQpPT57aWYoIWkpcmV0dXJuITE7dHJ5e2NvbnN0IHI9bmV3IFVSTChpKS5vcmlnaW4sbz1uZXcgVVJMKGUuZmV0Y2hVcmwpO3JldHVybiBvLm9yaWdpbj09PXImJm8ucGF0aG5hbWU9PT10fWNhdGNoKGUpe3JldHVybiExfX07YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZT0+e2NvbnN0IHI9ZS5kYXRhLG89dChlLnBvcnRzLDEpWzBdO2lmKCEoInR5cGUiaW4gcil8fCJpbml0IiE9PXIudHlwZSlyZXR1cm4idHlwZSJpbiByJiYiY2xlYXIiPT09ci50eXBlPyhhPXt9LHZvaWQobnVsbD09b3x8by5wb3N0TWVzc2FnZSh7b2s6ITB9KSkpOiJ0eXBlImluIHImJiJyZXZva2UiPT09ci50eXBlP3kociwiL29hdXRoL3Jldm9rZSIpP3ZvaWQgcChlKTp2b2lkKG51bGw9PW98fG8ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSkpOnZvaWQoImZldGNoVXJsImluIHImJnkociwiL29hdXRoL3Rva2VuIik/ZChlKTpudWxsPT1vfHxvLnBvc3RNZXNzYWdlKHtvazohMSxqc29uOntlcnJvcjoiaW52YWxpZF9mZXRjaF91cmwiLGVycm9yX2Rlc2NyaXB0aW9uOiJVbmF1dGhvcml6ZWQgZmV0Y2ggVVJMIn0saGVhZGVyczp7fX0pKTtpZihudWxsPT09aSl0cnl7bmV3IFVSTChyLmFsbG93ZWRCYXNlVXJsKSxpPXIuYWxsb3dlZEJhc2VVcmx9Y2F0Y2goZSl7cmV0dXJufX0pfSgpOwoK",dt=null,ht=!1,function(e){return pt=pt||ut(lt,dt,ht),new Worker(pt,e)});class mt{constructor(e,t){this.cache=e,this.clientId=t,this.manifestKey=this.createManifestKeyFrom(this.clientId);}async add(e){var t;const n=new Set((null===(t=await this.cache.get(this.manifestKey))||void 0===t?void 0:t.keys)||[]);n.add(e),await this.cache.set(this.manifestKey,{keys:[...n]});}async remove(e){const t=await this.cache.get(this.manifestKey);if(t){const 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 "".concat(Le,"::").concat(e)}}const yt="auth0.is.authenticated",wt={memory:()=>(new De).enclosedCache,localstorage:()=>new Je},gt=e=>wt[e],vt=t=>{const n=t.openUrl,o=t.onRedirect,i=e(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},i),{openUrl:!1===n||n?n:o})},bt=(e,t,n)=>{const o=(null==e?void 0:e.split(" "))||[],i=n?o.filter(e=>e!==k):o;const r=(null==t?void 0:t.split(" "))||[];return i.filter(e=>-1==r.indexOf(e)).join(",")},_t={NONCE:"nonce",KEYPAIR:"keypair"};class kt{constructor(e){this.clientId=e;}getVersion(){return 1}createDbHandle(){const 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||(this.dbHandle=await this.createDbHandle()),this.dbHandle}async executeDbRequest(e,t,n){const o=n((await this.getDbHandle()).transaction(e,t).objectStore(e));return new Promise((e,t)=>{o.onsuccess=()=>e(o.result),o.onerror=()=>t(o.error);})}buildKey(e){const t=e?"_".concat(e):"auth0";return "".concat(this.clientId,"::").concat(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){const n=await this.executeDbRequest(e,"readonly",e=>e.getAllKeys());await Promise.all((null==n?void 0:n.filter(t).map(t=>this.executeDbRequest(e,"readwrite",e=>e.delete(t))))||[]);}deleteByClientId(e,t){return this.deleteBy(e,e=>"string"==typeof e&&e.startsWith("".concat(t,"::")))}clearNonces(){return this.deleteByClientId(_t.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(_t.KEYPAIR,this.clientId)}}class St{constructor(e){this.storage=new kt(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 Ce(),await this.storage.setKeyPair(e)),e}async generateProof(e){const t=await this.getOrGenerateKeyPair();return Ie(Object.assign({keyPair:t},e))}async calculateThumbprint(){return xe(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()]);}}var Tt;!function(e){e.Bearer="Bearer",e.DPoP="DPoP";}(Tt||(Tt={}));class Pt{constructor(e,t){this.hooks=t,this.config=Object.assign(Object.assign({},e),{fetch:e.fetch||("undefined"==typeof window?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 "".concat(e.replace(/\/?\/$/,""),"/").concat(t.replace(/^\/+/,""))}throw new 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 "string"==typeof e?e:e instanceof URL?e.href:e.url}buildBaseRequest(e,t){if(!this.config.baseUrl)return new Request(e,t);const n=this.buildUrl(this.config.baseUrl,this.extractUrl(e)),o=e instanceof Request?new Request(n,e):n;return new Request(o,t)}setAuthorizationHeader(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Tt.Bearer;e.headers.set("authorization","".concat(n," ").concat(t));}async setDpopProofHeader(e,t){if(!this.config.dpopNonceId)return;const n=await this.hooks.getDpopNonce(),o=await this.hooks.generateDpopProof({accessToken:t,method:e.method,nonce:n,url:e.url});e.headers.set("dpop",o);}async prepareRequest(e,t){const n=await this.getAccessToken(t);if(void 0===n)throw new E("missing_access_token","No access token available");let o,i;"string"==typeof n?(o=this.config.dpopNonceId?Tt.DPoP:Tt.Bearer,i=n):(o=n.token_type,i=n.access_token),this.setAuthorizationHeader(e,i,o),o===Tt.DPoP&&await this.setDpopProofHeader(e,i);}getHeader(e,t){return Array.isArray(e)?new Headers(e).get(t)||"":"function"==typeof e.get?e.get(t)||"":e[t]||""}hasUseDpopNonceError(e){if(401!==e.status)return !1;const t=this.getHeader(e.headers,"www-authenticate");return t.includes("invalid_dpop_nonce")||t.includes("use_dpop_nonce")}async handleResponse(e,t){const n=this.getHeader(e.headers,Ee);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new K(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,o){const i=this.buildBaseRequest(e,t);await this.prepareRequest(i,o);const r=await this.config.fetch(i);return this.handleResponse(r,n)}fetchWithAuth(e,t,n){const o={onUseDpopNonceError:()=>this.internalFetchWithAuth(e,t,Object.assign(Object.assign({},o),{onUseDpopNonceError:void 0}),n)};return this.internalFetchWithAuth(e,t,o,n)}}class Et{constructor(e,t){this.myAccountFetcher=e,this.apiBase=t;}async connectAccount(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/connected-accounts/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:connected_accounts"]});return this._handleResponse(t)}async completeAccount(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/connected-accounts/complete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:connected_accounts"]});return this._handleResponse(t)}async getFactors(){const e=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/factors"),{method:"GET"},{scope:["read:me:factors"]});return (await this._handleResponse(e)).factors}async getAuthenticationMethods(e){const t=e?"?".concat(new URLSearchParams({type:e})):"",n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods").concat(t),{method:"GET"},{scope:["read:me:authentication_methods"]});return (await this._handleResponse(n)).authentication_methods}async getAuthenticationMethod(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"GET"},{scope:["read:me:authentication_methods"]});return this._handleResponse(t)}async deleteAuthenticationMethod(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"DELETE"},{scope:["delete:me:authentication_methods"]});t.ok||await this._handleResponse(t);}async updateAuthenticationMethod(e,t){const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},{scope:["update:me:authentication_methods"]});return this._handleResponse(n)}async enrollmentChallenge(e){var t;const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:authentication_methods"]}),o=await this._handleResponse(n),i=null!==(t=n.headers.get("location"))&&void 0!==t?t:"",r=decodeURIComponent(i.split("/").pop()||"");return Object.assign(Object.assign({},o),{id:r,location:i})}async enrollmentVerify(t){const n=t,o=n.location;n.type;const i=e(n,["location","type"]),r=await this.myAccountFetcher.fetchWithAuth("".concat(o,"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)},{scope:["create:me:authentication_methods"]});return this._handleResponse(r)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t);}catch(n){throw new Rt({type:"invalid_json",status:e.status,title:"Invalid JSON response",detail:t||String(n)})}if(e.ok)return t;throw new Rt(t)}}class Rt extends Error{constructor(e){let t=e.type,n=e.status,o=e.title,i=e.detail,r=e.validation_errors;super(i),this.name="MyAccountApiError",this.type=t,this.status=n,this.title=o,this.detail=i,this.validation_errors=r,Object.setPrototypeOf(this,Rt.prototype);}}const Ct={otp:{authenticatorTypes:["otp"]},sms:{authenticatorTypes:["oob"],oobChannels:["sms"]},email:{authenticatorTypes:["oob"],oobChannels:["email"]},push:{authenticatorTypes:["oob"],oobChannels:["auth0"]},voice:{authenticatorTypes:["oob"],oobChannels:["voice"]}},xt="http://auth0.com/oauth/grant-type/mfa-otp",It="http://auth0.com/oauth/grant-type/mfa-oob",At="http://auth0.com/oauth/grant-type/mfa-recovery-code";var Ot,jt;let Wt;if("undefined"==typeof navigator||null===(Ot=navigator.userAgent)||void 0===Ot||null===(jt=Ot.startsWith)||void 0===jt||!jt.call(Ot,"Mozilla/5.0 ")){const e="v3.8.6";Wt="".concat("oauth4webapi","/").concat(e);}function Nt(e,t){if(null==e)return !1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch(e){return !1}}const Ut="ERR_INVALID_ARG_VALUE",Kt="ERR_INVALID_ARG_TYPE";function Lt(e,t,n){const o=new TypeError(e,{cause:n});return Object.assign(o,{code:t}),o}const Mt=Symbol(),zt=Symbol(),Jt=Symbol(),Dt=Symbol(),Zt=Symbol(),Ht=Symbol(),Ft=new TextEncoder,Vt=new TextDecoder;function Xt(e){return "string"==typeof e?Ft.encode(e):Vt.decode(e)}let Gt,Yt;if(Uint8Array.prototype.toBase64)Gt=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0}));else {const e=32768;Gt=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));const n=[];for(let o=0;o<t.byteLength;o+=e)n.push(String.fromCharCode.apply(null,t.subarray(o,o+e)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};}function qt(e){return "string"==typeof e?Yt(e):Gt(e)}Yt=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(e){throw Lt("The input to be decoded is not correctly encoded.",Ut,e)}}:e=>{try{const 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 Lt("The input to be decoded is not correctly encoded.",Ut,e)}};class Bt extends Error{constructor(e,t){var n;super(e,t),h(this,"code",void 0),this.name=this.constructor.name,this.code=ro,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}class Qt extends Error{constructor(e,t){var n;super(e,t),h(this,"code",void 0),this.name=this.constructor.name,null!=t&&t.code&&(this.code=null==t?void 0:t.code),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}function $t(e,t,n){return new Qt(e,{code:t,cause:n})}function en(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw Lt("".concat(t," must be a CryptoKey"),Kt)}(e,t),"private"!==e.type)throw Lt("".concat(t," must be a private CryptoKey"),Ut)}function tn(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function nn(e){Nt(e,Headers)&&(e=Object.fromEntries(e.entries()));const t=new Headers(null!=e?e:{});if(Wt&&!t.has("user-agent")&&t.set("user-agent",Wt),t.has("authorization"))throw Lt('"options.headers" must not include the "authorization" header name',Ut);return t}function on(e,t){if(void 0!==t){if("function"==typeof t&&(t=t(e.href)),!(t instanceof AbortSignal))throw Lt('"options.signal" must return or be an instance of AbortSignal',Kt);return t}}function rn(e){return e.includes("//")?e.replace("//","/"):e}async function sn(e,t){return async function(e,t,n,o){if(!(e instanceof URL))throw Lt('"'.concat(t,'" must be an instance of URL'),Kt);bn(e,!0!==(null==o?void 0:o[Mt]));const i=n(new URL(e.href)),r=nn(null==o?void 0:o.headers);return r.set("accept","application/json"),((null==o?void 0:o[Dt])||fetch)(i.href,{body:void 0,headers:Object.fromEntries(r.entries()),method:"GET",redirect:"manual",signal:on(i,null==o?void 0:o.signal)})}(e,"issuerIdentifier",e=>{switch(null==t?void 0:t.algorithm){case void 0:case"oidc":!function(e,t){e.pathname=rn("".concat(e.pathname,"/").concat(t));}(e,".well-known/openid-configuration");break;case"oauth2":!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];"/"===e.pathname?e.pathname=t:e.pathname=rn("".concat(t,"/").concat(n?e.pathname:e.pathname.replace(/(\/)$/,"")));}(e,".well-known/oauth-authorization-server");break;default:throw Lt('"options.algorithm" must be "oidc" (default), or "oauth2"',Ut)}return e},t)}function an(e,t,n,o,i){try{if("number"!=typeof e||!Number.isFinite(e))throw Lt("".concat(n," must be a number"),Kt,i);if(e>0)return;if(t){if(0!==e)throw Lt("".concat(n," must be a non-negative number"),Ut,i);return}throw Lt("".concat(n," must be a positive number"),Ut,i)}catch(e){if(o)throw $t(e.message,o,i);throw e}}function cn(e,t,n,o){try{if("string"!=typeof e)throw Lt("".concat(t," must be a string"),Kt,o);if(0===e.length)throw Lt("".concat(t," must not be empty"),Ut,o)}catch(e){if(n)throw $t(e.message,n,o);throw e}}function un(e){!function(e,t){if(Kn(e)!==t)throw function(e){let t='"response" content-type must be ';for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];if(o.length>2){const e=o.pop();t+="".concat(o.join(", "),", or ").concat(e);}else 2===o.length?t+="".concat(o[0]," or ").concat(o[1]):t+=o[0];return $t(t,lo,e)}(e,t)}(e,"application/json");}function ln(){return qt(crypto.getRandomValues(new Uint8Array(32)))}function dn(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 Bt("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 Bt("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 Bt("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 Bt("unsupported CryptoKey algorithm name",{cause:e})}}function hn(e){const t=null==e?void 0:e[zt];return "number"==typeof t&&Number.isFinite(t)?t:0}function pn(e){const t=null==e?void 0:e[Jt];return "number"==typeof t&&Number.isFinite(t)&&-1!==Math.sign(t)?t:30}function fn(){return Math.floor(Date.now()/1e3)}function mn(e){if("object"!=typeof e||null===e)throw Lt('"as" must be an object',Kt);cn(e.issuer,'"as.issuer"');}function yn(e){if("object"!=typeof e||null===e)throw Lt('"client" must be an object',Kt);cn(e.client_id,'"client.client_id"');}function wn(e){return cn(e,'"clientSecret"'),(t,n,o,i)=>{o.set("client_id",n.client_id),o.set("client_secret",e);}}function gn(e,t){const n=(r=e)instanceof CryptoKey?{key:r}:(null==r?void 0:r.key)instanceof CryptoKey?(void 0!==r.kid&&cn(r.kid,'"kid"'),{key:r.key,kid:r.kid}):{},o=n.key,i=n.kid;var r;return en(o,'"clientPrivateKey.key"'),async(e,n,r,s)=>{var a;const c={alg:dn(o),kid:i},u=function(e,t){const n=fn()+hn(t);return {jti:ln(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,n);null==t||null===(a=t[Zt])||void 0===a||a.call(t,c,u),r.set("client_id",n.client_id),r.set("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),r.set("client_assertion",await async function(e,t,n){if(!n.usages.includes("sign"))throw Lt('CryptoKey instances used for signing assertions must include "sign" in their "usages"',Ut);const o="".concat(qt(Xt(JSON.stringify(e))),".").concat(qt(Xt(JSON.stringify(t)))),i=qt(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return {name:e.algorithm.name,hash:So(e)};case"RSA-PSS":switch(ko(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 Bt("unsupported RSA-PSS hash name",{cause:e})}case"RSASSA-PKCS1-v1_5":return ko(e),e.algorithm.name;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":case"Ed25519":return e.algorithm.name}throw new Bt("unsupported CryptoKey algorithm name",{cause:e})}(n),n,Xt(o)));return "".concat(o,".").concat(i)}(c,u,o));}}const vn=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch(e){return null}};function bn(e,t){if(t&&"https:"!==e.protocol)throw $t("only requests to HTTPS are allowed",po,e);if("https:"!==e.protocol&&"http:"!==e.protocol)throw $t("only HTTP and HTTPS requests are allowed",fo,e)}function _n(e,t,n,o){let i;if("string"!=typeof e||!(i=vn(e)))throw $t("authorization server metadata does not contain a valid ".concat(n?'"as.mtls_endpoint_aliases.'.concat(t,'"'):'"as.'.concat(t,'"')),void 0===e?go:vo,{attribute:n?"mtls_endpoint_aliases.".concat(t):t});return bn(i,o),i}function kn(e,t,n,o){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?_n(e.mtls_endpoint_aliases[t],t,n,o):_n(e[t],t,n,o)}class Sn extends Error{constructor(e,t){var n;super(e,t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"error",void 0),h(this,"status",void 0),h(this,"error_description",void 0),h(this,"response",void 0),this.name=this.constructor.name,this.code=io,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}),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}class Tn extends Error{constructor(e,t){var n,o;super(e,t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"error",void 0),h(this,"error_description",void 0),this.name=this.constructor.name,this.code=so,this.cause=t.cause,this.error=t.cause.get("error"),this.error_description=null!==(n=t.cause.get("error_description"))&&void 0!==n?n:void 0,null===(o=Error.captureStackTrace)||void 0===o||o.call(Error,this,this.constructor);}}class Pn extends Error{constructor(e,t){var n;super(e,t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"response",void 0),h(this,"status",void 0),this.name=this.constructor.name,this.code=oo,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,"response",{enumerable:!1}),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}const En="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",Rn="("+En+')\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"',Cn="("+En+")\\s*=\\s*("+En+")",xn=new RegExp("^[,\\s]*("+En+")"),In=new RegExp("^[,\\s]*"+Rn+"[,\\s]*(.*)"),An=new RegExp("^[,\\s]*"+Cn+"[,\\s]*(.*)"),On=new RegExp("^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)");async function jn(e,t,n){if(e.status!==t){let t;var o;if(Fn(e),t=await async function(e){if(e.status>399&&e.status<500){_o(e),un(e);try{const t=await e.clone().json();if(tn(t)&&"string"==typeof t.error&&t.error.length)return t}catch(e){}}}(e))throw await(null===(o=e.body)||void 0===o?void 0:o.cancel()),new Sn("server responded with an error in the response body",{cause:t,response:e});throw $t('"response" is not a conform '.concat(n," response (unexpected HTTP status code)"),ho,e)}}function Wn(e){if(!qn.has(e))throw Lt('"options.DPoP" is not a valid DPoPHandle',Ut)}async function Nn(e,t,n,o){mn(e),yn(t);const i=kn(e,"userinfo_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==o?void 0:o[Mt])),r=nn(null==o?void 0:o.headers);return t.userinfo_signed_response_alg?r.set("accept","application/jwt"):(r.set("accept","application/json"),r.append("accept","application/jwt")),async function(e,t,n,o,i,r){var s;if(cn(e,'"accessToken"'),!(n instanceof URL))throw Lt('"url" must be an instance of URL',Kt);bn(n,!0!==(null==r?void 0:r[Mt])),o=nn(o),null!=r&&r.DPoP&&(Wn(r.DPoP),await r.DPoP.addProof(n,o,t.toUpperCase(),e)),o.set("authorization","".concat(o.has("dpop")?"DPoP":"Bearer"," ").concat(e));const a=await((null==r?void 0:r[Dt])||fetch)(n.href,{duplex:Nt(i,ReadableStream)?"half":void 0,body:i,headers:Object.fromEntries(o.entries()),method:t,redirect:"manual",signal:on(n,null==r?void 0:r.signal)});return null==r||null===(s=r.DPoP)||void 0===s||s.cacheNonce(a,n),a}(n,"GET",i,r,null,f(f({},o),{},{[zt]:hn(t)}))}const Un=Symbol();function Kn(e){var t;return null===(t=e.headers.get("content-type"))||void 0===t?void 0:t.split(";")[0]}async function Ln(e,t,n,o,i){if(mn(e),yn(t),!Nt(o,Response))throw Lt('"response" must be an instance of Response',Kt);if(Fn(o),200!==o.status)throw $t('"response" is not a conform UserInfo Endpoint response (unexpected HTTP status code)',ho,o);let r;if(_o(o),"application/jwt"===Kn(o)){const n=await To(await o.text(),Eo.bind(void 0,t.userinfo_signed_response_alg,e.userinfo_signing_alg_values_supported,void 0),hn(t),pn(t),null==i?void 0:i[Ht]).then(Vn.bind(void 0,t.client_id)).then(Gn.bind(void 0,e)),s=n.claims,a=n.jwt;Dn.set(o,a),r=s;}else {if(t.userinfo_signed_response_alg)throw $t("JWT UserInfo Response expected",ao,o);r=await Ao(o);}if(cn(r.sub,'"response" body "sub" property',uo,{body:r}),n===Un);else if(cn(n,'"expectedSubject"'),r.sub!==n)throw $t('unexpected "response" body "sub" property value',wo,{expected:n,body:r,attribute:"sub"});return r}async function Mn(e,t,n,o,i,r,s){return await n(e,t,i,r),r.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),((null==s?void 0:s[Dt])||fetch)(o.href,{body:i,headers:Object.fromEntries(r.entries()),method:"POST",redirect:"manual",signal:on(o,null==s?void 0:s.signal)})}async function zn(e,t,n,o,i,r){var s;const a=kn(e,"token_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==r?void 0:r[Mt]));i.set("grant_type",o);const c=nn(null==r?void 0:r.headers);c.set("accept","application/json"),void 0!==(null==r?void 0:r.DPoP)&&(Wn(r.DPoP),await r.DPoP.addProof(a,c,"POST"));const u=await Mn(e,t,n,a,i,c,r);return null==r||null===(s=r.DPoP)||void 0===s||s.cacheNonce(u,a),u}const Jn=new WeakMap,Dn=new WeakMap;function Zn(e){if(!e.id_token)return;const t=Jn.get(e);if(!t)throw Lt('"ref" was already garbage collected or did not resolve from the proper sources',Ut);return t}async function Hn(e,t,n,o,i,r){if(mn(e),yn(t),!Nt(n,Response))throw Lt('"response" must be an instance of Response',Kt);await jn(n,200,"Token Endpoint"),_o(n);const s=await Ao(n);if(cn(s.access_token,'"response" body "access_token" property',uo,{body:s}),cn(s.token_type,'"response" body "token_type" property',uo,{body:s}),s.token_type=s.token_type.toLowerCase(),void 0!==s.expires_in){let e="number"!=typeof s.expires_in?parseFloat(s.expires_in):s.expires_in;an(e,!0,'"response" body "expires_in" property',uo,{body:s}),s.expires_in=e;}if(void 0!==s.refresh_token&&cn(s.refresh_token,'"response" body "refresh_token" property',uo,{body:s}),void 0!==s.scope&&"string"!=typeof s.scope)throw $t('"response" body "scope" property must be a string',uo,{body:s});if(void 0!==s.id_token){cn(s.id_token,'"response" body "id_token" property',uo,{body:s});const r=["aud","exp","iat","iss","sub"];!0===t.require_auth_time&&r.push("auth_time"),void 0!==t.default_max_age&&(an(t.default_max_age,!0,'"client.default_max_age"'),r.push("auth_time")),null!=o&&o.length&&r.push(...o);const a=await To(s.id_token,Eo.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),hn(t),pn(t),i).then($n.bind(void 0,r)).then(Yn.bind(void 0,e)).then(Xn.bind(void 0,t.client_id)),c=a.claims,u=a.jwt;if(Array.isArray(c.aud)&&1!==c.aud.length){if(void 0===c.azp)throw $t('ID Token "aud" (audience) claim includes additional untrusted audiences',yo,{claims:c,claim:"aud"});if(c.azp!==t.client_id)throw $t('unexpected ID Token "azp" (authorized party) claim value',yo,{expected:t.client_id,claims:c,claim:"azp"})}void 0!==c.auth_time&&an(c.auth_time,!0,'ID Token "auth_time" (authentication time)',uo,{claims:c}),Dn.set(n,u),Jn.set(s,c);}if(void 0!==(null==r?void 0:r[s.token_type]))r[s.token_type](n,s);else if("dpop"!==s.token_type&&"bearer"!==s.token_type)throw new Bt("unsupported `token_type` value",{cause:{body:s}});return s}function Fn(e){let t;if(t=function(e){if(!Nt(e,Response))throw Lt('"response" must be an instance of Response',Kt);const t=e.headers.get("www-authenticate");if(null===t)return;const n=[];let o=t;for(;o;){var i;let e=o.match(xn);const t=null===(i=e)||void 0===i?void 0:i[1].toLowerCase();if(!t)return;const c=o.substring(e[0].length);if(c&&!c.match(/^[\s,]/))return;const u=c.match(/^\s+(.*)$/),l=!!u;o=u?u[1]:void 0;const d={};let h;if(l)for(;o;){let t,n;if(e=o.match(In)){var r=y(e,4);if(t=r[1],n=r[2],o=r[3],n.includes("\\"))try{n=JSON.parse('"'.concat(n,'"'));}catch(e){}d[t.toLowerCase()]=n;}else {if(!(e=o.match(An))){if(e=o.match(On)){if(Object.keys(d).length)break;var s=y(e,3);h=s[1],o=s[2];break}return}var a=y(e,4);t=a[1],n=a[2],o=a[3],d[t.toLowerCase()]=n;}}else o=c||void 0;const p={scheme:t,parameters:d};h&&(p.token68=h),n.push(p);}return n.length?n:void 0}(e))throw new Pn("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:t,response:e})}function Vn(e,t){return void 0!==t.claims.aud?Xn(e,t):t}function Xn(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw $t('unexpected JWT "aud" (audience) claim value',yo,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw $t('unexpected JWT "aud" (audience) claim value',yo,{expected:e,claims:t.claims,claim:"aud"});return t}function Gn(e,t){return void 0!==t.claims.iss?Yn(e,t):t}function Yn(e,t){var n,o;const i=null!==(n=null===(o=e[jo])||void 0===o?void 0:o.call(e,t))&&void 0!==n?n:e.issuer;if(t.claims.iss!==i)throw $t('unexpected JWT "iss" (issuer) claim value',yo,{expected:i,claims:t.claims,claim:"iss"});return t}const qn=new WeakSet;const Bn=Symbol();const Qn={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 $n(e,t){for(const n of e)if(void 0===t.claims[n])throw $t('JWT "'.concat(n,'" (').concat(Qn[n],") claim missing"),uo,{claims:t.claims});return t}const eo=Symbol(),to=Symbol();async function no(e,t,n,o){return "string"==typeof(null==o?void 0:o.expectedNonce)||"number"==typeof(null==o?void 0:o.maxAge)||null!=o&&o.requireIdToken?async function(e,t,n,o,i,r,s){const a=[];switch(o){case void 0:o=eo;break;case eo:break;default:cn(o,'"expectedNonce" argument'),a.push("nonce");}switch(null!=i||(i=t.default_max_age),i){case void 0:i=to;break;case to:break;default:an(i,!0,'"maxAge" argument'),a.push("auth_time");}const c=await Hn(e,t,n,a,r,s);cn(c.id_token,'"response" body "id_token" property',uo,{body:c});const u=Zn(c);if(i!==to){const e=fn()+hn(t),n=pn(t);if(u.auth_time+i<e-n)throw $t("too much time has elapsed since the last End-User authentication",mo,{claims:u,now:e,tolerance:n,claim:"auth_time"})}if(o===eo){if(void 0!==u.nonce)throw $t('unexpected ID Token "nonce" claim value',yo,{expected:void 0,claims:u,claim:"nonce"})}else if(u.nonce!==o)throw $t('unexpected ID Token "nonce" claim value',yo,{expected:o,claims:u,claim:"nonce"});return c}(e,t,n,o.expectedNonce,o.maxAge,o[Ht],o.recognizedTokenTypes):async function(e,t,n,o,i){const r=await Hn(e,t,n,void 0,o,i),s=Zn(r);if(s){if(void 0!==t.default_max_age){an(t.default_max_age,!0,'"client.default_max_age"');const e=fn()+hn(t),n=pn(t);if(s.auth_time+t.default_max_age<e-n)throw $t("too much time has elapsed since the last End-User authentication",mo,{claims:s,now:e,tolerance:n,claim:"auth_time"})}if(void 0!==s.nonce)throw $t('unexpected ID Token "nonce" claim value',yo,{expected:void 0,claims:s,claim:"nonce"})}return r}(e,t,n,null==o?void 0:o[Ht],null==o?void 0:o.recognizedTokenTypes)}const oo="OAUTH_WWW_AUTHENTICATE_CHALLENGE",io="OAUTH_RESPONSE_BODY_ERROR",ro="OAUTH_UNSUPPORTED_OPERATION",so="OAUTH_AUTHORIZATION_RESPONSE_ERROR",ao="OAUTH_JWT_USERINFO_EXPECTED",co="OAUTH_PARSE_ERROR",uo="OAUTH_INVALID_RESPONSE",lo="OAUTH_RESPONSE_IS_NOT_JSON",ho="OAUTH_RESPONSE_IS_NOT_CONFORM",po="OAUTH_HTTP_REQUEST_FORBIDDEN",fo="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",mo="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",yo="OAUTH_JWT_CLAIM_COMPARISON_FAILED",wo="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED",go="OAUTH_MISSING_SERVER_METADATA",vo="OAUTH_INVALID_SERVER_METADATA";async function bo(e){if(!Nt(e,Response))throw Lt('"response" must be an instance of Response',Kt);await jn(e,200,"Revocation Endpoint");}function _o(e){if(e.bodyUsed)throw Lt('"response" body has been used already',Ut)}function ko(e){const t=e.algorithm;if("number"!=typeof t.modulusLength||t.modulusLength<2048)throw new Bt("unsupported ".concat(t.name," modulusLength"),{cause:e})}function So(e){switch(e.algorithm.namedCurve){case"P-256":return "SHA-256";case"P-384":return "SHA-384";case"P-521":return "SHA-512";default:throw new Bt("unsupported ECDSA namedCurve",{cause:e})}}async function To(e,t,n,o,i){let r,s,a=e.split("."),c=a[0],u=a[1],l=a.length;if(5===l){if(void 0===i)throw new Bt("JWE decryption is not configured",{cause:e});var d=(e=await i(e)).split(".");c=d[0],u=d[1],l=d.length;}if(3!==l)throw $t("Invalid JWT",uo,e);try{r=JSON.parse(Xt(qt(c)));}catch(e){throw $t("failed to parse JWT Header body as base64url encoded JSON",co,e)}if(!tn(r))throw $t("JWT Header must be a top level object",uo,e);if(t(r),void 0!==r.crit)throw new Bt('no JWT "crit" header parameter extensions are supported',{cause:{header:r}});try{s=JSON.parse(Xt(qt(u)));}catch(e){throw $t("failed to parse JWT Payload body as base64url encoded JSON",co,e)}if(!tn(s))throw $t("JWT Payload must be a top level object",uo,e);const h=fn()+n;if(void 0!==s.exp){if("number"!=typeof s.exp)throw $t('unexpected JWT "exp" (expiration time) claim type',uo,{claims:s});if(s.exp<=h-o)throw $t('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',mo,{claims:s,now:h,tolerance:o,claim:"exp"})}if(void 0!==s.iat&&"number"!=typeof s.iat)throw $t('unexpected JWT "iat" (issued at) claim type',uo,{claims:s});if(void 0!==s.iss&&"string"!=typeof s.iss)throw $t('unexpected JWT "iss" (issuer) claim type',uo,{claims:s});if(void 0!==s.nbf){if("number"!=typeof s.nbf)throw $t('unexpected JWT "nbf" (not before) claim type',uo,{claims:s});if(s.nbf>h+o)throw $t('unexpected JWT "nbf" (not before) claim value',mo,{claims:s,now:h,tolerance:o,claim:"nbf"})}if(void 0!==s.aud&&"string"!=typeof s.aud&&!Array.isArray(s.aud))throw $t('unexpected JWT "aud" (audience) claim type',uo,{claims:s});return {header:r,claims:s,jwt:e}}async function Po(e){if("POST"!==e.method)throw Lt("form_post responses are expected to use the POST method",Ut,{cause:e});if("application/x-www-form-urlencoded"!==Kn(e))throw Lt("form_post responses are expected to use the application/x-www-form-urlencoded content-type",Ut,{cause:e});return async function(e){if(e.bodyUsed)throw Lt("form_post Request instances must contain a readable body",Ut,{cause:e});return e.text()}(e)}function Eo(e,t,n,o){if(void 0===e)if(Array.isArray(t)){if(!t.includes(o.alg))throw $t('unexpected JWT "alg" header parameter',uo,{header:o,expected:t,reason:"authorization server metadata"})}else {if(void 0===n)throw $t('missing client or server configuration to verify used JWT "alg" header parameter',void 0,{client:e,issuer:t,fallback:n});if("string"==typeof n?o.alg!==n:"function"==typeof n?!n(o.alg):!n.includes(o.alg))throw $t('unexpected JWT "alg" header parameter',uo,{header:o,expected:n,reason:"default value"})}else if("string"==typeof e?o.alg!==e:!e.includes(o.alg))throw $t('unexpected JWT "alg" header parameter',uo,{header:o,expected:e,reason:"client configuration"})}function Ro(e,t){const n=e.getAll(t),o=n[0];if(n.length>1)throw $t('"'.concat(t,'" parameter must be provided only once'),uo);return o}const Co=Symbol(),xo=Symbol();function Io(e,t,n,o){if(mn(e),yn(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw Lt('"parameters" must be an instance of URLSearchParams, or URL',Kt);if(Ro(n,"response"))throw $t('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',uo,{parameters:n});const i=Ro(n,"iss"),r=Ro(n,"state");if(!i&&e.authorization_response_iss_parameter_supported)throw $t('response parameter "iss" (issuer) missing',uo,{parameters:n});if(i&&i!==e.issuer)throw $t('unexpected "iss" (issuer) response parameter value',uo,{expected:e.issuer,parameters:n});switch(o){case void 0:case xo:if(void 0!==r)throw $t('unexpected "state" response parameter encountered',uo,{expected:void 0,parameters:n});break;case Co:break;default:if(cn(o,'"expectedState" argument'),r!==o)throw $t(void 0===r?'response parameter "state" missing':'unexpected "state" response parameter value',uo,{expected:o,parameters:n})}if(Ro(n,"error"))throw new Tn("authorization response from the server is an error",{cause:n});const s=Ro(n,"id_token"),a=Ro(n,"token");if(void 0!==s||void 0!==a)throw new Bt("implicit and hybrid flows are not supported");return c=new URLSearchParams(n),qn.add(c),c;var c;}async function Ao(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:un;try{t=await e.json();}catch(t){throw n(e),$t('failed to parse "response" body as JSON',co,t)}if(!tn(t))throw $t('"response" body must be a top level object',uo,{body:t});return t}const Oo=Symbol(),jo=Symbol(),Wo=new TextEncoder,No=new TextDecoder,Uo=new TextDecoder("utf-8",{fatal:!0});function Ko(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const o=t.reduce((e,t)=>e+t.length,0),i=new Uint8Array(o);let r=0;for(const e of t)i.set(e,r),r+=e.length;return i}function Lo(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){const o=e.charCodeAt(n);if(o>127)throw new TypeError("non-ASCII string encountered in encode()");t[n]=o;}return t}const Mo=function(e){return new TypeError("CryptoKey does not support this operation, its ".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"algorithm.name"," must be ").concat(e))};function zo(e,t,n){var o;const i=e.algorithm;if(i.name!==t.name)throw Mo(t.name);if(t.hash&&(null===(o=i.hash)||void 0===o?void 0:o.name)!==t.hash)throw Mo(t.hash,"algorithm.hash");if(t.namedCurve&&i.namedCurve!==t.namedCurve)throw Mo(t.namedCurve,"algorithm.namedCurve");if(void 0!==t.length&&i.length!==t.length)throw Mo(t.length,"algorithm.length");!function(e,t){if(t&&!e.usages.includes(t))throw new TypeError("CryptoKey does not support this operation, its usages must include ".concat(t,"."))}(e,n);}const Jo=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];return function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];if(o.length>2){const t=o.pop();e+="one of type ".concat(o.join(", "),", or ").concat(t,".");}else 2===o.length?e+="one of type ".concat(o[0]," or ").concat(o[1],"."):e+="of type ".concat(o[0],".");if(null==t)e+=" Received ".concat(t);else if("function"==typeof t&&t.name)e+=" Received function ".concat(t.name);else if("object"==typeof t&&null!=t){var r;null!==(r=t.constructor)&&void 0!==r&&r.name&&(e+=" Received an instance of ".concat(t.constructor.name));}return e}("Key for the ".concat(e," algorithm must be "),t,...o)};class Do extends Error{constructor(e,t){var n;super(e,t),h(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}h(Do,"code","ERR_JOSE_GENERIC");class Zo extends Do{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:o,payload:t}}),h(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),h(this,"claim",void 0),h(this,"reason",void 0),h(this,"payload",void 0),this.claim=n,this.reason=o,this.payload=t;}}h(Zo,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class Ho extends Do{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:o,payload:t}}),h(this,"code","ERR_JWT_EXPIRED"),h(this,"claim",void 0),h(this,"reason",void 0),h(this,"payload",void 0),this.claim=n,this.reason=o,this.payload=t;}}h(Ho,"code","ERR_JWT_EXPIRED");class Fo extends Do{constructor(){super(...arguments),h(this,"code","ERR_JOSE_ALG_NOT_ALLOWED");}}h(Fo,"code","ERR_JOSE_ALG_NOT_ALLOWED");class Vo extends Do{constructor(){super(...arguments),h(this,"code","ERR_JOSE_NOT_SUPPORTED");}}h(Vo,"code","ERR_JOSE_NOT_SUPPORTED");h(class extends Do{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"decryption operation failed",arguments.length>1?arguments[1]:void 0),h(this,"code","ERR_JWE_DECRYPTION_FAILED");}},"code","ERR_JWE_DECRYPTION_FAILED");h(class extends Do{constructor(){super(...arguments),h(this,"code","ERR_JWE_INVALID");}},"code","ERR_JWE_INVALID");class Xo extends Do{constructor(){super(...arguments),h(this,"code","ERR_JWS_INVALID");}}h(Xo,"code","ERR_JWS_INVALID");class Go extends Do{constructor(){super(...arguments),h(this,"code","ERR_JWT_INVALID");}}h(Go,"code","ERR_JWT_INVALID");h(class extends Do{constructor(){super(...arguments),h(this,"code","ERR_JWK_INVALID");}},"code","ERR_JWK_INVALID");class Yo extends Do{constructor(){super(...arguments),h(this,"code","ERR_JWKS_INVALID");}}h(Yo,"code","ERR_JWKS_INVALID");class qo extends Do{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"no applicable key found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),h(this,"code","ERR_JWKS_NO_MATCHING_KEY");}}h(qo,"code","ERR_JWKS_NO_MATCHING_KEY");class Bo extends Do{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"multiple matching keys found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),h(this,Symbol.asyncIterator,w(function*(){})),h(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");}}h(Bo,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class Qo extends Do{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"request timed out",arguments.length>1?arguments[1]:void 0),h(this,"code","ERR_JWKS_TIMEOUT");}}h(Qo,"code","ERR_JWKS_TIMEOUT");class $o extends Do{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"signature verification failed",arguments.length>1?arguments[1]:void 0),h(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");}}h($o,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");const ei=e=>{if("CryptoKey"===(null==e?void 0:e[Symbol.toStringTag]))return !0;try{return e instanceof CryptoKey}catch(e){return !1}},ti=e=>ei(e)||(e=>"KeyObject"===(null==e?void 0:e[Symbol.toStringTag]))(e);function ni(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}const oi="The input to be decoded is not correctly encoded.";function ii(e){if(Uint8Array.fromBase64)try{return Uint8Array.fromBase64("string"==typeof e?e:No.decode(e),{alphabet:"base64url"})}catch(e){throw new TypeError(oi,{cause:e})}let t=e;if(t instanceof Uint8Array&&(t=No.decode(t)),t.includes("+")||t.includes("/"))throw new TypeError(oi);t=t.replace(/-/g,"+").replace(/_/g,"/");try{return ni(t)}catch(e){throw new TypeError(oi)}}function ri(e){let t=e;return "string"==typeof t&&(t=Wo.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:"base64url",omitPadding:!0}):function(e){if(Uint8Array.prototype.toBase64)return e.toBase64();const t=[];for(let n=0;n<e.length;n+=32768)t.push(String.fromCharCode.apply(null,e.subarray(n,n+32768)));return btoa(t.join(""))}(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function si(e){if("object"!=typeof e||null===e||"[object Object]"!==Object.prototype.toString.call(e))return !1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}function ai(e){return si(e)&&Array.isArray(e.keys)&&Array.from(e.keys).every(si)}function ci(e,t,n){try{return ii(e)}catch(e){throw new n("Failed to base64url decode the ".concat(t))}}async function ui(e,t){var n,o,i,r;if("RSA"===t.kty&&"oth"in t&&void 0!==t.oth)throw new Vo('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');if(!e.kty.includes(t.kty))throw new Vo('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');const s=null!==(n=null===(o=e.resolve)||void 0===o?void 0:o.call(e,{kty:t.kty,crv:t.crv}))&&void 0!==n?n:e.subtle,a=!(!t.d&&!t.priv),c=f({},t);return "AKP"!==c.kty&&delete c.alg,delete c.use,crypto.subtle.importKey("jwk",c,s,null!==(i=t.ext)&&void 0!==i?i:!a,null!==(r=t.key_ops)&&void 0!==r?r:e.usages[a?1:0])}function li(e){return f({__proto__:null},e)}const di=e=>e[Symbol.toStringTag];function hi(e,t,n){const o=e.alg,i=e.secret,r="decrypt"===n||"sign"===n;if(i&&t instanceof Uint8Array)return [pi,t];if(si(t)){const s=function(e){const t=li(e);if(void 0!==t.ext&&"boolean"!=typeof t.ext)throw new TypeError('"ext" (Extractable) Parameter must be a boolean');if(void 0!==t.key_ops){const e=t.key_ops,n=Array.isArray(e)?[...e]:void 0;if(!n||n.some(e=>"string"!=typeof e)||new Set(n).size!==n.length)throw new TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');t.key_ops=n;}return t}(t);if("string"!=typeof s.kty)throw new TypeError(i?Jo(o,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"):Jo(o,t,"CryptoKey","KeyObject","JSON Web Key"));if(!(i?"oct"===s.kty&&"string"==typeof s.k:"oct"!==s.kty&&(r?"AKP"===s.kty&&"string"==typeof s.priv||"string"==typeof s.d:void 0===s.d&&void 0===s.priv)))throw new TypeError(i?'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present':"JSON Web Key for this operation must be a ".concat(r?"private":"public"," JWK"));return ((e,t,n)=>{const o=e.alg;if(void 0!==t.use){const e="sign"===n||"verify"===n?"sig":"enc";if(t.use!==e)throw new TypeError('Invalid key for this operation, its "use" must be "'.concat(e,'" when present'))}if(void 0!==t.alg&&t.alg!==o)throw new TypeError('Invalid key for this operation, its "alg" must be "'.concat(o,'" when present'));if(Array.isArray(t.key_ops)){var i;const o="encrypt"===n||"decrypt"===n?null===(i=e.ops)||void 0===i?void 0:i["encrypt"===n?0:1]:n;if(o&&!t.key_ops.includes(o))throw new TypeError('Invalid key for this operation, its "key_ops" must include "'.concat(o,'" when present'))}})(e,s,n),[yi,t,s]}if(!ti(t))throw new TypeError(i?Jo(o,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"):Jo(o,t,"CryptoKey","KeyObject","JSON Web Key"));if(i){if("secret"!==t.type)throw new TypeError("".concat(di(t),' instances for symmetric algorithms must be of type "secret"'))}else {if("secret"===t.type)throw new TypeError("".concat(di(t),' instances for asymmetric algorithms must not be of type "secret"'));const e=r?"private":"public";if(("public"===t.type||"private"===t.type)&&t.type!==e){const o="sign"===n?"signing":"verify"===n?"verifying":"".concat(n.slice(0,-1),"tion");throw new TypeError("".concat(di(t)," instances for asymmetric algorithm ").concat(o,' must be of type "').concat(e,'"'))}}return ei(t)?[fi,t]:[mi,t]}const pi=0,fi=1,mi=2,yi=3;let wi;const gi={__proto__:null,prime256v1:"P-256",secp384r1:"P-384",secp521r1:"P-521"};function vi(e,t,n){wi||(wi=new WeakMap);const o=wi.get(e);return n&&(o?o[t]=n:wi.set(e,{[t]:n})),null!=n?n:null==o?void 0:o[t]}const bi=async(e,t,n)=>{var o;return null!==(o=vi(e,n.alg))&&void 0!==o?o:vi(e,n.alg,await ui(n,f(f({},t),{},{alg:n.alg})))};async function _i(e,t,n){const o=hi(e,t,n);switch(o[0]){case pi:case fi:return o[1];case yi:{const t=o[1],n=o[2];if("oct"===n.kty)return ii(n.k);if(!Object.isFrozen(t)){const e=t.key_ops;Array.isArray(e)&&Object.freeze(e),Object.freeze(t);}return bi(t,n,e)}case mi:{const t=o[1];return "secret"===t.type?t.export():"toCryptoKey"in t&&"function"==typeof t.toCryptoKey?((e,t)=>{var n,o,i;const r=vi(e,t.alg);if(r)return r;const s="public"===e.type,a=t.usages[s?0:1],c=e.asymmetricKeyType,u=gi[null===(n=e.asymmetricKeyDetails)||void 0===n?void 0:n.namedCurve],l=null!==(o=null===(i=t.resolve)||void 0===i?void 0:i.call(t,{crv:u,asymmetricKeyType:c}))&&void 0!==o?o:t.subtle;return vi(e,t.alg,e.toCryptoKey(l,s,a))})(t,e):bi(t,t.export({format:"jwk"}),e)}}}function ki(e){const t={__proto__:null};for(const n in e)t[n]=f(f({},e[n]),{},{alg:n});return t}const Si=[["encrypt","wrapKey"],["decrypt","unwrapKey"]],Ti=[[],["deriveBits"]],Pi=[[],[]];function Ei(e){return {kty:["RSA"],subtle:{name:"RSA-OAEP",hash:"SHA-".concat(e)},usages:Si,ops:["wrapKey","unwrapKey"]}}function Ri(){return {kty:["EC","OKP"],subtle:{name:"ECDH"},resolve:e=>{let t=e.kty,n=e.crv,o=e.asymmetricKeyType;if("X25519"===n||"x25519"===o)return {name:"X25519"};if("OKP"===t)throw new Vo('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');return {name:"ECDH",namedCurve:n}},usages:Ti,ops:[void 0,"deriveBits"]}}function Ci(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return {kty:["oct"],secret:!0,subtle:{name:t?"AES-GCM":"AES-KW",length:e},usages:Pi,ops:t?["encrypt","decrypt"]:["wrapKey","unwrapKey"]}}function xi(){return {kty:["oct"],secret:!0,subtle:{name:"PBKDF2"},usages:Pi,ops:["deriveBits","deriveBits"]}}const Ii=ki({dir:{kty:["oct"],secret:!0,subtle:{name:"AES-GCM"},usages:Pi,ops:["encrypt","decrypt"]},"RSA-OAEP":Ei(1),"RSA-OAEP-256":Ei(256),"RSA-OAEP-384":Ei(384),"RSA-OAEP-512":Ei(512),"ECDH-ES":Ri(),"ECDH-ES+A128KW":Ri(),"ECDH-ES+A192KW":Ri(),"ECDH-ES+A256KW":Ri(),A128KW:Ci(128),A192KW:Ci(192),A256KW:Ci(256),A128GCMKW:Ci(128,!0),A192GCMKW:Ci(192,!0),A256GCMKW:Ci(256,!0),"PBES2-HS256+A128KW":xi(),"PBES2-HS384+A192KW":xi(),"PBES2-HS512+A256KW":xi()}),Ai=["encrypt","decrypt"];function Oi(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return {kty:["oct"],secret:!0,subtle:{name:t?"AES-CBC":"AES-GCM",length:e},usages:Pi,ops:Ai,cekBits:e,ivBits:t?128:96,cbc:t}}ki({A128GCM:Oi(128),A192GCM:Oi(192),A256GCM:Oi(256),"A128CBC-HS256":Oi(256,!0),"A192CBC-HS384":Oi(384,!0),"A256CBC-HS512":Oi(512,!0)});const ji={__proto__:null,b64:!0};function Wi(e,t){if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw new TypeError('"'.concat(e,'" option must be an array of strings'));if(t)return new Set(t)}function Ni(e,t,n,o,i){if(void 0!==i.crit&&void 0===(null==o?void 0:o.crit))throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!o||void 0===o.crit)return [];if(!Array.isArray(o.crit)||0===o.crit.length||o.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');const r=void 0===n?t:f(f({__proto__:null},n),t);for(const t of o.crit){if(!(t in r))throw new Vo('Extension Header Parameter "'.concat(t,'" is not recognized'));if(!Object.hasOwn(i,t)||void 0===i[t])throw new e('Extension Header Parameter "'.concat(t,'" is missing'));if(r[t]&&(!Object.hasOwn(o,t)||void 0===o[t]))throw new e('Extension Header Parameter "'.concat(t,'" MUST be integrity protected'))}return o.crit}function Ui(e,t){if(t.includes("b64")){const t=e.b64;if("boolean"!=typeof t)throw new Xo('The "b64" (base64url-encode payload) Header Parameter must be a boolean');return t}return !0}var Ki,Li;let Mi,zi;if("undefined"==typeof navigator||null===(Ki=navigator.userAgent)||void 0===Ki||null===(Li=Ki.startsWith)||void 0===Li||!Li.call(Ki,"Mozilla/5.0 ")){const e="v6.8.4";zi="".concat("openid-client","/").concat(e),Mi={"user-agent":zi};}const Ji=e=>Di.get(e);let Di,Zi;function Hi(e){return void 0!==e?wn(e):(Zi||(Zi=new WeakMap),(e,t,n,o)=>{let i;return (i=Zi.get(t))||(!function(e,t){if("string"!=typeof e)throw Yi("".concat(t," must be a string"),Gi);if(0===e.length)throw Yi("".concat(t," must not be empty"),Xi)}(t.client_secret,'"metadata.client_secret"'),i=wn(t.client_secret),Zi.set(t,i)),i(e,t,n,o)})}const Fi=Un,Vi=Dt,Xi="ERR_INVALID_ARG_VALUE",Gi="ERR_INVALID_ARG_TYPE";function Yi(e,t,n){const o=new TypeError(e,{cause:n});return Object.assign(o,{code:t}),o}function qi(e){return async function(e){return cn(e,"codeVerifier"),qt(await crypto.subtle.digest("SHA-256",Xt(e)))}(e)}function Bi(){return ln()}class Qi extends Error{constructor(e,t){var n;super(e,t),h(this,"code",void 0),this.name=this.constructor.name,this.code=null==t?void 0:t.code,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}function $i(e,t,n){return new Qi(e,{cause:t,code:n})}function er(e){if(e instanceof TypeError||e instanceof Qi||e instanceof Sn||e instanceof Tn||e instanceof Pn)throw e;if(e instanceof Qt)switch(e.code){case po:throw $i("only requests to HTTPS are allowed",e,e.code);case fo:throw $i("only requests to HTTP or HTTPS are allowed",e,e.code);case ho:throw $i("unexpected HTTP response status code",e.cause,e.code);case lo:throw $i("unexpected response content-type",e.cause,e.code);case co:throw $i("parsing error occured",e,e.code);case uo:throw $i("invalid response encountered",e,e.code);case yo:throw $i("unexpected JWT claim value encountered",e,e.code);case wo:throw $i("unexpected JSON attribute value encountered",e,e.code);case mo:throw $i("JWT timestamp claim value failed validation",e,e.code);default:throw $i(e.message,e,e.code)}if(e instanceof Bt)throw $i("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw $i("runtime operation error",e,ro);case"NotSupportedError":throw $i("runtime unsupported operation",e,ro);case"TimeoutError":throw $i("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw $i("operation aborted",e,"OAUTH_ABORT")}throw new Qi("something went wrong",{cause:e})}async function tr(e,t,n,o,i){const r=await async function(e,t){var n,o;if(!(e instanceof URL))throw Yi('"server" must be an instance of URL',Gi);const i=!e.href.includes("/.well-known/"),r=null!==(n=null==t?void 0:t.timeout)&&void 0!==n?n:30,s=AbortSignal.timeout(1e3*r),a=await(i?sn(e,{algorithm:null==t?void 0:t.algorithm,[Dt]:null==t?void 0:t[Vi],[Mt]:null==t||null===(o=t.execute)||void 0===o?void 0:o.includes(ur),signal:s,headers:new Headers(Mi)}):((null==t?void 0:t[Vi])||fetch)((bn(e,null==t||null===(c=t.execute)||void 0===c||!c.includes(ur)),e.href),{headers:Object.fromEntries(new Headers(f({accept:"application/json"},Mi)).entries()),body:void 0,method:"GET",redirect:"manual",signal:s})).then(e=>async function(e,t){const n=e;if(!(n instanceof URL)&&n!==Oo)throw Lt('"expectedIssuerIdentifier" must be an instance of URL',Kt);if(!Nt(t,Response))throw Lt('"response" must be an instance of Response',Kt);if(200!==t.status)throw $t('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',ho,t);_o(t);const o=await Ao(t);if(cn(o.issuer,'"response" body "issuer" property',uo,{body:o}),n!==Oo&&new URL(o.issuer).href!==n.href)throw $t('"response" body "issuer" property does not match the expected value',wo,{expected:n.href,body:o,attribute:"issuer"});return o}(Oo,e)).catch(er);var c;i&&new URL(a.issuer).href!==e.href&&(function(e,t,n){return !("https://login.microsoftonline.com"!==e.origin||null!=n&&n.algorithm&&"oidc"!==n.algorithm||(t[nr]=!0,0))}(e,a,t)||function(e,t){return !(!e.hostname.endsWith(".b2clogin.com")||null!=t&&t.algorithm&&"oidc"!==t.algorithm)}(e,t)||(()=>{throw new Qi("discovered metadata issuer does not match the expected issuer",{code:wo,cause:{expected:e.href,body:a,attribute:"issuer"}})})());return a}(e,i),s=new or(r,t,n,o);let a=Ji(s);if(null!=i&&i[Vi]&&(a.fetch=i[Vi]),null!=i&&i.timeout&&(a.timeout=i.timeout),null!=i&&i.execute)for(const e of i.execute)e(s);return s}new TextDecoder;const nr=Symbol();class or{constructor(e,t,n,o){var i,r,s,a,c;if("string"!=typeof t||!t.length)throw Yi('"clientId" must be a non-empty string',Gi);if("string"==typeof n&&(n={client_secret:n}),void 0!==(null===(i=n)||void 0===i?void 0:i.client_id)&&t!==n.client_id)throw Yi('"clientId" and "metadata.client_id" must be the same',Xi);const u=f(f({},structuredClone(n)),{},{client_id:t});let l;u[zt]=null!==(r=null===(s=n)||void 0===s?void 0:s[zt])&&void 0!==r?r:0,u[Jt]=null!==(a=null===(c=n)||void 0===c?void 0:c[Jt])&&void 0!==a?a:30,l=o||("string"==typeof u.client_secret&&u.client_secret.length?Hi(u.client_secret):(e,t,n,o)=>{n.set("client_id",t.client_id);});let d=Object.freeze(u);const h=structuredClone(e);nr in e&&(h[jo]=t=>{let n=t.claims.tid;return e.issuer.replace("{tenantid}",n)});let p=Object.freeze(h);Di||(Di=new WeakMap),Di.set(this,{__proto__:null,as:p,c:d,auth:l,tlsOnly:!0,jwksCache:{}});}serverMetadata(){const e=structuredClone(Ji(this).as);return function(e){Object.defineProperties(e,function(e){return {supportsPKCE:{__proto__:null,value(){var t;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"S256";return !0===(null===(t=e.code_challenge_methods_supported)||void 0===t?void 0:t.includes(n))}}}}(e));}(e),e}clientMetadata(){return structuredClone(Ji(this).c)}get timeout(){return Ji(this).timeout}set timeout(e){Ji(this).timeout=e;}get[Vi](){return Ji(this).fetch}set[Vi](e){Ji(this).fetch=e;}}function ir(e){Object.defineProperties(e,function(e){let t;if(void 0!==e.expires_in){const n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime();}return {expiresIn:{__proto__:null,value(){if(t){const e=Date.now();return t>e?Math.floor((t-e)/1e3):0}}},claims:{__proto__:null,value(){try{return Zn(this)}catch(e){return}}}}}(e));}async function rr(e,t,n){var o;let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=null===(o=e.headers.get("retry-after"))||void 0===o?void 0:o.trim();if(void 0===r)return;let s;if(/^\d+$/.test(r))s=parseInt(r,10);else {const e=new Date(r);if(Number.isFinite(e.getTime())){const t=new Date,n=e.getTime()-t.getTime();n>0&&(s=Math.ceil(n/1e3));}}if(i&&!Number.isFinite(s))throw new Qt("invalid Retry-After header value",{cause:e});s>t&&await sr(s-t,n);}function sr(e,t){return new Promise((n,o)=>{const i=e=>{try{t.throwIfAborted();}catch(e){return void o(e)}if(e<=0)return void n();const r=Math.min(e,5);setTimeout(()=>i(e-r),1e3*r);};i(e);})}async function ar(e,t){mr(e);const n=Ji(e),o=n.as,i=n.c,r=n.auth,s=n.fetch,a=n.tlsOnly,c=n.timeout;return async function(e,t,n,o,i){mn(e),yn(t);const r=kn(e,"backchannel_authentication_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[Mt])),s=new URLSearchParams(o);s.set("client_id",t.client_id);const a=nn(null==i?void 0:i.headers);return a.set("accept","application/json"),Mn(e,t,n,r,s,a,i)}(o,i,r,t,{[Dt]:s,[Mt]:!a,headers:new Headers(Mi),signal:yr(c)}).then(e=>async function(e,t,n){if(mn(e),yn(t),!Nt(n,Response))throw Lt('"response" must be an instance of Response',Kt);await jn(n,200,"Backchannel Authentication Endpoint"),_o(n);const o=await Ao(n);cn(o.auth_req_id,'"response" body "auth_req_id" property',uo,{body:o});let i="number"!=typeof o.expires_in?parseFloat(o.expires_in):o.expires_in;return an(i,!0,'"response" body "expires_in" property',uo,{body:o}),o.expires_in=i,void 0!==o.interval&&an(o.interval,!1,'"response" body "interval" property',uo,{body:o}),o}(o,i,e)).catch(er)}async function cr(e,t,n,o){var i,r;mr(e),n=new URLSearchParams(n);let s=null!==(i=t.interval)&&void 0!==i?i:5;const a=null!==(r=null==o?void 0:o.signal)&&void 0!==r?r:AbortSignal.timeout(1e3*t.expires_in);try{await sr(s,a);}catch(e){er(e);}const c=Ji(e),u=c.as,l=c.c,d=c.auth,h=c.fetch,p=c.tlsOnly,m=c.nonRepudiation,y=c.timeout,w=c.decrypt,g=(i,r)=>cr(e,f(f({},t),{},{interval:i}),n,f(f({},o),{},{signal:a,flag:r})),v=function(e,t){const n=yr(t);if(!n)return {signal:e,cleanup(){}};const o=new AbortController,i=e=>{const t=e.target;o.abort(t.reason);};return e.aborted?o.abort(e.reason):n.aborted?o.abort(n.reason):(e.addEventListener("abort",i,{once:!0}),n.addEventListener("abort",i,{once:!0})),{signal:o.signal,cleanup(){e.removeEventListener("abort",i),n.removeEventListener("abort",i);}}}(a,y),b=await async function(e,t,n,o,i){mn(e),yn(t),cn(o,'"authReqId"');const r=new URLSearchParams(null==i?void 0:i.additionalParameters);return r.set("auth_req_id",o),zn(e,t,n,"urn:openid:params:grant-type:ciba",r,i)}(u,l,d,t.auth_req_id,{[Dt]:h,[Mt]:!p,additionalParameters:n,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Mi),signal:v.signal}).catch(er).finally(v.cleanup);var _;if(503===b.status&&b.headers.has("retry-after"))return await rr(b,s,a,!0),await(null===(_=b.body)||void 0===_?void 0:_.cancel()),g(s);const k=async function(e,t,n,o){return Hn(e,t,n,void 0,null==o?void 0:o[Ht],null==o?void 0:o.recognizedTokenTypes)}(u,l,b,{[Ht]:w});let S;try{S=await k;}catch(e){if(gr(e,o))return g(s,vr);if(e instanceof Sn)switch(e.error){case"slow_down":s+=5;case"authorization_pending":return await rr(e.response,s,a),g(s)}er(e);}return S.id_token&&await(null==m?void 0:m(b)),ir(S),S}function ur(e){Ji(e).tlsOnly=!1;}async function lr(e,t,n,o,i){if(mr(e),!((null==i?void 0:i.flag)===vr||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch(e){return !1}}(t,"Request")))throw Yi('"currentUrl" must be an instance of URL, or Request',Gi);let r,s;const a=Ji(e),c=a.as,u=a.c,l=a.auth,d=a.fetch,h=a.tlsOnly,p=a.jarm,m=a.hybrid,w=a.nonRepudiation,g=a.timeout,v=a.decrypt,b=a.implicit;if((null==i?void 0:i.flag)===vr)r=i.authResponse,s=i.redirectUri;else {if(!(t instanceof URL)){const e=t;switch(t=new URL(t.url),e.method){case"GET":break;case"POST":const n=new URLSearchParams(await Po(e));if(m)t.hash=n.toString();else for(const e of n.entries()){var _=y(e,2);const n=_[0],o=_[1];t.searchParams.append(n,o);}break;default:throw Yi("unexpected Request HTTP method",Xi)}}switch(s=function(e){return (e=new URL(e)).search="",e.hash="",e.href}(t),!0){case!!p:r=await p(t,null==n?void 0:n.expectedState);break;case!!m:r=await m(t,null==n?void 0:n.expectedNonce,null==n?void 0:n.expectedState,null==n?void 0:n.maxAge);break;case!!b:throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{r=Io(c,u,t.searchParams,null==n?void 0:n.expectedState);}catch(e){er(e);}}}const k=await async function(e,t,n,o,i,r,s){if(mn(e),yn(t),!qn.has(o))throw Lt('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',Ut);cn(i,'"redirectUri"');const a=Ro(o,"code");if(!a)throw $t('no authorization code in "callbackParameters"',uo);const c=new URLSearchParams(null==s?void 0:s.additionalParameters);return c.set("redirect_uri",i),c.set("code",a),r!==Bn&&(cn(r,'"codeVerifier"'),c.set("code_verifier",r)),zn(e,t,n,"authorization_code",c,s)}(c,u,l,r,s,(null==n?void 0:n.pkceCodeVerifier)||Bn,{additionalParameters:o,[Dt]:d,[Mt]:!h,DPoP:null==i?void 0:i.DPoP,headers:new Headers(Mi),signal:yr(g)}).catch(er);"string"!=typeof(null==n?void 0:n.expectedNonce)&&"number"!=typeof(null==n?void 0:n.maxAge)||(n.idTokenExpected=!0);const S=no(c,u,k,{expectedNonce:null==n?void 0:n.expectedNonce,maxAge:null==n?void 0:n.maxAge,requireIdToken:null==n?void 0:n.idTokenExpected,[Ht]:v});let T;try{T=await S;}catch(t){if(gr(t,i))return lr(e,void 0,n,o,f(f({},i),{},{flag:vr,authResponse:r,redirectUri:s}));er(t);}return T.id_token&&await(null==w?void 0:w(k)),ir(T),T}async function dr(e,t,n,o){mr(e),n=new URLSearchParams(n);const i=Ji(e),r=i.as,s=i.c,a=i.auth,c=i.fetch,u=i.tlsOnly,l=i.nonRepudiation,d=i.timeout,h=i.decrypt,p=await async function(e,t,n,o,i){mn(e),yn(t),cn(o,'"refreshToken"');const r=new URLSearchParams(null==i?void 0:i.additionalParameters);return r.set("refresh_token",o),zn(e,t,n,"refresh_token",r,i)}(r,s,a,t,{[Dt]:c,[Mt]:!u,additionalParameters:n,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Mi),signal:yr(d)}).catch(er),m=async function(e,t,n,o){return Hn(e,t,n,void 0,null==o?void 0:o[Ht],null==o?void 0:o.recognizedTokenTypes)}(r,s,p,{[Ht]:h});let y;try{y=await m;}catch(i){if(gr(i,o))return dr(e,t,n,f(f({},o),{},{flag:vr}));er(i);}return y.id_token&&await(null==l?void 0:l(p)),ir(y),y}async function hr(e,t,n){mr(e),t=new URLSearchParams(t);const o=Ji(e),i=o.as,r=o.c,s=o.auth,a=o.fetch,c=o.tlsOnly,u=o.timeout,l=await async function(e,t,n,o,i){return mn(e),yn(t),zn(e,t,n,"client_credentials",new URLSearchParams(o),i)}(i,r,s,t,{[Dt]:a,[Mt]:!c,DPoP:null==n?void 0:n.DPoP,headers:new Headers(Mi),signal:yr(u)}).catch(er),d=async function(e,t,n,o){return Hn(e,t,n,void 0,null==o?void 0:o[Ht],null==o?void 0:o.recognizedTokenTypes)}(i,r,l);let h;try{h=await d;}catch(o){if(gr(o,n))return hr(e,t,f(f({},n),{},{flag:vr}));er(o);}return ir(h),h}function pr(e,t){mr(e);const n=Ji(e),o=n.as,i=n.c,r=n.tlsOnly,s=n.hybrid,a=n.jarm,c=n.implicit,u=kn(o,"authorization_endpoint",!1,r);if((t=new URLSearchParams(t)).has("client_id")||t.set("client_id",i.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",s?"code id_token":c?"id_token":"code"),c&&!t.has("nonce"))throw Yi("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",Xi);a&&t.set("response_mode","jwt");}for(const e of t.entries()){var l=y(e,2);const t=l[0],n=l[1];u.searchParams.append(t,n);}return u}async function fr(e,t,n){mr(e);const o=pr(e,t),i=Ji(e),r=i.as,s=i.c,a=i.auth,c=i.fetch,u=i.tlsOnly,l=i.timeout,d=await async function(e,t,n,o,i){var r;mn(e),yn(t);const s=kn(e,"pushed_authorization_request_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[Mt])),a=new URLSearchParams(o);a.set("client_id",t.client_id);const c=nn(null==i?void 0:i.headers);c.set("accept","application/json"),void 0!==(null==i?void 0:i.DPoP)&&(Wn(i.DPoP),await i.DPoP.addProof(s,c,"POST"));const u=await Mn(e,t,n,s,a,c,i);return null==i||null===(r=i.DPoP)||void 0===r||r.cacheNonce(u,s),u}(r,s,a,o.searchParams,{[Dt]:c,[Mt]:!u,DPoP:null==n?void 0:n.DPoP,headers:new Headers(Mi),signal:yr(l)}).catch(er),h=async function(e,t,n){if(mn(e),yn(t),!Nt(n,Response))throw Lt('"response" must be an instance of Response',Kt);await jn(n,201,"Pushed Authorization Request Endpoint"),_o(n);const o=await Ao(n);cn(o.request_uri,'"response" body "request_uri" property',uo,{body:o});let i="number"!=typeof o.expires_in?parseFloat(o.expires_in):o.expires_in;return an(i,!0,'"response" body "expires_in" property',uo,{body:o}),o.expires_in=i,o}(r,s,d);let p;try{p=await h;}catch(o){if(gr(o,n))return fr(e,t,f(f({},n),{},{flag:vr}));er(o);}return pr(e,{request_uri:p.request_uri})}function mr(e){if(!(e instanceof or))throw Yi('"config" must be an instance of Configuration',Gi);if(Object.getPrototypeOf(e)!==or.prototype)throw Yi("subclassing Configuration is not allowed",Xi)}function yr(e){return e?AbortSignal.timeout(1e3*e):void 0}async function wr(e,t,n,o){mr(e);const i=Ji(e),r=i.as,s=i.c,a=i.fetch,c=i.tlsOnly,u=i.nonRepudiation,l=i.timeout,d=i.decrypt,h=await Nn(r,s,t,{[Dt]:a,[Mt]:!c,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Mi),signal:yr(l)}).catch(er);let p,m=Ln(r,s,n,h,{[Ht]:d});try{p=await m;}catch(i){if(gr(i,o))return wr(e,t,n,f(f({},o),{},{flag:vr}));er(i);}return "application/jwt"===Kn(h)&&await(null==u?void 0:u(h)),p}function gr(e,t){return !(null==t||!t.DPoP||t.flag===vr)&&function(e){if(e instanceof Pn){const t=e.cause,n=t[0];return 1===t.length&&"dpop"===n.scheme&&"use_dpop_nonce"===n.parameters.error}return e instanceof Sn&&"use_dpop_nonce"===e.error}(e)}Object.freeze(or.prototype);const vr=Symbol();async function br(e,t,n,o){mr(e);const i=Ji(e),r=i.as,s=i.c,a=i.auth,c=i.fetch,u=i.tlsOnly,l=i.timeout,d=i.decrypt,h=i.nonRepudiation,p=await async function(e,t,n,o,i,r){return mn(e),yn(t),cn(o,'"grantType"'),zn(e,t,n,o,new URLSearchParams(i),r)}(r,s,a,t,new URLSearchParams(n),{[Dt]:c,[Mt]:!u,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Mi),signal:yr(l)}).catch(er);let m;"urn:ietf:params:oauth:grant-type:token-exchange"===t&&(m={n_a:()=>{}});const y=async function(e,t,n,o){return Hn(e,t,n,void 0,null==o?void 0:o[Ht],null==o?void 0:o.recognizedTokenTypes)}(r,s,p,{[Ht]:d,recognizedTokenTypes:m});let w;try{w=await y;}catch(i){if(gr(i,o))return br(e,t,n,f(f({},o),{},{flag:vr}));er(i);}return w.id_token&&await(null==h?void 0:h(p)),ir(w),w}async function _r(e,t,n){mr(e);const o=Ji(e),i=o.as,r=o.c,s=o.auth,a=o.fetch,c=o.tlsOnly,u=o.timeout;return async function(e,t,n,o,i){mn(e),yn(t),cn(o,'"token"');const r=kn(e,"revocation_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[Mt])),s=new URLSearchParams(null==i?void 0:i.additionalParameters);s.set("token",o);const a=nn(null==i?void 0:i.headers);return a.delete("accept"),Mn(e,t,n,r,s,a,i)}(i,r,s,t,{[Dt]:a,[Mt]:!c,additionalParameters:new URLSearchParams(n),headers:new Headers(Mi),signal:yr(u)}).then(bo).catch(er)}async function kr(e,t,n){return t instanceof Uint8Array?crypto.subtle.importKey("raw",t,e.subtle,!1,[n]):(zo(t,e.subtle,n),e.minRsaBits&&function(e,t){const n=t.algorithm.modulusLength;if("number"!=typeof n||n<2048)throw new TypeError("".concat(e," requires key modulusLength to be 2048 bits or larger"))}(e.alg,t),t)}const Sr=[["verify"],["sign"]];function Tr(e){const t={name:"HMAC",hash:"SHA-".concat(e)};return {kty:["oct"],secret:!0,subtle:t,signing:t,usages:Sr}}function Pr(e,t){const n={name:t?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(e)};return {kty:["RSA"],subtle:n,signing:t?f(f({},n),{},{saltLength:t}):n,usages:Sr,minRsaBits:2048}}function Er(e,t){return {kty:["EC"],crv:e,subtle:{name:"ECDSA",namedCurve:e},signing:{name:"ECDSA",hash:"SHA-".concat(t)},usages:Sr}}function Rr(){const e={name:"Ed25519"};return {kty:["OKP"],crv:"Ed25519",subtle:e,signing:e,usages:Sr}}function Cr(e){const t={name:"ML-DSA-".concat(e)};return {kty:["AKP"],subtle:t,signing:t,usages:Sr}}const xr=ki({HS256:Tr(256),HS384:Tr(384),HS512:Tr(512),RS256:Pr(256),RS384:Pr(384),RS512:Pr(512),PS256:Pr(256,32),PS384:Pr(384,48),PS512:Pr(512,64),ES256:Er("P-256",256),ES384:Er("P-384",384),ES512:Er("P-521",512),EdDSA:Rr(),Ed25519:Rr(),"ML-DSA-44":Cr(44),"ML-DSA-65":Cr(65),"ML-DSA-87":Cr(87)});function Ir(e){const t="string"==typeof e?xr[e]:void 0;if(!t)throw new Vo("alg ".concat(e," is not supported either by JOSE or your javascript runtime"));return t}function Ar(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0===e?{}:function(e,t,n){let o;try{o=JSON.parse(Uo.decode(ii(e)));}catch(e){throw new t(n)}if(!si(o))throw new t(n);return o}(e,Xo,"JWS Protected Header is invalid");return t}async function Or(e,t,n,o,i,r,s){var a;let c=!1;"function"==typeof n&&(n=await n(i,e),c=!0);const u="string"==typeof s,l=Ir(r),d=Ko(void 0!==o?Lo(o):new Uint8Array,Lo("."),u?null!==(a=t[2])&&void 0!==a?a:t[2]=function(e,t,n){try{return Lo(e)}catch(e){throw new n("The ".concat(t," is not a valid base64url string"))}}(s,"payload",Xo):s),h=ci(e.signature,"signature",Xo),p=await _i(l,n,"verify");if(!await async function(e,t,n,o){const i=await kr(e,t,"verify");try{return await crypto.subtle.verify(e.signing,i,n,o)}catch(e){return !1}}(l,p,h,d))throw new $o;return [u?ci(s,"payload",Xo):s,i,u,p,c]}async function jr(e,t,n){if(e instanceof Uint8Array&&(e=No.decode(e)),"string"!=typeof e)throw new Xo("Compact JWS must be a string or Uint8Array");const o=e.split("."),i=o[0],r=o[1],s=o[2];if(3!==o.length)throw new Xo("Invalid Compact JWS");const a={payload:r,protected:i,signature:s},c=Ar(i),u=function(e,t,n){const o=Ui(e,Ni(Xo,ji,n[1],e,t)),i=t.alg;if("string"!=typeof i||!i)throw new Xo('JWS "alg" (Algorithm) Header Parameter missing or invalid');if(n[0]&&!n[0].has(i))throw new Fo('"alg" (Algorithm) Header Parameter value not allowed');return [o,i]}(c,c,t),l=y(u,2),d=l[0],h=l[1],p=d?r:function(e){try{return Lo(e)}catch(e){throw new Xo("JWS Compact Serialization payload must use only ASCII characters")}}(r);return Or(a,t,n,i,c,h,p)}const Wr=e=>Math.floor(e.getTime()/1e3),Nr={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},Ur=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Kr="check_failed";function Lr(){throw new TypeError("Invalid time period format")}function Mr(e){"string"!=typeof e&&Lr();const t=Ur.exec(e);(!t||t[4]&&t[1])&&Lr();const n=parseFloat(t[2]),o=Math.round(n*Nr[t[3][0].toLowerCase()]);return Number.isFinite(o)||Lr(),"-"===t[1]||"ago"===t[4]?-o:o}function zr(e,t){if(!Number.isFinite(t))throw new TypeError("Invalid ".concat(e," input"));return t}function Jr(e,t){if("string"!=typeof t)throw new TypeError('"'.concat(e,'" claim must be a string'))}function Dr(e,t){return "number"==typeof e?zr(t,e):e instanceof Date?zr(t,Wr(e)):Wr(new Date)+Mr(e)}const Zr=e=>{const t=e.toLowerCase();return e.includes("/")?t:"application/".concat(t)};function Hr(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const o=e[t];if(void 0!==o||n){if("number"!=typeof o)throw new Zo('"'.concat(t,'" claim must be a number'),e,t,"invalid");return o}}function Fr(e,t){throw new Zo('unexpected "'.concat(t,'" claim value'),e,t,Kr)}function Vr(e,t){let n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{n=JSON.parse(Uo.decode(t));}catch(e){}if(!si(n))throw new Go("JWT Claims Set must be a top-level JSON object");const i=o.typ;if(void 0!==i&&("string"!=typeof e.typ||Zr(e.typ)!==Zr(i)))throw new Zo('unexpected "typ" JWT header value',n,"typ",Kr);const r=o.requiredClaims,s=void 0===r?[]:r,a=o.issuer,c=o.subject,u=o.audience,l=o.maxTokenAge,d=[...s];void 0!==l&&d.push("iat"),void 0!==u&&d.push("aud"),void 0!==c&&d.push("sub"),void 0!==a&&d.push("iss");for(const e of new Set(d.reverse()))if(!Object.hasOwn(n,e))throw new Zo('missing required "'.concat(e,'" claim'),n,e,"missing");var h,p;void 0===a||(Array.isArray(a)?a:[a]).includes(n.iss)||Fr(n,"iss"),void 0!==c&&n.sub!==c&&Fr(n,"sub"),void 0===u||(h=n.aud,p="string"==typeof u?[u]:u,"string"==typeof h?p.includes(h):Array.isArray(h)&&p.some(e=>h.includes(e)))||Fr(n,"aud");const f=o.clockTolerance;let m=0;if("string"==typeof f)m=Mr(f);else if(void 0!==f){if("number"!=typeof f)throw new TypeError("Invalid clockTolerance option type");m=f;}zr("clockTolerance option",m);const y=o.currentDate,w=zr("currentDate option",Wr(void 0===y?new Date:y)),g=Hr(n,"iat",void 0!==l),v=Hr(n,"nbf");if(void 0!==v&&v>w+m)throw new Zo('"nbf" claim timestamp check failed',n,"nbf",Kr);const b=Hr(n,"exp");if(void 0!==b&&b<=w-m)throw new Ho('"exp" claim timestamp check failed',n,"exp",Kr);if(void 0!==l){const e=w-g;if(e-m>zr("maxTokenAge option","number"==typeof l?l:Mr(l)))throw new Ho('"iat" claim timestamp check failed (too far in the past)',n,"iat",Kr);if(e<-m)throw new Zo('"iat" claim timestamp check failed (it should be in the past)',n,"iat",Kr)}return n}let Xr;function Gr(e){return Xr.get(e)}async function Yr(e,t,n){const o=await jr(e,function(e){return [e&&Wi("algorithms",e.algorithms),null==e?void 0:e.crit]}(n),t);if(!o[2])throw new Go("JWTs MUST NOT use unencoded payload");const i={payload:Vr(o[1],o[0],n),protectedHeader:o[1]};return "function"==typeof t?f(f({},i),{},{key:o[3]}):i}function qr(e){if(void 0===e)return [void 0,""];const t=function(e,t){let n,o;try{n=JSON.stringify(t),o=JSON.parse(n);}catch(t){throw new e("JOSE Header is not valid JSON",{cause:t})}if(!si(o))throw new e("JOSE Header is not a JSON object");return [o,n]}(Xo,e);return [t[0],ri(t[1])]}function Br(e,t,n){return function(e,t){const n=(null!=t?t:{}).crit;if(Array.isArray(n)&&new Set(n).size!==n.length)throw new e('"crit" (Critical) Header Parameter MUST NOT contain duplicate values')}(Xo,e),Ui(e,Ni(Xo,ji,n,e,t))}async function Qr(e,t,n,o){const i=Ko(Lo(e),Lo("."),t),r=await _i(n,o,"sign");return ri(await async function(e,t,n){const o=await kr(e,t,"sign"),i=await crypto.subtle.sign(e.signing,o,n);return new Uint8Array(i)}(n,r,i))}async function $r(e,t,n,o,i){const r=y(qr(t),2),s=r[0],a=r[1];if(!s)throw new Xo("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");Br(s,s,n)||i();const c=function(e){const t=e.alg;if("string"!=typeof t||!t)throw new Xo('JWS "alg" (Algorithm) Header Parameter missing or invalid');return Ir(t)}(s),u=ri(e),l=await Qr(a,Lo(u),c,o);return "".concat(a,".").concat(u,".").concat(l)}const es=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!si(e))throw new TypeError("JWT Claims Set MUST be an object");(Xr||(Xr=new WeakMap)).set(this,structuredClone(e));}setIssuer(e){return Jr("iss",e),Gr(this).iss=e,this}setSubject(e){return Jr("sub",e),Gr(this).sub=e,this}setAudience(e){return function(e){if("string"!=typeof e&&(!Array.isArray(e)||Array.from(e).some(e=>"string"!=typeof e)))throw new TypeError('"aud" claim must be a string or an array of strings')}(e),Gr(this).aud=e,this}setJti(e){return Jr("jti",e),Gr(this).jti=e,this}setNotBefore(e){return Gr(this).nbf=Dr(e,"setNotBefore"),this}setExpirationTime(e){return Gr(this).exp=Dr(e,"setExpirationTime"),this}setIssuedAt(e){const t=Gr(this);return t.iat=void 0===e?Wr(new Date):"string"==typeof e?zr("setIssuedAt",Wr(new Date)+Mr(e)):Dr(e,"setIssuedAt"),this}};var ts=new WeakMap;class ns extends es{constructor(){super(...arguments),u(this,ts,void 0);}setProtectedHeader(e){return function(e,t){if(void 0!==e)throw new TypeError("".concat(t," can only be called once"))}(c(ts,this),"setProtectedHeader"),l(ts,this,e),this}async sign(e,t){return $r(function(e){const t=Gr(e);for(const e of ["iat","nbf","exp"]){const n=t[e];if("number"==typeof n&&!Number.isFinite(n))throw new TypeError('"'.concat(e,'" claim must be a finite number'))}return Wo.encode(JSON.stringify(t))}(this),c(ts,this),null==t?void 0:t.crit,e,()=>{throw new Go("JWTs MUST NOT use unencoded payload")})}}const os='"alg" (Algorithm)';function is(){throw new Vo("Invalid or unsupported ".concat(arguments.length>0&&void 0!==arguments[0]?arguments[0]:'JWK "alg" (Algorithm) Parameter'," value"))}const rs=(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},ss=e=>{const t=e.data[e.pos++];if(void 0===t)throw new Error("Unexpected end of ASN.1 input");return t},as=e=>{const t=ss(e);if(128&t){const n=127&t;let o=0;for(let t=0;t<n;t++)o=o<<8|ss(e);return o}return t},cs=(e,t,n)=>{if(ss(e)!==t)throw new Error(n)},us=(e,t)=>{if(t<0||e.pos+t>e.data.length)throw new Error("Unexpected end of ASN.1 input");const n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n};const ls=e=>{const t=(e=>{cs(e,6,"Expected algorithm OID");const t=as(e);return us(e,t)})(e);if(rs(t,[43,101,110]))return "X25519";if(!rs(t,[42,134,72,206,61,2,1]))throw new Error("Unsupported key algorithm");cs(e,6,"Expected curve OID");const n=as(e),o=us(e,n);if(rs(o,[42,134,72,206,61,3,1,7]))return "P-256";if(rs(o,[43,129,4,0,34]))return "P-384";if(rs(o,[43,129,4,0,35]))return "P-521";throw new Error("Unsupported named curve")},ds=async(e,t,n,o)=>{const i=function(e){if(void 0!==e&&"boolean"!=typeof e)throw new TypeError('"extractable" option must be a boolean');return e}(null==o?void 0:o.extractable),r=function(e,t){var n,o;return null!==(n="string"==typeof e?null!==(o=xr[e])&&void 0!==o?o:Ii[e]:void 0)&&void 0!==n?n:is(t)}(n,os);r.secret&&is(os);const s="spki"===e;let a;if(r.resolve)try{const n={data:t,pos:0};!function(e,t){if(cs(e,48,"Invalid ".concat("spki"===t?"SPKI":"PKCS#8"," structure")),as(e),"pkcs8"===t){cs(e,2,"Expected version field");const t=as(e);e.pos+=t;}cs(e,48,"Expected algorithm identifier"),as(e);}(n,e),a=r.resolve({crv:ls(n)});}catch(e){throw new Vo("Invalid or unsupported key format")}else a=r.subtle;return crypto.subtle.importKey(e,t,a,null!=i?i:s,r.usages[s?0:1])},hs=(e,t,n)=>{const o=((e,t)=>ni(e.replace(t,"")))(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);return ds("pkcs8",o,t,n)};async function ps(e,t,n){const o=e.get(t)||e.set(t,{}).get(t),i=n.alg;if(void 0===o[i]){const e=await ui(n,f(f({},t),{},{alg:i,ext:!0}));if("public"!==e.type)throw new Yo("JSON Web Key Set members must be public keys");o[i]=e;}return o[i]}function fs(e){let t;try{t=structuredClone(e);}catch(e){}if(!ai(t))throw new Yo("JSON Web Key Set malformed");const n=new WeakMap;return Object.defineProperty(async(e,o)=>{const i=f(f({},e),null==o?void 0:o.header),r=i.alg,a=i.kid,c="string"==typeof r?xr[r]:void 0;if(!c||c.secret)throw new Vo('Unsupported "alg" value for a JSON Web Key Set');const u=t.keys.filter(e=>function(e,t,n,o){const i=li(e),r=i.kty,s=i.key_ops,a=i.ext,c=i.kid,u=i.alg,l=i.use,d=i.crv,h=Array.isArray(s)?[...s]:s;return (void 0===a||"boolean"==typeof a)&&(void 0===h||Array.isArray(h)&&h.every((e,t)=>"string"==typeof e&&h.indexOf(e)===t)&&h.includes("verify"))&&t.kty.includes(r)&&(void 0===o||"string"==typeof o&&o===c)&&(void 0===u?"AKP"!==r:n===u)&&(void 0===l||"sig"===l)&&(!t.crv||d===t.crv)}(e,c,r,a)),l=u[0],d=u.length;if(!d)throw new qo;if(1!==d){const e=new Bo;throw e[Symbol.asyncIterator]=w(function*(){for(const e of u)try{yield yield s(ps(n,e,c));}catch(e){}}),e}return ps(n,l,c)},"jwks",{value:()=>structuredClone(t)})}var ms,ys;let ws;if("undefined"==typeof navigator||null===(ms=navigator.userAgent)||void 0===ms||null===(ys=ms.startsWith)||void 0===ys||!ys.call(ms,"Mozilla/5.0 ")){const e="v6.2.10";ws="".concat("jose","/").concat(e);}const gs=Symbol();const vs=Symbol();function bs(e,t){return Number.isFinite(e)&&Date.now()<e+t}function _s(e,t,n){if(Number.isNaN(e))throw new TypeError('"'.concat(n,'" option must not be NaN'));return "number"==typeof e?e:t}function ks(e,t){if(!(e instanceof URL))throw new TypeError("url must be an instance of URL");const n=new URL(e.href).href,o=null!=t?t:{},i=o.timeoutDuration;if("number"==typeof i&&(!Number.isInteger(i)||i<0))throw new TypeError('"timeoutDuration" option must be a non-negative integer');const r="number"==typeof i?i:5e3,s=_s(o.cooldownDuration,3e4,"cooldownDuration"),a=_s(o.cacheMaxAge,6e5,"cacheMaxAge"),c=new Headers(o.headers);ws&&!c.has("User-Agent")&&c.set("User-Agent",ws),c.has("accept")||c.set("accept","application/json, application/jwk-set+json");const u=o[gs],l=o[vs];let d,h,p,f=0,m=0;if(l&&"object"==typeof l){const e=l.uat,t=l.jwks;bs(e,a)&&ai(t)&&(d=e,p=fs(t));}const y=async()=>{if(h&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(h=void 0),!h){const e=++f,t=h=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:fetch;const i=await o(e,{method:"GET",signal:n,redirect:"manual",headers:t}).catch(e=>{if("TimeoutError"===e.name)throw new Qo;throw e});if(200!==i.status)throw new Do("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch(e){throw new Do("Failed to parse the JSON Web Key Set HTTP response as JSON")}}(n,c,AbortSignal.timeout(r),u).then(t=>{const n=fs(t);if(e<=m)return;p=n;const o=Date.now();l&&(l.uat=o,l.jwks=t),d=o,m=e;}).finally(()=>{h===t&&(h=void 0);});}await h;};return Object.defineProperties(async(e,t)=>{p&&bs(d,a)||await y();try{return await p(e,t)}catch(n){if(n instanceof qo&&!bs(d,s))return await y(),p(e,t);throw n}},{coolingDown:{get:()=>bs(d,s),enumerable:!0},fresh:{get:()=>bs(d,a),enumerable:!0},reload:{value:y,enumerable:!0},reloading:{get:()=>!!h,enumerable:!0},jwks:{value:()=>{var e;return null===(e=p)||void 0===e?void 0:e.jwks()},enumerable:!0}})}async function Ss(e,t,n){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return hs(e,t,n)}const Ts=["mfaToken"],Ps=["mfaToken"];var Es,Rs,Cs,xs,Is,As,Os,js,Ws,Ns,Us,Ks,Ls,Ms,zs,Js,Ds,Zs,Hs,Fs,Vs,Xs,Gs,Ys,qs,Bs,Qs,$s,ea,ta,na,oa,ia,ra,sa,aa,ca,ua,la,da,ha,pa,fa;function ma(e){if("object"!=typeof e||null===e)return {};const t=e;return {statusCode:"number"==typeof t.statusCode?t.statusCode:void 0,headers:t.headers instanceof Headers?t.headers:void 0,body:"string"==typeof t.body?t.body:void 0}}function ya(e){var t,n;if("object"!=typeof e||null===e)return {error:"unknown_error",error_description:String(e)};const o=e;let i;if(o.response instanceof Response)try{i=new Headers(o.response.headers),i.delete("set-cookie");}catch(e){i=void 0;}const r={error:null!==(t=o.error)&&void 0!==t?t:"",error_description:null!==(n=o.error_description)&&void 0!==n?n:"",message:o.message,statusCode:"number"==typeof o.status?o.status:void 0,headers:i};if("mfa_required"===o.error&&o.cause){r.mfa_token="string"==typeof o.cause.mfa_token?o.cause.mfa_token:void 0;const e=o.cause.mfa_requirements;"object"==typeof e&&null!==e&&(r.mfa_requirements=e);}return r}var wa=class extends Error{constructor(e,t){super(t),h(this,"code",void 0),this.name="NotSupportedError",this.code=e;}},ga=class extends Error{constructor(e,t,n){super(t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"statusCode",void 0),h(this,"headers",void 0),h(this,"body",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements};const o=ma(n);this.statusCode=o.statusCode,this.headers=o.headers,this.body=o.body;}},va=class extends ga{constructor(e,t){super("token_by_code_error",e,t),this.name="TokenByCodeError";}},ba=class extends ga{constructor(e,t){super("token_by_client_credentials_error",e,t),this.name="TokenByClientCredentialsError";}},_a=class extends ga{constructor(e,t){super("token_by_refresh_token_error",e,t),this.name="TokenByRefreshTokenError";}},ka=class extends ga{constructor(e,t){super("token_by_password_error",e,t),this.name="TokenByPasswordError";}},Sa=class extends ga{constructor(e,t){super("token_for_connection_error",e,t),this.name="TokenForConnectionErrorCode";}},Ta=class extends ga{constructor(e,t){super("token_exchange_error",e,t),this.name="TokenExchangeError";}},Pa=class extends ga{constructor(e,t){super("token_revocation_error",e,t),this.name="TokenRevocationError";}},Ea=class extends ga{constructor(e,t){super("user_info_error",e,t),this.name="UserInfoError";}},Ra=class extends Error{constructor(e){super(e),h(this,"code","verify_logout_token_error"),this.name="VerifyLogoutTokenError";}},Ca=class extends ga{constructor(e){super("backchannel_authentication_error","There was an error when trying to use Client-Initiated Backchannel Authentication.",e),h(this,"code","backchannel_authentication_error"),this.name="BackchannelAuthenticationError";}},xa=class extends ga{constructor(e){super("build_authorization_url_error","There was an error when trying to build the authorization URL.",e),this.name="BuildAuthorizationUrlError";}},Ia=class extends ga{constructor(e){super("build_link_user_url_error","There was an error when trying to build the Link User URL.",e),this.name="BuildLinkUserUrlError";}},Aa=class extends ga{constructor(e){super("build_unlink_user_url_error","There was an error when trying to build the Unlink User URL.",e),this.name="BuildUnlinkUserUrlError";}},Oa=class extends Error{constructor(){super("The client secret or client assertion signing key must be provided."),h(this,"code","missing_client_auth_error"),this.name="MissingClientAuthError";}},ja=class extends Error{constructor(e){super(e),h(this,"code","organization_validation_error"),this.name="OrganizationValidationError";}},Wa=class extends Error{constructor(e){super(e||"fullResponse: true requested but no HTTP Response was captured. This is a bug in CapturingFetch."),h(this,"code","missing_captured_response_error"),this.name="MissingCapturedResponseError";}};function Na(e){try{const t=new Headers(e);return t.delete("set-cookie"),t}catch(e){return new Headers}}function Ua(e,t,n){var o;const i="object"==typeof t&&null!==t?t:void 0,r=null!==(o=null==i?void 0:i.response)&&void 0!==o?o:n,s="number"==typeof(null==i?void 0:i.status)?i.status:null==r?void 0:r.status;"number"==typeof s&&(e.statusCode=s),null!=r&&r.headers&&(e.headers=Na(r.headers));}function Ka(e){return Object.entries(e).filter(e=>void 0!==y(e,2)[1]).reduce((e,t)=>f(f({},e),{},{[t[0]]:t[1]}),{})}function La(e){if(!e.trim())throw new ja("organization must not be blank")}function Ma(e,t){if(!e)return;const n=t.trim();if(n.startsWith("org_")){const t=e.org_id;if("string"!=typeof t)throw new ja("Organization Id (org_id) claim must be a string present in the ID token");if(t!==n)throw new ja('Organization Id (org_id) claim value mismatch in the ID token; expected "'.concat(n,'", found "').concat(t,'"'))}else {const t=e.org_name;if("string"!=typeof t)throw new ja("Organization Name (org_name) claim must be a string present in the ID token");if(t.toLowerCase()!==n.toLowerCase())throw new ja('Organization Name (org_name) claim value mismatch in the ID token; expected "'.concat(n,'", found "').concat(t,'"'))}}var za=class extends Error{constructor(e,t,n){super(t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"statusCode",void 0),h(this,"headers",void 0),h(this,"body",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};const o=ma(n);this.statusCode=o.statusCode,this.headers=o.headers,this.body=o.body;}},Ja=class extends za{constructor(e,t){super("mfa_list_authenticators_error",e,t),this.name="MfaListAuthenticatorsError";}},Da=class extends za{constructor(e,t){super("mfa_enrollment_error",e,t),this.name="MfaEnrollmentError";}},Za=class extends za{constructor(e,t){super("mfa_delete_authenticator_error",e,t),this.name="MfaDeleteAuthenticatorError";}},Ha=class extends za{constructor(e,t){super("mfa_challenge_error",e,t),this.name="MfaChallengeError";}},Fa=class extends za{constructor(e,t){super("mfa_verify_error",e,t),this.name="MfaVerifyError";}};function Va(e){return {id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var Xa=class e{constructor(e,t,n,o,i,r,s){h(this,"accessToken",void 0),h(this,"idToken",void 0),h(this,"refreshToken",void 0),h(this,"expiresAt",void 0),h(this,"scope",void 0),h(this,"claims",void 0),h(this,"authorizationDetails",void 0),h(this,"tokenType",void 0),h(this,"issuedTokenType",void 0),h(this,"recoveryCode",void 0),h(this,"act",void 0),this.accessToken=e,this.idToken=n,this.refreshToken=o,this.expiresAt=t,this.scope=i,this.claims=r,this.authorizationDetails=s;}static fromTokenEndpointResponse(t){const n=t.id_token?t.claims():void 0,o=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 o.tokenType=t.token_type,o.issuedTokenType=t.issued_token_type,o}};function Ga(e,t){if(!1===t.enabled)return e;const n={name:t.name,version:t.version},o=btoa(JSON.stringify(n));return async(t,n)=>{const i=t instanceof Request?new Headers(t.headers):new Headers;if(null!=n&&n.headers){new Headers(n.headers).forEach((e,t)=>{i.set(t,e);});}return i.set("Auth0-Client",o),e(t,f(f({},n),{},{headers:i}))}}function Ya(e){var t,n;return !1===(null==e?void 0:e.enabled)?e:{enabled:!0,name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"@auth0/auth0-auth-js",version:null!==(n=null==e?void 0:e.version)&&void 0!==n?n:"1.13.0"}}function qa(e){let t;const n=async(n,o)=>{const i=await e(n,o);return t=i.clone(),i};return n.getCapturedResponse=()=>t,n}function Ba(e,t,n){if(!t)return e;const o=t.signal,i=t.headers,r=t.customFetch,s=r?Ga(r,n):e;return o||i?async(e,t)=>{const n=i?new Headers(e instanceof Request?e.headers:void 0):void 0;if(n&&null!=t&&t.headers&&new Headers(t.headers).forEach((e,t)=>n.set(t,e)),i)for(const e of Object.entries(i)){var r=y(e,2);const t=r[0],o=r[1],i=t.toLowerCase();"authorization"!==i&&"auth0-client"!==i&&n.set(t,o);}const a=function(e,t){if(!e)return {signal:null!=t?t:void 0};if(!t)return {signal:e};if("undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.any)return {signal:AbortSignal.any([e,t])};const n=new AbortController,o=[e,t],i=o.find(e=>e.aborted);if(i)return n.abort(i.reason),{signal:n.signal};const r=[],s=()=>{o.forEach((e,t)=>{const n=r[t];n&&e.removeEventListener("abort",n);});};return o.forEach((e,t)=>{const o=()=>{s(),n.abort(e.reason);};r[t]=o,e.addEventListener("abort",o,{once:!0});}),{signal:n.signal,cleanup:s}}(o,null==t?void 0:t.signal);try{return await s(e,f(f(f({},t),n&&{headers:n}),{},{signal:a.signal}))}finally{var c;null===(c=a.cleanup)||void 0===c||c.call(a);}}:s}var Qa={otp:"http://auth0.com/oauth/grant-type/mfa-otp",oob:"http://auth0.com/oauth/grant-type/mfa-oob","recovery-code":"http://auth0.com/oauth/grant-type/mfa-recovery-code"},$a=(Es=new WeakMap,Rs=new WeakMap,Cs=new WeakMap,xs=new WeakMap,Is=new WeakMap,As=new WeakMap,Os=new WeakMap,js=new WeakSet,class{constructor(e){var t,n;d(this,js),u(this,Es,void 0),u(this,Rs,void 0),u(this,Cs,void 0),u(this,xs,void 0),u(this,Is,void 0),u(this,As,void 0),u(this,Os,void 0),l(Es,this,"https://".concat(e.domain)),l(Rs,this,e.clientId),l(Cs,this,e.clientSecret),l(xs,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),l(Is,this,null!==(n=e.telemetryConfig)&&void 0!==n?n:Ya()),l(As,this,e.getConfiguration),l(Os,this,e.createCaptureConfiguration);}async listAuthenticators(e,t){const n="".concat(c(Es,this),"/mfa/authenticators"),o=e.mfaToken,i=await r(js,this,ec).call(this,t)(n,{method:"GET",headers:{Authorization:"Bearer ".concat(o),"Content-Type":"application/json"}});if(!i.ok){const e=await i.clone().text(),t=i.status,n=Na(i.headers);let o;try{o=JSON.parse(e);}catch(o){throw new Ja("Failed to list authenticators",{error:"unknown_error",error_description:"Failed to list authenticators",statusCode:t,headers:n,body:e})}throw new Ja(o.error_description||"Failed to list authenticators",f(f({},o),{},{statusCode:t,headers:n,body:e}))}return (await i.json()).map(Va)}async enrollAuthenticator(e,t){const n="".concat(c(Es,this),"/mfa/associate"),o=e.mfaToken,i=m(e,Ts),s={authenticator_types:i.authenticatorTypes};"oobChannels"in i&&(s.oob_channels=i.oobChannels),"phoneNumber"in i&&i.phoneNumber&&(s.phone_number=i.phoneNumber),"email"in i&&i.email&&(s.email=i.email);const a=await r(js,this,ec).call(this,t)(n,{method:"POST",headers:{Authorization:"Bearer ".concat(o),"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const e=await a.clone().text(),t=a.status,n=Na(a.headers);let o;try{o=JSON.parse(e);}catch(o){throw new Da("Failed to enroll authenticator",{error:"unknown_error",error_description:"Failed to enroll authenticator",statusCode:t,headers:n,body:e})}throw new Da(o.error_description||"Failed to enroll authenticator",f(f({},o),{},{statusCode:t,headers:n,body:e}))}return function(e){if("otp"===e.authenticator_type)return {authenticatorType:"otp",secret:e.secret,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes,id:e.id};if("oob"===e.authenticator_type)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 new Error("Unexpected authenticator type: ".concat(e.authenticator_type))}(await a.json())}async deleteAuthenticator(e,t){const n=e.authenticatorId,o=e.mfaToken,i="".concat(c(Es,this),"/mfa/authenticators/").concat(encodeURIComponent(n)),s=await r(js,this,ec).call(this,t)(i,{method:"DELETE",headers:{Authorization:"Bearer ".concat(o),"Content-Type":"application/json"}});if(!s.ok){const e=await s.clone().text(),t=s.status,n=Na(s.headers);let o;try{o=JSON.parse(e);}catch(o){throw new Za("Failed to delete authenticator",{error:"unknown_error",error_description:"Failed to delete authenticator",statusCode:t,headers:n,body:e})}throw new Za(o.error_description||"Failed to delete authenticator",f(f({},o),{},{statusCode:t,headers:n,body:e}))}}async challengeAuthenticator(e,t){const n="".concat(c(Es,this),"/mfa/challenge"),o=e.mfaToken,i=m(e,Ps),s={mfa_token:o,client_id:c(Rs,this),challenge_type:i.challengeType};c(Cs,this)&&(s.client_secret=c(Cs,this)),i.authenticatorId&&(s.authenticator_id=i.authenticatorId);const a=await r(js,this,ec).call(this,t)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const e=await a.clone().text(),t=a.status,n=Na(a.headers);let o;try{o=JSON.parse(e);}catch(o){throw new Ha("Failed to challenge authenticator",{error:"unknown_error",error_description:"Failed to challenge authenticator",statusCode:t,headers:n,body:e})}throw new Ha(o.error_description||"Failed to challenge authenticator",f(f({},o),{},{statusCode:t,headers:n,body:e}))}return function(e){const t={challengeType:e.challenge_type};return void 0!==e.oob_code&&(t.oobCode=e.oob_code),void 0!==e.binding_method&&(t.bindingMethod=e.binding_method),t}(await a.json())}async verify(e,t){if(!c(As,this))throw new Error("MFA verify requires a configuration provider (getConfiguration was not set)");const n={mfa_token:e.mfaToken};if(e.audience&&(n.audience=e.audience),"otp"===e.factorType?n.otp=e.otp:"oob"===e.factorType?(n.oob_code=e.oobCode,e.bindingCode&&(n.binding_code=e.bindingCode)):"recovery-code"===e.factorType&&(n.recovery_code=e.recoveryCode),e.fullResponse){var o;if(!c(Os,this))throw new Error("MFA verify fullResponse requires a capture-config factory (createCaptureConfiguration was not set)");const a=qa(null!==(o=(await c(As,this).call(this,t))[Vi])&&void 0!==o?o:fetch),u=await c(Os,this).call(this,a);try{const t=await br(u,Qa[e.factorType],n),o=Xa.fromTokenEndpointResponse(t);t.recovery_code&&(o.recoveryCode=t.recovery_code);const i=a.getCapturedResponse();if(!i)throw new Wa;return {data:o,response:i}}catch(e){var i,r,s;if(e instanceof Wa)throw e;if(e instanceof Fa)throw e;const t=e,n=new Fa(t.error_description||t.message||"Failed to verify MFA challenge",{error:null!==(i=t.error)&&void 0!==i?i:"mfa_verify_error",error_description:null!==(r=null!==(s=t.error_description)&&void 0!==s?s:t.message)&&void 0!==r?r:"Failed to verify MFA challenge"});throw Ua(n,e,a.getCapturedResponse()),n}}const a=await c(As,this).call(this,t);try{const t=await br(a,Qa[e.factorType],n),o=Xa.fromTokenEndpointResponse(t);return t.recovery_code&&(o.recoveryCode=t.recovery_code),o}catch(e){var u,l,d;if(e instanceof Fa)throw e;const t=e,n=new Fa(t.error_description||t.message||"Failed to verify MFA challenge",{error:null!==(u=t.error)&&void 0!==u?u:"mfa_verify_error",error_description:null!==(l=null!==(d=t.error_description)&&void 0!==d?d:t.message)&&void 0!==l?l:"Failed to verify MFA challenge"});throw Ua(n,e),n}}});function ec(e){return Ba(c(xs,this),e,c(Is,this))}var tc=class extends Error{constructor(e,t,n){super(t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"statusCode",void 0),h(this,"headers",void 0),h(this,"body",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};const o=ma(n);this.statusCode=o.statusCode,this.headers=o.headers,this.body=o.body;}},nc=class extends tc{constructor(e,t){super("passkey_register_error",e,t),this.name="PasskeyRegisterError";}},oc=class extends tc{constructor(e,t){super("passkey_challenge_error",e,t),this.name="PasskeyChallengeError";}},ic=class extends tc{constructor(e,t){super("passkey_get_token_error",e,t),this.name="PasskeyGetTokenError",this.cause=t&&{error:t.error,error_description:t.error_description,message:t.message,mfa_token:t.mfa_token,mfa_requirements:t.mfa_requirements};}};function rc(e){return e.useMtls?{}:e.clientSecret?{client_secret:e.clientSecret}:{}}var sc="urn:okta:params:oauth:grant-type:webauthn",ac=(Ws=new WeakMap,Ns=new WeakMap,Us=new WeakMap,Ks=new WeakMap,Ls=new WeakMap,Ms=new WeakMap,zs=new WeakSet,class{constructor(e){var t,n;d(this,zs),u(this,Ws,void 0),u(this,Ns,void 0),u(this,Us,void 0),u(this,Ks,void 0),u(this,Ls,void 0),u(this,Ms,void 0),l(Ws,this,"https://".concat(e.domain)),l(Ns,this,e.clientId),l(Us,this,{clientSecret:e.clientSecret,useMtls:e.useMtls}),l(Ks,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),l(Ls,this,null!==(n=e.telemetryConfig)&&void 0!==n?n:Ya()),l(Ms,this,e.grantRequest);}async register(e,t){const n="".concat(c(Ws,this),"/passkey/register"),o=f(f(f(f(f(f(f(f({},e.email&&{email:e.email}),e.name&&{name:e.name}),e.phoneNumber&&{phone_number:e.phoneNumber}),e.username&&{username:e.username}),e.givenName&&{given_name:e.givenName}),e.familyName&&{family_name:e.familyName}),e.nickname&&{nickname:e.nickname}),e.picture&&{picture:e.picture}),i=f(f({client_id:c(Ns,this)},rc(c(Us,this))),{},{user_profile:o});e.realm&&(i.realm=e.realm),e.organization&&(i.organization=e.organization),e.userMetadata&&(i.user_metadata=e.userMetadata);const s=await r(zs,this,cc).call(this,t)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok){const e=await r(zs,this,uc).call(this,s),t=new nc(e.error_description||"Failed to request signup challenge",e);throw t.statusCode=s.status,t.headers=Na(s.headers),t}const a=await s.json();return {authSession:(u=a).auth_session,authnParamsPublicKey:f({},u.authn_params_public_key)};var u;}async challenge(e,t){const n="".concat(c(Ws,this),"/passkey/challenge"),o=f({client_id:c(Ns,this)},rc(c(Us,this)));null!=e&&e.realm&&(o.realm=e.realm),null!=e&&e.organization&&(o.organization=e.organization);const i=await r(zs,this,cc).call(this,t)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok){const e=await r(zs,this,uc).call(this,i),t=new oc(e.error_description||"Failed to request login challenge",e);throw t.statusCode=i.status,t.headers=Na(i.headers),t}const s=await i.json();return {authSession:(a=s).auth_session,authnParamsPublicKey:f({},a.authn_params_public_key)};var a;}async getTokenByPasskey(e,t){void 0!==e.organization&&La(e.organization);const n=new URLSearchParams({auth_session:e.authSession,authn_response:JSON.stringify(e.credential)});let o;e.realm&&n.append("realm",e.realm),e.scope&&n.append("scope",e.scope),e.audience&&n.append("audience",e.audience),e.organization&&n.append("organization",e.organization);try{o=await c(Ms,this).call(this,sc,n,t,e.fullResponse);}catch(e){if(e instanceof Wa)throw e;const t=ya(e),n=new ic(t.error_description||"Failed to exchange passkey credential for tokens.",t);throw Ua(n,e),n}if(e.fullResponse){const t=o;return e.organization&&Ma(t.data.claims,e.organization),t}const i=o;return e.organization&&Ma(i.claims,e.organization),i}});function cc(e){return Ba(c(Ks,this),e,c(Ls,this))}async function uc(e){const t=await e.clone().text();try{return f(f({},JSON.parse(t)),{},{statusCode:e.status,headers:e.headers,body:t})}catch(n){return {error:"unknown_error",error_description:"HTTP ".concat(e.status," ").concat(e.statusText),statusCode:e.status,headers:e.headers,body:t}}}var lc=class extends Error{constructor(e,t,n){super(t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"statusCode",void 0),h(this,"headers",void 0),h(this,"body",void 0),Object.setPrototypeOf(this,new.target.prototype),this.code=e,this.cause=n&&(n.error||n.error_description)?{error:n.error,error_description:n.error_description,message:n.message,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements}:void 0;const o=ma(n);this.statusCode=o.statusCode,this.headers=o.headers,this.body=o.body;}},dc=class extends lc{constructor(e,t){super("passwordless_start_error",e,t),this.name="PasswordlessStartError";}},hc=class extends lc{constructor(e,t){super("passwordless_verify_error",e,t),this.name="PasswordlessVerifyError";}},pc=class extends lc{constructor(e,t){super("passwordless_db_get_token_error",e,t),this.name="PasswordlessDbGetTokenError";}},fc=class extends lc{constructor(e,t,n,o,i){super("passwordless_challenge_error",e,n),h(this,"statusCode",void 0),h(this,"validationErrors",void 0),this.name="PasswordlessChallengeError",this.statusCode=t,this.validationErrors=o,this.headers=null!=i?i:this.headers;}};function mc(e){return /^\+[1-9]\d{1,14}$/.test(e)}async function yc(e,t,n){if(e.useMtls)return {};if(e.clientAssertionSigningKey){var o;const i=null!==(o=e.clientAssertionSigningAlg)&&void 0!==o?o:"RS256",r=e.clientAssertionSigningKey instanceof CryptoKey?e.clientAssertionSigningKey:await Ss(e.clientAssertionSigningKey,i);return {client_assertion:await new ns({}).setProtectedHeader({alg:i}).setIssuer(t).setSubject(t).setAudience("https://".concat(n,"/")).setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime("".concat(120,"s")).sign(r),client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}}if(e.clientSecret)return {client_secret:e.clientSecret};throw new Oa}var wc=(Js=new WeakMap,Ds=new WeakMap,Zs=new WeakMap,Hs=new WeakMap,Fs=new WeakMap,Vs=new WeakMap,Xs=new WeakMap,Gs=new WeakSet,class{constructor(e){var t,n;d(this,Gs),u(this,Js,void 0),u(this,Ds,void 0),u(this,Zs,void 0),u(this,Hs,void 0),u(this,Fs,void 0),u(this,Vs,void 0),u(this,Xs,void 0),l(Ds,this,e.domain),l(Js,this,"https://".concat(e.domain)),l(Zs,this,e.clientId),l(Hs,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),l(Fs,this,null!==(n=e.telemetryConfig)&&void 0!==n?n:Ya()),l(Vs,this,{clientSecret:e.clientSecret,clientAssertionSigningKey:e.clientAssertionSigningKey,clientAssertionSigningAlg:e.clientAssertionSigningAlg,useMtls:e.useMtls}),l(Xs,this,e.grantRequest);}async sendEmail(e,t){const n=await r(Gs,this,vc).call(this,function(e){var t;const n=null!==(t=e.send)&&void 0!==t?t:"code",o={email:e.email,connection:"email",send:n};return "link"===n&&e.authParams&&(o.authParams=e.authParams),o}(e),"Failed to send passwordless email",e.language,t);if(e.fullResponse)return {data:void 0,response:n}}async sendSms(e,t){if(!mc(e.phoneNumber))throw new dc("Phone number must be in E.164 format (e.g. +14155550100).");const n=await r(Gs,this,vc).call(this,function(e){return {phone_number:e.phoneNumber,connection:"sms"}}(e),"Failed to send passwordless SMS",e.language,t);if(e.fullResponse)return {data:void 0,response:n}}async challengeWithEmail(e,t){const n=function(e){var t;return {email:e.email,connection:e.connection,allow_signup:null!==(t=e.allowSignup)&&void 0!==t&&t}}(e);return r(Gs,this,bc).call(this,n,"Failed to request email OTP challenge",t)}async challengeWithPhoneNumber(e,t){if(!mc(e.phoneNumber))throw new fc("Phone number must be in E.164 format (e.g. +14155550100).",0,void 0,void 0);const n=function(e){var t;const n={phone_number:e.phoneNumber,connection:e.connection,allow_signup:null!==(t=e.allowSignup)&&void 0!==t&&t};return e.deliveryMethod&&(n.delivery_method=e.deliveryMethod),n}(e);return r(Gs,this,bc).call(this,n,"Failed to request phone OTP challenge",t)}async getTokenByPasswordlessDbConnection(e,t){const n=new URLSearchParams({auth_session:e.authSession,otp:e.otp});if(e.scope&&n.append("scope",e.scope),e.audience&&n.append("audience",e.audience),!c(Xs,this))throw new pc("Missing grant request delegate.",ya(new Error("missing grantRequest")));try{return await c(Xs,this).call(this,"http://auth0.com/oauth/grant-type/passwordless/otp",n,t,e.fullResponse)}catch(e){if(e instanceof Wa)throw e;const t=new pc("There was an error while trying to request a token.",ya(e)),n=e;throw t.statusCode=n._statusCode,t.headers=n._headers,t}}});function gc(e){return Ba(c(Hs,this),e,c(Fs,this))}async function vc(e,t,n,o){var i;const s=await yc(c(Vs,this),c(Zs,this),c(Ds,this)),a=f(f({client_id:c(Zs,this)},e),s);let u;try{u=await r(Gs,this,gc).call(this,o)("".concat(c(Js,this),"/passwordless/start"),{method:"POST",headers:f({"Content-Type":"application/json"},n?{"x-request-language":n}:{}),body:JSON.stringify(a)});}catch(e){throw new dc("".concat(t,": a network error occurred."))}if(u.ok)return u;const l=await u.clone().text();let d;if(204!==u.status)try{d=JSON.parse(l);}catch(e){d=void 0;}const h=new dc((null===(i=d)||void 0===i?void 0:i.error_description)||t,d);throw h.statusCode=u.status,h.headers=Na(u.headers),h.body=l,h}async function bc(e,t,n){var o,i;const s=await yc(c(Vs,this),c(Zs,this),c(Ds,this)),a=f(f({client_id:c(Zs,this)},e),s);let u;try{u=await r(Gs,this,gc).call(this,n)("".concat(c(Js,this),"/otp/challenge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});}catch(e){throw new fc("challenge error: a network error occurred.",0,void 0,void 0)}if(u.ok){let e;try{e=await u.json();}catch(e){throw new fc("".concat(t,": could not parse the response body."),u.status,void 0,void 0,Na(u.headers))}return {authSession:e.auth_session}}const l=await u.clone().text();let d;try{d=JSON.parse(l);}catch(e){d=void 0;}const h=d?f(f({},d),{},{statusCode:u.status,headers:u.headers,body:l}):{error:"",error_description:"",statusCode:u.status,headers:u.headers,body:l};throw new fc((null===(o=d)||void 0===o?void 0:o.error_description)||t,u.status,h,null===(i=d)||void 0===i?void 0:i.validation_errors,Na(u.headers))}var _c=class extends Error{constructor(e,t,n){super(t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"statusCode",void 0),h(this,"headers",void 0),h(this,"body",void 0),Object.setPrototypeOf(this,new.target.prototype),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};const o=ma(n);this.statusCode=o.statusCode,this.headers=o.headers,this.body=o.body;}},kc=class extends _c{constructor(e,t){super("signup_error",e,t),this.name="SignUpError";}},Sc=class extends _c{constructor(e,t){super("change_password_error",e,t),this.name="ChangePasswordError";}};function Tc(e,t,n){for(const o of t)if(null===e[o]||void 0===e[o]||""===e[o])throw new n('Required parameter "'.concat(String(o),'" was null, undefined, or empty.'))}function Pc(e){var t,n;return {id:null!==(t=null!==(n=e._id)&&void 0!==n?n:e.user_id)&&void 0!==t?t:e.id,email:"string"==typeof e.email?e.email:"",emailVerified:Boolean(e.email_verified),username:e.username,givenName:e.given_name,familyName:e.family_name,name:e.name,nickname:e.nickname,picture:e.picture,userMetadata:e.user_metadata}}var Ec=(Ys=new WeakMap,qs=new WeakMap,Bs=new WeakMap,Qs=new WeakMap,$s=new WeakSet,class{constructor(e){var t,n;d(this,$s),u(this,Ys,void 0),u(this,qs,void 0),u(this,Bs,void 0),u(this,Qs,void 0),l(Ys,this,"https://".concat(e.domain)),l(qs,this,e.clientId),l(Bs,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),l(Qs,this,null!==(n=e.telemetryConfig)&&void 0!==n?n:Ya());}async signUp(e,t){var n;Tc(e,["email","password","connection"],kc);const o=f({client_id:null!==(n=e.clientId)&&void 0!==n?n:c(qs,this)},function(e){const t={email:e.email,password:e.password,connection:e.connection};return void 0!==e.username&&(t.username=e.username),void 0!==e.givenName&&(t.given_name=e.givenName),void 0!==e.familyName&&(t.family_name=e.familyName),void 0!==e.name&&(t.name=e.name),void 0!==e.nickname&&(t.nickname=e.nickname),void 0!==e.picture&&(t.picture=e.picture),void 0!==e.userMetadata&&(t.user_metadata=e.userMetadata),t}(e)),i=await r($s,this,Rc).call(this,"/dbconnections/signup",o,kc,"Failed to sign up",t);if(e.fullResponse){const e=i.clone();return {data:Pc(await i.json()),response:e}}return Pc(await i.json())}async changePassword(e,t){var n;if(Tc(e,["connection"],Sc),!e.email&&!e.username)throw new Sc('Either "email" or "username" is required.');const o=f({client_id:null!==(n=e.clientId)&&void 0!==n?n:c(qs,this)},function(e){const t={connection:e.connection};return void 0!==e.email&&(t.email=e.email),void 0!==e.username&&(t.username=e.username),void 0!==e.organization&&(t.organization=e.organization),t}(e)),i=await r($s,this,Rc).call(this,"/dbconnections/change_password",o,Sc,"Failed to request a password change",t);if(e.fullResponse){const e=i.clone();return {data:await i.text(),response:e}}return i.text()}});async function Rc(e,t,n,o,i){const r=Ba(c(Bs,this),i,c(Qs,this));let s;try{s=await r("".concat(c(Ys,this)).concat(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});}catch(e){throw new n("".concat(o,": a network error occurred."))}if(s.ok)return s;const a=await s.clone().text(),u=await async function(e){let t;try{t=await e.json();}catch(e){return}return "string"==typeof t.error?t:"string"==typeof t.code?{error:t.code,error_description:"string"==typeof t.description?t.description:""}:void 0}(s.clone()),l=new n((null==u?void 0:u.error_description)||o,null!=u?u:{error:"unknown_error",error_description:o});throw l.statusCode=s.status,l.headers=Na(s.headers),l.body=a,l}var Cc=(ea=new WeakMap,ta=new WeakMap,na=new WeakMap,class{constructor(e,t){u(this,ea,new Map),u(this,ta,void 0),u(this,na,void 0),l(na,this,Math.max(1,Math.floor(e))),l(ta,this,Math.max(0,Math.floor(t)));}get(e){const t=c(ea,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return c(ea,this).delete(e),c(ea,this).set(e,t),t.value;c(ea,this).delete(e);}}set(e,t){for(c(ea,this).has(e)&&c(ea,this).delete(e),c(ea,this).set(e,{value:t,expiresAt:Date.now()+c(ta,this)});c(ea,this).size>c(na,this);){const e=c(ea,this).keys().next().value;if(void 0===e)break;c(ea,this).delete(e);}}}),xc=new Map;function Ic(e){return {ttlMs:1e3*("number"==typeof(null==e?void 0:e.ttl)?e.ttl:600),maxEntries:"number"==typeof(null==e?void 0:e.maxEntries)&&e.maxEntries>0?e.maxEntries:100}}var Ac=class{static createDiscoveryCache(e){const t=(n=e.maxEntries,o=e.ttlMs,"".concat(n,":").concat(o));var n,o;let i=(r=t,xc.get(r));var r;return i||(i=new Cc(e.maxEntries,e.ttlMs),xc.set(t,i)),i}static createJwksCache(){return {}}},Oc="openid profile email offline_access",jc=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 Wc(e){if(null==e)throw new Ta("subject_token is required");if("string"!=typeof e)throw new Ta("subject_token must be a string");if(0===e.trim().length)throw new Ta("subject_token cannot be blank or whitespace");if(e!==e.trim())throw new Ta("subject_token must not include leading or trailing whitespace");if(/^bearer\s+/i.test(e))throw new Ta("subject_token must not include the 'Bearer ' prefix")}function Nc(e,t){if(t)for(const o of Object.entries(t)){var n=y(o,2);const t=n[0],i=n[1];if(!jc.has(t))if(Array.isArray(i)){if(i.length>20)throw new Ta("Parameter '".concat(t,"' exceeds maximum array size of ").concat(20));i.forEach(n=>{e.append(t,n);});}else e.append(t,i);}}var Uc="urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",Kc="urn:ietf:params:oauth:grant-type:token-exchange",Lc="urn:ietf:params:oauth:token-type:access_token";function Mc(e,t){return (n,o)=>{const i=null==o?void 0:o.body;if(t!==sc||!(i instanceof URLSearchParams))return e(n,o);const r={};for(const e of i){var s=y(e,2);const t=s[0],n=s[1];r[t]="authn_response"===t?JSON.parse(n):n;}const a=new Headers(null==o?void 0:o.headers);return a.set("Content-Type","application/json"),e(n,f(f({},o),{},{headers:a,body:JSON.stringify(r)}))}}var zc=(oa=new WeakMap,ia=new WeakMap,ra=new WeakMap,sa=new WeakMap,aa=new WeakMap,ca=new WeakMap,ua=new WeakMap,la=new WeakMap,da=new WeakMap,ha=new WeakMap,pa=new WeakMap,fa=new WeakSet,class{constructor(e){var t;if(d(this,fa),u(this,oa,void 0),u(this,ia,void 0),u(this,ra,void 0),u(this,sa,void 0),u(this,aa,void 0),u(this,ca,void 0),u(this,ua,void 0),u(this,la,void 0),u(this,da,void 0),u(this,ha,void 0),u(this,pa,void 0),h(this,"mfa",void 0),h(this,"passkey",void 0),h(this,"passwordless",void 0),h(this,"database",void 0),l(aa,this,e),e.useMtls&&!e.customFetch)throw new wa("mtls_without_custom_fetch_not_supported","Using mTLS without a custom fetch implementation is not supported");l(ua,this,Ya(e.telemetry)),l(ca,this,Ga(null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)},c(ua,this)));const n=Ic(e.discoveryCache);l(da,this,Ac.createDiscoveryCache(n)),l(ha,this,new Map),l(pa,this,Ac.createJwksCache()),this.mfa=new $a({domain:c(aa,this).domain,clientId:c(aa,this).clientId,clientSecret:c(aa,this).clientSecret,customFetch:c(ca,this),telemetryConfig:c(ua,this),getConfiguration:async e=>(await r(fa,this,Hc).call(this,e)).configuration,createCaptureConfiguration:async e=>{const t=(await r(fa,this,Fc).call(this)).serverMetadata;return r(fa,this,Dc).call(this,t,e)}}),this.passkey=new ac({domain:c(aa,this).domain,clientId:c(aa,this).clientId,clientSecret:c(aa,this).clientSecret,useMtls:c(aa,this).useMtls,customFetch:c(ca,this),telemetryConfig:c(ua,this),grantRequest:async(e,t,n,o)=>{const i=(await r(fa,this,Fc).call(this)).serverMetadata,s=r(fa,this,Zc).call(this,n);if(o){const n=qa(s),o=await r(fa,this,Dc).call(this,i,n);o[Vi]=Mc(n,e);const a=await br(o,e,t),c=Xa.fromTokenEndpointResponse(a),u=n.getCapturedResponse();if(!u)throw new Wa;return {data:c,response:u}}const a=await r(fa,this,Dc).call(this,i);a[Vi]=Mc(s,e);const c=await br(a,e,t);return Xa.fromTokenEndpointResponse(c)}}),this.passwordless=new wc({domain:c(aa,this).domain,clientId:c(aa,this).clientId,customFetch:c(ca,this),telemetryConfig:c(ua,this),clientSecret:c(aa,this).clientSecret,clientAssertionSigningKey:c(aa,this).clientAssertionSigningKey,clientAssertionSigningAlg:c(aa,this).clientAssertionSigningAlg,useMtls:c(aa,this).useMtls,grantRequest:async(e,t,n,o)=>{const i=(await r(fa,this,Hc).call(this,n)).configuration;if(o){var s;const n=qa(null!==(s=i[Vi])&&void 0!==s?s:c(ca,this)),o=await r(fa,this,Dc).call(this,i.serverMetadata(),n),a=await br(o,e,t),u=Xa.fromTokenEndpointResponse(a),l=n.getCapturedResponse();if(!l)throw new Wa;return {data:u,response:l}}try{const n=await br(i,e,t);return Xa.fromTokenEndpointResponse(n)}catch(e){const t=e,n={};throw Ua(n,e),t._statusCode=n.statusCode,t._headers=n.headers,e}}}),this.database=new Ec({domain:c(aa,this).domain,clientId:c(aa,this).clientId,customFetch:c(ca,this),telemetryConfig:c(ua,this)});}async getServerMetadata(){return (await r(fa,this,Fc).call(this)).serverMetadata}async buildAuthorizationUrl(e){const t=(await r(fa,this,Fc).call(this)).serverMetadata;if(null!=e&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new wa("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 r(fa,this,Qc).call(this,e)}catch(e){throw new xa(e)}}async buildLinkUserUrl(e){try{const t=await r(fa,this,Qc).call(this,{authorizationParams:f(f({},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 Ia(e)}}async buildUnlinkUserUrl(e){try{const t=await r(fa,this,Qc).call(this,{authorizationParams:f(f({},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 Aa(e)}}async backchannelAuthentication(e,t){var n;const o=await r(fa,this,Hc).call(this,t),i=o.configuration,s=o.serverMetadata,a=Ka(f(f({},c(aa,this).authorizationParams),null==e?void 0:e.authorizationParams)),u=new URLSearchParams(f(f({scope:Oc},a),{},{client_id:c(aa,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:s.issuer,sub:e.loginHint.sub})}));if(e.requestedExpiry&&u.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&u.append("authorization_details",JSON.stringify(e.authorizationDetails)),e.fullResponse){var l;const e=qa(null!==(l=i[Vi])&&void 0!==l?l:c(ca,this)),t=await r(fa,this,Dc).call(this,i.serverMetadata(),e);try{const n=await ar(i,u),o=await cr(t,n),r=e.getCapturedResponse();if(!r)throw new Wa;return {data:Xa.fromTokenEndpointResponse(o),response:r}}catch(t){if(t instanceof Wa)throw t;const n=new Ca(t);throw Ua(n,t,e.getCapturedResponse()),n}}const d=qa(null!==(n=i[Vi])&&void 0!==n?n:c(ca,this)),h=await r(fa,this,Dc).call(this,i.serverMetadata(),d);try{const e=await ar(i,u),t=await cr(h,e);return Xa.fromTokenEndpointResponse(t)}catch(e){const t=new Ca(e);throw Ua(t,e,d.getCapturedResponse()),t}}async initiateBackchannelAuthentication(e,t){var n;const o=await r(fa,this,Hc).call(this,t),i=o.configuration,s=o.serverMetadata,a=Ka(f(f({},c(aa,this).authorizationParams),null==e?void 0:e.authorizationParams)),u=new URLSearchParams(f(f({scope:Oc},a),{},{client_id:c(aa,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:s.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&u.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&u.append("authorization_details",JSON.stringify(e.authorizationDetails));const l=qa(null!==(n=i[Vi])&&void 0!==n?n:c(ca,this)),d=await r(fa,this,Dc).call(this,i.serverMetadata(),l);try{const e=await ar(d,u);return {authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){const t=new Ca(e),n=l.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Na(n.headers):void 0,t}}async backchannelAuthenticationGrant(e,t){var n;let o=e.authReqId;const i=(await r(fa,this,Hc).call(this,t)).configuration,s=new URLSearchParams({auth_req_id:o}),a=qa(null!==(n=i[Vi])&&void 0!==n?n:c(ca,this)),u=await r(fa,this,Dc).call(this,i.serverMetadata(),a);try{const e=await br(u,"urn:openid:params:grant-type:ciba",s);return Xa.fromTokenEndpointResponse(e)}catch(e){const t=new Ca(e),n=a.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Na(n.headers):void 0,t}}async getTokenForConnection(e,t){var n;if(e.refreshToken&&e.accessToken)throw new Sa("Either a refresh or access token should be specified, but not both.");const o=null!==(n=e.accessToken)&&void 0!==n?n:e.refreshToken;if(!o)throw new Sa("Either a refresh or access token must be specified.");try{return await this.exchangeToken(f({connection:e.connection,subjectToken:o,subjectTokenType:e.accessToken?Lc:"urn:ietf:params:oauth:token-type:refresh_token",loginHint:e.loginHint},e.fullResponse?{fullResponse:!0}:{}),t)}catch(e){if(e instanceof Ta){const t=new Sa(e.message,e.cause);throw t.statusCode=e.statusCode,t.headers=e.headers,t}throw e}}async exchangeToken(e,t){return e.fullResponse?"connection"in e?r(fa,this,Xc).call(this,e,t,!0):r(fa,this,Yc).call(this,e,t,!0):"connection"in e?r(fa,this,Xc).call(this,e,t):r(fa,this,Yc).call(this,e,t)}async getTokenByCode(e,t,n){var o;const i=(await r(fa,this,Hc).call(this,n)).configuration;if(void 0!==t.organization&&La(t.organization),t.fullResponse){var s;const n=qa(null!==(s=i[Vi])&&void 0!==s?s:c(ca,this)),o=await r(fa,this,Dc).call(this,i.serverMetadata(),n);let a,u;try{const i=await lr(o,e,{pkceCodeVerifier:t.codeVerifier});if(a=Xa.fromTokenEndpointResponse(i),u=n.getCapturedResponse(),!u)throw new Wa}catch(e){if(e instanceof Wa)throw e;const t=new va("There was an error while trying to request a token.",ya(e)),o=n.getCapturedResponse();throw t.statusCode=null==o?void 0:o.status,t.headers=o?Na(o.headers):void 0,t}return t.organization&&Ma(a.claims,t.organization),{data:a,response:u}}const a=qa(null!==(o=i[Vi])&&void 0!==o?o:c(ca,this)),u=await r(fa,this,Dc).call(this,i.serverMetadata(),a);let l;try{const n=await lr(u,e,{pkceCodeVerifier:t.codeVerifier});l=Xa.fromTokenEndpointResponse(n);}catch(e){const t=new va("There was an error while trying to request a token.",ya(e)),n=a.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Na(n.headers):void 0,t}return t.organization&&Ma(l.claims,t.organization),l}async getTokenByMagicLinkCode(e,t,n){var o;const i=(await r(fa,this,Hc).call(this,n)).configuration;if(null!=t&&t.fullResponse){var s;const n=qa(null!==(s=i[Vi])&&void 0!==s?s:c(ca,this)),o=await r(fa,this,Dc).call(this,i.serverMetadata(),n);try{const i=await lr(o,e,{expectedState:null==t?void 0:t.expectedState}),r=Xa.fromTokenEndpointResponse(i),s=n.getCapturedResponse();if(!s)throw new Wa;return {data:r,response:s}}catch(e){if(e instanceof Wa)throw e;const t=e instanceof Error&&e.message?e.message:"There was an error while trying to request a token.",o=new va(t,e),i=n.getCapturedResponse();throw o.statusCode=null==i?void 0:i.status,o.headers=i?Na(i.headers):void 0,o}}const a=qa(null!==(o=i[Vi])&&void 0!==o?o:c(ca,this)),u=await r(fa,this,Dc).call(this,i.serverMetadata(),a);try{const n=await lr(u,e,{expectedState:null==t?void 0:t.expectedState});return Xa.fromTokenEndpointResponse(n)}catch(e){const t=e instanceof Error&&e.message?e.message:"There was an error while trying to request a token.",n=new va(t,e),o=a.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Na(o.headers):void 0,n}}async getTokenByRefreshToken(e,t){var n;const o=(await r(fa,this,Hc).call(this,t)).configuration,i=new URLSearchParams;if(e.audience&&i.append("audience",e.audience),e.scope&&i.append("scope",e.scope),e.fullResponse){var s;const t=qa(null!==(s=o[Vi])&&void 0!==s?s:c(ca,this)),n=await r(fa,this,Dc).call(this,o.serverMetadata(),t);try{const o=await dr(n,e.refreshToken,i),r=Xa.fromTokenEndpointResponse(o),s=t.getCapturedResponse();if(!s)throw new Wa;return {data:r,response:s}}catch(e){if(e instanceof Wa)throw e;const n=new _a("The access token has expired and there was an error while trying to refresh it.",ya(e)),o=t.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Na(o.headers):void 0,n}}const a=qa(null!==(n=o[Vi])&&void 0!==n?n:c(ca,this)),u=await r(fa,this,Dc).call(this,o.serverMetadata(),a);try{const t=await dr(u,e.refreshToken,i);return Xa.fromTokenEndpointResponse(t)}catch(e){const t=new _a("The access token has expired and there was an error while trying to refresh it.",ya(e)),n=a.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Na(n.headers):void 0,t}}async revokeToken(e,t){var n;const o=(await r(fa,this,Hc).call(this,t)).configuration,i={};e.tokenTypeHint&&(i.token_type_hint=e.tokenTypeHint);const s=qa(null!==(n=o[Vi])&&void 0!==n?n:c(ca,this)),a=await r(fa,this,Dc).call(this,o.serverMetadata(),s);try{await _r(a,e.token,i);}catch(e){const t=new Pa("An error occurred while trying to revoke the token.",ya(e)),n=s.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Na(n.headers):void 0,t}}async getUserInfo(e,t){const n=(await r(fa,this,Hc).call(this,t,!0)).configuration;try{var o;return await wr(n,e.accessToken,null!==(o=e.expectedSubject)&&void 0!==o?o:Fi)}catch(e){throw new Ea("There was an error while trying to retrieve the user info.",ya(e))}}async getTokenByPassword(e,t){var n;const o=(await r(fa,this,Hc).call(this,t)).configuration,i=new URLSearchParams({username:e.username,password:e.password});e.audience&&i.append("audience",e.audience),e.scope&&i.append("scope",e.scope),e.realm&&i.append("realm",e.realm);let s=o;if(e.auth0ForwardedFor){const t=await r(fa,this,Bc).call(this);s=new or(o.serverMetadata(),c(aa,this).clientId,{client_secret:c(aa,this).clientSecret,use_mtls_endpoint_aliases:c(aa,this).useMtls},t);const n=o[Vi];s[Vi]=(t,o)=>n(t,f(f({},o),{},{headers:f(f({},o.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}));}if(e.fullResponse){var a;const e=qa(null!==(a=s[Vi])&&void 0!==a?a:c(ca,this)),t=await r(fa,this,Dc).call(this,s.serverMetadata(),e);try{const n=await br(t,"password",i),o=Xa.fromTokenEndpointResponse(n),r=e.getCapturedResponse();if(!r)throw new Wa;return {data:o,response:r}}catch(t){if(t instanceof Wa)throw t;const n=new ka("There was an error while trying to request a token.",ya(t)),o=e.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Na(o.headers):void 0,n}}const u=qa(null!==(n=s[Vi])&&void 0!==n?n:c(ca,this)),l=await r(fa,this,Dc).call(this,s.serverMetadata(),u);try{const e=await br(l,"password",i);return Xa.fromTokenEndpointResponse(e)}catch(e){const t=new ka("There was an error while trying to request a token.",ya(e)),n=u.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Na(n.headers):void 0,t}}async getTokenByPasswordlessEmail(e,t){const n=new URLSearchParams({username:e.email,otp:e.code,realm:"email"});return e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),r(fa,this,qc).call(this,n,t,e.fullResponse)}async getTokenByPasswordlessSms(e,t){if(!mc(e.phoneNumber))throw new hc("Phone number must be in E.164 format (e.g. +14155550100).");const n=new URLSearchParams({username:e.phoneNumber,otp:e.code,realm:"sms"});return e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),r(fa,this,qc).call(this,n,t,e.fullResponse)}async getTokenByClientCredentials(e,t){var n;const o=(await r(fa,this,Hc).call(this,t)).configuration;if(e.fullResponse){var i;const t=qa(null!==(i=o[Vi])&&void 0!==i?i:c(ca,this)),n=await r(fa,this,Dc).call(this,o.serverMetadata(),t),s=new URLSearchParams({audience:e.audience});e.organization&&s.append("organization",e.organization);try{const e=await hr(n,s),o=Xa.fromTokenEndpointResponse(e),i=t.getCapturedResponse();if(!i)throw new Wa;return {data:o,response:i}}catch(e){if(e instanceof Wa)throw e;const n=new ba("There was an error while trying to request a token.",ya(e)),o=t.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Na(o.headers):void 0,n}}const s=qa(null!==(n=o[Vi])&&void 0!==n?n:c(ca,this)),a=await r(fa,this,Dc).call(this,o.serverMetadata(),s);try{const t=new URLSearchParams({audience:e.audience});e.organization&&t.append("organization",e.organization);const n=await hr(a,t);return Xa.fromTokenEndpointResponse(n)}catch(e){const t=new ba("There was an error while trying to request a token.",ya(e)),n=s.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Na(n.headers):void 0,t}}async buildLogoutUrl(e){const t=await r(fa,this,Fc).call(this),n=t.configuration;if(!t.serverMetadata.end_session_endpoint){const t=new URL("https://".concat(c(aa,this).domain,"/v2/logout"));return t.searchParams.set("returnTo",e.returnTo),t.searchParams.set("client_id",c(aa,this).clientId),t}return function(e,t){mr(e);const n=Ji(e),o=n.as,i=n.c,r=kn(o,"end_session_endpoint",!1,n.tlsOnly);(t=new URLSearchParams(t)).has("client_id")||t.set("client_id",i.client_id);for(const e of t.entries()){var s=y(e,2);const t=s[0],n=s[1];r.searchParams.append(t,n);}return r}(n,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){const t=(await r(fa,this,Fc).call(this)).serverMetadata,n=Ic(c(aa,this).discoveryCache),o=t.jwks_uri;c(la,this)||l(la,this,ks(new URL(o),{cacheMaxAge:n.ttlMs,[gs]:c(ca,this),[vs]:c(pa,this)}));const i=(await Yr(e.logoutToken,c(la,this),{issuer:t.issuer,audience:c(aa,this).clientId,algorithms:["RS256"],requiredClaims:["iat"]})).payload;if(!("sid"in i)&&!("sub"in i))throw new Ra('either "sid" or "sub" (or both) claims must be present');if("sid"in i&&"string"!=typeof i.sid)throw new Ra('"sid" claim must be a string');if("sub"in i&&"string"!=typeof i.sub)throw new Ra('"sub" claim must be a string');if("nonce"in i)throw new Ra('"nonce" claim is prohibited');if(!("events"in i))throw new Ra('"events" claim is missing');if("object"!=typeof i.events||null===i.events)throw new Ra('"events" claim must be an object');if(!("http://schemas.openid.net/event/backchannel-logout"in i.events))throw new Ra('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim');if("object"!=typeof i.events["http://schemas.openid.net/event/backchannel-logout"])throw new Ra('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object');return {sid:i.sid,sub:i.sub}}});function Jc(){const e=c(aa,this).domain.toLowerCase();return "".concat(e,"|mtls:").concat(c(aa,this).useMtls?"1":"0")}async function Dc(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const o=await r(fa,this,Bc).call(this,n),i=new or(e,c(aa,this).clientId,{client_secret:c(aa,this).clientSecret,use_mtls_endpoint_aliases:c(aa,this).useMtls},o);return i[Vi]=null!=t?t:c(ca,this),i}function Zc(e){return Ba(c(ca,this),e,c(ua,this))}async function Hc(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=await r(fa,this,Fc).call(this,t),o=n.configuration,i=n.serverMetadata;if(!e)return {configuration:o,serverMetadata:i};const s=r(fa,this,Zc).call(this,e);return {configuration:await r(fa,this,Dc).call(this,i,s,t),serverMetadata:i}}async function Fc(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=c(e?ia:oa,this);if(t&&c(ra,this))return {configuration:t,serverMetadata:c(ra,this)};const n=r(fa,this,Jc).call(this);e||await r(fa,this,Bc).call(this,!1);const o=c(da,this).get(n);if(o)return r(fa,this,Vc).call(this,o.serverMetadata,e);const i=c(ha,this).get(n);if(i){const t=await i;return r(fa,this,Vc).call(this,t.serverMetadata,e)}const s=(async()=>{const e=(await tr(new URL("https://".concat(c(aa,this).domain)),c(aa,this).clientId,{use_mtls_endpoint_aliases:c(aa,this).useMtls},(e,t,n,o)=>{n.set("client_id",t.client_id);},{[Vi]:c(ca,this)})).serverMetadata();return c(da,this).set(n,{serverMetadata:e}),{serverMetadata:e}})();s.catch(()=>{}),c(ha,this).set(n,s);try{const t=(await s).serverMetadata;return r(fa,this,Vc).call(this,t,e)}finally{c(ha,this).delete(n);}}async function Vc(e,t){const n=await r(fa,this,Dc).call(this,e,void 0,t);return l(ra,this,e),l(t?ia:oa,this,n),{configuration:n,serverMetadata:e}}async function Xc(e,t,n){var o,i,s;const a=(await r(fa,this,Hc).call(this,t)).configuration;if("audience"in e||"resource"in e)throw new Ta("audience and resource parameters are not supported for Token Vault exchanges");Wc(e.subjectToken);const u=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:null!==(o=e.subjectTokenType)&&void 0!==o?o:Lc,requested_token_type:null!==(i=e.requestedTokenType)&&void 0!==i?i:"http://auth0.com/oauth/token-type/federated-connection-access-token"});if(e.loginHint&&u.append("login_hint",e.loginHint),e.scope&&u.append("scope",e.scope),Nc(u,e.extra),n){var l;const t=qa(null!==(l=a[Vi])&&void 0!==l?l:c(ca,this)),n=await r(fa,this,Dc).call(this,a.serverMetadata(),t);try{const e=await br(n,Uc,u),o=Xa.fromTokenEndpointResponse(e),i=t.getCapturedResponse();if(!i)throw new Wa;return {data:o,response:i}}catch(n){if(n instanceof Wa)throw n;const o=new Ta("Failed to exchange token for connection '".concat(e.connection,"'."),ya(n)),i=t.getCapturedResponse();throw o.statusCode=null==i?void 0:i.status,o.headers=i?Na(i.headers):void 0,o}}const d=qa(null!==(s=a[Vi])&&void 0!==s?s:c(ca,this)),h=await r(fa,this,Dc).call(this,a.serverMetadata(),d);try{const e=await br(h,Uc,u);return Xa.fromTokenEndpointResponse(e)}catch(t){const n=new Ta("Failed to exchange token for connection '".concat(e.connection,"'."),ya(t)),o=d.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Na(o.headers):void 0,n}}function Gc(e,t,n){var o;if(n.organization&&Ma(e.claims,n.organization),n.actorToken)if(null!==(o=e.claims)&&void 0!==o&&o.act)e.act=e.claims.act;else try{e.act=function(e){if("string"!=typeof e)throw new Go("JWTs must use Compact JWS serialization, JWT must be a string");const t=e.split("."),n=t[1],o=t.length;if(5===o)throw new Go("Only JWTs using Compact JWS serialization can be decoded");if(3!==o)throw new Go("Invalid JWT");if(!n)throw new Go("JWTs must contain a payload");let i,r;try{i=ii(n);}catch(e){throw new Go("Failed to base64url decode the payload")}try{r=JSON.parse(Uo.decode(i));}catch(e){throw new Go("Failed to parse the decoded payload as JSON")}if(!si(r))throw new Go("Invalid JWT Claims Set");return r}(t.access_token).act;}catch(e){}return e}async function Yc(e,t,n){var o;const i=(await r(fa,this,Hc).call(this,t)).configuration;if(Wc(e.subjectToken),void 0!==e.organization&&La(e.organization),void 0!==e.actorToken&&void 0===e.actorTokenType)throw new Ta("actorTokenType is required when actorToken is provided");const s=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});if(e.audience&&s.append("audience",e.audience),e.scope&&s.append("scope",e.scope),e.requestedTokenType&&s.append("requested_token_type",e.requestedTokenType),e.organization&&s.append("organization",e.organization),e.actorToken&&s.append("actor_token",e.actorToken),e.actorTokenType&&s.append("actor_token_type",e.actorTokenType),Nc(s,e.extra),n){var a;const t=qa(null!==(a=i[Vi])&&void 0!==a?a:c(ca,this)),n=await r(fa,this,Dc).call(this,i.serverMetadata(),t);let o,u,l;try{if(u=await br(n,Kc,s),o=Xa.fromTokenEndpointResponse(u),l=t.getCapturedResponse(),!l)throw new Wa}catch(n){if(n instanceof Wa)throw n;const o=new Ta("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),ya(n)),i=t.getCapturedResponse();throw o.statusCode=null==i?void 0:i.status,o.headers=i?Na(i.headers):void 0,o}return r(fa,this,Gc).call(this,o,u,e),{data:o,response:l}}const u=qa(null!==(o=i[Vi])&&void 0!==o?o:c(ca,this)),l=await r(fa,this,Dc).call(this,i.serverMetadata(),u);let d,h;try{h=await br(l,Kc,s),d=Xa.fromTokenEndpointResponse(h);}catch(t){const n=new Ta("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),ya(t)),o=u.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Na(o.headers):void 0,n}return r(fa,this,Gc).call(this,d,h,e),d}async function qc(e,t,n){var o;const i=(await r(fa,this,Hc).call(this,t)).configuration;if(n){var s;const t=qa(null!==(s=i[Vi])&&void 0!==s?s:c(ca,this)),n=await r(fa,this,Dc).call(this,i.serverMetadata(),t);try{const o=await br(n,"http://auth0.com/oauth/grant-type/passwordless/otp",e),i=Xa.fromTokenEndpointResponse(o),r=t.getCapturedResponse();if(!r)throw new Wa;return {data:i,response:r}}catch(e){if(e instanceof Wa)throw e;const n=new hc("There was an error while trying to request a token.",ya(e)),o=t.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Na(o.headers):void 0,n}}const a=qa(null!==(o=i[Vi])&&void 0!==o?o:c(ca,this)),u=await r(fa,this,Dc).call(this,i.serverMetadata(),a);try{const t=await br(u,"http://auth0.com/oauth/grant-type/passwordless/otp",e);return Xa.fromTokenEndpointResponse(t)}catch(e){const t=new hc("There was an error while trying to request a token.",ya(e)),n=a.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Na(n.headers):void 0,t}}async function Bc(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=!!c(aa,this).clientSecret||!!c(aa,this).clientAssertionSigningKey||!!c(aa,this).useMtls;return e&&!t?(e,t,n,o)=>{n.set("client_id",t.client_id);}:(c(sa,this)||l(sa,this,(async()=>{if(!c(aa,this).clientSecret&&!c(aa,this).clientAssertionSigningKey&&!c(aa,this).useMtls)throw new Oa;if(c(aa,this).useMtls)return (e,t,n,o)=>{n.set("client_id",t.client_id);};let e=c(aa,this).clientAssertionSigningKey;return !e||e instanceof CryptoKey||(e=await Ss(e,c(aa,this).clientAssertionSigningAlg||"RS256")),e?function(e,t){return gn(e,t)}(e):Hi(c(aa,this).clientSecret)})().catch(e=>{throw l(sa,this,void 0),e})),c(sa,this))}async function Qc(e){const t=(await r(fa,this,Fc).call(this)).configuration,n=Bi(),o=await qi(n),i=Ka(f(f({},c(aa,this).authorizationParams),null==e?void 0:e.authorizationParams)),s=new URLSearchParams(f(f({scope:Oc},i),{},{client_id:c(aa,this).clientId,code_challenge:o,code_challenge_method:"S256"}));return {authorizationUrl:null!=e&&e.pushedAuthorizationRequests?await fr(t,s):await pr(t,s),codeVerifier:n}}class $c extends E{constructor(e,t){super(e,t),Object.setPrototypeOf(this,$c.prototype);}static fromPayload(e){let t=e.error,n=e.error_description;return new $c(t,n)}}class eu extends $c{constructor(e,t){super(e,t),Object.setPrototypeOf(this,eu.prototype);}}class tu extends $c{constructor(e,t){super(e,t),Object.setPrototypeOf(this,tu.prototype);}}class nu extends $c{constructor(e,t){super(e,t),Object.setPrototypeOf(this,nu.prototype);}}class ou extends $c{constructor(e,t){super(e,t),Object.setPrototypeOf(this,ou.prototype);}}class iu extends $c{constructor(e,t){super(e,t),Object.setPrototypeOf(this,iu.prototype);}}class ru{constructor(){let e=arguments.length>0&&void 0!==arguments[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){const 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(){const e=Date.now();for(const n of this.contexts){var t=y(n,2);const o=t[0];e-t[1].createdAt>this.ttlMs&&this.contexts.delete(o);}}get size(){return this.contexts.size}}class su{constructor(e,t){this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new ru;}setMFAAuthDetails(e,t,n,o){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:o});}async getAuthenticators(e){var t,n,o;const i=this.contextManager.get(e);if(!i)throw new eu("invalid_request","MFA context not found for this MFA token");const r=null===(n=null===(t=i.mfaRequirements)||void 0===t?void 0:t.challenge)||void 0===n?void 0:n.map(e=>e.type);try{const t=await this.authJsMfaClient.listAuthenticators({mfaToken:e});return r&&0!==r.length?t.filter(e=>!!e.type&&r.includes(e.type)):t}catch(e){if(e instanceof Ja)throw new eu(null===(o=e.cause)||void 0===o?void 0:o.error,e.message);throw e}}async enroll(e){var t;const n=function(e){const t=Ct[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(n)}catch(e){if(e instanceof Da)throw new tu(null===(t=e.cause)||void 0===t?void 0:t.error,e.message);throw e}}async challenge(e){var t;try{const t={challengeType:e.challengeType,mfaToken:e.mfaToken};return e.authenticatorId&&(t.authenticatorId=e.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(t)}catch(e){if(e instanceof Ha)throw new nu(null===(t=e.cause)||void 0===t?void 0:t.error,e.message);throw e}}async getEnrollmentFactors(e){const t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new iu("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&&0!==t.mfaRequirements.enroll.length?t.mfaRequirements.enroll:[]}async verify(e){const t=this.contextManager.get(e.mfaToken);if(!t)throw new ou("mfa_context_not_found","MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");const n=function(e){return "otp"in e&&e.otp?xt:"oobCode"in e&&e.oobCode?It:"recoveryCode"in e&&e.recoveryCode?At:void 0}(e);if(!n)throw new ou("invalid_request","Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.");const o=t.scope,i=t.audience;try{const t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:o,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 ou)throw new ou(e.error,e.error_description);throw e}}}class au extends Error{constructor(e,t,n){super(t),this.name="PasskeyError",this.code=e,this.cause=n,Object.setPrototypeOf(this,au.prototype);}}var cu,uu;class lu{constructor(e,t){cu.set(this,void 0),uu.set(this,void 0),n(this,cu,e,"f"),n(this,uu,t,"f");}async signup(n){if(!window.PublicKeyCredential)throw new au("passkey_not_supported","WebAuthn is not supported in this browser.");const o=n.scope,i=n.audience,r=e(n,["scope","audience"]),s=await t(this,cu,"f").register(r),a=pu(s.authnParamsPublicKey),c=await navigator.credentials.create({publicKey:a});if(!c)throw new au("passkey_cancelled","Passkey creation was cancelled or no credential was returned.");const u=mu(c);return t(this,uu,"f")._requestTokenForPasskey({authSession:s.authSession,credential:u,realm:r.realm,organization:r.organization,scope:o,audience:i})}async login(n){if(!window.PublicKeyCredential)throw new au("passkey_not_supported","WebAuthn is not supported in this browser.");const o=n||{},i=o.scope,r=o.audience,s=e(o,["scope","audience"]),a=await t(this,cu,"f").challenge(Object.keys(s).length>0?s:void 0),c=fu(a.authnParamsPublicKey),u=await navigator.credentials.get({publicKey:c});if(!u)throw new au("passkey_cancelled","Passkey authentication was cancelled or no credential was returned.");const l=yu(u);return t(this,uu,"f")._requestTokenForPasskey({authSession:a.authSession,credential:l,realm:s.realm,organization:s.organization,scope:i,audience:r})}async getSignupChallenge(e){if(!window.PublicKeyCredential)throw new au("passkey_not_supported","WebAuthn is not supported in this browser.");const n=await t(this,cu,"f").register(e);return {authSession:n.authSession,publicKey:pu(n.authnParamsPublicKey)}}async getLoginChallenge(e){if(!window.PublicKeyCredential)throw new au("passkey_not_supported","WebAuthn is not supported in this browser.");const n=await t(this,cu,"f").challenge(e);return {authSession:n.authSession,publicKey:fu(n.authnParamsPublicKey)}}async getTokenWithPasskey(e){if(!window.PublicKeyCredential)throw new au("passkey_not_supported","WebAuthn is not supported in this browser.");const n=e.authSession,o=e.credential,i=e.realm,r=e.organization,s=e.scope,a=e.audience,c=o.response;let u;if(c instanceof AuthenticatorAttestationResponse)u=mu(o);else {if(!(c instanceof AuthenticatorAssertionResponse))throw new au("passkey_invalid_credential","The provided credential is not a valid attestation or assertion response.");u=yu(o);}return t(this,uu,"f")._requestTokenForPasskey({authSession:n,credential:u,realm:i,organization:r,scope:s,audience:a})}}function du(e){const t=new Uint8Array(e),n=Array.from(t,e=>String.fromCharCode(e)).join("");return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function hu(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),o=atob(n),i=new Uint8Array(o.length);for(let e=0;e<o.length;e++)i[e]=o.charCodeAt(e);return i.buffer}function pu(e){return Object.assign(Object.assign({},e),{challenge:hu(e.challenge),user:Object.assign(Object.assign({},e.user),{id:hu(e.user.id)}),pubKeyCredParams:e.pubKeyCredParams,authenticatorSelection:e.authenticatorSelection})}function fu(e){return Object.assign(Object.assign({},e),{challenge:hu(e.challenge)})}function mu(e){var t;const n=e.response;return {id:e.id,rawId:du(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{clientDataJSON:du(n.clientDataJSON),attestationObject:du(n.attestationObject)},clientExtensionResults:e.getClientExtensionResults()}}function yu(e){var t;const n=e.response;return {id:e.id,rawId:du(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{clientDataJSON:du(n.clientDataJSON),authenticatorData:du(n.authenticatorData),signature:du(n.signature),userHandle:n.userHandle?du(n.userHandle):void 0},clientExtensionResults:e.getClientExtensionResults()}}cu=new WeakMap,uu=new WeakMap;class wu{resolveOnlineAccess(e){if("online"!==e.refreshTokenMode)return !1;if(!0!==e.useRefreshTokens)throw new R('`refreshTokenMode: "online"` requires the refresh-token grant.',"Set `useRefreshTokens: true`.");if(!0!==e.useDpop)throw new R('`refreshTokenMode: "online"` requires DPoP, which is missing or disabled.',"Set `useDpop: true` (DPoP is mandatory for online access).");return !0}constructor(e){let t,n;if(this.userCache=(new De).enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0,refreshTokenMode:"offline"},this.onlineAccess=this.resolveOnlineAccess(e),this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),"undefined"!=typeof window&&(()=>{if(!M())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===M().subtle)throw new Error("\n 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.\n ")})(),this.lockManager=(de||(de=le()),de),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||_,!gt(t))throw new Error('Invalid cache location "'.concat(t,'"'));n=gt(t)();}var o;this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:b,this.cookieStorage=!1===e.legacySameSiteCookie?nt:it,this.orgHintCookieName=(o=this.options.clientId,"auth0.".concat(o,".organization_hint")),this.isAuthenticatedCookieName=(e=>"auth0.".concat(e,".is.authenticated"))(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;const i=e.useCookiesForTransactions?this.cookieStorage:rt;let r="";var s;this.onlineAccess?r=k:this.options.useRefreshTokens&&(r="offline_access"),this.scope=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];if("object"!=typeof e)return {[P]:Ue(t,e,...o)};let r={[P]:Ue(t,...o)};return Object.keys(e).forEach(n=>{const i=e[n];r[n]=Ue(t,i,...o);}),r}(this.options.authorizationParams.scope,"openid",r),this.transactionManager=new He(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||T,this.cacheManager=new Ze(n,n.allKeys?void 0:new mt(n,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new St(this.options.clientId):void 0,this.domainUrl=(s=this.options.domain,/^https?:\/\//.test(s)?s:"https://".concat(s)),this.tokenIssuer=((e,t)=>e?e.startsWith("https://")?e:"https://".concat(e,"/"):"".concat(t,"/"))(this.options.issuer,this.domainUrl);const a="".concat(this.domainUrl,"/me/"),c=this.createFetcher(Object.assign(Object.assign({},this.options.useDpop&&{dpopNonceId:"__auth0_my_account_api__"}),{getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" "),audience:a},detailedResponse:!0})}}));this.myAccount=new Et(c,a),this.authJsClient=new zc({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new su(this.authJsClient.mfa,this),this.passkey=new lu(this.authJsClient.passkey,this),"undefined"!=typeof window&&window.Worker&&this.options.useRefreshTokens&&t===_&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new ft,this.worker.postMessage({type:"init",allowedBaseUrl:this.domainUrl}));}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){const t=this.options.auth0Client||S,n=Z(t,!0),o=encodeURIComponent(btoa(JSON.stringify(n)));return "".concat(this.domainUrl).concat(e,"&auth0Client=").concat(o)}_authorizeUrl(e){return this._url("/authorize?".concat(H(e)))}async _verifyIdToken(e,t,n){const o=await this.nowProvider();return Xe({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,"string"!=typeof i?i:parseInt(i,10)||void 0),now:o});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{const t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState({},"",t.toString()));}catch(e){}}_applySessionTransferToken(e){const t=this.options.sessionTransferTokenQueryParamName;if(!t||e.session_transfer_token)return e;const n=this._extractSessionTransferToken(t);return n?(this._clearSessionTransferTokenFromUrl(t),Object.assign(Object.assign({},e),{session_transfer_token:n})):e}async _prepareAuthorizeUrl(e,t,n){var o;const i=J(z()),r=J(z()),s=z(),a=await F(s),c=X(a),u=await(null===(o=this.dpop)||void 0===o?void 0:o.calculateThumbprint()),l=((e,t,n,o,i,r,s,a,c)=>Object.assign(Object.assign(Object.assign({client_id:e.clientId},e.authorizationParams),n),{scope:Ke(t,n.scope,n.audience),response_type:"code",response_mode:a||"query",state:o,nonce:i,redirect_uri:s||e.authorizationParams.redirect_uri,code_challenge:r,code_challenge_method:"S256",dpop_jkt:c}))(this.options,this.scope,e,i,r,c,e.redirect_uri||this.options.authorizationParams.redirect_uri||n,null==t?void 0:t.response_mode,u),d=this._authorizeUrl(l);return {nonce:r,code_verifier:s,scope:l.scope,audience:l.audience||P,redirect_uri:l.redirect_uri,state:i,url:d}}async loginWithPopup(e,t){var n;if(e=e||{},!(t=t||{}).popup&&(t.popup=(e=>{const t=window.screenX+(window.innerWidth-400)/2,n=window.screenY+(window.innerHeight-600)/2;return window.open(e,"auth0:authorize:popup","left=".concat(t,",top=").concat(n,",width=").concat(400,",height=").concat(600,",resizable,scrollbars=yes,status=1"))})(""),!t.popup))throw new j;const o=this._applySessionTransferToken(e.authorizationParams||{}),i=await this._prepareAuthorizeUrl(o,{response_mode:"web_message"},window.location.origin);t.popup.location.href=i.url;const r=await((e,t)=>new Promise((n,o)=>{let i;const r=setInterval(()=>{e.popup&&e.popup.closed&&(clearInterval(r),clearTimeout(s),window.removeEventListener("message",i,!1),o(new O(e.popup)));},1e3),s=setTimeout(()=>{clearInterval(r),o(new A(e.popup)),window.removeEventListener("message",i,!1);},1e3*(e.timeoutInSeconds||60));i=function(a){if(a.origin===t&&a.data&&"authorization_response"===a.data.type){if(clearTimeout(s),clearInterval(r),window.removeEventListener("message",i,!1),!1!==e.closePopup&&e.popup.close(),a.data.response.error)return o(E.fromPayload(a.data.response));n(a.data.response);}},window.addEventListener("message",i);}))(Object.assign(Object.assign({},t),{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(i.url).origin);if(i.state!==r.state)throw new E("state_mismatch","Invalid state");const s=(null===(n=e.authorizationParams)||void 0===n?void 0:n.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:i.audience,scope:i.scope,code_verifier:i.code_verifier,grant_type:"authorization_code",code:r.code,redirect_uri:i.redirect_uri},{nonceIn:i.nonce,organization:s});}async getUser(){var e;if(await this._isSessionCeilingReached())return;const t=await this._getIdTokenFromCache();return null===(e=null==t?void 0:t.decodedToken)||void 0===e?void 0:e.user}async getIdTokenClaims(){var e;if(await this._isSessionCeilingReached())return;const t=await this._getIdTokenFromCache();return null===(e=null==t?void 0:t.decodedToken)||void 0===e?void 0:e.claims}async loginWithRedirect(){var t;const n=vt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),o=n.openUrl,i=n.fragment,r=n.appState,s=e(n,["openUrl","fragment","appState"]),a=(null===(t=s.authorizationParams)||void 0===t?void 0:t.organization)||this.options.authorizationParams.organization,c=this._applySessionTransferToken(s.authorizationParams||{}),u=await this._prepareAuthorizeUrl(c),l=u.url,d=e(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},d),{appState:r,response_type:exports.ResponseType.Code}),a&&{organization:a}));const h=i?"".concat(l,"#").concat(i):l;o?await o(h):window.location.assign(h);}async handleRedirectCallback(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location.href).split("?").slice(1);if(0===e.length)throw new Error("There are no query params available for parsing.");const t=this.transactionManager.get();if(!t)throw new E("missing_transaction","Invalid state");this.transactionManager.remove();const n=(e=>{e.indexOf("#")>-1&&(e=e.substring(0,e.indexOf("#")));const 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===exports.ResponseType.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){const n=e.code,o=e.state,i=e.error,r=e.error_description;if(i)throw new C(i,r||i,o,t.appState);if(!t.code_verifier||t.state&&t.state!==o)throw new E("state_mismatch","Invalid state");const s=t.organization,a=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:a,organization:s}),{appState:t.appState,response_type:exports.ResponseType.Code}}async _handleConnectAccountRedirectCallback(e,t){const n=e.connect_code,o=e.state,i=e.error,r=e.error_description;if(i)throw new x(i,r||i,t.connection,o,t.appState);if(!n)throw new E("missing_connect_code","Missing connect code");if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===o))throw new E("state_mismatch","Invalid state");const s=await this.myAccount.completeAccount({auth_session:t.auth_session,connect_code:n,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier});return Object.assign(Object.assign({},s),{appState:t.appState,response_type:exports.ResponseType.ConnectCode})}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(yt))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(yt);}try{await this.getTokenSilently(e);}catch(e){}}async getTokenSilently(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,n;const o=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Ke(this.scope,null===(t=e.authorizationParams)||void 0===t?void 0:t.scope,(null===(n=e.authorizationParams)||void 0===n?void 0:n.audience)||this.options.authorizationParams.audience)})}),i=await this._getTokenSilently(o);return e.detailedResponse?i:null==i?void 0:i.access_token}async _getTokenSilently(t){const n=t.cacheMode,o=e(t,["cacheMode"]);if(await this._isSessionCeilingReached())return;if("off"!==n){const e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||P,clientId:this.options.clientId,cacheMode:n});if(e)return e}if("cache-only"===n)return;const i=(r=this.options.clientId,s=o.authorizationParams.audience||"default","".concat("auth0.lock.getTokenSilently",".").concat(r,".").concat(s));var r,s;try{return await this.lockManager.runWithLock(i,5e3,async()=>{if("off"!==n){const e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||P,clientId:this.options.clientId});if(e)return e}const e=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(o):await this._getTokenFromIFrame(o),t=e.id_token,i=e.token_type,r=e.access_token,s=e.oauthTokenScope,a=e.expires_in;return Object.assign(Object.assign({id_token:t,token_type:i,access_token:r},s?{scope:s}:null),{expires_in:a})})}catch(e){if(this._isInteractiveError(e)&&"popup"===this.options.interactiveErrorHandler)return await this._handleInteractiveErrorWithPopup(o);throw e}}_isInteractiveError(e){return e instanceof W||e instanceof E&&this._isIframeMfaError(e)}_isIframeMfaError(e){return "login_required"===e.error&&"Multifactor authentication required"===e.error_description}async _handleInteractiveErrorWithPopup(e){try{await this.loginWithPopup({authorizationParams:e.authorizationParams});const t=await this._getEntryFromCache({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||P,clientId:this.options.clientId});if(!t)throw new E("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&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n,o;const i=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Ke(this.scope,null===(n=e.authorizationParams)||void 0===n?void 0:n.scope,(null===(o=e.authorizationParams)||void 0===o?void 0:o.audience)||this.options.authorizationParams.audience)})});t=Object.assign(Object.assign({},v),t),await this.loginWithPopup(i,t);return (await this.cacheManager.get(new ze({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||P,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return !!await this.getUser()}_buildLogoutUrl(t){null!==t.clientId?t.clientId=t.clientId||this.options.clientId:delete t.clientId;const n=t.logoutParams||{},o=n.federated,i=e(n,["federated"]),r=o?"&federated":"";return this._url("/v2/logout?".concat(H(Object.assign({clientId:t.clientId},i))))+r}async revokeRefreshToken(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.options.useRefreshTokens)return;const t=e.audience||this.options.authorizationParams.audience||P,n=await this.cacheManager.getRefreshTokensByAudience(t,this.options.clientId);await async function(e,t){let n=e.baseUrl,o=e.timeout,i=e.auth0Client,r=e.useFormData,s=e.refreshTokens,a=e.audience,c=e.client_id,u=e.onRefreshTokenRevoked;const l=o||b,d="refresh_token",h="".concat(n,"/oauth/revoke"),p={"Content-Type":r?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(Z(i||S)))};if(t){const e={client_id:c,token_type_hint:d},n=r?H(e):JSON.stringify(e);try{return await Ae({type:"revoke",timeout:l,fetchUrl:h,fetchOptions:{method:"POST",body:n,headers:p},useFormData:r,auth:{audience:null!=a?a:P}},t)}catch(e){throw new E("revoke_error",e.message)}}for(const e of s){const t={client_id:c,token_type_hint:d,token:e},n=r?H(t):JSON.stringify(t),o=await Oe(h,{method:"POST",body:n,headers:p},l);if(!o.ok){let e,t;try{var f=JSON.parse(await o.text());e=f.error,t=f.error_description;}catch(e){}throw new E(e||"revoke_error",t||"HTTP error ".concat(o.status))}await(null==u?void 0:u(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),this.onlineAccess&&await this._clearLocalSession();}async logout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=vt(t),o=n.openUrl,i=e(n,["openUrl"]);await this._clearLocalSession(t.clientId);const r=this._buildLogoutUrl(i);o?await o(r):!1!==o&&window.location.assign(r);}async _getTokenFromIFrame(e){const t=(n=this.options.clientId,"".concat("auth0.lock.getTokenFromIFrame",".").concat(n));var n;try{return await this.lockManager.runWithLock(t,5e3,async()=>{const t=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!t.organization&&(t.organization=n);const o=await this._prepareAuthorizeUrl(t,{response_mode:"web_message"},window.location.origin),i=o.url,r=o.state,s=o.nonce,a=o.code_verifier,c=o.redirect_uri,u=o.scope,l=o.audience;if(window.crossOriginIsolated)throw new E("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const d=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds;let h;try{h=new URL(this.domainUrl).origin;}catch(e){h=this.domainUrl;}const p=await function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60;return new Promise((o,i)=>{const r=window.document.createElement("iframe");r.setAttribute("width","0"),r.setAttribute("height","0"),r.style.display="none";const s=()=>{window.document.body.contains(r)&&(window.document.body.removeChild(r),window.removeEventListener("message",a,!1));};let a;const c=setTimeout(()=>{i(new I),s();},1e3*n);a=function(e){if(e.origin!=t)return;if(!e.data||"authorization_response"!==e.data.type)return;const n=e.source;n&&n.close(),e.data.response.error?i(E.fromPayload(e.data.response)):o(e.data.response),clearTimeout(c),window.removeEventListener("message",a,!1),setTimeout(s,2e3);},window.addEventListener("message",a,!1),window.document.body.appendChild(r),r.setAttribute("src",e);})}(i,h,d);if(r!==p.state)throw new E("state_mismatch","Invalid state");const f=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:a,code:p.code,grant_type:"authorization_code",redirect_uri:c,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:s,organization:t.organization});return Object.assign(Object.assign({},f),{scope:u,oauthTokenScope:f.scope,audience:l})})}catch(e){if("login_required"===e.error){e instanceof E&&this._isIframeMfaError(e)&&"popup"===this.options.interactiveErrorHandler||this.logout({openUrl:!1});}throw e}}async _getTokenUsingRefreshToken(e){const t=await this.cacheManager.get(new ze({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||P,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 N(e.authorizationParams.audience||P,e.authorizationParams.scope)}const n=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,o="number"==typeof e.timeoutInSeconds?1e3*e.timeoutInSeconds:null,i=((e,t,n,o)=>{var i;if(e&&n&&o){if(t.audience!==n)return t.scope;const e=o.split(" "),r=(null===(i=t.scope)||void 0===i?void 0:i.split(" "))||[],s=r.every(t=>e.includes(t));return e.length>=r.length&&s?o:t.scope}return t.scope})(this.options.useMrrt,e.authorizationParams,null==t?void 0:t.audience,null==t?void 0:t.scope);try{const u=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:t&&t.refresh_token,redirect_uri:n}),o&&{timeout:o}),{scopesToRequest:i});if(await this._propagateRotatedRefreshToken(null==t?void 0:t.refresh_token,u.refresh_token),this.options.useMrrt){if(r=null==t?void 0:t.audience,s=null==t?void 0:t.scope,a=e.authorizationParams.audience,c=e.authorizationParams.scope,r!==a||!((e,t)=>{const n=(null==t?void 0:t.split(" "))||[];return ((null==e?void 0:e.split(" "))||[]).every(e=>n.includes(e))})(c,s)){const t=bt(i,u.scope,this.onlineAccess);if(t){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience,e.authorizationParams.scope),new U(e.authorizationParams.audience||"default",t)}}}return Object.assign(Object.assign({},u),{scope:e.authorizationParams.scope,oauthTokenScope:u.scope,audience:e.authorizationParams.audience||P})}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}var r,s,a,c;}async _propagateRotatedRefreshToken(e,t){!this.onlineAccess&&t&&e&&await this.cacheManager.updateEntry(e,t,this.options.clientId,this.options.useMrrt);}async _saveEntryInCache(t){const n=t.decodedToken.claims,o=n.session_expiry,i=n.iat;if(void 0!==o){if("number"!=typeof o)throw new E("invalid_token","Invalid session_expiry: value must be a number.");if(o>=1e10)throw new E("invalid_token","Invalid session_expiry: value appears to be in milliseconds; expected a Unix timestamp in seconds.");if(void 0===i||o<=i)throw new E("invalid_token","Invalid session_expiry: session ceiling is before or at the token issue time.")}const r=t.id_token,s=t.decodedToken,a=e(t,["id_token","decodedToken"]);this.userCache.set(Me,{id_token:r,decodedToken:s}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(a);}async _clearLocalSession(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.clientId;var t;null===e?await this.cacheManager.clear():await this.cacheManager.clear(e),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(Me);try{await(null===(t=this.dpop)||void 0===t?void 0:t.clear());}catch(e){}if(this.worker)try{await Ae({type:"clear"},this.worker);}catch(e){}}async _isSessionCeilingReached(){var e,t;const n=this.userCache.get(Me),o=null!=n?n:await this.cacheManager.getIdToken(new ze({clientId:this.options.clientId})),i=null===(t=null===(e=null==o?void 0:o.decodedToken)||void 0===e?void 0:e.claims)||void 0===t?void 0:t.session_expiry;if(void 0===i)return !1;const r=await this.nowProvider();return Math.floor(r/1e3)>=i-30&&(await this._clearLocalSession(),!0)}async _getIdTokenFromCache(){const e=this.options.authorizationParams.audience||P,t=this.scope[e],n=await this.cacheManager.getIdToken(new ze({clientId:this.options.clientId,audience:e,scope:t})),o=this.userCache.get(Me);return n&&n.id_token===(null==o?void 0:o.id_token)?o:(this.userCache.set(Me,n),n)}async _getEntryFromCache(e){let t=e.scope,n=e.audience,o=e.clientId,i=e.cacheMode;const r=await this.cacheManager.get(new ze({scope:t,audience:n,clientId:o}),60,this.options.useMrrt,i);if(r&&r.access_token){const e=r.token_type,t=r.access_token,n=r.oauthTokenScope,o=r.expires_in,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:o})}}_storeMfaContext(e,t,n){e instanceof W&&this.mfa.setMFAAuthDetails(e.mfa_token,t,n,e.mfa_requirements);}async _requestToken(e,t){var n,o,i,r,s,a;const c=t||{},u=c.nonceIn,l=c.organization,d=c.scopesToRequest;try{const t=await Ne(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,preserveRefreshToken:this.onlineAccess},e),{scope:d||e.scope}),this.worker);let c=await this._verifyIdToken(t.id_token,u,l);if("authorization_code"===e.grant_type){const e=await this._getIdTokenFromCache();(null===(o=null===(n=null==e?void 0:e.decodedToken)||void 0===n?void 0:n.claims)||void 0===o?void 0:o.sub)&&e.decodedToken.claims.sub!==c.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(Me));}if("authorization_code"!==e.grant_type){const e=await this._getIdTokenFromCache(),t=null===(r=null===(i=null==e?void 0:e.decodedToken)||void 0===i?void 0:i.claims)||void 0===r?void 0:r.session_expiry;void 0!==t&&(c=Object.assign(Object.assign({},c),{claims:Object.assign(Object.assign({},c.claims),{session_expiry:t})}));}return !t.refresh_token&&this.onlineAccess&&(t.refresh_token=null!==(s=e.refresh_token)&&void 0!==s?s:null===(a=await this.cacheManager.get(new ze({scope:d||e.scope,audience:e.audience||P,clientId:this.options.clientId}),void 0,this.options.useMrrt))||void 0===a?void 0:a.refresh_token),await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},t),{decodedToken:c,scope:e.scope,audience:e.audience||P}),t.scope?{oauthTokenScope:t.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(l||c.claims.org_id),Object.assign(Object.assign({},t),{decodedToken:c})}catch(t){throw "authorization_code"!==e.grant_type&&this._storeMfaContext(t,d||e.scope,e.audience),t}}_buildTokenExchangeParams(e){return Object.assign(Object.assign(Object.assign(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}),e.actor_token&&{actor_token:e.actor_token}),e.actor_token_type&&{actor_token_type:e.actor_token_type}),{scope:Ke(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 loginWithCustomTokenExchange(e){return this._requestToken(this._buildTokenExchangeParams(e))}async customTokenExchange(e){const t=this._buildTokenExchangeParams(e);try{const n=await Ne(Object.assign(Object.assign({},t),{baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,dpop:this.dpop}),this.worker,!0);return n.id_token&&await this._verifyIdToken(n.id_token,void 0,e.organization),n}catch(e){throw this._storeMfaContext(e,t.scope,t.audience),e}}async exchangeToken(e){return this.loginWithCustomTokenExchange(e)}_assertDpop(e){if(!e)throw new 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&&void 0!==arguments[0]?arguments[0]:{};return new Pt(e,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" "),audience:null==e?void 0:e.audience},detailedResponse:!0})},getDpopNonce:()=>this.getDpopNonce(e.dpopNonceId),setDpopNonce:t=>this.setDpopNonce(t,e.dpopNonceId),generateDpopProof:e=>this.generateDpopProof(e)})}async connectAccountWithRedirect(e){const t=e.openUrl,n=e.appState,o=e.connection,i=e.scopes,r=e.authorization_params,s=e.redirectUri,a=void 0===s?this.options.authorizationParams.redirect_uri||window.location.origin:s;if(!o)throw new Error("connection is required");const c=J(z()),u=z(),l=await F(u),d=X(l),h=await this.myAccount.connectAccount({connection:o,scopes:i,redirect_uri:a,state:c,code_challenge:d,code_challenge_method:"S256",authorization_params:r}),p=h.connect_uri,f=h.connect_params,m=h.auth_session;this.transactionManager.create({state:c,code_verifier:u,auth_session:m,redirect_uri:a,appState:n,connection:o,response_type:exports.ResponseType.ConnectCode});const y=new URL(p);y.searchParams.set("ticket",f.ticket),t?await t(y.toString()):window.location.assign(y);}async _requestTokenForPasskey(e){const t=e.audience||this.options.authorizationParams.audience,n=e.organization||this.options.authorizationParams.organization;return this._requestToken(Object.assign(Object.assign(Object.assign({grant_type:"urn:okta:params:oauth:grant-type:webauthn",auth_session:e.authSession,authn_response:e.credential},e.realm&&{realm:e.realm}),n&&{organization:n}),{scope:Ke(this.scope,e.scope,t),audience:t}))}async _requestTokenForMfa(t,n){const o=t.mfaToken,i=e(t,["mfaToken"]),r=await this.cacheManager.get(new ze({scope:i.scope,audience:i.audience||P,clientId:this.options.clientId}),void 0,this.options.useMrrt),s=await this._requestToken(Object.assign(Object.assign({},i),{mfa_token:o}),n);return await this._propagateRotatedRefreshToken(null==r?void 0:r.refresh_token,s.refresh_token),s}}
114
+ function e(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]]);}return n}function t(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return "m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function n(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return "a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}function o(e,t){this.v=e,this.k=t;}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function r(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function s(e){return new o(e,0)}function a(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function c(e,t){return e.get(r(e,t))}function u(e,t,n){a(e,t),t.set(e,n);}function l(e,t,n){return e.set(r(e,t),n),n}function d(e,t){a(e,t),t.add(e);}function h(e,t,n){return (t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o);}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach(function(t){h(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e}function m(e,t){if(null==e)return {};var n,o,i=function(e,t){if(null==e)return {};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==t.indexOf(o))continue;n[o]=e[o];}return n}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);}return i}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,i,r,s,a=[],c=!0,u=!1;try{if(r=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1;}else for(;!(c=(o=r.call(n)).done)&&(a.push(o.value),a.length!==t);c=!0);}catch(e){u=!0,i=e;}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.toString.call(e).slice(8,-1);return "Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e){return function(){return new g(e.apply(this,arguments))}}function g(e){var t,n;function i(t,n){try{var s=e[t](n),a=s.value,c=a instanceof o;Promise.resolve(c?a.v:a).then(function(n){if(c){var o="return"===t&&a.k?t:"next";if(!a.k||n.done)return i(o,n);n=e[o](n).value;}r(!!s.done,n);},function(e){i("throw",e);});}catch(e){r(2,e);}}function r(e,o){2===e?t.reject(o):t.resolve({value:o,done:e}),(t=t.next)?i(t.key,t.arg):n=null;}this._invoke=function(e,o){return new Promise(function(r,s){var a={key:e,arg:o,resolve:r,reject:s,next:null};n?n=n.next=a:(t=n=a,i(e,o));})},"function"!=typeof e.return&&(this.return=void 0);}"function"==typeof SuppressedError&&SuppressedError,g.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},g.prototype.next=function(e){return this._invoke("next",e)},g.prototype.throw=function(e){return this._invoke("throw",e)},g.prototype.return=function(e){return this._invoke("return",e)};const v={timeoutInSeconds:60},b=1e4,_="memory",k="Multifactor authentication required",S="online_access",T={name:"auth0-spa-js",version:"2.27.0"},P=()=>Date.now(),E="default";class C extends Error{constructor(e,t){super(t),this.error=e,this.error_description=t,Object.setPrototypeOf(this,C.prototype);}static fromPayload(e){let t=e.error,n=e.error_description;return new C(t,n)}}class A extends C{constructor(e,t){super("invalid_configuration","".concat(e," ").concat(t)),this.suggestion=t,Object.setPrototypeOf(this,A.prototype);}}class R extends C{constructor(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;super(e,t),this.state=n,this.appState=o,Object.setPrototypeOf(this,R.prototype);}}class x extends C{constructor(e,t,n,o){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;super(e,t),this.connection=n,this.state=o,this.appState=i,Object.setPrototypeOf(this,x.prototype);}}class I extends C{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,I.prototype);}}class O extends I{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,O.prototype);}}class j extends C{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,j.prototype);}}class W extends C{constructor(){super("popup_open","Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,W.prototype);}}class N extends C{constructor(e,t,n,o){super(e,t),this.mfa_token=n,this.mfa_requirements=o,Object.setPrototypeOf(this,N.prototype);}}class K extends C{constructor(e,t){super("missing_refresh_token","Missing Refresh Token (audience: '".concat(L(e,["default"]),"', scope: '").concat(L(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,K.prototype);}}class M extends C{constructor(e,t){super("missing_scopes","Missing requested scopes after refresh (audience: '".concat(L(e,["default"]),"', missing scope: '").concat(L(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,M.prototype);}}class U extends C{constructor(e){super("use_dpop_nonce","Server rejected DPoP proof: wrong nonce"),this.newDpopNonce=e,Object.setPrototypeOf(this,U.prototype);}}function L(e){return e&&!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).includes(e)?e:""}const z=()=>window.crypto,J=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";for(;t.length<43;){const n=z().getRandomValues(new Uint8Array(43-t.length));for(const o of n)t.length<43&&o<198&&(t+=e[o%66]);}return t},D=e=>btoa(e),Z=[{key:"name",type:["string"]},{key:"version",type:["string","number"]},{key:"env",type:["object"]}],H=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Object.keys(e).reduce((n,o)=>{if(t&&"env"===o)return n;const i=Z.find(e=>e.key===o);return i&&i.type.includes(typeof e[o])&&(n[o]=e[o]),n},{})},F=t=>{var n=t.clientId,o=e(t,["clientId"]);return new URLSearchParams((e=>Object.keys(e).filter(t=>void 0!==e[t]).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{}))(Object.assign({client_id:n},o))).toString()},V=async e=>{const t=z().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e));return await t},X=e=>(e=>decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))(e.replace(/_/g,"/").replace(/-/g,"+")),G=e=>{const t=new Uint8Array(e);return (e=>{const t={"+":"-","/":"_","=":""};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))};var q="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Y={},B={};Object.defineProperty(B,"__esModule",{value:!0});var Q=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var o=e.locked.get(t);void 0===o?void 0===n?e.locked.set(t,[]):e.locked.set(t,[n]):void 0!==n&&(o.unshift(n),e.locked.set(t,o));},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise(function(n,o){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n());})},this.unlock=function(t){var n=e.locked.get(t);if(void 0!==n&&0!==n.length){var o=n.pop();e.locked.set(t,n),void 0!==o&&setTimeout(o,0);}else e.locked.delete(t);};}return e.getInstance=function(){return void 0===e.instance&&(e.instance=new e),e.instance},e}();B.default=function(){return Q.getInstance()};var $=q&&q.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(i,r){function s(e){try{c(o.next(e));}catch(e){r(e);}}function a(e){try{c(o.throw(e));}catch(e){r(e);}}function c(e){e.done?i(e.value):new n(function(t){t(e.value);}).then(s,a);}c((o=o.apply(e,t||[])).next());})},ee=q&&q.__generator||function(e,t){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=t.call(e,s);}catch(e){r=[6,e],o=0;}finally{n=i=0;}if(5&r[0])throw r[1];return {value:r[0]?r[1]:void 0,done:!0}}([r,a])}}},te=q;Object.defineProperty(Y,"__esModule",{value:!0});var ne=B,oe="browser-tabs-lock-key",ie={key:function(e){return $(te,void 0,void 0,function(){return ee(this,function(e){throw new Error("Unsupported")})})},getItem:function(e){return $(te,void 0,void 0,function(){return ee(this,function(e){throw new Error("Unsupported")})})},clear:function(){return $(te,void 0,void 0,function(){return ee(this,function(e){return [2,window.localStorage.clear()]})})},removeItem:function(e){return $(te,void 0,void 0,function(){return ee(this,function(e){throw new Error("Unsupported")})})},setItem:function(e,t){return $(te,void 0,void 0,function(){return ee(this,function(e){throw new 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 se(e){for(var t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="",o=0;o<e;o++){n+=t[Math.floor(61*Math.random())];}return n}var ae=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+se(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,void 0===e.waiters&&(e.waiters=[]);}return e.prototype.acquireLock=function(t,n){return void 0===n&&(n=5e3),$(this,void 0,void 0,function(){var o,i,r,s,a,c,u;return ee(this,function(l){switch(l.label){case 0:o=Date.now()+se(4),i=Date.now()+n,r=oe+"-"+t,s=void 0===this.storageHandler?ie:this.storageHandler,l.label=1;case 1:return Date.now()<i?[4,re(30)]:[3,8];case 2:return l.sent(),null!==s.getItemSync(r)?[3,5]:(a=this.id+"-"+t+"-"+o,[4,re(Math.floor(25*Math.random()))]);case 3:return l.sent(),s.setItemSync(r,JSON.stringify({id:this.id,iat:o,timeoutKey:a,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,re(30)];case 4:return l.sent(),null!==(c=s.getItemSync(r))&&(u=JSON.parse(c)).id===this.id&&u.iat===o?(this.acquiredIatSet.add(o),this.refreshLockWhileAcquired(r,o),[2,!0]):[3,7];case 5:return e.lockCorrector(void 0===this.storageHandler?ie:this.storageHandler),[4,this.waitForSomethingToChange(i)];case 6:l.sent(),l.label=7;case 7:return o=Date.now()+se(4),[3,1];case 8:return [2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(e,t){return $(this,void 0,void 0,function(){var n=this;return ee(this,function(o){return setTimeout(function(){return $(n,void 0,void 0,function(){var n,o,i;return ee(this,function(r){switch(r.label){case 0:return [4,ne.default().lock(t)];case 1:return r.sent(),this.acquiredIatSet.has(t)?(n=void 0===this.storageHandler?ie:this.storageHandler,null===(o=n.getItemSync(e))?(ne.default().unlock(t),[2]):((i=JSON.parse(o)).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 $(this,void 0,void 0,function(){return ee(this,function(n){switch(n.label){case 0:return [4,new Promise(function(n){var o=!1,i=Date.now(),r=!1;function s(){if(r||(window.removeEventListener("storage",s),e.removeFromWaiting(s),clearTimeout(a),r=!0),!o){o=!0;var t=50-(Date.now()-i);t>0?setTimeout(n,t):n(null);}}window.addEventListener("storage",s),e.addToWaiting(s);var a=setTimeout(s,Math.max(0,t-Date.now()));})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),void 0!==e.waiters&&e.waiters.push(t);},e.removeFromWaiting=function(t){void 0!==e.waiters&&(e.waiters=e.waiters.filter(function(e){return e!==t}));},e.notifyWaiters=function(){void 0!==e.waiters&&e.waiters.slice().forEach(function(e){return e()});},e.prototype.releaseLock=function(e){return $(this,void 0,void 0,function(){return ee(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 $(this,void 0,void 0,function(){var n,o,i,r;return ee(this,function(s){switch(s.label){case 0:return n=void 0===this.storageHandler?ie:this.storageHandler,o=oe+"-"+t,null===(i=n.getItemSync(o))?[2]:(r=JSON.parse(i)).id!==this.id?[3,2]:[4,ne.default().lock(r.iat)];case 1:s.sent(),this.acquiredIatSet.delete(r.iat),n.removeItemSync(o),ne.default().unlock(r.iat),e.notifyWaiters(),s.label=2;case 2:return [2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,o=t,i=[],r=0;;){var s=o.keySync(r);if(null===s)break;i.push(s),r++;}for(var a=!1,c=0;c<i.length;c++){var u=i[c];if(u.includes(oe)){var l=o.getItemSync(u);if(null!==l){var d=JSON.parse(l);(void 0===d.timeRefreshed&&d.timeAcquired<n||void 0!==d.timeRefreshed&&d.timeRefreshed<n)&&(o.removeItemSync(u),a=!0);}}}a&&e.notifyWaiters();},e.waiters=void 0,e}(),ce=Y.default=ae;class ue{async runWithLock(e,t,n){const o=new AbortController,i=setTimeout(()=>o.abort(),t);try{return await navigator.locks.request(e,{mode:"exclusive",signal:o.signal},async e=>{if(clearTimeout(i),!e)throw new Error("Lock not available");return await n()})}catch(e){if(clearTimeout(i),"AbortError"===(null==e?void 0:e.name))throw new I;throw e}}}class le{constructor(){this.activeLocks=new Set,this.lock=new ce,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear();};}async runWithLock(e,t,n){let o=!1;for(let n=0;n<10&&!o;n++)o=await this.lock.acquireLock(e,t);if(!o)throw new I;this.activeLocks.add(e),1===this.activeLocks.size&&"undefined"!=typeof window&&window.addEventListener("pagehide",this.pagehideHandler);try{return await n()}finally{this.activeLocks.delete(e),await this.lock.releaseLock(e),0===this.activeLocks.size&&"undefined"!=typeof window&&window.removeEventListener("pagehide",this.pagehideHandler);}}}function de(){return "undefined"!=typeof navigator&&"function"==typeof(null===(e=navigator.locks)||void 0===e?void 0:e.request)?new ue:new le;var e;}let he=null;function pe(){return he||(he=de()),he}const fe=new TextEncoder,me=new TextDecoder;function ye(e){return "string"==typeof e?fe.encode(e):me.decode(e)}function we(e){if("number"!=typeof e.modulusLength||e.modulusLength<2048)throw new ke(`${e.name} modulusLength must be at least 2048 bits`)}async function ge(e,t,n){if(!1===n.usages.includes("sign"))throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');const o=`${be(ye(JSON.stringify(e)))}.${be(ye(JSON.stringify(t)))}`;return `${o}.${be(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return {name:e.algorithm.name,hash:"SHA-256"};case"RSA-PSS":return we(e.algorithm),{name:e.algorithm.name,saltLength:32};case"RSASSA-PKCS1-v1_5":return we(e.algorithm),{name:e.algorithm.name};case"Ed25519":return {name:e.algorithm.name}}throw new _e}(n),n,ye(o)))}`}let ve;if(Uint8Array.prototype.toBase64)ve=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0}));else {const e=32768;ve=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));const n=[];for(let o=0;o<t.byteLength;o+=e)n.push(String.fromCharCode.apply(null,t.subarray(o,o+e)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};}function be(e){return ve(e)}class _e extends Error{constructor(e){var t;super(null!=e?e:"operation not supported"),this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor);}}class ke extends Error{constructor(e){var t;super(e),this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor);}}function Se(e){switch(e.algorithm.name){case"RSA-PSS":return function(e){if("SHA-256"===e.algorithm.hash.name)return "PS256";throw new _e("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"RSASSA-PKCS1-v1_5":return function(e){if("SHA-256"===e.algorithm.hash.name)return "RS256";throw new _e("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"ECDSA":return function(e){if("P-256"===e.algorithm.namedCurve)return "ES256";throw new _e("unsupported EcKeyAlgorithm namedCurve")}(e);case"Ed25519":return "Ed25519";default:throw new _e("unsupported CryptoKey algorithm name")}}function Te(e){return e instanceof CryptoKey}function Pe(e){return Te(e)&&"public"===e.type}async function Ee(e,t,n,o,i,r){const s=null==e?void 0:e.privateKey,a=null==e?void 0:e.publicKey;if(!Te(c=s)||"private"!==c.type)throw new TypeError('"keypair.privateKey" must be a private CryptoKey');var c;if(!Pe(a))throw new TypeError('"keypair.publicKey" must be a public CryptoKey');if(!0!==a.extractable)throw new TypeError('"keypair.publicKey.extractable" must be true');if("string"!=typeof t)throw new TypeError('"htu" must be a string');if("string"!=typeof n)throw new TypeError('"htm" must be a string');if(void 0!==o&&"string"!=typeof o)throw new TypeError('"nonce" must be a string or undefined');if(void 0!==i&&"string"!=typeof i)throw new TypeError('"accessToken" must be a string or undefined');if(void 0!==r&&("object"!=typeof r||null===r||Array.isArray(r)))throw new TypeError('"additional" must be an object');const u=Object.assign(Object.create(null),r,{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:o,htu:t,ath:i?be(await crypto.subtle.digest("SHA-256",ye(i))):void 0});return ge({alg:Se(s),typ:"dpop+jwt",jwk:await Ce(a)},u,s)}async function Ce(e){const{kty:t,e:n,n:o,x:i,y:r,crv:s}=await crypto.subtle.exportKey("jwk",e);return {kty:t,crv:s,e:n,n:o,x:i,y:r}}const Ae="dpop-nonce",Re=["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:token-exchange","urn:okta:params:oauth:grant-type:webauthn","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 xe(){return async function(e,t){var n;let o;if("string"!=typeof e||0===e.length)throw new TypeError('"alg" must be a non-empty string');switch(e){case"PS256":o={name:"RSA-PSS",hash:"SHA-256",modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case"RS256":o={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case"ES256":o={name:"ECDSA",namedCurve:"P-256"};break;case"Ed25519":o={name:"Ed25519"};break;default:throw new _e}return crypto.subtle.generateKey(o,null!==(n=null==t?void 0:t.extractable)&&void 0!==n&&n,["sign","verify"])}("ES256",{extractable:!1})}function Ie(e){return async function(e){if(!Pe(e))throw new TypeError('"publicKey" must be a public CryptoKey');if(!0!==e.extractable)throw new TypeError('"publicKey.extractable" must be true');const t=await Ce(e);let 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 _e("unsupported JWK kty")}return be(await crypto.subtle.digest({name:"SHA-256"},ye(JSON.stringify(n))))}(e.publicKey)}function Oe(e){let t=e.keyPair,n=e.url,o=e.method,i=e.nonce,r=e.accessToken;const s=function(e){const t=new URL(e);return t.search="",t.hash="",t.href}(n);return Ee(t,s,o,i,r)}const je=(e,t)=>new Promise(function(n,o){const i=new MessageChannel;i.port1.onmessage=function(e){e.data.error?o(new Error(e.data.error)):n(e.data),i.port1.close();},t.postMessage(e,[i.port2]);}),We=(e,t,n)=>{const o=new AbortController;let i;return t.signal=o.signal,Promise.race([fetch(e,t),new Promise((e,t)=>{i=setTimeout(()=>{o.abort(),t(new Error("Timeout when executing 'fetch'"));},n);})]).finally(()=>{clearTimeout(i);})},Ne=async function(e,t,n,o,i,r){let s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:b;return i?(async(e,t,n,o,i,r,s,a,c,u)=>je({type:"refresh",auth:{audience:t,scope:n},timeout:i,fetchUrl:e,fetchOptions:o,useFormData:s,useMrrt:a,skipTokenStorage:c,preserveRefreshToken:u},r))(e,t,n,o,s,i,r,arguments.length>7?arguments[7]:void 0,arguments.length>8?arguments[8]:void 0,arguments.length>9?arguments[9]:void 0):(async(e,t,n)=>{const o=await We(e,t,n);return {ok:o.ok,json:await o.json(),headers:(i=o.headers,[...i].reduce((e,t)=>{let n=y(t,2),o=n[0],i=n[1];return e[o]=i,e},{}))};var i;})(e,o,s)};async function Ke(t,n,o,i,r,s,a,c,u,l,d,h){if(u){const e=await u.generateProof({url:t,method:r.method||"GET",nonce:await u.getNonce()});r.headers=Object.assign(Object.assign({},r.headers),{dpop:e});}let p,f=null;for(let e=0;e<3;e++)try{p=await Ne(t,o,i,r,s,a,n,c,d,h),f=null;break}catch(e){f=e;}if(f)throw f;const m=p.json,y=m.error,w=m.error_description,g=e(m,["error","error_description"]),v=p,b=v.headers,_=v.ok;let k;if(u&&(k=b[Ae],k&&await u.setNonce(k)),!_){const e=w||"HTTP error. Unable to fetch ".concat(t);if("mfa_required"===y)throw new N(y,e,g.mfa_token,g.mfa_requirements);if("missing_refresh_token"===y)throw new K(o,i);if("use_dpop_nonce"===y){if(!u||!k||l)throw new U(k);return Ke(t,n,o,i,r,s,a,c,u,!0,d,h)}throw new C(y||"request_error",e)}return g}async function Me(t,n,o){var i=t.baseUrl,r=t.timeout,s=t.audience,a=t.scope,c=t.auth0Client,u=t.useFormData,l=t.useMrrt,d=t.dpop,h=t.preserveRefreshToken,p=e(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData","useMrrt","dpop","preserveRefreshToken"]);const f="urn:ietf:params:oauth:grant-type:token-exchange"===p.grant_type,m="urn:okta:params:oauth:grant-type:webauthn"===p.grant_type,y="refresh_token"===p.grant_type&&l,w=f||m||y,g=Object.assign(Object.assign(Object.assign({},p),w&&s&&{audience:s}),w&&a&&{scope:a}),v=m||!u,b=v?JSON.stringify(g):F(g),_=(k=p.grant_type,Re.includes(k));var k;return await Ke("".concat(i,"/oauth/token"),r,s||E,a,{method:"POST",body:b,headers:{"Content-Type":v?"application/json":"application/x-www-form-urlencoded","Auth0-Client":btoa(JSON.stringify(H(c||T)))}},n,u,l,_?d:void 0,void 0,o,h)}const Ue=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return (o=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(o))).join(" ");var o;},Le=(e,t,n)=>{let o;return n&&(o=e[n]),o||(o=e[E]),Ue(o,t)},ze="@@auth0spajs@@",Je="@@user@@";class De{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ze,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(e){const t=y(e.split("::"),4),n=t[0],o=t[1],i=t[2],r=t[3];return new De({clientId:o,scope:r,audience:i},n)}static fromCacheEntry(e){const t=e.scope,n=e.audience,o=e.client_id;return new De({scope:t,audience:n,clientId:o})}}class Ze{set(e,t){localStorage.setItem(e,JSON.stringify(t));}get(e){const t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(e){return}}remove(e){localStorage.removeItem(e);}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith(ze))}}class He{constructor(){this.enclosedCache=function(){let e={};return {set(t,n){e[t]=n;},get(t){const n=e[t];if(n)return n},remove(t){delete e[t];},allKeys:()=>Object.keys(e)}}();}}class Fe{constructor(e,t,n){this.cache=e,this.keyManifest=t,this.nowProvider=n||P;}async setIdToken(e,t,n){var o;const i=this.getIdTokenCacheKey(e);await this.cache.set(i,{id_token:t,decodedToken:n}),await(null===(o=this.keyManifest)||void 0===o?void 0:o.add(i));}async getIdToken(e){const t=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!t&&e.scope&&e.audience){const t=await this.get(e);if(!t)return;if(!t.id_token||!t.decodedToken)return;return {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&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3?arguments[3]:void 0;var i;let r=await this.cache.get(e.toKey()),s=e;if(!r){const t=await this.getCacheKeys();if(!t)return;const i=this.matchExistingCacheKey(e,t);if(i&&(r=await this.cache.get(i),s=De.fromKey(i)),!r&&n&&"cache-only"!==o)return this.getEntryWithRefreshToken(e,t)}if(!r)return;const a=await this.nowProvider(),c=Math.floor(a/1e3);return r.expiresAt-t<c?r.body.refresh_token?this.modifiedCachedEntry(r,s):(await this.cache.remove(s.toKey()),void await(null===(i=this.keyManifest)||void 0===i?void 0:i.remove(s.toKey()))):r.body}async modifiedCachedEntry(e,t){const n={refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope},o={body:n,expiresAt:e.expiresAt};return await this.cache.set(t.toKey(),o),{refresh_token:n.refresh_token,audience:n.audience,scope:n.scope}}async set(e){var t;const n=new De({clientId:e.client_id,scope:e.scope,audience:e.audience}),o=await this.wrapCacheEntry(e);await this.cache.set(n.toKey(),o),await(null===(t=this.keyManifest)||void 0===t?void 0:t.add(n.toKey()));}async remove(e,t,n){const o=new De({clientId:e,scope:n,audience:t});await this.cache.remove(o.toKey());}async stripRefreshToken(e){var t;const n=await this.getCacheKeys();if(n)for(const o of n){const n=await this.cache.get(o);(null===(t=null==n?void 0:n.body)||void 0===t?void 0:t.refresh_token)===e&&(delete n.body.refresh_token,await this.cache.set(o,n));}}async clear(e){var t;const n=await this.getCacheKeys();n&&(await n.filter(t=>!e||t.includes(e)).reduce(async(e,t)=>{await e,await this.cache.remove(t);},Promise.resolve()),await(null===(t=this.keyManifest)||void 0===t?void 0:t.clear()));}async wrapCacheEntry(e){const t=await this.nowProvider();return {body:e,expiresAt:Math.floor(t/1e3)+e.expires_in}}async getCacheKeys(){var e;return this.keyManifest?null===(e=await this.keyManifest.get())||void 0===e?void 0:e.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new De({clientId:e},ze,Je).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{var n;const o=De.fromKey(t),i=new Set(o.scope&&o.scope.split(" ")),r=(null===(n=e.scope)||void 0===n?void 0:n.split(" "))||[],s=o.scope&&r.reduce((e,t)=>e&&i.has(t),!0);return o.prefix===ze&&o.clientId===e.clientId&&o.audience===e.audience&&s})[0]}async getEntryWithRefreshToken(e,t){var n;for(const o of t){const t=De.fromKey(o);if(t.prefix===ze&&t.clientId===e.clientId){const e=await this.cache.get(o);if(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.refresh_token)return {refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope}}}}async getRefreshTokensByAudience(e,t){var n;const o=await this.getCacheKeys();if(!o)return [];const i=new Set;for(const r of o){const o=De.fromKey(r);if(o.prefix===ze&&o.clientId===t&&o.audience===e){const e=await this.cache.get(r);(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.refresh_token)&&i.add(e.body.refresh_token);}}return Array.from(i)}async updateEntry(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=await this.getCacheKeys();if(i)for(const r of i){if(De.fromKey(r).clientId!==n)continue;const i=await this.cache.get(r);if(!(null==i?void 0:i.body))continue;const s=i.body.refresh_token;s&&(o||s===e)&&(i.body.refresh_token=t,await this.cache.set(r,i));}}}class Ve{constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,this.storageKey="".concat("a0.spajs.txs",".").concat(this.clientId);}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain});}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain});}}const Xe=e=>"number"==typeof e,Ge=["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"],qe=e=>{if(!e.id_token)throw new Error("ID token is required but missing");const t=(e=>{const t=e.split("."),n=y(t,3),o=n[0],i=n[1],r=n[2];if(3!==t.length||!o||!i||!r)throw new Error("ID token could not be decoded");const s=JSON.parse(X(i)),a={__raw:e},c={};return Object.keys(s).forEach(e=>{a[e]=s[e],Ge.includes(e)||(c[e]=s[e]);}),{encoded:{header:o,payload:i,signature:r},header:JSON.parse(X(o)),claims:a,user:c}})(e.id_token);if(!t.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(t.claims.iss!==e.iss)throw new Error('Issuer (iss) claim mismatch in the ID token; expected "'.concat(e.iss,'", found "').concat(t.claims.iss,'"'));if(!t.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if("RS256"!==t.header.alg)throw new Error('Signature algorithm of "'.concat(t.header.alg,'" is not supported. Expected the ID token to be signed with "RS256".'));if(!t.claims.aud||"string"!=typeof t.claims.aud&&!Array.isArray(t.claims.aud))throw new 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 new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but was not one of "').concat(t.claims.aud.join(", "),'"'));if(t.claims.aud.length>1){if(!t.claims.azp)throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");if(t.claims.azp!==e.aud)throw new Error('Authorized Party (azp) claim mismatch in the ID token; expected "'.concat(e.aud,'", found "').concat(t.claims.azp,'"'))}}else if(t.claims.aud!==e.aud)throw new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but found "').concat(t.claims.aud,'"'));if(e.nonce){if(!t.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(t.claims.nonce!==e.nonce)throw new Error('Nonce (nonce) claim mismatch in the ID token; expected "'.concat(e.nonce,'", found "').concat(t.claims.nonce,'"'))}if(e.max_age&&!Xe(t.claims.auth_time))throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");if(null==t.claims.exp||!Xe(t.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Xe(t.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const n=e.leeway||60,o=new Date(e.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(t.claims.exp+n),o>i)throw new Error("Expiration Time (exp) claim error in the ID token; current time (".concat(o,") is after expiration time (").concat(i,")"));if(null!=t.claims.nbf&&Xe(t.claims.nbf)){const e=new Date(0);if(e.setUTCSeconds(t.claims.nbf-n),o<e)throw new Error("Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (".concat(o,") is before ").concat(e))}if(null!=t.claims.auth_time&&Xe(t.claims.auth_time)){const i=new Date(0);if(i.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),o>i)throw new Error("Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (".concat(o,") is after last auth at ").concat(i))}if(e.organization){const n=e.organization.trim();if(n.startsWith("org_")){const e=n;if(!t.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(e!==t.claims.org_id)throw new Error('Organization ID (org_id) claim mismatch in the ID token; expected "'.concat(e,'", found "').concat(t.claims.org_id,'"'))}else {const e=n.toLowerCase();if(!t.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(e!==t.claims.org_name)throw new Error('Organization Name (org_name) claim mismatch in the ID token; expected "'.concat(e,'", found "').concat(t.claims.org_name,'"'))}}return t};var Ye=q&&q.__assign||function(){return Ye=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ye.apply(this,arguments)};function Be(e,t){if(!t)return "";var n="; "+e;return !0===t?n:n+"="+t}function Qe(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("number"==typeof e.expires){var t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t;}return Be("Expires",e.expires?e.expires.toUTCString():"")+Be("Domain",e.domain)+Be("Path",e.path)+Be("Secure",e.secure)+Be("SameSite",e.sameSite)}(n)}function $e(){return function(e){for(var t={},n=e?e.split("; "):[],o=/(%[\dA-F]{2})+/gi,i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");'"'===s.charAt(0)&&(s=s.slice(1,-1));try{t[r[0].replace(o,decodeURIComponent)]=s.replace(o,decodeURIComponent);}catch(e){}}return t}(document.cookie)}var et=function(e){return $e()[e]};function tt(e,t,n){document.cookie=Qe(e,t,Ye({path:"/"},n));}var nt=tt;var ot=function(e,t){tt(e,"",Ye(Ye({},t),{expires:-1}));};const it={get(e){const t=et(e);if(void 0!==t)return JSON.parse(t)},save(e,t,n){let o={};"https:"===window.location.protocol&&(o={secure:!0,sameSite:"none"}),(null==n?void 0:n.daysUntilExpire)&&(o.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(o.domain=n.cookieDomain),nt(e,JSON.stringify(t),o);},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),ot(e,n);}},rt="_legacy_",st={get(e){const t=it.get(e);return t||it.get("".concat(rt).concat(e))},save(e,t,n){let o={};"https:"===window.location.protocol&&(o={secure:!0}),(null==n?void 0:n.daysUntilExpire)&&(o.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(o.domain=n.cookieDomain),nt("".concat(rt).concat(e),JSON.stringify(t),o),it.save(e,t,n);},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),ot(e,n),it.remove(e,t),it.remove("".concat(rt).concat(e),t);}},at={get(e){if("undefined"==typeof sessionStorage)return;const t=sessionStorage.getItem(e);return null!=t?JSON.parse(t):void 0},save(e,t){sessionStorage.setItem(e,JSON.stringify(t));},remove(e){sessionStorage.removeItem(e);}},ct={Offline:"offline",Online:"online"};exports.ResponseType = void 0;!function(e){e.Code="code",e.ConnectCode="connect_code";}(exports.ResponseType||(exports.ResponseType={}));class lt{}function dt(e,t,n){var o=void 0===t?null:t,i=function(e,t){var n=atob(e);if(t){for(var o=new Uint8Array(n.length),i=0,r=n.length;i<r;++i)o[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(o.buffer))}return n}(e,void 0!==n&&n),r=i.indexOf("\n",10)+1,s=i.substring(r)+(o?"//# sourceMappingURL="+o:""),a=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(a)}var ht,pt,ft,mt,yt=(ht="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7ZnVuY3Rpb24gZShlLHQpeyhudWxsPT10fHx0PmUubGVuZ3RoKSYmKHQ9ZS5sZW5ndGgpO2Zvcih2YXIgcj0wLG89QXJyYXkodCk7cjx0O3IrKylvW3JdPWVbcl07cmV0dXJuIG99ZnVuY3Rpb24gdCh0LHIpe3JldHVybiBmdW5jdGlvbihlKXtpZihBcnJheS5pc0FycmF5KGUpKXJldHVybiBlfSh0KXx8ZnVuY3Rpb24oZSx0KXt2YXIgcj1udWxsPT1lP251bGw6InVuZGVmaW5lZCIhPXR5cGVvZiBTeW1ib2wmJmVbU3ltYm9sLml0ZXJhdG9yXXx8ZVsiQEBpdGVyYXRvciJdO2lmKG51bGwhPXIpe3ZhciBvLG4scyxhLGk9W10sYz0hMCxsPSExO3RyeXtpZihzPShyPXIuY2FsbChlKSkubmV4dCwwPT09dCl7aWYoT2JqZWN0KHIpIT09cilyZXR1cm47Yz0hMX1lbHNlIGZvcig7IShjPShvPXMuY2FsbChyKSkuZG9uZSkmJihpLnB1c2goby52YWx1ZSksaS5sZW5ndGghPT10KTtjPSEwKTt9Y2F0Y2goZSl7bD0hMCxuPWV9ZmluYWxseXt0cnl7aWYoIWMmJm51bGwhPXIucmV0dXJuJiYoYT1yLnJldHVybigpLE9iamVjdChhKSE9PWEpKXJldHVybn1maW5hbGx5e2lmKGwpdGhyb3cgbn19cmV0dXJuIGl9fSh0LHIpfHxmdW5jdGlvbih0LHIpe2lmKHQpe2lmKCJzdHJpbmciPT10eXBlb2YgdClyZXR1cm4gZSh0LHIpO3ZhciBvPXt9LnRvU3RyaW5nLmNhbGwodCkuc2xpY2UoOCwtMSk7cmV0dXJuIk9iamVjdCI9PT1vJiZ0LmNvbnN0cnVjdG9yJiYobz10LmNvbnN0cnVjdG9yLm5hbWUpLCJNYXAiPT09b3x8IlNldCI9PT1vP0FycmF5LmZyb20odCk6IkFyZ3VtZW50cyI9PT1vfHwvXig/OlVpfEkpbnQoPzo4fDE2fDMyKSg/OkNsYW1wZWQpP0FycmF5JC8udGVzdChvKT9lKHQscik6dm9pZCAwfX0odCxyKXx8ZnVuY3Rpb24oKXt0aHJvdyBuZXcgVHlwZUVycm9yKCJJbnZhbGlkIGF0dGVtcHQgdG8gZGVzdHJ1Y3R1cmUgbm9uLWl0ZXJhYmxlIGluc3RhbmNlLlxuSW4gb3JkZXIgdG8gYmUgaXRlcmFibGUsIG5vbi1hcnJheSBvYmplY3RzIG11c3QgaGF2ZSBhIFtTeW1ib2wuaXRlcmF0b3JdKCkgbWV0aG9kLiIpfSgpfWNsYXNzIHIgZXh0ZW5kcyBFcnJvcntjb25zdHJ1Y3RvcihlLHQpe3N1cGVyKHQpLHRoaXMuZXJyb3I9ZSx0aGlzLmVycm9yX2Rlc2NyaXB0aW9uPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsci5wcm90b3R5cGUpfXN0YXRpYyBmcm9tUGF5bG9hZChlKXtsZXQgdD1lLmVycm9yLG89ZS5lcnJvcl9kZXNjcmlwdGlvbjtyZXR1cm4gbmV3IHIodCxvKX19Y2xhc3MgbyBleHRlbmRzIHJ7Y29uc3RydWN0b3IoZSx0KXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIiwiTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyIuY29uY2F0KG4oZSxbImRlZmF1bHQiXSksIicsIHNjb3BlOiAnIikuY29uY2F0KG4odCksIicpIikpLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsby5wcm90b3R5cGUpfX1mdW5jdGlvbiBuKGUpe3JldHVybiBlJiYhKGFyZ3VtZW50cy5sZW5ndGg+MSYmdm9pZCAwIT09YXJndW1lbnRzWzFdP2FyZ3VtZW50c1sxXTpbXSkuaW5jbHVkZXMoZSk/ZToiIn0iZnVuY3Rpb24iPT10eXBlb2YgU3VwcHJlc3NlZEVycm9yJiZTdXBwcmVzc2VkRXJyb3I7Y29uc3Qgcz1lPT57dmFyIHQ9ZS5jbGllbnRJZCxyPWZ1bmN0aW9uKGUsdCl7dmFyIHI9e307Zm9yKHZhciBvIGluIGUpT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKGUsbykmJnQuaW5kZXhPZihvKTwwJiYocltvXT1lW29dKTtpZihudWxsIT1lJiYiZnVuY3Rpb24iPT10eXBlb2YgT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scyl7dmFyIG49MDtmb3Iobz1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO248by5sZW5ndGg7bisrKXQuaW5kZXhPZihvW25dKTwwJiZPYmplY3QucHJvdG90eXBlLnByb3BlcnR5SXNFbnVtZXJhYmxlLmNhbGwoZSxvW25dKSYmKHJbb1tuXV09ZVtvW25dXSl9cmV0dXJuIHJ9KGUsWyJjbGllbnRJZCJdKTtyZXR1cm4gbmV3IFVSTFNlYXJjaFBhcmFtcygoZT0+T2JqZWN0LmtleXMoZSkuZmlsdGVyKHQ9PnZvaWQgMCE9PWVbdF0pLnJlZHVjZSgodCxyKT0+T2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHQpLHtbcl06ZVtyXX0pLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IGE9e30saT1udWxsO2NvbnN0IGM9KGUsdCk9PiIiLmNvbmNhdChlLCJ8IikuY29uY2F0KHQpLGw9KGUsdCk9PnQuc3RhcnRzV2l0aCgiIi5jb25jYXQoZSwifCIpKSx1PShlLHQpPT5hW2MoZSx0KV0sZj1lPT57T2JqZWN0LmVudHJpZXMoYSkuZm9yRWFjaChyPT57bGV0IG89dChyLDIpLG49b1swXTtvWzFdPT09ZSYmZGVsZXRlIGFbbl19KX0saD1lPT57Y29uc3QgdD1uZXcgVVJMU2VhcmNoUGFyYW1zKGUpLHI9e307cmV0dXJuIHQuZm9yRWFjaCgoZSx0KT0+e3JbdF09ZX0pLHJ9LGQ9YXN5bmMgZT0+e2xldCByLG4saT1lLmRhdGEsZj1pLnRpbWVvdXQsZD1pLmF1dGgscD1pLmZldGNoVXJsLHk9aS5mZXRjaE9wdGlvbnMsZz1pLnVzZUZvcm1EYXRhLGI9aS51c2VNcnJ0LE89aS5za2lwVG9rZW5TdG9yYWdlLGs9aS5wcmVzZXJ2ZVJlZnJlc2hUb2tlbixtPXQoZS5wb3J0cywxKVswXSxqPXt9O2NvbnN0IHY9ZHx8e30sXz12LmF1ZGllbmNlLHc9di5zY29wZTt0cnl7Y29uc3QgZT1nP2goeS5ib2R5KTpKU09OLnBhcnNlKHkuYm9keSk7aWYoZS5yZWZyZXNoX3Rva2VufHwicmVmcmVzaF90b2tlbiIhPT1lLmdyYW50X3R5cGUpZS5tZmFfdG9rZW4mJihuPXUoXyx3KSwhbiYmYiYmKG49YS5sYXRlc3RfcmVmcmVzaF90b2tlbikpO2Vsc2V7aWYobj11KF8sdyksIW4mJmIpe2NvbnN0IGU9YS5sYXRlc3RfcmVmcmVzaF90b2tlbix0PSgoZSx0KT0+ISFPYmplY3Qua2V5cyhhKS5maW5kKHI9PntpZigibGF0ZXN0X3JlZnJlc2hfdG9rZW4iIT09cil7Y29uc3Qgbz1sKHQsciksbj1yLnNwbGl0KCJ8IilbMV0uc3BsaXQoIiAiKSxzPWUuc3BsaXQoIiAiKS5ldmVyeShlPT5uLmluY2x1ZGVzKGUpKTtyZXR1cm4gbyYmc319KSkodyxfKTtlJiYhdCYmKG49ZSl9aWYoIW4pdGhyb3cgbmV3IG8oXyx3KTt5LmJvZHk9Zz9zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpufSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpufSkpfWxldCBpLGQ7ImZ1bmN0aW9uIj09dHlwZW9mIEFib3J0Q29udHJvbGxlciYmKGk9bmV3IEFib3J0Q29udHJvbGxlcix5LnNpZ25hbD1pLnNpZ25hbCk7dHJ5e2Q9YXdhaXQgUHJvbWlzZS5yYWNlKFsoUD1mLG5ldyBQcm9taXNlKGU9PnNldFRpbWVvdXQoZSxQKSkpLGZldGNoKHAsT2JqZWN0LmFzc2lnbih7fSx5KSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBtLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZClyZXR1cm4gaSYmaS5hYm9ydCgpLHZvaWQgbS5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtpZihVPWQuaGVhZGVycyxqPVsuLi5VXS5yZWR1Y2UoKGUscik9PntsZXQgbz10KHIsMiksbj1vWzBdLHM9b1sxXTtyZXR1cm4gZVtuXT1zLGV9LHt9KSxyPWF3YWl0IGQuanNvbigpLE8pcmV0dXJuIGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4sdm9pZCBtLnBvc3RNZXNzYWdlKHtvazpkLm9rLGpzb246cixoZWFkZXJzOmp9KTtyLnJlZnJlc2hfdG9rZW4/KGImJihhLmxhdGVzdF9yZWZyZXNoX3Rva2VuPXIucmVmcmVzaF90b2tlbixTPW4sTT1yLnJlZnJlc2hfdG9rZW4sT2JqZWN0LmVudHJpZXMoYSkuZm9yRWFjaChlPT57bGV0IHI9dChlLDIpLG89clswXTtyWzFdPT09UyYmKGFbb109TSl9KSksKChlLHQscik9PnthW2ModCxyKV09ZX0pKHIucmVmcmVzaF90b2tlbixfLHcpLGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4pOmt8fCgoZSx0KT0+e2RlbGV0ZSBhW2MoZSx0KV19KShfLHcpLG0ucG9zdE1lc3NhZ2Uoe29rOmQub2ssanNvbjpyLGhlYWRlcnM6an0pfWNhdGNoKGUpe20ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOmUuZXJyb3IsZXJyb3JfZGVzY3JpcHRpb246ZS5tZXNzYWdlfSxoZWFkZXJzOmp9KX12YXIgUyxNLFUsUH0scD1hc3luYyBlPT57bGV0IHI9ZS5kYXRhLG89ci50aW1lb3V0LG49ci5hdXRoLGk9ci5mZXRjaFVybCxjPXIuZmV0Y2hPcHRpb25zLHU9ci51c2VGb3JtRGF0YSxkPXQoZS5wb3J0cywxKVswXTtjb25zdCBwPShufHx7fSkuYXVkaWVuY2U7dHJ5e2NvbnN0IGU9KGU9Pntjb25zdCByPW5ldyBTZXQ7cmV0dXJuIE9iamVjdC5lbnRyaWVzKGEpLmZvckVhY2gobz0+e2xldCBuPXQobywyKSxzPW5bMF0sYT1uWzFdO2woZSxzKSYmci5hZGQoYSl9KSxBcnJheS5mcm9tKHIpfSkocCk7aWYoMD09PWUubGVuZ3RoKXJldHVybiB2b2lkIGQucG9zdE1lc3NhZ2Uoe29rOiEwfSk7Y29uc3Qgcj11P2goYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7Zm9yKGNvbnN0IHQgb2YgZSl7Y29uc3QgZT11P3MoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHIpLHt0b2tlbjp0fSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxyKSx7dG9rZW46dH0pKTtsZXQgbixhLGwsaDsiZnVuY3Rpb24iPT10eXBlb2YgQWJvcnRDb250cm9sbGVyJiYobj1uZXcgQWJvcnRDb250cm9sbGVyLGE9bi5zaWduYWwpO3RyeXtoPWF3YWl0IFByb21pc2UucmFjZShbbmV3IFByb21pc2UoZT0+e2w9c2V0VGltZW91dChlLG8pfSksZmV0Y2goaSxPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sYykse2JvZHk6ZSxzaWduYWw6YX0pKV0pLmZpbmFsbHkoKCk9PmNsZWFyVGltZW91dChsKSl9Y2F0Y2goZSl7cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZS5tZXNzYWdlfSl9aWYoIWgpcmV0dXJuIG4mJm4uYWJvcnQoKSx2b2lkIGQucG9zdE1lc3NhZ2Uoe2Vycm9yOiJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCcifSk7aWYoIWgub2spe2xldCBlO3RyeXtjb25zdCB0PUpTT04ucGFyc2UoYXdhaXQgaC50ZXh0KCkpO2U9dC5lcnJvcl9kZXNjcmlwdGlvbn1jYXRjaChlKXt9cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZXx8IkhUVFAgZXJyb3IgIi5jb25jYXQoaC5zdGF0dXMpfSl9Zih0KX1kLnBvc3RNZXNzYWdlKHtvazohMH0pfWNhdGNoKGUpe2QucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZXx8IlVua25vd24gZXJyb3IgZHVyaW5nIHRva2VuIHJldm9jYXRpb24ifSl9fSx5PShlLHQpPT57aWYoIWkpcmV0dXJuITE7dHJ5e2NvbnN0IHI9bmV3IFVSTChpKS5vcmlnaW4sbz1uZXcgVVJMKGUuZmV0Y2hVcmwpO3JldHVybiBvLm9yaWdpbj09PXImJm8ucGF0aG5hbWU9PT10fWNhdGNoKGUpe3JldHVybiExfX07YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZT0+e2NvbnN0IHI9ZS5kYXRhLG89dChlLnBvcnRzLDEpWzBdO2lmKCEoInR5cGUiaW4gcil8fCJpbml0IiE9PXIudHlwZSlyZXR1cm4idHlwZSJpbiByJiYiY2xlYXIiPT09ci50eXBlPyhhPXt9LHZvaWQobnVsbD09b3x8by5wb3N0TWVzc2FnZSh7b2s6ITB9KSkpOiJ0eXBlImluIHImJiJyZXZva2UiPT09ci50eXBlP3kociwiL29hdXRoL3Jldm9rZSIpP3ZvaWQgcChlKTp2b2lkKG51bGw9PW98fG8ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSkpOnZvaWQoImZldGNoVXJsImluIHImJnkociwiL29hdXRoL3Rva2VuIik/ZChlKTpudWxsPT1vfHxvLnBvc3RNZXNzYWdlKHtvazohMSxqc29uOntlcnJvcjoiaW52YWxpZF9mZXRjaF91cmwiLGVycm9yX2Rlc2NyaXB0aW9uOiJVbmF1dGhvcml6ZWQgZmV0Y2ggVVJMIn0saGVhZGVyczp7fX0pKTtpZihudWxsPT09aSl0cnl7bmV3IFVSTChyLmFsbG93ZWRCYXNlVXJsKSxpPXIuYWxsb3dlZEJhc2VVcmx9Y2F0Y2goZSl7cmV0dXJufX0pfSgpOwoK",pt=null,ft=!1,function(e){return mt=mt||dt(ht,pt,ft),new Worker(mt,e)});class wt{constructor(e,t){this.cache=e,this.clientId=t,this.manifestKey=this.createManifestKeyFrom(this.clientId);}async add(e){var t;const n=new Set((null===(t=await this.cache.get(this.manifestKey))||void 0===t?void 0:t.keys)||[]);n.add(e),await this.cache.set(this.manifestKey,{keys:[...n]});}async remove(e){const t=await this.cache.get(this.manifestKey);if(t){const 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 "".concat(ze,"::").concat(e)}}const gt="auth0.is.authenticated",vt={memory:()=>(new He).enclosedCache,localstorage:()=>new Ze},bt=e=>vt[e],_t=t=>{const n=t.openUrl,o=t.onRedirect,i=e(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},i),{openUrl:!1===n||n?n:o})},kt=(e,t,n)=>{const o=(null==e?void 0:e.split(" "))||[],i=n?o.filter(e=>e!==S):o;const r=(null==t?void 0:t.split(" "))||[];return i.filter(e=>-1==r.indexOf(e)).join(",")},St={NONCE:"nonce",KEYPAIR:"keypair"};class Tt{constructor(e){this.clientId=e;}getVersion(){return 1}createDbHandle(){const e=window.indexedDB.open("auth0-spa-js",this.getVersion());return new Promise((t,n)=>{e.onupgradeneeded=()=>Object.values(St).forEach(t=>e.result.createObjectStore(t)),e.onerror=()=>n(e.error),e.onsuccess=()=>t(e.result);})}async getDbHandle(){return this.dbHandle||(this.dbHandle=await this.createDbHandle()),this.dbHandle}async executeDbRequest(e,t,n){const o=n((await this.getDbHandle()).transaction(e,t).objectStore(e));return new Promise((e,t)=>{o.onsuccess=()=>e(o.result),o.onerror=()=>t(o.error);})}buildKey(e){const t=e?"_".concat(e):"auth0";return "".concat(this.clientId,"::").concat(t)}setNonce(e,t){return this.save(St.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save(St.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,"readwrite",e=>e.put(n,t));}findNonce(e){return this.find(St.NONCE,this.buildKey(e))}findKeyPair(){return this.find(St.KEYPAIR,this.buildKey())}find(e,t){return this.executeDbRequest(e,"readonly",e=>e.get(t))}async deleteBy(e,t){const n=await this.executeDbRequest(e,"readonly",e=>e.getAllKeys());await Promise.all((null==n?void 0:n.filter(t).map(t=>this.executeDbRequest(e,"readwrite",e=>e.delete(t))))||[]);}deleteByClientId(e,t){return this.deleteBy(e,e=>"string"==typeof e&&e.startsWith("".concat(t,"::")))}clearNonces(){return this.deleteByClientId(St.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(St.KEYPAIR,this.clientId)}}class Pt{constructor(e){this.storage=new Tt(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 xe(),await this.storage.setKeyPair(e)),e}async generateProof(e){const t=await this.getOrGenerateKeyPair();return Oe(Object.assign({keyPair:t},e))}async calculateThumbprint(){return Ie(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()]);}}var Et;!function(e){e.Bearer="Bearer",e.DPoP="DPoP";}(Et||(Et={}));class Ct{constructor(e,t){this.hooks=t,this.config=Object.assign(Object.assign({},e),{fetch:e.fetch||("undefined"==typeof window?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 "".concat(e.replace(/\/?\/$/,""),"/").concat(t.replace(/^\/+/,""))}throw new 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 "string"==typeof e?e:e instanceof URL?e.href:e.url}buildBaseRequest(e,t){if(!this.config.baseUrl)return new Request(e,t);const n=this.buildUrl(this.config.baseUrl,this.extractUrl(e)),o=e instanceof Request?new Request(n,e):n;return new Request(o,t)}setAuthorizationHeader(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Et.Bearer;e.headers.set("authorization","".concat(n," ").concat(t));}async setDpopProofHeader(e,t){if(!this.config.dpopNonceId)return;const n=await this.hooks.getDpopNonce(),o=await this.hooks.generateDpopProof({accessToken:t,method:e.method,nonce:n,url:e.url});e.headers.set("dpop",o);}async prepareRequest(e,t){const n=await this.getAccessToken(t);if(void 0===n)throw new C("missing_access_token","No access token available");let o,i;"string"==typeof n?(o=this.config.dpopNonceId?Et.DPoP:Et.Bearer,i=n):(o=n.token_type,i=n.access_token),this.setAuthorizationHeader(e,i,o),o===Et.DPoP&&await this.setDpopProofHeader(e,i);}getHeader(e,t){return Array.isArray(e)?new Headers(e).get(t)||"":"function"==typeof e.get?e.get(t)||"":e[t]||""}hasUseDpopNonceError(e){if(401!==e.status)return !1;const t=this.getHeader(e.headers,"www-authenticate");return t.includes("invalid_dpop_nonce")||t.includes("use_dpop_nonce")}async handleResponse(e,t){const n=this.getHeader(e.headers,Ae);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new U(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,o){const i=this.buildBaseRequest(e,t);await this.prepareRequest(i,o);const r=await this.config.fetch(i);return this.handleResponse(r,n)}fetchWithAuth(e,t,n){const o={onUseDpopNonceError:()=>this.internalFetchWithAuth(e,t,Object.assign(Object.assign({},o),{onUseDpopNonceError:void 0}),n)};return this.internalFetchWithAuth(e,t,o,n)}}class At{constructor(e,t){this.myAccountFetcher=e,this.apiBase=t;}async connectAccount(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/connected-accounts/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:connected_accounts"]});return this._handleResponse(t)}async completeAccount(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/connected-accounts/complete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:connected_accounts"]});return this._handleResponse(t)}async getFactors(){const e=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/factors"),{method:"GET"},{scope:["read:me:factors"]});return (await this._handleResponse(e)).factors}async getAuthenticationMethods(e){const t=e?"?".concat(new URLSearchParams({type:e})):"",n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods").concat(t),{method:"GET"},{scope:["read:me:authentication_methods"]});return (await this._handleResponse(n)).authentication_methods}async getAuthenticationMethod(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"GET"},{scope:["read:me:authentication_methods"]});return this._handleResponse(t)}async deleteAuthenticationMethod(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"DELETE"},{scope:["delete:me:authentication_methods"]});t.ok||await this._handleResponse(t);}async updateAuthenticationMethod(e,t){const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},{scope:["update:me:authentication_methods"]});return this._handleResponse(n)}async enrollmentChallenge(e){var t;const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:authentication_methods"]}),o=await this._handleResponse(n),i=null!==(t=n.headers.get("location"))&&void 0!==t?t:"",r=decodeURIComponent(i.split("/").pop()||"");return Object.assign(Object.assign({},o),{id:r,location:i})}async enrollmentVerify(t){const n=t,o=n.location;n.type;const i=e(n,["location","type"]),r=await this.myAccountFetcher.fetchWithAuth("".concat(o,"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)},{scope:["create:me:authentication_methods"]});return this._handleResponse(r)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t);}catch(n){throw new Rt({type:"invalid_json",status:e.status,title:"Invalid JSON response",detail:t||String(n)})}if(e.ok)return t;throw new Rt(t)}}class Rt extends Error{constructor(e){let t=e.type,n=e.status,o=e.title,i=e.detail,r=e.validation_errors;super(i),this.name="MyAccountApiError",this.type=t,this.status=n,this.title=o,this.detail=i,this.validation_errors=r,Object.setPrototypeOf(this,Rt.prototype);}}const xt={otp:{authenticatorTypes:["otp"]},sms:{authenticatorTypes:["oob"],oobChannels:["sms"]},email:{authenticatorTypes:["oob"],oobChannels:["email"]},push:{authenticatorTypes:["oob"],oobChannels:["auth0"]},voice:{authenticatorTypes:["oob"],oobChannels:["voice"]}},It="http://auth0.com/oauth/grant-type/mfa-otp",Ot="http://auth0.com/oauth/grant-type/mfa-oob",jt="http://auth0.com/oauth/grant-type/mfa-recovery-code";var Wt,Nt;let Kt;if("undefined"==typeof navigator||null===(Wt=navigator.userAgent)||void 0===Wt||null===(Nt=Wt.startsWith)||void 0===Nt||!Nt.call(Wt,"Mozilla/5.0 ")){const e="v3.8.6";Kt="".concat("oauth4webapi","/").concat(e);}function Mt(e,t){if(null==e)return !1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch(e){return !1}}const Ut="ERR_INVALID_ARG_VALUE",Lt="ERR_INVALID_ARG_TYPE";function zt(e,t,n){const o=new TypeError(e,{cause:n});return Object.assign(o,{code:t}),o}const Jt=Symbol(),Dt=Symbol(),Zt=Symbol(),Ht=Symbol(),Ft=Symbol(),Vt=Symbol(),Xt=new TextEncoder,Gt=new TextDecoder;function qt(e){return "string"==typeof e?Xt.encode(e):Gt.decode(e)}let Yt,Bt;if(Uint8Array.prototype.toBase64)Yt=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0}));else {const e=32768;Yt=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));const n=[];for(let o=0;o<t.byteLength;o+=e)n.push(String.fromCharCode.apply(null,t.subarray(o,o+e)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};}function Qt(e){return "string"==typeof e?Bt(e):Yt(e)}Bt=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(e){throw zt("The input to be decoded is not correctly encoded.",Ut,e)}}:e=>{try{const 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 zt("The input to be decoded is not correctly encoded.",Ut,e)}};class $t extends Error{constructor(e,t){var n;super(e,t),h(this,"code",void 0),this.name=this.constructor.name,this.code=ao,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}class en extends Error{constructor(e,t){var n;super(e,t),h(this,"code",void 0),this.name=this.constructor.name,null!=t&&t.code&&(this.code=null==t?void 0:t.code),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}function tn(e,t,n){return new en(e,{code:t,cause:n})}function nn(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw zt("".concat(t," must be a CryptoKey"),Lt)}(e,t),"private"!==e.type)throw zt("".concat(t," must be a private CryptoKey"),Ut)}function on(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function rn(e){Mt(e,Headers)&&(e=Object.fromEntries(e.entries()));const t=new Headers(null!=e?e:{});if(Kt&&!t.has("user-agent")&&t.set("user-agent",Kt),t.has("authorization"))throw zt('"options.headers" must not include the "authorization" header name',Ut);return t}function sn(e,t){if(void 0!==t){if("function"==typeof t&&(t=t(e.href)),!(t instanceof AbortSignal))throw zt('"options.signal" must return or be an instance of AbortSignal',Lt);return t}}function an(e){return e.includes("//")?e.replace("//","/"):e}async function cn(e,t){return async function(e,t,n,o){if(!(e instanceof URL))throw zt('"'.concat(t,'" must be an instance of URL'),Lt);kn(e,!0!==(null==o?void 0:o[Jt]));const i=n(new URL(e.href)),r=rn(null==o?void 0:o.headers);return r.set("accept","application/json"),((null==o?void 0:o[Ht])||fetch)(i.href,{body:void 0,headers:Object.fromEntries(r.entries()),method:"GET",redirect:"manual",signal:sn(i,null==o?void 0:o.signal)})}(e,"issuerIdentifier",e=>{switch(null==t?void 0:t.algorithm){case void 0:case"oidc":!function(e,t){e.pathname=an("".concat(e.pathname,"/").concat(t));}(e,".well-known/openid-configuration");break;case"oauth2":!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];"/"===e.pathname?e.pathname=t:e.pathname=an("".concat(t,"/").concat(n?e.pathname:e.pathname.replace(/(\/)$/,"")));}(e,".well-known/oauth-authorization-server");break;default:throw zt('"options.algorithm" must be "oidc" (default), or "oauth2"',Ut)}return e},t)}function un(e,t,n,o,i){try{if("number"!=typeof e||!Number.isFinite(e))throw zt("".concat(n," must be a number"),Lt,i);if(e>0)return;if(t){if(0!==e)throw zt("".concat(n," must be a non-negative number"),Ut,i);return}throw zt("".concat(n," must be a positive number"),Ut,i)}catch(e){if(o)throw tn(e.message,o,i);throw e}}function ln(e,t,n,o){try{if("string"!=typeof e)throw zt("".concat(t," must be a string"),Lt,o);if(0===e.length)throw zt("".concat(t," must not be empty"),Ut,o)}catch(e){if(n)throw tn(e.message,n,o);throw e}}function dn(e){!function(e,t){if(Ln(e)!==t)throw function(e){let t='"response" content-type must be ';for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];if(o.length>2){const e=o.pop();t+="".concat(o.join(", "),", or ").concat(e);}else 2===o.length?t+="".concat(o[0]," or ").concat(o[1]):t+=o[0];return tn(t,po,e)}(e,t)}(e,"application/json");}function hn(){return Qt(crypto.getRandomValues(new Uint8Array(32)))}function pn(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 $t("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 $t("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 $t("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 $t("unsupported CryptoKey algorithm name",{cause:e})}}function fn(e){const t=null==e?void 0:e[Dt];return "number"==typeof t&&Number.isFinite(t)?t:0}function mn(e){const t=null==e?void 0:e[Zt];return "number"==typeof t&&Number.isFinite(t)&&-1!==Math.sign(t)?t:30}function yn(){return Math.floor(Date.now()/1e3)}function wn(e){if("object"!=typeof e||null===e)throw zt('"as" must be an object',Lt);ln(e.issuer,'"as.issuer"');}function gn(e){if("object"!=typeof e||null===e)throw zt('"client" must be an object',Lt);ln(e.client_id,'"client.client_id"');}function vn(e){return ln(e,'"clientSecret"'),(t,n,o,i)=>{o.set("client_id",n.client_id),o.set("client_secret",e);}}function bn(e,t){const n=(r=e)instanceof CryptoKey?{key:r}:(null==r?void 0:r.key)instanceof CryptoKey?(void 0!==r.kid&&ln(r.kid,'"kid"'),{key:r.key,kid:r.kid}):{},o=n.key,i=n.kid;var r;return nn(o,'"clientPrivateKey.key"'),async(e,n,r,s)=>{var a;const c={alg:pn(o),kid:i},u=function(e,t){const n=yn()+fn(t);return {jti:hn(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,n);null==t||null===(a=t[Ft])||void 0===a||a.call(t,c,u),r.set("client_id",n.client_id),r.set("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),r.set("client_assertion",await async function(e,t,n){if(!n.usages.includes("sign"))throw zt('CryptoKey instances used for signing assertions must include "sign" in their "usages"',Ut);const o="".concat(Qt(qt(JSON.stringify(e))),".").concat(Qt(qt(JSON.stringify(t)))),i=Qt(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return {name:e.algorithm.name,hash:Po(e)};case"RSA-PSS":switch(To(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 $t("unsupported RSA-PSS hash name",{cause:e})}case"RSASSA-PKCS1-v1_5":return To(e),e.algorithm.name;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":case"Ed25519":return e.algorithm.name}throw new $t("unsupported CryptoKey algorithm name",{cause:e})}(n),n,qt(o)));return "".concat(o,".").concat(i)}(c,u,o));}}const _n=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch(e){return null}};function kn(e,t){if(t&&"https:"!==e.protocol)throw tn("only requests to HTTPS are allowed",mo,e);if("https:"!==e.protocol&&"http:"!==e.protocol)throw tn("only HTTP and HTTPS requests are allowed",yo,e)}function Sn(e,t,n,o){let i;if("string"!=typeof e||!(i=_n(e)))throw tn("authorization server metadata does not contain a valid ".concat(n?'"as.mtls_endpoint_aliases.'.concat(t,'"'):'"as.'.concat(t,'"')),void 0===e?bo:_o,{attribute:n?"mtls_endpoint_aliases.".concat(t):t});return kn(i,o),i}function Tn(e,t,n,o){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?Sn(e.mtls_endpoint_aliases[t],t,n,o):Sn(e[t],t,n,o)}class Pn extends Error{constructor(e,t){var n;super(e,t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"error",void 0),h(this,"status",void 0),h(this,"error_description",void 0),h(this,"response",void 0),this.name=this.constructor.name,this.code=so,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}),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}class En extends Error{constructor(e,t){var n,o;super(e,t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"error",void 0),h(this,"error_description",void 0),this.name=this.constructor.name,this.code=co,this.cause=t.cause,this.error=t.cause.get("error"),this.error_description=null!==(n=t.cause.get("error_description"))&&void 0!==n?n:void 0,null===(o=Error.captureStackTrace)||void 0===o||o.call(Error,this,this.constructor);}}class Cn extends Error{constructor(e,t){var n;super(e,t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"response",void 0),h(this,"status",void 0),this.name=this.constructor.name,this.code=ro,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,"response",{enumerable:!1}),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}const An="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",Rn="("+An+')\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"',xn="("+An+")\\s*=\\s*("+An+")",In=new RegExp("^[,\\s]*("+An+")"),On=new RegExp("^[,\\s]*"+Rn+"[,\\s]*(.*)"),jn=new RegExp("^[,\\s]*"+xn+"[,\\s]*(.*)"),Wn=new RegExp("^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)");async function Nn(e,t,n){if(e.status!==t){let t;var o;if(Xn(e),t=await async function(e){if(e.status>399&&e.status<500){So(e),dn(e);try{const t=await e.clone().json();if(on(t)&&"string"==typeof t.error&&t.error.length)return t}catch(e){}}}(e))throw await(null===(o=e.body)||void 0===o?void 0:o.cancel()),new Pn("server responded with an error in the response body",{cause:t,response:e});throw tn('"response" is not a conform '.concat(n," response (unexpected HTTP status code)"),fo,e)}}function Kn(e){if(!Qn.has(e))throw zt('"options.DPoP" is not a valid DPoPHandle',Ut)}async function Mn(e,t,n,o){wn(e),gn(t);const i=Tn(e,"userinfo_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==o?void 0:o[Jt])),r=rn(null==o?void 0:o.headers);return t.userinfo_signed_response_alg?r.set("accept","application/jwt"):(r.set("accept","application/json"),r.append("accept","application/jwt")),async function(e,t,n,o,i,r){var s;if(ln(e,'"accessToken"'),!(n instanceof URL))throw zt('"url" must be an instance of URL',Lt);kn(n,!0!==(null==r?void 0:r[Jt])),o=rn(o),null!=r&&r.DPoP&&(Kn(r.DPoP),await r.DPoP.addProof(n,o,t.toUpperCase(),e)),o.set("authorization","".concat(o.has("dpop")?"DPoP":"Bearer"," ").concat(e));const a=await((null==r?void 0:r[Ht])||fetch)(n.href,{duplex:Mt(i,ReadableStream)?"half":void 0,body:i,headers:Object.fromEntries(o.entries()),method:t,redirect:"manual",signal:sn(n,null==r?void 0:r.signal)});return null==r||null===(s=r.DPoP)||void 0===s||s.cacheNonce(a,n),a}(n,"GET",i,r,null,f(f({},o),{},{[Dt]:fn(t)}))}const Un=Symbol();function Ln(e){var t;return null===(t=e.headers.get("content-type"))||void 0===t?void 0:t.split(";")[0]}async function zn(e,t,n,o,i){if(wn(e),gn(t),!Mt(o,Response))throw zt('"response" must be an instance of Response',Lt);if(Xn(o),200!==o.status)throw tn('"response" is not a conform UserInfo Endpoint response (unexpected HTTP status code)',fo,o);let r;if(So(o),"application/jwt"===Ln(o)){const n=await Eo(await o.text(),Ao.bind(void 0,t.userinfo_signed_response_alg,e.userinfo_signing_alg_values_supported,void 0),fn(t),mn(t),null==i?void 0:i[Vt]).then(Gn.bind(void 0,t.client_id)).then(Yn.bind(void 0,e)),s=n.claims,a=n.jwt;Hn.set(o,a),r=s;}else {if(t.userinfo_signed_response_alg)throw tn("JWT UserInfo Response expected",uo,o);r=await jo(o);}if(ln(r.sub,'"response" body "sub" property',ho,{body:r}),n===Un);else if(ln(n,'"expectedSubject"'),r.sub!==n)throw tn('unexpected "response" body "sub" property value',vo,{expected:n,body:r,attribute:"sub"});return r}async function Jn(e,t,n,o,i,r,s){return await n(e,t,i,r),r.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),((null==s?void 0:s[Ht])||fetch)(o.href,{body:i,headers:Object.fromEntries(r.entries()),method:"POST",redirect:"manual",signal:sn(o,null==s?void 0:s.signal)})}async function Dn(e,t,n,o,i,r){var s;const a=Tn(e,"token_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==r?void 0:r[Jt]));i.set("grant_type",o);const c=rn(null==r?void 0:r.headers);c.set("accept","application/json"),void 0!==(null==r?void 0:r.DPoP)&&(Kn(r.DPoP),await r.DPoP.addProof(a,c,"POST"));const u=await Jn(e,t,n,a,i,c,r);return null==r||null===(s=r.DPoP)||void 0===s||s.cacheNonce(u,a),u}const Zn=new WeakMap,Hn=new WeakMap;function Fn(e){if(!e.id_token)return;const t=Zn.get(e);if(!t)throw zt('"ref" was already garbage collected or did not resolve from the proper sources',Ut);return t}async function Vn(e,t,n,o,i,r){if(wn(e),gn(t),!Mt(n,Response))throw zt('"response" must be an instance of Response',Lt);await Nn(n,200,"Token Endpoint"),So(n);const s=await jo(n);if(ln(s.access_token,'"response" body "access_token" property',ho,{body:s}),ln(s.token_type,'"response" body "token_type" property',ho,{body:s}),s.token_type=s.token_type.toLowerCase(),void 0!==s.expires_in){let e="number"!=typeof s.expires_in?parseFloat(s.expires_in):s.expires_in;un(e,!0,'"response" body "expires_in" property',ho,{body:s}),s.expires_in=e;}if(void 0!==s.refresh_token&&ln(s.refresh_token,'"response" body "refresh_token" property',ho,{body:s}),void 0!==s.scope&&"string"!=typeof s.scope)throw tn('"response" body "scope" property must be a string',ho,{body:s});if(void 0!==s.id_token){ln(s.id_token,'"response" body "id_token" property',ho,{body:s});const r=["aud","exp","iat","iss","sub"];!0===t.require_auth_time&&r.push("auth_time"),void 0!==t.default_max_age&&(un(t.default_max_age,!0,'"client.default_max_age"'),r.push("auth_time")),null!=o&&o.length&&r.push(...o);const a=await Eo(s.id_token,Ao.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),fn(t),mn(t),i).then(to.bind(void 0,r)).then(Bn.bind(void 0,e)).then(qn.bind(void 0,t.client_id)),c=a.claims,u=a.jwt;if(Array.isArray(c.aud)&&1!==c.aud.length){if(void 0===c.azp)throw tn('ID Token "aud" (audience) claim includes additional untrusted audiences',go,{claims:c,claim:"aud"});if(c.azp!==t.client_id)throw tn('unexpected ID Token "azp" (authorized party) claim value',go,{expected:t.client_id,claims:c,claim:"azp"})}void 0!==c.auth_time&&un(c.auth_time,!0,'ID Token "auth_time" (authentication time)',ho,{claims:c}),Hn.set(n,u),Zn.set(s,c);}if(void 0!==(null==r?void 0:r[s.token_type]))r[s.token_type](n,s);else if("dpop"!==s.token_type&&"bearer"!==s.token_type)throw new $t("unsupported `token_type` value",{cause:{body:s}});return s}function Xn(e){let t;if(t=function(e){if(!Mt(e,Response))throw zt('"response" must be an instance of Response',Lt);const t=e.headers.get("www-authenticate");if(null===t)return;const n=[];let o=t;for(;o;){var i;let e=o.match(In);const t=null===(i=e)||void 0===i?void 0:i[1].toLowerCase();if(!t)return;const c=o.substring(e[0].length);if(c&&!c.match(/^[\s,]/))return;const u=c.match(/^\s+(.*)$/),l=!!u;o=u?u[1]:void 0;const d={};let h;if(l)for(;o;){let t,n;if(e=o.match(On)){var r=y(e,4);if(t=r[1],n=r[2],o=r[3],n.includes("\\"))try{n=JSON.parse('"'.concat(n,'"'));}catch(e){}d[t.toLowerCase()]=n;}else {if(!(e=o.match(jn))){if(e=o.match(Wn)){if(Object.keys(d).length)break;var s=y(e,3);h=s[1],o=s[2];break}return}var a=y(e,4);t=a[1],n=a[2],o=a[3],d[t.toLowerCase()]=n;}}else o=c||void 0;const p={scheme:t,parameters:d};h&&(p.token68=h),n.push(p);}return n.length?n:void 0}(e))throw new Cn("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:t,response:e})}function Gn(e,t){return void 0!==t.claims.aud?qn(e,t):t}function qn(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw tn('unexpected JWT "aud" (audience) claim value',go,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw tn('unexpected JWT "aud" (audience) claim value',go,{expected:e,claims:t.claims,claim:"aud"});return t}function Yn(e,t){return void 0!==t.claims.iss?Bn(e,t):t}function Bn(e,t){var n,o;const i=null!==(n=null===(o=e[No])||void 0===o?void 0:o.call(e,t))&&void 0!==n?n:e.issuer;if(t.claims.iss!==i)throw tn('unexpected JWT "iss" (issuer) claim value',go,{expected:i,claims:t.claims,claim:"iss"});return t}const Qn=new WeakSet;const $n=Symbol();const eo={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 to(e,t){for(const n of e)if(void 0===t.claims[n])throw tn('JWT "'.concat(n,'" (').concat(eo[n],") claim missing"),ho,{claims:t.claims});return t}const no=Symbol(),oo=Symbol();async function io(e,t,n,o){return "string"==typeof(null==o?void 0:o.expectedNonce)||"number"==typeof(null==o?void 0:o.maxAge)||null!=o&&o.requireIdToken?async function(e,t,n,o,i,r,s){const a=[];switch(o){case void 0:o=no;break;case no:break;default:ln(o,'"expectedNonce" argument'),a.push("nonce");}switch(null!=i||(i=t.default_max_age),i){case void 0:i=oo;break;case oo:break;default:un(i,!0,'"maxAge" argument'),a.push("auth_time");}const c=await Vn(e,t,n,a,r,s);ln(c.id_token,'"response" body "id_token" property',ho,{body:c});const u=Fn(c);if(i!==oo){const e=yn()+fn(t),n=mn(t);if(u.auth_time+i<e-n)throw tn("too much time has elapsed since the last End-User authentication",wo,{claims:u,now:e,tolerance:n,claim:"auth_time"})}if(o===no){if(void 0!==u.nonce)throw tn('unexpected ID Token "nonce" claim value',go,{expected:void 0,claims:u,claim:"nonce"})}else if(u.nonce!==o)throw tn('unexpected ID Token "nonce" claim value',go,{expected:o,claims:u,claim:"nonce"});return c}(e,t,n,o.expectedNonce,o.maxAge,o[Vt],o.recognizedTokenTypes):async function(e,t,n,o,i){const r=await Vn(e,t,n,void 0,o,i),s=Fn(r);if(s){if(void 0!==t.default_max_age){un(t.default_max_age,!0,'"client.default_max_age"');const e=yn()+fn(t),n=mn(t);if(s.auth_time+t.default_max_age<e-n)throw tn("too much time has elapsed since the last End-User authentication",wo,{claims:s,now:e,tolerance:n,claim:"auth_time"})}if(void 0!==s.nonce)throw tn('unexpected ID Token "nonce" claim value',go,{expected:void 0,claims:s,claim:"nonce"})}return r}(e,t,n,null==o?void 0:o[Vt],null==o?void 0:o.recognizedTokenTypes)}const ro="OAUTH_WWW_AUTHENTICATE_CHALLENGE",so="OAUTH_RESPONSE_BODY_ERROR",ao="OAUTH_UNSUPPORTED_OPERATION",co="OAUTH_AUTHORIZATION_RESPONSE_ERROR",uo="OAUTH_JWT_USERINFO_EXPECTED",lo="OAUTH_PARSE_ERROR",ho="OAUTH_INVALID_RESPONSE",po="OAUTH_RESPONSE_IS_NOT_JSON",fo="OAUTH_RESPONSE_IS_NOT_CONFORM",mo="OAUTH_HTTP_REQUEST_FORBIDDEN",yo="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",wo="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",go="OAUTH_JWT_CLAIM_COMPARISON_FAILED",vo="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED",bo="OAUTH_MISSING_SERVER_METADATA",_o="OAUTH_INVALID_SERVER_METADATA";async function ko(e){if(!Mt(e,Response))throw zt('"response" must be an instance of Response',Lt);await Nn(e,200,"Revocation Endpoint");}function So(e){if(e.bodyUsed)throw zt('"response" body has been used already',Ut)}function To(e){const t=e.algorithm;if("number"!=typeof t.modulusLength||t.modulusLength<2048)throw new $t("unsupported ".concat(t.name," modulusLength"),{cause:e})}function Po(e){switch(e.algorithm.namedCurve){case"P-256":return "SHA-256";case"P-384":return "SHA-384";case"P-521":return "SHA-512";default:throw new $t("unsupported ECDSA namedCurve",{cause:e})}}async function Eo(e,t,n,o,i){let r,s,a=e.split("."),c=a[0],u=a[1],l=a.length;if(5===l){if(void 0===i)throw new $t("JWE decryption is not configured",{cause:e});var d=(e=await i(e)).split(".");c=d[0],u=d[1],l=d.length;}if(3!==l)throw tn("Invalid JWT",ho,e);try{r=JSON.parse(qt(Qt(c)));}catch(e){throw tn("failed to parse JWT Header body as base64url encoded JSON",lo,e)}if(!on(r))throw tn("JWT Header must be a top level object",ho,e);if(t(r),void 0!==r.crit)throw new $t('no JWT "crit" header parameter extensions are supported',{cause:{header:r}});try{s=JSON.parse(qt(Qt(u)));}catch(e){throw tn("failed to parse JWT Payload body as base64url encoded JSON",lo,e)}if(!on(s))throw tn("JWT Payload must be a top level object",ho,e);const h=yn()+n;if(void 0!==s.exp){if("number"!=typeof s.exp)throw tn('unexpected JWT "exp" (expiration time) claim type',ho,{claims:s});if(s.exp<=h-o)throw tn('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',wo,{claims:s,now:h,tolerance:o,claim:"exp"})}if(void 0!==s.iat&&"number"!=typeof s.iat)throw tn('unexpected JWT "iat" (issued at) claim type',ho,{claims:s});if(void 0!==s.iss&&"string"!=typeof s.iss)throw tn('unexpected JWT "iss" (issuer) claim type',ho,{claims:s});if(void 0!==s.nbf){if("number"!=typeof s.nbf)throw tn('unexpected JWT "nbf" (not before) claim type',ho,{claims:s});if(s.nbf>h+o)throw tn('unexpected JWT "nbf" (not before) claim value',wo,{claims:s,now:h,tolerance:o,claim:"nbf"})}if(void 0!==s.aud&&"string"!=typeof s.aud&&!Array.isArray(s.aud))throw tn('unexpected JWT "aud" (audience) claim type',ho,{claims:s});return {header:r,claims:s,jwt:e}}async function Co(e){if("POST"!==e.method)throw zt("form_post responses are expected to use the POST method",Ut,{cause:e});if("application/x-www-form-urlencoded"!==Ln(e))throw zt("form_post responses are expected to use the application/x-www-form-urlencoded content-type",Ut,{cause:e});return async function(e){if(e.bodyUsed)throw zt("form_post Request instances must contain a readable body",Ut,{cause:e});return e.text()}(e)}function Ao(e,t,n,o){if(void 0===e)if(Array.isArray(t)){if(!t.includes(o.alg))throw tn('unexpected JWT "alg" header parameter',ho,{header:o,expected:t,reason:"authorization server metadata"})}else {if(void 0===n)throw tn('missing client or server configuration to verify used JWT "alg" header parameter',void 0,{client:e,issuer:t,fallback:n});if("string"==typeof n?o.alg!==n:"function"==typeof n?!n(o.alg):!n.includes(o.alg))throw tn('unexpected JWT "alg" header parameter',ho,{header:o,expected:n,reason:"default value"})}else if("string"==typeof e?o.alg!==e:!e.includes(o.alg))throw tn('unexpected JWT "alg" header parameter',ho,{header:o,expected:e,reason:"client configuration"})}function Ro(e,t){const n=e.getAll(t),o=n[0];if(n.length>1)throw tn('"'.concat(t,'" parameter must be provided only once'),ho);return o}const xo=Symbol(),Io=Symbol();function Oo(e,t,n,o){if(wn(e),gn(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw zt('"parameters" must be an instance of URLSearchParams, or URL',Lt);if(Ro(n,"response"))throw tn('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',ho,{parameters:n});const i=Ro(n,"iss"),r=Ro(n,"state");if(!i&&e.authorization_response_iss_parameter_supported)throw tn('response parameter "iss" (issuer) missing',ho,{parameters:n});if(i&&i!==e.issuer)throw tn('unexpected "iss" (issuer) response parameter value',ho,{expected:e.issuer,parameters:n});switch(o){case void 0:case Io:if(void 0!==r)throw tn('unexpected "state" response parameter encountered',ho,{expected:void 0,parameters:n});break;case xo:break;default:if(ln(o,'"expectedState" argument'),r!==o)throw tn(void 0===r?'response parameter "state" missing':'unexpected "state" response parameter value',ho,{expected:o,parameters:n})}if(Ro(n,"error"))throw new En("authorization response from the server is an error",{cause:n});const s=Ro(n,"id_token"),a=Ro(n,"token");if(void 0!==s||void 0!==a)throw new $t("implicit and hybrid flows are not supported");return c=new URLSearchParams(n),Qn.add(c),c;var c;}async function jo(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dn;try{t=await e.json();}catch(t){throw n(e),tn('failed to parse "response" body as JSON',lo,t)}if(!on(t))throw tn('"response" body must be a top level object',ho,{body:t});return t}const Wo=Symbol(),No=Symbol(),Ko=new TextEncoder,Mo=new TextDecoder,Uo=new TextDecoder("utf-8",{fatal:!0});function Lo(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const o=t.reduce((e,t)=>e+t.length,0),i=new Uint8Array(o);let r=0;for(const e of t)i.set(e,r),r+=e.length;return i}function zo(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){const o=e.charCodeAt(n);if(o>127)throw new TypeError("non-ASCII string encountered in encode()");t[n]=o;}return t}const Jo=function(e){return new TypeError("CryptoKey does not support this operation, its ".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"algorithm.name"," must be ").concat(e))};function Do(e,t,n){var o;const i=e.algorithm;if(i.name!==t.name)throw Jo(t.name);if(t.hash&&(null===(o=i.hash)||void 0===o?void 0:o.name)!==t.hash)throw Jo(t.hash,"algorithm.hash");if(t.namedCurve&&i.namedCurve!==t.namedCurve)throw Jo(t.namedCurve,"algorithm.namedCurve");if(void 0!==t.length&&i.length!==t.length)throw Jo(t.length,"algorithm.length");!function(e,t){if(t&&!e.usages.includes(t))throw new TypeError("CryptoKey does not support this operation, its usages must include ".concat(t,"."))}(e,n);}const Zo=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];return function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];if(o.length>2){const t=o.pop();e+="one of type ".concat(o.join(", "),", or ").concat(t,".");}else 2===o.length?e+="one of type ".concat(o[0]," or ").concat(o[1],"."):e+="of type ".concat(o[0],".");if(null==t)e+=" Received ".concat(t);else if("function"==typeof t&&t.name)e+=" Received function ".concat(t.name);else if("object"==typeof t&&null!=t){var r;null!==(r=t.constructor)&&void 0!==r&&r.name&&(e+=" Received an instance of ".concat(t.constructor.name));}return e}("Key for the ".concat(e," algorithm must be "),t,...o)};class Ho extends Error{constructor(e,t){var n;super(e,t),h(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}h(Ho,"code","ERR_JOSE_GENERIC");class Fo extends Ho{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:o,payload:t}}),h(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),h(this,"claim",void 0),h(this,"reason",void 0),h(this,"payload",void 0),this.claim=n,this.reason=o,this.payload=t;}}h(Fo,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class Vo extends Ho{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:o,payload:t}}),h(this,"code","ERR_JWT_EXPIRED"),h(this,"claim",void 0),h(this,"reason",void 0),h(this,"payload",void 0),this.claim=n,this.reason=o,this.payload=t;}}h(Vo,"code","ERR_JWT_EXPIRED");class Xo extends Ho{constructor(){super(...arguments),h(this,"code","ERR_JOSE_ALG_NOT_ALLOWED");}}h(Xo,"code","ERR_JOSE_ALG_NOT_ALLOWED");class Go extends Ho{constructor(){super(...arguments),h(this,"code","ERR_JOSE_NOT_SUPPORTED");}}h(Go,"code","ERR_JOSE_NOT_SUPPORTED");h(class extends Ho{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"decryption operation failed",arguments.length>1?arguments[1]:void 0),h(this,"code","ERR_JWE_DECRYPTION_FAILED");}},"code","ERR_JWE_DECRYPTION_FAILED");h(class extends Ho{constructor(){super(...arguments),h(this,"code","ERR_JWE_INVALID");}},"code","ERR_JWE_INVALID");class qo extends Ho{constructor(){super(...arguments),h(this,"code","ERR_JWS_INVALID");}}h(qo,"code","ERR_JWS_INVALID");class Yo extends Ho{constructor(){super(...arguments),h(this,"code","ERR_JWT_INVALID");}}h(Yo,"code","ERR_JWT_INVALID");h(class extends Ho{constructor(){super(...arguments),h(this,"code","ERR_JWK_INVALID");}},"code","ERR_JWK_INVALID");class Bo extends Ho{constructor(){super(...arguments),h(this,"code","ERR_JWKS_INVALID");}}h(Bo,"code","ERR_JWKS_INVALID");class Qo extends Ho{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"no applicable key found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),h(this,"code","ERR_JWKS_NO_MATCHING_KEY");}}h(Qo,"code","ERR_JWKS_NO_MATCHING_KEY");class $o extends Ho{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"multiple matching keys found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),h(this,Symbol.asyncIterator,w(function*(){})),h(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");}}h($o,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class ei extends Ho{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"request timed out",arguments.length>1?arguments[1]:void 0),h(this,"code","ERR_JWKS_TIMEOUT");}}h(ei,"code","ERR_JWKS_TIMEOUT");class ti extends Ho{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"signature verification failed",arguments.length>1?arguments[1]:void 0),h(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");}}h(ti,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");const ni=e=>{if("CryptoKey"===(null==e?void 0:e[Symbol.toStringTag]))return !0;try{return e instanceof CryptoKey}catch(e){return !1}},oi=e=>ni(e)||(e=>"KeyObject"===(null==e?void 0:e[Symbol.toStringTag]))(e);function ii(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}const ri="The input to be decoded is not correctly encoded.";function si(e){if(Uint8Array.fromBase64)try{return Uint8Array.fromBase64("string"==typeof e?e:Mo.decode(e),{alphabet:"base64url"})}catch(e){throw new TypeError(ri,{cause:e})}let t=e;if(t instanceof Uint8Array&&(t=Mo.decode(t)),t.includes("+")||t.includes("/"))throw new TypeError(ri);t=t.replace(/-/g,"+").replace(/_/g,"/");try{return ii(t)}catch(e){throw new TypeError(ri)}}function ai(e){let t=e;return "string"==typeof t&&(t=Ko.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:"base64url",omitPadding:!0}):function(e){if(Uint8Array.prototype.toBase64)return e.toBase64();const t=[];for(let n=0;n<e.length;n+=32768)t.push(String.fromCharCode.apply(null,e.subarray(n,n+32768)));return btoa(t.join(""))}(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function ci(e){if("object"!=typeof e||null===e||"[object Object]"!==Object.prototype.toString.call(e))return !1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}function ui(e){return ci(e)&&Array.isArray(e.keys)&&Array.from(e.keys).every(ci)}function li(e,t,n){try{return si(e)}catch(e){throw new n("Failed to base64url decode the ".concat(t))}}async function di(e,t){var n,o,i,r;if("RSA"===t.kty&&"oth"in t&&void 0!==t.oth)throw new Go('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');if(!e.kty.includes(t.kty))throw new Go('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');const s=null!==(n=null===(o=e.resolve)||void 0===o?void 0:o.call(e,{kty:t.kty,crv:t.crv}))&&void 0!==n?n:e.subtle,a=!(!t.d&&!t.priv),c=f({},t);return "AKP"!==c.kty&&delete c.alg,delete c.use,crypto.subtle.importKey("jwk",c,s,null!==(i=t.ext)&&void 0!==i?i:!a,null!==(r=t.key_ops)&&void 0!==r?r:e.usages[a?1:0])}function hi(e){return f({__proto__:null},e)}const pi=e=>e[Symbol.toStringTag];function fi(e,t,n){const o=e.alg,i=e.secret,r="decrypt"===n||"sign"===n;if(i&&t instanceof Uint8Array)return [mi,t];if(ci(t)){const s=function(e){const t=hi(e);if(void 0!==t.ext&&"boolean"!=typeof t.ext)throw new TypeError('"ext" (Extractable) Parameter must be a boolean');if(void 0!==t.key_ops){const e=t.key_ops,n=Array.isArray(e)?[...e]:void 0;if(!n||n.some(e=>"string"!=typeof e)||new Set(n).size!==n.length)throw new TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');t.key_ops=n;}return t}(t);if("string"!=typeof s.kty)throw new TypeError(i?Zo(o,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"):Zo(o,t,"CryptoKey","KeyObject","JSON Web Key"));if(!(i?"oct"===s.kty&&"string"==typeof s.k:"oct"!==s.kty&&(r?"AKP"===s.kty&&"string"==typeof s.priv||"string"==typeof s.d:void 0===s.d&&void 0===s.priv)))throw new TypeError(i?'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present':"JSON Web Key for this operation must be a ".concat(r?"private":"public"," JWK"));return ((e,t,n)=>{const o=e.alg;if(void 0!==t.use){const e="sign"===n||"verify"===n?"sig":"enc";if(t.use!==e)throw new TypeError('Invalid key for this operation, its "use" must be "'.concat(e,'" when present'))}if(void 0!==t.alg&&t.alg!==o)throw new TypeError('Invalid key for this operation, its "alg" must be "'.concat(o,'" when present'));if(Array.isArray(t.key_ops)){var i;const o="encrypt"===n||"decrypt"===n?null===(i=e.ops)||void 0===i?void 0:i["encrypt"===n?0:1]:n;if(o&&!t.key_ops.includes(o))throw new TypeError('Invalid key for this operation, its "key_ops" must include "'.concat(o,'" when present'))}})(e,s,n),[gi,t,s]}if(!oi(t))throw new TypeError(i?Zo(o,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"):Zo(o,t,"CryptoKey","KeyObject","JSON Web Key"));if(i){if("secret"!==t.type)throw new TypeError("".concat(pi(t),' instances for symmetric algorithms must be of type "secret"'))}else {if("secret"===t.type)throw new TypeError("".concat(pi(t),' instances for asymmetric algorithms must not be of type "secret"'));const e=r?"private":"public";if(("public"===t.type||"private"===t.type)&&t.type!==e){const o="sign"===n?"signing":"verify"===n?"verifying":"".concat(n.slice(0,-1),"tion");throw new TypeError("".concat(pi(t)," instances for asymmetric algorithm ").concat(o,' must be of type "').concat(e,'"'))}}return ni(t)?[yi,t]:[wi,t]}const mi=0,yi=1,wi=2,gi=3;let vi;const bi={__proto__:null,prime256v1:"P-256",secp384r1:"P-384",secp521r1:"P-521"};function _i(e,t,n){vi||(vi=new WeakMap);const o=vi.get(e);return n&&(o?o[t]=n:vi.set(e,{[t]:n})),null!=n?n:null==o?void 0:o[t]}const ki=async(e,t,n)=>{var o;return null!==(o=_i(e,n.alg))&&void 0!==o?o:_i(e,n.alg,await di(n,f(f({},t),{},{alg:n.alg})))};async function Si(e,t,n){const o=fi(e,t,n);switch(o[0]){case mi:case yi:return o[1];case gi:{const t=o[1],n=o[2];if("oct"===n.kty)return si(n.k);if(!Object.isFrozen(t)){const e=t.key_ops;Array.isArray(e)&&Object.freeze(e),Object.freeze(t);}return ki(t,n,e)}case wi:{const t=o[1];return "secret"===t.type?t.export():"toCryptoKey"in t&&"function"==typeof t.toCryptoKey?((e,t)=>{var n,o,i;const r=_i(e,t.alg);if(r)return r;const s="public"===e.type,a=t.usages[s?0:1],c=e.asymmetricKeyType,u=bi[null===(n=e.asymmetricKeyDetails)||void 0===n?void 0:n.namedCurve],l=null!==(o=null===(i=t.resolve)||void 0===i?void 0:i.call(t,{crv:u,asymmetricKeyType:c}))&&void 0!==o?o:t.subtle;return _i(e,t.alg,e.toCryptoKey(l,s,a))})(t,e):ki(t,t.export({format:"jwk"}),e)}}}function Ti(e){const t={__proto__:null};for(const n in e)t[n]=f(f({},e[n]),{},{alg:n});return t}const Pi=[["encrypt","wrapKey"],["decrypt","unwrapKey"]],Ei=[[],["deriveBits"]],Ci=[[],[]];function Ai(e){return {kty:["RSA"],subtle:{name:"RSA-OAEP",hash:"SHA-".concat(e)},usages:Pi,ops:["wrapKey","unwrapKey"]}}function Ri(){return {kty:["EC","OKP"],subtle:{name:"ECDH"},resolve:e=>{let t=e.kty,n=e.crv,o=e.asymmetricKeyType;if("X25519"===n||"x25519"===o)return {name:"X25519"};if("OKP"===t)throw new Go('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');return {name:"ECDH",namedCurve:n}},usages:Ei,ops:[void 0,"deriveBits"]}}function xi(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return {kty:["oct"],secret:!0,subtle:{name:t?"AES-GCM":"AES-KW",length:e},usages:Ci,ops:t?["encrypt","decrypt"]:["wrapKey","unwrapKey"]}}function Ii(){return {kty:["oct"],secret:!0,subtle:{name:"PBKDF2"},usages:Ci,ops:["deriveBits","deriveBits"]}}const Oi=Ti({dir:{kty:["oct"],secret:!0,subtle:{name:"AES-GCM"},usages:Ci,ops:["encrypt","decrypt"]},"RSA-OAEP":Ai(1),"RSA-OAEP-256":Ai(256),"RSA-OAEP-384":Ai(384),"RSA-OAEP-512":Ai(512),"ECDH-ES":Ri(),"ECDH-ES+A128KW":Ri(),"ECDH-ES+A192KW":Ri(),"ECDH-ES+A256KW":Ri(),A128KW:xi(128),A192KW:xi(192),A256KW:xi(256),A128GCMKW:xi(128,!0),A192GCMKW:xi(192,!0),A256GCMKW:xi(256,!0),"PBES2-HS256+A128KW":Ii(),"PBES2-HS384+A192KW":Ii(),"PBES2-HS512+A256KW":Ii()}),ji=["encrypt","decrypt"];function Wi(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return {kty:["oct"],secret:!0,subtle:{name:t?"AES-CBC":"AES-GCM",length:e},usages:Ci,ops:ji,cekBits:e,ivBits:t?128:96,cbc:t}}Ti({A128GCM:Wi(128),A192GCM:Wi(192),A256GCM:Wi(256),"A128CBC-HS256":Wi(256,!0),"A192CBC-HS384":Wi(384,!0),"A256CBC-HS512":Wi(512,!0)});const Ni={__proto__:null,b64:!0};function Ki(e,t){if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw new TypeError('"'.concat(e,'" option must be an array of strings'));if(t)return new Set(t)}function Mi(e,t,n,o,i){if(void 0!==i.crit&&void 0===(null==o?void 0:o.crit))throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!o||void 0===o.crit)return [];if(!Array.isArray(o.crit)||0===o.crit.length||o.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');const r=void 0===n?t:f(f({__proto__:null},n),t);for(const t of o.crit){if(!(t in r))throw new Go('Extension Header Parameter "'.concat(t,'" is not recognized'));if(!Object.hasOwn(i,t)||void 0===i[t])throw new e('Extension Header Parameter "'.concat(t,'" is missing'));if(r[t]&&(!Object.hasOwn(o,t)||void 0===o[t]))throw new e('Extension Header Parameter "'.concat(t,'" MUST be integrity protected'))}return o.crit}function Ui(e,t){if(t.includes("b64")){const t=e.b64;if("boolean"!=typeof t)throw new qo('The "b64" (base64url-encode payload) Header Parameter must be a boolean');return t}return !0}var Li,zi;let Ji,Di;if("undefined"==typeof navigator||null===(Li=navigator.userAgent)||void 0===Li||null===(zi=Li.startsWith)||void 0===zi||!zi.call(Li,"Mozilla/5.0 ")){const e="v6.8.4";Di="".concat("openid-client","/").concat(e),Ji={"user-agent":Di};}const Zi=e=>Hi.get(e);let Hi,Fi;function Vi(e){return void 0!==e?vn(e):(Fi||(Fi=new WeakMap),(e,t,n,o)=>{let i;return (i=Fi.get(t))||(!function(e,t){if("string"!=typeof e)throw Bi("".concat(t," must be a string"),Yi);if(0===e.length)throw Bi("".concat(t," must not be empty"),qi)}(t.client_secret,'"metadata.client_secret"'),i=vn(t.client_secret),Fi.set(t,i)),i(e,t,n,o)})}const Xi=Un,Gi=Ht,qi="ERR_INVALID_ARG_VALUE",Yi="ERR_INVALID_ARG_TYPE";function Bi(e,t,n){const o=new TypeError(e,{cause:n});return Object.assign(o,{code:t}),o}function Qi(e){return async function(e){return ln(e,"codeVerifier"),Qt(await crypto.subtle.digest("SHA-256",qt(e)))}(e)}function $i(){return hn()}class er extends Error{constructor(e,t){var n;super(e,t),h(this,"code",void 0),this.name=this.constructor.name,this.code=null==t?void 0:t.code,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}function tr(e,t,n){return new er(e,{cause:t,code:n})}function nr(e){if(e instanceof TypeError||e instanceof er||e instanceof Pn||e instanceof En||e instanceof Cn)throw e;if(e instanceof en)switch(e.code){case mo:throw tr("only requests to HTTPS are allowed",e,e.code);case yo:throw tr("only requests to HTTP or HTTPS are allowed",e,e.code);case fo:throw tr("unexpected HTTP response status code",e.cause,e.code);case po:throw tr("unexpected response content-type",e.cause,e.code);case lo:throw tr("parsing error occured",e,e.code);case ho:throw tr("invalid response encountered",e,e.code);case go:throw tr("unexpected JWT claim value encountered",e,e.code);case vo:throw tr("unexpected JSON attribute value encountered",e,e.code);case wo:throw tr("JWT timestamp claim value failed validation",e,e.code);default:throw tr(e.message,e,e.code)}if(e instanceof $t)throw tr("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw tr("runtime operation error",e,ao);case"NotSupportedError":throw tr("runtime unsupported operation",e,ao);case"TimeoutError":throw tr("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw tr("operation aborted",e,"OAUTH_ABORT")}throw new er("something went wrong",{cause:e})}async function or(e,t,n,o,i){const r=await async function(e,t){var n,o;if(!(e instanceof URL))throw Bi('"server" must be an instance of URL',Yi);const i=!e.href.includes("/.well-known/"),r=null!==(n=null==t?void 0:t.timeout)&&void 0!==n?n:30,s=AbortSignal.timeout(1e3*r),a=await(i?cn(e,{algorithm:null==t?void 0:t.algorithm,[Ht]:null==t?void 0:t[Gi],[Jt]:null==t||null===(o=t.execute)||void 0===o?void 0:o.includes(dr),signal:s,headers:new Headers(Ji)}):((null==t?void 0:t[Gi])||fetch)((kn(e,null==t||null===(c=t.execute)||void 0===c||!c.includes(dr)),e.href),{headers:Object.fromEntries(new Headers(f({accept:"application/json"},Ji)).entries()),body:void 0,method:"GET",redirect:"manual",signal:s})).then(e=>async function(e,t){const n=e;if(!(n instanceof URL)&&n!==Wo)throw zt('"expectedIssuerIdentifier" must be an instance of URL',Lt);if(!Mt(t,Response))throw zt('"response" must be an instance of Response',Lt);if(200!==t.status)throw tn('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',fo,t);So(t);const o=await jo(t);if(ln(o.issuer,'"response" body "issuer" property',ho,{body:o}),n!==Wo&&new URL(o.issuer).href!==n.href)throw tn('"response" body "issuer" property does not match the expected value',vo,{expected:n.href,body:o,attribute:"issuer"});return o}(Wo,e)).catch(nr);var c;i&&new URL(a.issuer).href!==e.href&&(function(e,t,n){return !("https://login.microsoftonline.com"!==e.origin||null!=n&&n.algorithm&&"oidc"!==n.algorithm||(t[ir]=!0,0))}(e,a,t)||function(e,t){return !(!e.hostname.endsWith(".b2clogin.com")||null!=t&&t.algorithm&&"oidc"!==t.algorithm)}(e,t)||(()=>{throw new er("discovered metadata issuer does not match the expected issuer",{code:vo,cause:{expected:e.href,body:a,attribute:"issuer"}})})());return a}(e,i),s=new rr(r,t,n,o);let a=Zi(s);if(null!=i&&i[Gi]&&(a.fetch=i[Gi]),null!=i&&i.timeout&&(a.timeout=i.timeout),null!=i&&i.execute)for(const e of i.execute)e(s);return s}new TextDecoder;const ir=Symbol();class rr{constructor(e,t,n,o){var i,r,s,a,c;if("string"!=typeof t||!t.length)throw Bi('"clientId" must be a non-empty string',Yi);if("string"==typeof n&&(n={client_secret:n}),void 0!==(null===(i=n)||void 0===i?void 0:i.client_id)&&t!==n.client_id)throw Bi('"clientId" and "metadata.client_id" must be the same',qi);const u=f(f({},structuredClone(n)),{},{client_id:t});let l;u[Dt]=null!==(r=null===(s=n)||void 0===s?void 0:s[Dt])&&void 0!==r?r:0,u[Zt]=null!==(a=null===(c=n)||void 0===c?void 0:c[Zt])&&void 0!==a?a:30,l=o||("string"==typeof u.client_secret&&u.client_secret.length?Vi(u.client_secret):(e,t,n,o)=>{n.set("client_id",t.client_id);});let d=Object.freeze(u);const h=structuredClone(e);ir in e&&(h[No]=t=>{let n=t.claims.tid;return e.issuer.replace("{tenantid}",n)});let p=Object.freeze(h);Hi||(Hi=new WeakMap),Hi.set(this,{__proto__:null,as:p,c:d,auth:l,tlsOnly:!0,jwksCache:{}});}serverMetadata(){const e=structuredClone(Zi(this).as);return function(e){Object.defineProperties(e,function(e){return {supportsPKCE:{__proto__:null,value(){var t;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"S256";return !0===(null===(t=e.code_challenge_methods_supported)||void 0===t?void 0:t.includes(n))}}}}(e));}(e),e}clientMetadata(){return structuredClone(Zi(this).c)}get timeout(){return Zi(this).timeout}set timeout(e){Zi(this).timeout=e;}get[Gi](){return Zi(this).fetch}set[Gi](e){Zi(this).fetch=e;}}function sr(e){Object.defineProperties(e,function(e){let t;if(void 0!==e.expires_in){const n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime();}return {expiresIn:{__proto__:null,value(){if(t){const e=Date.now();return t>e?Math.floor((t-e)/1e3):0}}},claims:{__proto__:null,value(){try{return Fn(this)}catch(e){return}}}}}(e));}async function ar(e,t,n){var o;let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=null===(o=e.headers.get("retry-after"))||void 0===o?void 0:o.trim();if(void 0===r)return;let s;if(/^\d+$/.test(r))s=parseInt(r,10);else {const e=new Date(r);if(Number.isFinite(e.getTime())){const t=new Date,n=e.getTime()-t.getTime();n>0&&(s=Math.ceil(n/1e3));}}if(i&&!Number.isFinite(s))throw new en("invalid Retry-After header value",{cause:e});s>t&&await cr(s-t,n);}function cr(e,t){return new Promise((n,o)=>{const i=e=>{try{t.throwIfAborted();}catch(e){return void o(e)}if(e<=0)return void n();const r=Math.min(e,5);setTimeout(()=>i(e-r),1e3*r);};i(e);})}async function ur(e,t){wr(e);const n=Zi(e),o=n.as,i=n.c,r=n.auth,s=n.fetch,a=n.tlsOnly,c=n.timeout;return async function(e,t,n,o,i){wn(e),gn(t);const r=Tn(e,"backchannel_authentication_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[Jt])),s=new URLSearchParams(o);s.set("client_id",t.client_id);const a=rn(null==i?void 0:i.headers);return a.set("accept","application/json"),Jn(e,t,n,r,s,a,i)}(o,i,r,t,{[Ht]:s,[Jt]:!a,headers:new Headers(Ji),signal:gr(c)}).then(e=>async function(e,t,n){if(wn(e),gn(t),!Mt(n,Response))throw zt('"response" must be an instance of Response',Lt);await Nn(n,200,"Backchannel Authentication Endpoint"),So(n);const o=await jo(n);ln(o.auth_req_id,'"response" body "auth_req_id" property',ho,{body:o});let i="number"!=typeof o.expires_in?parseFloat(o.expires_in):o.expires_in;return un(i,!0,'"response" body "expires_in" property',ho,{body:o}),o.expires_in=i,void 0!==o.interval&&un(o.interval,!1,'"response" body "interval" property',ho,{body:o}),o}(o,i,e)).catch(nr)}async function lr(e,t,n,o){var i,r;wr(e),n=new URLSearchParams(n);let s=null!==(i=t.interval)&&void 0!==i?i:5;const a=null!==(r=null==o?void 0:o.signal)&&void 0!==r?r:AbortSignal.timeout(1e3*t.expires_in);try{await cr(s,a);}catch(e){nr(e);}const c=Zi(e),u=c.as,l=c.c,d=c.auth,h=c.fetch,p=c.tlsOnly,m=c.nonRepudiation,y=c.timeout,w=c.decrypt,g=(i,r)=>lr(e,f(f({},t),{},{interval:i}),n,f(f({},o),{},{signal:a,flag:r})),v=function(e,t){const n=gr(t);if(!n)return {signal:e,cleanup(){}};const o=new AbortController,i=e=>{const t=e.target;o.abort(t.reason);};return e.aborted?o.abort(e.reason):n.aborted?o.abort(n.reason):(e.addEventListener("abort",i,{once:!0}),n.addEventListener("abort",i,{once:!0})),{signal:o.signal,cleanup(){e.removeEventListener("abort",i),n.removeEventListener("abort",i);}}}(a,y),b=await async function(e,t,n,o,i){wn(e),gn(t),ln(o,'"authReqId"');const r=new URLSearchParams(null==i?void 0:i.additionalParameters);return r.set("auth_req_id",o),Dn(e,t,n,"urn:openid:params:grant-type:ciba",r,i)}(u,l,d,t.auth_req_id,{[Ht]:h,[Jt]:!p,additionalParameters:n,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Ji),signal:v.signal}).catch(nr).finally(v.cleanup);var _;if(503===b.status&&b.headers.has("retry-after"))return await ar(b,s,a,!0),await(null===(_=b.body)||void 0===_?void 0:_.cancel()),g(s);const k=async function(e,t,n,o){return Vn(e,t,n,void 0,null==o?void 0:o[Vt],null==o?void 0:o.recognizedTokenTypes)}(u,l,b,{[Vt]:w});let S;try{S=await k;}catch(e){if(br(e,o))return g(s,_r);if(e instanceof Pn)switch(e.error){case"slow_down":s+=5;case"authorization_pending":return await ar(e.response,s,a),g(s)}nr(e);}return S.id_token&&await(null==m?void 0:m(b)),sr(S),S}function dr(e){Zi(e).tlsOnly=!1;}async function hr(e,t,n,o,i){if(wr(e),!((null==i?void 0:i.flag)===_r||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch(e){return !1}}(t,"Request")))throw Bi('"currentUrl" must be an instance of URL, or Request',Yi);let r,s;const a=Zi(e),c=a.as,u=a.c,l=a.auth,d=a.fetch,h=a.tlsOnly,p=a.jarm,m=a.hybrid,w=a.nonRepudiation,g=a.timeout,v=a.decrypt,b=a.implicit;if((null==i?void 0:i.flag)===_r)r=i.authResponse,s=i.redirectUri;else {if(!(t instanceof URL)){const e=t;switch(t=new URL(t.url),e.method){case"GET":break;case"POST":const n=new URLSearchParams(await Co(e));if(m)t.hash=n.toString();else for(const e of n.entries()){var _=y(e,2);const n=_[0],o=_[1];t.searchParams.append(n,o);}break;default:throw Bi("unexpected Request HTTP method",qi)}}switch(s=function(e){return (e=new URL(e)).search="",e.hash="",e.href}(t),!0){case!!p:r=await p(t,null==n?void 0:n.expectedState);break;case!!m:r=await m(t,null==n?void 0:n.expectedNonce,null==n?void 0:n.expectedState,null==n?void 0:n.maxAge);break;case!!b:throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{r=Oo(c,u,t.searchParams,null==n?void 0:n.expectedState);}catch(e){nr(e);}}}const k=await async function(e,t,n,o,i,r,s){if(wn(e),gn(t),!Qn.has(o))throw zt('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',Ut);ln(i,'"redirectUri"');const a=Ro(o,"code");if(!a)throw tn('no authorization code in "callbackParameters"',ho);const c=new URLSearchParams(null==s?void 0:s.additionalParameters);return c.set("redirect_uri",i),c.set("code",a),r!==$n&&(ln(r,'"codeVerifier"'),c.set("code_verifier",r)),Dn(e,t,n,"authorization_code",c,s)}(c,u,l,r,s,(null==n?void 0:n.pkceCodeVerifier)||$n,{additionalParameters:o,[Ht]:d,[Jt]:!h,DPoP:null==i?void 0:i.DPoP,headers:new Headers(Ji),signal:gr(g)}).catch(nr);"string"!=typeof(null==n?void 0:n.expectedNonce)&&"number"!=typeof(null==n?void 0:n.maxAge)||(n.idTokenExpected=!0);const S=io(c,u,k,{expectedNonce:null==n?void 0:n.expectedNonce,maxAge:null==n?void 0:n.maxAge,requireIdToken:null==n?void 0:n.idTokenExpected,[Vt]:v});let T;try{T=await S;}catch(t){if(br(t,i))return hr(e,void 0,n,o,f(f({},i),{},{flag:_r,authResponse:r,redirectUri:s}));nr(t);}return T.id_token&&await(null==w?void 0:w(k)),sr(T),T}async function pr(e,t,n,o){wr(e),n=new URLSearchParams(n);const i=Zi(e),r=i.as,s=i.c,a=i.auth,c=i.fetch,u=i.tlsOnly,l=i.nonRepudiation,d=i.timeout,h=i.decrypt,p=await async function(e,t,n,o,i){wn(e),gn(t),ln(o,'"refreshToken"');const r=new URLSearchParams(null==i?void 0:i.additionalParameters);return r.set("refresh_token",o),Dn(e,t,n,"refresh_token",r,i)}(r,s,a,t,{[Ht]:c,[Jt]:!u,additionalParameters:n,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Ji),signal:gr(d)}).catch(nr),m=async function(e,t,n,o){return Vn(e,t,n,void 0,null==o?void 0:o[Vt],null==o?void 0:o.recognizedTokenTypes)}(r,s,p,{[Vt]:h});let y;try{y=await m;}catch(i){if(br(i,o))return pr(e,t,n,f(f({},o),{},{flag:_r}));nr(i);}return y.id_token&&await(null==l?void 0:l(p)),sr(y),y}async function fr(e,t,n){wr(e),t=new URLSearchParams(t);const o=Zi(e),i=o.as,r=o.c,s=o.auth,a=o.fetch,c=o.tlsOnly,u=o.timeout,l=await async function(e,t,n,o,i){return wn(e),gn(t),Dn(e,t,n,"client_credentials",new URLSearchParams(o),i)}(i,r,s,t,{[Ht]:a,[Jt]:!c,DPoP:null==n?void 0:n.DPoP,headers:new Headers(Ji),signal:gr(u)}).catch(nr),d=async function(e,t,n,o){return Vn(e,t,n,void 0,null==o?void 0:o[Vt],null==o?void 0:o.recognizedTokenTypes)}(i,r,l);let h;try{h=await d;}catch(o){if(br(o,n))return fr(e,t,f(f({},n),{},{flag:_r}));nr(o);}return sr(h),h}function mr(e,t){wr(e);const n=Zi(e),o=n.as,i=n.c,r=n.tlsOnly,s=n.hybrid,a=n.jarm,c=n.implicit,u=Tn(o,"authorization_endpoint",!1,r);if((t=new URLSearchParams(t)).has("client_id")||t.set("client_id",i.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",s?"code id_token":c?"id_token":"code"),c&&!t.has("nonce"))throw Bi("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",qi);a&&t.set("response_mode","jwt");}for(const e of t.entries()){var l=y(e,2);const t=l[0],n=l[1];u.searchParams.append(t,n);}return u}async function yr(e,t,n){wr(e);const o=mr(e,t),i=Zi(e),r=i.as,s=i.c,a=i.auth,c=i.fetch,u=i.tlsOnly,l=i.timeout,d=await async function(e,t,n,o,i){var r;wn(e),gn(t);const s=Tn(e,"pushed_authorization_request_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[Jt])),a=new URLSearchParams(o);a.set("client_id",t.client_id);const c=rn(null==i?void 0:i.headers);c.set("accept","application/json"),void 0!==(null==i?void 0:i.DPoP)&&(Kn(i.DPoP),await i.DPoP.addProof(s,c,"POST"));const u=await Jn(e,t,n,s,a,c,i);return null==i||null===(r=i.DPoP)||void 0===r||r.cacheNonce(u,s),u}(r,s,a,o.searchParams,{[Ht]:c,[Jt]:!u,DPoP:null==n?void 0:n.DPoP,headers:new Headers(Ji),signal:gr(l)}).catch(nr),h=async function(e,t,n){if(wn(e),gn(t),!Mt(n,Response))throw zt('"response" must be an instance of Response',Lt);await Nn(n,201,"Pushed Authorization Request Endpoint"),So(n);const o=await jo(n);ln(o.request_uri,'"response" body "request_uri" property',ho,{body:o});let i="number"!=typeof o.expires_in?parseFloat(o.expires_in):o.expires_in;return un(i,!0,'"response" body "expires_in" property',ho,{body:o}),o.expires_in=i,o}(r,s,d);let p;try{p=await h;}catch(o){if(br(o,n))return yr(e,t,f(f({},n),{},{flag:_r}));nr(o);}return mr(e,{request_uri:p.request_uri})}function wr(e){if(!(e instanceof rr))throw Bi('"config" must be an instance of Configuration',Yi);if(Object.getPrototypeOf(e)!==rr.prototype)throw Bi("subclassing Configuration is not allowed",qi)}function gr(e){return e?AbortSignal.timeout(1e3*e):void 0}async function vr(e,t,n,o){wr(e);const i=Zi(e),r=i.as,s=i.c,a=i.fetch,c=i.tlsOnly,u=i.nonRepudiation,l=i.timeout,d=i.decrypt,h=await Mn(r,s,t,{[Ht]:a,[Jt]:!c,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Ji),signal:gr(l)}).catch(nr);let p,m=zn(r,s,n,h,{[Vt]:d});try{p=await m;}catch(i){if(br(i,o))return vr(e,t,n,f(f({},o),{},{flag:_r}));nr(i);}return "application/jwt"===Ln(h)&&await(null==u?void 0:u(h)),p}function br(e,t){return !(null==t||!t.DPoP||t.flag===_r)&&function(e){if(e instanceof Cn){const t=e.cause,n=t[0];return 1===t.length&&"dpop"===n.scheme&&"use_dpop_nonce"===n.parameters.error}return e instanceof Pn&&"use_dpop_nonce"===e.error}(e)}Object.freeze(rr.prototype);const _r=Symbol();async function kr(e,t,n,o){wr(e);const i=Zi(e),r=i.as,s=i.c,a=i.auth,c=i.fetch,u=i.tlsOnly,l=i.timeout,d=i.decrypt,h=i.nonRepudiation,p=await async function(e,t,n,o,i,r){return wn(e),gn(t),ln(o,'"grantType"'),Dn(e,t,n,o,new URLSearchParams(i),r)}(r,s,a,t,new URLSearchParams(n),{[Ht]:c,[Jt]:!u,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Ji),signal:gr(l)}).catch(nr);let m;"urn:ietf:params:oauth:grant-type:token-exchange"===t&&(m={n_a:()=>{}});const y=async function(e,t,n,o){return Vn(e,t,n,void 0,null==o?void 0:o[Vt],null==o?void 0:o.recognizedTokenTypes)}(r,s,p,{[Vt]:d,recognizedTokenTypes:m});let w;try{w=await y;}catch(i){if(br(i,o))return kr(e,t,n,f(f({},o),{},{flag:_r}));nr(i);}return w.id_token&&await(null==h?void 0:h(p)),sr(w),w}async function Sr(e,t,n){wr(e);const o=Zi(e),i=o.as,r=o.c,s=o.auth,a=o.fetch,c=o.tlsOnly,u=o.timeout;return async function(e,t,n,o,i){wn(e),gn(t),ln(o,'"token"');const r=Tn(e,"revocation_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[Jt])),s=new URLSearchParams(null==i?void 0:i.additionalParameters);s.set("token",o);const a=rn(null==i?void 0:i.headers);return a.delete("accept"),Jn(e,t,n,r,s,a,i)}(i,r,s,t,{[Ht]:a,[Jt]:!c,additionalParameters:new URLSearchParams(n),headers:new Headers(Ji),signal:gr(u)}).then(ko).catch(nr)}async function Tr(e,t,n){return t instanceof Uint8Array?crypto.subtle.importKey("raw",t,e.subtle,!1,[n]):(Do(t,e.subtle,n),e.minRsaBits&&function(e,t){const n=t.algorithm.modulusLength;if("number"!=typeof n||n<2048)throw new TypeError("".concat(e," requires key modulusLength to be 2048 bits or larger"))}(e.alg,t),t)}const Pr=[["verify"],["sign"]];function Er(e){const t={name:"HMAC",hash:"SHA-".concat(e)};return {kty:["oct"],secret:!0,subtle:t,signing:t,usages:Pr}}function Cr(e,t){const n={name:t?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(e)};return {kty:["RSA"],subtle:n,signing:t?f(f({},n),{},{saltLength:t}):n,usages:Pr,minRsaBits:2048}}function Ar(e,t){return {kty:["EC"],crv:e,subtle:{name:"ECDSA",namedCurve:e},signing:{name:"ECDSA",hash:"SHA-".concat(t)},usages:Pr}}function Rr(){const e={name:"Ed25519"};return {kty:["OKP"],crv:"Ed25519",subtle:e,signing:e,usages:Pr}}function xr(e){const t={name:"ML-DSA-".concat(e)};return {kty:["AKP"],subtle:t,signing:t,usages:Pr}}const Ir=Ti({HS256:Er(256),HS384:Er(384),HS512:Er(512),RS256:Cr(256),RS384:Cr(384),RS512:Cr(512),PS256:Cr(256,32),PS384:Cr(384,48),PS512:Cr(512,64),ES256:Ar("P-256",256),ES384:Ar("P-384",384),ES512:Ar("P-521",512),EdDSA:Rr(),Ed25519:Rr(),"ML-DSA-44":xr(44),"ML-DSA-65":xr(65),"ML-DSA-87":xr(87)});function Or(e){const t="string"==typeof e?Ir[e]:void 0;if(!t)throw new Go("alg ".concat(e," is not supported either by JOSE or your javascript runtime"));return t}function jr(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0===e?{}:function(e,t,n){let o;try{o=JSON.parse(Uo.decode(si(e)));}catch(e){throw new t(n)}if(!ci(o))throw new t(n);return o}(e,qo,"JWS Protected Header is invalid");return t}async function Wr(e,t,n,o,i,r,s){var a;let c=!1;"function"==typeof n&&(n=await n(i,e),c=!0);const u="string"==typeof s,l=Or(r),d=Lo(void 0!==o?zo(o):new Uint8Array,zo("."),u?null!==(a=t[2])&&void 0!==a?a:t[2]=function(e,t,n){try{return zo(e)}catch(e){throw new n("The ".concat(t," is not a valid base64url string"))}}(s,"payload",qo):s),h=li(e.signature,"signature",qo),p=await Si(l,n,"verify");if(!await async function(e,t,n,o){const i=await Tr(e,t,"verify");try{return await crypto.subtle.verify(e.signing,i,n,o)}catch(e){return !1}}(l,p,h,d))throw new ti;return [u?li(s,"payload",qo):s,i,u,p,c]}async function Nr(e,t,n){if(e instanceof Uint8Array&&(e=Mo.decode(e)),"string"!=typeof e)throw new qo("Compact JWS must be a string or Uint8Array");const o=e.split("."),i=o[0],r=o[1],s=o[2];if(3!==o.length)throw new qo("Invalid Compact JWS");const a={payload:r,protected:i,signature:s},c=jr(i),u=function(e,t,n){const o=Ui(e,Mi(qo,Ni,n[1],e,t)),i=t.alg;if("string"!=typeof i||!i)throw new qo('JWS "alg" (Algorithm) Header Parameter missing or invalid');if(n[0]&&!n[0].has(i))throw new Xo('"alg" (Algorithm) Header Parameter value not allowed');return [o,i]}(c,c,t),l=y(u,2),d=l[0],h=l[1],p=d?r:function(e){try{return zo(e)}catch(e){throw new qo("JWS Compact Serialization payload must use only ASCII characters")}}(r);return Wr(a,t,n,i,c,h,p)}const Kr=e=>Math.floor(e.getTime()/1e3),Mr={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},Ur=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Lr="check_failed";function zr(){throw new TypeError("Invalid time period format")}function Jr(e){"string"!=typeof e&&zr();const t=Ur.exec(e);(!t||t[4]&&t[1])&&zr();const n=parseFloat(t[2]),o=Math.round(n*Mr[t[3][0].toLowerCase()]);return Number.isFinite(o)||zr(),"-"===t[1]||"ago"===t[4]?-o:o}function Dr(e,t){if(!Number.isFinite(t))throw new TypeError("Invalid ".concat(e," input"));return t}function Zr(e,t){if("string"!=typeof t)throw new TypeError('"'.concat(e,'" claim must be a string'))}function Hr(e,t){return "number"==typeof e?Dr(t,e):e instanceof Date?Dr(t,Kr(e)):Kr(new Date)+Jr(e)}const Fr=e=>{const t=e.toLowerCase();return e.includes("/")?t:"application/".concat(t)};function Vr(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const o=e[t];if(void 0!==o||n){if("number"!=typeof o)throw new Fo('"'.concat(t,'" claim must be a number'),e,t,"invalid");return o}}function Xr(e,t){throw new Fo('unexpected "'.concat(t,'" claim value'),e,t,Lr)}function Gr(e,t){let n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{n=JSON.parse(Uo.decode(t));}catch(e){}if(!ci(n))throw new Yo("JWT Claims Set must be a top-level JSON object");const i=o.typ;if(void 0!==i&&("string"!=typeof e.typ||Fr(e.typ)!==Fr(i)))throw new Fo('unexpected "typ" JWT header value',n,"typ",Lr);const r=o.requiredClaims,s=void 0===r?[]:r,a=o.issuer,c=o.subject,u=o.audience,l=o.maxTokenAge,d=[...s];void 0!==l&&d.push("iat"),void 0!==u&&d.push("aud"),void 0!==c&&d.push("sub"),void 0!==a&&d.push("iss");for(const e of new Set(d.reverse()))if(!Object.hasOwn(n,e))throw new Fo('missing required "'.concat(e,'" claim'),n,e,"missing");var h,p;void 0===a||(Array.isArray(a)?a:[a]).includes(n.iss)||Xr(n,"iss"),void 0!==c&&n.sub!==c&&Xr(n,"sub"),void 0===u||(h=n.aud,p="string"==typeof u?[u]:u,"string"==typeof h?p.includes(h):Array.isArray(h)&&p.some(e=>h.includes(e)))||Xr(n,"aud");const f=o.clockTolerance;let m=0;if("string"==typeof f)m=Jr(f);else if(void 0!==f){if("number"!=typeof f)throw new TypeError("Invalid clockTolerance option type");m=f;}Dr("clockTolerance option",m);const y=o.currentDate,w=Dr("currentDate option",Kr(void 0===y?new Date:y)),g=Vr(n,"iat",void 0!==l),v=Vr(n,"nbf");if(void 0!==v&&v>w+m)throw new Fo('"nbf" claim timestamp check failed',n,"nbf",Lr);const b=Vr(n,"exp");if(void 0!==b&&b<=w-m)throw new Vo('"exp" claim timestamp check failed',n,"exp",Lr);if(void 0!==l){const e=w-g;if(e-m>Dr("maxTokenAge option","number"==typeof l?l:Jr(l)))throw new Vo('"iat" claim timestamp check failed (too far in the past)',n,"iat",Lr);if(e<-m)throw new Fo('"iat" claim timestamp check failed (it should be in the past)',n,"iat",Lr)}return n}let qr;function Yr(e){return qr.get(e)}async function Br(e,t,n){const o=await Nr(e,function(e){return [e&&Ki("algorithms",e.algorithms),null==e?void 0:e.crit]}(n),t);if(!o[2])throw new Yo("JWTs MUST NOT use unencoded payload");const i={payload:Gr(o[1],o[0],n),protectedHeader:o[1]};return "function"==typeof t?f(f({},i),{},{key:o[3]}):i}function Qr(e){if(void 0===e)return [void 0,""];const t=function(e,t){let n,o;try{n=JSON.stringify(t),o=JSON.parse(n);}catch(t){throw new e("JOSE Header is not valid JSON",{cause:t})}if(!ci(o))throw new e("JOSE Header is not a JSON object");return [o,n]}(qo,e);return [t[0],ai(t[1])]}function $r(e,t,n){return function(e,t){const n=(null!=t?t:{}).crit;if(Array.isArray(n)&&new Set(n).size!==n.length)throw new e('"crit" (Critical) Header Parameter MUST NOT contain duplicate values')}(qo,e),Ui(e,Mi(qo,Ni,n,e,t))}async function es(e,t,n,o){const i=Lo(zo(e),zo("."),t),r=await Si(n,o,"sign");return ai(await async function(e,t,n){const o=await Tr(e,t,"sign"),i=await crypto.subtle.sign(e.signing,o,n);return new Uint8Array(i)}(n,r,i))}async function ts(e,t,n,o,i){const r=y(Qr(t),2),s=r[0],a=r[1];if(!s)throw new qo("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");$r(s,s,n)||i();const c=function(e){const t=e.alg;if("string"!=typeof t||!t)throw new qo('JWS "alg" (Algorithm) Header Parameter missing or invalid');return Or(t)}(s),u=ai(e),l=await es(a,zo(u),c,o);return "".concat(a,".").concat(u,".").concat(l)}const ns=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ci(e))throw new TypeError("JWT Claims Set MUST be an object");(qr||(qr=new WeakMap)).set(this,structuredClone(e));}setIssuer(e){return Zr("iss",e),Yr(this).iss=e,this}setSubject(e){return Zr("sub",e),Yr(this).sub=e,this}setAudience(e){return function(e){if("string"!=typeof e&&(!Array.isArray(e)||Array.from(e).some(e=>"string"!=typeof e)))throw new TypeError('"aud" claim must be a string or an array of strings')}(e),Yr(this).aud=e,this}setJti(e){return Zr("jti",e),Yr(this).jti=e,this}setNotBefore(e){return Yr(this).nbf=Hr(e,"setNotBefore"),this}setExpirationTime(e){return Yr(this).exp=Hr(e,"setExpirationTime"),this}setIssuedAt(e){const t=Yr(this);return t.iat=void 0===e?Kr(new Date):"string"==typeof e?Dr("setIssuedAt",Kr(new Date)+Jr(e)):Hr(e,"setIssuedAt"),this}};var os=new WeakMap;class is extends ns{constructor(){super(...arguments),u(this,os,void 0);}setProtectedHeader(e){return function(e,t){if(void 0!==e)throw new TypeError("".concat(t," can only be called once"))}(c(os,this),"setProtectedHeader"),l(os,this,e),this}async sign(e,t){return ts(function(e){const t=Yr(e);for(const e of ["iat","nbf","exp"]){const n=t[e];if("number"==typeof n&&!Number.isFinite(n))throw new TypeError('"'.concat(e,'" claim must be a finite number'))}return Ko.encode(JSON.stringify(t))}(this),c(os,this),null==t?void 0:t.crit,e,()=>{throw new Yo("JWTs MUST NOT use unencoded payload")})}}const rs='"alg" (Algorithm)';function ss(){throw new Go("Invalid or unsupported ".concat(arguments.length>0&&void 0!==arguments[0]?arguments[0]:'JWK "alg" (Algorithm) Parameter'," value"))}const as=(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},cs=e=>{const t=e.data[e.pos++];if(void 0===t)throw new Error("Unexpected end of ASN.1 input");return t},us=e=>{const t=cs(e);if(128&t){const n=127&t;let o=0;for(let t=0;t<n;t++)o=o<<8|cs(e);return o}return t},ls=(e,t,n)=>{if(cs(e)!==t)throw new Error(n)},ds=(e,t)=>{if(t<0||e.pos+t>e.data.length)throw new Error("Unexpected end of ASN.1 input");const n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n};const hs=e=>{const t=(e=>{ls(e,6,"Expected algorithm OID");const t=us(e);return ds(e,t)})(e);if(as(t,[43,101,110]))return "X25519";if(!as(t,[42,134,72,206,61,2,1]))throw new Error("Unsupported key algorithm");ls(e,6,"Expected curve OID");const n=us(e),o=ds(e,n);if(as(o,[42,134,72,206,61,3,1,7]))return "P-256";if(as(o,[43,129,4,0,34]))return "P-384";if(as(o,[43,129,4,0,35]))return "P-521";throw new Error("Unsupported named curve")},ps=async(e,t,n,o)=>{const i=function(e){if(void 0!==e&&"boolean"!=typeof e)throw new TypeError('"extractable" option must be a boolean');return e}(null==o?void 0:o.extractable),r=function(e,t){var n,o;return null!==(n="string"==typeof e?null!==(o=Ir[e])&&void 0!==o?o:Oi[e]:void 0)&&void 0!==n?n:ss(t)}(n,rs);r.secret&&ss(rs);const s="spki"===e;let a;if(r.resolve)try{const n={data:t,pos:0};!function(e,t){if(ls(e,48,"Invalid ".concat("spki"===t?"SPKI":"PKCS#8"," structure")),us(e),"pkcs8"===t){ls(e,2,"Expected version field");const t=us(e);e.pos+=t;}ls(e,48,"Expected algorithm identifier"),us(e);}(n,e),a=r.resolve({crv:hs(n)});}catch(e){throw new Go("Invalid or unsupported key format")}else a=r.subtle;return crypto.subtle.importKey(e,t,a,null!=i?i:s,r.usages[s?0:1])},fs=(e,t,n)=>{const o=((e,t)=>ii(e.replace(t,"")))(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);return ps("pkcs8",o,t,n)};async function ms(e,t,n){const o=e.get(t)||e.set(t,{}).get(t),i=n.alg;if(void 0===o[i]){const e=await di(n,f(f({},t),{},{alg:i,ext:!0}));if("public"!==e.type)throw new Bo("JSON Web Key Set members must be public keys");o[i]=e;}return o[i]}function ys(e){let t;try{t=structuredClone(e);}catch(e){}if(!ui(t))throw new Bo("JSON Web Key Set malformed");const n=new WeakMap;return Object.defineProperty(async(e,o)=>{const i=f(f({},e),null==o?void 0:o.header),r=i.alg,a=i.kid,c="string"==typeof r?Ir[r]:void 0;if(!c||c.secret)throw new Go('Unsupported "alg" value for a JSON Web Key Set');const u=t.keys.filter(e=>function(e,t,n,o){const i=hi(e),r=i.kty,s=i.key_ops,a=i.ext,c=i.kid,u=i.alg,l=i.use,d=i.crv,h=Array.isArray(s)?[...s]:s;return (void 0===a||"boolean"==typeof a)&&(void 0===h||Array.isArray(h)&&h.every((e,t)=>"string"==typeof e&&h.indexOf(e)===t)&&h.includes("verify"))&&t.kty.includes(r)&&(void 0===o||"string"==typeof o&&o===c)&&(void 0===u?"AKP"!==r:n===u)&&(void 0===l||"sig"===l)&&(!t.crv||d===t.crv)}(e,c,r,a)),l=u[0],d=u.length;if(!d)throw new Qo;if(1!==d){const e=new $o;throw e[Symbol.asyncIterator]=w(function*(){for(const e of u)try{yield yield s(ms(n,e,c));}catch(e){}}),e}return ms(n,l,c)},"jwks",{value:()=>structuredClone(t)})}var ws,gs;let vs;if("undefined"==typeof navigator||null===(ws=navigator.userAgent)||void 0===ws||null===(gs=ws.startsWith)||void 0===gs||!gs.call(ws,"Mozilla/5.0 ")){const e="v6.2.10";vs="".concat("jose","/").concat(e);}const bs=Symbol();const _s=Symbol();function ks(e,t){return Number.isFinite(e)&&Date.now()<e+t}function Ss(e,t,n){if(Number.isNaN(e))throw new TypeError('"'.concat(n,'" option must not be NaN'));return "number"==typeof e?e:t}function Ts(e,t){if(!(e instanceof URL))throw new TypeError("url must be an instance of URL");const n=new URL(e.href).href,o=null!=t?t:{},i=o.timeoutDuration;if("number"==typeof i&&(!Number.isInteger(i)||i<0))throw new TypeError('"timeoutDuration" option must be a non-negative integer');const r="number"==typeof i?i:5e3,s=Ss(o.cooldownDuration,3e4,"cooldownDuration"),a=Ss(o.cacheMaxAge,6e5,"cacheMaxAge"),c=new Headers(o.headers);vs&&!c.has("User-Agent")&&c.set("User-Agent",vs),c.has("accept")||c.set("accept","application/json, application/jwk-set+json");const u=o[bs],l=o[_s];let d,h,p,f=0,m=0;if(l&&"object"==typeof l){const e=l.uat,t=l.jwks;ks(e,a)&&ui(t)&&(d=e,p=ys(t));}const y=async()=>{if(h&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(h=void 0),!h){const e=++f,t=h=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:fetch;const i=await o(e,{method:"GET",signal:n,redirect:"manual",headers:t}).catch(e=>{if("TimeoutError"===e.name)throw new ei;throw e});if(200!==i.status)throw new Ho("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch(e){throw new Ho("Failed to parse the JSON Web Key Set HTTP response as JSON")}}(n,c,AbortSignal.timeout(r),u).then(t=>{const n=ys(t);if(e<=m)return;p=n;const o=Date.now();l&&(l.uat=o,l.jwks=t),d=o,m=e;}).finally(()=>{h===t&&(h=void 0);});}await h;};return Object.defineProperties(async(e,t)=>{p&&ks(d,a)||await y();try{return await p(e,t)}catch(n){if(n instanceof Qo&&!ks(d,s))return await y(),p(e,t);throw n}},{coolingDown:{get:()=>ks(d,s),enumerable:!0},fresh:{get:()=>ks(d,a),enumerable:!0},reload:{value:y,enumerable:!0},reloading:{get:()=>!!h,enumerable:!0},jwks:{value:()=>{var e;return null===(e=p)||void 0===e?void 0:e.jwks()},enumerable:!0}})}async function Ps(e,t,n){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return fs(e,t,n)}const Es=["mfaToken"],Cs=["mfaToken"];var As,Rs,xs,Is,Os,js,Ws,Ns,Ks,Ms,Us,Ls,zs,Js,Ds,Zs,Hs,Fs,Vs,Xs,Gs,qs,Ys,Bs,Qs,$s,ea,ta,na,oa,ia,ra,sa,aa,ca,ua,la,da,ha,pa,fa,ma,ya,wa,ga,va,ba,_a,ka,Sa,Ta,Pa;function Ea(e){if("object"!=typeof e||null===e)return {};const t=e;return {statusCode:"number"==typeof t.statusCode?t.statusCode:void 0,headers:t.headers instanceof Headers?t.headers:void 0,body:"string"==typeof t.body?t.body:void 0}}function Ca(e){var t,n;if("object"!=typeof e||null===e)return {error:"unknown_error",error_description:String(e)};const o=e;let i;if(o.response instanceof Response)try{i=new Headers(o.response.headers),i.delete("set-cookie");}catch(e){i=void 0;}const r={error:null!==(t=o.error)&&void 0!==t?t:"",error_description:null!==(n=o.error_description)&&void 0!==n?n:"",message:o.message,statusCode:"number"==typeof o.status?o.status:void 0,headers:i};if("mfa_required"===o.error&&o.cause){r.mfa_token="string"==typeof o.cause.mfa_token?o.cause.mfa_token:void 0;const e=o.cause.mfa_requirements;"object"==typeof e&&null!==e&&(r.mfa_requirements=e);}return r}var Aa=class extends Error{constructor(e,t){super(t),h(this,"code",void 0),this.name="NotSupportedError",this.code=e;}},Ra=class extends Error{constructor(e,t,n){super(t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"statusCode",void 0),h(this,"headers",void 0),h(this,"body",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements};const o=Ea(n);this.statusCode=o.statusCode,this.headers=o.headers,this.body=o.body;}},xa=class extends Ra{constructor(e,t){super("token_by_code_error",e,t),this.name="TokenByCodeError";}},Ia=class extends Ra{constructor(e,t){super("token_by_client_credentials_error",e,t),this.name="TokenByClientCredentialsError";}},Oa=class extends Ra{constructor(e,t){super("token_by_refresh_token_error",e,t),this.name="TokenByRefreshTokenError";}},ja=class extends Ra{constructor(e,t){super("token_by_password_error",e,t),this.name="TokenByPasswordError";}},Wa=class extends Ra{constructor(e,t){super("token_for_connection_error",e,t),this.name="TokenForConnectionErrorCode";}},Na=class extends Ra{constructor(e,t){super("token_exchange_error",e,t),this.name="TokenExchangeError";}},Ka=class extends Ra{constructor(e,t){super("token_revocation_error",e,t),this.name="TokenRevocationError";}},Ma=class extends Ra{constructor(e,t){super("user_info_error",e,t),this.name="UserInfoError";}},Ua=class extends Error{constructor(e){super(e),h(this,"code","verify_logout_token_error"),this.name="VerifyLogoutTokenError";}},La=class extends Ra{constructor(e){super("backchannel_authentication_error","There was an error when trying to use Client-Initiated Backchannel Authentication.",e),h(this,"code","backchannel_authentication_error"),this.name="BackchannelAuthenticationError";}},za=class extends Ra{constructor(e){super("build_authorization_url_error","There was an error when trying to build the authorization URL.",e),this.name="BuildAuthorizationUrlError";}},Ja=class extends Ra{constructor(e){super("build_link_user_url_error","There was an error when trying to build the Link User URL.",e),this.name="BuildLinkUserUrlError";}},Da=class extends Ra{constructor(e){super("build_unlink_user_url_error","There was an error when trying to build the Unlink User URL.",e),this.name="BuildUnlinkUserUrlError";}},Za=class extends Error{constructor(){super("The client secret or client assertion signing key must be provided."),h(this,"code","missing_client_auth_error"),this.name="MissingClientAuthError";}},Ha=class extends Error{constructor(e){super(e),h(this,"code","organization_validation_error"),this.name="OrganizationValidationError";}},Fa=class extends Error{constructor(e){super(e||"fullResponse: true requested but no HTTP Response was captured. This is a bug in CapturingFetch."),h(this,"code","missing_captured_response_error"),this.name="MissingCapturedResponseError";}};function Va(e){try{const t=new Headers(e);return t.delete("set-cookie"),t}catch(e){return new Headers}}function Xa(e,t,n){var o;const i="object"==typeof t&&null!==t?t:void 0,r=null!==(o=null==i?void 0:i.response)&&void 0!==o?o:n,s="number"==typeof(null==i?void 0:i.status)?i.status:null==r?void 0:r.status;"number"==typeof s&&(e.statusCode=s),null!=r&&r.headers&&(e.headers=Va(r.headers));}function Ga(e){return Object.entries(e).filter(e=>void 0!==y(e,2)[1]).reduce((e,t)=>f(f({},e),{},{[t[0]]:t[1]}),{})}function qa(e){if(!e.trim())throw new Ha("organization must not be blank")}function Ya(e,t){if(!e)return;const n=t.trim();if(n.startsWith("org_")){const t=e.org_id;if("string"!=typeof t)throw new Ha("Organization Id (org_id) claim must be a string present in the ID token");if(t!==n)throw new Ha('Organization Id (org_id) claim value mismatch in the ID token; expected "'.concat(n,'", found "').concat(t,'"'))}else {const t=e.org_name;if("string"!=typeof t)throw new Ha("Organization Name (org_name) claim must be a string present in the ID token");if(t.toLowerCase()!==n.toLowerCase())throw new Ha('Organization Name (org_name) claim value mismatch in the ID token; expected "'.concat(n,'", found "').concat(t,'"'))}}var Ba=class extends Error{constructor(e,t,n){super(t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"statusCode",void 0),h(this,"headers",void 0),h(this,"body",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};const o=Ea(n);this.statusCode=o.statusCode,this.headers=o.headers,this.body=o.body;}},Qa=class extends Ba{constructor(e,t){super("mfa_list_authenticators_error",e,t),this.name="MfaListAuthenticatorsError";}},$a=class extends Ba{constructor(e,t){super("mfa_enrollment_error",e,t),this.name="MfaEnrollmentError";}},ec=class extends Ba{constructor(e,t){super("mfa_delete_authenticator_error",e,t),this.name="MfaDeleteAuthenticatorError";}},tc=class extends Ba{constructor(e,t){super("mfa_challenge_error",e,t),this.name="MfaChallengeError";}},nc=class extends Ba{constructor(e,t){super("mfa_verify_error",e,t),this.name="MfaVerifyError";}};function oc(e){return {id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var ic=class e{constructor(e,t,n,o,i,r,s){h(this,"accessToken",void 0),h(this,"idToken",void 0),h(this,"refreshToken",void 0),h(this,"expiresAt",void 0),h(this,"scope",void 0),h(this,"claims",void 0),h(this,"authorizationDetails",void 0),h(this,"tokenType",void 0),h(this,"issuedTokenType",void 0),h(this,"recoveryCode",void 0),h(this,"act",void 0),this.accessToken=e,this.idToken=n,this.refreshToken=o,this.expiresAt=t,this.scope=i,this.claims=r,this.authorizationDetails=s;}static fromTokenEndpointResponse(t){const n=t.id_token?t.claims():void 0,o=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 o.tokenType=t.token_type,o.issuedTokenType=t.issued_token_type,o}};function rc(e,t){if(!1===t.enabled)return e;const n={name:t.name,version:t.version},o=btoa(JSON.stringify(n));return async(t,n)=>{const i=t instanceof Request?new Headers(t.headers):new Headers;if(null!=n&&n.headers){new Headers(n.headers).forEach((e,t)=>{i.set(t,e);});}return i.set("Auth0-Client",o),e(t,f(f({},n),{},{headers:i}))}}function sc(e){var t,n;return !1===(null==e?void 0:e.enabled)?e:{enabled:!0,name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"@auth0/auth0-auth-js",version:null!==(n=null==e?void 0:e.version)&&void 0!==n?n:"1.15.0"}}function ac(e){let t;const n=async(n,o)=>{const i=await e(n,o);return t=i.clone(),i};return n.getCapturedResponse=()=>t,n}function cc(e,t,n){if(!t)return e;const o=t.signal,i=t.headers,r=t.customFetch,s=r?rc(r,n):e;return o||i?async(e,t)=>{const n=i?new Headers(e instanceof Request?e.headers:void 0):void 0;if(n&&null!=t&&t.headers&&new Headers(t.headers).forEach((e,t)=>n.set(t,e)),i)for(const e of Object.entries(i)){var r=y(e,2);const t=r[0],o=r[1],i=t.toLowerCase();"authorization"!==i&&"auth0-client"!==i&&n.set(t,o);}const a=function(e,t){if(!e)return {signal:null!=t?t:void 0};if(!t)return {signal:e};if("undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.any)return {signal:AbortSignal.any([e,t])};const n=new AbortController,o=[e,t],i=o.find(e=>e.aborted);if(i)return n.abort(i.reason),{signal:n.signal};const r=[],s=()=>{o.forEach((e,t)=>{const n=r[t];n&&e.removeEventListener("abort",n);});};return o.forEach((e,t)=>{const o=()=>{s(),n.abort(e.reason);};r[t]=o,e.addEventListener("abort",o,{once:!0});}),{signal:n.signal,cleanup:s}}(o,null==t?void 0:t.signal);try{return await s(e,f(f(f({},t),n&&{headers:n}),{},{signal:a.signal}))}finally{var c;null===(c=a.cleanup)||void 0===c||c.call(a);}}:s}var uc={otp:"http://auth0.com/oauth/grant-type/mfa-otp",oob:"http://auth0.com/oauth/grant-type/mfa-oob","recovery-code":"http://auth0.com/oauth/grant-type/mfa-recovery-code"},lc=(As=new WeakMap,Rs=new WeakMap,xs=new WeakMap,Is=new WeakMap,Os=new WeakMap,js=new WeakMap,Ws=new WeakMap,Ns=new WeakSet,class{constructor(e){var t,n;d(this,Ns),u(this,As,void 0),u(this,Rs,void 0),u(this,xs,void 0),u(this,Is,void 0),u(this,Os,void 0),u(this,js,void 0),u(this,Ws,void 0),l(As,this,"https://".concat(e.domain)),l(Rs,this,e.clientId),l(xs,this,e.clientSecret),l(Is,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),l(Os,this,null!==(n=e.telemetryConfig)&&void 0!==n?n:sc()),l(js,this,e.getConfiguration),l(Ws,this,e.createCaptureConfiguration);}async listAuthenticators(e,t){const n="".concat(c(As,this),"/mfa/authenticators"),o=e.mfaToken,i=await r(Ns,this,dc).call(this,t)(n,{method:"GET",headers:{Authorization:"Bearer ".concat(o),"Content-Type":"application/json"}});if(!i.ok){const e=await i.clone().text(),t=i.status,n=Va(i.headers);let o;try{o=JSON.parse(e);}catch(o){throw new Qa("Failed to list authenticators",{error:"unknown_error",error_description:"Failed to list authenticators",statusCode:t,headers:n,body:e})}throw new Qa(o.error_description||"Failed to list authenticators",f(f({},o),{},{statusCode:t,headers:n,body:e}))}return (await i.json()).map(oc)}async enrollAuthenticator(e,t){const n="".concat(c(As,this),"/mfa/associate"),o=e.mfaToken,i=m(e,Es),s={authenticator_types:i.authenticatorTypes};"oobChannels"in i&&(s.oob_channels=i.oobChannels),"phoneNumber"in i&&i.phoneNumber&&(s.phone_number=i.phoneNumber),"email"in i&&i.email&&(s.email=i.email);const a=await r(Ns,this,dc).call(this,t)(n,{method:"POST",headers:{Authorization:"Bearer ".concat(o),"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const e=await a.clone().text(),t=a.status,n=Va(a.headers);let o;try{o=JSON.parse(e);}catch(o){throw new $a("Failed to enroll authenticator",{error:"unknown_error",error_description:"Failed to enroll authenticator",statusCode:t,headers:n,body:e})}throw new $a(o.error_description||"Failed to enroll authenticator",f(f({},o),{},{statusCode:t,headers:n,body:e}))}return function(e){if("otp"===e.authenticator_type)return {authenticatorType:"otp",secret:e.secret,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes,id:e.id};if("oob"===e.authenticator_type)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 new Error("Unexpected authenticator type: ".concat(e.authenticator_type))}(await a.json())}async deleteAuthenticator(e,t){const n=e.authenticatorId,o=e.mfaToken,i="".concat(c(As,this),"/mfa/authenticators/").concat(encodeURIComponent(n)),s=await r(Ns,this,dc).call(this,t)(i,{method:"DELETE",headers:{Authorization:"Bearer ".concat(o),"Content-Type":"application/json"}});if(!s.ok){const e=await s.clone().text(),t=s.status,n=Va(s.headers);let o;try{o=JSON.parse(e);}catch(o){throw new ec("Failed to delete authenticator",{error:"unknown_error",error_description:"Failed to delete authenticator",statusCode:t,headers:n,body:e})}throw new ec(o.error_description||"Failed to delete authenticator",f(f({},o),{},{statusCode:t,headers:n,body:e}))}}async challengeAuthenticator(e,t){const n="".concat(c(As,this),"/mfa/challenge"),o=e.mfaToken,i=m(e,Cs),s={mfa_token:o,client_id:c(Rs,this),challenge_type:i.challengeType};c(xs,this)&&(s.client_secret=c(xs,this)),i.authenticatorId&&(s.authenticator_id=i.authenticatorId);const a=await r(Ns,this,dc).call(this,t)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const e=await a.clone().text(),t=a.status,n=Va(a.headers);let o;try{o=JSON.parse(e);}catch(o){throw new tc("Failed to challenge authenticator",{error:"unknown_error",error_description:"Failed to challenge authenticator",statusCode:t,headers:n,body:e})}throw new tc(o.error_description||"Failed to challenge authenticator",f(f({},o),{},{statusCode:t,headers:n,body:e}))}return function(e){const t={challengeType:e.challenge_type};return void 0!==e.oob_code&&(t.oobCode=e.oob_code),void 0!==e.binding_method&&(t.bindingMethod=e.binding_method),t}(await a.json())}async verify(e,t){if(!c(js,this))throw new Error("MFA verify requires a configuration provider (getConfiguration was not set)");const n={mfa_token:e.mfaToken};if(e.audience&&(n.audience=e.audience),"otp"===e.factorType?n.otp=e.otp:"oob"===e.factorType?(n.oob_code=e.oobCode,e.bindingCode&&(n.binding_code=e.bindingCode)):"recovery-code"===e.factorType&&(n.recovery_code=e.recoveryCode),e.fullResponse){var o;if(!c(Ws,this))throw new Error("MFA verify fullResponse requires a capture-config factory (createCaptureConfiguration was not set)");const a=ac(null!==(o=(await c(js,this).call(this,t))[Gi])&&void 0!==o?o:fetch),u=await c(Ws,this).call(this,a);try{const t=await kr(u,uc[e.factorType],n),o=ic.fromTokenEndpointResponse(t);t.recovery_code&&(o.recoveryCode=t.recovery_code);const i=a.getCapturedResponse();if(!i)throw new Fa;return {data:o,response:i}}catch(e){var i,r,s;if(e instanceof Fa)throw e;if(e instanceof nc)throw e;const t=e,n=new nc(t.error_description||t.message||"Failed to verify MFA challenge",{error:null!==(i=t.error)&&void 0!==i?i:"mfa_verify_error",error_description:null!==(r=null!==(s=t.error_description)&&void 0!==s?s:t.message)&&void 0!==r?r:"Failed to verify MFA challenge"});throw Xa(n,e,a.getCapturedResponse()),n}}const a=await c(js,this).call(this,t);try{const t=await kr(a,uc[e.factorType],n),o=ic.fromTokenEndpointResponse(t);return t.recovery_code&&(o.recoveryCode=t.recovery_code),o}catch(e){var u,l,d;if(e instanceof nc)throw e;const t=e,n=new nc(t.error_description||t.message||"Failed to verify MFA challenge",{error:null!==(u=t.error)&&void 0!==u?u:"mfa_verify_error",error_description:null!==(l=null!==(d=t.error_description)&&void 0!==d?d:t.message)&&void 0!==l?l:"Failed to verify MFA challenge"});throw Xa(n,e),n}}});function dc(e){return cc(c(Is,this),e,c(Os,this))}var hc=class extends Error{constructor(e,t,n){super(t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"statusCode",void 0),h(this,"headers",void 0),h(this,"body",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};const o=Ea(n);this.statusCode=o.statusCode,this.headers=o.headers,this.body=o.body;}},pc=class extends hc{constructor(e,t){super("passkey_register_error",e,t),this.name="PasskeyRegisterError";}},fc=class extends hc{constructor(e,t){super("passkey_challenge_error",e,t),this.name="PasskeyChallengeError";}},mc=class extends hc{constructor(e,t){super("passkey_get_token_error",e,t),this.name="PasskeyGetTokenError",this.cause=t&&{error:t.error,error_description:t.error_description,message:t.message,mfa_token:t.mfa_token,mfa_requirements:t.mfa_requirements};}};function yc(e){return e.useMtls?{}:e.clientSecret?{client_secret:e.clientSecret}:{}}var wc="urn:okta:params:oauth:grant-type:webauthn",gc=(Ks=new WeakMap,Ms=new WeakMap,Us=new WeakMap,Ls=new WeakMap,zs=new WeakMap,Js=new WeakMap,Ds=new WeakSet,class{constructor(e){var t,n;d(this,Ds),u(this,Ks,void 0),u(this,Ms,void 0),u(this,Us,void 0),u(this,Ls,void 0),u(this,zs,void 0),u(this,Js,void 0),l(Ks,this,"https://".concat(e.domain)),l(Ms,this,e.clientId),l(Us,this,{clientSecret:e.clientSecret,useMtls:e.useMtls}),l(Ls,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),l(zs,this,null!==(n=e.telemetryConfig)&&void 0!==n?n:sc()),l(Js,this,e.grantRequest);}async register(e,t){const n="".concat(c(Ks,this),"/passkey/register"),o=f(f(f(f(f(f(f(f({},e.email&&{email:e.email}),e.name&&{name:e.name}),e.phoneNumber&&{phone_number:e.phoneNumber}),e.username&&{username:e.username}),e.givenName&&{given_name:e.givenName}),e.familyName&&{family_name:e.familyName}),e.nickname&&{nickname:e.nickname}),e.picture&&{picture:e.picture}),i=f(f({client_id:c(Ms,this)},yc(c(Us,this))),{},{user_profile:o});e.realm&&(i.realm=e.realm),e.organization&&(i.organization=e.organization),e.userMetadata&&(i.user_metadata=e.userMetadata);const s=await r(Ds,this,vc).call(this,t)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok){const e=await r(Ds,this,bc).call(this,s),t=new pc(e.error_description||"Failed to request signup challenge",e);throw t.statusCode=s.status,t.headers=Va(s.headers),t}const a=await s.json();return {authSession:(u=a).auth_session,authnParamsPublicKey:f({},u.authn_params_public_key)};var u;}async challenge(e,t){const n="".concat(c(Ks,this),"/passkey/challenge"),o=f({client_id:c(Ms,this)},yc(c(Us,this)));null!=e&&e.realm&&(o.realm=e.realm),null!=e&&e.organization&&(o.organization=e.organization);const i=await r(Ds,this,vc).call(this,t)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok){const e=await r(Ds,this,bc).call(this,i),t=new fc(e.error_description||"Failed to request login challenge",e);throw t.statusCode=i.status,t.headers=Va(i.headers),t}const s=await i.json();return {authSession:(a=s).auth_session,authnParamsPublicKey:f({},a.authn_params_public_key)};var a;}async getTokenByPasskey(e,t){void 0!==e.organization&&qa(e.organization);const n=new URLSearchParams({auth_session:e.authSession,authn_response:JSON.stringify(e.credential)});let o;e.realm&&n.append("realm",e.realm),e.scope&&n.append("scope",e.scope),e.audience&&n.append("audience",e.audience),e.organization&&n.append("organization",e.organization);try{o=await c(Js,this).call(this,wc,n,t,e.fullResponse);}catch(e){if(e instanceof Fa)throw e;const t=Ca(e),n=new mc(t.error_description||"Failed to exchange passkey credential for tokens.",t);throw Xa(n,e),n}if(e.fullResponse){const t=o;return e.organization&&Ya(t.data.claims,e.organization),t}const i=o;return e.organization&&Ya(i.claims,e.organization),i}});function vc(e){return cc(c(Ls,this),e,c(zs,this))}async function bc(e){const t=await e.clone().text();try{return f(f({},JSON.parse(t)),{},{statusCode:e.status,headers:e.headers,body:t})}catch(n){return {error:"unknown_error",error_description:"HTTP ".concat(e.status," ").concat(e.statusText),statusCode:e.status,headers:e.headers,body:t}}}var _c=class extends Error{constructor(e,t,n){super(t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"statusCode",void 0),h(this,"headers",void 0),h(this,"body",void 0),Object.setPrototypeOf(this,new.target.prototype),this.code=e,this.cause=n&&(n.error||n.error_description)?{error:n.error,error_description:n.error_description,message:n.message,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements}:void 0;const o=Ea(n);this.statusCode=o.statusCode,this.headers=o.headers,this.body=o.body;}},kc=class extends _c{constructor(e,t){super("passwordless_start_error",e,t),this.name="PasswordlessStartError";}},Sc=class extends _c{constructor(e,t){super("passwordless_verify_error",e,t),this.name="PasswordlessVerifyError";}},Tc=class extends _c{constructor(e,t){super("passwordless_db_get_token_error",e,t),this.name="PasswordlessDbGetTokenError";}},Pc=class extends _c{constructor(e,t,n,o,i){super("passwordless_challenge_error",e,n),h(this,"statusCode",void 0),h(this,"validationErrors",void 0),this.name="PasswordlessChallengeError",this.statusCode=t,this.validationErrors=o,this.headers=null!=i?i:this.headers;}};function Ec(e){return /^\+[1-9]\d{1,14}$/.test(e)}async function Cc(e,t,n){if(e.useMtls)return {};if(e.clientAssertionSigningKey){var o;const i=null!==(o=e.clientAssertionSigningAlg)&&void 0!==o?o:"RS256",r=e.clientAssertionSigningKey instanceof CryptoKey?e.clientAssertionSigningKey:await Ps(e.clientAssertionSigningKey,i);return {client_assertion:await new is({}).setProtectedHeader({alg:i}).setIssuer(t).setSubject(t).setAudience("https://".concat(n,"/")).setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime("".concat(120,"s")).sign(r),client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}}if(e.clientSecret)return {client_secret:e.clientSecret};throw new Za}var Ac=(Zs=new WeakMap,Hs=new WeakMap,Fs=new WeakMap,Vs=new WeakMap,Xs=new WeakMap,Gs=new WeakMap,qs=new WeakMap,Ys=new WeakSet,class{constructor(e){var t,n;d(this,Ys),u(this,Zs,void 0),u(this,Hs,void 0),u(this,Fs,void 0),u(this,Vs,void 0),u(this,Xs,void 0),u(this,Gs,void 0),u(this,qs,void 0),l(Hs,this,e.domain),l(Zs,this,"https://".concat(e.domain)),l(Fs,this,e.clientId),l(Vs,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),l(Xs,this,null!==(n=e.telemetryConfig)&&void 0!==n?n:sc()),l(Gs,this,{clientSecret:e.clientSecret,clientAssertionSigningKey:e.clientAssertionSigningKey,clientAssertionSigningAlg:e.clientAssertionSigningAlg,useMtls:e.useMtls}),l(qs,this,e.grantRequest);}async sendEmail(e,t){const n=await r(Ys,this,xc).call(this,function(e){var t;const n=null!==(t=e.send)&&void 0!==t?t:"code",o={email:e.email,connection:"email",send:n};return "link"===n&&e.authParams&&(o.authParams=e.authParams),o}(e),"Failed to send passwordless email",e.language,t);if(e.fullResponse)return {data:void 0,response:n}}async sendSms(e,t){if(!Ec(e.phoneNumber))throw new kc("Phone number must be in E.164 format (e.g. +14155550100).");const n=await r(Ys,this,xc).call(this,function(e){return {phone_number:e.phoneNumber,connection:"sms"}}(e),"Failed to send passwordless SMS",e.language,t);if(e.fullResponse)return {data:void 0,response:n}}async challengeWithEmail(e,t){const n=function(e){var t;return {email:e.email,connection:e.connection,allow_signup:null!==(t=e.allowSignup)&&void 0!==t&&t}}(e);return r(Ys,this,Ic).call(this,n,"Failed to request email OTP challenge",t)}async challengeWithPhoneNumber(e,t){if(!Ec(e.phoneNumber))throw new Pc("Phone number must be in E.164 format (e.g. +14155550100).",0,void 0,void 0);const n=function(e){var t;const n={phone_number:e.phoneNumber,connection:e.connection,allow_signup:null!==(t=e.allowSignup)&&void 0!==t&&t};return e.deliveryMethod&&(n.delivery_method=e.deliveryMethod),n}(e);return r(Ys,this,Ic).call(this,n,"Failed to request phone OTP challenge",t)}async getTokenByPasswordlessDbConnection(e,t){const n=new URLSearchParams({auth_session:e.authSession,otp:e.otp});if(e.scope&&n.append("scope",e.scope),e.audience&&n.append("audience",e.audience),!c(qs,this))throw new Tc("Missing grant request delegate.",Ca(new Error("missing grantRequest")));try{return await c(qs,this).call(this,"http://auth0.com/oauth/grant-type/passwordless/otp",n,t,e.fullResponse)}catch(e){if(e instanceof Fa)throw e;const t=new Tc("There was an error while trying to request a token.",Ca(e)),n=e;throw t.statusCode=n._statusCode,t.headers=n._headers,t}}});function Rc(e){return cc(c(Vs,this),e,c(Xs,this))}async function xc(e,t,n,o){var i;const s=await Cc(c(Gs,this),c(Fs,this),c(Hs,this)),a=f(f({client_id:c(Fs,this)},e),s);let u;try{u=await r(Ys,this,Rc).call(this,o)("".concat(c(Zs,this),"/passwordless/start"),{method:"POST",headers:f({"Content-Type":"application/json"},n?{"x-request-language":n}:{}),body:JSON.stringify(a)});}catch(e){throw new kc("".concat(t,": a network error occurred."))}if(u.ok)return u;const l=await u.clone().text();let d;if(204!==u.status)try{d=JSON.parse(l);}catch(e){d=void 0;}const h=new kc((null===(i=d)||void 0===i?void 0:i.error_description)||t,d);throw h.statusCode=u.status,h.headers=Va(u.headers),h.body=l,h}async function Ic(e,t,n){var o,i;const s=await Cc(c(Gs,this),c(Fs,this),c(Hs,this)),a=f(f({client_id:c(Fs,this)},e),s);let u;try{u=await r(Ys,this,Rc).call(this,n)("".concat(c(Zs,this),"/otp/challenge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});}catch(e){throw new Pc("challenge error: a network error occurred.",0,void 0,void 0)}if(u.ok){let e;try{e=await u.json();}catch(e){throw new Pc("".concat(t,": could not parse the response body."),u.status,void 0,void 0,Va(u.headers))}return {authSession:e.auth_session}}const l=await u.clone().text();let d;try{d=JSON.parse(l);}catch(e){d=void 0;}const h=d?f(f({},d),{},{statusCode:u.status,headers:u.headers,body:l}):{error:"",error_description:"",statusCode:u.status,headers:u.headers,body:l};throw new Pc((null===(o=d)||void 0===o?void 0:o.error_description)||t,u.status,h,null===(i=d)||void 0===i?void 0:i.validation_errors,Va(u.headers))}var Oc=class extends Error{constructor(e,t,n){super(t),h(this,"cause",void 0),h(this,"code",void 0),h(this,"statusCode",void 0),h(this,"headers",void 0),h(this,"body",void 0),Object.setPrototypeOf(this,new.target.prototype),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};const o=Ea(n);this.statusCode=o.statusCode,this.headers=o.headers,this.body=o.body;}},jc=class extends Oc{constructor(e,t){super("signup_error",e,t),this.name="SignUpError";}},Wc=class extends Oc{constructor(e,t){super("change_password_error",e,t),this.name="ChangePasswordError";}};function Nc(e,t,n){for(const o of t)if(null===e[o]||void 0===e[o]||""===e[o])throw new n('Required parameter "'.concat(String(o),'" was null, undefined, or empty.'))}function Kc(e){var t,n;return {id:null!==(t=null!==(n=e._id)&&void 0!==n?n:e.user_id)&&void 0!==t?t:e.id,email:"string"==typeof e.email?e.email:"",emailVerified:Boolean(e.email_verified),username:e.username,givenName:e.given_name,familyName:e.family_name,name:e.name,nickname:e.nickname,picture:e.picture,userMetadata:e.user_metadata}}var Mc=(Bs=new WeakMap,Qs=new WeakMap,$s=new WeakMap,ea=new WeakMap,ta=new WeakSet,class{constructor(e){var t,n;d(this,ta),u(this,Bs,void 0),u(this,Qs,void 0),u(this,$s,void 0),u(this,ea,void 0),l(Bs,this,"https://".concat(e.domain)),l(Qs,this,e.clientId),l($s,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),l(ea,this,null!==(n=e.telemetryConfig)&&void 0!==n?n:sc());}async signUp(e,t){var n;Nc(e,["email","password","connection"],jc);const o=f({client_id:null!==(n=e.clientId)&&void 0!==n?n:c(Qs,this)},function(e){const t={email:e.email,password:e.password,connection:e.connection};return void 0!==e.username&&(t.username=e.username),void 0!==e.givenName&&(t.given_name=e.givenName),void 0!==e.familyName&&(t.family_name=e.familyName),void 0!==e.name&&(t.name=e.name),void 0!==e.nickname&&(t.nickname=e.nickname),void 0!==e.picture&&(t.picture=e.picture),void 0!==e.userMetadata&&(t.user_metadata=e.userMetadata),t}(e)),i=await r(ta,this,Uc).call(this,"/dbconnections/signup",o,jc,"Failed to sign up",t);if(e.fullResponse){const e=i.clone();return {data:Kc(await i.json()),response:e}}return Kc(await i.json())}async changePassword(e,t){var n;if(Nc(e,["connection"],Wc),!e.email&&!e.username)throw new Wc('Either "email" or "username" is required.');const o=f({client_id:null!==(n=e.clientId)&&void 0!==n?n:c(Qs,this)},function(e){const t={connection:e.connection};return void 0!==e.email&&(t.email=e.email),void 0!==e.username&&(t.username=e.username),void 0!==e.organization&&(t.organization=e.organization),t}(e)),i=await r(ta,this,Uc).call(this,"/dbconnections/change_password",o,Wc,"Failed to request a password change",t);if(e.fullResponse){const e=i.clone();return {data:await i.text(),response:e}}return i.text()}});async function Uc(e,t,n,o,i){const r=cc(c($s,this),i,c(ea,this));let s;try{s=await r("".concat(c(Bs,this)).concat(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});}catch(e){throw new n("".concat(o,": a network error occurred."))}if(s.ok)return s;const a=await s.clone().text(),u=await async function(e){let t;try{t=await e.json();}catch(e){return}return "string"==typeof t.error?t:"string"==typeof t.code?{error:t.code,error_description:"string"==typeof t.description?t.description:""}:void 0}(s.clone()),l=new n((null==u?void 0:u.error_description)||o,null!=u?u:{error:"unknown_error",error_description:o});throw l.statusCode=s.status,l.headers=Va(s.headers),l.body=a,l}var Lc=class extends Error{constructor(e,t,n){super(t),h(this,"code",void 0),h(this,"cause",void 0),this.name="AnonymousSessionError",this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};}};var zc=new Set(["session_expired","invalid_session_token"]);async function Jc(e){const t="Request failed with status ".concat(e.status);let n={};try{n=await e.json();}catch(e){}return {error:"string"==typeof n.error?n.error:"server_error",error_description:"string"==typeof n.error_description?n.error_description:t}}var Dc=(na=new WeakMap,oa=new WeakMap,ia=new WeakMap,ra=new WeakMap,sa=new WeakMap,aa=new WeakMap,ca=new WeakMap,ua=new WeakMap,la=new WeakSet,class{constructor(e){var t;d(this,la),u(this,na,void 0),u(this,oa,void 0),u(this,ia,void 0),u(this,ra,void 0),u(this,sa,void 0),u(this,aa,void 0),u(this,ca,void 0),u(this,ua,void 0),l(na,this,e.domain),l(oa,this,"https://".concat(e.domain)),l(ia,this,e.clientId),l(ra,this,e.clientSecret),l(sa,this,e.clientAssertionSigningKey),l(aa,this,e.clientAssertionSigningAlg),l(ca,this,e.useMtls),l(ua,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)});}async createSession(e){const t={client_id:c(ia,this)};null!=e&&e.audience&&(t.audience=e.audience),null!=e&&e.scope&&(t.scope=e.scope),null!=e&&e.metadata&&(t.metadata=e.metadata);const n=await r(la,this,Hc).call(this,t);if(!n.sessionToken)throw new Lc("server_error","session_token missing from create session response");return {sessionToken:n.sessionToken,accessToken:n.accessToken,expiresAt:n.expiresAt,sessionTokenExpiresAt:n.sessionTokenExpiresAt,scope:n.scope}}async getAccessToken(e){if(null==e||!e.sessionToken)return this.createSession({audience:null==e?void 0:e.audience,scope:null==e?void 0:e.scope});try{return await r(la,this,Zc).call(this,e.sessionToken,e)}catch(t){if(t instanceof Lc&&zc.has(t.code)){return f(f({},await this.createSession({audience:null==e?void 0:e.audience,scope:null==e?void 0:e.scope})),{},{sessionReplaced:!0})}throw t}}async logout(){const e="".concat(c(oa,this),"/anonymous/logout"),t={client_id:c(ia,this)},n=await c(ua,this).call(this,e,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",redirect:"error",body:JSON.stringify(t)});if(!n.ok){const e=await Jc(n);throw new Lc(e.error,e.error_description||"Failed to end anonymous session",e)}}});async function Zc(e,t){const n={client_id:c(ia,this),session_token:e};null!=t&&t.audience&&(n.audience=t.audience),null!=t&&t.scope&&(n.scope=t.scope);const o=await r(la,this,Hc).call(this,n);return {sessionToken:e,accessToken:o.accessToken,expiresAt:o.expiresAt,sessionTokenExpiresAt:o.sessionTokenExpiresAt,scope:o.scope,sessionReplaced:!1}}async function Hc(e){const t="".concat(c(oa,this),"/anonymous/token"),n=await async function(e,t,n){if(e.useMtls)return {};if(e.clientAssertionSigningKey){var o;const i=null!==(o=e.clientAssertionSigningAlg)&&void 0!==o?o:"RS256",r=e.clientAssertionSigningKey instanceof CryptoKey?e.clientAssertionSigningKey:await Ps(e.clientAssertionSigningKey,i);return {client_assertion:await new is({}).setProtectedHeader({alg:i}).setIssuer(t).setSubject(t).setAudience("https://".concat(n,"/")).setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime("".concat(120,"s")).sign(r),client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}}return e.clientSecret?{client_secret:e.clientSecret}:{}}({clientSecret:c(ra,this),clientAssertionSigningKey:c(sa,this),clientAssertionSigningAlg:c(aa,this),useMtls:c(ca,this)},c(ia,this),c(na,this));Object.assign(e,n);const o=await c(ua,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",redirect:"error",body:JSON.stringify(e)});if(!o.ok){const e=await Jc(o);throw new Lc(e.error,e.error_description||"Anonymous token request failed",e)}let i;try{i=await o.json();}catch(e){throw new Lc("server_error","Invalid response from anonymous token endpoint")}return function(e){const t=Math.floor(Date.now()/1e3);if("string"!=typeof e.access_token||!e.access_token)throw new Lc("server_error","access_token missing or invalid in anonymous token response");const n=e.expires_in;if("number"!=typeof n||!Number.isFinite(n))throw new Lc("server_error","expires_in missing or invalid in anonymous token response");return {accessToken:e.access_token,expiresAt:t+n,scope:e.scope,sessionToken:e.session_token,sessionTokenExpiresAt:"number"==typeof e.session_expires_in&&Number.isFinite(e.session_expires_in)?t+e.session_expires_in:void 0}}(i)}var Fc=(da=new WeakMap,ha=new WeakMap,pa=new WeakMap,class{constructor(e,t){u(this,da,new Map),u(this,ha,void 0),u(this,pa,void 0),l(pa,this,Math.max(1,Math.floor(e))),l(ha,this,Math.max(0,Math.floor(t)));}get(e){const t=c(da,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return c(da,this).delete(e),c(da,this).set(e,t),t.value;c(da,this).delete(e);}}set(e,t,n){c(da,this).has(e)&&c(da,this).delete(e);const o=null!=n&&Number.isFinite(n)&&n>0?n:c(ha,this);for(c(da,this).set(e,{value:t,expiresAt:Date.now()+o});c(da,this).size>c(pa,this);){const e=c(da,this).keys().next().value;if(void 0===e)break;c(da,this).delete(e);}}}),Vc=new Map;function Xc(e){return {ttlMs:1e3*("number"==typeof(null==e?void 0:e.ttl)?e.ttl:600),maxEntries:"number"==typeof(null==e?void 0:e.maxEntries)&&e.maxEntries>0?e.maxEntries:100}}var Gc=class{static createDiscoveryCache(e){const t=(n=e.maxEntries,o=e.ttlMs,"".concat(n,":").concat(o));var n,o;let i=(r=t,Vc.get(r));var r;return i||(i=new Fc(e.maxEntries,e.ttlMs),Vc.set(t,i)),i}static createJwksCache(){return {}}},qc="openid profile email offline_access",Yc=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 Bc(e){if(null==e)throw new Na("subject_token is required");if("string"!=typeof e)throw new Na("subject_token must be a string");if(0===e.trim().length)throw new Na("subject_token cannot be blank or whitespace");if(e!==e.trim())throw new Na("subject_token must not include leading or trailing whitespace");if(/^bearer\s+/i.test(e))throw new Na("subject_token must not include the 'Bearer ' prefix")}function Qc(e,t){if(t)for(const o of Object.entries(t)){var n=y(o,2);const t=n[0],i=n[1];if(!Yc.has(t))if(Array.isArray(i)){if(i.length>20)throw new Na("Parameter '".concat(t,"' exceeds maximum array size of ").concat(20));i.forEach(n=>{e.append(t,n);});}else e.append(t,i);}}var $c="urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",eu="urn:ietf:params:oauth:grant-type:token-exchange",tu="urn:ietf:params:oauth:token-type:access_token";function nu(e,t){return (n,o)=>{const i=null==o?void 0:o.body;if(t!==wc||!(i instanceof URLSearchParams))return e(n,o);const r={};for(const e of i){var s=y(e,2);const t=s[0],n=s[1];r[t]="authn_response"===t?JSON.parse(n):n;}const a=new Headers(null==o?void 0:o.headers);return a.set("Content-Type","application/json"),e(n,f(f({},o),{},{headers:a,body:JSON.stringify(r)}))}}var ou=(fa=new WeakMap,ma=new WeakMap,ya=new WeakMap,wa=new WeakMap,ga=new WeakMap,va=new WeakMap,ba=new WeakMap,_a=new WeakMap,ka=new WeakMap,Sa=new WeakMap,Ta=new WeakMap,Pa=new WeakSet,class{constructor(e){var t;if(d(this,Pa),u(this,fa,void 0),u(this,ma,void 0),u(this,ya,void 0),u(this,wa,void 0),u(this,ga,void 0),u(this,va,void 0),u(this,ba,void 0),u(this,_a,void 0),u(this,ka,void 0),u(this,Sa,void 0),u(this,Ta,void 0),h(this,"mfa",void 0),h(this,"passkey",void 0),h(this,"passwordless",void 0),h(this,"database",void 0),h(this,"anonymous",void 0),l(ga,this,e),e.useMtls&&!e.customFetch)throw new Aa("mtls_without_custom_fetch_not_supported","Using mTLS without a custom fetch implementation is not supported");l(ba,this,sc(e.telemetry)),l(va,this,rc(null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)},c(ba,this)));const n=Xc(e.discoveryCache);l(ka,this,Gc.createDiscoveryCache(n)),l(Sa,this,new Map),l(Ta,this,Gc.createJwksCache()),this.mfa=new lc({domain:c(ga,this).domain,clientId:c(ga,this).clientId,clientSecret:c(ga,this).clientSecret,customFetch:c(va,this),telemetryConfig:c(ba,this),getConfiguration:async e=>(await r(Pa,this,au).call(this,e)).configuration,createCaptureConfiguration:async e=>{const t=(await r(Pa,this,cu).call(this)).serverMetadata;return r(Pa,this,ru).call(this,t,e)}}),this.passkey=new gc({domain:c(ga,this).domain,clientId:c(ga,this).clientId,clientSecret:c(ga,this).clientSecret,useMtls:c(ga,this).useMtls,customFetch:c(va,this),telemetryConfig:c(ba,this),grantRequest:async(e,t,n,o)=>{const i=(await r(Pa,this,cu).call(this)).serverMetadata,s=r(Pa,this,su).call(this,n);if(o){const n=ac(s),o=await r(Pa,this,ru).call(this,i,n);o[Gi]=nu(n,e);const a=await kr(o,e,t),c=ic.fromTokenEndpointResponse(a),u=n.getCapturedResponse();if(!u)throw new Fa;return {data:c,response:u}}const a=await r(Pa,this,ru).call(this,i);a[Gi]=nu(s,e);const c=await kr(a,e,t);return ic.fromTokenEndpointResponse(c)}}),this.passwordless=new Ac({domain:c(ga,this).domain,clientId:c(ga,this).clientId,customFetch:c(va,this),telemetryConfig:c(ba,this),clientSecret:c(ga,this).clientSecret,clientAssertionSigningKey:c(ga,this).clientAssertionSigningKey,clientAssertionSigningAlg:c(ga,this).clientAssertionSigningAlg,useMtls:c(ga,this).useMtls,grantRequest:async(e,t,n,o)=>{const i=(await r(Pa,this,au).call(this,n)).configuration;if(o){var s;const n=ac(null!==(s=i[Gi])&&void 0!==s?s:c(va,this)),o=await r(Pa,this,ru).call(this,i.serverMetadata(),n),a=await kr(o,e,t),u=ic.fromTokenEndpointResponse(a),l=n.getCapturedResponse();if(!l)throw new Fa;return {data:u,response:l}}try{const n=await kr(i,e,t);return ic.fromTokenEndpointResponse(n)}catch(e){const t=e,n={};throw Xa(n,e),t._statusCode=n.statusCode,t._headers=n.headers,e}}}),this.database=new Mc({domain:c(ga,this).domain,clientId:c(ga,this).clientId,customFetch:c(va,this),telemetryConfig:c(ba,this)}),this.anonymous=new Dc({domain:c(ga,this).domain,clientId:c(ga,this).clientId,clientSecret:c(ga,this).clientSecret,clientAssertionSigningKey:c(ga,this).clientAssertionSigningKey,clientAssertionSigningAlg:c(ga,this).clientAssertionSigningAlg,useMtls:c(ga,this).useMtls,customFetch:c(va,this)});}async getServerMetadata(){return (await r(Pa,this,cu).call(this)).serverMetadata}async buildAuthorizationUrl(e){const t=(await r(Pa,this,cu).call(this)).serverMetadata;if(null!=e&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new Aa("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 r(Pa,this,mu).call(this,e)}catch(e){throw new za(e)}}async buildLinkUserUrl(e){try{const t=await r(Pa,this,mu).call(this,{authorizationParams:f(f({},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 Ja(e)}}async buildUnlinkUserUrl(e){try{const t=await r(Pa,this,mu).call(this,{authorizationParams:f(f({},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 Da(e)}}async backchannelAuthentication(e,t){var n;const o=await r(Pa,this,au).call(this,t),i=o.configuration,s=o.serverMetadata,a=Ga(f(f({},c(ga,this).authorizationParams),null==e?void 0:e.authorizationParams)),u=new URLSearchParams(f(f({scope:qc},a),{},{client_id:c(ga,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:s.issuer,sub:e.loginHint.sub})}));if(e.requestedExpiry&&u.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&u.append("authorization_details",JSON.stringify(e.authorizationDetails)),e.fullResponse){var l;const e=ac(null!==(l=i[Gi])&&void 0!==l?l:c(va,this)),t=await r(Pa,this,ru).call(this,i.serverMetadata(),e);try{const n=await ur(i,u),o=await lr(t,n),r=e.getCapturedResponse();if(!r)throw new Fa;return {data:ic.fromTokenEndpointResponse(o),response:r}}catch(t){if(t instanceof Fa)throw t;const n=new La(t);throw Xa(n,t,e.getCapturedResponse()),n}}const d=ac(null!==(n=i[Gi])&&void 0!==n?n:c(va,this)),h=await r(Pa,this,ru).call(this,i.serverMetadata(),d);try{const e=await ur(i,u),t=await lr(h,e);return ic.fromTokenEndpointResponse(t)}catch(e){const t=new La(e);throw Xa(t,e,d.getCapturedResponse()),t}}async initiateBackchannelAuthentication(e,t){var n;const o=await r(Pa,this,au).call(this,t),i=o.configuration,s=o.serverMetadata,a=Ga(f(f({},c(ga,this).authorizationParams),null==e?void 0:e.authorizationParams)),u=new URLSearchParams(f(f({scope:qc},a),{},{client_id:c(ga,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:s.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&u.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&u.append("authorization_details",JSON.stringify(e.authorizationDetails));const l=ac(null!==(n=i[Gi])&&void 0!==n?n:c(va,this)),d=await r(Pa,this,ru).call(this,i.serverMetadata(),l);try{const e=await ur(d,u);return {authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){const t=new La(e),n=l.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Va(n.headers):void 0,t}}async backchannelAuthenticationGrant(e,t){var n;let o=e.authReqId;const i=(await r(Pa,this,au).call(this,t)).configuration,s=new URLSearchParams({auth_req_id:o}),a=ac(null!==(n=i[Gi])&&void 0!==n?n:c(va,this)),u=await r(Pa,this,ru).call(this,i.serverMetadata(),a);try{const e=await kr(u,"urn:openid:params:grant-type:ciba",s);return ic.fromTokenEndpointResponse(e)}catch(e){const t=new La(e),n=a.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Va(n.headers):void 0,t}}async getTokenForConnection(e,t){var n;if(e.refreshToken&&e.accessToken)throw new Wa("Either a refresh or access token should be specified, but not both.");const o=null!==(n=e.accessToken)&&void 0!==n?n:e.refreshToken;if(!o)throw new Wa("Either a refresh or access token must be specified.");try{return await this.exchangeToken(f({connection:e.connection,subjectToken:o,subjectTokenType:e.accessToken?tu:"urn:ietf:params:oauth:token-type:refresh_token",loginHint:e.loginHint},e.fullResponse?{fullResponse:!0}:{}),t)}catch(e){if(e instanceof Na){const t=new Wa(e.message,e.cause);throw t.statusCode=e.statusCode,t.headers=e.headers,t}throw e}}async exchangeToken(e,t){return e.fullResponse?"connection"in e?r(Pa,this,lu).call(this,e,t,!0):r(Pa,this,hu).call(this,e,t,!0):"connection"in e?r(Pa,this,lu).call(this,e,t):r(Pa,this,hu).call(this,e,t)}async getTokenByCode(e,t,n){var o;const i=(await r(Pa,this,au).call(this,n)).configuration;if(void 0!==t.organization&&qa(t.organization),t.fullResponse){var s;const n=ac(null!==(s=i[Gi])&&void 0!==s?s:c(va,this)),o=await r(Pa,this,ru).call(this,i.serverMetadata(),n);let a,u;try{const i=await hr(o,e,{pkceCodeVerifier:t.codeVerifier});if(a=ic.fromTokenEndpointResponse(i),u=n.getCapturedResponse(),!u)throw new Fa}catch(e){if(e instanceof Fa)throw e;const t=new xa("There was an error while trying to request a token.",Ca(e)),o=n.getCapturedResponse();throw t.statusCode=null==o?void 0:o.status,t.headers=o?Va(o.headers):void 0,t}return t.organization&&Ya(a.claims,t.organization),{data:a,response:u}}const a=ac(null!==(o=i[Gi])&&void 0!==o?o:c(va,this)),u=await r(Pa,this,ru).call(this,i.serverMetadata(),a);let l;try{const n=await hr(u,e,{pkceCodeVerifier:t.codeVerifier});l=ic.fromTokenEndpointResponse(n);}catch(e){const t=new xa("There was an error while trying to request a token.",Ca(e)),n=a.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Va(n.headers):void 0,t}return t.organization&&Ya(l.claims,t.organization),l}async getTokenByMagicLinkCode(e,t,n){var o;const i=(await r(Pa,this,au).call(this,n)).configuration;if(null!=t&&t.fullResponse){var s;const n=ac(null!==(s=i[Gi])&&void 0!==s?s:c(va,this)),o=await r(Pa,this,ru).call(this,i.serverMetadata(),n);try{const i=await hr(o,e,{expectedState:null==t?void 0:t.expectedState}),r=ic.fromTokenEndpointResponse(i),s=n.getCapturedResponse();if(!s)throw new Fa;return {data:r,response:s}}catch(e){if(e instanceof Fa)throw e;const t=e instanceof Error&&e.message?e.message:"There was an error while trying to request a token.",o=new xa(t,e),i=n.getCapturedResponse();throw o.statusCode=null==i?void 0:i.status,o.headers=i?Va(i.headers):void 0,o}}const a=ac(null!==(o=i[Gi])&&void 0!==o?o:c(va,this)),u=await r(Pa,this,ru).call(this,i.serverMetadata(),a);try{const n=await hr(u,e,{expectedState:null==t?void 0:t.expectedState});return ic.fromTokenEndpointResponse(n)}catch(e){const t=e instanceof Error&&e.message?e.message:"There was an error while trying to request a token.",n=new xa(t,e),o=a.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Va(o.headers):void 0,n}}async getTokenByRefreshToken(e,t){var n;const o=(await r(Pa,this,au).call(this,t)).configuration,i=new URLSearchParams;if(e.audience&&i.append("audience",e.audience),e.scope&&i.append("scope",e.scope),e.fullResponse){var s;const t=ac(null!==(s=o[Gi])&&void 0!==s?s:c(va,this)),n=await r(Pa,this,ru).call(this,o.serverMetadata(),t);try{const o=await pr(n,e.refreshToken,i),r=ic.fromTokenEndpointResponse(o),s=t.getCapturedResponse();if(!s)throw new Fa;return {data:r,response:s}}catch(e){if(e instanceof Fa)throw e;const n=new Oa("The access token has expired and there was an error while trying to refresh it.",Ca(e)),o=t.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Va(o.headers):void 0,n}}const a=ac(null!==(n=o[Gi])&&void 0!==n?n:c(va,this)),u=await r(Pa,this,ru).call(this,o.serverMetadata(),a);try{const t=await pr(u,e.refreshToken,i);return ic.fromTokenEndpointResponse(t)}catch(e){const t=new Oa("The access token has expired and there was an error while trying to refresh it.",Ca(e)),n=a.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Va(n.headers):void 0,t}}async revokeToken(e,t){var n;const o=(await r(Pa,this,au).call(this,t)).configuration,i={};e.tokenTypeHint&&(i.token_type_hint=e.tokenTypeHint);const s=ac(null!==(n=o[Gi])&&void 0!==n?n:c(va,this)),a=await r(Pa,this,ru).call(this,o.serverMetadata(),s);try{await Sr(a,e.token,i);}catch(e){const t=new Ka("An error occurred while trying to revoke the token.",Ca(e)),n=s.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Va(n.headers):void 0,t}}async getUserInfo(e,t){const n=(await r(Pa,this,au).call(this,t,!0)).configuration;try{var o;return await vr(n,e.accessToken,null!==(o=e.expectedSubject)&&void 0!==o?o:Xi)}catch(e){throw new Ma("There was an error while trying to retrieve the user info.",Ca(e))}}async getTokenByPassword(e,t){var n;const o=(await r(Pa,this,au).call(this,t)).configuration,i=new URLSearchParams({username:e.username,password:e.password});e.audience&&i.append("audience",e.audience),e.scope&&i.append("scope",e.scope),e.realm&&i.append("realm",e.realm);let s=o;if(e.auth0ForwardedFor){const t=await r(Pa,this,fu).call(this);s=new rr(o.serverMetadata(),c(ga,this).clientId,{client_secret:c(ga,this).clientSecret,use_mtls_endpoint_aliases:c(ga,this).useMtls},t);const n=o[Gi];s[Gi]=(t,o)=>n(t,f(f({},o),{},{headers:f(f({},o.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}));}if(e.fullResponse){var a;const e=ac(null!==(a=s[Gi])&&void 0!==a?a:c(va,this)),t=await r(Pa,this,ru).call(this,s.serverMetadata(),e);try{const n=await kr(t,"password",i),o=ic.fromTokenEndpointResponse(n),r=e.getCapturedResponse();if(!r)throw new Fa;return {data:o,response:r}}catch(t){if(t instanceof Fa)throw t;const n=new ja("There was an error while trying to request a token.",Ca(t)),o=e.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Va(o.headers):void 0,n}}const u=ac(null!==(n=s[Gi])&&void 0!==n?n:c(va,this)),l=await r(Pa,this,ru).call(this,s.serverMetadata(),u);try{const e=await kr(l,"password",i);return ic.fromTokenEndpointResponse(e)}catch(e){const t=new ja("There was an error while trying to request a token.",Ca(e)),n=u.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Va(n.headers):void 0,t}}async getTokenByPasswordlessEmail(e,t){const n=new URLSearchParams({username:e.email,otp:e.code,realm:"email"});return e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),r(Pa,this,pu).call(this,n,t,e.fullResponse)}async getTokenByPasswordlessSms(e,t){if(!Ec(e.phoneNumber))throw new Sc("Phone number must be in E.164 format (e.g. +14155550100).");const n=new URLSearchParams({username:e.phoneNumber,otp:e.code,realm:"sms"});return e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),r(Pa,this,pu).call(this,n,t,e.fullResponse)}async getTokenByClientCredentials(e,t){var n;const o=(await r(Pa,this,au).call(this,t)).configuration;if(e.fullResponse){var i;const t=ac(null!==(i=o[Gi])&&void 0!==i?i:c(va,this)),n=await r(Pa,this,ru).call(this,o.serverMetadata(),t),s=new URLSearchParams({audience:e.audience});e.organization&&s.append("organization",e.organization);try{const e=await fr(n,s),o=ic.fromTokenEndpointResponse(e),i=t.getCapturedResponse();if(!i)throw new Fa;return {data:o,response:i}}catch(e){if(e instanceof Fa)throw e;const n=new Ia("There was an error while trying to request a token.",Ca(e)),o=t.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Va(o.headers):void 0,n}}const s=ac(null!==(n=o[Gi])&&void 0!==n?n:c(va,this)),a=await r(Pa,this,ru).call(this,o.serverMetadata(),s);try{const t=new URLSearchParams({audience:e.audience});e.organization&&t.append("organization",e.organization);const n=await fr(a,t);return ic.fromTokenEndpointResponse(n)}catch(e){const t=new Ia("There was an error while trying to request a token.",Ca(e)),n=s.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Va(n.headers):void 0,t}}async buildLogoutUrl(e){const t=await r(Pa,this,cu).call(this),n=t.configuration;if(!t.serverMetadata.end_session_endpoint){const t=new URL("https://".concat(c(ga,this).domain,"/v2/logout"));return t.searchParams.set("returnTo",e.returnTo),t.searchParams.set("client_id",c(ga,this).clientId),e.federated&&t.searchParams.set("federated",""),t}const o={post_logout_redirect_uri:e.returnTo};return e.federated&&(o.federated=""),function(e,t){wr(e);const n=Zi(e),o=n.as,i=n.c,r=Tn(o,"end_session_endpoint",!1,n.tlsOnly);(t=new URLSearchParams(t)).has("client_id")||t.set("client_id",i.client_id);for(const e of t.entries()){var s=y(e,2);const t=s[0],n=s[1];r.searchParams.append(t,n);}return r}(n,o)}async verifyLogoutToken(e){const t=(await r(Pa,this,cu).call(this)).serverMetadata,n=Xc(c(ga,this).discoveryCache),o=t.jwks_uri;c(_a,this)||l(_a,this,Ts(new URL(o),{cacheMaxAge:n.ttlMs,[bs]:c(va,this),[_s]:c(Ta,this)}));const i=(await Br(e.logoutToken,c(_a,this),{issuer:t.issuer,audience:c(ga,this).clientId,algorithms:["RS256"],requiredClaims:["iat"]})).payload;if(!("sid"in i)&&!("sub"in i))throw new Ua('either "sid" or "sub" (or both) claims must be present');if("sid"in i&&"string"!=typeof i.sid)throw new Ua('"sid" claim must be a string');if("sub"in i&&"string"!=typeof i.sub)throw new Ua('"sub" claim must be a string');if("nonce"in i)throw new Ua('"nonce" claim is prohibited');if(!("events"in i))throw new Ua('"events" claim is missing');if("object"!=typeof i.events||null===i.events)throw new Ua('"events" claim must be an object');if(!("http://schemas.openid.net/event/backchannel-logout"in i.events))throw new Ua('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim');if("object"!=typeof i.events["http://schemas.openid.net/event/backchannel-logout"])throw new Ua('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object');return {sid:i.sid,sub:i.sub}}});function iu(){const e=c(ga,this).domain.toLowerCase();return "".concat(e,"|mtls:").concat(c(ga,this).useMtls?"1":"0")}async function ru(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const o=await r(Pa,this,fu).call(this,n),i=new rr(e,c(ga,this).clientId,{client_secret:c(ga,this).clientSecret,use_mtls_endpoint_aliases:c(ga,this).useMtls},o);return i[Gi]=null!=t?t:c(va,this),i}function su(e){return cc(c(va,this),e,c(ba,this))}async function au(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=await r(Pa,this,cu).call(this,t),o=n.configuration,i=n.serverMetadata;if(!e)return {configuration:o,serverMetadata:i};const s=r(Pa,this,su).call(this,e);return {configuration:await r(Pa,this,ru).call(this,i,s,t),serverMetadata:i}}async function cu(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=c(e?ma:fa,this);if(t&&c(ya,this))return {configuration:t,serverMetadata:c(ya,this)};const n=r(Pa,this,iu).call(this);e||await r(Pa,this,fu).call(this,!1);const o=c(ka,this).get(n);if(o)return r(Pa,this,uu).call(this,o.serverMetadata,e);const i=c(Sa,this).get(n);if(i){const t=await i;return r(Pa,this,uu).call(this,t.serverMetadata,e)}const s=(async()=>{const e=(await or(new URL("https://".concat(c(ga,this).domain)),c(ga,this).clientId,{use_mtls_endpoint_aliases:c(ga,this).useMtls},(e,t,n,o)=>{n.set("client_id",t.client_id);},{[Gi]:c(va,this)})).serverMetadata();return c(ka,this).set(n,{serverMetadata:e}),{serverMetadata:e}})();s.catch(()=>{}),c(Sa,this).set(n,s);try{const t=(await s).serverMetadata;return r(Pa,this,uu).call(this,t,e)}finally{c(Sa,this).delete(n);}}async function uu(e,t){const n=await r(Pa,this,ru).call(this,e,void 0,t);return l(ya,this,e),l(t?ma:fa,this,n),{configuration:n,serverMetadata:e}}async function lu(e,t,n){var o,i,s;const a=(await r(Pa,this,au).call(this,t)).configuration;if("audience"in e||"resource"in e)throw new Na("audience and resource parameters are not supported for Token Vault exchanges");Bc(e.subjectToken);const u=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:null!==(o=e.subjectTokenType)&&void 0!==o?o:tu,requested_token_type:null!==(i=e.requestedTokenType)&&void 0!==i?i:"http://auth0.com/oauth/token-type/federated-connection-access-token"});if(e.loginHint&&u.append("login_hint",e.loginHint),e.scope&&u.append("scope",e.scope),Qc(u,e.extra),n){var l;const t=ac(null!==(l=a[Gi])&&void 0!==l?l:c(va,this)),n=await r(Pa,this,ru).call(this,a.serverMetadata(),t);try{const e=await kr(n,$c,u),o=ic.fromTokenEndpointResponse(e),i=t.getCapturedResponse();if(!i)throw new Fa;return {data:o,response:i}}catch(n){if(n instanceof Fa)throw n;const o=new Na("Failed to exchange token for connection '".concat(e.connection,"'."),Ca(n)),i=t.getCapturedResponse();throw o.statusCode=null==i?void 0:i.status,o.headers=i?Va(i.headers):void 0,o}}const d=ac(null!==(s=a[Gi])&&void 0!==s?s:c(va,this)),h=await r(Pa,this,ru).call(this,a.serverMetadata(),d);try{const e=await kr(h,$c,u);return ic.fromTokenEndpointResponse(e)}catch(t){const n=new Na("Failed to exchange token for connection '".concat(e.connection,"'."),Ca(t)),o=d.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Va(o.headers):void 0,n}}function du(e,t,n){var o;if(n.organization&&Ya(e.claims,n.organization),n.actorToken)if(null!==(o=e.claims)&&void 0!==o&&o.act)e.act=e.claims.act;else try{e.act=function(e){if("string"!=typeof e)throw new Yo("JWTs must use Compact JWS serialization, JWT must be a string");const t=e.split("."),n=t[1],o=t.length;if(5===o)throw new Yo("Only JWTs using Compact JWS serialization can be decoded");if(3!==o)throw new Yo("Invalid JWT");if(!n)throw new Yo("JWTs must contain a payload");let i,r;try{i=si(n);}catch(e){throw new Yo("Failed to base64url decode the payload")}try{r=JSON.parse(Uo.decode(i));}catch(e){throw new Yo("Failed to parse the decoded payload as JSON")}if(!ci(r))throw new Yo("Invalid JWT Claims Set");return r}(t.access_token).act;}catch(e){}return e}async function hu(e,t,n){var o;const i=(await r(Pa,this,au).call(this,t)).configuration;if(Bc(e.subjectToken),void 0!==e.organization&&qa(e.organization),void 0!==e.actorToken&&void 0===e.actorTokenType)throw new Na("actorTokenType is required when actorToken is provided");const s=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});if(e.audience&&s.append("audience",e.audience),e.scope&&s.append("scope",e.scope),e.requestedTokenType&&s.append("requested_token_type",e.requestedTokenType),e.organization&&s.append("organization",e.organization),e.actorToken&&s.append("actor_token",e.actorToken),e.actorTokenType&&s.append("actor_token_type",e.actorTokenType),Qc(s,e.extra),n){var a;const t=ac(null!==(a=i[Gi])&&void 0!==a?a:c(va,this)),n=await r(Pa,this,ru).call(this,i.serverMetadata(),t);let o,u,l;try{if(u=await kr(n,eu,s),o=ic.fromTokenEndpointResponse(u),l=t.getCapturedResponse(),!l)throw new Fa}catch(n){if(n instanceof Fa)throw n;const o=new Na("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),Ca(n)),i=t.getCapturedResponse();throw o.statusCode=null==i?void 0:i.status,o.headers=i?Va(i.headers):void 0,o}return r(Pa,this,du).call(this,o,u,e),{data:o,response:l}}const u=ac(null!==(o=i[Gi])&&void 0!==o?o:c(va,this)),l=await r(Pa,this,ru).call(this,i.serverMetadata(),u);let d,h;try{h=await kr(l,eu,s),d=ic.fromTokenEndpointResponse(h);}catch(t){const n=new Na("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),Ca(t)),o=u.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Va(o.headers):void 0,n}return r(Pa,this,du).call(this,d,h,e),d}async function pu(e,t,n){var o;const i=(await r(Pa,this,au).call(this,t)).configuration;if(n){var s;const t=ac(null!==(s=i[Gi])&&void 0!==s?s:c(va,this)),n=await r(Pa,this,ru).call(this,i.serverMetadata(),t);try{const o=await kr(n,"http://auth0.com/oauth/grant-type/passwordless/otp",e),i=ic.fromTokenEndpointResponse(o),r=t.getCapturedResponse();if(!r)throw new Fa;return {data:i,response:r}}catch(e){if(e instanceof Fa)throw e;const n=new Sc("There was an error while trying to request a token.",Ca(e)),o=t.getCapturedResponse();throw n.statusCode=null==o?void 0:o.status,n.headers=o?Va(o.headers):void 0,n}}const a=ac(null!==(o=i[Gi])&&void 0!==o?o:c(va,this)),u=await r(Pa,this,ru).call(this,i.serverMetadata(),a);try{const t=await kr(u,"http://auth0.com/oauth/grant-type/passwordless/otp",e);return ic.fromTokenEndpointResponse(t)}catch(e){const t=new Sc("There was an error while trying to request a token.",Ca(e)),n=a.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?Va(n.headers):void 0,t}}async function fu(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=!!c(ga,this).clientSecret||!!c(ga,this).clientAssertionSigningKey||!!c(ga,this).useMtls;return e&&!t?(e,t,n,o)=>{n.set("client_id",t.client_id);}:(c(wa,this)||l(wa,this,(async()=>{if(!c(ga,this).clientSecret&&!c(ga,this).clientAssertionSigningKey&&!c(ga,this).useMtls)throw new Za;if(c(ga,this).useMtls)return (e,t,n,o)=>{n.set("client_id",t.client_id);};let e=c(ga,this).clientAssertionSigningKey;return !e||e instanceof CryptoKey||(e=await Ps(e,c(ga,this).clientAssertionSigningAlg||"RS256")),e?function(e,t){return bn(e,t)}(e):Vi(c(ga,this).clientSecret)})().catch(e=>{throw l(wa,this,void 0),e})),c(wa,this))}async function mu(e){const t=(await r(Pa,this,cu).call(this)).configuration,n=$i(),o=await Qi(n),i=Ga(f(f({},c(ga,this).authorizationParams),null==e?void 0:e.authorizationParams)),s=new URLSearchParams(f(f({scope:qc},i),{},{client_id:c(ga,this).clientId,code_challenge:o,code_challenge_method:"S256"}));return {authorizationUrl:null!=e&&e.pushedAuthorizationRequests?await yr(t,s):await mr(t,s),codeVerifier:n}}var yu=new Fc(1e3,6e4);class wu extends C{constructor(e,t){super(e,t),Object.setPrototypeOf(this,wu.prototype);}static fromPayload(e){let t=e.error,n=e.error_description;return new wu(t,n)}}class gu extends wu{constructor(e,t){super(e,t),Object.setPrototypeOf(this,gu.prototype);}}class vu extends wu{constructor(e,t){super(e,t),Object.setPrototypeOf(this,vu.prototype);}}class bu extends wu{constructor(e,t){super(e,t),Object.setPrototypeOf(this,bu.prototype);}}class _u extends wu{constructor(e,t){super(e,t),Object.setPrototypeOf(this,_u.prototype);}}class ku extends wu{constructor(e,t){super(e,t),Object.setPrototypeOf(this,ku.prototype);}}class Su{constructor(){let e=arguments.length>0&&void 0!==arguments[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){const 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(){const e=Date.now();for(const n of this.contexts){var t=y(n,2);const o=t[0];e-t[1].createdAt>this.ttlMs&&this.contexts.delete(o);}}get size(){return this.contexts.size}}class Tu{constructor(e,t){this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new Su;}setMFAAuthDetails(e,t,n,o){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:o});}async getAuthenticators(e){var t,n,o;const i=this.contextManager.get(e);if(!i)throw new gu("invalid_request","MFA context not found for this MFA token");const r=null===(n=null===(t=i.mfaRequirements)||void 0===t?void 0:t.challenge)||void 0===n?void 0:n.map(e=>e.type);try{const t=await this.authJsMfaClient.listAuthenticators({mfaToken:e});return r&&0!==r.length?t.filter(e=>!!e.type&&r.includes(e.type)):t}catch(e){if(e instanceof Qa)throw new gu(null===(o=e.cause)||void 0===o?void 0:o.error,e.message);throw e}}async enroll(e){var t;const n=function(e){const t=xt[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(n)}catch(e){if(e instanceof $a)throw new vu(null===(t=e.cause)||void 0===t?void 0:t.error,e.message);throw e}}async challenge(e){var t;try{const t={challengeType:e.challengeType,mfaToken:e.mfaToken};return e.authenticatorId&&(t.authenticatorId=e.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(t)}catch(e){if(e instanceof tc)throw new bu(null===(t=e.cause)||void 0===t?void 0:t.error,e.message);throw e}}async getEnrollmentFactors(e){const t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new ku("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&&0!==t.mfaRequirements.enroll.length?t.mfaRequirements.enroll:[]}async verify(e){const t=this.contextManager.get(e.mfaToken);if(!t)throw new _u("mfa_context_not_found","MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");const n=function(e){return "otp"in e&&e.otp?It:"oobCode"in e&&e.oobCode?Ot:"recoveryCode"in e&&e.recoveryCode?jt:void 0}(e);if(!n)throw new _u("invalid_request","Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.");const o=t.scope,i=t.audience;try{const t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:o,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 _u)throw new _u(e.error,e.error_description);throw e}}}class Pu extends Error{constructor(e,t,n){super(t),this.name="PasskeyError",this.code=e,this.cause=n,Object.setPrototypeOf(this,Pu.prototype);}}var Eu,Cu;class Au{constructor(e,t){Eu.set(this,void 0),Cu.set(this,void 0),n(this,Eu,e,"f"),n(this,Cu,t,"f");}async signup(n){if(!window.PublicKeyCredential)throw new Pu("passkey_not_supported","WebAuthn is not supported in this browser.");const o=n.scope,i=n.audience,r=e(n,["scope","audience"]),s=await t(this,Eu,"f").register(r),a=Iu(s.authnParamsPublicKey),c=await navigator.credentials.create({publicKey:a});if(!c)throw new Pu("passkey_cancelled","Passkey creation was cancelled or no credential was returned.");const u=ju(c);return t(this,Cu,"f")._requestTokenForPasskey({authSession:s.authSession,credential:u,realm:r.realm,organization:r.organization,scope:o,audience:i})}async login(n){if(!window.PublicKeyCredential)throw new Pu("passkey_not_supported","WebAuthn is not supported in this browser.");const o=n||{},i=o.scope,r=o.audience,s=e(o,["scope","audience"]),a=await t(this,Eu,"f").challenge(Object.keys(s).length>0?s:void 0),c=Ou(a.authnParamsPublicKey),u=await navigator.credentials.get({publicKey:c});if(!u)throw new Pu("passkey_cancelled","Passkey authentication was cancelled or no credential was returned.");const l=Wu(u);return t(this,Cu,"f")._requestTokenForPasskey({authSession:a.authSession,credential:l,realm:s.realm,organization:s.organization,scope:i,audience:r})}async getSignupChallenge(e){if(!window.PublicKeyCredential)throw new Pu("passkey_not_supported","WebAuthn is not supported in this browser.");const n=await t(this,Eu,"f").register(e);return {authSession:n.authSession,publicKey:Iu(n.authnParamsPublicKey)}}async getLoginChallenge(e){if(!window.PublicKeyCredential)throw new Pu("passkey_not_supported","WebAuthn is not supported in this browser.");const n=await t(this,Eu,"f").challenge(e);return {authSession:n.authSession,publicKey:Ou(n.authnParamsPublicKey)}}async getTokenWithPasskey(e){if(!window.PublicKeyCredential)throw new Pu("passkey_not_supported","WebAuthn is not supported in this browser.");const n=e.authSession,o=e.credential,i=e.realm,r=e.organization,s=e.scope,a=e.audience,c=o.response;let u;if(c instanceof AuthenticatorAttestationResponse)u=ju(o);else {if(!(c instanceof AuthenticatorAssertionResponse))throw new Pu("passkey_invalid_credential","The provided credential is not a valid attestation or assertion response.");u=Wu(o);}return t(this,Cu,"f")._requestTokenForPasskey({authSession:n,credential:u,realm:i,organization:r,scope:s,audience:a})}}function Ru(e){const t=new Uint8Array(e),n=Array.from(t,e=>String.fromCharCode(e)).join("");return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function xu(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),o=atob(n),i=new Uint8Array(o.length);for(let e=0;e<o.length;e++)i[e]=o.charCodeAt(e);return i.buffer}function Iu(e){return Object.assign(Object.assign({},e),{challenge:xu(e.challenge),user:Object.assign(Object.assign({},e.user),{id:xu(e.user.id)}),pubKeyCredParams:e.pubKeyCredParams,authenticatorSelection:e.authenticatorSelection})}function Ou(e){return Object.assign(Object.assign({},e),{challenge:xu(e.challenge)})}function ju(e){var t;const n=e.response;return {id:e.id,rawId:Ru(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{clientDataJSON:Ru(n.clientDataJSON),attestationObject:Ru(n.attestationObject)},clientExtensionResults:e.getClientExtensionResults()}}function Wu(e){var t;const n=e.response;return {id:e.id,rawId:Ru(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{clientDataJSON:Ru(n.clientDataJSON),authenticatorData:Ru(n.authenticatorData),signature:Ru(n.signature),userHandle:n.userHandle?Ru(n.userHandle):void 0},clientExtensionResults:e.getClientExtensionResults()}}Eu=new WeakMap,Cu=new WeakMap;function Nu(e){return {get(){try{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null}catch(e){return null}},set(t){try{window.localStorage.setItem(e,JSON.stringify(t));}catch(e){}},remove(){try{window.localStorage.removeItem(e);}catch(e){}}}}function Ku(){let e=null;return {get:()=>e,set:t=>{e=t;},remove:()=>{e=null;}}}class Mu{constructor(e,t){this.slots=new Map,this.baseKey="".concat("@@auth0spajs@@","::").concat(e,"::anonymous"),this.useLocalStorage="localStorage"===t&&"undefined"!=typeof window&&!!window.localStorage,this.sessionKey="".concat(this.baseKey,"::").concat("session"),this.sessionStore=this.useLocalStorage?Nu(this.sessionKey):Ku();}getStore(e,t){const n="".concat(this.baseKey,"::").concat(JSON.stringify([null!=e?e:"",null!=t?t:""]));return this.slots.has(n)||this.slots.set(n,this.useLocalStorage?Nu(n):Ku()),this.slots.get(n)}getSessionToken(){return this.sessionStore.get()}setSessionToken(e){this.sessionStore.set(e);}removeAll(){if(this.sessionStore.remove(),this.slots.forEach(e=>e.remove()),this.slots.clear(),this.useLocalStorage)try{const e=this.baseKey+"::",t=[];for(let n=0;n<window.localStorage.length;n++){const o=window.localStorage.key(n);(null==o?void 0:o.startsWith(e))&&t.push(o);}t.forEach(e=>window.localStorage.removeItem(e));}catch(e){}}}class Uu{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"localStorage",o=arguments.length>3?arguments[3]:void 0;this.authJsClient=e,this.clientId=t,this.cache=new Mu(t,n),this.lockManager=null!=o?o:pe();}async createSession(e){const t=await this.authJsClient.createSession(e);return this.cache.setSessionToken(Object.assign({sessionToken:t.sessionToken},void 0!==t.sessionTokenExpiresAt&&{sessionTokenExpiresAt:t.sessionTokenExpiresAt})),this.cache.getStore(null==e?void 0:e.audience,null==e?void 0:e.scope).set(Object.assign({accessToken:t.accessToken,expiresAt:t.expiresAt},void 0!==t.scope&&{scope:t.scope})),t}async getTokenSilently(e){const t=this.cache.getStore(null==e?void 0:e.audience,null==e?void 0:e.scope),n=t.get();return n&&n.expiresAt-60>Date.now()/1e3?n:this.lockManager.runWithLock("anonymous::".concat(this.clientId),5e3,async()=>{var n;const o=t.get();if(o&&o.expiresAt-60>Date.now()/1e3)return o;const i=null===(n=this.cache.getSessionToken())||void 0===n?void 0:n.sessionToken,r=await this.authJsClient.getAccessToken(Object.assign(Object.assign({},e),{sessionToken:i}));return this.cache.getStore(null==e?void 0:e.audience,null==e?void 0:e.scope).set(Object.assign({accessToken:r.accessToken,expiresAt:r.expiresAt},void 0!==r.scope&&{scope:r.scope})),!r.sessionReplaced&&this.cache.getSessionToken()||this.cache.setSessionToken(Object.assign({sessionToken:r.sessionToken},void 0!==r.sessionTokenExpiresAt&&{sessionTokenExpiresAt:r.sessionTokenExpiresAt})),Object.assign({accessToken:r.accessToken,expiresAt:r.expiresAt},void 0!==r.scope&&{scope:r.scope})})}async logout(){await this.authJsClient.logout(),this.cache.removeAll();}hasSession(){var e;return !!(null===(e=this.cache.getSessionToken())||void 0===e?void 0:e.sessionToken)}getClaims(){return null}}class Lu{resolveOnlineAccess(e){if("online"!==e.refreshTokenMode)return !1;if(!0!==e.useRefreshTokens)throw new A('`refreshTokenMode: "online"` requires the refresh-token grant.',"Set `useRefreshTokens: true`.");if(!0!==e.useDpop)throw new A('`refreshTokenMode: "online"` requires DPoP, which is missing or disabled.',"Set `useDpop: true` (DPoP is mandatory for online access).");return !0}warnEnterpriseConnectConfig(e){var t,n;if(!0!==e.enterpriseConnect)return;const o=null===(t=e.authorizationParams)||void 0===t?void 0:t.scope;(!0===e.useRefreshTokens||"string"==typeof o&&o.includes("offline_access"))&&console.warn("Enterprise Connect issues no refresh token; `useRefreshTokens` and `offline_access` in `scope` have no effect."),(null===(n=e.authorizationParams)||void 0===n?void 0:n.organization)&&console.warn("Enterprise Connect resolves the organization from the email domain (Home Realm Discovery); a static `organization` breaks multi-customer setups.");}constructor(e){let t,n;if(this.userCache=(new He).enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0,refreshTokenMode:"offline",anonymousSessionsCacheMode:"localStorage"},this.onlineAccess=this.resolveOnlineAccess(e),this.warnEnterpriseConnectConfig(e),this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),"undefined"!=typeof window&&(()=>{if(!z())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===z().subtle)throw new Error("\n 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.\n ")})(),this.lockManager=pe(),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||_,!bt(t))throw new Error('Invalid cache location "'.concat(t,'"'));n=bt(t)();}var o;this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:b,this.cookieStorage=!1===e.legacySameSiteCookie?it:st,this.orgHintCookieName=(o=this.options.clientId,"auth0.".concat(o,".organization_hint")),this.isAuthenticatedCookieName=(e=>"auth0.".concat(e,".is.authenticated"))(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;const i=e.useCookiesForTransactions?this.cookieStorage:at;let r="";var s;this.onlineAccess?r=S:this.options.useRefreshTokens&&(r="offline_access"),this.scope=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];if("object"!=typeof e)return {[E]:Ue(t,e,...o)};let r={[E]:Ue(t,...o)};return Object.keys(e).forEach(n=>{const i=e[n];r[n]=Ue(t,i,...o);}),r}(this.options.authorizationParams.scope,"openid",r),this.transactionManager=new Ve(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||P,this.cacheManager=new Fe(n,n.allKeys?void 0:new wt(n,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new Pt(this.options.clientId):void 0,this.domainUrl=(s=this.options.domain,/^https?:\/\//.test(s)?s:"https://".concat(s)),this.tokenIssuer=((e,t)=>e?e.startsWith("https://")?e:"https://".concat(e,"/"):"".concat(t,"/"))(this.options.issuer,this.domainUrl);const a="".concat(this.domainUrl,"/me/"),c=this.createFetcher(Object.assign(Object.assign({},this.options.useDpop&&{dpopNonceId:"__auth0_my_account_api__"}),{getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" "),audience:a},detailedResponse:!0})}}));this.myAccount=new At(c,a),this.authJsClient=new ou({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new Tu(this.authJsClient.mfa,this),this.anonymous=new Uu(this.authJsClient.anonymous,this.options.clientId,this.options.anonymousSessionsCacheMode,this.lockManager),this.passkey=new Au(this.authJsClient.passkey,this),"undefined"!=typeof window&&window.Worker&&this.options.useRefreshTokens&&t===_&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new yt,this.worker.postMessage({type:"init",allowedBaseUrl:this.domainUrl}));}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){const t=this.options.auth0Client||T,n=H(t,!0),o=encodeURIComponent(btoa(JSON.stringify(n)));return "".concat(this.domainUrl).concat(e,"&auth0Client=").concat(o)}_authorizeUrl(e){return this._url("/authorize?".concat(F(e)))}async _verifyIdToken(e,t,n){const o=await this.nowProvider();return qe({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,"string"!=typeof i?i:parseInt(i,10)||void 0),now:o});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{const t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState({},"",t.toString()));}catch(e){}}_applySessionTransferToken(e){const t=this.options.sessionTransferTokenQueryParamName;if(!t||e.session_transfer_token)return e;const n=this._extractSessionTransferToken(t);return n?(this._clearSessionTransferTokenFromUrl(t),Object.assign(Object.assign({},e),{session_transfer_token:n})):e}async _prepareAuthorizeUrl(e,t,n){var o;const i=D(J()),r=D(J()),s=J(),a=await V(s),c=G(a),u=await(null===(o=this.dpop)||void 0===o?void 0:o.calculateThumbprint()),l=((e,t,n,o,i,r,s,a,c)=>Object.assign(Object.assign(Object.assign({client_id:e.clientId},e.authorizationParams),n),{scope:Le(t,n.scope,n.audience),response_type:"code",response_mode:a||"query",state:o,nonce:i,redirect_uri:s||e.authorizationParams.redirect_uri,code_challenge:r,code_challenge_method:"S256",dpop_jkt:c}))(this.options,this.scope,e,i,r,c,e.redirect_uri||this.options.authorizationParams.redirect_uri||n,null==t?void 0:t.response_mode,u),d=this._authorizeUrl(l);return {nonce:r,code_verifier:s,scope:l.scope,audience:l.audience||E,redirect_uri:l.redirect_uri,state:i,url:d}}async loginWithPopup(e,t){var n;if(e=e||{},!(t=t||{}).popup&&(t.popup=(e=>{const t=window.screenX+(window.innerWidth-400)/2,n=window.screenY+(window.innerHeight-600)/2;return window.open(e,"auth0:authorize:popup","left=".concat(t,",top=").concat(n,",width=").concat(400,",height=").concat(600,",resizable,scrollbars=yes,status=1"))})(""),!t.popup))throw new W;const o=this._applySessionTransferToken(e.authorizationParams||{}),i=await this._prepareAuthorizeUrl(o,{response_mode:"web_message"},window.location.origin);t.popup.location.href=i.url;const r=await((e,t)=>new Promise((n,o)=>{let i;const r=setInterval(()=>{e.popup&&e.popup.closed&&(clearInterval(r),clearTimeout(s),window.removeEventListener("message",i,!1),o(new j(e.popup)));},1e3),s=setTimeout(()=>{clearInterval(r),o(new O(e.popup)),window.removeEventListener("message",i,!1);},1e3*(e.timeoutInSeconds||60));i=function(a){if(a.origin===t&&a.data&&"authorization_response"===a.data.type){if(clearTimeout(s),clearInterval(r),window.removeEventListener("message",i,!1),!1!==e.closePopup&&e.popup.close(),a.data.response.error)return o(C.fromPayload(a.data.response));n(a.data.response);}},window.addEventListener("message",i);}))(Object.assign(Object.assign({},t),{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(i.url).origin);if(i.state!==r.state)throw new C("state_mismatch","Invalid state");const s=(null===(n=e.authorizationParams)||void 0===n?void 0:n.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:i.audience,scope:i.scope,code_verifier:i.code_verifier,grant_type:"authorization_code",code:r.code,redirect_uri:i.redirect_uri},{nonceIn:i.nonce,organization:s});}async getUser(){var e;if(await this._isSessionCeilingReached())return;const t=await this._getIdTokenFromCache();return null===(e=null==t?void 0:t.decodedToken)||void 0===e?void 0:e.user}async getIdTokenClaims(){var e;if(await this._isSessionCeilingReached())return;const t=await this._getIdTokenFromCache();return null===(e=null==t?void 0:t.decodedToken)||void 0===e?void 0:e.claims}async loginWithRedirect(){var t;const n=_t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),o=n.openUrl,i=n.fragment,r=n.appState,s=e(n,["openUrl","fragment","appState"]),a=(null===(t=s.authorizationParams)||void 0===t?void 0:t.organization)||this.options.authorizationParams.organization,c=this._applySessionTransferToken(s.authorizationParams||{}),u=await this._prepareAuthorizeUrl(c),l=u.url,d=e(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},d),{appState:r,response_type:exports.ResponseType.Code}),a&&{organization:a}));const h=i?"".concat(l,"#").concat(i):l;o?await o(h):window.location.assign(h);}async handleRedirectCallback(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location.href).split("?").slice(1);if(0===e.length)throw new Error("There are no query params available for parsing.");const t=this.transactionManager.get();if(!t)throw new C("missing_transaction","Invalid state");this.transactionManager.remove();const n=(e=>{e.indexOf("#")>-1&&(e=e.substring(0,e.indexOf("#")));const 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===exports.ResponseType.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){const n=e.code,o=e.state,i=e.error,r=e.error_description;if(i)throw new R(i,r||i,o,t.appState);if(!t.code_verifier||t.state&&t.state!==o)throw new C("state_mismatch","Invalid state");const s=t.organization,a=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:a,organization:s}),{appState:t.appState,response_type:exports.ResponseType.Code}}async _handleConnectAccountRedirectCallback(e,t){const n=e.connect_code,o=e.state,i=e.error,r=e.error_description;if(i)throw new x(i,r||i,t.connection,o,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===o))throw new C("state_mismatch","Invalid state");const s=await this.myAccount.completeAccount({auth_session:t.auth_session,connect_code:n,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier});return Object.assign(Object.assign({},s),{appState:t.appState,response_type:exports.ResponseType.ConnectCode})}async _maybeCreateAnonymousSession(){if(this.options.createAnonymousSessionOnFailedSilentAuth){if(this.anonymous.hasSession())return;try{await this.anonymous.getTokenSilently();}catch(e){console.debug("[auth0-spa-js] Anonymous session creation failed",e);}}}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(gt))return void await this._maybeCreateAnonymousSession();this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(gt);}try{await this.getTokenSilently(e);}catch(e){e instanceof C&&"login_required"===e.error&&e.error_description!==k&&await this._maybeCreateAnonymousSession();}}async getTokenSilently(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,n;const o=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Le(this.scope,null===(t=e.authorizationParams)||void 0===t?void 0:t.scope,(null===(n=e.authorizationParams)||void 0===n?void 0:n.audience)||this.options.authorizationParams.audience)})}),i=await this._getTokenSilently(o);return e.detailedResponse?i:null==i?void 0:i.access_token}async _getTokenSilently(t){const n=t.cacheMode,o=e(t,["cacheMode"]);if(await this._isSessionCeilingReached())return;if("off"!==n){const e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||E,clientId:this.options.clientId,cacheMode:n});if(e)return e}if("cache-only"===n)return;const i=(r=this.options.clientId,s=o.authorizationParams.audience||"default","".concat("auth0.lock.getTokenSilently",".").concat(r,".").concat(s));var r,s;try{return await this.lockManager.runWithLock(i,5e3,async()=>{if("off"!==n){const e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||E,clientId:this.options.clientId});if(e)return e}const e=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(o):await this._getTokenFromIFrame(o),t=e.id_token,i=e.token_type,r=e.access_token,s=e.oauthTokenScope,a=e.expires_in;return Object.assign(Object.assign({id_token:t,token_type:i,access_token:r},s?{scope:s}:null),{expires_in:a})})}catch(e){if(this._isInteractiveError(e)&&"popup"===this.options.interactiveErrorHandler)return await this._handleInteractiveErrorWithPopup(o);throw e}}_isInteractiveError(e){return e instanceof N||e instanceof C&&this._isIframeMfaError(e)}_isIframeMfaError(e){return "login_required"===e.error&&e.error_description===k}async _handleInteractiveErrorWithPopup(e){try{await this.loginWithPopup({authorizationParams:e.authorizationParams});const t=await this._getEntryFromCache({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||E,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&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n,o;const i=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Le(this.scope,null===(n=e.authorizationParams)||void 0===n?void 0:n.scope,(null===(o=e.authorizationParams)||void 0===o?void 0:o.audience)||this.options.authorizationParams.audience)})});t=Object.assign(Object.assign({},v),t),await this.loginWithPopup(i,t);return (await this.cacheManager.get(new De({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||E,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return !!await this.getUser()}_buildLogoutUrl(t){null!==t.clientId?t.clientId=t.clientId||this.options.clientId:delete t.clientId;const n=t.logoutParams||{},o=n.federated,i=e(n,["federated"]),r=o?"&federated":"";return this._url("/v2/logout?".concat(F(Object.assign({clientId:t.clientId},i))))+r}async revokeRefreshToken(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.options.useRefreshTokens)return;const t=e.audience||this.options.authorizationParams.audience||E,n=await this.cacheManager.getRefreshTokensByAudience(t,this.options.clientId);await async function(e,t){let n=e.baseUrl,o=e.timeout,i=e.auth0Client,r=e.useFormData,s=e.refreshTokens,a=e.audience,c=e.client_id,u=e.onRefreshTokenRevoked;const l=o||b,d="refresh_token",h="".concat(n,"/oauth/revoke"),p={"Content-Type":r?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(H(i||T)))};if(t){const e={client_id:c,token_type_hint:d},n=r?F(e):JSON.stringify(e);try{return await je({type:"revoke",timeout:l,fetchUrl:h,fetchOptions:{method:"POST",body:n,headers:p},useFormData:r,auth:{audience:null!=a?a:E}},t)}catch(e){throw new C("revoke_error",e.message)}}for(const e of s){const t={client_id:c,token_type_hint:d,token:e},n=r?F(t):JSON.stringify(t),o=await We(h,{method:"POST",body:n,headers:p},l);if(!o.ok){let e,t;try{var f=JSON.parse(await o.text());e=f.error,t=f.error_description;}catch(e){}throw new C(e||"revoke_error",t||"HTTP error ".concat(o.status))}await(null==u?void 0:u(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),this.onlineAccess&&await this._clearLocalSession();}async logout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var n;this.options.enterpriseConnect&&!0!==(null===(n=t.logoutParams)||void 0===n?void 0:n.federated)&&console.warn("Enterprise Connect logout without `federated: true` leaves the enterprise IdP session alive; the next login may silently reuse the previous user.");const o=_t(t),i=o.openUrl,r=e(o,["openUrl"]);await this._clearLocalSession(t.clientId);const s=this._buildLogoutUrl(r);i?await i(s):!1!==i&&window.location.assign(s);}async _getTokenFromIFrame(e){const t=(n=this.options.clientId,"".concat("auth0.lock.getTokenFromIFrame",".").concat(n));var n;try{return await this.lockManager.runWithLock(t,5e3,async()=>{const t=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!t.organization&&(t.organization=n);const o=await this._prepareAuthorizeUrl(t,{response_mode:"web_message"},window.location.origin),i=o.url,r=o.state,s=o.nonce,a=o.code_verifier,c=o.redirect_uri,u=o.scope,l=o.audience;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.");const d=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds;let h;try{h=new URL(this.domainUrl).origin;}catch(e){h=this.domainUrl;}const p=await function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60;return new Promise((o,i)=>{const r=window.document.createElement("iframe");r.setAttribute("width","0"),r.setAttribute("height","0"),r.style.display="none";const s=()=>{window.document.body.contains(r)&&(window.document.body.removeChild(r),window.removeEventListener("message",a,!1));};let a;const c=setTimeout(()=>{i(new I),s();},1e3*n);a=function(e){if(e.origin!=t)return;if(!e.data||"authorization_response"!==e.data.type)return;const n=e.source;n&&n.close(),e.data.response.error?i(C.fromPayload(e.data.response)):o(e.data.response),clearTimeout(c),window.removeEventListener("message",a,!1),setTimeout(s,2e3);},window.addEventListener("message",a,!1),window.document.body.appendChild(r),r.setAttribute("src",e);})}(i,h,d);if(r!==p.state)throw new C("state_mismatch","Invalid state");const f=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:a,code:p.code,grant_type:"authorization_code",redirect_uri:c,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:s,organization:t.organization});return Object.assign(Object.assign({},f),{scope:u,oauthTokenScope:f.scope,audience:l})})}catch(e){if("login_required"===e.error){e instanceof C&&this._isIframeMfaError(e)&&"popup"===this.options.interactiveErrorHandler||this.logout({openUrl:!1});}throw e}}async _getTokenUsingRefreshToken(e){const t=await this.cacheManager.get(new De({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||E,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 K(e.authorizationParams.audience||E,e.authorizationParams.scope)}const n=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,o="number"==typeof e.timeoutInSeconds?1e3*e.timeoutInSeconds:null,i=((e,t,n,o)=>{var i;if(e&&n&&o){if(t.audience!==n)return t.scope;const e=o.split(" "),r=(null===(i=t.scope)||void 0===i?void 0:i.split(" "))||[],s=r.every(t=>e.includes(t));return e.length>=r.length&&s?o:t.scope}return t.scope})(this.options.useMrrt,e.authorizationParams,null==t?void 0:t.audience,null==t?void 0:t.scope);try{const u=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:t&&t.refresh_token,redirect_uri:n}),o&&{timeout:o}),{scopesToRequest:i});if(await this._propagateRotatedRefreshToken(null==t?void 0:t.refresh_token,u.refresh_token),this.options.useMrrt){if(r=null==t?void 0:t.audience,s=null==t?void 0:t.scope,a=e.authorizationParams.audience,c=e.authorizationParams.scope,r!==a||!((e,t)=>{const n=(null==t?void 0:t.split(" "))||[];return ((null==e?void 0:e.split(" "))||[]).every(e=>n.includes(e))})(c,s)){const t=kt(i,u.scope,this.onlineAccess);if(t){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience,e.authorizationParams.scope),new M(e.authorizationParams.audience||"default",t)}}}return Object.assign(Object.assign({},u),{scope:e.authorizationParams.scope,oauthTokenScope:u.scope,audience:e.authorizationParams.audience||E})}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}var r,s,a,c;}async _propagateRotatedRefreshToken(e,t){!this.onlineAccess&&t&&e&&await this.cacheManager.updateEntry(e,t,this.options.clientId,this.options.useMrrt);}async _saveEntryInCache(t){const n=t.decodedToken.claims,o=n.session_expiry,i=n.iat;if(void 0!==o){if("number"!=typeof o)throw new C("invalid_token","Invalid session_expiry: value must be a number.");if(o>=1e10)throw new C("invalid_token","Invalid session_expiry: value appears to be in milliseconds; expected a Unix timestamp in seconds.");if(void 0===i||o<=i)throw new C("invalid_token","Invalid session_expiry: session ceiling is before or at the token issue time.")}const r=t.id_token,s=t.decodedToken,a=e(t,["id_token","decodedToken"]);this.userCache.set(Je,{id_token:r,decodedToken:s}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(a);}async _clearLocalSession(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.clientId;var t;null===e?await this.cacheManager.clear():await this.cacheManager.clear(e),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(Je);try{await(null===(t=this.dpop)||void 0===t?void 0:t.clear());}catch(e){}if(this.worker)try{await je({type:"clear"},this.worker);}catch(e){}}async _isSessionCeilingReached(){var e,t;const n=this.userCache.get(Je),o=null!=n?n:await this.cacheManager.getIdToken(new De({clientId:this.options.clientId})),i=null===(t=null===(e=null==o?void 0:o.decodedToken)||void 0===e?void 0:e.claims)||void 0===t?void 0:t.session_expiry;if(void 0===i)return !1;const r=await this.nowProvider();return Math.floor(r/1e3)>=i-30&&(await this._clearLocalSession(),!0)}async _getIdTokenFromCache(){const e=this.options.authorizationParams.audience||E,t=this.scope[e],n=await this.cacheManager.getIdToken(new De({clientId:this.options.clientId,audience:e,scope:t})),o=this.userCache.get(Je);return n&&n.id_token===(null==o?void 0:o.id_token)?o:(this.userCache.set(Je,n),n)}async _getEntryFromCache(e){let t=e.scope,n=e.audience,o=e.clientId,i=e.cacheMode;const r=await this.cacheManager.get(new De({scope:t,audience:n,clientId:o}),60,this.options.useMrrt,i);if(r&&r.access_token){const e=r.token_type,t=r.access_token,n=r.oauthTokenScope,o=r.expires_in,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:o})}}_storeMfaContext(e,t,n){e instanceof N&&this.mfa.setMFAAuthDetails(e.mfa_token,t,n,e.mfa_requirements);}async _requestToken(e,t){var n,o,i,r,s,a;const c=t||{},u=c.nonceIn,l=c.organization,d=c.scopesToRequest;try{const t=await Me(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,preserveRefreshToken:this.onlineAccess},e),{scope:d||e.scope}),this.worker);let c=await this._verifyIdToken(t.id_token,u,l);if("authorization_code"===e.grant_type){const e=await this._getIdTokenFromCache();(null===(o=null===(n=null==e?void 0:e.decodedToken)||void 0===n?void 0:n.claims)||void 0===o?void 0:o.sub)&&e.decodedToken.claims.sub!==c.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(Je));}if("authorization_code"!==e.grant_type){const e=await this._getIdTokenFromCache(),t=null===(r=null===(i=null==e?void 0:e.decodedToken)||void 0===i?void 0:i.claims)||void 0===r?void 0:r.session_expiry;void 0!==t&&(c=Object.assign(Object.assign({},c),{claims:Object.assign(Object.assign({},c.claims),{session_expiry:t})}));}return !t.refresh_token&&this.onlineAccess&&(t.refresh_token=null!==(s=e.refresh_token)&&void 0!==s?s:null===(a=await this.cacheManager.get(new De({scope:d||e.scope,audience:e.audience||E,clientId:this.options.clientId}),void 0,this.options.useMrrt))||void 0===a?void 0:a.refresh_token),await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},t),{decodedToken:c,scope:e.scope,audience:e.audience||E}),t.scope?{oauthTokenScope:t.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(l||c.claims.org_id),Object.assign(Object.assign({},t),{decodedToken:c})}catch(t){throw "authorization_code"!==e.grant_type&&this._storeMfaContext(t,d||e.scope,e.audience),t}}_buildTokenExchangeParams(e){return Object.assign(Object.assign(Object.assign(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}),e.actor_token&&{actor_token:e.actor_token}),e.actor_token_type&&{actor_token_type:e.actor_token_type}),{scope:Le(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 loginWithCustomTokenExchange(e){return this._requestToken(this._buildTokenExchangeParams(e))}async customTokenExchange(e){const t=this._buildTokenExchangeParams(e);try{const n=await Me(Object.assign(Object.assign({},t),{baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,dpop:this.dpop}),this.worker,!0);return n.id_token&&await this._verifyIdToken(n.id_token,void 0,e.organization),n}catch(e){throw this._storeMfaContext(e,t.scope,t.audience),e}}async exchangeToken(e){return this.loginWithCustomTokenExchange(e)}_assertDpop(e){if(!e)throw new 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&&void 0!==arguments[0]?arguments[0]:{};return new Ct(e,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" "),audience:null==e?void 0:e.audience},detailedResponse:!0})},getDpopNonce:()=>this.getDpopNonce(e.dpopNonceId),setDpopNonce:t=>this.setDpopNonce(t,e.dpopNonceId),generateDpopProof:e=>this.generateDpopProof(e)})}async connectAccountWithRedirect(e){const t=e.openUrl,n=e.appState,o=e.connection,i=e.scopes,r=e.authorization_params,s=e.redirectUri,a=void 0===s?this.options.authorizationParams.redirect_uri||window.location.origin:s;if(!o)throw new Error("connection is required");const c=D(J()),u=J(),l=await V(u),d=G(l),h=await this.myAccount.connectAccount({connection:o,scopes:i,redirect_uri:a,state:c,code_challenge:d,code_challenge_method:"S256",authorization_params:r}),p=h.connect_uri,f=h.connect_params,m=h.auth_session;this.transactionManager.create({state:c,code_verifier:u,auth_session:m,redirect_uri:a,appState:n,connection:o,response_type:exports.ResponseType.ConnectCode});const y=new URL(p);y.searchParams.set("ticket",f.ticket),t?await t(y.toString()):window.location.assign(y);}async _requestTokenForPasskey(e){const t=e.audience||this.options.authorizationParams.audience,n=e.organization||this.options.authorizationParams.organization;return this._requestToken(Object.assign(Object.assign(Object.assign({grant_type:"urn:okta:params:oauth:grant-type:webauthn",auth_session:e.authSession,authn_response:e.credential},e.realm&&{realm:e.realm}),n&&{organization:n}),{scope:Le(this.scope,e.scope,t),audience:t}))}async _requestTokenForMfa(t,n){const o=t.mfaToken,i=e(t,["mfaToken"]),r=await this.cacheManager.get(new De({scope:i.scope,audience:i.audience||E,clientId:this.options.clientId}),void 0,this.options.useMrrt),s=await this._requestToken(Object.assign(Object.assign({},i),{mfa_token:o}),n);return await this._propagateRotatedRefreshToken(null==r?void 0:r.refresh_token,s.refresh_token),s}}function zu(e,t,n){var o;return async function(e,t,n){const o=t.toLowerCase(),i=e.replace(/^https?:\/\//,""),r="".concat(i,"|").concat(o),s=yu.get(r);if(void 0!==s)return s;try{var a;const e=new URL("https://".concat(i,"/.well-known/webfinger"));e.searchParams.set("resource","urn:auth0:discovery:domain:".concat(o)),e.searchParams.set("rel","http://openid.net/specs/connect/1.0/issuer");let t=null!==(a=null==n?void 0:n.customFetch)&&void 0!==a?a:globalThis.fetch;null!=n&&n.telemetry&&!1!==n.telemetry.enabled&&(t=rc(t,n.telemetry));const s=await t(e.toString());return s.ok?(yu.set(r,!0),!0):404===s.status?(yu.set(r,!1,15e3),!1):429===s.status&&(console.warn("[Auth0] isFederatedDomain: rate limit hit (429)"),!1)}catch(e){return !1}}(e.replace(/^https?:\/\//i,"").toLowerCase(),t.toLowerCase(),Object.assign(Object.assign({},n),{telemetry:null!==(o=null==n?void 0:n.telemetry)&&void 0!==o?o:T}))}
115
115
 
116
116
  /**
117
117
  * The initial auth state.
@@ -149,6 +149,12 @@
149
149
  deleteAuthenticationMethod: stub,
150
150
  enrollmentChallenge: stub,
151
151
  enrollmentVerify: stub,
152
+ }, anonymous: {
153
+ createSession: stub,
154
+ getTokenSilently: stub,
155
+ logout: stub,
156
+ hasSession: stub,
157
+ getClaims: stub,
152
158
  } });
153
159
  /**
154
160
  * The Auth0 Context
@@ -258,7 +264,7 @@
258
264
  deprecateRedirectUri(opts);
259
265
  return __assign(__assign({}, opts), { auth0Client: {
260
266
  name: 'auth0-react',
261
- version: '2.25.0',
267
+ version: '2.27.0',
262
268
  } });
263
269
  };
264
270
  /**
@@ -308,7 +314,7 @@
308
314
  'configuration options. Remove `domain`, `clientId`, and any other Auth0Client configuration ' +
309
315
  'props when using the `client` prop.');
310
316
  }
311
- var client = React.useState(function () { return providedClient !== null && providedClient !== void 0 ? providedClient : new wu(toAuth0ClientOptions(clientOpts)); })[0];
317
+ var client = React.useState(function () { return providedClient !== null && providedClient !== void 0 ? providedClient : new Lu(toAuth0ClientOptions(clientOpts)); })[0];
312
318
  var _d = React.useReducer((reducer), initialAuthState), state = _d[0], dispatch = _d[1];
313
319
  // In state so the init retry below can swap in a fresh, non-rejected promise.
314
320
  // Without that swap the first rejection would re-throw on every later render,
@@ -623,6 +629,7 @@
623
629
  var getConfiguration = React.useCallback(function () { return client.getConfiguration(); }, [client]);
624
630
  var mfa = React.useMemo(function () { return client.mfa; }, [client]);
625
631
  var myAccount = React.useMemo(function () { return client.myAccount; }, [client]);
632
+ var anonymous = React.useMemo(function () { return client.anonymous; }, [client]);
626
633
  var passkeySignup = React.useCallback(function (options) { return __awaiter(void 0, void 0, void 0, function () {
627
634
  var tokenResponse, error_7, _a;
628
635
  var _b;
@@ -681,7 +688,7 @@
681
688
  }); }, [client]);
682
689
  var passkey = React.useMemo(function () { return ({ signup: passkeySignup, login: passkeyLogin }); }, [passkeySignup, passkeyLogin]);
683
690
  var contextValue = React.useMemo(function () {
684
- return __assign(__assign({}, state), { getAccessTokenSilently: getAccessTokenSilently, getAccessTokenWithPopup: getAccessTokenWithPopup, getIdTokenClaims: getIdTokenClaims, loginWithCustomTokenExchange: loginWithCustomTokenExchange, customTokenExchange: customTokenExchange, exchangeToken: exchangeToken, loginWithRedirect: loginWithRedirect, loginWithPopup: loginWithPopup, connectAccountWithRedirect: connectAccountWithRedirect, logout: logout, revokeRefreshToken: revokeRefreshToken, handleRedirectCallback: handleRedirectCallback, getDpopNonce: getDpopNonce, setDpopNonce: setDpopNonce, generateDpopProof: generateDpopProof, createFetcher: createFetcher, getConfiguration: getConfiguration, mfa: mfa, passkey: passkey, myAccount: myAccount, _initPromise: initDeferred.promise });
691
+ return __assign(__assign({}, state), { getAccessTokenSilently: getAccessTokenSilently, getAccessTokenWithPopup: getAccessTokenWithPopup, getIdTokenClaims: getIdTokenClaims, loginWithCustomTokenExchange: loginWithCustomTokenExchange, customTokenExchange: customTokenExchange, exchangeToken: exchangeToken, loginWithRedirect: loginWithRedirect, loginWithPopup: loginWithPopup, connectAccountWithRedirect: connectAccountWithRedirect, logout: logout, revokeRefreshToken: revokeRefreshToken, handleRedirectCallback: handleRedirectCallback, getDpopNonce: getDpopNonce, setDpopNonce: setDpopNonce, generateDpopProof: generateDpopProof, createFetcher: createFetcher, getConfiguration: getConfiguration, mfa: mfa, passkey: passkey, myAccount: myAccount, anonymous: anonymous, _initPromise: initDeferred.promise });
685
692
  }, [
686
693
  state,
687
694
  getAccessTokenSilently,
@@ -704,6 +711,7 @@
704
711
  mfa,
705
712
  passkey,
706
713
  myAccount,
714
+ anonymous,
707
715
  initDeferred,
708
716
  ]);
709
717
  return React.createElement(context.Provider, { value: contextValue }, children);
@@ -782,6 +790,30 @@
782
790
  }, [ctx]);
783
791
  };
784
792
 
793
+ /**
794
+ * ```js
795
+ * const { isFederatedDomain, loginWithSSO } = useEnterpriseConnect();
796
+ * ```
797
+ *
798
+ * Convenience hook for the Enterprise Connect flow. `isFederatedDomain` reads
799
+ * the Auth0 domain from the `Auth0Provider` configuration, so callers pass
800
+ * only the email domain. `loginWithSSO` is sugar over `loginWithRedirect`
801
+ * that sets `login_hint` to the provided email.
802
+ */
803
+ var useEnterpriseConnect = function (context) {
804
+ if (context === void 0) { context = Auth0Context; }
805
+ var _a = React.useContext(context), getConfiguration = _a.getConfiguration, loginWithRedirect = _a.loginWithRedirect;
806
+ var isFederatedDomain = React.useCallback(
807
+ // domain is read at call time, not when the callback is memoized
808
+ function (emailDomain, options) {
809
+ return zu(getConfiguration().domain, emailDomain, options);
810
+ }, [getConfiguration]);
811
+ var loginWithSSO = React.useCallback(function (email, options) {
812
+ return loginWithRedirect(__assign(__assign({}, options), { authorizationParams: __assign(__assign({}, options === null || options === void 0 ? void 0 : options.authorizationParams), { login_hint: email }) }));
813
+ }, [loginWithRedirect]);
814
+ return { isFederatedDomain: isFederatedDomain, loginWithSSO: loginWithSSO };
815
+ };
816
+
785
817
  /**
786
818
  * ```jsx
787
819
  * class MyComponent extends Component {
@@ -872,39 +904,41 @@
872
904
  };
873
905
  };
874
906
 
907
+ exports.AnonymousSessionError = Lc;
875
908
  exports.Auth0Context = Auth0Context;
876
909
  exports.Auth0Provider = Auth0Provider;
877
- exports.AuthenticationError = C;
910
+ exports.AuthenticationError = R;
878
911
  exports.ConnectError = x;
879
- exports.GenericError = E;
880
- exports.InMemoryCache = De;
881
- exports.InvalidConfigurationError = R;
882
- exports.LocalStorageCache = Je;
883
- exports.MfaChallengeError = nu;
884
- exports.MfaEnrollmentError = tu;
885
- exports.MfaEnrollmentFactorsError = iu;
886
- exports.MfaError = $c;
887
- exports.MfaListAuthenticatorsError = eu;
888
- exports.MfaRequiredError = W;
889
- exports.MfaVerifyError = ou;
890
- exports.MissingRefreshTokenError = N;
891
- exports.MissingScopesError = U;
912
+ exports.GenericError = C;
913
+ exports.InMemoryCache = He;
914
+ exports.InvalidConfigurationError = A;
915
+ exports.LocalStorageCache = Ze;
916
+ exports.MfaChallengeError = bu;
917
+ exports.MfaEnrollmentError = vu;
918
+ exports.MfaEnrollmentFactorsError = ku;
919
+ exports.MfaError = wu;
920
+ exports.MfaListAuthenticatorsError = gu;
921
+ exports.MfaRequiredError = N;
922
+ exports.MfaVerifyError = _u;
923
+ exports.MissingRefreshTokenError = K;
924
+ exports.MissingScopesError = M;
892
925
  exports.MyAccountApiError = Rt;
893
926
  exports.OAuthError = OAuthError;
894
- exports.PasskeyChallengeError = oc;
895
- exports.PasskeyError = au;
896
- exports.PasskeyGetTokenError = ic;
897
- exports.PasskeyRegisterError = nc;
898
- exports.PopupCancelledError = O;
899
- exports.PopupOpenError = j;
900
- exports.PopupTimeoutError = A;
901
- exports.RefreshTokenMode = st;
927
+ exports.PasskeyChallengeError = fc;
928
+ exports.PasskeyError = Pu;
929
+ exports.PasskeyGetTokenError = mc;
930
+ exports.PasskeyRegisterError = pc;
931
+ exports.PopupCancelledError = j;
932
+ exports.PopupOpenError = W;
933
+ exports.PopupTimeoutError = O;
934
+ exports.RefreshTokenMode = ct;
902
935
  exports.TimeoutError = I;
903
- exports.UseDpopNonceError = K;
904
- exports.User = ct;
936
+ exports.UseDpopNonceError = U;
937
+ exports.User = lt;
905
938
  exports.initialContext = initialContext;
906
939
  exports.useAuth0 = useAuth0;
907
940
  exports.useAuth0Suspense = useAuth0Suspense;
941
+ exports.useEnterpriseConnect = useEnterpriseConnect;
908
942
  exports.withAuth0 = withAuth0;
909
943
  exports.withAuthenticationRequired = withAuthenticationRequired;
910
944