@lilaquadrat/chat 0.1.8 → 0.1.11

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.
@@ -0,0 +1 @@
1
+ var e={status:{connected:"Verbunden",disconnected:"Getrennt"},retry:"Wiederholen","new chat":"Neuer Chat",conversations:"Unterhaltungen","contact support":"Support kontaktieren",support:"Support",options:"Optionen",actions:"Aktionen",mute:"Stumm schalten",delete:"Löschen",leave:"Verlassen","leave now":"Möchten Sie diese Unterhaltung verlassen?","delete now":"Diese Unterhaltung löschen? Sie wird nur für Sie entfernt – die anderen Teilnehmer behalten sie.","select contacts":"Kontakte auswählen","conversation options":"Konversationsoptionen","save edits":"Änderungen speichern","cancel edits":"Bearbeiten abbrechen",abandon:"Verwerfen",close:"Schließen",rights:"Rechte",members:"Mitglieder","update members":"Mitglieder aktualisieren",read:"Lesen",write:"Schreiben",rename:"Umbenennen",save:"Speichern","conversation name":"Name der Unterhaltung","you left this conversation":"Sie haben diese Unterhaltung verlassen.",participants:"Teilnehmer","filter members":"Mitglieder filtern","filter contacts":"Kontakte filtern","member count":"{count} Mitglieder","created at":"Erstellt am","last activity":"Letzte Aktivität",messages:"{count} Nachrichten","no messages yet":"Noch keine Nachrichten",message:"Nachricht","abandon draft":"Entwurf verwerfen","chat already exists":"Chat existiert bereits","this is a draft":"Dies ist ein Entwurf","jump to chat":"Zum Chat wechseln",new:"Neu","group chat":"Gruppenchat","select participants":"Teilnehmer auswählen",writing:"{users} schreibt… | {users} schreiben…",accept:"Akzeptieren",decline:"Ablehnen","confirm action":"Aktion bestätigen",block:"Blockieren",unblock:"Freigeben",dismiss:"Ausblenden",errors:{unknown:"Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.",RATE_LIMIT_EXCEEDED:"Zu viele Nachrichten in kurzer Zeit. Bitte warten Sie einen Moment.",NOT_ALLOWED:"Dazu haben Sie keine Berechtigung.",ACTION_NOT_ALLOWED:"Ihre App-Version ist veraltet. Bitte laden Sie die Seite neu.",NOT_A_CONTACT:"Sie können nur mit Personen aus Ihrer Organisation chatten.",CONVERSATION_NOT_FOUND:"Diese Unterhaltung existiert nicht mehr.",CONVERSATION_ALREADY_EXISTS:"Diese Unterhaltung existiert bereits.",MIN_PARTICIPANTS:"Bitte wählen Sie mindestens einen Teilnehmer aus.",CONTACT_NOT_FOUND:"Dieser Kontakt wurde nicht gefunden.",CANNOT_BLOCK_SELF:"Sie können sich nicht selbst blockieren.",UNKNOWN_MESSAGE_TYPE:"Ihre App-Version ist veraltet. Bitte laden Sie die Seite neu.",INVALID_LAST_READ_ID:"Der Lesestand konnte nicht gespeichert werden.",INTERNAL_ERROR:"Auf dem Server ist ein Problem aufgetreten. Bitte versuchen Sie es erneut."},system:{renamed:'{user} hat "{from}" in "{to}" umbenannt',created:"{user} hat diese Unterhaltung erstellt",left:"{user} hat die Unterhaltung verlassen",blocked:"{user} hat {target} blockiert",unblocked:"{user} hat {target} entsperrt",participants:{addedAndRemoved:"{user} hat {added} hinzugefügt und {removed} entfernt",added:"{user} hat {added} hinzugefügt",removed:"{user} hat {removed} entfernt",updated:"{user} hat die Teilnehmer aktualisiert"}}};export{e as default};
@@ -0,0 +1 @@
1
+ import{t as o}from"./web-component-NO1YrOLk.js";export{o as default};
@@ -0,0 +1 @@
1
+ !function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const n of e)if("childList"===n.type)for(const e of n.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)}).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();var e="/settings/settings.json",t=["localhost","127.0.0.1","[::1]"];function n(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 r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function o(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 r(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function i(e,t){this.v=e,this.k=t}function a(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 s(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 c(e){return new i(e,0)}function u(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function l(e,t){return e.get(s(e,t))}function h(e,t,n){u(e,t),t.set(e,n)}function d(e,t,n){return e.set(s(e,t),n),n}function p(e,t){u(e,t),t.add(e)}function f(e,t,n){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);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 m(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 y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?m(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function w(e,t){if(null==e)return{};var n,o,r=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 i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function g(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,r,i,a,s=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(o=i.call(n)).done)&&(s.push(o.value),s.length!==t);c=!0);}catch(e){u=!0,r=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw r}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(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)?a(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 v(e){var t,n;function o(t,n){try{var a=e[t](n),s=a.value,c=s instanceof i;Promise.resolve(c?s.v:s).then(function(n){if(c){var i="return"===t&&s.k?t:"next";if(!s.k||n.done)return o(i,n);n=e[i](n).value}r(!!a.done,n)},function(e){o("throw",e)})}catch(e){r(2,e)}}function r(e,r){2===e?t.reject(r):t.resolve({value:r,done:e}),(t=t.next)?o(t.key,t.arg):n=null}this._invoke=function(e,r){return new Promise(function(i,a){var s={key:e,arg:r,resolve:i,reject:a,next:null};n?n=n.next=s:(t=n=s,o(e,r))})},"function"!=typeof e.return&&(this.return=void 0)}v.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},v.prototype.next=function(e){return this._invoke("next",e)},v.prototype.throw=function(e){return this._invoke("throw",e)},v.prototype.return=function(e){return this._invoke("return",e)};var b={timeoutInSeconds:60},k=1e4,_="memory",S="online_access",T={name:"auth0-spa-js",version:"2.24.0"},P=()=>Date.now(),E="default",A=class e extends Error{constructor(t,n){super(n),this.error=t,this.error_description=n,Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let n=t.error,o=t.error_description;return new e(n,o)}},I=class e extends A{constructor(t,n){super("invalid_configuration","".concat(t," ").concat(n)),this.suggestion=n,Object.setPrototypeOf(this,e.prototype)}},x=class e extends A{constructor(t,n,o){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;super(t,n),this.state=o,this.appState=r,Object.setPrototypeOf(this,e.prototype)}},R=class e extends A{constructor(t,n,o,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;super(t,n),this.connection=o,this.state=r,this.appState=i,Object.setPrototypeOf(this,e.prototype)}},O=class e extends A{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,e.prototype)}},C=class e extends O{constructor(t){super(),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},W=class e extends A{constructor(t){super("cancelled","Popup closed"),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},j=class e extends A{constructor(){super("popup_open","Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,e.prototype)}},K=class e extends A{constructor(t,n,o,r){super(t,n),this.mfa_token=o,this.mfa_requirements=r,Object.setPrototypeOf(this,e.prototype)}},U=class e extends A{constructor(t,n){super("missing_refresh_token","Missing Refresh Token (audience: '".concat(z(t,["default"]),"', scope: '").concat(z(n),"')")),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},L=class e extends A{constructor(t,n){super("missing_scopes","Missing requested scopes after refresh (audience: '".concat(z(t,["default"]),"', missing scope: '").concat(z(n),"')")),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},N=class e extends A{constructor(t){super("use_dpop_nonce","Server rejected DPoP proof: wrong nonce"),this.newDpopNonce=t,Object.setPrototypeOf(this,e.prototype)}};function z(e){return e&&!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).includes(e)?e:""}var M=()=>window.crypto,D=()=>{let e="";for(;e.length<43;){const t=M().getRandomValues(new Uint8Array(43-e.length));for(const n of t)e.length<43&&n<198&&(e+="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~."[n%66])}return e},J=e=>btoa(e),H=[{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 r=H.find(e=>e.key===o);return r&&r.type.includes(typeof e[o])&&(n[o]=e[o]),n},{})},F=e=>{var t=e.clientId,o=n(e,["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:t},o))).toString()},V=async e=>await M().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e)),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))))},Y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},q={},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 $=Y&&Y.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){e.done?r(e.value):new n(function(t){t(e.value)}).then(a,s)}c((o=o.apply(e,t||[])).next())})},ee=Y&&Y.__generator||function(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},te=Y;Object.defineProperty(q,"__esModule",{value:!0});var ne=B,oe="browser-tabs-lock-key",re={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 ie(e){return new Promise(function(t){return setTimeout(t,e)})}function ae(e){for(var t="",n=0;n<e;n++)t+="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"[Math.floor(61*Math.random())];return t}var se=q.default=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+ae(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,r,i,a,s,c,u;return ee(this,function(l){switch(l.label){case 0:o=Date.now()+ae(4),r=Date.now()+n,i=oe+"-"+t,a=void 0===this.storageHandler?re:this.storageHandler,l.label=1;case 1:return Date.now()<r?[4,ie(30)]:[3,8];case 2:return l.sent(),null!==a.getItemSync(i)?[3,5]:(s=this.id+"-"+t+"-"+o,[4,ie(Math.floor(25*Math.random()))]);case 3:return l.sent(),a.setItemSync(i,JSON.stringify({id:this.id,iat:o,timeoutKey:s,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,ie(30)];case 4:return l.sent(),null!==(c=a.getItemSync(i))&&(u=JSON.parse(c)).id===this.id&&u.iat===o?(this.acquiredIatSet.add(o),this.refreshLockWhileAcquired(i,o),[2,!0]):[3,7];case 5:return e.lockCorrector(void 0===this.storageHandler?re:this.storageHandler),[4,this.waitForSomethingToChange(r)];case 6:l.sent(),l.label=7;case 7:return o=Date.now()+ae(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,r;return ee(this,function(i){switch(i.label){case 0:return[4,ne.default().lock(t)];case 1:return i.sent(),this.acquiredIatSet.has(t)?(n=void 0===this.storageHandler?re:this.storageHandler,null===(o=n.getItemSync(e))?(ne.default().unlock(t),[2]):((r=JSON.parse(o)).timeRefreshed=Date.now(),n.setItemSync(e,JSON.stringify(r)),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,r=Date.now(),i=!1;function a(){if(i||(window.removeEventListener("storage",a),e.removeFromWaiting(a),clearTimeout(s),i=!0),!o){o=!0;var t=50-(Date.now()-r);t>0?setTimeout(n,t):n(null)}}window.addEventListener("storage",a),e.addToWaiting(a);var s=setTimeout(a,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,r,i;return ee(this,function(a){switch(a.label){case 0:return n=void 0===this.storageHandler?re:this.storageHandler,o=oe+"-"+t,null===(r=n.getItemSync(o))?[2]:(i=JSON.parse(r)).id!==this.id?[3,2]:[4,ne.default().lock(i.iat)];case 1:a.sent(),this.acquiredIatSet.delete(i.iat),n.removeItemSync(o),ne.default().unlock(i.iat),e.notifyWaiters(),a.label=2;case 2:return[2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,o=t,r=[],i=0;;){var a=o.keySync(i);if(null===a)break;r.push(a),i++}for(var s=!1,c=0;c<r.length;c++){var u=r[c];if(u.includes(oe)){var l=o.getItemSync(u);if(null!==l){var h=JSON.parse(l);(void 0===h.timeRefreshed&&h.timeAcquired<n||void 0!==h.timeRefreshed&&h.timeRefreshed<n)&&(o.removeItemSync(u),s=!0)}}}s&&e.notifyWaiters()},e.waiters=void 0,e}(),ce=class{async runWithLock(e,t,n){const o=new AbortController,r=setTimeout(()=>o.abort(),t);try{return await navigator.locks.request(e,{mode:"exclusive",signal:o.signal},async e=>{if(clearTimeout(r),!e)throw new Error("Lock not available");return await n()})}catch(e){if(clearTimeout(r),"AbortError"===(null==e?void 0:e.name))throw new O;throw e}}},ue=class{constructor(){this.activeLocks=new Set,this.lock=new se,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear()}}async runWithLock(e,t,n){let o=!1;for(let r=0;r<10&&!o;r++)o=await this.lock.acquireLock(e,t);if(!o)throw new O;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)}}};var le,he=null,de=new TextEncoder,pe=new TextDecoder;function fe(e){return"string"==typeof e?de.encode(e):pe.decode(e)}function me(e){if("number"!=typeof e.modulusLength||e.modulusLength<2048)throw new ge(`${e.name} modulusLength must be at least 2048 bits`)}if(Uint8Array.prototype.toBase64)le=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0}));else{const e=32768;le=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 ye(e){return le(e)}var we=class 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)}},ge=class 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 ve(e){switch(e.algorithm.name){case"RSA-PSS":return function(e){if("SHA-256"===e.algorithm.hash.name)return"PS256";throw new we("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"RSASSA-PKCS1-v1_5":return function(e){if("SHA-256"===e.algorithm.hash.name)return"RS256";throw new we("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"ECDSA":return function(e){if("P-256"===e.algorithm.namedCurve)return"ES256";throw new we("unsupported EcKeyAlgorithm namedCurve")}(e);case"Ed25519":return"Ed25519";default:throw new we("unsupported CryptoKey algorithm name")}}function be(e){return e instanceof CryptoKey}function ke(e){return be(e)&&"public"===e.type}async function _e(e,t,n,o,r,i){const a=null==e?void 0:e.privateKey,s=null==e?void 0:e.publicKey;if(!be(c=a)||"private"!==c.type)throw new TypeError('"keypair.privateKey" must be a private CryptoKey');var c;if(!ke(s))throw new TypeError('"keypair.publicKey" must be a public CryptoKey');if(!0!==s.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!==r&&"string"!=typeof r)throw new TypeError('"accessToken" must be a string or undefined');if(void 0!==i&&("object"!=typeof i||null===i||Array.isArray(i)))throw new TypeError('"additional" must be an object');return async function(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=`${ye(fe(JSON.stringify(e)))}.${ye(fe(JSON.stringify(t)))}`;return`${o}.${ye(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return{name:e.algorithm.name,hash:"SHA-256"};case"RSA-PSS":return 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 we}(n),n,fe(o)))}`}({alg:ve(a),typ:"dpop+jwt",jwk:await Se(s)},Object.assign(Object.assign({},i),{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:o,htu:t,ath:r?ye(await crypto.subtle.digest("SHA-256",fe(r))):void 0}),a)}async function Se(e){const{kty:t,e:n,n:o,x:r,y:i,crv:a}=await crypto.subtle.exportKey("jwk",e);return{kty:t,crv:a,e:n,n:o,x:r,y:i}}var Te="dpop-nonce",Pe=["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"];var Ee=(e,t)=>new Promise(function(n,o){const r=new MessageChannel;r.port1.onmessage=function(e){e.data.error?o(new Error(e.data.error)):n(e.data),r.port1.close()},t.postMessage(e,[r.port2])}),Ae=(e,t,n)=>{const o=new AbortController;let r;return t.signal=o.signal,Promise.race([fetch(e,t),new Promise((e,t)=>{r=setTimeout(()=>{o.abort(),t(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(r)})},Ie=async function(e,t,n,o,r,i){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:k;return r?(async(e,t,n,o,r,i,a,s,c,u)=>Ee({type:"refresh",auth:{audience:t,scope:n},timeout:r,fetchUrl:e,fetchOptions:o,useFormData:a,useMrrt:s,skipTokenStorage:c,preserveRefreshToken:u},i))(e,t,n,o,a,r,i,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 Ae(e,t,n);return{ok:o.ok,json:await o.json(),headers:(r=o.headers,[...r].reduce((e,t)=>{let n=g(t,2);return e[n[0]]=n[1],e},{}))};var r})(e,o,a)};async function xe(e,t,o,r,i,a,s,c,u,l,h,d){if(u){const t=await u.generateProof({url:e,method:i.method||"GET",nonce:await u.getNonce()});i.headers=Object.assign(Object.assign({},i.headers),{dpop:t})}let p,f=null;for(let S=0;S<3;S++)try{p=await Ie(e,o,r,i,a,s,t,c,h,d),f=null;break}catch(n){f=n}if(f)throw f;const m=p.json,y=m.error,w=m.error_description,g=n(m,["error","error_description"]),v=p,b=v.headers,k=v.ok;let _;if(u&&(_=b[Te],_&&await u.setNonce(_)),!k){const n=w||"HTTP error. Unable to fetch ".concat(e);if("mfa_required"===y)throw new K(y,n,g.mfa_token,g.mfa_requirements);if("missing_refresh_token"===y)throw new U(o,r);if("use_dpop_nonce"===y){if(!u||!_||l)throw new N(_);return xe(e,t,o,r,i,a,s,c,u,!0,h,d)}throw new A(y||"request_error",n)}return g}async function Re(e,t,o){var r=e.baseUrl,i=e.timeout,a=e.audience,s=e.scope,c=e.auth0Client,u=e.useFormData,l=e.useMrrt,h=e.dpop,d=e.preserveRefreshToken,p=n(e,["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&&a&&{audience:a}),w&&s&&{scope:s}),v=m||!u,b=v?JSON.stringify(g):F(g),k=(_=p.grant_type,Pe.includes(_));var _;return await xe("".concat(r,"/oauth/token"),i,a||E,s,{method:"POST",body:b,headers:{"Content-Type":v?"application/json":"application/x-www-form-urlencoded","Auth0-Client":btoa(JSON.stringify(Z(c||T)))}},t,u,l,k?h:void 0,void 0,o,d)}var Oe=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},Ce=(e,t,n)=>{let o;return n&&(o=e[n]),o||(o=e[E]),Oe(o,t)},We="@@auth0spajs@@",je="@@user@@",Ke=class e{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:We,n=arguments.length>2?arguments[2]:void 0;this.prefix=t,this.suffix=n,this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(t){const n=g(t.split("::"),4),o=n[0],r=n[1],i=n[2],a=n[3];return new e({clientId:r,scope:a,audience:i},o)}static fromCacheEntry(t){const n=t.scope,o=t.audience,r=t.client_id;return new e({scope:n,audience:o,clientId:r})}},Ue=class{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(We))}},Le=class{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)}}()}},Ne=class{constructor(e,t,n){this.cache=e,this.keyManifest=t,this.nowProvider=n||P}async setIdToken(e,t,n){var o;const r=this.getIdTokenCacheKey(e);await this.cache.set(r,{id_token:t,decodedToken:n}),await(null===(o=this.keyManifest)||void 0===o?void 0:o.add(r))}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 r;let i=await this.cache.get(e.toKey()),a=e;if(!i){const t=await this.getCacheKeys();if(!t)return;const r=this.matchExistingCacheKey(e,t);if(r&&(i=await this.cache.get(r),a=Ke.fromKey(r)),!i&&n&&"cache-only"!==o)return this.getEntryWithRefreshToken(e,t)}if(!i)return;const s=await this.nowProvider(),c=Math.floor(s/1e3);return i.expiresAt-t<c?i.body.refresh_token?this.modifiedCachedEntry(i,a):(await this.cache.remove(a.toKey()),void(await(null===(r=this.keyManifest)||void 0===r?void 0:r.remove(a.toKey())))):i.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 Ke({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 Ke({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 Ke({clientId:e},We,je).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{var n;const o=Ke.fromKey(t),r=new Set(o.scope&&o.scope.split(" ")),i=(null===(n=e.scope)||void 0===n?void 0:n.split(" "))||[],a=o.scope&&i.reduce((e,t)=>e&&r.has(t),!0);return o.prefix===We&&o.clientId===e.clientId&&o.audience===e.audience&&a})[0]}async getEntryWithRefreshToken(e,t){var n;for(const o of t){const t=Ke.fromKey(o);if(t.prefix===We&&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 r=new Set;for(const i of o){const o=Ke.fromKey(i);if(o.prefix===We&&o.clientId===t&&o.audience===e){const e=await this.cache.get(i);null!==(n=null==e?void 0:e.body)&&void 0!==n&&n.refresh_token&&r.add(e.body.refresh_token)}}return Array.from(r)}async updateEntry(e,t){var n;const o=await this.getCacheKeys();if(o)for(const r of o){const o=await this.cache.get(r);(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.refresh_token)===e&&(o.body.refresh_token=t,await this.cache.set(r,o))}}},ze=class{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})}},Me=e=>"number"==typeof e,De=["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"],Je=Y&&Y.__assign||function(){return Je=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Je.apply(this,arguments)};function He(e,t){if(!t)return"";var n="; "+e;return!0===t?n:n+"="+t}var Ze=function(e){return function(e){for(var t={},n=e?e.split("; "):[],o=/(%[\dA-F]{2})+/gi,r=0;r<n.length;r++){var i=n[r].split("="),a=i.slice(1).join("=");'"'===a.charAt(0)&&(a=a.slice(1,-1));try{t[i[0].replace(o,decodeURIComponent)]=a.replace(o,decodeURIComponent)}catch(e){}}return t}(document.cookie)[e]};function Fe(e,t,n){document.cookie=function(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 He("Expires",e.expires?e.expires.toUTCString():"")+He("Domain",e.domain)+He("Path",e.path)+He("Secure",e.secure)+He("SameSite",e.sameSite)}(n)}(e,t,Je({path:"/"},n))}var Ve,Xe,Ge=Fe,Ye=function(e,t){Fe(e,"",Je(Je({},t),{expires:-1}))},qe={get(e){const t=Ze(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&&n.daysUntilExpire&&(o.expires=n.daysUntilExpire),null!=n&&n.cookieDomain&&(o.domain=n.cookieDomain),Ge(e,JSON.stringify(t),o)},remove(e,t){let n={};null!=t&&t.cookieDomain&&(n.domain=t.cookieDomain),Ye(e,n)}},Be="_legacy_",Qe={get:e=>qe.get(e)||qe.get("".concat(Be).concat(e)),save(e,t,n){let o={};"https:"===window.location.protocol&&(o={secure:!0}),null!=n&&n.daysUntilExpire&&(o.expires=n.daysUntilExpire),null!=n&&n.cookieDomain&&(o.domain=n.cookieDomain),Ge("".concat(Be).concat(e),JSON.stringify(t),o),qe.save(e,t,n)},remove(e,t){let n={};null!=t&&t.cookieDomain&&(n.domain=t.cookieDomain),Ye(e,n),qe.remove(e,t),qe.remove("".concat(Be).concat(e),t)}},$e={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)}};!function(e){e.Code="code",e.ConnectCode="connect_code"}(Ve||(Ve={}));var et,tt=function(e){return Xe=Xe||function(e,t,n){var o=void 0===t?null:t,r=function(e,t){var n=atob(e);if(t){for(var o=new Uint8Array(n.length),r=0,i=n.length;r<i;++r)o[r]=n.charCodeAt(r);return String.fromCharCode.apply(null,new Uint16Array(o.buffer))}return n}(e,void 0!==n&&n),i=r.indexOf("\n",10)+1,a=r.substring(i)+(o?"//# sourceMappingURL="+o:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7ZnVuY3Rpb24gZShlLHQpeyhudWxsPT10fHx0PmUubGVuZ3RoKSYmKHQ9ZS5sZW5ndGgpO2Zvcih2YXIgcj0wLG89QXJyYXkodCk7cjx0O3IrKylvW3JdPWVbcl07cmV0dXJuIG99ZnVuY3Rpb24gdCh0LHIpe3JldHVybiBmdW5jdGlvbihlKXtpZihBcnJheS5pc0FycmF5KGUpKXJldHVybiBlfSh0KXx8ZnVuY3Rpb24oZSx0KXt2YXIgcj1udWxsPT1lP251bGw6InVuZGVmaW5lZCIhPXR5cGVvZiBTeW1ib2wmJmVbU3ltYm9sLml0ZXJhdG9yXXx8ZVsiQEBpdGVyYXRvciJdO2lmKG51bGwhPXIpe3ZhciBvLG4scyxpLGE9W10sYz0hMCxsPSExO3RyeXtpZihzPShyPXIuY2FsbChlKSkubmV4dCwwPT09dCl7aWYoT2JqZWN0KHIpIT09cilyZXR1cm47Yz0hMX1lbHNlIGZvcig7IShjPShvPXMuY2FsbChyKSkuZG9uZSkmJihhLnB1c2goby52YWx1ZSksYS5sZW5ndGghPT10KTtjPSEwKTt9Y2F0Y2goZSl7bD0hMCxuPWV9ZmluYWxseXt0cnl7aWYoIWMmJm51bGwhPXIucmV0dXJuJiYoaT1yLnJldHVybigpLE9iamVjdChpKSE9PWkpKXJldHVybn1maW5hbGx5e2lmKGwpdGhyb3cgbn19cmV0dXJuIGF9fSh0LHIpfHxmdW5jdGlvbih0LHIpe2lmKHQpe2lmKCJzdHJpbmciPT10eXBlb2YgdClyZXR1cm4gZSh0LHIpO3ZhciBvPXt9LnRvU3RyaW5nLmNhbGwodCkuc2xpY2UoOCwtMSk7cmV0dXJuIk9iamVjdCI9PT1vJiZ0LmNvbnN0cnVjdG9yJiYobz10LmNvbnN0cnVjdG9yLm5hbWUpLCJNYXAiPT09b3x8IlNldCI9PT1vP0FycmF5LmZyb20odCk6IkFyZ3VtZW50cyI9PT1vfHwvXig/OlVpfEkpbnQoPzo4fDE2fDMyKSg/OkNsYW1wZWQpP0FycmF5JC8udGVzdChvKT9lKHQscik6dm9pZCAwfX0odCxyKXx8ZnVuY3Rpb24oKXt0aHJvdyBuZXcgVHlwZUVycm9yKCJJbnZhbGlkIGF0dGVtcHQgdG8gZGVzdHJ1Y3R1cmUgbm9uLWl0ZXJhYmxlIGluc3RhbmNlLlxuSW4gb3JkZXIgdG8gYmUgaXRlcmFibGUsIG5vbi1hcnJheSBvYmplY3RzIG11c3QgaGF2ZSBhIFtTeW1ib2wuaXRlcmF0b3JdKCkgbWV0aG9kLiIpfSgpfWNsYXNzIHIgZXh0ZW5kcyBFcnJvcntjb25zdHJ1Y3RvcihlLHQpe3N1cGVyKHQpLHRoaXMuZXJyb3I9ZSx0aGlzLmVycm9yX2Rlc2NyaXB0aW9uPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsci5wcm90b3R5cGUpfXN0YXRpYyBmcm9tUGF5bG9hZChlKXtsZXQgdD1lLmVycm9yLG89ZS5lcnJvcl9kZXNjcmlwdGlvbjtyZXR1cm4gbmV3IHIodCxvKX19Y2xhc3MgbyBleHRlbmRzIHJ7Y29uc3RydWN0b3IoZSx0KXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIiwiTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyIuY29uY2F0KG4oZSxbImRlZmF1bHQiXSksIicsIHNjb3BlOiAnIikuY29uY2F0KG4odCksIicpIikpLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsby5wcm90b3R5cGUpfX1mdW5jdGlvbiBuKGUpe3JldHVybiBlJiYhKGFyZ3VtZW50cy5sZW5ndGg+MSYmdm9pZCAwIT09YXJndW1lbnRzWzFdP2FyZ3VtZW50c1sxXTpbXSkuaW5jbHVkZXMoZSk/ZToiIn0iZnVuY3Rpb24iPT10eXBlb2YgU3VwcHJlc3NlZEVycm9yJiZTdXBwcmVzc2VkRXJyb3I7Y29uc3Qgcz1lPT57dmFyIHQ9ZS5jbGllbnRJZCxyPWZ1bmN0aW9uKGUsdCl7dmFyIHI9e307Zm9yKHZhciBvIGluIGUpT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKGUsbykmJnQuaW5kZXhPZihvKTwwJiYocltvXT1lW29dKTtpZihudWxsIT1lJiYiZnVuY3Rpb24iPT10eXBlb2YgT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scyl7dmFyIG49MDtmb3Iobz1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO248by5sZW5ndGg7bisrKXQuaW5kZXhPZihvW25dKTwwJiZPYmplY3QucHJvdG90eXBlLnByb3BlcnR5SXNFbnVtZXJhYmxlLmNhbGwoZSxvW25dKSYmKHJbb1tuXV09ZVtvW25dXSl9cmV0dXJuIHJ9KGUsWyJjbGllbnRJZCJdKTtyZXR1cm4gbmV3IFVSTFNlYXJjaFBhcmFtcygoZT0+T2JqZWN0LmtleXMoZSkuZmlsdGVyKHQ9PnZvaWQgMCE9PWVbdF0pLnJlZHVjZSgodCxyKT0+T2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHQpLHtbcl06ZVtyXX0pLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IGk9e30sYT1udWxsO2NvbnN0IGM9KGUsdCk9PiIiLmNvbmNhdChlLCJ8IikuY29uY2F0KHQpLGw9KGUsdCk9PnQuc3RhcnRzV2l0aCgiIi5jb25jYXQoZSwifCIpKSx1PWU9PntPYmplY3QuZW50cmllcyhpKS5mb3JFYWNoKHI9PntsZXQgbz10KHIsMiksbj1vWzBdO29bMV09PT1lJiZkZWxldGUgaVtuXX0pfSxmPWU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKChlLHQpPT57clt0XT1lfSkscn0saD1hc3luYyBlPT57bGV0IHIsbixhPWUuZGF0YSx1PWEudGltZW91dCxoPWEuYXV0aCxkPWEuZmV0Y2hVcmwscD1hLmZldGNoT3B0aW9ucyx5PWEudXNlRm9ybURhdGEsZz1hLnVzZU1ycnQsYj1hLnNraXBUb2tlblN0b3JhZ2UsTz1hLnByZXNlcnZlUmVmcmVzaFRva2VuLGs9dChlLnBvcnRzLDEpWzBdLG09e307Y29uc3Qgaj1ofHx7fSx2PWouYXVkaWVuY2UsXz1qLnNjb3BlO3RyeXtjb25zdCBlPXk/ZihwLmJvZHkpOkpTT04ucGFyc2UocC5ib2R5KTtpZighZS5yZWZyZXNoX3Rva2VuJiYicmVmcmVzaF90b2tlbiI9PT1lLmdyYW50X3R5cGUpe2lmKG49KChlLHQpPT5pW2MoZSx0KV0pKHYsXyksIW4mJmcpe2NvbnN0IGU9aS5sYXRlc3RfcmVmcmVzaF90b2tlbix0PSgoZSx0KT0+ISFPYmplY3Qua2V5cyhpKS5maW5kKHI9PntpZigibGF0ZXN0X3JlZnJlc2hfdG9rZW4iIT09cil7Y29uc3Qgbz1sKHQsciksbj1yLnNwbGl0KCJ8IilbMV0uc3BsaXQoIiAiKSxzPWUuc3BsaXQoIiAiKS5ldmVyeShlPT5uLmluY2x1ZGVzKGUpKTtyZXR1cm4gbyYmc319KSkoXyx2KTtlJiYhdCYmKG49ZSl9aWYoIW4pdGhyb3cgbmV3IG8odixfKTtwLmJvZHk9eT9zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpufSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpufSkpfWxldCBhLGg7ImZ1bmN0aW9uIj09dHlwZW9mIEFib3J0Q29udHJvbGxlciYmKGE9bmV3IEFib3J0Q29udHJvbGxlcixwLnNpZ25hbD1hLnNpZ25hbCk7dHJ5e2g9YXdhaXQgUHJvbWlzZS5yYWNlKFsoVT11LG5ldyBQcm9taXNlKGU9PnNldFRpbWVvdXQoZSxVKSkpLGZldGNoKGQsT2JqZWN0LmFzc2lnbih7fSxwKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBrLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighaClyZXR1cm4gYSYmYS5hYm9ydCgpLHZvaWQgay5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtpZihNPWguaGVhZGVycyxtPVsuLi5NXS5yZWR1Y2UoKGUscik9PntsZXQgbz10KHIsMiksbj1vWzBdLHM9b1sxXTtyZXR1cm4gZVtuXT1zLGV9LHt9KSxyPWF3YWl0IGguanNvbigpLGIpcmV0dXJuIGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4sdm9pZCBrLnBvc3RNZXNzYWdlKHtvazpoLm9rLGpzb246cixoZWFkZXJzOm19KTtyLnJlZnJlc2hfdG9rZW4/KGcmJihpLmxhdGVzdF9yZWZyZXNoX3Rva2VuPXIucmVmcmVzaF90b2tlbix3PW4sUz1yLnJlZnJlc2hfdG9rZW4sT2JqZWN0LmVudHJpZXMoaSkuZm9yRWFjaChlPT57bGV0IHI9dChlLDIpLG89clswXTtyWzFdPT09dyYmKGlbb109Uyl9KSksKChlLHQscik9PntpW2ModCxyKV09ZX0pKHIucmVmcmVzaF90b2tlbix2LF8pLGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4pOk98fCgoZSx0KT0+e2RlbGV0ZSBpW2MoZSx0KV19KSh2LF8pLGsucG9zdE1lc3NhZ2Uoe29rOmgub2ssanNvbjpyLGhlYWRlcnM6bX0pfWNhdGNoKGUpe2sucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOmUuZXJyb3IsZXJyb3JfZGVzY3JpcHRpb246ZS5tZXNzYWdlfSxoZWFkZXJzOm19KX12YXIgdyxTLE0sVX0sZD1hc3luYyBlPT57bGV0IHI9ZS5kYXRhLG89ci50aW1lb3V0LG49ci5hdXRoLGE9ci5mZXRjaFVybCxjPXIuZmV0Y2hPcHRpb25zLGg9ci51c2VGb3JtRGF0YSxkPXQoZS5wb3J0cywxKVswXTtjb25zdCBwPShufHx7fSkuYXVkaWVuY2U7dHJ5e2NvbnN0IGU9KGU9Pntjb25zdCByPW5ldyBTZXQ7cmV0dXJuIE9iamVjdC5lbnRyaWVzKGkpLmZvckVhY2gobz0+e2xldCBuPXQobywyKSxzPW5bMF0saT1uWzFdO2woZSxzKSYmci5hZGQoaSl9KSxBcnJheS5mcm9tKHIpfSkocCk7aWYoMD09PWUubGVuZ3RoKXJldHVybiB2b2lkIGQucG9zdE1lc3NhZ2Uoe29rOiEwfSk7Y29uc3Qgcj1oP2YoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7Zm9yKGNvbnN0IHQgb2YgZSl7Y29uc3QgZT1oP3MoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHIpLHt0b2tlbjp0fSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxyKSx7dG9rZW46dH0pKTtsZXQgbixpLGwsZjsiZnVuY3Rpb24iPT10eXBlb2YgQWJvcnRDb250cm9sbGVyJiYobj1uZXcgQWJvcnRDb250cm9sbGVyLGk9bi5zaWduYWwpO3RyeXtmPWF3YWl0IFByb21pc2UucmFjZShbbmV3IFByb21pc2UoZT0+e2w9c2V0VGltZW91dChlLG8pfSksZmV0Y2goYSxPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sYykse2JvZHk6ZSxzaWduYWw6aX0pKV0pLmZpbmFsbHkoKCk9PmNsZWFyVGltZW91dChsKSl9Y2F0Y2goZSl7cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZS5tZXNzYWdlfSl9aWYoIWYpcmV0dXJuIG4mJm4uYWJvcnQoKSx2b2lkIGQucG9zdE1lc3NhZ2Uoe2Vycm9yOiJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCcifSk7aWYoIWYub2spe2xldCBlO3RyeXtjb25zdCB0PUpTT04ucGFyc2UoYXdhaXQgZi50ZXh0KCkpO2U9dC5lcnJvcl9kZXNjcmlwdGlvbn1jYXRjaChlKXt9cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZXx8IkhUVFAgZXJyb3IgIi5jb25jYXQoZi5zdGF0dXMpfSl9dSh0KX1kLnBvc3RNZXNzYWdlKHtvazohMH0pfWNhdGNoKGUpe2QucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZXx8IlVua25vd24gZXJyb3IgZHVyaW5nIHRva2VuIHJldm9jYXRpb24ifSl9fSxwPShlLHQpPT57aWYoIWEpcmV0dXJuITE7dHJ5e2NvbnN0IHI9bmV3IFVSTChhKS5vcmlnaW4sbz1uZXcgVVJMKGUuZmV0Y2hVcmwpO3JldHVybiBvLm9yaWdpbj09PXImJm8ucGF0aG5hbWU9PT10fWNhdGNoKGUpe3JldHVybiExfX07YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZT0+e2NvbnN0IHI9ZS5kYXRhLG89dChlLnBvcnRzLDEpWzBdO2lmKCEoInR5cGUiaW4gcil8fCJpbml0IiE9PXIudHlwZSlyZXR1cm4idHlwZSJpbiByJiYiY2xlYXIiPT09ci50eXBlPyhpPXt9LHZvaWQobnVsbD09b3x8by5wb3N0TWVzc2FnZSh7b2s6ITB9KSkpOiJ0eXBlImluIHImJiJyZXZva2UiPT09ci50eXBlP3AociwiL29hdXRoL3Jldm9rZSIpP3ZvaWQgZChlKTp2b2lkKG51bGw9PW98fG8ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSkpOnZvaWQoImZldGNoVXJsImluIHImJnAociwiL29hdXRoL3Rva2VuIik/aChlKTpudWxsPT1vfHxvLnBvc3RNZXNzYWdlKHtvazohMSxqc29uOntlcnJvcjoiaW52YWxpZF9mZXRjaF91cmwiLGVycm9yX2Rlc2NyaXB0aW9uOiJVbmF1dGhvcml6ZWQgZmV0Y2ggVVJMIn0saGVhZGVyczp7fX0pKTtpZihudWxsPT09YSl0cnl7bmV3IFVSTChyLmFsbG93ZWRCYXNlVXJsKSxhPXIuYWxsb3dlZEJhc2VVcmx9Y2F0Y2goZSl7cmV0dXJufX0pfSgpOwoK",null,false),new Worker(Xe,e)},nt={},ot=class{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(We,"::").concat(e)}},rt="auth0.is.authenticated",it={memory:()=>(new Le).enclosedCache,localstorage:()=>new Ue},at=e=>it[e],st=e=>{const t=e.openUrl,o=e.onRedirect,r=n(e,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:!1===t||t?t:o})},ct={NONCE:"nonce",KEYPAIR:"keypair"},ut=class{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(ct).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(ct.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save(ct.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,"readwrite",e=>e.put(n,t))}findNonce(e){return this.find(ct.NONCE,this.buildKey(e))}findKeyPair(){return this.find(ct.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(ct.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(ct.KEYPAIR,this.clientId)}},lt=class{constructor(e){this.storage=new ut(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 async function(e,t){var n;let o;return o={name:"ECDSA",namedCurve:"P-256"},crypto.subtle.generateKey(o,null!==(n=null==t?void 0:t.extractable)&&void 0!==n&&n,["sign","verify"])}(0,{extractable:!1}),await this.storage.setKeyPair(e)),e}async generateProof(e){const t=await this.getOrGenerateKeyPair();return function(e){let t=e.keyPair,n=e.url,o=e.method,r=e.nonce,i=e.accessToken;return _e(t,function(e){const t=new URL(e);return t.search="",t.hash="",t.href}(n),o,r,i)}(Object.assign({keyPair:t},e))}async calculateThumbprint(){return function(e){return async function(e){if(!ke(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 Se(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 we("unsupported JWK kty")}return ye(await crypto.subtle.digest({name:"SHA-256"},fe(JSON.stringify(n))))}(e.publicKey)}(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()])}};!function(e){e.Bearer="Bearer",e.DPoP="DPoP"}(et||(et={}));var ht,dt,pt,ft=class{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);let o,r;"string"==typeof n?(o=this.config.dpopNonceId?et.DPoP:et.Bearer,r=n):(o=n.token_type,r=n.access_token),this.setAuthorizationHeader(e,r,o),o===et.DPoP&&await this.setDpopProofHeader(e,r)}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,Te);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new N(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,o){const r=this.buildBaseRequest(e,t);await this.prepareRequest(r,o);const i=await this.config.fetch(r);return this.handleResponse(i,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)}},mt=class{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),r=null!==(t=n.headers.get("location"))&&void 0!==t?t:"",i=decodeURIComponent(r.split("/").pop()||"");return Object.assign(Object.assign({},o),{id:i,location:r})}async enrollmentVerify(e){const t=e,o=t.location;t.type;const r=n(t,["location","type"]),i=await this.myAccountFetcher.fetchWithAuth("".concat(o,"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)},{scope:["create:me:authentication_methods"]});return this._handleResponse(i)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t)}catch(r){throw new yt({type:"invalid_json",status:e.status,title:"Invalid JSON response",detail:t||String(r)})}if(e.ok)return t;throw new yt(t)}},yt=class e extends Error{constructor(t){let n=t.type,o=t.status,r=t.title,i=t.detail,a=t.validation_errors;super(i),this.name="MyAccountApiError",this.type=n,this.status=o,this.title=r,this.detail=i,this.validation_errors=a,Object.setPrototypeOf(this,e.prototype)}},wt={otp:{authenticatorTypes:["otp"]},sms:{authenticatorTypes:["oob"],oobChannels:["sms"]},email:{authenticatorTypes:["oob"],oobChannels:["email"]},push:{authenticatorTypes:["oob"],oobChannels:["auth0"]},voice:{authenticatorTypes:["oob"],oobChannels:["voice"]}};function gt(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}}"undefined"!=typeof navigator&&null!==(ht=navigator.userAgent)&&void 0!==ht&&null!==(dt=ht.startsWith)&&void 0!==dt&&dt.call(ht,"Mozilla/5.0 ")||(pt="".concat("oauth4webapi","/").concat("v3.8.6"));var vt="ERR_INVALID_ARG_VALUE",bt="ERR_INVALID_ARG_TYPE";function kt(e,t,n){const o=new TypeError(e,{cause:n});return Object.assign(o,{code:t}),o}var _t,St,Tt=Symbol(),Pt=Symbol(),Et=Symbol(),At=Symbol(),It=Symbol(),xt=Symbol(),Rt=new TextEncoder,Ot=new TextDecoder;function Ct(e){return"string"==typeof e?Rt.encode(e):Ot.decode(e)}if(Uint8Array.prototype.toBase64)_t=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0}));else{const e=32768;_t=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 Wt(e){return"string"==typeof e?St(e):_t(e)}St=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(e){throw kt("The input to be decoded is not correctly encoded.",vt,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 kt("The input to be decoded is not correctly encoded.",vt,e)}};var jt=class extends Error{constructor(e,t){var n;super(e,t),f(this,"code",void 0),this.name=this.constructor.name,this.code=Rn,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor)}},Kt=class extends Error{constructor(e,t){var n;super(e,t),f(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 Ut(e,t,n){return new Kt(e,{code:t,cause:n})}function Lt(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Nt(e){gt(e,Headers)&&(e=Object.fromEntries(e.entries()));const t=new Headers(null!=e?e:{});if(pt&&!t.has("user-agent")&&t.set("user-agent",pt),t.has("authorization"))throw kt('"options.headers" must not include the "authorization" header name',vt);return t}function zt(e,t){if(void 0!==t){if("function"==typeof t&&(t=t(e.href)),!(t instanceof AbortSignal))throw kt('"options.signal" must return or be an instance of AbortSignal',bt);return t}}function Mt(e){return e.includes("//")?e.replace("//","/"):e}function Dt(e,t,n,o,r){try{if("number"!=typeof e||!Number.isFinite(e))throw kt("".concat(n," must be a number"),bt,r);if(e>0)return;if(t){if(0!==e)throw kt("".concat(n," must be a non-negative number"),vt,r);return}throw kt("".concat(n," must be a positive number"),vt,r)}catch(e){if(o)throw Ut(e.message,o,r);throw e}}function Jt(e,t,n,o){try{if("string"!=typeof e)throw kt("".concat(t," must be a string"),bt,o);if(0===e.length)throw kt("".concat(t," must not be empty"),vt,o)}catch(e){if(n)throw Ut(e.message,n,o);throw e}}function Ht(e){!function(e,t){if(pn(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),r=1;r<n;r++)o[r-1]=arguments[r];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 Ut(t,jn,e)}(e,t)}(e,"application/json")}function Zt(){return Wt(crypto.getRandomValues(new Uint8Array(32)))}function Ft(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 jt("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 jt("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 jt("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 jt("unsupported CryptoKey algorithm name",{cause:e})}}function Vt(e){const t=null==e?void 0:e[Pt];return"number"==typeof t&&Number.isFinite(t)?t:0}function Xt(e){const t=null==e?void 0:e[Et];return"number"==typeof t&&Number.isFinite(t)&&-1!==Math.sign(t)?t:30}function Gt(){return Math.floor(Date.now()/1e3)}function Yt(e){if("object"!=typeof e||null===e)throw kt('"as" must be an object',bt);Jt(e.issuer,'"as.issuer"')}function qt(e){if("object"!=typeof e||null===e)throw kt('"client" must be an object',bt);Jt(e.client_id,'"client.client_id"')}function Bt(e){return Jt(e,'"clientSecret"'),(t,n,o,r)=>{o.set("client_id",n.client_id),o.set("client_secret",e)}}function Qt(e,t){const n=(i=e)instanceof CryptoKey?{key:i}:(null==i?void 0:i.key)instanceof CryptoKey?(void 0!==i.kid&&Jt(i.kid,'"kid"'),{key:i.key,kid:i.kid}):{},o=n.key,r=n.kid;var i;return function(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw kt("".concat(t," must be a CryptoKey"),bt)}(e,t),"private"!==e.type)throw kt("".concat(t," must be a private CryptoKey"),vt)}(o,'"clientPrivateKey.key"'),async(e,n,i,a)=>{var s;const c={alg:Ft(o),kid:r},u=function(e,t){const n=Gt()+Vt(t);return{jti:Zt(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,n);null==t||null===(s=t[It])||void 0===s||s.call(t,c,u),i.set("client_id",n.client_id),i.set("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),i.set("client_assertion",await async function(e,t,n){if(!n.usages.includes("sign"))throw kt('CryptoKey instances used for signing assertions must include "sign" in their "usages"',vt);const o="".concat(Wt(Ct(JSON.stringify(e))),".").concat(Wt(Ct(JSON.stringify(t)))),r=Wt(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return{name:e.algorithm.name,hash:Vn(e)};case"RSA-PSS":switch(Fn(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 jt("unsupported RSA-PSS hash name",{cause:e})}case"RSASSA-PKCS1-v1_5":return Fn(e),e.algorithm.name;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":case"Ed25519":return e.algorithm.name}throw new jt("unsupported CryptoKey algorithm name",{cause:e})}(n),n,Ct(o)));return"".concat(o,".").concat(r)}(c,u,o))}}var $t=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch(e){return null}};function en(e,t){if(t&&"https:"!==e.protocol)throw Ut("only requests to HTTPS are allowed",Un,e);if("https:"!==e.protocol&&"http:"!==e.protocol)throw Ut("only HTTP and HTTPS requests are allowed",Ln,e)}function tn(e,t,n,o){let r;if("string"!=typeof e||!(r=$t(e)))throw Ut("authorization server metadata does not contain a valid ".concat(n?'"as.mtls_endpoint_aliases.'.concat(t,'"'):'"as.'.concat(t,'"')),void 0===e?Dn:Jn,{attribute:n?"mtls_endpoint_aliases.".concat(t):t});return en(r,o),r}function nn(e,t,n,o){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?tn(e.mtls_endpoint_aliases[t],t,n,o):tn(e[t],t,n,o)}var on=class extends Error{constructor(e,t){var n;super(e,t),f(this,"cause",void 0),f(this,"code",void 0),f(this,"error",void 0),f(this,"status",void 0),f(this,"error_description",void 0),f(this,"response",void 0),this.name=this.constructor.name,this.code=xn,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)}},rn=class extends Error{constructor(e,t){var n,o;super(e,t),f(this,"cause",void 0),f(this,"code",void 0),f(this,"error",void 0),f(this,"error_description",void 0),this.name=this.constructor.name,this.code=On,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)}},an=class extends Error{constructor(e,t){var n;super(e,t),f(this,"cause",void 0),f(this,"code",void 0),f(this,"response",void 0),f(this,"status",void 0),this.name=this.constructor.name,this.code=In,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)}},sn=new RegExp("^[,\\s]*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)"),cn=new RegExp('^[,\\s]*([a-zA-Z0-9!#$%&\\\'\\*\\+\\-\\.\\^_`\\|~]+)\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"[,\\s]*(.*)'),un=new RegExp("^[,\\s]*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)[,\\s]*(.*)"),ln=new RegExp("^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)");async function hn(e,t,n){if(e.status!==t){let t;var o;if(function(e){let t;if(t=function(e){if(!gt(e,Response))throw kt('"response" must be an instance of Response',bt);const t=e.headers.get("www-authenticate");if(null===t)return;const n=[];let o=t;for(;o;){var r;let t=o.match(sn);const c=null===(r=t)||void 0===r?void 0:r[1].toLowerCase();if(!c)return;const u=o.substring(t[0].length);if(u&&!u.match(/^[\s,]/))return;const l=u.match(/^\s+(.*)$/),h=!!l;o=l?l[1]:void 0;const d={};let p;if(h)for(;o;){let n,r;if(t=o.match(cn)){var i=g(t,4);if(n=i[1],r=i[2],o=i[3],r.includes("\\"))try{r=JSON.parse('"'.concat(r,'"'))}catch(e){}d[n.toLowerCase()]=r}else{if(!(t=o.match(un))){if(t=o.match(ln)){if(Object.keys(d).length)break;var a=g(t,3);p=a[1],o=a[2];break}return}var s=g(t,4);n=s[1],r=s[2],o=s[3],d[n.toLowerCase()]=r}}else o=u||void 0;const f={scheme:c,parameters:d};p&&(f.token68=p),n.push(f)}return n.length?n:void 0}(e))throw new an("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:t,response:e})}(e),t=await async function(e){if(e.status>399&&e.status<500){Zn(e),Ht(e);try{const t=await e.clone().json();if(Lt(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 on("server responded with an error in the response body",{cause:t,response:e});throw Ut('"response" is not a conform '.concat(n," response (unexpected HTTP status code)"),Kn,e)}}function dn(e){if(!_n.has(e))throw kt('"options.DPoP" is not a valid DPoPHandle',vt)}function pn(e){var t;return null===(t=e.headers.get("content-type"))||void 0===t?void 0:t.split(";")[0]}async function fn(e,t,n,o,r,i,a){return await n(e,t,r,i),i.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),((null==a?void 0:a[At])||fetch)(o.href,{body:r,headers:Object.fromEntries(i.entries()),method:"POST",redirect:"manual",signal:zt(o,null==a?void 0:a.signal)})}async function mn(e,t,n,o,r,i){var a;const s=nn(e,"token_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[Tt]));r.set("grant_type",o);const c=Nt(null==i?void 0:i.headers);c.set("accept","application/json"),void 0!==(null==i?void 0:i.DPoP)&&(dn(i.DPoP),await i.DPoP.addProof(s,c,"POST"));const u=await fn(e,t,n,s,r,c,i);return null==i||null===(a=i.DPoP)||void 0===a||a.cacheNonce(u,s),u}var yn=new WeakMap,wn=new WeakMap;function gn(e){if(!e.id_token)return;const t=yn.get(e);if(!t)throw kt('"ref" was already garbage collected or did not resolve from the proper sources',vt);return t}async function vn(e,t,n,o,r,i){if(Yt(e),qt(t),!gt(n,Response))throw kt('"response" must be an instance of Response',bt);await hn(n,200,"Token Endpoint"),Zn(n);const a=await Bn(n);if(Jt(a.access_token,'"response" body "access_token" property',Wn,{body:a}),Jt(a.token_type,'"response" body "token_type" property',Wn,{body:a}),a.token_type=a.token_type.toLowerCase(),void 0!==a.expires_in){let e="number"!=typeof a.expires_in?parseFloat(a.expires_in):a.expires_in;Dt(e,!0,'"response" body "expires_in" property',Wn,{body:a}),a.expires_in=e}if(void 0!==a.refresh_token&&Jt(a.refresh_token,'"response" body "refresh_token" property',Wn,{body:a}),void 0!==a.scope&&"string"!=typeof a.scope)throw Ut('"response" body "scope" property must be a string',Wn,{body:a});if(void 0!==a.id_token){Jt(a.id_token,'"response" body "id_token" property',Wn,{body:a});const i=["aud","exp","iat","iss","sub"];!0===t.require_auth_time&&i.push("auth_time"),void 0!==t.default_max_age&&(Dt(t.default_max_age,!0,'"client.default_max_age"'),i.push("auth_time")),null!=o&&o.length&&i.push(...o);const s=await async function(e,t,n,o,r){let i,a,s=e.split("."),c=s[0],u=s[1],l=s.length;if(5===l){if(void 0===r)throw new jt("JWE decryption is not configured",{cause:e});var h=(e=await r(e)).split(".");c=h[0],u=h[1],l=h.length}if(3!==l)throw Ut("Invalid JWT",Wn,e);try{i=JSON.parse(Ct(Wt(c)))}catch(e){throw Ut("failed to parse JWT Header body as base64url encoded JSON",Cn,e)}if(!Lt(i))throw Ut("JWT Header must be a top level object",Wn,e);if(t(i),void 0!==i.crit)throw new jt('no JWT "crit" header parameter extensions are supported',{cause:{header:i}});try{a=JSON.parse(Ct(Wt(u)))}catch(e){throw Ut("failed to parse JWT Payload body as base64url encoded JSON",Cn,e)}if(!Lt(a))throw Ut("JWT Payload must be a top level object",Wn,e);const d=Gt()+n;if(void 0!==a.exp){if("number"!=typeof a.exp)throw Ut('unexpected JWT "exp" (expiration time) claim type',Wn,{claims:a});if(a.exp<=d-o)throw Ut('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',Nn,{claims:a,now:d,tolerance:o,claim:"exp"})}if(void 0!==a.iat&&"number"!=typeof a.iat)throw Ut('unexpected JWT "iat" (issued at) claim type',Wn,{claims:a});if(void 0!==a.iss&&"string"!=typeof a.iss)throw Ut('unexpected JWT "iss" (issuer) claim type',Wn,{claims:a});if(void 0!==a.nbf){if("number"!=typeof a.nbf)throw Ut('unexpected JWT "nbf" (not before) claim type',Wn,{claims:a});if(a.nbf>d+o)throw Ut('unexpected JWT "nbf" (not before) claim value',Nn,{claims:a,now:d,tolerance:o,claim:"nbf"})}if(void 0!==a.aud&&"string"!=typeof a.aud&&!Array.isArray(a.aud))throw Ut('unexpected JWT "aud" (audience) claim type',Wn,{claims:a});return{header:i,claims:a,jwt:e}}(a.id_token,Xn.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),Vt(t),Xt(t),r).then(Pn.bind(void 0,i)).then(kn.bind(void 0,e)).then(bn.bind(void 0,t.client_id)),c=s.claims,u=s.jwt;if(Array.isArray(c.aud)&&1!==c.aud.length){if(void 0===c.azp)throw Ut('ID Token "aud" (audience) claim includes additional untrusted audiences',zn,{claims:c,claim:"aud"});if(c.azp!==t.client_id)throw Ut('unexpected ID Token "azp" (authorized party) claim value',zn,{expected:t.client_id,claims:c,claim:"azp"})}void 0!==c.auth_time&&Dt(c.auth_time,!0,'ID Token "auth_time" (authentication time)',Wn,{claims:c}),wn.set(n,u),yn.set(a,c)}if(void 0!==(null==i?void 0:i[a.token_type]))i[a.token_type](n,a);else if("dpop"!==a.token_type&&"bearer"!==a.token_type)throw new jt("unsupported `token_type` value",{cause:{body:a}});return a}function bn(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw Ut('unexpected JWT "aud" (audience) claim value',zn,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw Ut('unexpected JWT "aud" (audience) claim value',zn,{expected:e,claims:t.claims,claim:"aud"});return t}function kn(e,t){var n,o;const r=null!==(n=null===(o=e[$n])||void 0===o?void 0:o.call(e,t))&&void 0!==n?n:e.issuer;if(t.claims.iss!==r)throw Ut('unexpected JWT "iss" (issuer) claim value',zn,{expected:r,claims:t.claims,claim:"iss"});return t}var _n=new WeakSet,Sn=Symbol(),Tn={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 Pn(e,t){for(const n of e)if(void 0===t.claims[n])throw Ut('JWT "'.concat(n,'" (').concat(Tn[n],") claim missing"),Wn,{claims:t.claims});return t}var En=Symbol(),An=Symbol();var In="OAUTH_WWW_AUTHENTICATE_CHALLENGE",xn="OAUTH_RESPONSE_BODY_ERROR",Rn="OAUTH_UNSUPPORTED_OPERATION",On="OAUTH_AUTHORIZATION_RESPONSE_ERROR",Cn="OAUTH_PARSE_ERROR",Wn="OAUTH_INVALID_RESPONSE",jn="OAUTH_RESPONSE_IS_NOT_JSON",Kn="OAUTH_RESPONSE_IS_NOT_CONFORM",Un="OAUTH_HTTP_REQUEST_FORBIDDEN",Ln="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",Nn="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",zn="OAUTH_JWT_CLAIM_COMPARISON_FAILED",Mn="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED",Dn="OAUTH_MISSING_SERVER_METADATA",Jn="OAUTH_INVALID_SERVER_METADATA";async function Hn(e){if(!gt(e,Response))throw kt('"response" must be an instance of Response',bt);await hn(e,200,"Revocation Endpoint")}function Zn(e){if(e.bodyUsed)throw kt('"response" body has been used already',vt)}function Fn(e){const t=e.algorithm;if("number"!=typeof t.modulusLength||t.modulusLength<2048)throw new jt("unsupported ".concat(t.name," modulusLength"),{cause:e})}function Vn(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 jt("unsupported ECDSA namedCurve",{cause:e})}}function Xn(e,t,n,o){if(void 0===e)if(Array.isArray(t)){if(!t.includes(o.alg))throw Ut('unexpected JWT "alg" header parameter',Wn,{header:o,expected:t,reason:"authorization server metadata"})}else{if(void 0===n)throw Ut('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 Ut('unexpected JWT "alg" header parameter',Wn,{header:o,expected:n,reason:"default value"})}else if("string"==typeof e?o.alg!==e:!e.includes(o.alg))throw Ut('unexpected JWT "alg" header parameter',Wn,{header:o,expected:e,reason:"client configuration"})}function Gn(e,t){const n=e.getAll(t),o=n[0];if(n.length>1)throw Ut('"'.concat(t,'" parameter must be provided only once'),Wn);return o}var Yn=Symbol(),qn=Symbol();async function Bn(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ht;try{t=await e.json()}catch(t){throw n(e),Ut('failed to parse "response" body as JSON',Cn,t)}if(!Lt(t))throw Ut('"response" body must be a top level object',Wn,{body:t});return t}var Qn=Symbol(),$n=Symbol(),eo=new TextEncoder,to=new TextDecoder;function no(){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),r=new Uint8Array(o);let i=0;for(const a of t)r.set(a,i),i+=a.length;return r}function oo(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}function ro(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}function io(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64("string"==typeof e?e:to.decode(e),{alphabet:"base64url"});let t=e;t instanceof Uint8Array&&(t=to.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/");try{return ro(t)}catch(e){throw new TypeError("The input to be decoded is not correctly encoded.")}}function ao(e){let t=e;return"string"==typeof t&&(t=eo.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,"_")}var so=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))},co=(e,t)=>e.name===t;function uo(e,t){var n;if(n=e.hash,parseInt(n.name.slice(4),10)!==t)throw so("SHA-".concat(t),"algorithm.hash")}function lo(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];if((o=o.filter(Boolean)).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 i;null!==(i=t.constructor)&&void 0!==i&&i.name&&(e+=" Received an instance of ".concat(t.constructor.name))}return e}var ho=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return lo("Key for the ".concat(e," algorithm must be "),t,...o)},po=class extends Error{constructor(e,t){var n;super(e,t),f(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor)}};f(po,"code","ERR_JOSE_GENERIC");var fo=class extends po{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}}),f(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),f(this,"claim",void 0),f(this,"reason",void 0),f(this,"payload",void 0),this.claim=n,this.reason=o,this.payload=t}};f(fo,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");var mo=class extends po{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}}),f(this,"code","ERR_JWT_EXPIRED"),f(this,"claim",void 0),f(this,"reason",void 0),f(this,"payload",void 0),this.claim=n,this.reason=o,this.payload=t}};f(mo,"code","ERR_JWT_EXPIRED");var yo=class extends po{constructor(){super(...arguments),f(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}};f(yo,"code","ERR_JOSE_ALG_NOT_ALLOWED");var wo=class extends po{constructor(){super(...arguments),f(this,"code","ERR_JOSE_NOT_SUPPORTED")}};f(wo,"code","ERR_JOSE_NOT_SUPPORTED"),f(class extends po{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"decryption operation failed",arguments.length>1?arguments[1]:void 0),f(this,"code","ERR_JWE_DECRYPTION_FAILED")}},"code","ERR_JWE_DECRYPTION_FAILED"),f(class extends po{constructor(){super(...arguments),f(this,"code","ERR_JWE_INVALID")}},"code","ERR_JWE_INVALID");var go=class extends po{constructor(){super(...arguments),f(this,"code","ERR_JWS_INVALID")}};f(go,"code","ERR_JWS_INVALID");var vo=class extends po{constructor(){super(...arguments),f(this,"code","ERR_JWT_INVALID")}};f(vo,"code","ERR_JWT_INVALID"),f(class extends po{constructor(){super(...arguments),f(this,"code","ERR_JWK_INVALID")}},"code","ERR_JWK_INVALID");var bo=class extends po{constructor(){super(...arguments),f(this,"code","ERR_JWKS_INVALID")}};f(bo,"code","ERR_JWKS_INVALID");var ko=class extends po{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),f(this,"code","ERR_JWKS_NO_MATCHING_KEY")}};f(ko,"code","ERR_JWKS_NO_MATCHING_KEY");var _o=class extends po{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),f(this,Symbol.asyncIterator,void 0),f(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}};f(_o,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");var So=class extends po{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"request timed out",arguments.length>1?arguments[1]:void 0),f(this,"code","ERR_JWKS_TIMEOUT")}};f(So,"code","ERR_JWKS_TIMEOUT");var To=class extends po{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"signature verification failed",arguments.length>1?arguments[1]:void 0),f(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}};f(To,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");var Po=e=>{if("CryptoKey"===(null==e?void 0:e[Symbol.toStringTag]))return!0;try{return e instanceof CryptoKey}catch(e){return!1}},Eo=e=>"KeyObject"===(null==e?void 0:e[Symbol.toStringTag]),Ao=e=>Po(e)||Eo(e);function Io(e,t){if(e)throw new TypeError("".concat(t," can only be called once"))}function xo(e,t,n){try{return io(e)}catch(e){throw new n("Failed to base64url decode the ".concat(t))}}function Ro(e){if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return!1;var t;if(null===Object.getPrototypeOf(e))return!0;let n=e;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}function Oo(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const o=t.filter(Boolean);if(0===o.length||1===o.length)return!0;let r;for(const i of o){const e=Object.keys(i);if(r&&0!==r.size)for(const t of e){if(r.has(t))return!1;r.add(t)}else r=new Set(e)}return!0}var Co=e=>Ro(e)&&"string"==typeof e.kty;function Wo(e,t){if(e.startsWith("RS")||e.startsWith("PS")){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"))}}function jo(e,t){const n="SHA-".concat(e.slice(-3));switch(e){case"HS256":case"HS384":case"HS512":return{hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:n,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:n,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:e};default:throw new wo("alg ".concat(e," is not supported either by JOSE or your javascript runtime"))}}async function Ko(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return lo("Key must be ",e,...n)}(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:"SHA-".concat(e.slice(-3)),name:"HMAC"},!1,[n])}return function(e,t,n){switch(t){case"HS256":case"HS384":case"HS512":if(!co(e.algorithm,"HMAC"))throw so("HMAC");uo(e.algorithm,parseInt(t.slice(2),10));break;case"RS256":case"RS384":case"RS512":if(!co(e.algorithm,"RSASSA-PKCS1-v1_5"))throw so("RSASSA-PKCS1-v1_5");uo(e.algorithm,parseInt(t.slice(2),10));break;case"PS256":case"PS384":case"PS512":if(!co(e.algorithm,"RSA-PSS"))throw so("RSA-PSS");uo(e.algorithm,parseInt(t.slice(2),10));break;case"Ed25519":case"EdDSA":if(!co(e.algorithm,"Ed25519"))throw so("Ed25519");break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":if(!co(e.algorithm,t))throw so(t);break;case"ES256":case"ES384":case"ES512":{if(!co(e.algorithm,"ECDSA"))throw so("ECDSA");const n=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}(t);if(e.algorithm.namedCurve!==n)throw so(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}!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)}(t,e,n),t}var Uo='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';async function Lo(e){var t,n;if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const o=function(e){let t,n;switch(e.kty){case"AKP":switch(e.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":t={name:e.alg},n=e.priv?["sign"]:["verify"];break;default:throw new wo(Uo)}break;case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:"SHA-".concat(e.alg.slice(-3))},n=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(e.alg.slice(-3))},n=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:"SHA-".concat(parseInt(e.alg.slice(-3),10)||1)},n=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new wo(Uo)}break;case"EC":switch(e.alg){case"ES256":case"ES384":case"ES512":t={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[e.alg]},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new wo(Uo)}break;case"OKP":switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new wo(Uo)}break;default:throw new wo('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:n}}(e),r=o.algorithm,i=o.keyUsages,a=y({},e);return"AKP"!==a.kty&&delete a.alg,delete a.use,crypto.subtle.importKey("jwk",a,r,null!==(t=e.ext)&&void 0!==t?t:!e.d&&!e.priv,null!==(n=e.key_ops)&&void 0!==n?n:i)}var No,zo="given KeyObject instance cannot be used for this algorithm",Mo=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];No||(No=new WeakMap);let r=No.get(e);if(null!=r&&r[n])return r[n];const i=await Lo(y(y({},t),{},{alg:n}));return o&&Object.freeze(e),r?r[n]=i:No.set(e,{[n]:i}),i};async function Do(e,t){if(e instanceof Uint8Array)return e;if(Po(e))return e;if(Eo(e)){if("secret"===e.type)return e.export();if("toCryptoKey"in e&&"function"==typeof e.toCryptoKey)try{return((e,t)=>{No||(No=new WeakMap);let n=No.get(e);if(null!=n&&n[t])return n[t];const o="public"===e.type,r=!!o;let i;if("x25519"===e.asymmetricKeyType){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError(zo)}i=e.toCryptoKey(e.asymmetricKeyType,r,o?[]:["deriveBits"])}if("ed25519"===e.asymmetricKeyType){if("EdDSA"!==t&&"Ed25519"!==t)throw new TypeError(zo);i=e.toCryptoKey(e.asymmetricKeyType,r,[o?"verify":"sign"])}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":if(t!==e.asymmetricKeyType.toUpperCase())throw new TypeError(zo);i=e.toCryptoKey(e.asymmetricKeyType,r,[o?"verify":"sign"])}if("rsa"===e.asymmetricKeyType){let n;switch(t){case"RSA-OAEP":n="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":n="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":n="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":n="SHA-512";break;default:throw new TypeError(zo)}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:n},r,o?["encrypt"]:["decrypt"]);i=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:n},r,[o?"verify":"sign"])}if("ec"===e.asymmetricKeyType){var a;const n=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(null===(a=e.asymmetricKeyDetails)||void 0===a?void 0:a.namedCurve);if(!n)throw new TypeError(zo);const s={ES256:"P-256",ES384:"P-384",ES512:"P-521"};s[t]&&n===s[t]&&(i=e.toCryptoKey({name:"ECDSA",namedCurve:n},r,[o?"verify":"sign"])),t.startsWith("ECDH-ES")&&(i=e.toCryptoKey({name:"ECDH",namedCurve:n},r,o?[]:["deriveBits"]))}if(!i)throw new TypeError(zo);return n?n[t]=i:No.set(e,{[t]:i}),i})(e,t)}catch(e){if(e instanceof TypeError)throw e}let n=e.export({format:"jwk"});return Mo(e,n,t)}if(Co(e))return e.k?io(e.k):Mo(e,e,t,!0);throw new Error("unreachable")}var Jo=(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},Ho=e=>{const t=e.data[e.pos++];if(128&t){const n=127&t;let o=0;for(let t=0;t<n;t++)o=o<<8|e.data[e.pos++];return o}return t},Zo=(e,t,n)=>{if(e.data[e.pos++]!==t)throw new Error(n)},Fo=(e,t)=>{const n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n},Vo=(e,t,n)=>{var o;const r=(e=>ro(e.replace(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"")))(e);let i=n;return null!=t&&null!==(o=t.startsWith)&&void 0!==o&&o.call(t,"ECDH-ES")&&(i||(i={}),i.getNamedCurve=e=>{const t={data:e,pos:0};return function(e){Zo(e,48,"Invalid PKCS#8 structure"),Ho(e),Zo(e,2,"Expected version field");const t=Ho(e);e.pos+=t,Zo(e,48,"Expected algorithm identifier"),Ho(e),e.pos}(t),(e=>{const t=(e=>{Zo(e,6,"Expected algorithm OID");const t=Ho(e);return Fo(e,t)})(e);if(Jo(t,[43,101,110]))return"X25519";if(!Jo(t,[42,134,72,206,61,2,1]))throw new Error("Unsupported key algorithm");Zo(e,6,"Expected curve OID");const n=Ho(e),o=Fo(e,n);for(const r of[{name:"P-256",oid:[42,134,72,206,61,3,1,7]},{name:"P-384",oid:[43,129,4,0,34]},{name:"P-521",oid:[43,129,4,0,35]}]){const e=r.name,t=r.oid;if(Jo(o,t))return e}throw new Error("Unsupported named curve")})(t)}),(async(e,t,n,o)=>{var r;let i,a;const s="spki"===e,c=()=>s?["verify"]:["sign"];switch(n){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:"SHA-".concat(n.slice(-3))},a=c();break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(n.slice(-3))},a=c();break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:"SHA-".concat(parseInt(n.slice(-3),10)||1)},a=s?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":case"ES384":case"ES512":i={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[n]},a=c();break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":try{const e=o.getNamedCurve(t);i="X25519"===e?{name:"X25519"}:{name:"ECDH",namedCurve:e}}catch(e){throw new wo("Invalid or unsupported key format")}a=s?[]:["deriveBits"];break;case"Ed25519":case"EdDSA":i={name:"Ed25519"},a=c();break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":i={name:n},a=c();break;default:throw new wo('Invalid or unsupported "alg" (Algorithm) value')}return crypto.subtle.importKey(e,t,i,null!==(r=null==o?void 0:o.extractable)&&void 0!==r?r:!!s,a)})("pkcs8",r,t,i)};async function Xo(e,t,n){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return Vo(e,t,n)}function Go(e,t,n,o,r){if(void 0!==r.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 new Set;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');let i;i=void 0!==n?new Map([...Object.entries(n),...t.entries()]):t;for(const a of o.crit){if(!i.has(a))throw new wo('Extension Header Parameter "'.concat(a,'" is not recognized'));if(void 0===r[a])throw new e('Extension Header Parameter "'.concat(a,'" is missing'));if(i.get(a)&&void 0===o[a])throw new e('Extension Header Parameter "'.concat(a,'" MUST be integrity protected'))}return new Set(o.crit)}var Yo,qo,Bo,Qo,$o=e=>null==e?void 0:e[Symbol.toStringTag],er=(e,t,n)=>{if(void 0!==t.use){let e;switch(n){case"sign":case"verify":e="sig";break;case"encrypt":case"decrypt":e="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!==e)throw new TypeError('Invalid key for this operation, its "alg" must be "'.concat(e,'" when present'));if(Array.isArray(t.key_ops)){var o,r;let i;switch(!0){case"sign"===n||"verify"===n:case"dir"===e:case e.includes("CBC-HS"):i=n;break;case e.startsWith("PBES2"):i="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):i=!e.includes("GCM")&&e.endsWith("KW")?"encrypt"===n?"wrapKey":"unwrapKey":n;break;case"encrypt"===n&&e.startsWith("RSA"):i="wrapKey";break;case"decrypt"===n:i=e.startsWith("RSA")?"unwrapKey":"deriveBits"}if(i&&!1===(null===(o=t.key_ops)||void 0===o||null===(r=o.includes)||void 0===r?void 0:r.call(o,i)))throw new TypeError('Invalid key for this operation, its "key_ops" must include "'.concat(i,'" when present'))}return!0};function tr(e,t,n){switch(e.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":((e,t,n)=>{if(!(t instanceof Uint8Array)){if(Co(t)){if((e=>"oct"===e.kty&&"string"==typeof e.k)(t)&&er(e,t,n))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!Ao(t))throw new TypeError(ho(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if("secret"!==t.type)throw new TypeError("".concat($o(t),' instances for symmetric algorithms must be of type "secret"'))}})(e,t,n);break;default:((e,t,n)=>{if(Co(t))switch(n){case"decrypt":case"sign":if((e=>"oct"!==e.kty&&("AKP"===e.kty&&"string"==typeof e.priv||"string"==typeof e.d))(t)&&er(e,t,n))return;throw new TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if((e=>"oct"!==e.kty&&void 0===e.d&&void 0===e.priv)(t)&&er(e,t,n))return;throw new TypeError("JSON Web Key for this operation must be a public JWK")}if(!Ao(t))throw new TypeError(ho(e,t,"CryptoKey","KeyObject","JSON Web Key"));if("secret"===t.type)throw new TypeError("".concat($o(t),' instances for asymmetric algorithms must not be of type "secret"'));if("public"===t.type)switch(n){case"sign":throw new TypeError("".concat($o(t),' instances for asymmetric algorithm signing must be of type "private"'));case"decrypt":throw new TypeError("".concat($o(t),' instances for asymmetric algorithm decryption must be of type "private"'))}if("private"===t.type)switch(n){case"verify":throw new TypeError("".concat($o(t),' instances for asymmetric algorithm verifying must be of type "public"'));case"encrypt":throw new TypeError("".concat($o(t),' instances for asymmetric algorithm encryption must be of type "public"'))}})(e,t,n)}}"undefined"!=typeof navigator&&null!==(Yo=navigator.userAgent)&&void 0!==Yo&&null!==(qo=Yo.startsWith)&&void 0!==qo&&qo.call(Yo,"Mozilla/5.0 ")||(Qo="".concat("openid-client","/").concat("v6.8.4"),Bo={"user-agent":Qo});var nr,or,rr=e=>nr.get(e);function ir(e){return void 0!==e?Bt(e):(or||(or=new WeakMap),(e,t,n,o)=>{let r;return(r=or.get(t))||(function(e,t){if("string"!=typeof e)throw ur("".concat(t," must be a string"),cr);if(0===e.length)throw ur("".concat(t," must not be empty"),sr)}(t.client_secret,'"metadata.client_secret"'),r=Bt(t.client_secret),or.set(t,r)),r(e,t,n,o)})}var ar=At,sr="ERR_INVALID_ARG_VALUE",cr="ERR_INVALID_ARG_TYPE";function ur(e,t,n){const o=new TypeError(e,{cause:n});return Object.assign(o,{code:t}),o}var lr=class extends Error{constructor(e,t){var n;super(e,t),f(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 hr(e,t,n){return new lr(e,{cause:t,code:n})}function dr(e){if(e instanceof TypeError||e instanceof lr||e instanceof on||e instanceof rn||e instanceof an)throw e;if(e instanceof Kt)switch(e.code){case Un:throw hr("only requests to HTTPS are allowed",e,e.code);case Ln:throw hr("only requests to HTTP or HTTPS are allowed",e,e.code);case Kn:throw hr("unexpected HTTP response status code",e.cause,e.code);case jn:throw hr("unexpected response content-type",e.cause,e.code);case Cn:throw hr("parsing error occured",e,e.code);case Wn:throw hr("invalid response encountered",e,e.code);case zn:throw hr("unexpected JWT claim value encountered",e,e.code);case Mn:throw hr("unexpected JSON attribute value encountered",e,e.code);case Nn:throw hr("JWT timestamp claim value failed validation",e,e.code);default:throw hr(e.message,e,e.code)}if(e instanceof jt)throw hr("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw hr("runtime operation error",e,Rn);case"NotSupportedError":throw hr("runtime unsupported operation",e,Rn);case"TimeoutError":throw hr("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw hr("operation aborted",e,"OAUTH_ABORT")}throw new lr("something went wrong",{cause:e})}async function pr(e,t,n,o,r){const i=await async function(e,t){var n,o;if(!(e instanceof URL))throw ur('"server" must be an instance of URL',cr);const r=!e.href.includes("/.well-known/"),i=null!==(n=null==t?void 0:t.timeout)&&void 0!==n?n:30,a=AbortSignal.timeout(1e3*i),s=await(r?async function(e,t){return async function(e,t,n,o){if(!(e instanceof URL))throw kt('"'.concat("issuerIdentifier",'" must be an instance of URL'),bt);en(e,!0!==(null==o?void 0:o[Tt]));const r=n(new URL(e.href)),i=Nt(null==o?void 0:o.headers);return i.set("accept","application/json"),((null==o?void 0:o[At])||fetch)(r.href,{body:void 0,headers:Object.fromEntries(i.entries()),method:"GET",redirect:"manual",signal:zt(r,null==o?void 0:o.signal)})}(e,0,e=>{switch(null==t?void 0:t.algorithm){case void 0:case"oidc":!function(e){e.pathname=Mt("".concat(e.pathname,"/").concat(".well-known/openid-configuration"))}(e);break;case"oauth2":!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];"/"===e.pathname?e.pathname=t:e.pathname=Mt("".concat(t,"/").concat(n?e.pathname:e.pathname.replace(/(\/)$/,"")))}(e,".well-known/oauth-authorization-server");break;default:throw kt('"options.algorithm" must be "oidc" (default), or "oauth2"',vt)}return e},t)}(e,{algorithm:null==t?void 0:t.algorithm,[At]:null==t?void 0:t[ar],[Tt]:null==t||null===(o=t.execute)||void 0===o?void 0:o.includes(kr),signal:a,headers:new Headers(Bo)}):((null==t?void 0:t[ar])||fetch)((en(e,null==t||null===(c=t.execute)||void 0===c||!c.includes(kr)),e.href),{headers:Object.fromEntries(new Headers(y({accept:"application/json"},Bo)).entries()),body:void 0,method:"GET",redirect:"manual",signal:a})).then(e=>async function(e,t){const n=Qn;if(!(n instanceof URL)&&n!==Qn)throw kt('"expectedIssuerIdentifier" must be an instance of URL',bt);if(!gt(t,Response))throw kt('"response" must be an instance of Response',bt);if(200!==t.status)throw Ut('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',Kn,t);Zn(t);const o=await Bn(t);if(Jt(o.issuer,'"response" body "issuer" property',Wn,{body:o}),n!==Qn&&new URL(o.issuer).href!==n.href)throw Ut('"response" body "issuer" property does not match the expected value',Mn,{expected:n.href,body:o,attribute:"issuer"});return o}(0,e)).catch(dr);var c;return r&&new URL(s.issuer).href!==e.href&&(function(e,t,n){return!("https://login.microsoftonline.com"!==e.origin||null!=n&&n.algorithm&&"oidc"!==n.algorithm||(t[fr]=!0,0))}(e,s,t)||function(e,t){return!(!e.hostname.endsWith(".b2clogin.com")||null!=t&&t.algorithm&&"oidc"!==t.algorithm)}(e,t)||(()=>{throw new lr("discovered metadata issuer does not match the expected issuer",{code:Mn,cause:{expected:e.href,body:s,attribute:"issuer"}})})()),s}(e,r),a=new mr(i,t,n,o);let s=rr(a);if(null!=r&&r[ar]&&(s.fetch=r[ar]),null!=r&&r.timeout&&(s.timeout=r.timeout),null!=r&&r.execute)for(const c of r.execute)c(a);return a}new TextDecoder;var fr=Symbol(),mr=class{constructor(e,t,n,o){var r,i,a,s,c;if("string"!=typeof t||!t.length)throw ur('"clientId" must be a non-empty string',cr);if("string"==typeof n&&(n={client_secret:n}),void 0!==(null===(r=n)||void 0===r?void 0:r.client_id)&&t!==n.client_id)throw ur('"clientId" and "metadata.client_id" must be the same',sr);const u=y(y({},structuredClone(n)),{},{client_id:t});let l;u[Pt]=null!==(i=null===(a=n)||void 0===a?void 0:a[Pt])&&void 0!==i?i:0,u[Et]=null!==(s=null===(c=n)||void 0===c?void 0:c[Et])&&void 0!==s?s:30,l=o||("string"==typeof u.client_secret&&u.client_secret.length?ir(u.client_secret):(e,t,n,o)=>{n.set("client_id",t.client_id)});let h=Object.freeze(u);const d=structuredClone(e);fr in e&&(d[$n]=t=>{let n=t.claims.tid;return e.issuer.replace("{tenantid}",n)});let p=Object.freeze(d);nr||(nr=new WeakMap),nr.set(this,{__proto__:null,as:p,c:h,auth:l,tlsOnly:!0,jwksCache:{}})}serverMetadata(){const e=structuredClone(rr(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(rr(this).c)}get timeout(){return rr(this).timeout}set timeout(e){rr(this).timeout=e}get[ar](){return rr(this).fetch}set[ar](e){rr(this).fetch=e}};function yr(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 gn(this)}catch(e){return}}}}}(e))}async function wr(e,t,n){var o;let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=null===(o=e.headers.get("retry-after"))||void 0===o?void 0:o.trim();if(void 0===i)return;let a;if(/^\d+$/.test(i))a=parseInt(i,10);else{const e=new Date(i);if(Number.isFinite(e.getTime())){const t=new Date,n=e.getTime()-t.getTime();n>0&&(a=Math.ceil(n/1e3))}}if(r&&!Number.isFinite(a))throw new Kt("invalid Retry-After header value",{cause:e});a>t&&await gr(a-t,n)}function gr(e,t){return new Promise((n,o)=>{const r=e=>{try{t.throwIfAborted()}catch(e){return void o(e)}if(e<=0)return void n();const i=Math.min(e,5);setTimeout(()=>r(e-i),1e3*i)};r(e)})}async function vr(e,t){Ar(e);const n=rr(e),o=n.as,r=n.c,i=n.auth,a=n.fetch,s=n.tlsOnly,c=n.timeout;return async function(e,t,n,o,r){Yt(e),qt(t);const i=nn(e,"backchannel_authentication_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==r?void 0:r[Tt])),a=new URLSearchParams(o);a.set("client_id",t.client_id);const s=Nt(null==r?void 0:r.headers);return s.set("accept","application/json"),fn(e,t,n,i,a,s,r)}(o,r,i,t,{[At]:a,[Tt]:!s,headers:new Headers(Bo),signal:Ir(c)}).then(e=>async function(e,t,n){if(Yt(e),qt(t),!gt(n,Response))throw kt('"response" must be an instance of Response',bt);await hn(n,200,"Backchannel Authentication Endpoint"),Zn(n);const o=await Bn(n);Jt(o.auth_req_id,'"response" body "auth_req_id" property',Wn,{body:o});let r="number"!=typeof o.expires_in?parseFloat(o.expires_in):o.expires_in;return Dt(r,!0,'"response" body "expires_in" property',Wn,{body:o}),o.expires_in=r,void 0!==o.interval&&Dt(o.interval,!1,'"response" body "interval" property',Wn,{body:o}),o}(o,r,e)).catch(dr)}async function br(e,t,n,o){var r,i;Ar(e),n=new URLSearchParams(n);let a=null!==(r=t.interval)&&void 0!==r?r:5;const s=null!==(i=null==o?void 0:o.signal)&&void 0!==i?i:AbortSignal.timeout(1e3*t.expires_in);try{await gr(a,s)}catch(e){dr(e)}const c=rr(e),u=c.as,l=c.c,h=c.auth,d=c.fetch,p=c.tlsOnly,f=c.nonRepudiation,m=c.timeout,w=c.decrypt,g=(r,i)=>br(e,y(y({},t),{},{interval:r}),n,y(y({},o),{},{signal:s,flag:i})),v=function(e,t){const n=Ir(t);if(!n)return{signal:e,cleanup(){}};const o=new AbortController,r=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",r,{once:!0}),n.addEventListener("abort",r,{once:!0})),{signal:o.signal,cleanup(){e.removeEventListener("abort",r),n.removeEventListener("abort",r)}}}(s,m),b=await async function(e,t,n,o,r){Yt(e),qt(t),Jt(o,'"authReqId"');const i=new URLSearchParams(null==r?void 0:r.additionalParameters);return i.set("auth_req_id",o),mn(e,t,n,"urn:openid:params:grant-type:ciba",i,r)}(u,l,h,t.auth_req_id,{[At]:d,[Tt]:!p,additionalParameters:n,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Bo),signal:v.signal}).catch(dr).finally(v.cleanup);var k;if(503===b.status&&b.headers.has("retry-after"))return await wr(b,a,s,!0),await(null===(k=b.body)||void 0===k?void 0:k.cancel()),g(a);const _=async function(e,t,n,o){return vn(e,t,n,void 0,null==o?void 0:o[xt],null==o?void 0:o.recognizedTokenTypes)}(u,l,b,{[xt]:w});let S;try{S=await _}catch(e){if(xr(e,o))return g(a,Rr);if(e instanceof on)switch(e.error){case"slow_down":a+=5;case"authorization_pending":return await wr(e.response,a,s),g(a)}dr(e)}return S.id_token&&await(null==f?void 0:f(b)),yr(S),S}function kr(e){rr(e).tlsOnly=!1}async function _r(e,t,n,o,r){if(Ar(e),!((null==r?void 0:r.flag)===Rr||t instanceof URL||function(e){try{return"Request"===Object.getPrototypeOf(e)[Symbol.toStringTag]}catch(e){return!1}}(t)))throw ur('"currentUrl" must be an instance of URL, or Request',cr);let i,a;const s=rr(e),c=s.as,u=s.c,l=s.auth,h=s.fetch,d=s.tlsOnly,p=s.jarm,f=s.hybrid,m=s.nonRepudiation,w=s.timeout,v=s.decrypt,b=s.implicit;if((null==r?void 0:r.flag)===Rr)i=r.authResponse,a=r.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 async function(e){if("POST"!==e.method)throw kt("form_post responses are expected to use the POST method",vt,{cause:e});if("application/x-www-form-urlencoded"!==pn(e))throw kt("form_post responses are expected to use the application/x-www-form-urlencoded content-type",vt,{cause:e});return async function(e){if(e.bodyUsed)throw kt("form_post Request instances must contain a readable body",vt,{cause:e});return e.text()}(e)}(e));if(f)t.hash=n.toString();else for(const e of n.entries()){var k=g(e,2);const n=k[0],o=k[1];t.searchParams.append(n,o)}break;default:throw ur("unexpected Request HTTP method",sr)}}switch(a=function(e){return(e=new URL(e)).search="",e.hash="",e.href}(t),!0){case!!p:i=await p(t,null==n?void 0:n.expectedState);break;case!!f:i=await f(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{i=function(e,t,n,o){if(Yt(e),qt(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw kt('"parameters" must be an instance of URLSearchParams, or URL',bt);if(Gn(n,"response"))throw Ut('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',Wn,{parameters:n});const r=Gn(n,"iss"),i=Gn(n,"state");if(!r&&e.authorization_response_iss_parameter_supported)throw Ut('response parameter "iss" (issuer) missing',Wn,{parameters:n});if(r&&r!==e.issuer)throw Ut('unexpected "iss" (issuer) response parameter value',Wn,{expected:e.issuer,parameters:n});switch(o){case void 0:case qn:if(void 0!==i)throw Ut('unexpected "state" response parameter encountered',Wn,{expected:void 0,parameters:n});break;case Yn:break;default:if(Jt(o,'"expectedState" argument'),i!==o)throw Ut(void 0===i?'response parameter "state" missing':'unexpected "state" response parameter value',Wn,{expected:o,parameters:n})}if(Gn(n,"error"))throw new rn("authorization response from the server is an error",{cause:n});const a=Gn(n,"id_token"),s=Gn(n,"token");if(void 0!==a||void 0!==s)throw new jt("implicit and hybrid flows are not supported");return c=new URLSearchParams(n),_n.add(c),c;var c}(c,u,t.searchParams,null==n?void 0:n.expectedState)}catch(e){dr(e)}}}const _=await async function(e,t,n,o,r,i,a){if(Yt(e),qt(t),!_n.has(o))throw kt('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',vt);Jt(r,'"redirectUri"');const s=Gn(o,"code");if(!s)throw Ut('no authorization code in "callbackParameters"',Wn);const c=new URLSearchParams(null==a?void 0:a.additionalParameters);return c.set("redirect_uri",r),c.set("code",s),i!==Sn&&(Jt(i,'"codeVerifier"'),c.set("code_verifier",i)),mn(e,t,n,"authorization_code",c,a)}(c,u,l,i,a,(null==n?void 0:n.pkceCodeVerifier)||Sn,{additionalParameters:o,[At]:h,[Tt]:!d,DPoP:null==r?void 0:r.DPoP,headers:new Headers(Bo),signal:Ir(w)}).catch(dr);"string"!=typeof(null==n?void 0:n.expectedNonce)&&"number"!=typeof(null==n?void 0:n.maxAge)||(n.idTokenExpected=!0);const S=async function(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,r,i,a){const s=[];switch(o){case void 0:o=En;break;case En:break;default:Jt(o,'"expectedNonce" argument'),s.push("nonce")}switch(r??=t.default_max_age,r){case void 0:r=An;break;case An:break;default:Dt(r,!0,'"maxAge" argument'),s.push("auth_time")}const c=await vn(e,t,n,s,i,a);Jt(c.id_token,'"response" body "id_token" property',Wn,{body:c});const u=gn(c);if(r!==An){const e=Gt()+Vt(t),n=Xt(t);if(u.auth_time+r<e-n)throw Ut("too much time has elapsed since the last End-User authentication",Nn,{claims:u,now:e,tolerance:n,claim:"auth_time"})}if(o===En){if(void 0!==u.nonce)throw Ut('unexpected ID Token "nonce" claim value',zn,{expected:void 0,claims:u,claim:"nonce"})}else if(u.nonce!==o)throw Ut('unexpected ID Token "nonce" claim value',zn,{expected:o,claims:u,claim:"nonce"});return c}(e,t,n,o.expectedNonce,o.maxAge,o[xt],o.recognizedTokenTypes):async function(e,t,n,o,r){const i=await vn(e,t,n,void 0,o,r),a=gn(i);if(a){if(void 0!==t.default_max_age){Dt(t.default_max_age,!0,'"client.default_max_age"');const e=Gt()+Vt(t),n=Xt(t);if(a.auth_time+t.default_max_age<e-n)throw Ut("too much time has elapsed since the last End-User authentication",Nn,{claims:a,now:e,tolerance:n,claim:"auth_time"})}if(void 0!==a.nonce)throw Ut('unexpected ID Token "nonce" claim value',zn,{expected:void 0,claims:a,claim:"nonce"})}return i}(e,t,n,null==o?void 0:o[xt],null==o?void 0:o.recognizedTokenTypes)}(c,u,_,{expectedNonce:null==n?void 0:n.expectedNonce,maxAge:null==n?void 0:n.maxAge,requireIdToken:null==n?void 0:n.idTokenExpected,[xt]:v});let T;try{T=await S}catch(t){if(xr(t,r))return _r(e,void 0,n,o,y(y({},r),{},{flag:Rr,authResponse:i,redirectUri:a}));dr(t)}return T.id_token&&await(null==m?void 0:m(_)),yr(T),T}async function Sr(e,t,n,o){Ar(e),n=new URLSearchParams(n);const r=rr(e),i=r.as,a=r.c,s=r.auth,c=r.fetch,u=r.tlsOnly,l=r.nonRepudiation,h=r.timeout,d=r.decrypt,p=await async function(e,t,n,o,r){Yt(e),qt(t),Jt(o,'"refreshToken"');const i=new URLSearchParams(null==r?void 0:r.additionalParameters);return i.set("refresh_token",o),mn(e,t,n,"refresh_token",i,r)}(i,a,s,t,{[At]:c,[Tt]:!u,additionalParameters:n,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Bo),signal:Ir(h)}).catch(dr),f=async function(e,t,n,o){return vn(e,t,n,void 0,null==o?void 0:o[xt],null==o?void 0:o.recognizedTokenTypes)}(i,a,p,{[xt]:d});let m;try{m=await f}catch(r){if(xr(r,o))return Sr(e,t,n,y(y({},o),{},{flag:Rr}));dr(r)}return m.id_token&&await(null==l?void 0:l(p)),yr(m),m}async function Tr(e,t,n){Ar(e),t=new URLSearchParams(t);const o=rr(e),r=o.as,i=o.c,a=o.auth,s=o.fetch,c=o.tlsOnly,u=o.timeout,l=async function(e,t,n){return vn(e,t,n,void 0,void 0,void 0)}(r,i,await async function(e,t,n,o,r){return Yt(e),qt(t),mn(e,t,n,"client_credentials",new URLSearchParams(o),r)}(r,i,a,t,{[At]:s,[Tt]:!c,DPoP:null==n?void 0:n.DPoP,headers:new Headers(Bo),signal:Ir(u)}).catch(dr));let h;try{h=await l}catch(o){if(xr(o,n))return Tr(e,t,y(y({},n),{},{flag:Rr}));dr(o)}return yr(h),h}function Pr(e,t){Ar(e);const n=rr(e),o=n.as,r=n.c,i=n.tlsOnly,a=n.hybrid,s=n.jarm,c=n.implicit,u=nn(o,"authorization_endpoint",!1,i);if((t=new URLSearchParams(t)).has("client_id")||t.set("client_id",r.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",a?"code id_token":c?"id_token":"code"),c&&!t.has("nonce"))throw ur("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",sr);s&&t.set("response_mode","jwt")}for(const h of t.entries()){var l=g(h,2);const e=l[0],t=l[1];u.searchParams.append(e,t)}return u}async function Er(e,t,n){Ar(e);const o=Pr(e,t),r=rr(e),i=r.as,a=r.c,s=r.auth,c=r.fetch,u=r.tlsOnly,l=r.timeout,h=async function(e,t,n){if(Yt(e),qt(t),!gt(n,Response))throw kt('"response" must be an instance of Response',bt);await hn(n,201,"Pushed Authorization Request Endpoint"),Zn(n);const o=await Bn(n);Jt(o.request_uri,'"response" body "request_uri" property',Wn,{body:o});let r="number"!=typeof o.expires_in?parseFloat(o.expires_in):o.expires_in;return Dt(r,!0,'"response" body "expires_in" property',Wn,{body:o}),o.expires_in=r,o}(i,a,await async function(e,t,n,o,r){var i;Yt(e),qt(t);const a=nn(e,"pushed_authorization_request_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==r?void 0:r[Tt])),s=new URLSearchParams(o);s.set("client_id",t.client_id);const c=Nt(null==r?void 0:r.headers);c.set("accept","application/json"),void 0!==(null==r?void 0:r.DPoP)&&(dn(r.DPoP),await r.DPoP.addProof(a,c,"POST"));const u=await fn(e,t,n,a,s,c,r);return null==r||null===(i=r.DPoP)||void 0===i||i.cacheNonce(u,a),u}(i,a,s,o.searchParams,{[At]:c,[Tt]:!u,DPoP:null==n?void 0:n.DPoP,headers:new Headers(Bo),signal:Ir(l)}).catch(dr));let d;try{d=await h}catch(o){if(xr(o,n))return Er(e,t,y(y({},n),{},{flag:Rr}));dr(o)}return Pr(e,{request_uri:d.request_uri})}function Ar(e){if(!(e instanceof mr))throw ur('"config" must be an instance of Configuration',cr);if(Object.getPrototypeOf(e)!==mr.prototype)throw ur("subclassing Configuration is not allowed",sr)}function Ir(e){return e?AbortSignal.timeout(1e3*e):void 0}function xr(e,t){return!(null==t||!t.DPoP||t.flag===Rr)&&function(e){if(e instanceof an){const t=e.cause,n=t[0];return 1===t.length&&"dpop"===n.scheme&&"use_dpop_nonce"===n.parameters.error}return e instanceof on&&"use_dpop_nonce"===e.error}(e)}Object.freeze(mr.prototype);var Rr=Symbol();async function Or(e,t,n,o){Ar(e);const r=rr(e),i=r.as,a=r.c,s=r.auth,c=r.fetch,u=r.tlsOnly,l=r.timeout,h=r.decrypt,d=r.nonRepudiation,p=await async function(e,t,n,o,r,i){return Yt(e),qt(t),Jt(o,'"grantType"'),mn(e,t,n,o,new URLSearchParams(r),i)}(i,a,s,t,new URLSearchParams(n),{[At]:c,[Tt]:!u,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Bo),signal:Ir(l)}).catch(dr);let f;"urn:ietf:params:oauth:grant-type:token-exchange"===t&&(f={n_a:()=>{}});const m=async function(e,t,n,o){return vn(e,t,n,void 0,null==o?void 0:o[xt],null==o?void 0:o.recognizedTokenTypes)}(i,a,p,{[xt]:h,recognizedTokenTypes:f});let w;try{w=await m}catch(r){if(xr(r,o))return Or(e,t,n,y(y({},o),{},{flag:Rr}));dr(r)}return w.id_token&&await(null==d?void 0:d(p)),yr(w),w}var Cr=e=>Math.floor(e.getTime()/1e3),Wr=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function jr(e){const t=Wr.exec(e);if(!t||t[4]&&t[1])throw new TypeError("Invalid time period format");const n=parseFloat(t[2]);let o;switch(t[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(60*n);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(3600*n);break;case"day":case"days":case"d":o=Math.round(86400*n);break;case"week":case"weeks":case"w":o=Math.round(604800*n);break;default:o=Math.round(31557600*n)}return"-"===t[1]||"ago"===t[4]?-o:o}function Kr(e,t){if(!Number.isFinite(t))throw new TypeError("Invalid ".concat(e," input"));return t}var Ur=e=>e.includes("/")?e.toLowerCase():"application/".concat(e.toLowerCase());function Lr(e,t){let n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{n=JSON.parse(to.decode(t))}catch(e){}if(!Ro(n))throw new vo("JWT Claims Set must be a top-level JSON object");const r=o.typ;if(r&&("string"!=typeof e.typ||Ur(e.typ)!==Ur(r)))throw new fo('unexpected "typ" JWT header value',n,"typ","check_failed");const i=o.requiredClaims,a=void 0===i?[]:i,s=o.issuer,c=o.subject,u=o.audience,l=o.maxTokenAge,h=[...a];void 0!==l&&h.push("iat"),void 0!==u&&h.push("aud"),void 0!==c&&h.push("sub"),void 0!==s&&h.push("iss");for(const w of new Set(h.reverse()))if(!(w in n))throw new fo('missing required "'.concat(w,'" claim'),n,w,"missing");if(s&&!(Array.isArray(s)?s:[s]).includes(n.iss))throw new fo('unexpected "iss" claim value',n,"iss","check_failed");if(c&&n.sub!==c)throw new fo('unexpected "sub" claim value',n,"sub","check_failed");if(u&&(p="string"==typeof u?[u]:u,!("string"==typeof(d=n.aud)?p.includes(d):Array.isArray(d)&&p.some(Set.prototype.has.bind(new Set(d))))))throw new fo('unexpected "aud" claim value',n,"aud","check_failed");var d,p;let f;switch(typeof o.clockTolerance){case"string":f=jr(o.clockTolerance);break;case"number":f=o.clockTolerance;break;case"undefined":f=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const m=o.currentDate,y=Cr(m||new Date);if((void 0!==n.iat||l)&&"number"!=typeof n.iat)throw new fo('"iat" claim must be a number',n,"iat","invalid");if(void 0!==n.nbf){if("number"!=typeof n.nbf)throw new fo('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>y+f)throw new fo('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(void 0!==n.exp){if("number"!=typeof n.exp)throw new fo('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=y-f)throw new mo('"exp" claim timestamp check failed',n,"exp","check_failed")}if(l){const e=y-n.iat;if(e-f>("number"==typeof l?l:jr(l)))throw new mo('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(e<0-f)throw new fo('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n}var Nr=new WeakMap,zr=class{constructor(e){if(h(this,Nr,void 0),!Ro(e))throw new TypeError("JWT Claims Set MUST be an object");d(Nr,this,structuredClone(e))}data(){return eo.encode(JSON.stringify(l(Nr,this)))}get iss(){return l(Nr,this).iss}set iss(e){l(Nr,this).iss=e}get sub(){return l(Nr,this).sub}set sub(e){l(Nr,this).sub=e}get aud(){return l(Nr,this).aud}set aud(e){l(Nr,this).aud=e}set jti(e){l(Nr,this).jti=e}set nbf(e){"number"==typeof e?l(Nr,this).nbf=Kr("setNotBefore",e):e instanceof Date?l(Nr,this).nbf=Kr("setNotBefore",Cr(e)):l(Nr,this).nbf=Cr(new Date)+jr(e)}set exp(e){"number"==typeof e?l(Nr,this).exp=Kr("setExpirationTime",e):e instanceof Date?l(Nr,this).exp=Kr("setExpirationTime",Cr(e)):l(Nr,this).exp=Cr(new Date)+jr(e)}set iat(e){void 0===e?l(Nr,this).iat=Cr(new Date):e instanceof Date?l(Nr,this).iat=Kr("setIssuedAt",Cr(e)):l(Nr,this).iat=Kr("setIssuedAt","string"==typeof e?Cr(new Date)+jr(e):e)}};async function Mr(e,t,n){var o;const r=await async function(e,t,n){if(e instanceof Uint8Array&&(e=to.decode(e)),"string"!=typeof e)throw new go("Compact JWS must be a string or Uint8Array");const o=e.split("."),r=o[0],i=o[1],a=o[2];if(3!==o.length)throw new go("Invalid Compact JWS");const s=await async function(e,t,n){if(!Ro(e))throw new go("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new go('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new go("JWS Protected Header incorrect type");if(void 0===e.payload)throw new go("JWS Payload missing");if("string"!=typeof e.signature)throw new go("JWS Signature missing or incorrect type");if(void 0!==e.header&&!Ro(e.header))throw new go("JWS Unprotected Header incorrect type");let o={};if(e.protected)try{const t=io(e.protected);o=JSON.parse(to.decode(t))}catch(e){throw new go("JWS Protected Header is invalid")}if(!Oo(o,e.header))throw new go("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const r=y(y({},o),e.header);let i=!0;if(Go(go,new Map([["b64",!0]]),null==n?void 0:n.crit,o,r).has("b64")&&(i=o.b64,"boolean"!=typeof i))throw new go('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const a=r.alg;if("string"!=typeof a||!a)throw new go('JWS "alg" (Algorithm) Header Parameter missing or invalid');const s=n&&function(e,t){if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw new TypeError('"'.concat("algorithms",'" option must be an array of strings'));if(t)return new Set(t)}(0,n.algorithms);if(s&&!s.has(a))throw new yo('"alg" (Algorithm) Header Parameter value not allowed');if(i){if("string"!=typeof e.payload)throw new go("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new go("JWS Payload must be a string or an Uint8Array instance");let c=!1;"function"==typeof t&&(t=await t(o,e),c=!0),tr(a,t,"verify");const u=no(void 0!==e.protected?oo(e.protected):new Uint8Array,oo("."),"string"==typeof e.payload?i?oo(e.payload):eo.encode(e.payload):e.payload),l=xo(e.signature,"signature",go),h=await Do(t,a);if(!(await async function(e,t,n,o){const r=await Ko(e,t,"verify");Wo(e,r);const i=jo(e,r.algorithm);try{return await crypto.subtle.verify(i,r,n,o)}catch(e){return!1}}(a,h,l,u)))throw new To;let d;d=i?xo(e.payload,"payload",go):"string"==typeof e.payload?eo.encode(e.payload):e.payload;const p={payload:d};return void 0!==e.protected&&(p.protectedHeader=o),void 0!==e.header&&(p.unprotectedHeader=e.header),c?y(y({},p),{},{key:h}):p}({payload:i,protected:r,signature:a},t,n),c={payload:s.payload,protectedHeader:s.protectedHeader};return"function"==typeof t?y(y({},c),{},{key:s.key}):c}(e,t,n);if(null!==(o=r.protectedHeader.crit)&&void 0!==o&&o.includes("b64")&&!1===r.protectedHeader.b64)throw new vo("JWTs MUST NOT use unencoded payload");const i={payload:Lr(r.protectedHeader,r.payload,n),protectedHeader:r.protectedHeader};return"function"==typeof t?y(y({},i),{},{key:r.key}):i}var Dr,Jr,Hr=new WeakMap,Zr=new WeakMap,Fr=new WeakMap,Vr=class{constructor(e){if(h(this,Hr,void 0),h(this,Zr,void 0),h(this,Fr,void 0),!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");d(Hr,this,e)}setProtectedHeader(e){return Io(l(Zr,this),"setProtectedHeader"),d(Zr,this,e),this}setUnprotectedHeader(e){return Io(l(Fr,this),"setUnprotectedHeader"),d(Fr,this,e),this}async sign(e,t){if(!l(Zr,this)&&!l(Fr,this))throw new go("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Oo(l(Zr,this),l(Fr,this)))throw new go("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const n=y(y({},l(Zr,this)),l(Fr,this));let o=!0;if(Go(go,new Map([["b64",!0]]),null==t?void 0:t.crit,l(Zr,this),n).has("b64")&&(o=l(Zr,this).b64,"boolean"!=typeof o))throw new go('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const r=n.alg;if("string"!=typeof r||!r)throw new go('JWS "alg" (Algorithm) Header Parameter missing or invalid');let i,a,s,c;tr(r,e,"sign"),o?(i=ao(l(Hr,this)),a=oo(i)):(a=l(Hr,this),i=""),l(Zr,this)?(s=ao(JSON.stringify(l(Zr,this))),c=oo(s)):(s="",c=new Uint8Array);const u=no(c,oo("."),a),h={signature:ao(await async function(e,t,n){const o=await Ko(e,t,"sign");Wo(e,o);const r=await crypto.subtle.sign(jo(e,o.algorithm),o,n);return new Uint8Array(r)}(r,await Do(e,r),u)),payload:i};return l(Fr,this)&&(h.header=l(Fr,this)),l(Zr,this)&&(h.protected=s),h}},Xr=new WeakMap,Gr=class{constructor(e){h(this,Xr,void 0),d(Xr,this,new Vr(e))}setProtectedHeader(e){return l(Xr,this).setProtectedHeader(e),this}async sign(e,t){const n=await l(Xr,this).sign(e,t);if(void 0===n.payload)throw new TypeError("use the flattened module for creating JWS with b64: false");return"".concat(n.protected,".").concat(n.payload,".").concat(n.signature)}},Yr=new WeakMap,qr=new WeakMap,Br=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};h(this,Yr,void 0),h(this,qr,void 0),d(qr,this,new zr(e))}setIssuer(e){return l(qr,this).iss=e,this}setSubject(e){return l(qr,this).sub=e,this}setAudience(e){return l(qr,this).aud=e,this}setJti(e){return l(qr,this).jti=e,this}setNotBefore(e){return l(qr,this).nbf=e,this}setExpirationTime(e){return l(qr,this).exp=e,this}setIssuedAt(e){return l(qr,this).iat=e,this}setProtectedHeader(e){return d(Yr,this,e),this}async sign(e,t){var n;const o=new Gr(l(qr,this).data());if(o.setProtectedHeader(l(Yr,this)),Array.isArray(null===(n=l(Yr,this))||void 0===n?void 0:n.crit)&&l(Yr,this).crit.includes("b64")&&!1===l(Yr,this).b64)throw new vo("JWTs MUST NOT use unencoded payload");return o.sign(e,t)}};function Qr(e){return Ro(e)}var $r,ei=new WeakMap,ti=new WeakMap,ni=class{constructor(e){if(h(this,ei,void 0),h(this,ti,new WeakMap),!function(e){return e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(Qr)}(e))throw new bo("JSON Web Key Set malformed");d(ei,this,structuredClone(e))}jwks(){return l(ei,this)}async getKey(e,t){const n=y(y({},e),null==t?void 0:t.header),o=n.alg,r=n.kid,i=function(e){switch("string"==typeof e&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";case"ML":return"AKP";default:throw new wo('Unsupported "alg" value for a JSON Web Key Set')}}(o),a=l(ei,this).keys.filter(e=>{let t=i===e.kty;if(t&&"string"==typeof r&&(t=r===e.kid),!t||"string"!=typeof e.alg&&"AKP"!==i||(t=o===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t)switch(o){case"ES256":t="P-256"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv;break;case"Ed25519":case"EdDSA":t="Ed25519"===e.crv}return t}),s=a[0],u=a.length;if(0===u)throw new ko;if(1!==u){const e=new _o,t=l(ti,this);throw e[Symbol.asyncIterator]=function(e){return function(){return new v(e.apply(this,arguments))}}(function*(){for(const n of a)try{yield yield c(oi(t,n,o))}catch(e){}}),e}return oi(l(ti,this),s,o)}};async function oi(e,t,n){const o=e.get(t)||e.set(t,{}).get(t);if(void 0===o[n]){const e=await async function(e,t){if(!Ro(e))throw new TypeError("JWK must be an object");let n;switch(t??=e.alg,n??=e.ext,e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return io(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new wo('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return Lo(y(y({},e),{},{alg:t,ext:n}));case"AKP":if("string"!=typeof e.alg||!e.alg)throw new TypeError('missing "alg" (Algorithm) Parameter value');if(void 0!==t&&t!==e.alg)throw new TypeError("JWK alg and alg option value mismatch");return Lo(y(y({},e),{},{ext:n}));case"EC":case"OKP":return Lo(y(y({},e),{},{alg:t,ext:n}));default:throw new wo('Unsupported "kty" (Key Type) Parameter value')}}(y(y({},t),{},{ext:!0}),n);if(e instanceof Uint8Array||"public"!==e.type)throw new bo("JSON Web Key Set members must be public keys");o[n]=e}return o[n]}function ri(e){const t=new ni(e),n=async(e,n)=>t.getKey(e,n);return Object.defineProperties(n,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),n}"undefined"!=typeof navigator&&null!==(Dr=navigator.userAgent)&&void 0!==Dr&&null!==(Jr=Dr.startsWith)&&void 0!==Jr&&Jr.call(Dr,"Mozilla/5.0 ")||($r="".concat("jose","/").concat("v6.2.3"));var ii,ai,si,ci,ui,li,hi,di,pi,fi,mi,yi,wi,gi,vi,bi,ki,_i,Si,Ti,Pi,Ei,Ai,Ii,xi,Ri,Oi,Ci,Wi,ji,Ki,Ui,Li,Ni,zi=Symbol(),Mi=Symbol(),Di=new WeakMap,Ji=new WeakMap,Hi=new WeakMap,Zi=new WeakMap,Fi=new WeakMap,Vi=new WeakMap,Xi=new WeakMap,Gi=new WeakMap,Yi=new WeakMap,qi=new WeakMap,Bi=class{constructor(e,t){if(h(this,Di,void 0),h(this,Ji,void 0),h(this,Hi,void 0),h(this,Zi,void 0),h(this,Fi,void 0),h(this,Vi,void 0),h(this,Xi,void 0),h(this,Gi,void 0),h(this,Yi,void 0),h(this,qi,void 0),!(e instanceof URL))throw new TypeError("url must be an instance of URL");var n,o;d(Di,this,new URL(e.href)),d(Ji,this,"number"==typeof(null==t?void 0:t.timeoutDuration)?null==t?void 0:t.timeoutDuration:5e3),d(Hi,this,"number"==typeof(null==t?void 0:t.cooldownDuration)?null==t?void 0:t.cooldownDuration:3e4),d(Zi,this,"number"==typeof(null==t?void 0:t.cacheMaxAge)?null==t?void 0:t.cacheMaxAge:6e5),d(Xi,this,new Headers(null==t?void 0:t.headers)),$r&&!l(Xi,this).has("User-Agent")&&l(Xi,this).set("User-Agent",$r),l(Xi,this).has("accept")||(l(Xi,this).set("accept","application/json"),l(Xi,this).append("accept","application/jwk-set+json")),d(Gi,this,null==t?void 0:t[zi]),void 0!==(null==t?void 0:t[Mi])&&(d(qi,this,null==t?void 0:t[Mi]),n=null==t?void 0:t[Mi],o=l(Zi,this),"object"==typeof n&&null!==n&&"uat"in n&&"number"==typeof n.uat&&!(Date.now()-n.uat>=o)&&"jwks"in n&&Ro(n.jwks)&&Array.isArray(n.jwks.keys)&&Array.prototype.every.call(n.jwks.keys,Ro)&&(d(Fi,this,l(qi,this).uat),d(Yi,this,ri(l(qi,this).jwks))))}pendingFetch(){return!!l(Vi,this)}coolingDown(){return"number"==typeof l(Fi,this)&&Date.now()<l(Fi,this)+l(Hi,this)}fresh(){return"number"==typeof l(Fi,this)&&Date.now()<l(Fi,this)+l(Zi,this)}jwks(){var e;return null===(e=l(Yi,this))||void 0===e?void 0:e.jwks()}async getKey(e,t){l(Yi,this)&&this.fresh()||await this.reload();try{return await l(Yi,this).call(this,e,t)}catch(r){if(r instanceof ko&&!1===this.coolingDown())return await this.reload(),l(Yi,this).call(this,e,t);throw r}}async reload(){l(Vi,this)&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&d(Vi,this,void 0),l(Vi,this)||d(Vi,this,async function(e,t,n){const o=await(arguments.length>3&&void 0!==arguments[3]?arguments[3]:fetch)(e,{method:"GET",signal:n,redirect:"manual",headers:t}).catch(e=>{if("TimeoutError"===e.name)throw new So;throw e});if(200!==o.status)throw new po("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await o.json()}catch(e){throw new po("Failed to parse the JSON Web Key Set HTTP response as JSON")}}(l(Di,this).href,l(Xi,this),AbortSignal.timeout(l(Ji,this)),l(Gi,this)).then(e=>{d(Yi,this,ri(e)),l(qi,this)&&(l(qi,this).uat=Date.now(),l(qi,this).jwks=e),d(Fi,this,Date.now()),d(Vi,this,void 0)}).catch(e=>{throw d(Vi,this,void 0),e})),await l(Vi,this)}},Qi=["mfaToken"],$i=["mfaToken"];function ea(e){var t,n;if("object"!=typeof e||null===e)return{error:"unknown_error",error_description:String(e)};const o=e,r={error:null!==(t=o.error)&&void 0!==t?t:"",error_description:null!==(n=o.error_description)&&void 0!==n?n:"",message:o.message};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 ta=class extends Error{constructor(e,t){super(t),f(this,"code",void 0),this.name="NotSupportedError",this.code=e}},na=class extends Error{constructor(e,t,n){super(t),f(this,"cause",void 0),f(this,"code",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}}},oa=class extends na{constructor(e,t){super("token_by_code_error",e,t),this.name="TokenByCodeError"}},ra=class extends na{constructor(e,t){super("token_by_client_credentials_error",e,t),this.name="TokenByClientCredentialsError"}},ia=class extends na{constructor(e,t){super("token_by_refresh_token_error",e,t),this.name="TokenByRefreshTokenError"}},aa=class extends na{constructor(e,t){super("token_by_password_error",e,t),this.name="TokenByPasswordError"}},sa=class extends na{constructor(e,t){super("token_for_connection_error",e,t),this.name="TokenForConnectionErrorCode"}},ca=class extends na{constructor(e,t){super("token_exchange_error",e,t),this.name="TokenExchangeError"}},ua=class extends na{constructor(e,t){super("token_revocation_error",e,t),this.name="TokenRevocationError"}},la=class extends Error{constructor(e){super(e),f(this,"code","verify_logout_token_error"),this.name="VerifyLogoutTokenError"}},ha=class extends na{constructor(e){super("backchannel_authentication_error","There was an error when trying to use Client-Initiated Backchannel Authentication.",e),f(this,"code","backchannel_authentication_error"),this.name="BackchannelAuthenticationError"}},da=class extends na{constructor(e){super("build_authorization_url_error","There was an error when trying to build the authorization URL.",e),this.name="BuildAuthorizationUrlError"}},pa=class extends na{constructor(e){super("build_link_user_url_error","There was an error when trying to build the Link User URL.",e),this.name="BuildLinkUserUrlError"}},fa=class extends na{constructor(e){super("build_unlink_user_url_error","There was an error when trying to build the Unlink User URL.",e),this.name="BuildUnlinkUserUrlError"}},ma=class extends Error{constructor(){super("The client secret or client assertion signing key must be provided."),f(this,"code","missing_client_auth_error"),this.name="MissingClientAuthError"}},ya=class extends Error{constructor(e){super(e),f(this,"code","organization_validation_error"),this.name="OrganizationValidationError"}};function wa(e){return Object.entries(e).filter(e=>void 0!==g(e,2)[1]).reduce((e,t)=>y(y({},e),{},{[t[0]]:t[1]}),{})}function ga(e){if(!e.trim())throw new ya("organization must not be blank")}function va(e,t){if(!e)return;const n=t.trim();if(n.startsWith("org_")){const t=e.org_id;if("string"!=typeof t)throw new ya("Organization Id (org_id) claim must be a string present in the ID token");if(t!==n)throw new ya('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 ya("Organization Name (org_name) claim must be a string present in the ID token");if(t.toLowerCase()!==n.toLowerCase())throw new ya('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),f(this,"cause",void 0),f(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},ka=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"}},Sa=class extends ba{constructor(e,t){super("mfa_delete_authenticator_error",e,t),this.name="MfaDeleteAuthenticatorError"}},Ta=class extends ba{constructor(e,t){super("mfa_challenge_error",e,t),this.name="MfaChallengeError"}},Pa=class extends ba{constructor(e,t){super("mfa_verify_error",e,t),this.name="MfaVerifyError"}};function Ea(e){return{id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var Aa=class e{constructor(e,t,n,o,r,i,a){f(this,"accessToken",void 0),f(this,"idToken",void 0),f(this,"refreshToken",void 0),f(this,"expiresAt",void 0),f(this,"scope",void 0),f(this,"claims",void 0),f(this,"authorizationDetails",void 0),f(this,"tokenType",void 0),f(this,"issuedTokenType",void 0),f(this,"recoveryCode",void 0),f(this,"act",void 0),this.accessToken=e,this.idToken=n,this.refreshToken=o,this.expiresAt=t,this.scope=r,this.claims=i,this.authorizationDetails=a}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}},Ia={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"},xa=(ii=new WeakMap,ai=new WeakMap,si=new WeakMap,ci=new WeakMap,ui=new WeakMap,class{constructor(e){var t;h(this,ii,void 0),h(this,ai,void 0),h(this,si,void 0),h(this,ci,void 0),h(this,ui,void 0),d(ii,this,"https://".concat(e.domain)),d(ai,this,e.clientId),d(si,this,e.clientSecret),d(ci,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),d(ui,this,e.getConfiguration)}async listAuthenticators(e){const t="".concat(l(ii,this),"/mfa/authenticators"),n=e.mfaToken,o=await l(ci,this).call(this,t,{method:"GET",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(!o.ok){let t;try{t=await o.json()}catch(e){throw new ka("Failed to list authenticators")}throw new ka(t.error_description||"Failed to list authenticators",t)}return(await o.json()).map(Ea)}async enrollAuthenticator(e){const t="".concat(l(ii,this),"/mfa/associate"),n=e.mfaToken,o=w(e,Qi),r={authenticator_types:o.authenticatorTypes};"oobChannels"in o&&(r.oob_channels=o.oobChannels),"phoneNumber"in o&&o.phoneNumber&&(r.phone_number=o.phoneNumber),"email"in o&&o.email&&(r.email=o.email);const i=await l(ci,this).call(this,t,{method:"POST",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok){let t;try{t=await i.json()}catch(e){throw new _a("Failed to enroll authenticator")}throw new _a(t.error_description||"Failed to enroll authenticator",t)}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 i.json())}async deleteAuthenticator(e){const t=e.authenticatorId,n=e.mfaToken,o="".concat(l(ii,this),"/mfa/authenticators/").concat(encodeURIComponent(t)),r=await l(ci,this).call(this,o,{method:"DELETE",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(!r.ok){let t;try{t=await r.json()}catch(e){throw new Sa("Failed to delete authenticator")}throw new Sa(t.error_description||"Failed to delete authenticator",t)}}async challengeAuthenticator(e){const t="".concat(l(ii,this),"/mfa/challenge"),n=e.mfaToken,o=w(e,$i),r={mfa_token:n,client_id:l(ai,this),challenge_type:o.challengeType};l(si,this)&&(r.client_secret=l(si,this)),o.authenticatorId&&(r.authenticator_id=o.authenticatorId);const i=await l(ci,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok){let t;try{t=await i.json()}catch(e){throw new Ta("Failed to challenge authenticator")}throw new Ta(t.error_description||"Failed to challenge authenticator",t)}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 i.json())}async verify(e){if(!l(ui,this))throw new Error("MFA verify requires a configuration provider (getConfiguration was not set)");const t=await l(ui,this).call(this),n={mfa_token:e.mfaToken};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);try{const o=await Or(t,Ia[e.factorType],n),r=Aa.fromTokenEndpointResponse(o);return o.recovery_code&&(r.recoveryCode=o.recovery_code),r}catch(e){var o,r,i;if(e instanceof Pa)throw e;const t=e;throw new Pa(t.error_description||t.message||"Failed to verify MFA challenge",{error:null!==(o=t.error)&&void 0!==o?o:"mfa_verify_error",error_description:null!==(r=null!==(i=t.error_description)&&void 0!==i?i:t.message)&&void 0!==r?r:"Failed to verify MFA challenge"})}}}),Ra=class extends Error{constructor(e,t,n){super(t),f(this,"cause",void 0),f(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},Oa=class extends Ra{constructor(e,t){super("passkey_register_error",e,t),this.name="PasskeyRegisterError"}},Ca=class extends Ra{constructor(e,t){super("passkey_challenge_error",e,t),this.name="PasskeyChallengeError"}},Wa=class extends Ra{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}}},ja="urn:okta:params:oauth:grant-type:webauthn",Ka=(li=new WeakMap,hi=new WeakMap,di=new WeakMap,pi=new WeakMap,fi=new WeakSet,class{constructor(e){var t;p(this,fi),h(this,li,void 0),h(this,hi,void 0),h(this,di,void 0),h(this,pi,void 0),d(li,this,"https://".concat(e.domain)),d(hi,this,e.clientId),d(di,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),d(pi,this,e.grantRequest)}async register(e){const t="".concat(l(li,this),"/passkey/register"),n=y(y(y(y(y(y(y(y({},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}),o={client_id:l(hi,this),user_profile:n};e.realm&&(o.realm=e.realm),e.organization&&(o.organization=e.organization),e.userMetadata&&(o.user_metadata=e.userMetadata);const r=await l(di,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){const e=await s(fi,this,Ua).call(this,r);throw new Oa(e.error_description||"Failed to request signup challenge",e)}return{authSession:(i=await r.json()).auth_session,authnParamsPublicKey:y({},i.authn_params_public_key)};var i}async challenge(e){const t="".concat(l(li,this),"/passkey/challenge"),n={client_id:l(hi,this)};null!=e&&e.realm&&(n.realm=e.realm),null!=e&&e.organization&&(n.organization=e.organization);const o=await l(di,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok){const e=await s(fi,this,Ua).call(this,o);throw new Ca(e.error_description||"Failed to request login challenge",e)}return{authSession:(r=await o.json()).auth_session,authnParamsPublicKey:y({},r.authn_params_public_key)};var r}async getTokenByPasskey(e){void 0!==e.organization&&ga(e.organization);const t=new URLSearchParams({auth_session:e.authSession,authn_response:JSON.stringify(e.credential)});let n;e.realm&&t.append("realm",e.realm),e.scope&&t.append("scope",e.scope),e.audience&&t.append("audience",e.audience),e.organization&&t.append("organization",e.organization);try{n=await l(pi,this).call(this,ja,t)}catch(e){const t=ea(e);throw new Wa(t.error_description||"Failed to exchange passkey credential for tokens.",t)}return e.organization&&va(n.claims,e.organization),n}});async function Ua(e){try{return await e.json()}catch(o){return{error:"unknown_error",error_description:"HTTP ".concat(e.status," ").concat(e.statusText)}}}var La=class extends Error{constructor(e,t,n){super(t),f(this,"cause",void 0),f(this,"code",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,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements}}},Na=class extends La{constructor(e,t){super("passwordless_start_error",e,t),this.name="PasswordlessStartError"}},za=class extends La{constructor(e,t){super("passwordless_verify_error",e,t),this.name="PasswordlessVerifyError"}},Ma=class extends La{constructor(e,t){super("passwordless_db_get_token_error",e,t),this.name="PasswordlessDbGetTokenError"}},Da=class extends La{constructor(e,t,n,o){super("passwordless_challenge_error",e,n),f(this,"statusCode",void 0),f(this,"validationErrors",void 0),this.name="PasswordlessChallengeError",this.statusCode=t,this.validationErrors=o}};function Ja(e){return/^\+[1-9]\d{1,14}$/.test(e)}async function Ha(e,t,n){if(e.useMtls)return{};if(e.clientAssertionSigningKey){var o;const r=null!==(o=e.clientAssertionSigningAlg)&&void 0!==o?o:"RS256",i=e.clientAssertionSigningKey instanceof CryptoKey?e.clientAssertionSigningKey:await Xo(e.clientAssertionSigningKey,r);return{client_assertion:await new Br({}).setProtectedHeader({alg:r}).setIssuer(t).setSubject(t).setAudience("https://".concat(n,"/")).setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime("".concat(120,"s")).sign(i),client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}}if(e.clientSecret)return{client_secret:e.clientSecret};throw new ma}var Za=(mi=new WeakMap,yi=new WeakMap,wi=new WeakMap,gi=new WeakMap,vi=new WeakMap,bi=new WeakMap,ki=new WeakSet,class{constructor(e){var t;p(this,ki),h(this,mi,void 0),h(this,yi,void 0),h(this,wi,void 0),h(this,gi,void 0),h(this,vi,void 0),h(this,bi,void 0),d(yi,this,e.domain),d(mi,this,"https://".concat(e.domain)),d(wi,this,e.clientId),d(gi,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),d(vi,this,{clientSecret:e.clientSecret,clientAssertionSigningKey:e.clientAssertionSigningKey,clientAssertionSigningAlg:e.clientAssertionSigningAlg,useMtls:e.useMtls}),d(bi,this,e.grantRequest)}async sendEmail(e){await s(ki,this,Fa).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)}async sendSms(e){if(!Ja(e.phoneNumber))throw new Na("Phone number must be in E.164 format (e.g. +14155550100).");await s(ki,this,Fa).call(this,function(e){return{phone_number:e.phoneNumber,connection:"sms"}}(e),"Failed to send passwordless SMS",e.language)}async challengeWithEmail(e){const t=function(e){var t;return{email:e.email,connection:e.connection,allow_signup:null!==(t=e.allowSignup)&&void 0!==t&&t}}(e);return s(ki,this,Va).call(this,t,"Failed to request email OTP challenge")}async challengeWithPhoneNumber(e){if(!Ja(e.phoneNumber))throw new Da("Phone number must be in E.164 format (e.g. +14155550100).",0,void 0,void 0);const t=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 s(ki,this,Va).call(this,t,"Failed to request phone OTP challenge")}async getTokenByPasswordlessDbConnection(e){const t=new URLSearchParams({auth_session:e.authSession,otp:e.otp});if(e.scope&&t.append("scope",e.scope),e.audience&&t.append("audience",e.audience),!l(bi,this))throw new Ma("Missing grant request delegate.",ea(new Error("missing grantRequest")));try{return await l(bi,this).call(this,"http://auth0.com/oauth/grant-type/passwordless/otp",t)}catch(e){throw new Ma("There was an error while trying to request a token.",ea(e))}}});async function Fa(e,t,n){var o;const r=await Ha(l(vi,this),l(wi,this),l(yi,this)),i=y(y({client_id:l(wi,this)},e),r);let a,s;try{a=await l(gi,this).call(this,"".concat(l(mi,this),"/passwordless/start"),{method:"POST",headers:y({"Content-Type":"application/json"},n?{"x-request-language":n}:{}),body:JSON.stringify(i)})}catch(e){throw new Na("".concat(t,": a network error occurred."))}if(!a.ok){if(204!==a.status)try{s=await a.json()}catch(e){s=void 0}throw new Na((null===(o=s)||void 0===o?void 0:o.error_description)||t,s)}}async function Va(e,t){var n,o;const r=await Ha(l(vi,this),l(wi,this),l(yi,this)),i=y(y({client_id:l(wi,this)},e),r);let a,s;try{a=await l(gi,this).call(this,"".concat(l(mi,this),"/otp/challenge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}catch(e){throw new Da("challenge error: a network error occurred.",0,void 0,void 0)}if(a.ok){let n;try{n=await a.json()}catch(e){throw new Da("".concat(t,": could not parse the response body."),a.status,void 0,void 0)}return{authSession:n.auth_session}}try{s=await a.json()}catch(e){s=void 0}throw new Da((null===(n=s)||void 0===n?void 0:n.error_description)||t,a.status,s,null===(o=s)||void 0===o?void 0:o.validation_errors)}var Xa=class extends Error{constructor(e,t,n){super(t),f(this,"cause",void 0),f(this,"code",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}}},Ga=class extends Xa{constructor(e,t){super("signup_error",e,t),this.name="SignUpError"}},Ya=class extends Xa{constructor(e,t){super("change_password_error",e,t),this.name="ChangePasswordError"}};function qa(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.'))}var Ba=(_i=new WeakMap,Si=new WeakMap,Ti=new WeakMap,Pi=new WeakSet,class{constructor(e){var t;p(this,Pi),h(this,_i,void 0),h(this,Si,void 0),h(this,Ti,void 0),d(_i,this,"https://".concat(e.domain)),d(Si,this,e.clientId),d(Ti,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)})}async signUp(e){var t;qa(e,["email","password","connection"],Ga);const n=y({client_id:null!==(t=e.clientId)&&void 0!==t?t:l(Si,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));return function(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}}(await(await s(Pi,this,Qa).call(this,"/dbconnections/signup",n,Ga,"Failed to sign up")).json())}async changePassword(e){var t;if(qa(e,["connection"],Ya),!e.email&&!e.username)throw new Ya('Either "email" or "username" is required.');const n=y({client_id:null!==(t=e.clientId)&&void 0!==t?t:l(Si,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));return(await s(Pi,this,Qa).call(this,"/dbconnections/change_password",n,Ya,"Failed to request a password change")).text()}});async function Qa(e,t,n,o){let r;try{r=await l(Ti,this).call(this,"".concat(l(_i,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(r.ok)return r;const i=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}(r);throw new n((null==i?void 0:i.error_description)||o,i)}var $a=(Ei=new WeakMap,Ai=new WeakMap,Ii=new WeakMap,class{constructor(e,t){h(this,Ei,new Map),h(this,Ai,void 0),h(this,Ii,void 0),d(Ii,this,Math.max(1,Math.floor(e))),d(Ai,this,Math.max(0,Math.floor(t)))}get(e){const t=l(Ei,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return l(Ei,this).delete(e),l(Ei,this).set(e,t),t.value;l(Ei,this).delete(e)}}set(e,t){for(l(Ei,this).has(e)&&l(Ei,this).delete(e),l(Ei,this).set(e,{value:t,expiresAt:Date.now()+l(Ai,this)});l(Ei,this).size>l(Ii,this);){const e=l(Ei,this).keys().next().value;if(void 0===e)break;l(Ei,this).delete(e)}}}),es=new Map;function ts(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 ns=class{static createDiscoveryCache(e){const t=(n=e.maxEntries,o=e.ttlMs,"".concat(n,":").concat(o));var n,o;let r=(i=t,es.get(i));var i;return r||(r=new $a(e.maxEntries,e.ttlMs),es.set(t,r)),r}static createJwksCache(){return{}}},os="openid profile email offline_access",rs=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 is(e){if(null==e)throw new ca("subject_token is required");if("string"!=typeof e)throw new ca("subject_token must be a string");if(0===e.trim().length)throw new ca("subject_token cannot be blank or whitespace");if(e!==e.trim())throw new ca("subject_token must not include leading or trailing whitespace");if(/^bearer\s+/i.test(e))throw new ca("subject_token must not include the 'Bearer ' prefix")}function as(e,t){if(t)for(const o of Object.entries(t)){var n=g(o,2);const t=n[0],r=n[1];if(!rs.has(t))if(Array.isArray(r)){if(r.length>20)throw new ca("Parameter '".concat(t,"' exceeds maximum array size of ").concat(20));r.forEach(n=>{e.append(t,n)})}else e.append(t,r)}}var ss="urn:ietf:params:oauth:token-type:access_token",cs=(xi=new WeakMap,Ri=new WeakMap,Oi=new WeakMap,Ci=new WeakMap,Wi=new WeakMap,ji=new WeakMap,Ki=new WeakMap,Ui=new WeakMap,Li=new WeakMap,Ni=new WeakSet,class{constructor(e){var t,n,o,r;if(p(this,Ni),h(this,xi,void 0),h(this,Ri,void 0),h(this,Oi,void 0),h(this,Ci,void 0),h(this,Wi,void 0),h(this,ji,void 0),h(this,Ki,void 0),h(this,Ui,void 0),h(this,Li,void 0),f(this,"mfa",void 0),f(this,"passkey",void 0),f(this,"passwordless",void 0),f(this,"database",void 0),d(Ci,this,e),e.useMtls&&!e.customFetch)throw new ta("mtls_without_custom_fetch_not_supported","Using mTLS without a custom fetch implementation is not supported");d(Wi,this,function(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 r=t instanceof Request?new Headers(t.headers):new Headers;return null!=n&&n.headers&&new Headers(n.headers).forEach((e,t)=>{r.set(t,e)}),r.set("Auth0-Client",o),e(t,y(y({},n),{},{headers:r}))}}(null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)},!1===(null==(n=e.telemetry)?void 0:n.enabled)?n:{enabled:!0,name:null!==(o=null==n?void 0:n.name)&&void 0!==o?o:"@auth0/auth0-auth-js",version:null!==(r=null==n?void 0:n.version)&&void 0!==r?r:"1.12.0"}));const i=ts(e.discoveryCache);d(Ki,this,ns.createDiscoveryCache(i)),d(Ui,this,new Map),d(Li,this,ns.createJwksCache()),this.mfa=new xa({domain:l(Ci,this).domain,clientId:l(Ci,this).clientId,clientSecret:l(Ci,this).clientSecret,customFetch:l(Wi,this),getConfiguration:async()=>(await s(Ni,this,hs).call(this)).configuration}),this.passkey=new Ka({domain:l(Ci,this).domain,clientId:l(Ci,this).clientId,customFetch:l(Wi,this),grantRequest:async(e,t)=>{const n=(await s(Ni,this,hs).call(this)).serverMetadata,o=await s(Ni,this,ls).call(this,n);o[ar]=function(e,t){return(n,o)=>{const r=null==o?void 0:o.body;if(t!==ja||!(r instanceof URLSearchParams))return e(n,o);const i={};for(const e of r){var a=g(e,2);const t=a[0],n=a[1];i[t]="authn_response"===t?JSON.parse(n):n}const s=new Headers(null==o?void 0:o.headers);return s.set("Content-Type","application/json"),e(n,y(y({},o),{},{headers:s,body:JSON.stringify(i)}))}}(l(Wi,this),e);const r=await Or(o,e,t);return Aa.fromTokenEndpointResponse(r)}}),this.passwordless=new Za({domain:l(Ci,this).domain,clientId:l(Ci,this).clientId,customFetch:l(Wi,this),clientSecret:l(Ci,this).clientSecret,clientAssertionSigningKey:l(Ci,this).clientAssertionSigningKey,clientAssertionSigningAlg:l(Ci,this).clientAssertionSigningAlg,useMtls:l(Ci,this).useMtls,grantRequest:async(e,t)=>{const n=(await s(Ni,this,hs).call(this)).configuration,o=await Or(n,e,t);return Aa.fromTokenEndpointResponse(o)}}),this.database=new Ba({domain:l(Ci,this).domain,clientId:l(Ci,this).clientId,customFetch:l(Wi,this)})}async getServerMetadata(){return(await s(Ni,this,hs).call(this)).serverMetadata}async buildAuthorizationUrl(e){const t=(await s(Ni,this,hs).call(this)).serverMetadata;if(null!=e&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new ta("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 s(Ni,this,ys).call(this,e)}catch(e){throw new da(e)}}async buildLinkUserUrl(e){try{const t=await s(Ni,this,ys).call(this,{authorizationParams:y(y({},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 pa(e)}}async buildUnlinkUserUrl(e){try{const t=await s(Ni,this,ys).call(this,{authorizationParams:y(y({},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 fa(e)}}async backchannelAuthentication(e){const t=await s(Ni,this,hs).call(this),n=t.configuration,o=t.serverMetadata,r=wa(y(y({},l(Ci,this).authorizationParams),null==e?void 0:e.authorizationParams)),i=new URLSearchParams(y(y({scope:os},r),{},{client_id:l(Ci,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:o.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&i.append("authorization_details",JSON.stringify(e.authorizationDetails));try{const e=await br(n,await vr(n,i));return Aa.fromTokenEndpointResponse(e)}catch(e){throw new ha(e)}}async initiateBackchannelAuthentication(e){const t=await s(Ni,this,hs).call(this),n=t.configuration,o=t.serverMetadata,r=wa(y(y({},l(Ci,this).authorizationParams),null==e?void 0:e.authorizationParams)),i=new URLSearchParams(y(y({scope:os},r),{},{client_id:l(Ci,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:o.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&i.append("authorization_details",JSON.stringify(e.authorizationDetails));try{const e=await vr(n,i);return{authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){throw new ha(e)}}async backchannelAuthenticationGrant(e){let t=e.authReqId;const n=(await s(Ni,this,hs).call(this)).configuration,o=new URLSearchParams({auth_req_id:t});try{const e=await Or(n,"urn:openid:params:grant-type:ciba",o);return Aa.fromTokenEndpointResponse(e)}catch(e){throw new ha(e)}}async getTokenForConnection(e){var t;if(e.refreshToken&&e.accessToken)throw new sa("Either a refresh or access token should be specified, but not both.");const n=null!==(t=e.accessToken)&&void 0!==t?t:e.refreshToken;if(!n)throw new sa("Either a refresh or access token must be specified.");try{return await this.exchangeToken({connection:e.connection,subjectToken:n,subjectTokenType:e.accessToken?ss:"urn:ietf:params:oauth:token-type:refresh_token",loginHint:e.loginHint})}catch(e){if(e instanceof ca)throw new sa(e.message,e.cause);throw e}}async exchangeToken(e){return"connection"in e?s(Ni,this,ds).call(this,e):s(Ni,this,ps).call(this,e)}async getTokenByCode(e,t){const n=(await s(Ni,this,hs).call(this)).configuration;let o;void 0!==t.organization&&ga(t.organization);try{const r=await _r(n,e,{pkceCodeVerifier:t.codeVerifier});o=Aa.fromTokenEndpointResponse(r)}catch(e){throw new oa("There was an error while trying to request a token.",ea(e))}return t.organization&&va(o.claims,t.organization),o}async getTokenByMagicLinkCode(e,t){const n=(await s(Ni,this,hs).call(this)).configuration;try{const o=await _r(n,e,{expectedState:null==t?void 0:t.expectedState});return Aa.fromTokenEndpointResponse(o)}catch(e){throw new oa(e instanceof Error&&e.message?e.message:"There was an error while trying to request a token.",e)}}async getTokenByRefreshToken(e){const t=(await s(Ni,this,hs).call(this)).configuration,n=new URLSearchParams;e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope);try{const o=await Sr(t,e.refreshToken,n);return Aa.fromTokenEndpointResponse(o)}catch(e){throw new ia("The access token has expired and there was an error while trying to refresh it.",ea(e))}}async revokeToken(e){const t=(await s(Ni,this,hs).call(this)).configuration,n={};e.tokenTypeHint&&(n.token_type_hint=e.tokenTypeHint);try{await async function(e,t,n){Ar(e);const o=rr(e),r=o.as,i=o.c,a=o.auth,s=o.fetch,c=o.tlsOnly,u=o.timeout;return async function(e,t,n,o,r){Yt(e),qt(t),Jt(o,'"token"');const i=nn(e,"revocation_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==r?void 0:r[Tt])),a=new URLSearchParams(null==r?void 0:r.additionalParameters);a.set("token",o);const s=Nt(null==r?void 0:r.headers);return s.delete("accept"),fn(e,t,n,i,a,s,r)}(r,i,a,t,{[At]:s,[Tt]:!c,additionalParameters:new URLSearchParams(n),headers:new Headers(Bo),signal:Ir(u)}).then(Hn).catch(dr)}(t,e.token,n)}catch(e){throw new ua("An error occurred while trying to revoke the token.",ea(e))}}async getTokenByPassword(e){const t=(await s(Ni,this,hs).call(this)).configuration,n=new URLSearchParams({username:e.username,password:e.password});e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),e.realm&&n.append("realm",e.realm);let o=t;if(e.auth0ForwardedFor){const n=await s(Ni,this,ms).call(this);o=new mr(t.serverMetadata(),l(Ci,this).clientId,l(Ci,this).clientSecret,n),o[ar]=(t,n)=>l(Wi,this).call(this,t,y(y({},n),{},{headers:y(y({},n.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}))}try{const e=await Or(o,"password",n);return Aa.fromTokenEndpointResponse(e)}catch(e){throw new aa("There was an error while trying to request a token.",ea(e))}}async getTokenByPasswordlessEmail(e){const t=new URLSearchParams({username:e.email,otp:e.code,realm:"email"});return e.audience&&t.append("audience",e.audience),e.scope&&t.append("scope",e.scope),s(Ni,this,fs).call(this,t)}async getTokenByPasswordlessSms(e){if(!Ja(e.phoneNumber))throw new za("Phone number must be in E.164 format (e.g. +14155550100).");const t=new URLSearchParams({username:e.phoneNumber,otp:e.code,realm:"sms"});return e.audience&&t.append("audience",e.audience),e.scope&&t.append("scope",e.scope),s(Ni,this,fs).call(this,t)}async getTokenByClientCredentials(e){const t=(await s(Ni,this,hs).call(this)).configuration;try{const n=new URLSearchParams({audience:e.audience});e.organization&&n.append("organization",e.organization);const o=await Tr(t,n);return Aa.fromTokenEndpointResponse(o)}catch(e){throw new ra("There was an error while trying to request a token.",ea(e))}}async buildLogoutUrl(e){const t=await s(Ni,this,hs).call(this),n=t.configuration;if(!t.serverMetadata.end_session_endpoint){const t=new URL("https://".concat(l(Ci,this).domain,"/v2/logout"));return t.searchParams.set("returnTo",e.returnTo),t.searchParams.set("client_id",l(Ci,this).clientId),t}return function(e,t){Ar(e);const n=rr(e),o=n.as,r=n.c,i=nn(o,"end_session_endpoint",!1,n.tlsOnly);(t=new URLSearchParams(t)).has("client_id")||t.set("client_id",r.client_id);for(const s of t.entries()){var a=g(s,2);const e=a[0],t=a[1];i.searchParams.append(e,t)}return i}(n,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){const t=(await s(Ni,this,hs).call(this)).serverMetadata,n=ts(l(Ci,this).discoveryCache),o=t.jwks_uri;l(ji,this)||d(ji,this,function(e,t){const n=new Bi(e,t),o=async(e,t)=>n.getKey(e,t);return Object.defineProperties(o,{coolingDown:{get:()=>n.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>n.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>n.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>n.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>n.jwks(),enumerable:!0,configurable:!1,writable:!1}}),o}(new URL(o),{cacheMaxAge:n.ttlMs,[zi]:l(Wi,this),[Mi]:l(Li,this)}));const r=(await Mr(e.logoutToken,l(ji,this),{issuer:t.issuer,audience:l(Ci,this).clientId,algorithms:["RS256"],requiredClaims:["iat"]})).payload;if(!("sid"in r)&&!("sub"in r))throw new la('either "sid" or "sub" (or both) claims must be present');if("sid"in r&&"string"!=typeof r.sid)throw new la('"sid" claim must be a string');if("sub"in r&&"string"!=typeof r.sub)throw new la('"sub" claim must be a string');if("nonce"in r)throw new la('"nonce" claim is prohibited');if(!("events"in r))throw new la('"events" claim is missing');if("object"!=typeof r.events||null===r.events)throw new la('"events" claim must be an object');if(!("http://schemas.openid.net/event/backchannel-logout"in r.events))throw new la('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim');if("object"!=typeof r.events["http://schemas.openid.net/event/backchannel-logout"])throw new la('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object');return{sid:r.sid,sub:r.sub}}});function us(){const e=l(Ci,this).domain.toLowerCase();return"".concat(e,"|mtls:").concat(l(Ci,this).useMtls?"1":"0")}async function ls(e){const t=await s(Ni,this,ms).call(this),n=new mr(e,l(Ci,this).clientId,l(Ci,this).clientSecret,t);return n[ar]=l(Wi,this),n}async function hs(){if(l(xi,this)&&l(Ri,this))return{configuration:l(xi,this),serverMetadata:l(Ri,this)};const e=s(Ni,this,us).call(this),t=l(Ki,this).get(e);if(t)return d(Ri,this,t.serverMetadata),d(xi,this,await s(Ni,this,ls).call(this,t.serverMetadata)),{configuration:l(xi,this),serverMetadata:l(Ri,this)};const n=l(Ui,this).get(e);if(n){const e=await n;return d(Ri,this,e.serverMetadata),d(xi,this,await s(Ni,this,ls).call(this,e.serverMetadata)),{configuration:l(xi,this),serverMetadata:l(Ri,this)}}const o=(async()=>{const t=await s(Ni,this,ms).call(this),n=await pr(new URL("https://".concat(l(Ci,this).domain)),l(Ci,this).clientId,{use_mtls_endpoint_aliases:l(Ci,this).useMtls},t,{[ar]:l(Wi,this)}),o=n.serverMetadata();return l(Ki,this).set(e,{serverMetadata:o}),{configuration:n,serverMetadata:o}})(),r=o.then(e=>({serverMetadata:e.serverMetadata}));r.catch(()=>{}),l(Ui,this).set(e,r);try{const e=await o,t=e.configuration,n=e.serverMetadata;d(xi,this,t),d(Ri,this,n),l(xi,this)[ar]=l(Wi,this)}finally{l(Ui,this).delete(e)}return{configuration:l(xi,this),serverMetadata:l(Ri,this)}}async function ds(e){var t,n;const o=(await s(Ni,this,hs).call(this)).configuration;if("audience"in e||"resource"in e)throw new ca("audience and resource parameters are not supported for Token Vault exchanges");is(e.subjectToken);const r=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:null!==(t=e.subjectTokenType)&&void 0!==t?t:ss,requested_token_type:null!==(n=e.requestedTokenType)&&void 0!==n?n:"http://auth0.com/oauth/token-type/federated-connection-access-token"});e.loginHint&&r.append("login_hint",e.loginHint),e.scope&&r.append("scope",e.scope),as(r,e.extra);try{const e=await Or(o,"urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",r);return Aa.fromTokenEndpointResponse(e)}catch(t){throw new ca("Failed to exchange token for connection '".concat(e.connection,"'."),ea(t))}}async function ps(e){const t=(await s(Ni,this,hs).call(this)).configuration;if(is(e.subjectToken),void 0!==e.organization&&ga(e.organization),void 0!==e.actorToken&&void 0===e.actorTokenType)throw new ca("actorTokenType is required when actorToken is provided");const n=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});let o,r;e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),e.requestedTokenType&&n.append("requested_token_type",e.requestedTokenType),e.organization&&n.append("organization",e.organization),e.actorToken&&n.append("actor_token",e.actorToken),e.actorTokenType&&n.append("actor_token_type",e.actorTokenType),as(n,e.extra);try{r=await Or(t,"urn:ietf:params:oauth:grant-type:token-exchange",n),o=Aa.fromTokenEndpointResponse(r)}catch(t){throw new ca("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),ea(t))}var i;if(e.organization&&va(o.claims,e.organization),e.actorToken)if(null!==(i=o.claims)&&void 0!==i&&i.act)o.act=o.claims.act;else try{o.act=function(e){if("string"!=typeof e)throw new vo("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 vo("Only JWTs using Compact JWS serialization can be decoded");if(3!==o)throw new vo("Invalid JWT");if(!n)throw new vo("JWTs must contain a payload");let r,i;try{r=io(n)}catch(e){throw new vo("Failed to base64url decode the payload")}try{i=JSON.parse(to.decode(r))}catch(e){throw new vo("Failed to parse the decoded payload as JSON")}if(!Ro(i))throw new vo("Invalid JWT Claims Set");return i}(r.access_token).act}catch(e){}return o}async function fs(e){const t=(await s(Ni,this,hs).call(this)).configuration;try{const n=await Or(t,"http://auth0.com/oauth/grant-type/passwordless/otp",e);return Aa.fromTokenEndpointResponse(n)}catch(e){throw new za("There was an error while trying to request a token.",ea(e))}}async function ms(){return l(Oi,this)||d(Oi,this,(async()=>{if(!l(Ci,this).clientSecret&&!l(Ci,this).clientAssertionSigningKey&&!l(Ci,this).useMtls)throw new ma;if(l(Ci,this).useMtls)return(e,t,n,o)=>{n.set("client_id",t.client_id)};let e=l(Ci,this).clientAssertionSigningKey;return!e||e instanceof CryptoKey||(e=await Xo(e,l(Ci,this).clientAssertionSigningAlg||"RS256")),e?function(e){return Qt(e,void 0)}(e):ir(l(Ci,this).clientSecret)})().catch(e=>{throw d(Oi,this,void 0),e})),l(Oi,this)}async function ys(e){const t=(await s(Ni,this,hs).call(this)).configuration,n=Zt(),o=await function(e){return async function(e){return Jt(e,"codeVerifier"),Wt(await crypto.subtle.digest("SHA-256",Ct(e)))}(e)}(n),r=wa(y(y({},l(Ci,this).authorizationParams),null==e?void 0:e.authorizationParams)),i=new URLSearchParams(y(y({scope:os},r),{},{client_id:l(Ci,this).clientId,code_challenge:o,code_challenge_method:"S256"}));return{authorizationUrl:null!=e&&e.pushedAuthorizationRequests?await Er(t,i):await Pr(t,i),codeVerifier:n}}var ws,gs,vs=class e extends A{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let n=t.error,o=t.error_description;return new e(n,o)}},bs=class e extends vs{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},ks=class e extends vs{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},_s=class e extends vs{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},Ss=class e extends vs{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},Ts=class e extends vs{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},Ps=class{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=g(n,2);const o=t[0];e-t[1].createdAt>this.ttlMs&&this.contexts.delete(o)}}get size(){return this.contexts.size}},Es=class{constructor(e,t){this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new Ps}setMFAAuthDetails(e,t,n,o){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:o})}async getAuthenticators(e){var t,n,o;const r=this.contextManager.get(e);if(!r)throw new bs("invalid_request","MFA context not found for this MFA token");const i=null===(n=null===(t=r.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 i&&0!==i.length?t.filter(e=>!!e.type&&i.includes(e.type)):t}catch(e){if(e instanceof ka)throw new bs(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=wt[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 ks(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 Ta)throw new _s(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 Ts("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 Ss("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?"http://auth0.com/oauth/grant-type/mfa-otp":"oobCode"in e&&e.oobCode?"http://auth0.com/oauth/grant-type/mfa-oob":"recoveryCode"in e&&e.recoveryCode?"http://auth0.com/oauth/grant-type/mfa-recovery-code":void 0}(e);if(!n)throw new Ss("invalid_request","Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.");const o=t.scope,r=t.audience;try{const t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:o,audience:r,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 Ss)throw new Ss(e.error,e.error_description);throw e}}},As=class e extends Error{constructor(t,n,o){super(n),this.name="PasskeyError",this.code=t,this.cause=o,Object.setPrototypeOf(this,e.prototype)}},Is=class{constructor(e,t){ws.set(this,void 0),gs.set(this,void 0),r(this,ws,e,"f"),r(this,gs,t,"f")}async signup(e){if(!window.PublicKeyCredential)throw new As("passkey_not_supported","WebAuthn is not supported in this browser.");const t=e.scope,r=e.audience,i=n(e,["scope","audience"]),a=await o(this,ws,"f").register(i),s=Os(a.authnParamsPublicKey),c=await navigator.credentials.create({publicKey:s});if(!c)throw new As("passkey_cancelled","Passkey creation was cancelled or no credential was returned.");const u=Ws(c);return o(this,gs,"f")._requestTokenForPasskey({authSession:a.authSession,credential:u,realm:i.realm,organization:i.organization,scope:t,audience:r})}async login(e){if(!window.PublicKeyCredential)throw new As("passkey_not_supported","WebAuthn is not supported in this browser.");const t=e||{},r=t.scope,i=t.audience,a=n(t,["scope","audience"]),s=await o(this,ws,"f").challenge(Object.keys(a).length>0?a:void 0),c=Cs(s.authnParamsPublicKey),u=await navigator.credentials.get({publicKey:c});if(!u)throw new As("passkey_cancelled","Passkey authentication was cancelled or no credential was returned.");const l=js(u);return o(this,gs,"f")._requestTokenForPasskey({authSession:s.authSession,credential:l,realm:a.realm,organization:a.organization,scope:r,audience:i})}async getSignupChallenge(e){if(!window.PublicKeyCredential)throw new As("passkey_not_supported","WebAuthn is not supported in this browser.");const t=await o(this,ws,"f").register(e);return{authSession:t.authSession,publicKey:Os(t.authnParamsPublicKey)}}async getLoginChallenge(e){if(!window.PublicKeyCredential)throw new As("passkey_not_supported","WebAuthn is not supported in this browser.");const t=await o(this,ws,"f").challenge(e);return{authSession:t.authSession,publicKey:Cs(t.authnParamsPublicKey)}}async getTokenWithPasskey(e){if(!window.PublicKeyCredential)throw new As("passkey_not_supported","WebAuthn is not supported in this browser.");const t=e.authSession,n=e.credential,r=e.realm,i=e.organization,a=e.scope,s=e.audience,c=n.response;let u;if(c instanceof AuthenticatorAttestationResponse)u=Ws(n);else{if(!(c instanceof AuthenticatorAssertionResponse))throw new As("passkey_invalid_credential","The provided credential is not a valid attestation or assertion response.");u=js(n)}return o(this,gs,"f")._requestTokenForPasskey({authSession:t,credential:u,realm:r,organization:i,scope:a,audience:s})}};function xs(e){const t=new Uint8Array(e),n=Array.from(t,e=>String.fromCharCode(e)).join("");return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Rs(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),o=atob(n),r=new Uint8Array(o.length);for(let i=0;i<o.length;i++)r[i]=o.charCodeAt(i);return r.buffer}function Os(e){return Object.assign(Object.assign({},e),{challenge:Rs(e.challenge),user:Object.assign(Object.assign({},e.user),{id:Rs(e.user.id)}),pubKeyCredParams:e.pubKeyCredParams,authenticatorSelection:e.authenticatorSelection})}function Cs(e){return Object.assign(Object.assign({},e),{challenge:Rs(e.challenge)})}function Ws(e){var t;const n=e.response;return{id:e.id,rawId:xs(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{clientDataJSON:xs(n.clientDataJSON),attestationObject:xs(n.attestationObject)},clientExtensionResults:e.getClientExtensionResults()}}function js(e){var t;const n=e.response;return{id:e.id,rawId:xs(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{clientDataJSON:xs(n.clientDataJSON),authenticatorData:xs(n.authenticatorData),signature:xs(n.signature),userHandle:n.userHandle?xs(n.userHandle):void 0},clientExtensionResults:e.getClientExtensionResults()}}ws=new WeakMap,gs=new WeakMap;var Ks=class{resolveOnlineAccess(e){if("online"!==e.refreshTokenMode)return!1;if(!0!==e.useRefreshTokens)throw new I('`refreshTokenMode: "online"` requires the refresh-token grant.',"Set `useRefreshTokens: true`.");if(!0!==e.useDpop)throw new I('`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 Le).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=(he||(he=function(){return"undefined"!=typeof navigator&&"function"==typeof(null===(e=navigator.locks)||void 0===e?void 0:e.request)?new ce:new ue;var e}()),he),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)n=e.cache;else{if(t=e.cacheLocation||_,!at(t))throw new Error('Invalid cache location "'.concat(t,'"'));n=at(t)()}var o;this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:k,this.cookieStorage=!1===e.legacySameSiteCookie?qe:Qe,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 r=e.useCookiesForTransactions?this.cookieStorage:$e;let i="";var a;this.onlineAccess?i=S:this.options.useRefreshTokens&&(i="offline_access"),this.scope=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];if("object"!=typeof e)return{[E]:Oe(t,e,...o)};let i={[E]:Oe(t,...o)};return Object.keys(e).forEach(n=>{const r=e[n];i[n]=Oe(t,r,...o)}),i}(this.options.authorizationParams.scope,"openid",i),this.transactionManager=new ze(r,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||P,this.cacheManager=new Ne(n,n.allKeys?void 0:new ot(n,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new lt(this.options.clientId):void 0,this.domainUrl=(a=this.options.domain,/^https?:\/\//.test(a)?a:"https://".concat(a)),this.tokenIssuer=((e,t)=>e?e.startsWith("https://")?e:"https://".concat(e,"/"):"".concat(t,"/"))(this.options.issuer,this.domainUrl);const s="".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:s},detailedResponse:!0})}}));this.myAccount=new mt(c,s),this.authJsClient=new cs({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new Es(this.authJsClient.mfa,this),this.passkey=new Is(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 tt,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=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(F(e)))}async _verifyIdToken(e,t,n){const o=await this.nowProvider();return(e=>{if(!e.id_token)throw new Error("ID token is required but missing");const t=(e=>{const t=e.split("."),n=g(t,3),o=n[0],r=n[1],i=n[2];if(3!==t.length||!o||!r||!i)throw new Error("ID token could not be decoded");const a=JSON.parse(X(r)),s={__raw:e},c={};return Object.keys(a).forEach(e=>{s[e]=a[e],De.includes(e)||(c[e]=a[e])}),{encoded:{header:o,payload:r,signature:i},header:JSON.parse(X(o)),claims:s,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&&!Me(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||!Me(t.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Me(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()),r=new Date(0);if(r.setUTCSeconds(t.claims.exp+n),o>r)throw new Error("Expiration Time (exp) claim error in the ID token; current time (".concat(o,") is after expiration time (").concat(r,")"));if(null!=t.claims.nbf&&Me(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&&Me(t.claims.auth_time)){const r=new Date(0);if(r.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),o>r)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(r))}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})({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:t,organization:n,leeway:this.options.leeway,max_age:(r=this.options.authorizationParams.max_age,"string"!=typeof r?r:parseInt(r,10)||void 0),now:o});var r}_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 r=J(D()),i=J(D()),a=D(),s=await V(a),c=G(s),u=await(null===(o=this.dpop)||void 0===o?void 0:o.calculateThumbprint()),l=((e,t,n,o,r,i,a,s,c)=>Object.assign(Object.assign(Object.assign({client_id:e.clientId},e.authorizationParams),n),{scope:Ce(t,n.scope,n.audience),response_type:"code",response_mode:s||"query",state:o,nonce:r,redirect_uri:a||e.authorizationParams.redirect_uri,code_challenge:i,code_challenge_method:"S256",dpop_jkt:c}))(this.options,this.scope,e,r,i,c,e.redirect_uri||this.options.authorizationParams.redirect_uri||n,null==t?void 0:t.response_mode,u),h=this._authorizeUrl(l);return{nonce:i,code_verifier:a,scope:l.scope,audience:l.audience||E,redirect_uri:l.redirect_uri,state:r,url:h}}async loginWithPopup(e,t){var n;if(e=e||{},!(t=t||{}).popup&&(t.popup=(()=>{const e=window.screenX+(window.innerWidth-400)/2,t=window.screenY+(window.innerHeight-600)/2;return window.open("","auth0:authorize:popup","left=".concat(e,",top=").concat(t,",width=").concat(400,",height=").concat(600,",resizable,scrollbars=yes,status=1"))})(),!t.popup))throw new j;const o=this._applySessionTransferToken(e.authorizationParams||{}),r=await this._prepareAuthorizeUrl(o,{response_mode:"web_message"},window.location.origin);t.popup.location.href=r.url;const i=await((e,t)=>new Promise((n,o)=>{let r;const i=setInterval(()=>{e.popup&&e.popup.closed&&(clearInterval(i),clearTimeout(a),window.removeEventListener("message",r,!1),o(new W(e.popup)))},1e3),a=setTimeout(()=>{clearInterval(i),o(new C(e.popup)),window.removeEventListener("message",r,!1)},1e3*(e.timeoutInSeconds||60));r=function(s){if(s.origin===t&&s.data&&"authorization_response"===s.data.type){if(clearTimeout(a),clearInterval(i),window.removeEventListener("message",r,!1),!1!==e.closePopup&&e.popup.close(),s.data.response.error)return o(A.fromPayload(s.data.response));n(s.data.response)}},window.addEventListener("message",r)}))(Object.assign(Object.assign({},t),{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(r.url).origin);if(r.state!==i.state)throw new A("state_mismatch","Invalid state");const a=(null===(n=e.authorizationParams)||void 0===n?void 0:n.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:r.audience,scope:r.scope,code_verifier:r.code_verifier,grant_type:"authorization_code",code:i.code,redirect_uri:r.redirect_uri},{nonceIn:r.nonce,organization:a})}async getUser(){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 e;const t=st(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),o=t.openUrl,r=t.fragment,i=t.appState,a=n(t,["openUrl","fragment","appState"]),s=(null===(e=a.authorizationParams)||void 0===e?void 0:e.organization)||this.options.authorizationParams.organization,c=this._applySessionTransferToken(a.authorizationParams||{}),u=await this._prepareAuthorizeUrl(c),l=u.url,h=n(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},h),{appState:i,response_type:Ve.Code}),s&&{organization:s}));const d=r?"".concat(l,"#").concat(r):l;o?await o(d):window.location.assign(d)}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 A("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===Ve.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){const n=e.code,o=e.state,r=e.error,i=e.error_description;if(r)throw new x(r,i||r,o,t.appState);if(!t.code_verifier||t.state&&t.state!==o)throw new A("state_mismatch","Invalid state");const a=t.organization,s=t.nonce,c=t.redirect_uri;return await this._requestToken(Object.assign({audience:t.audience,scope:t.scope,code_verifier:t.code_verifier,grant_type:"authorization_code",code:n},c?{redirect_uri:c}:{}),{nonceIn:s,organization:a}),{appState:t.appState,response_type:Ve.Code}}async _handleConnectAccountRedirectCallback(e,t){const n=e.connect_code,o=e.state,r=e.error,i=e.error_description;if(r)throw new R(r,i||r,t.connection,o,t.appState);if(!n)throw new A("missing_connect_code","Missing connect code");if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===o))throw new A("state_mismatch","Invalid state");const a=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({},a),{appState:t.appState,response_type:Ve.ConnectCode})}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(rt))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(rt)}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:Ce(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)})}),r=await((e,t)=>{let n=nt[t];return n||(n=e().finally(()=>{delete nt[t],n=null}),nt[t]=n),n})(()=>this._getTokenSilently(o),"".concat(this.options.clientId,"::").concat(o.authorizationParams.audience,"::").concat(o.authorizationParams.scope));return e.detailedResponse?r:null==r?void 0:r.access_token}async _getTokenSilently(e){const t=e.cacheMode,o=n(e,["cacheMode"]);if(await this._isSessionCeilingReached())return;if("off"!==t){const e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||E,clientId:this.options.clientId,cacheMode:t});if(e)return e}if("cache-only"===t)return;const r=(i=this.options.clientId,a=o.authorizationParams.audience||"default","".concat("auth0.lock.getTokenSilently",".").concat(i,".").concat(a));var i,a;try{return await this.lockManager.runWithLock(r,5e3,async()=>{if("off"!==t){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),n=e.id_token,r=e.token_type,i=e.access_token,a=e.oauthTokenScope,s=e.expires_in;return Object.assign(Object.assign({id_token:n,token_type:r,access_token:i},a?{scope:a}:null),{expires_in:s})})}catch(n){if(this._isInteractiveError(n)&&"popup"===this.options.interactiveErrorHandler)return await this._handleInteractiveErrorWithPopup(o);throw n}}_isInteractiveError(e){return e instanceof K||e instanceof A&&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||E,clientId:this.options.clientId});if(!t)throw new A("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 r=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Ce(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)})});return t=Object.assign(Object.assign({},b),t),await this.loginWithPopup(r,t),(await this.cacheManager.get(new Ke({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||E,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return!!(await this.getUser())}_buildLogoutUrl(e){null!==e.clientId?e.clientId=e.clientId||this.options.clientId:delete e.clientId;const t=e.logoutParams||{},o=t.federated,r=n(t,["federated"]),i=o?"&federated":"";return this._url("/v2/logout?".concat(F(Object.assign({clientId:e.clientId},r))))+i}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.auth0Client,o=e.useFormData,r=e.refreshTokens,i=e.audience,a=e.client_id,s=e.onRefreshTokenRevoked;const c=e.timeout||k,u="refresh_token",l="".concat(e.baseUrl,"/oauth/revoke"),h={"Content-Type":o?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(Z(n||T)))};if(t){const n={client_id:a,token_type_hint:u},r=o?F(n):JSON.stringify(n);try{return await Ee({type:"revoke",timeout:c,fetchUrl:l,fetchOptions:{method:"POST",body:r,headers:h},useFormData:o,auth:{audience:null!=i?i:E}},t)}catch(e){throw new A("revoke_error",e.message)}}for(const p of r){const t={client_id:a,token_type_hint:u,token:p},n=o?F(t):JSON.stringify(t),r=await Ae(l,{method:"POST",body:n,headers:h},c);if(!r.ok){let t,n;try{var d=JSON.parse(await r.text());t=d.error,n=d.error_description}catch(e){}throw new A(t||"revoke_error",n||"HTTP error ".concat(r.status))}await(null==s?void 0:s(p))}}({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 e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=st(e),o=t.openUrl,r=n(t,["openUrl"]);await this._clearLocalSession(e.clientId);const i=this._buildLogoutUrl(r);o?await o(i):!1!==o&&window.location.assign(i)}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),r=o.url,i=o.state,a=o.nonce,s=o.code_verifier,c=o.redirect_uri,u=o.scope,l=o.audience;if(window.crossOriginIsolated)throw new A("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const h=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds;let d;try{d=new URL(this.domainUrl).origin}catch(e){d=this.domainUrl}const p=await function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60;return new Promise((o,r)=>{const i=window.document.createElement("iframe");i.setAttribute("width","0"),i.setAttribute("height","0"),i.style.display="none";const a=()=>{window.document.body.contains(i)&&(window.document.body.removeChild(i),window.removeEventListener("message",s,!1))};let s;const c=setTimeout(()=>{r(new O),a()},1e3*n);s=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?r(A.fromPayload(e.data.response)):o(e.data.response),clearTimeout(c),window.removeEventListener("message",s,!1),setTimeout(a,2e3)},window.addEventListener("message",s,!1),window.document.body.appendChild(i),i.setAttribute("src",e)})}(r,d,h);if(i!==p.state)throw new A("state_mismatch","Invalid state");const f=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:p.code,grant_type:"authorization_code",redirect_uri:c,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:t.organization});return Object.assign(Object.assign({},f),{scope:u,oauthTokenScope:f.scope,audience:l})})}catch(e){throw"login_required"===e.error&&(e instanceof A&&this._isIframeMfaError(e)&&"popup"===this.options.interactiveErrorHandler||this.logout({openUrl:!1})),e}}async _getTokenUsingRefreshToken(e){const t=await this.cacheManager.get(new Ke({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 U(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,r=((e,t,n,o)=>{var r;if(e&&n&&o){if(t.audience!==n)return t.scope;const e=o.split(" "),i=(null===(r=t.scope)||void 0===r?void 0:r.split(" "))||[],a=i.every(t=>e.includes(t));return e.length>=i.length&&a?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:r});if(!this.onlineAccess&&u.refresh_token&&null!=t&&t.refresh_token&&await this.cacheManager.updateEntry(t.refresh_token,u.refresh_token),this.options.useMrrt&&(i=null==t?void 0:t.audience,a=null==t?void 0:t.scope,s=e.authorizationParams.audience,c=e.authorizationParams.scope,i!==s||!((e,t)=>{const n=(null==t?void 0:t.split(" "))||[];return((null==e?void 0:e.split(" "))||[]).every(e=>n.includes(e))})(c,a))){const t=((e,t,n)=>{const o=(null==e?void 0:e.split(" "))||[],r=n?o.filter(e=>e!==S):o,i=(null==t?void 0:t.split(" "))||[];return r.filter(e=>-1==i.indexOf(e)).join(",")})(r,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 L(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 i,a,s,c}async _saveEntryInCache(e){const t=e.decodedToken.claims,o=t.session_expiry,r=t.iat;if(void 0!==o){if("number"!=typeof o)throw new A("invalid_token","Invalid session_expiry: value must be a number.");if(o>=1e10)throw new A("invalid_token","Invalid session_expiry: value appears to be in milliseconds; expected a Unix timestamp in seconds.");if(void 0===r||o<=r)throw new A("invalid_token","Invalid session_expiry: session ceiling is before or at the token issue time.")}const i=e.id_token,a=e.decodedToken,s=n(e,["id_token","decodedToken"]);this.userCache.set(je,{id_token:i,decodedToken:a}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(s)}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 Ee({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 Ke({clientId:this.options.clientId})),r=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===r)return!1;const i=await this.nowProvider();return Math.floor(i/1e3)>=r-30&&(await this._clearLocalSession(),!0)}async _getIdTokenFromCache(){const e=this.options.authorizationParams.audience||E,t=this.scope[e],n=await this.cacheManager.getIdToken(new Ke({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,r=e.cacheMode;const i=await this.cacheManager.get(new Ke({scope:t,audience:n,clientId:o}),60,this.options.useMrrt,r);if(i&&i.access_token){const e=i.token_type,t=i.access_token,n=i.oauthTokenScope,o=i.expires_in,r=await this._getIdTokenFromCache();return r&&Object.assign(Object.assign({id_token:r.id_token,token_type:e||"Bearer",access_token:t},n?{scope:n}:null),{expires_in:o})}}_storeMfaContext(e,t,n){e instanceof K&&this.mfa.setMFAAuthDetails(e.mfa_token,t,n,e.mfa_requirements)}async _requestToken(e,t){var n,o,r,i,a,s;const c=t||{},u=c.nonceIn,l=c.organization,h=c.scopesToRequest;try{const t=await Re(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:h||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&&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===(i=null===(r=null==e?void 0:e.decodedToken)||void 0===r?void 0:r.claims)||void 0===i?void 0:i.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!==(a=e.refresh_token)&&void 0!==a?a:null===(s=await this.cacheManager.get(new Ke({scope:h||e.scope,audience:e.audience||E,clientId:this.options.clientId}),void 0,this.options.useMrrt))||void 0===s?void 0:s.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,h||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:Ce(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 Re(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 ft(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,r=e.scopes,i=e.authorization_params,a=e.redirectUri,s=void 0===a?this.options.authorizationParams.redirect_uri||window.location.origin:a;if(!o)throw new Error("connection is required");const c=J(D()),u=D(),l=await V(u),h=G(l),d=await this.myAccount.connectAccount({connection:o,scopes:r,redirect_uri:s,state:c,code_challenge:h,code_challenge_method:"S256",authorization_params:i}),p=d.connect_uri,f=d.connect_params,m=d.auth_session;this.transactionManager.create({state:c,code_verifier:u,auth_session:m,redirect_uri:s,appState:n,connection:o,response_type:Ve.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:Ce(this.scope,e.scope,t),audience:t}))}async _requestTokenForMfa(e,t){const o=e.mfaToken,r=n(e,["mfaToken"]);return this._requestToken(Object.assign(Object.assign({},r),{mfa_token:o}),t)}},Us={domain:"lila2.eu.auth0.com",clientId:"IJTK7qwslPZsZ9A20HJylfu8ef3abHar",audience:"https://editor.lilaquadrat.de/api"},Ls="openid profile",Ns="/login/callback",zs=new class{client;dev=!1;devToken;profile;get origin(){return window.location.origin}get auth0(){if(!this.client)throw new Error("[studio-chat] auth used before init()");return this.client}async init(e){if(e.dev)return this.dev=!0,this.devToken=e.devToken,this.devToken||console.warn("[studio-chat] settings.dev is set but devToken is missing"),!0;const t={...Us,...e.auth0},n={domain:t.domain,clientId:t.clientId,authorizationParams:{redirect_uri:`${this.origin}${Ns}`,scope:Ls,audience:t.audience},useRefreshTokens:!0,cacheLocation:"localstorage"};return this.client=new Ks(n),await this.handleCallback(),await this.auth0.isAuthenticated()?(this.profile=await this.loadProfile(),!0):(await this.auth0.loginWithRedirect({appState:{target:window.location.pathname+window.location.search}}),!1)}async handleCallback(){if(window.location.pathname!==Ns)return;const e=new URLSearchParams(window.location.search);if(!e.has("code")||!e.has("state"))return void window.history.replaceState({},document.title,"/");const t=((await this.auth0.handleRedirectCallback())?.appState)?.target;window.history.replaceState({},document.title,t&&t!==Ns?t:"/")}async getToken(){return this.dev?this.devToken??"":this.auth0.getTokenSilently({authorizationParams:{scope:Ls}})}getProfile(){return this.profile}async loadProfile(){const e=await this.auth0.getUser();if(e?.sub)return{id:e.sub,prename:e.given_name,lastname:e.family_name,name:e.name,email:e.email}}logout(){this.dev?window.location.reload():this.auth0.logout({logoutParams:{returnTo:this.origin}})}},Ms={},Ds=function(e,t,n){let o=Promise.resolve();if(t&&t.length>0){const e=document.getElementsByTagName("link"),n=document.querySelector("meta[property=csp-nonce]"),i=n?.nonce||n?.getAttribute("nonce");r=t.map(t=>{var n;if(t=function(e){return"/"+e}(t),n=t,(t=import.meta.resolve?import.meta.resolve(n):new URL(n,import.meta.url).href)in Ms)return;Ms[t]=!0;const o=t.endsWith(".css");for(let i=e.length-1;i>=0;i--){const n=e[i];if(n.href===t&&(!o||"stylesheet"===n.rel))return}const r=document.createElement("link");return r.rel=o?"stylesheet":"modulepreload",o||(r.as="script"),r.crossOrigin="",r.href=t,i&&r.setAttribute("nonce",i),document.head.appendChild(r),o?new Promise((e,n)=>{r.addEventListener("load",e),r.addEventListener("error",()=>n(new Error(`Unable to preload CSS for ${t}`)))}):void 0}),o=Promise.all(r.map(e=>Promise.resolve(e).then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e}))))}var r;function i(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return o.then(t=>{for(const e of t||[])"rejected"===e.status&&i(e.reason);return e().catch(i)})},Js="#app";async function Hs(e){await Ds(()=>import("./web-component-NO1YrOLk.js"),[]);const t=document.createElement("lilaquadrat-studio-chat");t.config={...e.chat,token:await zs.getToken(),getToken:()=>zs.getToken(),user:zs.getProfile(),close:()=>zs.logout()},function(){const e=document.querySelector(Js);if(!e)throw new Error(`mount target ${Js} not found`);return e}().replaceChildren(t)}(async function(){const n=await async function(){const n=await fetch(e,{cache:"no-store"});if(!n.ok)throw new Error(`could not load ${e} (${n.status})`);const o=await n.json();if(!o.chat)throw new Error(`${e} has no "chat" section`);if(o.dev&&!t.includes(window.location.hostname))throw new Error(`${e} has dev mode enabled, which only works on localhost — replace it with this deployment's configuration`);return o}();n.title&&(document.title=n.title),await zs.init(n)&&await Hs(n)})().catch(function(e){const t=e instanceof Error?e.message:String(e);console.error("[studio-chat] standalone boot failed",e);const n=document.querySelector(Js);if(!n)return;const o=document.createElement("div");o.className="standalone-error",o.innerHTML="<h1>Chat unavailable</h1>",o.appendChild(Object.assign(document.createElement("p"),{textContent:t})),n.replaceChildren(o)});export{Ds as t};