@wandelbots/wandelbots-js-react-components 4.7.1 → 4.7.2-pr.dev-RB-3348-v1-clean-up.560.cbf9c17

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.
Files changed (109) hide show
  1. package/README.md +11 -32
  2. package/dist/3d-BOCs0RwR.cjs +2 -0
  3. package/dist/3d-BOCs0RwR.cjs.map +1 -0
  4. package/dist/3d-BTtdSlR9.js +1206 -0
  5. package/dist/3d-BTtdSlR9.js.map +1 -0
  6. package/dist/3d.cjs.js +1 -2
  7. package/dist/3d.esm.js +2 -0
  8. package/dist/auth0-spa-js.production.esm-8ppNz0la.js +5007 -0
  9. package/dist/auth0-spa-js.production.esm-8ppNz0la.js.map +1 -0
  10. package/dist/auth0-spa-js.production.esm-cNFf2AtX.cjs +5 -0
  11. package/dist/auth0-spa-js.production.esm-cNFf2AtX.cjs.map +1 -0
  12. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +1 -1
  13. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts.map +1 -1
  14. package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts +1 -2
  15. package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts.map +1 -1
  16. package/dist/components/3d-viewport/TrajectoryRenderer.d.ts +2 -2
  17. package/dist/components/3d-viewport/TrajectoryRenderer.d.ts.map +1 -1
  18. package/dist/components/3d-viewport/collider/ColliderCollection.d.ts +1 -1
  19. package/dist/components/3d-viewport/collider/ColliderElement.d.ts +1 -1
  20. package/dist/components/3d-viewport/collider/CollisionSceneRenderer.d.ts +2 -2
  21. package/dist/components/3d-viewport/collider/colliderShapeToBufferGeometry.d.ts +1 -1
  22. package/dist/components/jogging/JoggingStore.d.ts +5 -11
  23. package/dist/components/jogging/JoggingStore.d.ts.map +1 -1
  24. package/dist/core-DtLSGTAb.js +18258 -0
  25. package/dist/core-DtLSGTAb.js.map +1 -0
  26. package/dist/core-DufB-Zu5.cjs +52 -0
  27. package/dist/core-DufB-Zu5.cjs.map +1 -0
  28. package/dist/core.cjs.js +1 -2
  29. package/dist/core.esm.js +3 -0
  30. package/dist/index.cjs.js +1 -2
  31. package/dist/index.d.ts +0 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.esm.js +4 -0
  34. package/dist/interpolation-BmgrXVQ7.js +5859 -0
  35. package/dist/interpolation-BmgrXVQ7.js.map +1 -0
  36. package/dist/interpolation-Cz29Pgpr.cjs +8 -0
  37. package/dist/interpolation-Cz29Pgpr.cjs.map +1 -0
  38. package/dist/lib/ConnectedMotionGroup.d.ts +2 -3
  39. package/dist/lib/ConnectedMotionGroup.d.ts.map +1 -1
  40. package/dist/lib/MotionStreamConnection.d.ts +0 -1
  41. package/dist/lib/MotionStreamConnection.d.ts.map +1 -1
  42. package/dist/themes/createDarkTheme.d.ts.map +1 -1
  43. package/dist/themes/themeTypes.d.ts +0 -4
  44. package/dist/themes/themeTypes.d.ts.map +1 -1
  45. package/package.json +21 -24
  46. package/src/components/3d-viewport/CoordinateSystemTransform.tsx +29 -18
  47. package/src/components/3d-viewport/SafetyZonesRenderer.tsx +13 -96
  48. package/src/components/3d-viewport/TrajectoryRenderer.tsx +8 -8
  49. package/src/components/3d-viewport/collider/ColliderCollection.tsx +1 -1
  50. package/src/components/3d-viewport/collider/ColliderElement.tsx +1 -1
  51. package/src/components/3d-viewport/collider/CollisionSceneRenderer.tsx +2 -2
  52. package/src/components/3d-viewport/collider/colliderShapeToBufferGeometry.ts +1 -1
  53. package/src/components/jogging/JoggingStore.ts +5 -5
  54. package/src/components/utils/interpolation.test.ts +3 -3
  55. package/src/index.ts +0 -1
  56. package/src/lib/ConnectedMotionGroup.ts +0 -5
  57. package/src/lib/MotionStreamConnection.ts +0 -5
  58. package/src/themes/createDarkTheme.ts +1 -22
  59. package/src/themes/themeTypes.ts +0 -5
  60. package/dist/3d.cjs.js.map +0 -1
  61. package/dist/3d.es.js +0 -19
  62. package/dist/3d.es.js.map +0 -1
  63. package/dist/LoadingCover-B3UN1lnU.js +0 -81
  64. package/dist/LoadingCover-B3UN1lnU.js.map +0 -1
  65. package/dist/LoadingCover-DXcsXWDy.cjs +0 -2
  66. package/dist/LoadingCover-DXcsXWDy.cjs.map +0 -1
  67. package/dist/MotionGroupVisualizer-7Mw9PINy.js +0 -1366
  68. package/dist/MotionGroupVisualizer-7Mw9PINy.js.map +0 -1
  69. package/dist/MotionGroupVisualizer-C0ll-LQF.cjs +0 -2
  70. package/dist/MotionGroupVisualizer-C0ll-LQF.cjs.map +0 -1
  71. package/dist/WandelscriptEditor-6sAoniLC.cjs +0 -2
  72. package/dist/WandelscriptEditor-6sAoniLC.cjs.map +0 -1
  73. package/dist/WandelscriptEditor-kWC2VyG_.js +0 -140
  74. package/dist/WandelscriptEditor-kWC2VyG_.js.map +0 -1
  75. package/dist/auth0-spa-js.production.esm-DNao6_S5.js +0 -4064
  76. package/dist/auth0-spa-js.production.esm-DNao6_S5.js.map +0 -1
  77. package/dist/auth0-spa-js.production.esm-DaBMfOV8.cjs +0 -5
  78. package/dist/auth0-spa-js.production.esm-DaBMfOV8.cjs.map +0 -1
  79. package/dist/components/wandelscript-editor/WandelscriptEditor.d.ts +0 -16
  80. package/dist/components/wandelscript-editor/WandelscriptEditor.d.ts.map +0 -1
  81. package/dist/components/wandelscript-editor/wandelscript.tmLanguage.d.ts +0 -45
  82. package/dist/components/wandelscript-editor/wandelscript.tmLanguage.d.ts.map +0 -1
  83. package/dist/core.cjs.js.map +0 -1
  84. package/dist/core.es.js +0 -54
  85. package/dist/core.es.js.map +0 -1
  86. package/dist/externalizeComponent-B98tgTPP.cjs +0 -24
  87. package/dist/externalizeComponent-B98tgTPP.cjs.map +0 -1
  88. package/dist/externalizeComponent-BOqKMZMc.js +0 -526
  89. package/dist/externalizeComponent-BOqKMZMc.js.map +0 -1
  90. package/dist/index.cjs.js.map +0 -1
  91. package/dist/index.es.js +0 -72
  92. package/dist/index.es.js.map +0 -1
  93. package/dist/interpolation-B8AcxfdD.js +0 -7167
  94. package/dist/interpolation-B8AcxfdD.js.map +0 -1
  95. package/dist/interpolation-SWzo5zr4.cjs +0 -20
  96. package/dist/interpolation-SWzo5zr4.cjs.map +0 -1
  97. package/dist/theming-BKpqgTRM.js +0 -22360
  98. package/dist/theming-BKpqgTRM.js.map +0 -1
  99. package/dist/theming-CatQaIl_.cjs +0 -115
  100. package/dist/theming-CatQaIl_.cjs.map +0 -1
  101. package/dist/wandelscript.cjs.js +0 -2
  102. package/dist/wandelscript.cjs.js.map +0 -1
  103. package/dist/wandelscript.d.ts +0 -2
  104. package/dist/wandelscript.d.ts.map +0 -1
  105. package/dist/wandelscript.es.js +0 -5
  106. package/dist/wandelscript.es.js.map +0 -1
  107. package/src/components/wandelscript-editor/WandelscriptEditor.tsx +0 -142
  108. package/src/components/wandelscript-editor/wandelscript.tmLanguage.ts +0 -62
  109. package/src/wandelscript.ts +0 -2
@@ -0,0 +1,5 @@
1
+ function e(e,t){this.v=e,this.k=t}function t(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function n(t){return new e(t,0)}function r(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function i(e,n){return e.get(t(e,n))}function a(e,t,n){r(e,t),t.set(e,n)}function o(e,n,r){return e.set(t(e,n),r),r}function s(e,t,n){return(t=function(e){var t=function(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return typeof t==`symbol`?t:t+``}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?c(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function d(e){return function(){return new f(e.apply(this,arguments))}}function f(t){var n,r;function i(n,r){try{var o=t[n](r),s=o.value,c=s instanceof e;Promise.resolve(c?s.v:s).then(function(e){if(c){var r=n===`return`&&s.k?n:`next`;if(!s.k||e.done)return i(r,e);e=t[r](e).value}a(!!o.done,e)},function(e){i(`throw`,e)})}catch(e){a(2,e)}}function a(e,t){e===2?n.reject(t):n.resolve({value:t,done:e}),(n=n.next)?i(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise(function(a,o){var s={key:e,arg:t,resolve:a,reject:o,next:null};r?r=r.next=s:(n=r=s,i(e,t))})},typeof t.return!=`function`&&(this.return=void 0)}f.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},f.prototype.next=function(e){return this._invoke(`next`,e)},f.prototype.throw=function(e){return this._invoke(`throw`,e)},f.prototype.return=function(e){return this._invoke(`return`,e)};var p={timeoutInSeconds:60},m=`memory`,h={name:`auth0-spa-js`,version:`2.18.3`},g=()=>Date.now(),_=`default`,v=class e extends Error{constructor(t,n){super(n),this.error=t,this.error_description=n,Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let{error:n,error_description:r}=t;return new e(n,r)}},ee=class e extends v{constructor(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;super(t,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,e.prototype)}},y=class e extends v{constructor(t,n,r,i){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null;super(t,n),this.connection=r,this.state=i,this.appState=a,Object.setPrototypeOf(this,e.prototype)}},te=class e extends v{constructor(){super(`timeout`,`Timeout`),Object.setPrototypeOf(this,e.prototype)}},ne=class e extends te{constructor(t){super(),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},re=class e extends v{constructor(t){super(`cancelled`,`Popup closed`),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},ie=class e extends v{constructor(){super(`popup_open`,"Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,e.prototype)}},ae=class e extends v{constructor(t,n,r,i){super(t,n),this.mfa_token=r,this.mfa_requirements=i,Object.setPrototypeOf(this,e.prototype)}},oe=class e extends v{constructor(t,n){super(`missing_refresh_token`,`Missing Refresh Token (audience: '${le(t,[`default`])}', scope: '${le(n)}')`),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},se=class e extends v{constructor(t,n){super(`missing_scopes`,`Missing requested scopes after refresh (audience: '${le(t,[`default`])}', missing scope: '${le(n)}')`),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},ce=class e extends v{constructor(t){super(`use_dpop_nonce`,`Server rejected DPoP proof: wrong nonce`),this.newDpopNonce=t,Object.setPrototypeOf(this,e.prototype)}};function le(e){return e&&!(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).includes(e)?e:``}var ue=[`clientId`],de=()=>window.crypto,fe=()=>{let e=``;for(;e.length<43;){let t=de().getRandomValues(new Uint8Array(43-e.length));for(let n of t)e.length<43&&n<198&&(e+=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.`[n%66])}return e},pe=e=>btoa(e),me=[{key:`name`,type:[`string`]},{key:`version`,type:[`string`,`number`]},{key:`env`,type:[`object`]}],he=function(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return Object.keys(e).reduce((n,r)=>{if(t&&r===`env`)return n;let i=me.find(e=>e.key===r);return i&&i.type.includes(typeof e[r])&&(n[r]=e[r]),n},{})},ge=e=>{let{clientId:t}=e,n=u(e,ue);return new URLSearchParams((e=>Object.keys(e).filter(t=>e[t]!==void 0).reduce((t,n)=>l(l({},t),{},{[n]:e[n]}),{}))(l({client_id:t},n))).toString()},_e=async e=>await de().subtle.digest({name:`SHA-256`},new TextEncoder().encode(e)),ve=e=>(e=>decodeURIComponent(atob(e).split(``).map(e=>`%`+(`00`+e.charCodeAt(0).toString(16)).slice(-2)).join(``)))(e.replace(/_/g,`/`).replace(/-/g,`+`)),ye=e=>{let t=new Uint8Array(e);return(e=>{let t={"+":`-`,"/":`_`,"=":``};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))},be=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},xe={},Se={};Object.defineProperty(Se,`__esModule`,{value:!0});var Ce=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var r=e.locked.get(t);r===void 0?n===void 0?e.locked.set(t,[]):e.locked.set(t,[n]):n!==void 0&&(r.unshift(n),e.locked.set(t,r))},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise(function(n,r){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n())})},this.unlock=function(t){var n=e.locked.get(t);if(n!==void 0&&n.length!==0){var r=n.pop();e.locked.set(t,n),r!==void 0&&setTimeout(r,0)}else e.locked.delete(t)}}return e.getInstance=function(){return e.instance===void 0&&(e.instance=new e),e.instance},e}();Se.default=function(){return Ce.getInstance()};var b=be&&be.__awaiter||function(e,t,n,r){return new(n||=Promise)(function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(o,s)}c((r=r.apply(e,t||[])).next())})},x=be&&be.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw TypeError(`Generator is already executing.`);for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||a[0]!==6&&a[0]!==2)){o=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(a[0]===6&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},we=be;Object.defineProperty(xe,`__esModule`,{value:!0});var Te=Se,Ee=`browser-tabs-lock-key`,De={key:function(e){return b(we,void 0,void 0,function(){return x(this,function(e){throw Error(`Unsupported`)})})},getItem:function(e){return b(we,void 0,void 0,function(){return x(this,function(e){throw Error(`Unsupported`)})})},clear:function(){return b(we,void 0,void 0,function(){return x(this,function(e){return[2,window.localStorage.clear()]})})},removeItem:function(e){return b(we,void 0,void 0,function(){return x(this,function(e){throw Error(`Unsupported`)})})},setItem:function(e,t){return b(we,void 0,void 0,function(){return x(this,function(e){throw Error(`Unsupported`)})})},keySync:function(e){return window.localStorage.key(e)},getItemSync:function(e){return window.localStorage.getItem(e)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(e){return window.localStorage.removeItem(e)},setItemSync:function(e,t){return window.localStorage.setItem(e,t)}};function Oe(e){return new Promise(function(t){return setTimeout(t,e)})}function ke(e){for(var t=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`,n=``,r=0;r<e;r++)n+=t[Math.floor(61*Math.random())];return n}var Ae=xe.default=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+ke(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=t,e.waiters===void 0&&(e.waiters=[])}return e.prototype.acquireLock=function(t,n){return n===void 0&&(n=5e3),b(this,void 0,void 0,function(){var r,i,a,o,s,c,l;return x(this,function(u){switch(u.label){case 0:r=Date.now()+ke(4),i=Date.now()+n,a=Ee+`-`+t,o=this.storageHandler===void 0?De:this.storageHandler,u.label=1;case 1:return Date.now()<i?[4,Oe(30)]:[3,8];case 2:return u.sent(),o.getItemSync(a)===null?(s=this.id+`-`+t+`-`+r,[4,Oe(Math.floor(25*Math.random()))]):[3,5];case 3:return u.sent(),o.setItemSync(a,JSON.stringify({id:this.id,iat:r,timeoutKey:s,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,Oe(30)];case 4:return u.sent(),(c=o.getItemSync(a))!==null&&(l=JSON.parse(c)).id===this.id&&l.iat===r?(this.acquiredIatSet.add(r),this.refreshLockWhileAcquired(a,r),[2,!0]):[3,7];case 5:return e.lockCorrector(this.storageHandler===void 0?De:this.storageHandler),[4,this.waitForSomethingToChange(i)];case 6:u.sent(),u.label=7;case 7:return r=Date.now()+ke(4),[3,1];case 8:return[2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(e,t){return b(this,void 0,void 0,function(){var n=this;return x(this,function(r){return setTimeout(function(){return b(n,void 0,void 0,function(){var n,r,i;return x(this,function(a){switch(a.label){case 0:return[4,Te.default().lock(t)];case 1:return a.sent(),this.acquiredIatSet.has(t)?(n=this.storageHandler===void 0?De:this.storageHandler,(r=n.getItemSync(e))===null?(Te.default().unlock(t),[2]):((i=JSON.parse(r)).timeRefreshed=Date.now(),n.setItemSync(e,JSON.stringify(i)),Te.default().unlock(t),this.refreshLockWhileAcquired(e,t),[2])):(Te.default().unlock(t),[2])}})})},1e3),[2]})})},e.prototype.waitForSomethingToChange=function(t){return b(this,void 0,void 0,function(){return x(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var r=!1,i=Date.now(),a=!1;function o(){if(a||=(window.removeEventListener(`storage`,o),e.removeFromWaiting(o),clearTimeout(s),!0),!r){r=!0;var t=50-(Date.now()-i);t>0?setTimeout(n,t):n(null)}}window.addEventListener(`storage`,o),e.addToWaiting(o);var s=setTimeout(o,Math.max(0,t-Date.now()))})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),e.waiters!==void 0&&e.waiters.push(t)},e.removeFromWaiting=function(t){e.waiters!==void 0&&(e.waiters=e.waiters.filter(function(e){return e!==t}))},e.notifyWaiters=function(){e.waiters!==void 0&&e.waiters.slice().forEach(function(e){return e()})},e.prototype.releaseLock=function(e){return b(this,void 0,void 0,function(){return x(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 b(this,void 0,void 0,function(){var n,r,i,a;return x(this,function(o){switch(o.label){case 0:return n=this.storageHandler===void 0?De:this.storageHandler,r=Ee+`-`+t,(i=n.getItemSync(r))===null?[2]:(a=JSON.parse(i)).id===this.id?[4,Te.default().lock(a.iat)]:[3,2];case 1:o.sent(),this.acquiredIatSet.delete(a.iat),n.removeItemSync(r),Te.default().unlock(a.iat),e.notifyWaiters(),o.label=2;case 2:return[2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,r=t,i=[],a=0;;){var o=r.keySync(a);if(o===null)break;i.push(o),a++}for(var s=!1,c=0;c<i.length;c++){var l=i[c];if(l.includes(Ee)){var u=r.getItemSync(l);if(u!==null){var d=JSON.parse(u);(d.timeRefreshed===void 0&&d.timeAcquired<n||d.timeRefreshed!==void 0&&d.timeRefreshed<n)&&(r.removeItemSync(l),s=!0)}}}s&&e.notifyWaiters()},e.waiters=void 0,e}(),je=class{async runWithLock(e,t,n){let r=new AbortController,i=setTimeout(()=>r.abort(),t);try{return await navigator.locks.request(e,{mode:`exclusive`,signal:r.signal},async e=>{if(clearTimeout(i),!e)throw Error(`Lock not available`);return await n()})}catch(e){throw clearTimeout(i),e?.name===`AbortError`?new te:e}}},Me=class{constructor(){s(this,`lock`,void 0),s(this,`activeLocks`,new Set),s(this,`pagehideHandler`,void 0),this.lock=new Ae,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear()}}async runWithLock(e,t,n){let r=!1;for(let n=0;n<10&&!r;n++)r=await this.lock.acquireLock(e,t);if(!r)throw new te;this.activeLocks.add(e),this.activeLocks.size===1&&typeof window<`u`&&window.addEventListener(`pagehide`,this.pagehideHandler);try{return await n()}finally{this.activeLocks.delete(e),await this.lock.releaseLock(e),this.activeLocks.size===0&&typeof window<`u`&&window.removeEventListener(`pagehide`,this.pagehideHandler)}}};function Ne(){return typeof navigator<`u`&&typeof(e=navigator.locks)?.request==`function`?new je:new Me;var e}var Pe=null,Fe=new TextEncoder,Ie=new TextDecoder;function Le(e){return typeof e==`string`?Fe.encode(e):Ie.decode(e)}function Re(e){if(typeof e.modulusLength!=`number`||e.modulusLength<2048)throw new Ue(`${e.name} modulusLength must be at least 2048 bits`)}async function ze(e,t,n){if(!1===n.usages.includes(`sign`))throw TypeError(`private CryptoKey instances used for signing assertions must include "sign" in their "usages"`);let r=`${Ve(Le(JSON.stringify(e)))}.${Ve(Le(JSON.stringify(t)))}`;return`${r}.${Ve(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case`ECDSA`:return{name:e.algorithm.name,hash:`SHA-256`};case`RSA-PSS`:return Re(e.algorithm),{name:e.algorithm.name,saltLength:32};case`RSASSA-PKCS1-v1_5`:return Re(e.algorithm),{name:e.algorithm.name};case`Ed25519`:return{name:e.algorithm.name}}throw new He}(n),n,Le(r)))}`}var Be;if(Uint8Array.prototype.toBase64)Be=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:`base64url`,omitPadding:!0}));else{let e=32768;Be=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=e)n.push(String.fromCharCode.apply(null,t.subarray(r,r+e)));return btoa(n.join(``)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}}function Ve(e){return Be(e)}var He=class extends Error{constructor(e){var t;super(e??`operation not supported`),this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}},Ue=class extends Error{constructor(e){var t;super(e),this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}};function We(e){switch(e.algorithm.name){case`RSA-PSS`:return function(e){if(e.algorithm.hash.name===`SHA-256`)return`PS256`;throw new He(`unsupported RsaHashedKeyAlgorithm hash name`)}(e);case`RSASSA-PKCS1-v1_5`:return function(e){if(e.algorithm.hash.name===`SHA-256`)return`RS256`;throw new He(`unsupported RsaHashedKeyAlgorithm hash name`)}(e);case`ECDSA`:return function(e){if(e.algorithm.namedCurve===`P-256`)return`ES256`;throw new He(`unsupported EcKeyAlgorithm namedCurve`)}(e);case`Ed25519`:return`Ed25519`;default:throw new He(`unsupported CryptoKey algorithm name`)}}function Ge(e){return e instanceof CryptoKey}function Ke(e){return Ge(e)&&e.type===`public`}async function qe(e,t,n,r,i,a){let o=e?.privateKey,s=e?.publicKey;if(!Ge(c=o)||c.type!==`private`)throw TypeError(`"keypair.privateKey" must be a private CryptoKey`);var c;if(!Ke(s))throw TypeError(`"keypair.publicKey" must be a public CryptoKey`);if(!0!==s.extractable)throw TypeError(`"keypair.publicKey.extractable" must be true`);if(typeof t!=`string`)throw TypeError(`"htu" must be a string`);if(typeof n!=`string`)throw TypeError(`"htm" must be a string`);if(r!==void 0&&typeof r!=`string`)throw TypeError(`"nonce" must be a string or undefined`);if(i!==void 0&&typeof i!=`string`)throw TypeError(`"accessToken" must be a string or undefined`);if(a!==void 0&&(typeof a!=`object`||!a||Array.isArray(a)))throw TypeError(`"additional" must be an object`);return ze({alg:We(o),typ:`dpop+jwt`,jwk:await Je(s)},Object.assign(Object.assign({},a),{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:r,htu:t,ath:i?Ve(await crypto.subtle.digest(`SHA-256`,Le(i))):void 0}),o)}async function Je(e){let{kty:t,e:n,n:r,x:i,y:a,crv:o}=await crypto.subtle.exportKey(`jwk`,e);return{kty:t,crv:o,e:n,n:r,x:i,y:a}}var Ye=`dpop-nonce`,Xe=[`authorization_code`,`refresh_token`,`urn:ietf:params:oauth:grant-type:token-exchange`,`http://auth0.com/oauth/grant-type/mfa-oob`,`http://auth0.com/oauth/grant-type/mfa-otp`,`http://auth0.com/oauth/grant-type/mfa-recovery-code`];function Ze(){return async function(e,t){var n;let r;if(typeof e!=`string`||e.length===0)throw TypeError(`"alg" must be a non-empty string`);switch(e){case`PS256`:r={name:`RSA-PSS`,hash:`SHA-256`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case`RS256`:r={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case`ES256`:r={name:`ECDSA`,namedCurve:`P-256`};break;case`Ed25519`:r={name:`Ed25519`};break;default:throw new He}return crypto.subtle.generateKey(r,(n=t?.extractable)!=null&&n,[`sign`,`verify`])}(`ES256`,{extractable:!1})}function Qe(e){return async function(e){if(!Ke(e))throw TypeError(`"publicKey" must be a public CryptoKey`);if(!0!==e.extractable)throw TypeError(`"publicKey.extractable" must be true`);let t=await Je(e),n;switch(t.kty){case`EC`:n={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case`OKP`:n={crv:t.crv,kty:t.kty,x:t.x};break;case`RSA`:n={e:t.e,kty:t.kty,n:t.n};break;default:throw new He(`unsupported JWK kty`)}return Ve(await crypto.subtle.digest({name:`SHA-256`},Le(JSON.stringify(n))))}(e.publicKey)}function $e(e){let{keyPair:t,url:n,method:r,nonce:i,accessToken:a}=e;return qe(t,function(e){let t=new URL(e);return t.search=``,t.hash=``,t.href}(n),r,i,a)}var et=[`error`,`error_description`],tt=async(e,t)=>{let n=await fetch(e,t);return{ok:n.ok,json:await n.json(),headers:(r=n.headers,[...r].reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{}))};var r},nt=async(e,t,n)=>{let r=new AbortController,i;return t.signal=r.signal,Promise.race([tt(e,t),new Promise((e,t)=>{i=setTimeout(()=>{r.abort(),t(Error(`Timeout when executing 'fetch'`))},n)})]).finally(()=>{clearTimeout(i)})},rt=async(e,t,n,r,i,a,o,s)=>((e,t)=>new Promise(function(n,r){let i=new MessageChannel;i.port1.onmessage=function(e){e.data.error?r(Error(e.data.error)):n(e.data),i.port1.close()},t.postMessage(e,[i.port2])}))({auth:{audience:t,scope:n},timeout:i,fetchUrl:e,fetchOptions:r,useFormData:o,useMrrt:s},a),it=async function(e,t,n,r,i,a){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:1e4;return i?rt(e,t,n,r,o,i,a,arguments.length>7?arguments[7]:void 0):nt(e,r,o)};async function at(e,t,n,r,i,a,o,s,c,d){if(c){let t=await c.generateProof({url:e,method:i.method||`GET`,nonce:await c.getNonce()});i.headers=l(l({},i.headers),{},{dpop:t})}let f,p=null;for(let c=0;c<3;c++)try{f=await it(e,n,r,i,a,o,t,s),p=null;break}catch(e){p=e}if(p)throw p;let{json:{error:m,error_description:h},headers:g,ok:_}=f,ee=u(f.json,et),y;if(c&&(y=g[Ye],y&&await c.setNonce(y)),!_){let l=h||`HTTP error. Unable to fetch ${e}`;if(m===`mfa_required`)throw new ae(m,l,ee.mfa_token,ee.mfa_requirements);if(m===`missing_refresh_token`)throw new oe(n,r);if(m===`use_dpop_nonce`){if(!c||!y||d)throw new ce(y);return at(e,t,n,r,i,a,o,s,c,!0)}throw new v(m||`request_error`,l)}return ee}var ot=[`baseUrl`,`timeout`,`audience`,`scope`,`auth0Client`,`useFormData`,`useMrrt`,`dpop`];async function st(e,t){let{baseUrl:n,timeout:r,audience:i,scope:a,auth0Client:o,useFormData:s,useMrrt:c,dpop:d}=e,f=u(e,ot),p=f.grant_type===`urn:ietf:params:oauth:grant-type:token-exchange`,m=f.grant_type===`refresh_token`&&c,g=l(l(l(l({},f),p&&i&&{audience:i}),p&&a&&{scope:a}),m&&{audience:i,scope:a}),v=s?ge(g):JSON.stringify(g),ee=(y=f.grant_type,Xe.includes(y));var y;return await at(`${n}/oauth/token`,r,i||_,a,{method:`POST`,body:v,headers:{"Content-Type":s?`application/x-www-form-urlencoded`:`application/json`,"Auth0-Client":btoa(JSON.stringify(he(o||h)))}},t,s,c,ee?d:void 0)}var ct=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(r=t.filter(Boolean).join(` `).trim().split(/\s+/),Array.from(new Set(r))).join(` `);var r},lt=(e,t,n)=>{let r;return n&&(r=e[n]),r||=e[_],ct(r,t)},ut=`@@auth0spajs@@`,dt=`@@user@@`,ft=class e{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ut,n=arguments.length>2?arguments[2]:void 0;this.prefix=t,this.suffix=n,s(this,`clientId`,void 0),s(this,`scope`,void 0),s(this,`audience`,void 0),this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join(`::`)}static fromKey(t){let[n,r,i,a]=t.split(`::`);return new e({clientId:r,scope:a,audience:i},n)}static fromCacheEntry(t){let{scope:n,audience:r,client_id:i}=t;return new e({scope:n,audience:r,clientId:i})}},pt=class{set(e,t){localStorage.setItem(e,JSON.stringify(t))}get(e){let t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch{return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith(ut))}},mt=class{constructor(){s(this,`enclosedCache`,function(){let e={};return{set(t,n){e[t]=n},get(t){let n=e[t];if(n)return n},remove(t){delete e[t]},allKeys:()=>Object.keys(e)}}())}},ht=class{constructor(e,t,n){this.cache=e,this.keyManifest=t,s(this,`nowProvider`,void 0),this.nowProvider=n||g}async setIdToken(e,t,n){let r=this.getIdTokenCacheKey(e);await this.cache.set(r,{id_token:t,decodedToken:n}),await this.keyManifest?.add(r)}async getIdToken(e){let t=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!t&&e.scope&&e.audience){let t=await this.get(e);return!t||!t.id_token||!t.decodedToken?void 0:{id_token:t.id_token,decodedToken:t.decodedToken}}if(t)return{id_token:t.id_token,decodedToken:t.decodedToken}}async get(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=arguments.length>3?arguments[3]:void 0,i=await this.cache.get(e.toKey());if(!i){let t=await this.getCacheKeys();if(!t)return;let a=this.matchExistingCacheKey(e,t);if(a&&(i=await this.cache.get(a)),!i&&n&&r!==`cache-only`)return this.getEntryWithRefreshToken(e,t)}if(!i)return;let a=await this.nowProvider(),o=Math.floor(a/1e3);return i.expiresAt-t<o?i.body.refresh_token?this.modifiedCachedEntry(i,e):(await this.cache.remove(e.toKey()),void await this.keyManifest?.remove(e.toKey())):i.body}async modifiedCachedEntry(e,t){return e.body={refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope},await this.cache.set(t.toKey(),e),{refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope}}async set(e){let t=new ft({clientId:e.client_id,scope:e.scope,audience:e.audience}),n=await this.wrapCacheEntry(e);await this.cache.set(t.toKey(),n),await this.keyManifest?.add(t.toKey())}async remove(e,t,n){let r=new ft({clientId:e,scope:n,audience:t});await this.cache.remove(r.toKey())}async clear(e){let t=await this.getCacheKeys();t&&(await t.filter(t=>!e||t.includes(e)).reduce(async(e,t)=>{await e,await this.cache.remove(t)},Promise.resolve()),await this.keyManifest?.clear())}async wrapCacheEntry(e){let t=await this.nowProvider();return{body:e,expiresAt:Math.floor(t/1e3)+e.expires_in}}async getCacheKeys(){return this.keyManifest?(await this.keyManifest.get())?.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new ft({clientId:e},ut,dt).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{let n=ft.fromKey(t),r=new Set(n.scope&&n.scope.split(` `)),i=e.scope?.split(` `)||[],a=n.scope&&i.reduce((e,t)=>e&&r.has(t),!0);return n.prefix===ut&&n.clientId===e.clientId&&n.audience===e.audience&&a})[0]}async getEntryWithRefreshToken(e,t){for(let r of t){let t=ft.fromKey(r);if(t.prefix===ut&&t.clientId===e.clientId){var n;let t=await this.cache.get(r);if(t!=null&&(n=t.body)!=null&&n.refresh_token)return this.modifiedCachedEntry(t,e)}}}async updateEntry(e,t){let n=await this.getCacheKeys();if(n)for(let i of n){var r;let n=await this.cache.get(i);(n==null||(r=n.body)==null?void 0:r.refresh_token)===e&&(n.body.refresh_token=t,await this.cache.set(i,n))}}},gt=class{constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,s(this,`storageKey`,void 0),this.storageKey=`a0.spajs.txs.${this.clientId}`}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}},_t=e=>typeof e==`number`,vt=`iss.aud.exp.nbf.iat.jti.azp.nonce.auth_time.at_hash.c_hash.acr.amr.sub_jwk.cnf.sip_from_tag.sip_date.sip_callid.sip_cseq_num.sip_via_branch.orig.dest.mky.events.toe.txn.rph.sid.vot.vtm`.split(`.`),yt=e=>{if(!e.id_token)throw Error(`ID token is required but missing`);let t=(e=>{let t=e.split(`.`),[n,r,i]=t;if(t.length!==3||!n||!r||!i)throw Error(`ID token could not be decoded`);let a=JSON.parse(ve(r)),o={__raw:e},s={};return Object.keys(a).forEach(e=>{o[e]=a[e],vt.includes(e)||(s[e]=a[e])}),{encoded:{header:n,payload:r,signature:i},header:JSON.parse(ve(n)),claims:o,user:s}})(e.id_token);if(!t.claims.iss)throw Error(`Issuer (iss) claim must be a string present in the ID token`);if(t.claims.iss!==e.iss)throw Error(`Issuer (iss) claim mismatch in the ID token; expected "${e.iss}", found "${t.claims.iss}"`);if(!t.user.sub)throw Error(`Subject (sub) claim must be a string present in the ID token`);if(t.header.alg!==`RS256`)throw Error(`Signature algorithm of "${t.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!t.claims.aud||typeof t.claims.aud!=`string`&&!Array.isArray(t.claims.aud))throw Error(`Audience (aud) claim must be a string or array of strings present in the ID token`);if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e.aud))throw Error(`Audience (aud) claim mismatch in the ID token; expected "${e.aud}" but was not one of "${t.claims.aud.join(`, `)}"`);if(t.claims.aud.length>1){if(!t.claims.azp)throw Error(`Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values`);if(t.claims.azp!==e.aud)throw Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${e.aud}", found "${t.claims.azp}"`)}}else if(t.claims.aud!==e.aud)throw Error(`Audience (aud) claim mismatch in the ID token; expected "${e.aud}" but found "${t.claims.aud}"`);if(e.nonce){if(!t.claims.nonce)throw Error(`Nonce (nonce) claim must be a string present in the ID token`);if(t.claims.nonce!==e.nonce)throw Error(`Nonce (nonce) claim mismatch in the ID token; expected "${e.nonce}", found "${t.claims.nonce}"`)}if(e.max_age&&!_t(t.claims.auth_time))throw Error(`Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified`);if(t.claims.exp==null||!_t(t.claims.exp))throw Error(`Expiration Time (exp) claim must be a number present in the ID token`);if(!_t(t.claims.iat))throw Error(`Issued At (iat) claim must be a number present in the ID token`);let n=e.leeway||60,r=new Date(e.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(t.claims.exp+n),r>i)throw Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);if(t.claims.nbf!=null&&_t(t.claims.nbf)){let e=new Date(0);if(e.setUTCSeconds(t.claims.nbf-n),r<e)throw Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${e}`)}if(t.claims.auth_time!=null&&_t(t.claims.auth_time)){let i=new Date(0);if(i.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),r>i)throw Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${i}`)}if(e.organization){let n=e.organization.trim();if(n.startsWith(`org_`)){let e=n;if(!t.claims.org_id)throw Error(`Organization ID (org_id) claim must be a string present in the ID token`);if(e!==t.claims.org_id)throw Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${e}", found "${t.claims.org_id}"`)}else{let e=n.toLowerCase();if(!t.claims.org_name)throw Error(`Organization Name (org_name) claim must be a string present in the ID token`);if(e!==t.claims.org_name)throw Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${e}", found "${t.claims.org_name}"`)}}return t},bt=be&&be.__assign||function(){return bt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},bt.apply(this,arguments)};function xt(e,t){if(!t)return``;var n=`; `+e;return!0===t?n:n+`=`+t}function St(e,t,n){return encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,`%28`).replace(/\)/g,`%29`)+`=`+encodeURIComponent(t).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(e){if(typeof e.expires==`number`){var t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t}return xt(`Expires`,e.expires?e.expires.toUTCString():``)+xt(`Domain`,e.domain)+xt(`Path`,e.path)+xt(`Secure`,e.secure)+xt(`SameSite`,e.sameSite)}(n)}function Ct(){return function(e){for(var t={},n=e?e.split(`; `):[],r=/(%[\dA-F]{2})+/gi,i=0;i<n.length;i++){var a=n[i].split(`=`),o=a.slice(1).join(`=`);o.charAt(0)===`"`&&(o=o.slice(1,-1));try{t[a[0].replace(r,decodeURIComponent)]=o.replace(r,decodeURIComponent)}catch{}}return t}(document.cookie)}var wt=function(e){return Ct()[e]};function Tt(e,t,n){document.cookie=St(e,t,bt({path:`/`},n))}var Et=Tt,Dt=function(e,t){Tt(e,``,bt(bt({},t),{expires:-1}))},Ot={get(e){let t=wt(e);if(t!==void 0)return JSON.parse(t)},save(e,t,n){let r={};window.location.protocol===`https:`&&(r={secure:!0,sameSite:`none`}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Et(e,JSON.stringify(t),r)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),Dt(e,n)}},kt=`_legacy_`,At={get(e){return Ot.get(e)||Ot.get(`${kt}${e}`)},save(e,t,n){let r={};window.location.protocol===`https:`&&(r={secure:!0}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Et(`${kt}${e}`,JSON.stringify(t),r),Ot.save(e,t,n)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),Dt(e,n),Ot.remove(e,t),Ot.remove(`${kt}${e}`,t)}},jt={get(e){if(typeof sessionStorage>`u`)return;let t=sessionStorage.getItem(e);return t==null?void 0:JSON.parse(t)},save(e,t){sessionStorage.setItem(e,JSON.stringify(t))},remove(e){sessionStorage.removeItem(e)}},Mt=function(e){return e.Code=`code`,e.ConnectCode=`connect_code`,e}({});function Nt(e,t,n){var r=t===void 0?null:t,i=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),i=0,a=n.length;i<a;++i)r[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(e,n!==void 0&&n),a=i.indexOf(`
2
+ `,10)+1,o=i.substring(a)+(r?`//# sourceMappingURL=`+r:``),s=new Blob([o],{type:`application/javascript`});return URL.createObjectURL(s)}var Pt,Ft,It,Lt,Rt=(Pt=`Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7ZnVuY3Rpb24gZShlLHIsdCl7cmV0dXJuKHI9ZnVuY3Rpb24oZSl7dmFyIHI9ZnVuY3Rpb24oZSxyKXtpZigib2JqZWN0IiE9dHlwZW9mIGV8fCFlKXJldHVybiBlO3ZhciB0PWVbU3ltYm9sLnRvUHJpbWl0aXZlXTtpZih2b2lkIDAhPT10KXt2YXIgbj10LmNhbGwoZSxyfHwiZGVmYXVsdCIpO2lmKCJvYmplY3QiIT10eXBlb2YgbilyZXR1cm4gbjt0aHJvdyBuZXcgVHlwZUVycm9yKCJAQHRvUHJpbWl0aXZlIG11c3QgcmV0dXJuIGEgcHJpbWl0aXZlIHZhbHVlLiIpfXJldHVybigic3RyaW5nIj09PXI/U3RyaW5nOk51bWJlcikoZSl9KGUsInN0cmluZyIpO3JldHVybiJzeW1ib2wiPT10eXBlb2Ygcj9yOnIrIiJ9KHIpKWluIGU/T2JqZWN0LmRlZmluZVByb3BlcnR5KGUscix7dmFsdWU6dCxlbnVtZXJhYmxlOiEwLGNvbmZpZ3VyYWJsZTohMCx3cml0YWJsZTohMH0pOmVbcl09dCxlfWZ1bmN0aW9uIHIoZSxyKXt2YXIgdD1PYmplY3Qua2V5cyhlKTtpZihPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbj1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO3ImJihuPW4uZmlsdGVyKGZ1bmN0aW9uKHIpe3JldHVybiBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKGUscikuZW51bWVyYWJsZX0pKSx0LnB1c2guYXBwbHkodCxuKX1yZXR1cm4gdH1mdW5jdGlvbiB0KHQpe2Zvcih2YXIgbj0xO248YXJndW1lbnRzLmxlbmd0aDtuKyspe3ZhciBvPW51bGwhPWFyZ3VtZW50c1tuXT9hcmd1bWVudHNbbl06e307biUyP3IoT2JqZWN0KG8pLCEwKS5mb3JFYWNoKGZ1bmN0aW9uKHIpe2UodCxyLG9bcl0pfSk6T2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnM/T2JqZWN0LmRlZmluZVByb3BlcnRpZXModCxPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyhvKSk6cihPYmplY3QobykpLmZvckVhY2goZnVuY3Rpb24oZSl7T2JqZWN0LmRlZmluZVByb3BlcnR5KHQsZSxPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKG8sZSkpfSl9cmV0dXJuIHR9Y2xhc3MgbiBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKGUscil7c3VwZXIociksdGhpcy5lcnJvcj1lLHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxuLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKGUpe2xldHtlcnJvcjpyLGVycm9yX2Rlc2NyaXB0aW9uOnR9PWU7cmV0dXJuIG5ldyBuKHIsdCl9fWNsYXNzIG8gZXh0ZW5kcyBue2NvbnN0cnVjdG9yKGUscil7c3VwZXIoIm1pc3NpbmdfcmVmcmVzaF90b2tlbiIsIk1pc3NpbmcgUmVmcmVzaCBUb2tlbiAoYXVkaWVuY2U6ICciLmNvbmNhdChzKGUsWyJkZWZhdWx0Il0pLCInLCBzY29wZTogJyIpLmNvbmNhdChzKHIpLCInKSIpKSx0aGlzLmF1ZGllbmNlPWUsdGhpcy5zY29wZT1yLE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLG8ucHJvdG90eXBlKX19ZnVuY3Rpb24gcyhlKXtyZXR1cm4gZSYmIShhcmd1bWVudHMubGVuZ3RoPjEmJnZvaWQgMCE9PWFyZ3VtZW50c1sxXT9hcmd1bWVudHNbMV06W10pLmluY2x1ZGVzKGUpP2U6IiJ9Y29uc3QgaT1bImNsaWVudElkIl0sYz1lPT57bGV0e2NsaWVudElkOnJ9PWUsbj1mdW5jdGlvbihlLHIpe2lmKG51bGw9PWUpcmV0dXJue307dmFyIHQsbixvPWZ1bmN0aW9uKGUscil7aWYobnVsbD09ZSlyZXR1cm57fTt2YXIgdD17fTtmb3IodmFyIG4gaW4gZSlpZih7fS5oYXNPd25Qcm9wZXJ0eS5jYWxsKGUsbikpe2lmKC0xIT09ci5pbmRleE9mKG4pKWNvbnRpbnVlO3Rbbl09ZVtuXX1yZXR1cm4gdH0oZSxyKTtpZihPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgcz1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO2ZvcihuPTA7bjxzLmxlbmd0aDtuKyspdD1zW25dLC0xPT09ci5pbmRleE9mKHQpJiZ7fS5wcm9wZXJ0eUlzRW51bWVyYWJsZS5jYWxsKGUsdCkmJihvW3RdPWVbdF0pfXJldHVybiBvfShlLGkpO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIocj0+dm9pZCAwIT09ZVtyXSkucmVkdWNlKChyLG4pPT50KHQoe30scikse30se1tuXTplW25dfSkse30pKSh0KHtjbGllbnRfaWQ6cn0sbikpKS50b1N0cmluZygpfTtsZXQgYT17fSxsPW51bGw7Y29uc3QgdT0oZSxyKT0+IiIuY29uY2F0KGUsInwiKS5jb25jYXQociksZj1hc3luYyBlPT57bGV0IHIsbix7ZGF0YTp7dGltZW91dDpzLGF1dGg6aSxmZXRjaFVybDpsLGZldGNoT3B0aW9uczpmLHVzZUZvcm1EYXRhOnAsdXNlTXJydDpofSxwb3J0czpbZF19PWUseT17fTtjb25zdHthdWRpZW5jZTpiLHNjb3BlOk99PWl8fHt9O3RyeXtjb25zdCBlPXA/KGU9Pntjb25zdCByPW5ldyBVUkxTZWFyY2hQYXJhbXMoZSksdD17fTtyZXR1cm4gci5mb3JFYWNoKChlLHIpPT57dFtyXT1lfSksdH0pKGYuYm9keSk6SlNPTi5wYXJzZShmLmJvZHkpO2lmKCFlLnJlZnJlc2hfdG9rZW4mJiJyZWZyZXNoX3Rva2VuIj09PWUuZ3JhbnRfdHlwZSl7aWYobj0oKGUscik9PmFbdShlLHIpXSkoYixPKSwhbiYmaCl7Y29uc3QgZT1hLmxhdGVzdF9yZWZyZXNoX3Rva2VuLHI9KChlLHIpPT57Y29uc3QgdD1PYmplY3Qua2V5cyhhKS5maW5kKHQ9PntpZigibGF0ZXN0X3JlZnJlc2hfdG9rZW4iIT09dCl7Y29uc3Qgbj0oKGUscik9PnIuc3RhcnRzV2l0aCgiIi5jb25jYXQoZSwifCIpKSkocix0KSxvPXQuc3BsaXQoInwiKVsxXS5zcGxpdCgiICIpLHM9ZS5zcGxpdCgiICIpLmV2ZXJ5KGU9Pm8uaW5jbHVkZXMoZSkpO3JldHVybiBuJiZzfX0pO3JldHVybiEhdH0pKE8sYik7ZSYmIXImJihuPWUpfWlmKCFuKXRocm93IG5ldyBvKGIsTyk7Zi5ib2R5PXA/Yyh0KHQoe30sZSkse30se3JlZnJlc2hfdG9rZW46bn0pKTpKU09OLnN0cmluZ2lmeSh0KHQoe30sZSkse30se3JlZnJlc2hfdG9rZW46bn0pKX1sZXQgaSx2OyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihpPW5ldyBBYm9ydENvbnRyb2xsZXIsZi5zaWduYWw9aS5zaWduYWwpO3RyeXt2PWF3YWl0IFByb21pc2UucmFjZShbKGo9cyxuZXcgUHJvbWlzZShlPT5zZXRUaW1lb3V0KGUsaikpKSxmZXRjaChsLHQoe30sZikpXSl9Y2F0Y2goZSl7cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZS5tZXNzYWdlfSl9aWYoIXYpcmV0dXJuIGkmJmkuYWJvcnQoKSx2b2lkIGQucG9zdE1lc3NhZ2Uoe2Vycm9yOiJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCcifSk7dz12LmhlYWRlcnMseT1bLi4ud10ucmVkdWNlKChlLHIpPT57bGV0W3Qsbl09cjtyZXR1cm4gZVt0XT1uLGV9LHt9KSxyPWF3YWl0IHYuanNvbigpLHIucmVmcmVzaF90b2tlbj8oaCYmKGEubGF0ZXN0X3JlZnJlc2hfdG9rZW49ci5yZWZyZXNoX3Rva2VuLGc9bixtPXIucmVmcmVzaF90b2tlbixPYmplY3QuZW50cmllcyhhKS5mb3JFYWNoKGU9PntsZXRbcix0XT1lO3Q9PT1nJiYoYVtyXT1tKX0pKSwoKGUscix0KT0+e2FbdShyLHQpXT1lfSkoci5yZWZyZXNoX3Rva2VuLGIsTyksZGVsZXRlIHIucmVmcmVzaF90b2tlbik6KChlLHIpPT57ZGVsZXRlIGFbdShlLHIpXX0pKGIsTyksZC5wb3N0TWVzc2FnZSh7b2s6di5vayxqc29uOnIsaGVhZGVyczp5fSl9Y2F0Y2goZSl7ZC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9LGhlYWRlcnM6eX0pfXZhciBnLG0sdyxqfTthZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixlPT57Y29uc3R7ZGF0YTpyLHBvcnRzOnR9PWUsW25dPXQ7aWYoInR5cGUiaW4gciYmImluaXQiPT09ci50eXBlKXtpZihudWxsPT09bCl0cnl7bmV3IFVSTChyLmFsbG93ZWRCYXNlVXJsKSxsPXIuYWxsb3dlZEJhc2VVcmx9Y2F0Y2goZSl7cmV0dXJufX1lbHNlImZldGNoVXJsImluIHImJihlPT57aWYoIWwpcmV0dXJuITE7dHJ5e2NvbnN0IHI9bmV3IFVSTChsKS5vcmlnaW4sdD1uZXcgVVJMKGUuZmV0Y2hVcmwpO3JldHVybiB0Lm9yaWdpbj09PXImJiIvb2F1dGgvdG9rZW4iPT09dC5wYXRobmFtZX1jYXRjaChlKXtyZXR1cm4hMX19KShyKT9mKGUpOm51bGw9PW58fG4ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSl9KX0oKTsKCg==`,Ft=null,It=!1,function(e){return Lt||=Nt(Pt,Ft,It),new Worker(Lt,e)}),zt={},Bt=class{constructor(e,t){this.cache=e,this.clientId=t,s(this,`manifestKey`,void 0),this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(e){let t=new Set((await this.cache.get(this.manifestKey))?.keys||[]);t.add(e),await this.cache.set(this.manifestKey,{keys:[...t]})}async remove(e){let t=await this.cache.get(this.manifestKey);if(t){let n=new Set(t.keys);return n.delete(e),n.size>0?await this.cache.set(this.manifestKey,{keys:[...n]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return`${ut}::${e}`}},Vt=[`openUrl`,`onRedirect`],Ht=`auth0.is.authenticated`,Ut={memory:()=>new mt().enclosedCache,localstorage:()=>new pt},Wt=e=>Ut[e],Gt=e=>{let{openUrl:t,onRedirect:n}=e;return l(l({},u(e,Vt)),{},{openUrl:!1===t||t?t:n})},Kt=(e,t)=>{let n=t?.split(` `)||[];return(e?.split(` `)||[]).every(e=>n.includes(e))},qt={NONCE:`nonce`,KEYPAIR:`keypair`},Jt=class{constructor(e){s(this,`clientId`,void 0),s(this,`dbHandle`,void 0),this.clientId=e}getVersion(){return 1}createDbHandle(){let e=window.indexedDB.open(`auth0-spa-js`,this.getVersion());return new Promise((t,n)=>{e.onupgradeneeded=()=>Object.values(qt).forEach(t=>e.result.createObjectStore(t)),e.onerror=()=>n(e.error),e.onsuccess=()=>t(e.result)})}async getDbHandle(){return this.dbHandle||=await this.createDbHandle(),this.dbHandle}async executeDbRequest(e,t,n){let r=n((await this.getDbHandle()).transaction(e,t).objectStore(e));return new Promise((e,t)=>{r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)})}buildKey(e){let t=e?`_${e}`:`auth0`;return`${this.clientId}::${t}`}setNonce(e,t){return this.save(qt.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save(qt.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,`readwrite`,e=>e.put(n,t))}findNonce(e){return this.find(qt.NONCE,this.buildKey(e))}findKeyPair(){return this.find(qt.KEYPAIR,this.buildKey())}find(e,t){return this.executeDbRequest(e,`readonly`,e=>e.get(t))}async deleteBy(e,t){(await this.executeDbRequest(e,`readonly`,e=>e.getAllKeys()))?.filter(t).map(t=>this.executeDbRequest(e,`readwrite`,e=>e.delete(t)))}deleteByClientId(e,t){return this.deleteBy(e,e=>typeof e==`string`&&e.startsWith(`${t}::`))}clearNonces(){return this.deleteByClientId(qt.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(qt.KEYPAIR,this.clientId)}},Yt=class{constructor(e){s(this,`storage`,void 0),this.storage=new Jt(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 Ze(),await this.storage.setKeyPair(e)),e}async generateProof(e){return $e(l({keyPair:await this.getOrGenerateKeyPair()},e))}async calculateThumbprint(){return Qe(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()])}},Xt=function(e){return e.Bearer=`Bearer`,e.DPoP=`DPoP`,e}(Xt||{}),Zt=class{constructor(e,t){s(this,`config`,void 0),s(this,`hooks`,void 0),this.hooks=t,this.config=l(l({},e),{},{fetch:e.fetch||(typeof window>`u`?fetch:window.fetch.bind(window))})}isAbsoluteUrl(e){return/^(https?:)?\/\//i.test(e)}buildUrl(e,t){if(t){if(this.isAbsoluteUrl(t))return t;if(e)return`${e.replace(/\/?\/$/,``)}/${t.replace(/^\/+/,``)}`}throw TypeError("`url` must be absolute or `baseUrl` non-empty.")}getAccessToken(e){return this.config.getAccessToken?this.config.getAccessToken(e):this.hooks.getAccessToken(e)}extractUrl(e){return typeof e==`string`?e:e instanceof URL?e.href:e.url}buildBaseRequest(e,t){if(!this.config.baseUrl)return new Request(e,t);let n=this.buildUrl(this.config.baseUrl,this.extractUrl(e)),r=e instanceof Request?new Request(n,e):n;return new Request(r,t)}setAuthorizationHeader(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xt.Bearer;e.headers.set(`authorization`,`${n} ${t}`)}async setDpopProofHeader(e,t){if(!this.config.dpopNonceId)return;let n=await this.hooks.getDpopNonce(),r=await this.hooks.generateDpopProof({accessToken:t,method:e.method,nonce:n,url:e.url});e.headers.set(`dpop`,r)}async prepareRequest(e,t){let n=await this.getAccessToken(t),r,i;typeof n==`string`?(r=this.config.dpopNonceId?Xt.DPoP:Xt.Bearer,i=n):(r=n.token_type,i=n.access_token),this.setAuthorizationHeader(e,i,r),r===Xt.DPoP&&await this.setDpopProofHeader(e,i)}getHeader(e,t){return Array.isArray(e)?new Headers(e).get(t)||``:typeof e.get==`function`?e.get(t)||``:e[t]||``}hasUseDpopNonceError(e){if(e.status!==401)return!1;let t=this.getHeader(e.headers,`www-authenticate`);return t.includes(`invalid_dpop_nonce`)||t.includes(`use_dpop_nonce`)}async handleResponse(e,t){let n=this.getHeader(e.headers,Ye);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new ce(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,r){let i=this.buildBaseRequest(e,t);await this.prepareRequest(i,r);let a=await this.config.fetch(i);return this.handleResponse(a,n)}fetchWithAuth(e,t,n){let r={onUseDpopNonceError:()=>this.internalFetchWithAuth(e,t,l(l({},r),{},{onUseDpopNonceError:void 0}),n)};return this.internalFetchWithAuth(e,t,r,n)}},Qt=class{constructor(e,t){this.myAccountFetcher=e,this.apiBase=t}async connectAccount(e){let t=await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/connect`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return this._handleResponse(t)}async completeAccount(e){let t=await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/complete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return this._handleResponse(t)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t)}catch(n){throw new $t({type:`invalid_json`,status:e.status,title:`Invalid JSON response`,detail:t||String(n)})}if(e.ok)return t;throw new $t(t)}},$t=class e extends Error{constructor(t){let{type:n,status:r,title:i,detail:a,validation_errors:o}=t;super(a),s(this,`type`,void 0),s(this,`status`,void 0),s(this,`title`,void 0),s(this,`detail`,void 0),s(this,`validation_errors`,void 0),this.name=`MyAccountApiError`,this.type=n,this.status=r,this.title=i,this.detail=a,this.validation_errors=o,Object.setPrototypeOf(this,e.prototype)}},en={otp:{authenticatorTypes:[`otp`]},sms:{authenticatorTypes:[`oob`],oobChannels:[`sms`]},email:{authenticatorTypes:[`oob`],oobChannels:[`email`]},push:{authenticatorTypes:[`oob`],oobChannels:[`auth0`]},voice:{authenticatorTypes:[`oob`],oobChannels:[`voice`]}},tn=`http://auth0.com/oauth/grant-type/mfa-otp`,nn=`http://auth0.com/oauth/grant-type/mfa-oob`,rn=`http://auth0.com/oauth/grant-type/mfa-recovery-code`,an,on,sn;(typeof navigator>`u`||(an=navigator.userAgent)==null||(on=an.startsWith)==null||!on.call(an,`Mozilla/5.0 `))&&(sn=`oauth4webapi/v3.8.5`);function cn(e,t){if(e==null)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch{return!1}}var S=`ERR_INVALID_ARG_VALUE`,C=`ERR_INVALID_ARG_TYPE`;function w(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}var T=Symbol(),ln=Symbol(),un=Symbol(),E=Symbol(),dn=Symbol(),D=Symbol(),fn=new TextEncoder,pn=new TextDecoder;function mn(e){return typeof e==`string`?fn.encode(e):pn.decode(e)}var hn,gn;if(Uint8Array.prototype.toBase64)hn=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:`base64url`,omitPadding:!0}));else{let e=32768;hn=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=e)n.push(String.fromCharCode.apply(null,t.subarray(r,r+e)));return btoa(n.join(``)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}}function _n(e){return typeof e==`string`?gn(e):hn(e)}gn=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:`base64url`})}catch(e){throw w(`The input to be decoded is not correctly encoded.`,S,e)}}:e=>{try{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`).replace(/\s/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch(e){throw w(`The input to be decoded is not correctly encoded.`,S,e)}};var O=class extends Error{constructor(e,t){var n;super(e,t),s(this,`code`,void 0),this.name=this.constructor.name,this.code=mr,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},vn=class extends Error{constructor(e,t){var n;super(e,t),s(this,`code`,void 0),this.name=this.constructor.name,t!=null&&t.code&&(this.code=t?.code),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};function k(e,t,n){return new vn(e,{code:t,cause:n})}function yn(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw w(`${t} must be a CryptoKey`,C)}(e,t),e.type!==`private`)throw w(`${t} must be a private CryptoKey`,S)}function bn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xn(e){cn(e,Headers)&&(e=Object.fromEntries(e.entries()));let t=new Headers(e??{});if(sn&&!t.has(`user-agent`)&&t.set(`user-agent`,sn),t.has(`authorization`))throw w(`"options.headers" must not include the "authorization" header name`,S);return t}function Sn(e,t){if(t!==void 0){if(typeof t==`function`&&(t=t(e.href)),!(t instanceof AbortSignal))throw w(`"options.signal" must return or be an instance of AbortSignal`,C);return t}}function Cn(e){return e.includes(`//`)?e.replace(`//`,`/`):e}async function wn(e,t){return async function(e,t,n,r){if(!(e instanceof URL))throw w(`"${t}" must be an instance of URL`,C);Fn(e,!0!==r?.[T]);let i=n(new URL(e.href)),a=xn(r?.headers);return a.set(`accept`,`application/json`),(r?.[E]||fetch)(i.href,{body:void 0,headers:Object.fromEntries(a.entries()),method:`GET`,redirect:`manual`,signal:Sn(i,r?.signal)})}(e,`issuerIdentifier`,e=>{switch(t?.algorithm){case void 0:case`oidc`:(function(e,t){e.pathname=Cn(`${e.pathname}/${t}`)})(e,`.well-known/openid-configuration`);break;case`oauth2`:(function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2];e.pathname===`/`?e.pathname=t:e.pathname=Cn(`${t}/${n?e.pathname:e.pathname.replace(/(\/)$/,``)}`)})(e,`.well-known/oauth-authorization-server`);break;default:throw w(`"options.algorithm" must be "oidc" (default), or "oauth2"`,S)}return e},t)}function Tn(e,t,n,r,i){try{if(typeof e!=`number`||!Number.isFinite(e))throw w(`${n} must be a number`,C,i);if(e>0)return;if(t){if(e!==0)throw w(`${n} must be a non-negative number`,S,i);return}throw w(`${n} must be a positive number`,S,i)}catch(e){throw r?k(e.message,r,i):e}}function A(e,t,n,r){try{if(typeof e!=`string`)throw w(`${t} must be a string`,C,r);if(e.length===0)throw w(`${t} must not be empty`,S,r)}catch(e){throw n?k(e.message,n,r):e}}function En(e){(function(e,t){if(Xn(e)!==t)throw function(e){let t=`"response" content-type must be `;for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if(r.length>2){let e=r.pop();t+=`${r.join(`, `)}, or ${e}`}else r.length===2?t+=`${r[0]} or ${r[1]}`:t+=r[0];return k(t,_r,e)}(e,t)})(e,`application/json`)}function Dn(){return _n(crypto.getRandomValues(new Uint8Array(32)))}function On(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 O(`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 O(`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 O(`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 O(`unsupported CryptoKey algorithm name`,{cause:e})}}function kn(e){let t=e?.[ln];return typeof t==`number`&&Number.isFinite(t)?t:0}function An(e){let t=e?.[un];return typeof t==`number`&&Number.isFinite(t)&&Math.sign(t)!==-1?t:30}function jn(){return Math.floor(Date.now()/1e3)}function j(e){if(typeof e!=`object`||!e)throw w(`"as" must be an object`,C);A(e.issuer,`"as.issuer"`)}function M(e){if(typeof e!=`object`||!e)throw w(`"client" must be an object`,C);A(e.client_id,`"client.client_id"`)}function Mn(e){return A(e,`"clientSecret"`),(t,n,r,i)=>{r.set(`client_id`,n.client_id),r.set(`client_secret`,e)}}function Nn(e,t){let{key:n,kid:r}=(i=e)instanceof CryptoKey?{key:i}:i?.key instanceof CryptoKey?(i.kid!==void 0&&A(i.kid,`"kid"`),{key:i.key,kid:i.kid}):{};var i;return yn(n,`"clientPrivateKey.key"`),async(e,i,a,o)=>{var s;let c={alg:On(n),kid:r},l=function(e,t){let n=jn()+kn(t);return{jti:Dn(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,i);t==null||(s=t[dn])==null||s.call(t,c,l),a.set(`client_id`,i.client_id),a.set(`client_assertion_type`,`urn:ietf:params:oauth:client-assertion-type:jwt-bearer`),a.set(`client_assertion`,await async function(e,t,n){if(!n.usages.includes(`sign`))throw w(`CryptoKey instances used for signing assertions must include "sign" in their "usages"`,S);let r=`${_n(mn(JSON.stringify(e)))}.${_n(mn(JSON.stringify(t)))}`;return`${r}.${_n(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case`ECDSA`:return{name:e.algorithm.name,hash:Dr(e)};case`RSA-PSS`:switch(Er(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 O(`unsupported RSA-PSS hash name`,{cause:e})}case`RSASSA-PKCS1-v1_5`:return Er(e),e.algorithm.name;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:case`Ed25519`:return e.algorithm.name}throw new O(`unsupported CryptoKey algorithm name`,{cause:e})}(n),n,mn(r)))}`}(c,l,n))}}var Pn=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch{return null}};function Fn(e,t){if(t&&e.protocol!==`https:`)throw k(`only requests to HTTPS are allowed`,yr,e);if(e.protocol!==`https:`&&e.protocol!==`http:`)throw k(`only HTTP and HTTPS requests are allowed`,br,e)}function In(e,t,n,r){let i;if(typeof e!=`string`||!(i=Pn(e)))throw k(`authorization server metadata does not contain a valid ${n?`"as.mtls_endpoint_aliases.${t}"`:`"as.${t}"`}`,e===void 0?Cr:wr,{attribute:n?`mtls_endpoint_aliases.${t}`:t});return Fn(i,r),i}function Ln(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?In(e.mtls_endpoint_aliases[t],t,n,r):In(e[t],t,n,r)}var Rn=class extends Error{constructor(e,t){var n;super(e,t),s(this,`cause`,void 0),s(this,`code`,void 0),s(this,`error`,void 0),s(this,`status`,void 0),s(this,`error_description`,void 0),s(this,`response`,void 0),this.name=this.constructor.name,this.code=pr,this.cause=t.cause,this.error=t.cause.error,this.status=t.response.status,this.error_description=t.cause.error_description,Object.defineProperty(this,`response`,{enumerable:!1,value:t.response}),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},zn=class extends Error{constructor(e,t){var n;super(e,t),s(this,`cause`,void 0),s(this,`code`,void 0),s(this,`error`,void 0),s(this,`error_description`,void 0),this.name=this.constructor.name,this.code=hr,this.cause=t.cause,this.error=t.cause.get(`error`),this.error_description=t.cause.get(`error_description`)??void 0,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},Bn=class extends Error{constructor(e,t){var n;super(e,t),s(this,`cause`,void 0),s(this,`code`,void 0),s(this,`response`,void 0),s(this,`status`,void 0),this.name=this.constructor.name,this.code=fr,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,`response`,{enumerable:!1}),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},Vn="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",Hn=`(`+Vn+`)\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"`,Un=`(`+Vn+")\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)",Wn=RegExp(`^[,\\s]*(`+Vn+`)`),Gn=RegExp(`^[,\\s]*`+Hn+`[,\\s]*(.*)`),Kn=RegExp(`^[,\\s]*`+Un+`[,\\s]*(.*)`),qn=RegExp(`^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)`);async function Jn(e,t,n){if(e.status!==t){let t;throw function(e){let t;if(t=function(e){if(!cn(e,Response))throw w(`"response" must be an instance of Response`,C);let t=e.headers.get(`www-authenticate`);if(t===null)return;let n=[],r=t;for(;r;){let e=r.match(Wn),t=e?.[1].toLowerCase();if(!t)return;let i=r.substring(e[0].length);if(i&&!i.match(/^[\s,]/))return;let a=i.match(/^\s+(.*)$/),o=!!a;r=a?a[1]:void 0;let s={},c;if(o)for(;r;){let t,n;if(e=r.match(Gn)){if([,t,n,r]=e,n.includes(`\\`))try{n=JSON.parse(`"${n}"`)}catch{}s[t.toLowerCase()]=n}else{if(!(e=r.match(Kn))){if(e=r.match(qn)){if(Object.keys(s).length)break;[,c,r]=e;break}return}[,t,n,r]=e,s[t.toLowerCase()]=n}}else r=i||void 0;let l={scheme:t,parameters:s};c&&(l.token68=c),n.push(l)}return n.length?n:void 0}(e))throw new Bn(`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){Tr(e),En(e);try{let t=await e.clone().json();if(bn(t)&&typeof t.error==`string`&&t.error.length)return t}catch{}}}(e))?(await e.body?.cancel(),new Rn(`server responded with an error in the response body`,{cause:t,response:e})):k(`"response" is not a conform ${n} response (unexpected HTTP status code)`,vr,e)}}function Yn(e){if(!ar.has(e))throw w(`"options.DPoP" is not a valid DPoPHandle`,S)}function Xn(e){return e.headers.get(`content-type`)?.split(`;`)[0]}async function Zn(e,t,n,r,i,a,o){return await n(e,t,i,a),a.set(`content-type`,`application/x-www-form-urlencoded;charset=UTF-8`),(o?.[E]||fetch)(r.href,{body:i,headers:Object.fromEntries(a.entries()),method:`POST`,redirect:`manual`,signal:Sn(r,o?.signal)})}async function Qn(e,t,n,r,i,a){var o;let s=Ln(e,`token_endpoint`,t.use_mtls_endpoint_aliases,!0!==a?.[T]);i.set(`grant_type`,r);let c=xn(a?.headers);c.set(`accept`,`application/json`),a?.DPoP!==void 0&&(Yn(a.DPoP),await a.DPoP.addProof(s,c,`POST`));let l=await Zn(e,t,n,s,i,c,a);return a==null||(o=a.DPoP)==null||o.cacheNonce(l,s),l}var $n=new WeakMap,er=new WeakMap;function tr(e){if(!e.id_token)return;let t=$n.get(e);if(!t)throw w(`"ref" was already garbage collected or did not resolve from the proper sources`,S);return t}async function nr(e,t,n,r,i,a){if(j(e),M(t),!cn(n,Response))throw w(`"response" must be an instance of Response`,C);await Jn(n,200,`Token Endpoint`),Tr(n);let o=await Pr(n);if(A(o.access_token,`"response" body "access_token" property`,N,{body:o}),A(o.token_type,`"response" body "token_type" property`,N,{body:o}),o.token_type=o.token_type.toLowerCase(),o.expires_in!==void 0){let e=typeof o.expires_in==`number`?o.expires_in:parseFloat(o.expires_in);Tn(e,!0,`"response" body "expires_in" property`,N,{body:o}),o.expires_in=e}if(o.refresh_token!==void 0&&A(o.refresh_token,`"response" body "refresh_token" property`,N,{body:o}),o.scope!==void 0&&typeof o.scope!=`string`)throw k(`"response" body "scope" property must be a string`,N,{body:o});if(o.id_token!==void 0){A(o.id_token,`"response" body "id_token" property`,N,{body:o});let a=[`aud`,`exp`,`iat`,`iss`,`sub`];!0===t.require_auth_time&&a.push(`auth_time`),t.default_max_age!==void 0&&(Tn(t.default_max_age,!0,`"client.default_max_age"`),a.push(`auth_time`)),r!=null&&r.length&&a.push(...r);let{claims:s,jwt:c}=await async function(e,t,n,r,i){let a,o,{0:s,1:c,length:l}=e.split(`.`);if(l===5){if(i===void 0)throw new O(`JWE decryption is not configured`,{cause:e});e=await i(e),{0:s,1:c,length:l}=e.split(`.`)}if(l!==3)throw k(`Invalid JWT`,N,e);try{a=JSON.parse(mn(_n(s)))}catch(e){throw k(`failed to parse JWT Header body as base64url encoded JSON`,gr,e)}if(!bn(a))throw k(`JWT Header must be a top level object`,N,e);if(t(a),a.crit!==void 0)throw new O(`no JWT "crit" header parameter extensions are supported`,{cause:{header:a}});try{o=JSON.parse(mn(_n(c)))}catch(e){throw k(`failed to parse JWT Payload body as base64url encoded JSON`,gr,e)}if(!bn(o))throw k(`JWT Payload must be a top level object`,N,e);let u=jn()+n;if(o.exp!==void 0){if(typeof o.exp!=`number`)throw k(`unexpected JWT "exp" (expiration time) claim type`,N,{claims:o});if(o.exp<=u-r)throw k(`unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp`,xr,{claims:o,now:u,tolerance:r,claim:`exp`})}if(o.iat!==void 0&&typeof o.iat!=`number`)throw k(`unexpected JWT "iat" (issued at) claim type`,N,{claims:o});if(o.iss!==void 0&&typeof o.iss!=`string`)throw k(`unexpected JWT "iss" (issuer) claim type`,N,{claims:o});if(o.nbf!==void 0){if(typeof o.nbf!=`number`)throw k(`unexpected JWT "nbf" (not before) claim type`,N,{claims:o});if(o.nbf>u+r)throw k(`unexpected JWT "nbf" (not before) claim value`,xr,{claims:o,now:u,tolerance:r,claim:`nbf`})}if(o.aud!==void 0&&typeof o.aud!=`string`&&!Array.isArray(o.aud))throw k(`unexpected JWT "aud" (audience) claim type`,N,{claims:o});return{header:a,claims:o,jwt:e}}(o.id_token,kr.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,`RS256`),kn(t),An(t),i).then(cr.bind(void 0,a)).then(ir.bind(void 0,e)).then(rr.bind(void 0,t.client_id));if(Array.isArray(s.aud)&&s.aud.length!==1){if(s.azp===void 0)throw k(`ID Token "aud" (audience) claim includes additional untrusted audiences`,P,{claims:s,claim:`aud`});if(s.azp!==t.client_id)throw k(`unexpected ID Token "azp" (authorized party) claim value`,P,{expected:t.client_id,claims:s,claim:`azp`})}s.auth_time!==void 0&&Tn(s.auth_time,!0,`ID Token "auth_time" (authentication time)`,N,{claims:s}),er.set(n,c),$n.set(o,s)}if(a?.[o.token_type]!==void 0)a[o.token_type](n,o);else if(o.token_type!==`dpop`&&o.token_type!==`bearer`)throw new O("unsupported `token_type` value",{cause:{body:o}});return o}function rr(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw k(`unexpected JWT "aud" (audience) claim value`,P,{expected:e,claims:t.claims,claim:`aud`})}else if(t.claims.aud!==e)throw k(`unexpected JWT "aud" (audience) claim value`,P,{expected:e,claims:t.claims,claim:`aud`});return t}function ir(e,t){let n=e[Ir]?.call(e,t)??e.issuer;if(t.claims.iss!==n)throw k(`unexpected JWT "iss" (issuer) claim value`,P,{expected:n,claims:t.claims,claim:`iss`});return t}var ar=new WeakSet,or=Symbol(),sr={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 cr(e,t){for(let n of e)if(t.claims[n]===void 0)throw k(`JWT "${n}" (${sr[n]}) claim missing`,N,{claims:t.claims});return t}var lr=Symbol(),ur=Symbol();async function dr(e,t,n,r){return typeof r?.expectedNonce==`string`||typeof r?.maxAge==`number`||r!=null&&r.requireIdToken?async function(e,t,n,r,i,a,o){let s=[];switch(r){case void 0:r=lr;break;case lr:break;default:A(r,`"expectedNonce" argument`),s.push(`nonce`)}switch(i??=t.default_max_age,i){case void 0:i=ur;break;case ur:break;default:Tn(i,!0,`"maxAge" argument`),s.push(`auth_time`)}let c=await nr(e,t,n,s,a,o);A(c.id_token,`"response" body "id_token" property`,N,{body:c});let l=tr(c);if(i!==ur){let e=jn()+kn(t),n=An(t);if(l.auth_time+i<e-n)throw k(`too much time has elapsed since the last End-User authentication`,xr,{claims:l,now:e,tolerance:n,claim:`auth_time`})}if(r===lr){if(l.nonce!==void 0)throw k(`unexpected ID Token "nonce" claim value`,P,{expected:void 0,claims:l,claim:`nonce`})}else if(l.nonce!==r)throw k(`unexpected ID Token "nonce" claim value`,P,{expected:r,claims:l,claim:`nonce`});return c}(e,t,n,r.expectedNonce,r.maxAge,r[D],r.recognizedTokenTypes):async function(e,t,n,r,i){let a=await nr(e,t,n,void 0,r,i),o=tr(a);if(o){if(t.default_max_age!==void 0){Tn(t.default_max_age,!0,`"client.default_max_age"`);let e=jn()+kn(t),n=An(t);if(o.auth_time+t.default_max_age<e-n)throw k(`too much time has elapsed since the last End-User authentication`,xr,{claims:o,now:e,tolerance:n,claim:`auth_time`})}if(o.nonce!==void 0)throw k(`unexpected ID Token "nonce" claim value`,P,{expected:void 0,claims:o,claim:`nonce`})}return a}(e,t,n,r?.[D],r?.recognizedTokenTypes)}var fr=`OAUTH_WWW_AUTHENTICATE_CHALLENGE`,pr=`OAUTH_RESPONSE_BODY_ERROR`,mr=`OAUTH_UNSUPPORTED_OPERATION`,hr=`OAUTH_AUTHORIZATION_RESPONSE_ERROR`,gr=`OAUTH_PARSE_ERROR`,N=`OAUTH_INVALID_RESPONSE`,_r=`OAUTH_RESPONSE_IS_NOT_JSON`,vr=`OAUTH_RESPONSE_IS_NOT_CONFORM`,yr=`OAUTH_HTTP_REQUEST_FORBIDDEN`,br=`OAUTH_REQUEST_PROTOCOL_FORBIDDEN`,xr=`OAUTH_JWT_TIMESTAMP_CHECK_FAILED`,P=`OAUTH_JWT_CLAIM_COMPARISON_FAILED`,Sr=`OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED`,Cr=`OAUTH_MISSING_SERVER_METADATA`,wr=`OAUTH_INVALID_SERVER_METADATA`;function Tr(e){if(e.bodyUsed)throw w(`"response" body has been used already`,S)}function Er(e){let{algorithm:t}=e;if(typeof t.modulusLength!=`number`||t.modulusLength<2048)throw new O(`unsupported ${t.name} modulusLength`,{cause:e})}function Dr(e){let{algorithm:t}=e;switch(t.namedCurve){case`P-256`:return`SHA-256`;case`P-384`:return`SHA-384`;case`P-521`:return`SHA-512`;default:throw new O(`unsupported ECDSA namedCurve`,{cause:e})}}async function Or(e){if(e.method!==`POST`)throw w(`form_post responses are expected to use the POST method`,S,{cause:e});if(Xn(e)!==`application/x-www-form-urlencoded`)throw w(`form_post responses are expected to use the application/x-www-form-urlencoded content-type`,S,{cause:e});return async function(e){if(e.bodyUsed)throw w(`form_post Request instances must contain a readable body`,S,{cause:e});return e.text()}(e)}function kr(e,t,n,r){if(e===void 0)if(Array.isArray(t)){if(!t.includes(r.alg))throw k(`unexpected JWT "alg" header parameter`,N,{header:r,expected:t,reason:`authorization server metadata`})}else{if(n===void 0)throw k(`missing client or server configuration to verify used JWT "alg" header parameter`,void 0,{client:e,issuer:t,fallback:n});if(typeof n==`string`?r.alg!==n:typeof n==`function`?!n(r.alg):!n.includes(r.alg))throw k(`unexpected JWT "alg" header parameter`,N,{header:r,expected:n,reason:`default value`})}else if(typeof e==`string`?r.alg!==e:!e.includes(r.alg))throw k(`unexpected JWT "alg" header parameter`,N,{header:r,expected:e,reason:`client configuration`})}function Ar(e,t){let{0:n,length:r}=e.getAll(t);if(r>1)throw k(`"${t}" parameter must be provided only once`,N);return n}var jr=Symbol(),Mr=Symbol();function Nr(e,t,n,r){if(j(e),M(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw w(`"parameters" must be an instance of URLSearchParams, or URL`,C);if(Ar(n,`response`))throw k(`"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()`,N,{parameters:n});let i=Ar(n,`iss`),a=Ar(n,`state`);if(!i&&e.authorization_response_iss_parameter_supported)throw k(`response parameter "iss" (issuer) missing`,N,{parameters:n});if(i&&i!==e.issuer)throw k(`unexpected "iss" (issuer) response parameter value`,N,{expected:e.issuer,parameters:n});switch(r){case void 0:case Mr:if(a!==void 0)throw k(`unexpected "state" response parameter encountered`,N,{expected:void 0,parameters:n});break;case jr:break;default:if(A(r,`"expectedState" argument`),a!==r)throw k(a===void 0?`response parameter "state" missing`:`unexpected "state" response parameter value`,N,{expected:r,parameters:n})}if(Ar(n,`error`))throw new zn(`authorization response from the server is an error`,{cause:n});let o=Ar(n,`id_token`),s=Ar(n,`token`);if(o!==void 0||s!==void 0)throw new O(`implicit and hybrid flows are not supported`);return c=new URLSearchParams(n),ar.add(c),c;var c}async function Pr(e){let t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:En;try{t=await e.json()}catch(t){throw n(e),k(`failed to parse "response" body as JSON`,gr,t)}if(!bn(t))throw k(`"response" body must be a top level object`,N,{body:t});return t}var Fr=Symbol(),Ir=Symbol(),Lr=new TextEncoder,Rr=new TextDecoder;function zr(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>127)throw TypeError(`non-ASCII string encountered in encode()`);t[n]=r}return t}function Br(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Vr(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:Rr.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=Rr.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return Br(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}var Hr=function(e){return TypeError(`CryptoKey does not support this operation, its ${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`algorithm.name`} must be ${e}`)},Ur=(e,t)=>e.name===t;function Wr(e,t){var n;if((n=e.hash,parseInt(n.name.slice(4),10))!==t)throw Hr(`SHA-${t}`,`algorithm.hash`)}function Gr(e,t,n){switch(t){case`HS256`:case`HS384`:case`HS512`:if(!Ur(e.algorithm,`HMAC`))throw Hr(`HMAC`);Wr(e.algorithm,parseInt(t.slice(2),10));break;case`RS256`:case`RS384`:case`RS512`:if(!Ur(e.algorithm,`RSASSA-PKCS1-v1_5`))throw Hr(`RSASSA-PKCS1-v1_5`);Wr(e.algorithm,parseInt(t.slice(2),10));break;case`PS256`:case`PS384`:case`PS512`:if(!Ur(e.algorithm,`RSA-PSS`))throw Hr(`RSA-PSS`);Wr(e.algorithm,parseInt(t.slice(2),10));break;case`Ed25519`:case`EdDSA`:if(!Ur(e.algorithm,`Ed25519`))throw Hr(`Ed25519`);break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:if(!Ur(e.algorithm,t))throw Hr(t);break;case`ES256`:case`ES384`:case`ES512`:{if(!Ur(e.algorithm,`ECDSA`))throw Hr(`ECDSA`);let n=function(e){switch(e){case`ES256`:return`P-256`;case`ES384`:return`P-384`;case`ES512`:return`P-521`;default:throw Error(`unreachable`)}}(t);if(e.algorithm.namedCurve!==n)throw Hr(n,`algorithm.namedCurve`);break}default:throw TypeError(`CryptoKey does not support this operation`)}(function(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)})(e,n)}function Kr(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];if((r=r.filter(Boolean)).length>2){let t=r.pop();e+=`one of type ${r.join(`, `)}, or ${t}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==`function`&&t.name)e+=` Received function ${t.name}`;else if(typeof t==`object`&&t){var a;(a=t.constructor)!=null&&a.name&&(e+=` Received an instance of ${t.constructor.name}`)}return e}var qr=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return Kr(`Key for the ${e} algorithm must be `,t,...r)},F=class extends Error{constructor(e,t){var n;super(e,t),s(this,`code`,`ERR_JOSE_GENERIC`),this.name=this.constructor.name,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};s(F,`code`,`ERR_JOSE_GENERIC`);var I=class extends F{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),s(this,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`),s(this,`claim`,void 0),s(this,`reason`,void 0),s(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}};s(I,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`);var Jr=class extends F{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),s(this,`code`,`ERR_JWT_EXPIRED`),s(this,`claim`,void 0),s(this,`reason`,void 0),s(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}};s(Jr,`code`,`ERR_JWT_EXPIRED`);var Yr=class extends F{constructor(){super(...arguments),s(this,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`)}};s(Yr,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`);var L=class extends F{constructor(){super(...arguments),s(this,`code`,`ERR_JOSE_NOT_SUPPORTED`)}};s(L,`code`,`ERR_JOSE_NOT_SUPPORTED`),s(class extends F{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`decryption operation failed`,arguments.length>1?arguments[1]:void 0),s(this,`code`,`ERR_JWE_DECRYPTION_FAILED`)}},`code`,`ERR_JWE_DECRYPTION_FAILED`),s(class extends F{constructor(){super(...arguments),s(this,`code`,`ERR_JWE_INVALID`)}},`code`,`ERR_JWE_INVALID`);var R=class extends F{constructor(){super(...arguments),s(this,`code`,`ERR_JWS_INVALID`)}};s(R,`code`,`ERR_JWS_INVALID`);var Xr=class extends F{constructor(){super(...arguments),s(this,`code`,`ERR_JWT_INVALID`)}};s(Xr,`code`,`ERR_JWT_INVALID`),s(class extends F{constructor(){super(...arguments),s(this,`code`,`ERR_JWK_INVALID`)}},`code`,`ERR_JWK_INVALID`);var Zr=class extends F{constructor(){super(...arguments),s(this,`code`,`ERR_JWKS_INVALID`)}};s(Zr,`code`,`ERR_JWKS_INVALID`);var Qr=class extends F{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`no applicable key found in the JSON Web Key Set`,arguments.length>1?arguments[1]:void 0),s(this,`code`,`ERR_JWKS_NO_MATCHING_KEY`)}};s(Qr,`code`,`ERR_JWKS_NO_MATCHING_KEY`);var $r=class extends F{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`multiple matching keys found in the JSON Web Key Set`,arguments.length>1?arguments[1]:void 0),s(this,Symbol.asyncIterator,void 0),s(this,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`)}};s($r,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`);var ei=class extends F{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`request timed out`,arguments.length>1?arguments[1]:void 0),s(this,`code`,`ERR_JWKS_TIMEOUT`)}};s(ei,`code`,`ERR_JWKS_TIMEOUT`);var ti=class extends F{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`signature verification failed`,arguments.length>1?arguments[1]:void 0),s(this,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`)}};s(ti,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`);var ni=e=>{if(e?.[Symbol.toStringTag]===`CryptoKey`)return!0;try{return e instanceof CryptoKey}catch{return!1}},ri=e=>e?.[Symbol.toStringTag]===`KeyObject`,ii=e=>ni(e)||ri(e);function ai(e,t,n){try{return Vr(e)}catch{throw new n(`Failed to base64url decode the ${t}`)}}function oi(e){if(typeof(t=e)!=`object`||t===null||Object.prototype.toString.call(e)!==`[object Object]`)return!1;var t;if(Object.getPrototypeOf(e)===null)return!0;let n=e;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}var si=e=>oi(e)&&typeof e.kty==`string`;async function ci(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith(`HS`))throw TypeError(function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Kr(`Key must be `,e,...n)}(t,`CryptoKey`,`KeyObject`,`JSON Web Key`));return crypto.subtle.importKey(`raw`,t,{hash:`SHA-${e.slice(-3)}`,name:`HMAC`},!1,[n])}return Gr(t,e,n),t}async function li(e,t,n,r){let i=await ci(e,t,`verify`);(function(e,t){if(e.startsWith(`RS`)||e.startsWith(`PS`)){let{modulusLength:n}=t.algorithm;if(typeof n!=`number`||n<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}})(e,i);let a=function(e,t){let n=`SHA-${e.slice(-3)}`;switch(e){case`HS256`:case`HS384`:case`HS512`:return{hash:n,name:`HMAC`};case`PS256`:case`PS384`:case`PS512`:return{hash:n,name:`RSA-PSS`,saltLength:parseInt(e.slice(-3),10)>>3};case`RS256`:case`RS384`:case`RS512`:return{hash:n,name:`RSASSA-PKCS1-v1_5`};case`ES256`:case`ES384`:case`ES512`:return{hash:n,name:`ECDSA`,namedCurve:t.namedCurve};case`Ed25519`:case`EdDSA`:return{name:`Ed25519`};case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:return{name:e};default:throw new L(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}(e,i.algorithm);try{return await crypto.subtle.verify(a,i,n,r)}catch{return!1}}var ui=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;async function di(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=function(e){let t,n;switch(e.kty){case`AKP`:switch(e.alg){case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:t={name:e.alg},n=e.priv?[`sign`]:[`verify`];break;default:throw new L(ui)}break;case`RSA`:switch(e.alg){case`PS256`:case`PS384`:case`PS512`:t={name:`RSA-PSS`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RS256`:case`RS384`:case`RS512`:t={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:t={name:`RSA-OAEP`,hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?[`decrypt`,`unwrapKey`]:[`encrypt`,`wrapKey`];break;default:throw new L(ui)}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 L(ui)}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 L(ui)}break;default:throw new L(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}(e),r=l({},e);return r.kty!==`AKP`&&delete r.alg,delete r.use,crypto.subtle.importKey(`jwk`,r,t,e.ext??(!e.d&&!e.priv),e.key_ops??n)}var fi=`given KeyObject instance cannot be used for this algorithm`,pi,mi=async function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];pi||=new WeakMap;let i=pi.get(e);if(i!=null&&i[n])return i[n];let a=await di(l(l({},t),{},{alg:n}));return r&&Object.freeze(e),i?i[n]=a:pi.set(e,{[n]:a}),a};async function hi(e,t){if(e instanceof Uint8Array||ni(e))return e;if(ri(e)){if(e.type===`secret`)return e.export();if(`toCryptoKey`in e&&typeof e.toCryptoKey==`function`)try{return((e,t)=>{pi||=new WeakMap;let n=pi.get(e);if(n!=null&&n[t])return n[t];let r=e.type===`public`,i=!!r,a;if(e.asymmetricKeyType===`x25519`){switch(t){case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:break;default:throw TypeError(fi)}a=e.toCryptoKey(e.asymmetricKeyType,i,r?[]:[`deriveBits`])}if(e.asymmetricKeyType===`ed25519`){if(t!==`EdDSA`&&t!==`Ed25519`)throw TypeError(fi);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}switch(e.asymmetricKeyType){case`ml-dsa-44`:case`ml-dsa-65`:case`ml-dsa-87`:if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError(fi);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`rsa`){let n;switch(t){case`RSA-OAEP`:n=`SHA-1`;break;case`RS256`:case`PS256`:case`RSA-OAEP-256`:n=`SHA-256`;break;case`RS384`:case`PS384`:case`RSA-OAEP-384`:n=`SHA-384`;break;case`RS512`:case`PS512`:case`RSA-OAEP-512`:n=`SHA-512`;break;default:throw TypeError(fi)}if(t.startsWith(`RSA-OAEP`))return e.toCryptoKey({name:`RSA-OAEP`,hash:n},i,r?[`encrypt`]:[`decrypt`]);a=e.toCryptoKey({name:t.startsWith(`PS`)?`RSA-PSS`:`RSASSA-PKCS1-v1_5`,hash:n},i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`ec`){let n=new Map([[`prime256v1`,`P-256`],[`secp384r1`,`P-384`],[`secp521r1`,`P-521`]]).get(e.asymmetricKeyDetails?.namedCurve);if(!n)throw TypeError(fi);let o={ES256:`P-256`,ES384:`P-384`,ES512:`P-521`};o[t]&&n===o[t]&&(a=e.toCryptoKey({name:`ECDSA`,namedCurve:n},i,[r?`verify`:`sign`])),t.startsWith(`ECDH-ES`)&&(a=e.toCryptoKey({name:`ECDH`,namedCurve:n},i,r?[]:[`deriveBits`]))}if(!a)throw TypeError(fi);return n?n[t]=a:pi.set(e,{[t]:a}),a})(e,t)}catch(e){if(e instanceof TypeError)throw e}return mi(e,e.export({format:`jwk`}),t)}if(si(e))return e.k?Vr(e.k):mi(e,e,t,!0);throw Error(`unreachable`)}var gi=(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},_i=e=>{let t=e.data[e.pos++];if(128&t){let n=127&t,r=0;for(let t=0;t<n;t++)r=r<<8|e.data[e.pos++];return r}return t},vi=(e,t,n)=>{if(e.data[e.pos++]!==t)throw Error(n)},yi=(e,t)=>{let n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n},bi=e=>{let t=(e=>(vi(e,6,`Expected algorithm OID`),yi(e,_i(e))))(e);if(gi(t,[43,101,110]))return`X25519`;if(!gi(t,[42,134,72,206,61,2,1]))throw Error(`Unsupported key algorithm`);vi(e,6,`Expected curve OID`);let n=yi(e,_i(e));for(let{name:e,oid:t}of[{name:`P-256`,oid:[42,134,72,206,61,3,1,7]},{name:`P-384`,oid:[43,129,4,0,34]},{name:`P-521`,oid:[43,129,4,0,35]}])if(gi(n,t))return e;throw Error(`Unsupported named curve`)},xi=async(e,t,n,r)=>{let i,a,o=e===`spki`,s=()=>o?[`verify`]:[`sign`];switch(n){case`PS256`:case`PS384`:case`PS512`:i={name:`RSA-PSS`,hash:`SHA-${n.slice(-3)}`},a=s();break;case`RS256`:case`RS384`:case`RS512`:i={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${n.slice(-3)}`},a=s();break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:i={name:`RSA-OAEP`,hash:`SHA-${parseInt(n.slice(-3),10)||1}`},a=o?[`encrypt`,`wrapKey`]:[`decrypt`,`unwrapKey`];break;case`ES256`:case`ES384`:case`ES512`:i={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[n]},a=s();break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:try{let e=r.getNamedCurve(t);i=e===`X25519`?{name:`X25519`}:{name:`ECDH`,namedCurve:e}}catch{throw new L(`Invalid or unsupported key format`)}a=o?[]:[`deriveBits`];break;case`Ed25519`:case`EdDSA`:i={name:`Ed25519`},a=s();break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:i={name:n},a=s();break;default:throw new L(`Invalid or unsupported "alg" (Algorithm) value`)}return crypto.subtle.importKey(e,t,i,r?.extractable??!!o,a)},Si=(e,t,n)=>{var r;let i=((e,t)=>Br(e.replace(t,``)))(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g),a=n;return t!=null&&(r=t.startsWith)!=null&&r.call(t,`ECDH-ES`)&&(a||={},a.getNamedCurve=e=>{let t={data:e,pos:0};return function(e){vi(e,48,`Invalid PKCS#8 structure`),_i(e),vi(e,2,`Expected version field`);let t=_i(e);e.pos+=t,vi(e,48,`Expected algorithm identifier`),_i(e),e.pos}(t),bi(t)}),xi(`pkcs8`,i,t,a)},Ci=e=>e?.[Symbol.toStringTag],wi=(e,t,n)=>{if(t.use!==void 0){let e;switch(n){case`sign`:case`verify`:e=`sig`;break;case`encrypt`:case`decrypt`:e=`enc`}if(t.use!==e)throw TypeError(`Invalid key for this operation, its "use" must be "${e}" when present`)}if(t.alg!==void 0&&t.alg!==e)throw TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){var r,i;let a;switch(!0){case n===`sign`||n===`verify`:case e===`dir`:case e.includes(`CBC-HS`):a=n;break;case e.startsWith(`PBES2`):a=`deriveBits`;break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):a=!e.includes(`GCM`)&&e.endsWith(`KW`)?n===`encrypt`?`wrapKey`:`unwrapKey`:n;break;case n===`encrypt`&&e.startsWith(`RSA`):a=`wrapKey`;break;case n===`decrypt`:a=e.startsWith(`RSA`)?`unwrapKey`:`deriveBits`}if(a&&!1===((r=t.key_ops)==null||(i=r.includes)==null?void 0:i.call(r,a)))throw TypeError(`Invalid key for this operation, its "key_ops" must include "${a}" when present`)}return!0};function Ti(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(si(t)){if((e=>e.kty===`oct`&&typeof e.k==`string`)(t)&&wi(e,t,n))return;throw TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`)}if(!ii(t))throw TypeError(qr(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`,`Uint8Array`));if(t.type!==`secret`)throw TypeError(`${Ci(t)} instances for symmetric algorithms must be of type "secret"`)}})(e,t,n);break;default:((e,t,n)=>{if(si(t))switch(n){case`decrypt`:case`sign`:if((e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`))(t)&&wi(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a private JWK`);case`encrypt`:case`verify`:if((e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0)(t)&&wi(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a public JWK`)}if(!ii(t))throw TypeError(qr(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`));if(t.type===`secret`)throw TypeError(`${Ci(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type===`public`)switch(n){case`sign`:throw TypeError(`${Ci(t)} instances for asymmetric algorithm signing must be of type "private"`);case`decrypt`:throw TypeError(`${Ci(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type===`private`)switch(n){case`verify`:throw TypeError(`${Ci(t)} instances for asymmetric algorithm verifying must be of type "public"`);case`encrypt`:throw TypeError(`${Ci(t)} instances for asymmetric algorithm encryption must be of type "public"`)}})(e,t,n)}}var Ei,Di,z,Oi;(typeof navigator>`u`||(Ei=navigator.userAgent)==null||(Di=Ei.startsWith)==null||!Di.call(Ei,`Mozilla/5.0 `))&&(Oi=`openid-client/v6.8.2`,z={"user-agent":Oi});var B=e=>ki.get(e),ki,Ai;function ji(e){return e===void 0?(Ai||=new WeakMap,(e,t,n,r)=>{let i;return(i=Ai.get(t))||(function(e,t){if(typeof e!=`string`)throw H(`${t} must be a string`,Ni);if(e.length===0)throw H(`${t} must not be empty`,Mi)}(t.client_secret,`"metadata.client_secret"`),i=Mn(t.client_secret),Ai.set(t,i)),i(e,t,n,r)}):Mn(e)}var V=E,Mi=`ERR_INVALID_ARG_VALUE`,Ni=`ERR_INVALID_ARG_TYPE`;function H(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}function Pi(e){return async function(e){return A(e,`codeVerifier`),_n(await crypto.subtle.digest(`SHA-256`,mn(e)))}(e)}function Fi(){return Dn()}var Ii=class extends Error{constructor(e,t){var n;super(e,t),s(this,`code`,void 0),this.name=this.constructor.name,this.code=t?.code,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};function U(e,t,n){return new Ii(e,{cause:t,code:n})}function W(e){if(e instanceof TypeError||e instanceof Ii||e instanceof Rn||e instanceof zn||e instanceof Bn)throw e;if(e instanceof vn)switch(e.code){case yr:throw U(`only requests to HTTPS are allowed`,e,e.code);case br:throw U(`only requests to HTTP or HTTPS are allowed`,e,e.code);case vr:throw U(`unexpected HTTP response status code`,e.cause,e.code);case _r:throw U(`unexpected response content-type`,e.cause,e.code);case gr:throw U(`parsing error occured`,e,e.code);case N:throw U(`invalid response encountered`,e,e.code);case P:throw U(`unexpected JWT claim value encountered`,e,e.code);case Sr:throw U(`unexpected JSON attribute value encountered`,e,e.code);case xr:throw U(`JWT timestamp claim value failed validation`,e,e.code);default:throw U(e.message,e,e.code)}if(e instanceof O)throw U(`unsupported operation`,e,e.code);if(e instanceof DOMException)switch(e.name){case`OperationError`:throw U(`runtime operation error`,e,mr);case`NotSupportedError`:throw U(`runtime unsupported operation`,e,mr);case`TimeoutError`:throw U(`operation timed out`,e,`OAUTH_TIMEOUT`);case`AbortError`:throw U(`operation aborted`,e,`OAUTH_ABORT`)}throw new Ii(`something went wrong`,{cause:e})}async function Li(e,t,n,r,i){let a=new zi(await async function(e,t){var n;if(!(e instanceof URL))throw H(`"server" must be an instance of URL`,Ni);let r=!e.href.includes(`/.well-known/`),i=t?.timeout??30,a=AbortSignal.timeout(1e3*i),o=await(r?wn(e,{algorithm:t?.algorithm,[E]:t?.[V],[T]:t==null||(n=t.execute)==null?void 0:n.includes(Gi),signal:a,headers:new Headers(z)}):(t?.[V]||fetch)((Fn(e,t==null||(s=t.execute)==null||!s.includes(Gi)),e.href),{headers:Object.fromEntries(new Headers(l({accept:`application/json`},z)).entries()),body:void 0,method:`GET`,redirect:`manual`,signal:a})).then(e=>async function(e,t){let n=e;if(!(n instanceof URL)&&n!==Fr)throw w(`"expectedIssuerIdentifier" must be an instance of URL`,C);if(!cn(t,Response))throw w(`"response" must be an instance of Response`,C);if(t.status!==200)throw k(`"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)`,vr,t);Tr(t);let r=await Pr(t);if(A(r.issuer,`"response" body "issuer" property`,N,{body:r}),n!==Fr&&new URL(r.issuer).href!==n.href)throw k(`"response" body "issuer" property does not match the expected value`,Sr,{expected:n.href,body:r,attribute:`issuer`});return r}(Fr,e)).catch(W);var s;return r&&new URL(o.issuer).href!==e.href&&(function(e,t,n){return!(e.origin!==`https://login.microsoftonline.com`||n!=null&&n.algorithm&&n.algorithm!==`oidc`||(t[Ri]=!0,0))}(e,o,t)||function(e,t){return!(!e.hostname.endsWith(`.b2clogin.com`)||t!=null&&t.algorithm&&t.algorithm!==`oidc`)}(e,t)||(()=>{throw new Ii(`discovered metadata issuer does not match the expected issuer`,{code:Sr,cause:{expected:e.href,body:o,attribute:`issuer`}})})()),o}(e,i),t,n,r),o=B(a);if(i!=null&&i[V]&&(o.fetch=i[V]),i!=null&&i.timeout&&(o.timeout=i.timeout),i!=null&&i.execute)for(let e of i.execute)e(a);return a}new TextDecoder;var Ri=Symbol(),zi=class{constructor(e,t,n,r){if(typeof t!=`string`||!t.length)throw H(`"clientId" must be a non-empty string`,Ni);if(typeof n==`string`&&(n={client_secret:n}),n?.client_id!==void 0&&t!==n.client_id)throw H(`"clientId" and "metadata.client_id" must be the same`,Mi);let i=l(l({},structuredClone(n)),{},{client_id:t}),a;i[ln]=n?.[ln]??0,i[un]=n?.[un]??30,a=r||(typeof i.client_secret==`string`&&i.client_secret.length?ji(i.client_secret):(e,t,n,r)=>{n.set(`client_id`,t.client_id)});let o=Object.freeze(i),s=structuredClone(e);Ri in e&&(s[Ir]=t=>{let{claims:{tid:n}}=t;return e.issuer.replace(`{tenantid}`,n)});let c=Object.freeze(s);ki||=new WeakMap,ki.set(this,{__proto__:null,as:c,c:o,auth:a,tlsOnly:!0,jwksCache:{}})}serverMetadata(){let e=structuredClone(B(this).as);return function(e){Object.defineProperties(e,function(e){return{supportsPKCE:{__proto__:null,value(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`S256`;return!0===e.code_challenge_methods_supported?.includes(t)}}}}(e))}(e),e}clientMetadata(){return structuredClone(B(this).c)}get timeout(){return B(this).timeout}set timeout(e){B(this).timeout=e}get[V](){return B(this).fetch}set[V](e){B(this).fetch=e}};function Bi(e){Object.defineProperties(e,function(e){let t;if(e.expires_in!==void 0){let n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime()}return{expiresIn:{__proto__:null,value(){if(t){let e=Date.now();return t>e?Math.floor((t-e)/1e3):0}}},claims:{__proto__:null,value(){try{return tr(this)}catch{return}}}}}(e))}async function Vi(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3],i=e.headers.get(`retry-after`)?.trim();if(i===void 0)return;let a;if(/^\d+$/.test(i))a=parseInt(i,10);else{let e=new Date(i);if(Number.isFinite(e.getTime())){let t=new Date,n=e.getTime()-t.getTime();n>0&&(a=Math.ceil(n/1e3))}}if(r&&!Number.isFinite(a))throw new vn(`invalid Retry-After header value`,{cause:e});a>t&&await Hi(a-t,n)}function Hi(e,t){return new Promise((n,r)=>{let i=e=>{try{t.throwIfAborted()}catch(e){r(e);return}if(e<=0)return void n();let a=Math.min(e,5);setTimeout(()=>i(e-a),1e3*a)};i(e)})}async function Ui(e,t){Zi(e);let{as:n,c:r,auth:i,fetch:a,tlsOnly:o,timeout:s}=B(e);return async function(e,t,n,r,i){j(e),M(t);let a=Ln(e,`backchannel_authentication_endpoint`,t.use_mtls_endpoint_aliases,!0!==i?.[T]),o=new URLSearchParams(r);o.set(`client_id`,t.client_id);let s=xn(i?.headers);return s.set(`accept`,`application/json`),Zn(e,t,n,a,o,s,i)}(n,r,i,t,{[E]:a,[T]:!o,headers:new Headers(z),signal:Qi(s)}).then(e=>async function(e,t,n){if(j(e),M(t),!cn(n,Response))throw w(`"response" must be an instance of Response`,C);await Jn(n,200,`Backchannel Authentication Endpoint`),Tr(n);let r=await Pr(n);A(r.auth_req_id,`"response" body "auth_req_id" property`,N,{body:r});let i=typeof r.expires_in==`number`?r.expires_in:parseFloat(r.expires_in);return Tn(i,!0,`"response" body "expires_in" property`,N,{body:r}),r.expires_in=i,r.interval!==void 0&&Tn(r.interval,!1,`"response" body "interval" property`,N,{body:r}),r}(n,r,e)).catch(W)}async function Wi(e,t,n,r){Zi(e),n=new URLSearchParams(n);let i=t.interval??5,a=r?.signal??AbortSignal.timeout(1e3*t.expires_in);try{await Hi(i,a)}catch(e){W(e)}let{as:o,c:s,auth:c,fetch:u,tlsOnly:d,nonRepudiation:f,timeout:p,decrypt:m}=B(e),h=(i,o)=>Wi(e,l(l({},t),{},{interval:i}),n,l(l({},r),{},{signal:a,flag:o})),g=await async function(e,t,n,r,i){j(e),M(t),A(r,`"authReqId"`);let a=new URLSearchParams(i?.additionalParameters);return a.set(`auth_req_id`,r),Qn(e,t,n,`urn:openid:params:grant-type:ciba`,a,i)}(o,s,c,t.auth_req_id,{[E]:u,[T]:!d,additionalParameters:n,DPoP:r?.DPoP,headers:new Headers(z),signal:a.aborted?a:Qi(p)}).catch(W);if(g.status===503&&g.headers.has(`retry-after`))return await Vi(g,i,a,!0),await g.body?.cancel(),h(i);let _=async function(e,t,n,r){return nr(e,t,n,void 0,r?.[D],r?.recognizedTokenTypes)}(o,s,g,{[D]:m}),v;try{v=await _}catch(e){if($i(e,r))return h(i,ea);if(e instanceof Rn)switch(e.error){case`slow_down`:i+=5;case`authorization_pending`:return await Vi(e.response,i,a),h(i)}W(e)}return v.id_token&&await f?.(g),Bi(v),v}function Gi(e){B(e).tlsOnly=!1}async function Ki(e,t,n,r,i){if(Zi(e),!(i?.flag===ea||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch{return!1}}(t,`Request`)))throw H(`"currentUrl" must be an instance of URL, or Request`,Ni);let a,o,{as:s,c,auth:u,fetch:d,tlsOnly:f,jarm:p,hybrid:m,nonRepudiation:h,timeout:g,decrypt:_,implicit:v}=B(e);if(i?.flag===ea)a=i.authResponse,o=i.redirectUri;else{if(!(t instanceof URL)){let e=t;switch(t=new URL(t.url),e.method){case`GET`:break;case`POST`:let n=new URLSearchParams(await Or(e));if(m)t.hash=n.toString();else for(let[e,r]of n.entries())t.searchParams.append(e,r);break;default:throw H(`unexpected Request HTTP method`,Mi)}}switch(o=function(e){return(e=new URL(e)).search=``,e.hash=``,e.href}(t),!0){case!!p:a=await p(t,n?.expectedState);break;case!!m:a=await m(t,n?.expectedNonce,n?.expectedState,n?.maxAge);break;case!!v:throw TypeError(`authorizationCodeGrant() cannot be used by response_type=id_token clients`);default:try{a=Nr(s,c,t.searchParams,n?.expectedState)}catch(e){W(e)}}}let ee=await async function(e,t,n,r,i,a,o){if(j(e),M(t),!ar.has(r))throw w(`"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()`,S);A(i,`"redirectUri"`);let s=Ar(r,`code`);if(!s)throw k(`no authorization code in "callbackParameters"`,N);let c=new URLSearchParams(o?.additionalParameters);return c.set(`redirect_uri`,i),c.set(`code`,s),a!==or&&(A(a,`"codeVerifier"`),c.set(`code_verifier`,a)),Qn(e,t,n,`authorization_code`,c,o)}(s,c,u,a,o,n?.pkceCodeVerifier||or,{additionalParameters:r,[E]:d,[T]:!f,DPoP:i?.DPoP,headers:new Headers(z),signal:Qi(g)}).catch(W);typeof n?.expectedNonce!=`string`&&typeof n?.maxAge!=`number`||(n.idTokenExpected=!0);let y=dr(s,c,ee,{expectedNonce:n?.expectedNonce,maxAge:n?.maxAge,requireIdToken:n?.idTokenExpected,[D]:_}),te;try{te=await y}catch(t){if($i(t,i))return Ki(e,void 0,n,r,l(l({},i),{},{flag:ea,authResponse:a,redirectUri:o}));W(t)}return te.id_token&&await h?.(ee),Bi(te),te}async function qi(e,t,n,r){Zi(e),n=new URLSearchParams(n);let{as:i,c:a,auth:o,fetch:s,tlsOnly:c,nonRepudiation:u,timeout:d,decrypt:f}=B(e),p=await async function(e,t,n,r,i){j(e),M(t),A(r,`"refreshToken"`);let a=new URLSearchParams(i?.additionalParameters);return a.set(`refresh_token`,r),Qn(e,t,n,`refresh_token`,a,i)}(i,a,o,t,{[E]:s,[T]:!c,additionalParameters:n,DPoP:r?.DPoP,headers:new Headers(z),signal:Qi(d)}).catch(W),m=async function(e,t,n,r){return nr(e,t,n,void 0,r?.[D],r?.recognizedTokenTypes)}(i,a,p,{[D]:f}),h;try{h=await m}catch(i){if($i(i,r))return qi(e,t,n,l(l({},r),{},{flag:ea}));W(i)}return h.id_token&&await u?.(p),Bi(h),h}async function Ji(e,t,n){Zi(e),t=new URLSearchParams(t);let{as:r,c:i,auth:a,fetch:o,tlsOnly:s,timeout:c}=B(e),u=async function(e,t,n,r){return nr(e,t,n,void 0,r?.[D],r?.recognizedTokenTypes)}(r,i,await async function(e,t,n,r,i){return j(e),M(t),Qn(e,t,n,`client_credentials`,new URLSearchParams(r),i)}(r,i,a,t,{[E]:o,[T]:!s,DPoP:n?.DPoP,headers:new Headers(z),signal:Qi(c)}).catch(W)),d;try{d=await u}catch(r){if($i(r,n))return Ji(e,t,l(l({},n),{},{flag:ea}));W(r)}return Bi(d),d}function Yi(e,t){Zi(e);let{as:n,c:r,tlsOnly:i,hybrid:a,jarm:o,implicit:s}=B(e),c=Ln(n,`authorization_endpoint`,!1,i);if((t=new URLSearchParams(t)).has(`client_id`)||t.set(`client_id`,r.client_id),!t.has(`request_uri`)&&!t.has(`request`)){if(t.has(`response_type`)||t.set(`response_type`,a?`code id_token`:s?`id_token`:`code`),s&&!t.has(`nonce`))throw H(`response_type=id_token clients must provide a nonce parameter in their authorization request parameters`,Mi);o&&t.set(`response_mode`,`jwt`)}for(let[e,n]of t.entries())c.searchParams.append(e,n);return c}async function Xi(e,t,n){Zi(e);let r=Yi(e,t),{as:i,c:a,auth:o,fetch:s,tlsOnly:c,timeout:u}=B(e),d=async function(e,t,n){if(j(e),M(t),!cn(n,Response))throw w(`"response" must be an instance of Response`,C);await Jn(n,201,`Pushed Authorization Request Endpoint`),Tr(n);let r=await Pr(n);A(r.request_uri,`"response" body "request_uri" property`,N,{body:r});let i=typeof r.expires_in==`number`?r.expires_in:parseFloat(r.expires_in);return Tn(i,!0,`"response" body "expires_in" property`,N,{body:r}),r.expires_in=i,r}(i,a,await async function(e,t,n,r,i){var a;j(e),M(t);let o=Ln(e,`pushed_authorization_request_endpoint`,t.use_mtls_endpoint_aliases,!0!==i?.[T]),s=new URLSearchParams(r);s.set(`client_id`,t.client_id);let c=xn(i?.headers);c.set(`accept`,`application/json`),i?.DPoP!==void 0&&(Yn(i.DPoP),await i.DPoP.addProof(o,c,`POST`));let l=await Zn(e,t,n,o,s,c,i);return i==null||(a=i.DPoP)==null||a.cacheNonce(l,o),l}(i,a,o,r.searchParams,{[E]:s,[T]:!c,DPoP:n?.DPoP,headers:new Headers(z),signal:Qi(u)}).catch(W)),f;try{f=await d}catch(r){if($i(r,n))return Xi(e,t,l(l({},n),{},{flag:ea}));W(r)}return Yi(e,{request_uri:f.request_uri})}function Zi(e){if(!(e instanceof zi))throw H(`"config" must be an instance of Configuration`,Ni);if(Object.getPrototypeOf(e)!==zi.prototype)throw H(`subclassing Configuration is not allowed`,Mi)}function Qi(e){return e?AbortSignal.timeout(1e3*e):void 0}function $i(e,t){return!(t==null||!t.DPoP||t.flag===ea)&&function(e){if(e instanceof Bn){let{0:t,length:n}=e.cause;return n===1&&t.scheme===`dpop`&&t.parameters.error===`use_dpop_nonce`}return e instanceof Rn&&e.error===`use_dpop_nonce`}(e)}Object.freeze(zi.prototype);var ea=Symbol();async function ta(e,t,n,r){Zi(e);let{as:i,c:a,auth:o,fetch:s,tlsOnly:c,timeout:l,decrypt:u}=B(e),d=await async function(e,t,n,r,i,a){return j(e),M(t),A(r,`"grantType"`),Qn(e,t,n,r,new URLSearchParams(i),a)}(i,a,o,t,new URLSearchParams(n),{[E]:s,[T]:!c,DPoP:r?.DPoP,headers:new Headers(z),signal:Qi(l)}).then(e=>{let n;return t===`urn:ietf:params:oauth:grant-type:token-exchange`&&(n={n_a:()=>{}}),async function(e,t,n,r){return nr(e,t,n,void 0,r?.[D],r?.recognizedTokenTypes)}(i,a,e,{[D]:u,recognizedTokenTypes:n})}).catch(W);return Bi(d),d}async function na(e,t,n){if(!oi(e))throw new R(`Flattened JWS must be an object`);if(e.protected===void 0&&e.header===void 0)throw new R(`Flattened JWS must have either of the "protected" or "header" members`);if(e.protected!==void 0&&typeof e.protected!=`string`)throw new R(`JWS Protected Header incorrect type`);if(e.payload===void 0)throw new R(`JWS Payload missing`);if(typeof e.signature!=`string`)throw new R(`JWS Signature missing or incorrect type`);if(e.header!==void 0&&!oi(e.header))throw new R(`JWS Unprotected Header incorrect type`);let r={};if(e.protected)try{let t=Vr(e.protected);r=JSON.parse(Rr.decode(t))}catch{throw new R(`JWS Protected Header is invalid`)}if(!function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let r=t.filter(Boolean);if(r.length===0||r.length===1)return!0;let i;for(let e of r){let t=Object.keys(e);if(i&&i.size!==0)for(let e of t){if(i.has(e))return!1;i.add(e)}else i=new Set(t)}return!0}(r,e.header))throw new R(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let i=l(l({},r),e.header),a=function(e,t,n,r,i){if(i.crit!==void 0&&r?.crit===void 0)throw new e(`"crit" (Critical) Header Parameter MUST be integrity protected`);if(!r||r.crit===void 0)return new Set;if(!Array.isArray(r.crit)||r.crit.length===0||r.crit.some(e=>typeof e!=`string`||e.length===0))throw new e(`"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present`);let a;a=n===void 0?t:new Map([...Object.entries(n),...t.entries()]);for(let t of r.crit){if(!a.has(t))throw new L(`Extension Header Parameter "${t}" is not recognized`);if(i[t]===void 0)throw new e(`Extension Header Parameter "${t}" is missing`);if(a.get(t)&&r[t]===void 0)throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(r.crit)}(R,new Map([[`b64`,!0]]),n?.crit,r,i),o=!0;if(a.has(`b64`)&&(o=r.b64,typeof o!=`boolean`))throw new R(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:s}=i;if(typeof s!=`string`||!s)throw new R(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);let c=n&&function(e,t){if(t!==void 0&&(!Array.isArray(t)||t.some(e=>typeof e!=`string`)))throw TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}(`algorithms`,n.algorithms);if(c&&!c.has(s))throw new Yr(`"alg" (Algorithm) Header Parameter value not allowed`);if(o){if(typeof e.payload!=`string`)throw new R(`JWS Payload must be a string`)}else if(typeof e.payload!=`string`&&!(e.payload instanceof Uint8Array))throw new R(`JWS Payload must be a string or an Uint8Array instance`);let u=!1;typeof t==`function`&&(t=await t(r,e),u=!0),Ti(s,t,`verify`);let d=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let r=t.reduce((e,t)=>{let{length:n}=t;return e+n},0),i=new Uint8Array(r),a=0;for(let e of t)i.set(e,a),a+=e.length;return i}(e.protected===void 0?new Uint8Array:zr(e.protected),zr(`.`),typeof e.payload==`string`?o?zr(e.payload):Lr.encode(e.payload):e.payload),f=ai(e.signature,`signature`,R),p=await hi(t,s);if(!await li(s,p,f,d))throw new ti;let m;m=o?ai(e.payload,`payload`,R):typeof e.payload==`string`?Lr.encode(e.payload):e.payload;let h={payload:m};return e.protected!==void 0&&(h.protectedHeader=r),e.header!==void 0&&(h.unprotectedHeader=e.header),u?l(l({},h),{},{key:p}):h}var ra=86400,ia=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function aa(e){let t=ia.exec(e);if(!t||t[4]&&t[1])throw TypeError(`Invalid time period format`);let n=parseFloat(t[2]),r;switch(t[3].toLowerCase()){case`sec`:case`secs`:case`second`:case`seconds`:case`s`:r=Math.round(n);break;case`minute`:case`minutes`:case`min`:case`mins`:case`m`:r=Math.round(60*n);break;case`hour`:case`hours`:case`hr`:case`hrs`:case`h`:r=Math.round(3600*n);break;case`day`:case`days`:case`d`:r=Math.round(n*ra);break;case`week`:case`weeks`:case`w`:r=Math.round(604800*n);break;default:r=Math.round(31557600*n)}return t[1]===`-`||t[4]===`ago`?-r:r}var oa=e=>e.includes(`/`)?e.toLowerCase():`application/${e.toLowerCase()}`;function sa(e,t){let n,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};try{n=JSON.parse(Rr.decode(t))}catch{}if(!oi(n))throw new Xr(`JWT Claims Set must be a top-level JSON object`);let{typ:i}=r;if(i&&(typeof e.typ!=`string`||oa(e.typ)!==oa(i)))throw new I(`unexpected "typ" JWT header value`,n,`typ`,`check_failed`);let{requiredClaims:a=[],issuer:o,subject:s,audience:c,maxTokenAge:l}=r,u=[...a];l!==void 0&&u.push(`iat`),c!==void 0&&u.push(`aud`),s!==void 0&&u.push(`sub`),o!==void 0&&u.push(`iss`);for(let e of new Set(u.reverse()))if(!(e in n))throw new I(`missing required "${e}" claim`,n,e,`missing`);if(o&&!(Array.isArray(o)?o:[o]).includes(n.iss))throw new I(`unexpected "iss" claim value`,n,`iss`,`check_failed`);if(s&&n.sub!==s)throw new I(`unexpected "sub" claim value`,n,`sub`,`check_failed`);if(c&&(d=n.aud,f=typeof c==`string`?[c]:c,!(typeof d==`string`?f.includes(d):Array.isArray(d)&&f.some(Set.prototype.has.bind(new Set(d))))))throw new I(`unexpected "aud" claim value`,n,`aud`,`check_failed`);var d,f;let p;switch(typeof r.clockTolerance){case`string`:p=aa(r.clockTolerance);break;case`number`:p=r.clockTolerance;break;case`undefined`:p=0;break;default:throw TypeError(`Invalid clockTolerance option type`)}let{currentDate:m}=r,h=(g=m||new Date,Math.floor(g.getTime()/1e3));var g;if((n.iat!==void 0||l)&&typeof n.iat!=`number`)throw new I(`"iat" claim must be a number`,n,`iat`,`invalid`);if(n.nbf!==void 0){if(typeof n.nbf!=`number`)throw new I(`"nbf" claim must be a number`,n,`nbf`,`invalid`);if(n.nbf>h+p)throw new I(`"nbf" claim timestamp check failed`,n,`nbf`,`check_failed`)}if(n.exp!==void 0){if(typeof n.exp!=`number`)throw new I(`"exp" claim must be a number`,n,`exp`,`invalid`);if(n.exp<=h-p)throw new Jr(`"exp" claim timestamp check failed`,n,`exp`,`check_failed`)}if(l){let e=h-n.iat;if(e-p>(typeof l==`number`?l:aa(l)))throw new Jr(`"iat" claim timestamp check failed (too far in the past)`,n,`iat`,`check_failed`);if(e<0-p)throw new I(`"iat" claim timestamp check failed (it should be in the past)`,n,`iat`,`check_failed`)}return n}async function ca(e,t,n){var r;let i=await async function(e,t,n){if(e instanceof Uint8Array&&(e=Rr.decode(e)),typeof e!=`string`)throw new R(`Compact JWS must be a string or Uint8Array`);let{0:r,1:i,2:a,length:o}=e.split(`.`);if(o!==3)throw new R(`Invalid Compact JWS`);let s=await na({payload:i,protected:r,signature:a},t,n),c={payload:s.payload,protectedHeader:s.protectedHeader};return typeof t==`function`?l(l({},c),{},{key:s.key}):c}(e,t,n);if((r=i.protectedHeader.crit)!=null&&r.includes(`b64`)&&!1===i.protectedHeader.b64)throw new Xr(`JWTs MUST NOT use unencoded payload`);let a={payload:sa(i.protectedHeader,i.payload,n),protectedHeader:i.protectedHeader};return typeof t==`function`?l(l({},a),{},{key:i.key}):a}function la(e){return oi(e)}var ua,da,fa=new WeakMap,pa=new WeakMap,ma=class{constructor(e){if(a(this,fa,void 0),a(this,pa,new WeakMap),!function(e){return e&&typeof e==`object`&&Array.isArray(e.keys)&&e.keys.every(la)}(e))throw new Zr(`JSON Web Key Set malformed`);o(fa,this,structuredClone(e))}jwks(){return i(fa,this)}async getKey(e,t){let{alg:r,kid:a}=l(l({},e),t?.header),o=function(e){switch(typeof e==`string`&&e.slice(0,2)){case`RS`:case`PS`:return`RSA`;case`ES`:return`EC`;case`Ed`:return`OKP`;case`ML`:return`AKP`;default:throw new L(`Unsupported "alg" value for a JSON Web Key Set`)}}(r),s=i(fa,this).keys.filter(e=>{let t=o===e.kty;if(t&&typeof a==`string`&&(t=a===e.kid),!t||typeof e.alg!=`string`&&o!==`AKP`||(t=r===e.alg),t&&typeof e.use==`string`&&(t=e.use===`sig`),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes(`verify`)),t)switch(r){case`ES256`:t=e.crv===`P-256`;break;case`ES384`:t=e.crv===`P-384`;break;case`ES512`:t=e.crv===`P-521`;break;case`Ed25519`:case`EdDSA`:t=e.crv===`Ed25519`}return t}),{0:c,length:u}=s;if(u===0)throw new Qr;if(u!==1){let e=new $r,t=i(pa,this);throw e[Symbol.asyncIterator]=d(function*(){for(let e of s)try{yield yield n(ha(t,e,r))}catch{}}),e}return ha(i(pa,this),c,r)}};async function ha(e,t,n){let r=e.get(t)||e.set(t,{}).get(t);if(r[n]===void 0){let e=await async function(e,t,n){if(!oi(e))throw TypeError(`JWK must be an object`);let r;switch(t??=e.alg,r??=n?.extractable??e.ext,e.kty){case`oct`:if(typeof e.k!=`string`||!e.k)throw TypeError(`missing "k" (Key Value) Parameter value`);return Vr(e.k);case`RSA`:if(`oth`in e&&e.oth!==void 0)throw new L(`RSA JWK "oth" (Other Primes Info) Parameter value is not supported`);return di(l(l({},e),{},{alg:t,ext:r}));case`AKP`:if(typeof e.alg!=`string`||!e.alg)throw TypeError(`missing "alg" (Algorithm) Parameter value`);if(t!==void 0&&t!==e.alg)throw TypeError(`JWK alg and alg option value mismatch`);return di(l(l({},e),{},{ext:r}));case`EC`:case`OKP`:return di(l(l({},e),{},{alg:t,ext:r}));default:throw new L(`Unsupported "kty" (Key Type) Parameter value`)}}(l(l({},t),{},{ext:!0}),n);if(e instanceof Uint8Array||e.type!==`public`)throw new Zr(`JSON Web Key Set members must be public keys`);r[n]=e}return r[n]}function ga(e){let t=new ma(e),n=async(e,n)=>t.getKey(e,n);return Object.defineProperties(n,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),n}var _a;(typeof navigator>`u`||(ua=navigator.userAgent)==null||(da=ua.startsWith)==null||!da.call(ua,`Mozilla/5.0 `))&&(_a=`jose/v6.2.2`);var va=Symbol(),ya=Symbol(),ba=new WeakMap,xa=new WeakMap,Sa=new WeakMap,Ca=new WeakMap,wa=new WeakMap,Ta=new WeakMap,Ea=new WeakMap,Da=new WeakMap,Oa=new WeakMap,ka=new WeakMap,Aa=class{constructor(e,t){if(a(this,ba,void 0),a(this,xa,void 0),a(this,Sa,void 0),a(this,Ca,void 0),a(this,wa,void 0),a(this,Ta,void 0),a(this,Ea,void 0),a(this,Da,void 0),a(this,Oa,void 0),a(this,ka,void 0),!(e instanceof URL))throw TypeError(`url must be an instance of URL`);var n,r;o(ba,this,new URL(e.href)),o(xa,this,typeof t?.timeoutDuration==`number`?t?.timeoutDuration:5e3),o(Sa,this,typeof t?.cooldownDuration==`number`?t?.cooldownDuration:3e4),o(Ca,this,typeof t?.cacheMaxAge==`number`?t?.cacheMaxAge:6e5),o(Ea,this,new Headers(t?.headers)),_a&&!i(Ea,this).has(`User-Agent`)&&i(Ea,this).set(`User-Agent`,_a),i(Ea,this).has(`accept`)||(i(Ea,this).set(`accept`,`application/json`),i(Ea,this).append(`accept`,`application/jwk-set+json`)),o(Da,this,t?.[va]),t?.[ya]!==void 0&&(o(ka,this,t?.[ya]),n=t?.[ya],r=i(Ca,this),typeof n==`object`&&n&&`uat`in n&&typeof n.uat==`number`&&!(Date.now()-n.uat>=r)&&`jwks`in n&&oi(n.jwks)&&Array.isArray(n.jwks.keys)&&Array.prototype.every.call(n.jwks.keys,oi)&&(o(wa,this,i(ka,this).uat),o(Oa,this,ga(i(ka,this).jwks))))}pendingFetch(){return!!i(Ta,this)}coolingDown(){return typeof i(wa,this)==`number`&&Date.now()<i(wa,this)+i(Sa,this)}fresh(){return typeof i(wa,this)==`number`&&Date.now()<i(wa,this)+i(Ca,this)}jwks(){return i(Oa,this)?.jwks()}async getKey(e,t){i(Oa,this)&&this.fresh()||await this.reload();try{return await i(Oa,this).call(this,e,t)}catch(n){if(n instanceof Qr&&!1===this.coolingDown())return await this.reload(),i(Oa,this).call(this,e,t);throw n}}async reload(){i(Ta,this)&&(typeof WebSocketPair<`u`||typeof navigator<`u`&&navigator.userAgent===`Cloudflare-Workers`||typeof EdgeRuntime<`u`&&EdgeRuntime===`vercel`)&&o(Ta,this,void 0),i(Ta,this)||o(Ta,this,async function(e,t,n){let r=await(arguments.length>3&&arguments[3]!==void 0?arguments[3]:fetch)(e,{method:`GET`,signal:n,redirect:`manual`,headers:t}).catch(e=>{throw e.name===`TimeoutError`?new ei:e});if(r.status!==200)throw new F(`Expected 200 OK from the JSON Web Key Set HTTP response`);try{return await r.json()}catch{throw new F(`Failed to parse the JSON Web Key Set HTTP response as JSON`)}}(i(ba,this).href,i(Ea,this),AbortSignal.timeout(i(xa,this)),i(Da,this)).then(e=>{o(Oa,this,ga(e)),i(ka,this)&&(i(ka,this).uat=Date.now(),i(ka,this).jwks=e),o(wa,this,Date.now()),o(Ta,this,void 0)}).catch(e=>{throw o(Ta,this,void 0),e})),await i(Ta,this)}},ja=[`mfaToken`],Ma=[`mfaToken`],Na,Pa,Fa,G,Ia,La,K,q,Ra,J,Y,za,Ba,Va,Ha,X,Ua=class extends Error{constructor(e,t){super(t),s(this,`code`,void 0),this.name=`NotSupportedError`,this.code=e}},Z=class extends Error{constructor(e,t,n){super(t),s(this,`cause`,void 0),s(this,`code`,void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},Wa=class extends Z{constructor(e,t){super(`token_by_code_error`,e,t),this.name=`TokenByCodeError`}},Ga=class extends Z{constructor(e,t){super(`token_by_client_credentials_error`,e,t),this.name=`TokenByClientCredentialsError`}},Ka=class extends Z{constructor(e,t){super(`token_by_refresh_token_error`,e,t),this.name=`TokenByRefreshTokenError`}},qa=class extends Z{constructor(e,t){super(`token_by_password_error`,e,t),this.name=`TokenByPasswordError`}},Ja=class extends Z{constructor(e,t){super(`token_for_connection_error`,e,t),this.name=`TokenForConnectionErrorCode`}},Q=class extends Z{constructor(e,t){super(`token_exchange_error`,e,t),this.name=`TokenExchangeError`}},Ya=class extends Error{constructor(e){super(e),s(this,`code`,`verify_logout_token_error`),this.name=`VerifyLogoutTokenError`}},Xa=class extends Z{constructor(e){super(`backchannel_authentication_error`,`There was an error when trying to use Client-Initiated Backchannel Authentication.`,e),s(this,`code`,`backchannel_authentication_error`),this.name=`BackchannelAuthenticationError`}},Za=class extends Z{constructor(e){super(`build_authorization_url_error`,`There was an error when trying to build the authorization URL.`,e),this.name=`BuildAuthorizationUrlError`}},Qa=class extends Z{constructor(e){super(`build_link_user_url_error`,`There was an error when trying to build the Link User URL.`,e),this.name=`BuildLinkUserUrlError`}},$a=class extends Z{constructor(e){super(`build_unlink_user_url_error`,`There was an error when trying to build the Unlink User URL.`,e),this.name=`BuildUnlinkUserUrlError`}},eo=class extends Error{constructor(){super(`The client secret or client assertion signing key must be provided.`),s(this,`code`,`missing_client_auth_error`),this.name=`MissingClientAuthError`}};function to(e){return Object.entries(e).filter(e=>{let[,t]=e;return t!==void 0}).reduce((e,t)=>l(l({},e),{},{[t[0]]:t[1]}),{})}var no=class extends Error{constructor(e,t,n){super(t),s(this,`cause`,void 0),s(this,`code`,void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},ro=class extends no{constructor(e,t){super(`mfa_list_authenticators_error`,e,t),this.name=`MfaListAuthenticatorsError`}},io=class extends no{constructor(e,t){super(`mfa_enrollment_error`,e,t),this.name=`MfaEnrollmentError`}},ao=class extends no{constructor(e,t){super(`mfa_delete_authenticator_error`,e,t),this.name=`MfaDeleteAuthenticatorError`}},oo=class extends no{constructor(e,t){super(`mfa_challenge_error`,e,t),this.name=`MfaChallengeError`}};function so(e){return{id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var co=(Na=new WeakMap,Pa=new WeakMap,Fa=new WeakMap,class{constructor(e){a(this,Na,void 0),a(this,Pa,void 0),a(this,Fa,void 0),o(Na,this,`https://${e.domain}`),o(Pa,this,e.clientId),o(Fa,this,e.customFetch??function(){return fetch(...arguments)})}async listAuthenticators(e){let t=`${i(Na,this)}/mfa/authenticators`,{mfaToken:n}=e,r=await i(Fa,this).call(this,t,{method:`GET`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`}});if(!r.ok){let e=await r.json();throw new ro(e.error_description||`Failed to list authenticators`,e)}return(await r.json()).map(so)}async enrollAuthenticator(e){let t=`${i(Na,this)}/mfa/associate`,{mfaToken:n}=e,r=u(e,ja),a={authenticator_types:r.authenticatorTypes};`oobChannels`in r&&(a.oob_channels=r.oobChannels),`phoneNumber`in r&&r.phoneNumber&&(a.phone_number=r.phoneNumber),`email`in r&&r.email&&(a.email=r.email);let o=await i(Fa,this).call(this,t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(a)});if(!o.ok){let e=await o.json();throw new io(e.error_description||`Failed to enroll authenticator`,e)}return function(e){if(e.authenticator_type===`otp`)return{authenticatorType:`otp`,secret:e.secret,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes,id:e.id};if(e.authenticator_type===`oob`)return{authenticatorType:`oob`,oobChannel:e.oob_channel,oobCode:e.oob_code,bindingMethod:e.binding_method,id:e.id,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes};throw Error(`Unexpected authenticator type: ${e.authenticator_type}`)}(await o.json())}async deleteAuthenticator(e){let{authenticatorId:t,mfaToken:n}=e,r=`${i(Na,this)}/mfa/authenticators/${encodeURIComponent(t)}`,a=await i(Fa,this).call(this,r,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`}});if(!a.ok){let e=await a.json();throw new ao(e.error_description||`Failed to delete authenticator`,e)}}async challengeAuthenticator(e){let t=`${i(Na,this)}/mfa/challenge`,{mfaToken:n}=e,r=u(e,Ma),a={mfa_token:n,client_id:i(Pa,this),challenge_type:r.challengeType};r.authenticatorId&&(a.authenticator_id=r.authenticatorId);let o=await i(Fa,this).call(this,t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)});if(!o.ok){let e=await o.json();throw new oo(e.error_description||`Failed to challenge authenticator`,e)}return function(e){let t={challengeType:e.challenge_type};return e.oob_code!==void 0&&(t.oobCode=e.oob_code),e.binding_method!==void 0&&(t.bindingMethod=e.binding_method),t}(await o.json())}}),lo=class e{constructor(e,t,n,r,i,a,o){s(this,`accessToken`,void 0),s(this,`idToken`,void 0),s(this,`refreshToken`,void 0),s(this,`expiresAt`,void 0),s(this,`scope`,void 0),s(this,`claims`,void 0),s(this,`authorizationDetails`,void 0),s(this,`tokenType`,void 0),s(this,`issuedTokenType`,void 0),this.accessToken=e,this.idToken=n,this.refreshToken=r,this.expiresAt=t,this.scope=i,this.claims=a,this.authorizationDetails=o}static fromTokenEndpointResponse(t){let n=t.id_token?t.claims():void 0,r=new e(t.access_token,Math.floor(Date.now()/1e3)+Number(t.expires_in),t.id_token,t.refresh_token,t.scope,n,t.authorization_details);return r.tokenType=t.token_type,r.issuedTokenType=t.issued_token_type,r}},uo=(G=new WeakMap,Ia=new WeakMap,La=new WeakMap,class{constructor(e,t){a(this,G,new Map),a(this,Ia,void 0),a(this,La,void 0),o(La,this,Math.max(1,Math.floor(e))),o(Ia,this,Math.max(0,Math.floor(t)))}get(e){let t=i(G,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return i(G,this).delete(e),i(G,this).set(e,t),t.value;i(G,this).delete(e)}}set(e,t){for(i(G,this).has(e)&&i(G,this).delete(e),i(G,this).set(e,{value:t,expiresAt:Date.now()+i(Ia,this)});i(G,this).size>i(La,this);){let e=i(G,this).keys().next().value;if(e===void 0)break;i(G,this).delete(e)}}}),fo=new Map;function po(e){return{ttlMs:1e3*(typeof e?.ttl==`number`?e.ttl:600),maxEntries:typeof e?.maxEntries==`number`&&e.maxEntries>0?e.maxEntries:100}}var mo=class{static createDiscoveryCache(e){let t=(n=e.maxEntries,r=e.ttlMs,`${n}:${r}`);var n,r;let i=(a=t,fo.get(a));var a;return i||(i=new uo(e.maxEntries,e.ttlMs),fo.set(t,i)),i}static createJwksCache(){return{}}},ho=`openid profile email offline_access`,go=Object.freeze(new Set([`grant_type`,`client_id`,`client_secret`,`client_assertion`,`client_assertion_type`,`subject_token`,`subject_token_type`,`requested_token_type`,`actor_token`,`actor_token_type`,`audience`,`aud`,`resource`,`resources`,`resource_indicator`,`scope`,`connection`,`login_hint`,`organization`,`assertion`]));function _o(e){if(e==null)throw new Q(`subject_token is required`);if(typeof e!=`string`)throw new Q(`subject_token must be a string`);if(e.trim().length===0)throw new Q(`subject_token cannot be blank or whitespace`);if(e!==e.trim())throw new Q(`subject_token must not include leading or trailing whitespace`);if(/^bearer\s+/i.test(e))throw new Q(`subject_token must not include the 'Bearer ' prefix`)}function vo(e,t){if(t){for(let[n,r]of Object.entries(t))if(!go.has(n))if(Array.isArray(r)){if(r.length>20)throw new Q(`Parameter '${n}' exceeds maximum array size of 20`);r.forEach(t=>{e.append(n,t)})}else e.append(n,r)}}var yo=`urn:ietf:params:oauth:token-type:access_token`,bo=(K=new WeakMap,q=new WeakMap,Ra=new WeakMap,J=new WeakMap,Y=new WeakMap,za=new WeakMap,Ba=new WeakMap,Va=new WeakMap,Ha=new WeakMap,X=new WeakSet,class{constructor(e){var t;if(function(e,t){r(e,t),t.add(e)}(this,X),a(this,K,void 0),a(this,q,void 0),a(this,Ra,void 0),a(this,J,void 0),a(this,Y,void 0),a(this,za,void 0),a(this,Ba,void 0),a(this,Va,void 0),a(this,Ha,void 0),s(this,`mfa`,void 0),o(J,this,e),e.useMtls&&!e.customFetch)throw new Ua(`mtls_without_custom_fetch_not_supported`,`Using mTLS without a custom fetch implementation is not supported`);o(Y,this,function(e,t){if(!1===t.enabled)return e;let n={name:t.name,version:t.version},r=btoa(JSON.stringify(n));return async(t,n)=>{let i=t instanceof Request?new Headers(t.headers):new Headers;return n!=null&&n.headers&&new Headers(n.headers).forEach((e,t)=>{i.set(t,e)}),i.set(`Auth0-Client`,r),e(t,l(l({},n),{},{headers:i}))}}(e.customFetch??function(){return fetch(...arguments)},!1===(t=e.telemetry)?.enabled?t:{enabled:!0,name:t?.name??`@auth0/auth0-auth-js`,version:t?.version??`1.6.0`}));let n=po(e.discoveryCache);o(Ba,this,mo.createDiscoveryCache(n)),o(Va,this,new Map),o(Ha,this,mo.createJwksCache()),this.mfa=new co({domain:i(J,this).domain,clientId:i(J,this).clientId,customFetch:i(Y,this)})}async getServerMetadata(){let{serverMetadata:e}=await t(X,this,$).call(this);return e}async buildAuthorizationUrl(e){let{serverMetadata:n}=await t(X,this,$).call(this);if(e!=null&&e.pushedAuthorizationRequests&&!n.pushed_authorization_request_endpoint)throw new Ua(`par_not_supported_error`,`The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par`);try{return await t(X,this,Eo).call(this,e)}catch(e){throw new Za(e)}}async buildLinkUserUrl(e){try{let n=await t(X,this,Eo).call(this,{authorizationParams:l(l({},e.authorizationParams),{},{requested_connection:e.connection,requested_connection_scope:e.connectionScope,scope:`openid link_account offline_access`,id_token_hint:e.idToken})});return{linkUserUrl:n.authorizationUrl,codeVerifier:n.codeVerifier}}catch(e){throw new Qa(e)}}async buildUnlinkUserUrl(e){try{let n=await t(X,this,Eo).call(this,{authorizationParams:l(l({},e.authorizationParams),{},{requested_connection:e.connection,scope:`openid unlink_account`,id_token_hint:e.idToken})});return{unlinkUserUrl:n.authorizationUrl,codeVerifier:n.codeVerifier}}catch(e){throw new $a(e)}}async backchannelAuthentication(e){let{configuration:n,serverMetadata:r}=await t(X,this,$).call(this),a=to(l(l({},i(J,this).authorizationParams),e?.authorizationParams)),o=new URLSearchParams(l(l({scope:ho},a),{},{client_id:i(J,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:`iss_sub`,iss:r.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&o.append(`requested_expiry`,e.requestedExpiry.toString()),e.authorizationDetails&&o.append(`authorization_details`,JSON.stringify(e.authorizationDetails));try{let e=await Wi(n,await Ui(n,o));return lo.fromTokenEndpointResponse(e)}catch(e){throw new Xa(e)}}async initiateBackchannelAuthentication(e){let{configuration:n,serverMetadata:r}=await t(X,this,$).call(this),a=to(l(l({},i(J,this).authorizationParams),e?.authorizationParams)),o=new URLSearchParams(l(l({scope:ho},a),{},{client_id:i(J,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:`iss_sub`,iss:r.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&o.append(`requested_expiry`,e.requestedExpiry.toString()),e.authorizationDetails&&o.append(`authorization_details`,JSON.stringify(e.authorizationDetails));try{let e=await Ui(n,o);return{authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){throw new Xa(e)}}async backchannelAuthenticationGrant(e){let{authReqId:n}=e,{configuration:r}=await t(X,this,$).call(this),i=new URLSearchParams({auth_req_id:n});try{let e=await ta(r,`urn:openid:params:grant-type:ciba`,i);return lo.fromTokenEndpointResponse(e)}catch(e){throw new Xa(e)}}async getTokenForConnection(e){if(e.refreshToken&&e.accessToken)throw new Ja(`Either a refresh or access token should be specified, but not both.`);let t=e.accessToken??e.refreshToken;if(!t)throw new Ja(`Either a refresh or access token must be specified.`);try{return await this.exchangeToken({connection:e.connection,subjectToken:t,subjectTokenType:e.accessToken?yo:`urn:ietf:params:oauth:token-type:refresh_token`,loginHint:e.loginHint})}catch(e){throw e instanceof Q?new Ja(e.message,e.cause):e}}async exchangeToken(e){return`connection`in e?t(X,this,Co).call(this,e):t(X,this,wo).call(this,e)}async getTokenByCode(e,n){let{configuration:r}=await t(X,this,$).call(this);try{let t=await Ki(r,e,{pkceCodeVerifier:n.codeVerifier});return lo.fromTokenEndpointResponse(t)}catch(e){throw new Wa(`There was an error while trying to request a token.`,e)}}async getTokenByRefreshToken(e){let{configuration:n}=await t(X,this,$).call(this),r=new URLSearchParams;e.audience&&r.append(`audience`,e.audience),e.scope&&r.append(`scope`,e.scope);try{let t=await qi(n,e.refreshToken,r);return lo.fromTokenEndpointResponse(t)}catch(e){throw new Ka(`The access token has expired and there was an error while trying to refresh it.`,e)}}async getTokenByPassword(e){let{configuration:n}=await t(X,this,$).call(this),r=new URLSearchParams({username:e.username,password:e.password});e.audience&&r.append(`audience`,e.audience),e.scope&&r.append(`scope`,e.scope),e.realm&&r.append(`realm`,e.realm);let a=n;if(e.auth0ForwardedFor){let r=await t(X,this,To).call(this);a=new zi(n.serverMetadata(),i(J,this).clientId,i(J,this).clientSecret,r),a[V]=(t,n)=>i(Y,this).call(this,t,l(l({},n),{},{headers:l(l({},n.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}))}try{let e=await ta(a,`password`,r);return lo.fromTokenEndpointResponse(e)}catch(e){throw new qa(`There was an error while trying to request a token.`,e)}}async getTokenByClientCredentials(e){let{configuration:n}=await t(X,this,$).call(this);try{let t=new URLSearchParams({audience:e.audience});e.organization&&t.append(`organization`,e.organization);let r=await Ji(n,t);return lo.fromTokenEndpointResponse(r)}catch(e){throw new Ga(`There was an error while trying to request a token.`,e)}}async buildLogoutUrl(e){let{configuration:n,serverMetadata:r}=await t(X,this,$).call(this);if(!r.end_session_endpoint){let t=new URL(`https://${i(J,this).domain}/v2/logout`);return t.searchParams.set(`returnTo`,e.returnTo),t.searchParams.set(`client_id`,i(J,this).clientId),t}return function(e,t){Zi(e);let{as:n,c:r,tlsOnly:i}=B(e),a=Ln(n,`end_session_endpoint`,!1,i);(t=new URLSearchParams(t)).has(`client_id`)||t.set(`client_id`,r.client_id);for(let[e,n]of t.entries())a.searchParams.append(e,n);return a}(n,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){let{serverMetadata:n}=await t(X,this,$).call(this),r=po(i(J,this).discoveryCache),a=n.jwks_uri;i(za,this)||o(za,this,function(e,t){let n=new Aa(e,t),r=async(e,t)=>n.getKey(e,t);return Object.defineProperties(r,{coolingDown:{get:()=>n.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>n.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>n.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>n.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>n.jwks(),enumerable:!0,configurable:!1,writable:!1}}),r}(new URL(a),{cacheMaxAge:r.ttlMs,[va]:i(Y,this),[ya]:i(Ha,this)}));let{payload:s}=await ca(e.logoutToken,i(za,this),{issuer:n.issuer,audience:i(J,this).clientId,algorithms:[`RS256`],requiredClaims:[`iat`]});if(!(`sid`in s)&&!(`sub`in s))throw new Ya(`either "sid" or "sub" (or both) claims must be present`);if(`sid`in s&&typeof s.sid!=`string`)throw new Ya(`"sid" claim must be a string`);if(`sub`in s&&typeof s.sub!=`string`)throw new Ya(`"sub" claim must be a string`);if(`nonce`in s)throw new Ya(`"nonce" claim is prohibited`);if(!(`events`in s))throw new Ya(`"events" claim is missing`);if(typeof s.events!=`object`||s.events===null)throw new Ya(`"events" claim must be an object`);if(!(`http://schemas.openid.net/event/backchannel-logout`in s.events))throw new Ya(`"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim`);if(typeof s.events[`http://schemas.openid.net/event/backchannel-logout`]!=`object`)throw new Ya(`"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object`);return{sid:s.sid,sub:s.sub}}});function xo(){return`${i(J,this).domain.toLowerCase()}|mtls:${i(J,this).useMtls?`1`:`0`}`}async function So(e){let n=await t(X,this,To).call(this),r=new zi(e,i(J,this).clientId,i(J,this).clientSecret,n);return r[V]=i(Y,this),r}async function $(){if(i(K,this)&&i(q,this))return{configuration:i(K,this),serverMetadata:i(q,this)};let e=t(X,this,xo).call(this),n=i(Ba,this).get(e);if(n)return o(q,this,n.serverMetadata),o(K,this,await t(X,this,So).call(this,n.serverMetadata)),{configuration:i(K,this),serverMetadata:i(q,this)};let r=i(Va,this).get(e);if(r){let e=await r;return o(q,this,e.serverMetadata),o(K,this,await t(X,this,So).call(this,e.serverMetadata)),{configuration:i(K,this),serverMetadata:i(q,this)}}let a=(async()=>{let n=await t(X,this,To).call(this),r=await Li(new URL(`https://${i(J,this).domain}`),i(J,this).clientId,{use_mtls_endpoint_aliases:i(J,this).useMtls},n,{[V]:i(Y,this)}),a=r.serverMetadata();return i(Ba,this).set(e,{serverMetadata:a}),{configuration:r,serverMetadata:a}})(),s=a.then(e=>{let{serverMetadata:t}=e;return{serverMetadata:t}});s.catch(()=>{}),i(Va,this).set(e,s);try{let{configuration:e,serverMetadata:t}=await a;o(K,this,e),o(q,this,t),i(K,this)[V]=i(Y,this)}finally{i(Va,this).delete(e)}return{configuration:i(K,this),serverMetadata:i(q,this)}}async function Co(e){let{configuration:n}=await t(X,this,$).call(this);if(`audience`in e||`resource`in e)throw new Q(`audience and resource parameters are not supported for Token Vault exchanges`);_o(e.subjectToken);let r=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:e.subjectTokenType??yo,requested_token_type:e.requestedTokenType??`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),vo(r,e.extra);try{let e=await ta(n,`urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token`,r);return lo.fromTokenEndpointResponse(e)}catch(t){throw new Q(`Failed to exchange token for connection '${e.connection}'.`,t)}}async function wo(e){let{configuration:n}=await t(X,this,$).call(this);_o(e.subjectToken);let r=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});e.audience&&r.append(`audience`,e.audience),e.scope&&r.append(`scope`,e.scope),e.requestedTokenType&&r.append(`requested_token_type`,e.requestedTokenType),e.organization&&r.append(`organization`,e.organization),vo(r,e.extra);try{let e=await ta(n,`urn:ietf:params:oauth:grant-type:token-exchange`,r);return lo.fromTokenEndpointResponse(e)}catch(t){throw new Q(`Failed to exchange token of type '${e.subjectTokenType}'${e.audience?` for audience '${e.audience}'`:``}.`,t)}}async function To(){return i(Ra,this)||o(Ra,this,(async()=>{if(!i(J,this).clientSecret&&!i(J,this).clientAssertionSigningKey&&!i(J,this).useMtls)throw new eo;if(i(J,this).useMtls)return(e,t,n,r)=>{n.set(`client_id`,t.client_id)};let e=i(J,this).clientAssertionSigningKey;return!e||e instanceof CryptoKey||(e=await async function(e,t,n){if(typeof e!=`string`||e.indexOf(`-----BEGIN PRIVATE KEY-----`)!==0)throw TypeError(`"pkcs8" must be PKCS#8 formatted string`);return Si(e,t,n)}(e,i(J,this).clientAssertionSigningAlg||`RS256`)),e?function(e,t){return Nn(e,t)}(e):ji(i(J,this).clientSecret)})().catch(e=>{throw o(Ra,this,void 0),e})),i(Ra,this)}async function Eo(e){let{configuration:n}=await t(X,this,$).call(this),r=Fi(),a=await Pi(r),o=to(l(l({},i(J,this).authorizationParams),e?.authorizationParams)),s=new URLSearchParams(l(l({scope:ho},o),{},{client_id:i(J,this).clientId,code_challenge:a,code_challenge_method:`S256`}));return{authorizationUrl:e!=null&&e.pushedAuthorizationRequests?await Xi(n,s):await Yi(n,s),codeVerifier:r}}var Do=class e extends v{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let{error:n,error_description:r}=t;return new e(n,r)}},Oo=class e extends Do{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},ko=class e extends Do{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},Ao=class e extends Do{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},jo=class e extends Do{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},Mo=class e extends Do{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},No=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:6e5;s(this,`contexts`,new Map),s(this,`ttlMs`,void 0),this.ttlMs=e}set(e,t){this.cleanup(),this.contexts.set(e,l(l({},t),{},{createdAt:Date.now()}))}get(e){let t=this.contexts.get(e);if(t){if(!(Date.now()-t.createdAt>this.ttlMs))return t;this.contexts.delete(e)}}remove(e){this.contexts.delete(e)}cleanup(){let e=Date.now();for(let[t,n]of this.contexts)e-n.createdAt>this.ttlMs&&this.contexts.delete(t)}get size(){return this.contexts.size}},Po=class{constructor(e,t){s(this,`authJsMfaClient`,void 0),s(this,`auth0Client`,void 0),s(this,`contextManager`,void 0),this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new No}setMFAAuthDetails(e,t,n,r){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:r})}async getAuthenticators(e){var t;let n=this.contextManager.get(e);if(n==null||(t=n.mfaRequirements)==null||!t.challenge||n.mfaRequirements.challenge.length===0)throw new Oo(`invalid_request`,`challengeType is required and must contain at least one challenge type, please check mfa_required error payload`);let r=n.mfaRequirements.challenge.map(e=>e.type);try{return(await this.authJsMfaClient.listAuthenticators({mfaToken:e})).filter(e=>!!e.type&&r.includes(e.type))}catch(e){throw e instanceof ro?new Oo(e.cause?.error,e.message):e}}async enroll(e){let t=function(e){let t=en[e.factorType];return l(l(l({mfaToken:e.mfaToken,authenticatorTypes:t.authenticatorTypes},t.oobChannels&&{oobChannels:t.oobChannels}),`phoneNumber`in e&&{phoneNumber:e.phoneNumber}),`email`in e&&{email:e.email})}(e);try{return await this.authJsMfaClient.enrollAuthenticator(t)}catch(e){throw e instanceof io?new ko(e.cause?.error,e.message):e}}async challenge(e){try{let t={challengeType:e.challengeType,mfaToken:e.mfaToken};return e.authenticatorId&&(t.authenticatorId=e.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(t)}catch(e){throw e instanceof oo?new Ao(e.cause?.error,e.message):e}}async getEnrollmentFactors(e){let t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new Mo(`mfa_context_not_found`,`MFA context not found for this MFA token. Please retry the original request to get a new MFA token.`);return t.mfaRequirements.enroll&&t.mfaRequirements.enroll.length!==0?t.mfaRequirements.enroll:[]}async verify(e){let t=this.contextManager.get(e.mfaToken);if(!t)throw new jo(`mfa_context_not_found`,`MFA context not found for this MFA token. Please retry the original request to get a new MFA token.`);let n=function(e){return`otp`in e&&e.otp?tn:`oobCode`in e&&e.oobCode?nn:`recoveryCode`in e&&e.recoveryCode?rn:void 0}(e);if(!n)throw new jo(`invalid_request`,`Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.`);let r=t.scope,i=t.audience;try{let t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:r,audience:i,otp:e.otp,oob_code:e.oobCode,binding_code:e.bindingCode,recovery_code:e.recoveryCode});return this.contextManager.remove(e.mfaToken),t}catch(e){if(e instanceof ae)this.setMFAAuthDetails(e.mfa_token,r,i,e.mfa_requirements);else if(e instanceof jo)throw new jo(e.error,e.error_description);throw e}}},Fo=[`openUrl`,`fragment`,`appState`],Io=[`url`],Lo=[`cacheMode`],Ro=[`federated`],zo=[`openUrl`],Bo=[`id_token`,`decodedToken`],Vo=[`mfaToken`],Ho=class{constructor(e){let t,n;if(s(this,`transactionManager`,void 0),s(this,`cacheManager`,void 0),s(this,`lockManager`,void 0),s(this,`domainUrl`,void 0),s(this,`tokenIssuer`,void 0),s(this,`scope`,void 0),s(this,`cookieStorage`,void 0),s(this,`dpop`,void 0),s(this,`sessionCheckExpiryDays`,void 0),s(this,`orgHintCookieName`,void 0),s(this,`isAuthenticatedCookieName`,void 0),s(this,`nowProvider`,void 0),s(this,`httpTimeoutMs`,void 0),s(this,`options`,void 0),s(this,`userCache`,new mt().enclosedCache),s(this,`myAccountApi`,void 0),s(this,`mfa`,void 0),s(this,`worker`,void 0),s(this,`authJsClient`,void 0),s(this,`defaultOptions`,{authorizationParams:{scope:`openid profile email`},useRefreshTokensFallback:!1,useFormData:!0}),this.options=l(l(l({},this.defaultOptions),e),{},{authorizationParams:l(l({},this.defaultOptions.authorizationParams),e.authorizationParams)}),typeof window<`u`&&(()=>{if(!de())throw Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(de().subtle===void 0)throw Error(`
3
+ auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
4
+ `)})(),this.lockManager=(Pe||=Ne(),Pe),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)n=e.cache;else{if(t=e.cacheLocation||m,!Wt(t))throw Error(`Invalid cache location "${t}"`);n=Wt(t)()}var r;this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=!1===e.legacySameSiteCookie?Ot:At,this.orgHintCookieName=(r=this.options.clientId,`auth0.${r}.organization_hint`),this.isAuthenticatedCookieName=(e=>`auth0.${e}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;let i=e.useCookiesForTransactions?this.cookieStorage:jt;var a;this.scope=function(e,t){var n=[...arguments].slice(2);if(typeof e!=`object`)return{[_]:ct(t,e,...n)};let r={[_]:ct(t,...n)};return Object.keys(e).forEach(i=>{let a=e[i];r[i]=ct(t,a,...n)}),r}(this.options.authorizationParams.scope,`openid`,this.options.useRefreshTokens?`offline_access`:``),this.transactionManager=new gt(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||g,this.cacheManager=new ht(n,n.allKeys?void 0:new Bt(n,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new Yt(this.options.clientId):void 0,this.domainUrl=(a=this.options.domain,/^https?:\/\//.test(a)?a:`https://${a}`),this.tokenIssuer=((e,t)=>e?e.startsWith(`https://`)?e:`https://${e}/`:`${t}/`)(this.options.issuer,this.domainUrl);let o=`${this.domainUrl}/me/`;this.myAccountApi=new Qt(this.createFetcher(l(l({},this.options.useDpop&&{dpopNonceId:`__auth0_my_account_api__`}),{},{getAccessToken:()=>this.getTokenSilently({authorizationParams:{scope:`create:me:connected_accounts`,audience:o},detailedResponse:!0})})),o),this.authJsClient=new bo({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new Po(this.authJsClient.mfa,this),typeof window<`u`&&window.Worker&&this.options.useRefreshTokens&&t===m&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new Rt,this.worker.postMessage({type:`init`,allowedBaseUrl:this.domainUrl}))}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){let t=he(this.options.auth0Client||h,!0),n=encodeURIComponent(btoa(JSON.stringify(t)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${ge(e)}`)}async _verifyIdToken(e,t,n){let r=await this.nowProvider();return yt({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:t,organization:n,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,typeof i==`string`?parseInt(i,10)||void 0:i),now:r});var i}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}_extractSessionTransferToken(e){return new URLSearchParams(window.location.search).get(e)||void 0}_clearSessionTransferTokenFromUrl(e){try{let t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState({},``,t.toString()))}catch{}}_applySessionTransferToken(e){let t=this.options.sessionTransferTokenQueryParamName;if(!t||e.session_transfer_token)return e;let n=this._extractSessionTransferToken(t);return n?(this._clearSessionTransferTokenFromUrl(t),l(l({},e),{},{session_transfer_token:n})):e}async _prepareAuthorizeUrl(e,t,n){let r=pe(fe()),i=pe(fe()),a=fe(),o=ye(await _e(a)),s=await this.dpop?.calculateThumbprint(),c=((e,t,n,r,i,a,o,s,c)=>l(l(l({client_id:e.clientId},e.authorizationParams),n),{},{scope:lt(t,n.scope,n.audience),response_type:`code`,response_mode:s||`query`,state:r,nonce:i,redirect_uri:o||e.authorizationParams.redirect_uri,code_challenge:a,code_challenge_method:`S256`,dpop_jkt:c}))(this.options,this.scope,e,r,i,o,e.redirect_uri||this.options.authorizationParams.redirect_uri||n,t?.response_mode,s),u=this._authorizeUrl(c);return{nonce:i,code_verifier:a,scope:c.scope,audience:c.audience||_,redirect_uri:c.redirect_uri,state:r,url:u}}async loginWithPopup(e,t){if(e||={},!(t||={}).popup&&(t.popup=(e=>{let t=window.screenX+(window.innerWidth-400)/2,n=window.screenY+(window.innerHeight-600)/2;return window.open(e,`auth0:authorize:popup`,`left=${t},top=${n},width=400,height=600,resizable,scrollbars=yes,status=1`)})(``),!t.popup))throw new ie;let n=this._applySessionTransferToken(e.authorizationParams||{}),r=await this._prepareAuthorizeUrl(n,{response_mode:`web_message`},window.location.origin);t.popup.location.href=r.url;let i=await((e,t)=>new Promise((n,r)=>{let i,a=setInterval(()=>{e.popup&&e.popup.closed&&(clearInterval(a),clearTimeout(o),window.removeEventListener(`message`,i,!1),r(new re(e.popup)))},1e3),o=setTimeout(()=>{clearInterval(a),r(new ne(e.popup)),window.removeEventListener(`message`,i,!1)},1e3*(e.timeoutInSeconds||60));i=function(s){if(s.origin===t&&s.data&&s.data.type===`authorization_response`){if(clearTimeout(o),clearInterval(a),window.removeEventListener(`message`,i,!1),!1!==e.closePopup&&e.popup.close(),s.data.response.error)return r(v.fromPayload(s.data.response));n(s.data.response)}},window.addEventListener(`message`,i)}))(l(l({},t),{},{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(r.url).origin);if(r.state!==i.state)throw new v(`state_mismatch`,`Invalid state`);let a=e.authorizationParams?.organization||this.options.authorizationParams.organization;await this._requestToken({audience:r.audience,scope:r.scope,code_verifier:r.code_verifier,grant_type:`authorization_code`,code:i.code,redirect_uri:r.redirect_uri},{nonceIn:r.nonce,organization:a})}async getUser(){var e;let t=await this._getIdTokenFromCache();return t==null||(e=t.decodedToken)==null?void 0:e.user}async getIdTokenClaims(){var e;let t=await this._getIdTokenFromCache();return t==null||(e=t.decodedToken)==null?void 0:e.claims}async loginWithRedirect(){let e=Gt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),{openUrl:t,fragment:n,appState:r}=e,i=u(e,Fo),a=i.authorizationParams?.organization||this.options.authorizationParams.organization,o=this._applySessionTransferToken(i.authorizationParams||{}),s=await this._prepareAuthorizeUrl(o),{url:c}=s,d=u(s,Io);this.transactionManager.create(l(l({},d),{},{appState:r,response_type:Mt.Code},a&&{organization:a}));let f=n?`${c}#${n}`:c;t?await t(f):window.location.assign(f)}async handleRedirectCallback(){let e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.location.href).split(`?`).slice(1);if(e.length===0)throw Error(`There are no query params available for parsing.`);let t=this.transactionManager.get();if(!t)throw new v(`missing_transaction`,`Invalid state`);this.transactionManager.remove();let n=(e=>{e.indexOf(`#`)>-1&&(e=e.substring(0,e.indexOf(`#`)));let t=new URLSearchParams(e);return{state:t.get(`state`),code:t.get(`code`)||void 0,connect_code:t.get(`connect_code`)||void 0,error:t.get(`error`)||void 0,error_description:t.get(`error_description`)||void 0}})(e.join(``));return t.response_type===Mt.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){let{code:n,state:r,error:i,error_description:a}=e;if(i)throw new ee(i,a||i,r,t.appState);if(!t.code_verifier||t.state&&t.state!==r)throw new v(`state_mismatch`,`Invalid state`);let o=t.organization,s=t.nonce,c=t.redirect_uri;return await this._requestToken(l({audience:t.audience,scope:t.scope,code_verifier:t.code_verifier,grant_type:`authorization_code`,code:n},c?{redirect_uri:c}:{}),{nonceIn:s,organization:o}),{appState:t.appState,response_type:Mt.Code}}async _handleConnectAccountRedirectCallback(e,t){let{connect_code:n,state:r,error:i,error_description:a}=e;if(i)throw new y(i,a||i,t.connection,r,t.appState);if(!n)throw new v(`missing_connect_code`,`Missing connect code`);if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===r))throw new v(`state_mismatch`,`Invalid state`);return l(l({},await this.myAccountApi.completeAccount({auth_session:t.auth_session,connect_code:n,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier})),{},{appState:t.appState,response_type:Mt.ConnectCode})}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(Ht))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(Ht)}try{await this.getTokenSilently(e)}catch{}}async getTokenSilently(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=l(l({cacheMode:`on`},e),{},{authorizationParams:l(l(l({},this.options.authorizationParams),e.authorizationParams),{},{scope:lt(this.scope,e.authorizationParams?.scope,e.authorizationParams?.audience||this.options.authorizationParams.audience)})}),n=await((e,t)=>{let n=zt[t];return n||(n=e().finally(()=>{delete zt[t],n=null}),zt[t]=n),n})(()=>this._getTokenSilently(t),`${this.options.clientId}::${t.authorizationParams.audience}::${t.authorizationParams.scope}`);return e.detailedResponse?n:n?.access_token}async _getTokenSilently(e){let{cacheMode:t}=e,n=u(e,Lo);if(t!==`off`){let e=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||_,clientId:this.options.clientId,cacheMode:t});if(e)return e}if(t===`cache-only`)return;let r=(i=this.options.clientId,a=n.authorizationParams.audience||`default`,`auth0.lock.getTokenSilently.${i}.${a}`);var i,a;try{return await this.lockManager.runWithLock(r,5e3,async()=>{if(t!==`off`){let e=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||_,clientId:this.options.clientId});if(e)return e}let{id_token:e,token_type:r,access_token:i,oauthTokenScope:a,expires_in:o}=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(n):await this._getTokenFromIFrame(n);return l(l({id_token:e,token_type:r,access_token:i},a?{scope:a}:null),{},{expires_in:o})})}catch(e){if(this._isInteractiveError(e)&&this.options.interactiveErrorHandler===`popup`)return await this._handleInteractiveErrorWithPopup(n);throw e}}_isInteractiveError(e){return e instanceof ae||e instanceof v&&this._isIframeMfaError(e)}_isIframeMfaError(e){return e.error===`login_required`&&e.error_description===`Multifactor authentication required`}async _handleInteractiveErrorWithPopup(e){try{await this.loginWithPopup({authorizationParams:e.authorizationParams});let t=await this._getEntryFromCache({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||_,clientId:this.options.clientId});if(!t)throw new v(`interactive_handler_cache_miss`,`Token not found in cache after interactive authentication`);return t}catch(e){throw e}}async getTokenWithPopup(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=l(l({},e),{},{authorizationParams:l(l(l({},this.options.authorizationParams),e.authorizationParams),{},{scope:lt(this.scope,e.authorizationParams?.scope,e.authorizationParams?.audience||this.options.authorizationParams.audience)})});return t=l(l({},p),t),await this.loginWithPopup(n,t),(await this.cacheManager.get(new ft({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||_,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){e.clientId===null?delete e.clientId:e.clientId=e.clientId||this.options.clientId;let t=e.logoutParams||{},{federated:n}=t,r=u(t,Ro),i=n?`&federated`:``;return this._url(`/v2/logout?${ge(l({clientId:e.clientId},r))}`)+i}async logout(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Gt(e),{openUrl:n}=t,r=u(t,zo);e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(dt),await this.dpop?.clear();let i=this._buildLogoutUrl(r);n?await n(i):!1!==n&&window.location.assign(i)}async _getTokenFromIFrame(e){let t=(n=this.options.clientId,`auth0.lock.getTokenFromIFrame.${n}`);var n;try{return await this.lockManager.runWithLock(t,5e3,async()=>{let t=l(l({},e.authorizationParams),{},{prompt:`none`}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!t.organization&&(t.organization=n);let{url:r,state:i,nonce:a,code_verifier:o,redirect_uri:s,scope:c,audience:u}=await this._prepareAuthorizeUrl(t,{response_mode:`web_message`},window.location.origin);if(window.crossOriginIsolated)throw new v(`login_required`,`The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.`);let d=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,f;try{f=new URL(this.domainUrl).origin}catch{f=this.domainUrl}let p=await function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:60;return new Promise((r,i)=>{let a=window.document.createElement(`iframe`);a.setAttribute(`width`,`0`),a.setAttribute(`height`,`0`),a.style.display=`none`;let o=()=>{window.document.body.contains(a)&&(window.document.body.removeChild(a),window.removeEventListener(`message`,s,!1))},s,c=setTimeout(()=>{i(new te),o()},1e3*n);s=function(e){if(e.origin!=t||!e.data||e.data.type!==`authorization_response`)return;let n=e.source;n&&n.close(),e.data.response.error?i(v.fromPayload(e.data.response)):r(e.data.response),clearTimeout(c),window.removeEventListener(`message`,s,!1),setTimeout(o,2e3)},window.addEventListener(`message`,s,!1),window.document.body.appendChild(a),a.setAttribute(`src`,e)})}(r,f,d);if(i!==p.state)throw new v(`state_mismatch`,`Invalid state`);let m=await this._requestToken(l(l({},e.authorizationParams),{},{code_verifier:o,code:p.code,grant_type:`authorization_code`,redirect_uri:s,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:t.organization});return l(l({},m),{},{scope:c,oauthTokenScope:m.scope,audience:u})})}catch(e){throw e.error===`login_required`&&(e instanceof v&&this._isIframeMfaError(e)&&this.options.interactiveErrorHandler===`popup`||this.logout({openUrl:!1})),e}}async _getTokenUsingRefreshToken(e){let t=await this.cacheManager.get(new ft({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||_,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 oe(e.authorizationParams.audience||_,e.authorizationParams.scope)}let n=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,r=typeof e.timeoutInSeconds==`number`?1e3*e.timeoutInSeconds:null,i=((e,t,n,r)=>{if(e&&n&&r){if(t.audience!==n)return t.scope;let e=r.split(` `),i=t.scope?.split(` `)||[],a=i.every(t=>e.includes(t));return e.length>=i.length&&a?r:t.scope}return t.scope})(this.options.useMrrt,e.authorizationParams,t?.audience,t?.scope);try{let u=await this._requestToken(l(l({},e.authorizationParams),{},{grant_type:`refresh_token`,refresh_token:t&&t.refresh_token,redirect_uri:n},r&&{timeout:r}),{scopesToRequest:i});if(u.refresh_token&&t!=null&&t.refresh_token&&await this.cacheManager.updateEntry(t.refresh_token,u.refresh_token),this.options.useMrrt&&(a=t?.audience,o=t?.scope,s=e.authorizationParams.audience,c=e.authorizationParams.scope,(a!==s||!Kt(c,o))&&!Kt(i,u.scope))){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience,e.authorizationParams.scope);let t=((e,t)=>{let n=e?.split(` `)||[],r=t?.split(` `)||[];return n.filter(e=>r.indexOf(e)==-1).join(`,`)})(i,u.scope);throw new se(e.authorizationParams.audience||`default`,t)}return l(l({},u),{},{scope:e.authorizationParams.scope,oauthTokenScope:u.scope,audience:e.authorizationParams.audience||_})}catch(t){if(t.message){if(t.message.includes(`user is blocked`))throw await this.logout({openUrl:!1}),t;if((t.message.includes(`Missing Refresh Token`)||t.message.includes(`invalid refresh token`))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e)}throw t instanceof ae&&this.mfa.setMFAAuthDetails(t.mfa_token,e.authorizationParams?.scope,e.authorizationParams?.audience,t.mfa_requirements),t}var a,o,s,c}async _saveEntryInCache(e){let{id_token:t,decodedToken:n}=e,r=u(e,Bo);this.userCache.set(dt,{id_token:t,decodedToken:n}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(r)}async _getIdTokenFromCache(){let e=this.options.authorizationParams.audience||_,t=this.scope[e],n=await this.cacheManager.getIdToken(new ft({clientId:this.options.clientId,audience:e,scope:t})),r=this.userCache.get(dt);return n&&n.id_token===r?.id_token?r:(this.userCache.set(dt,n),n)}async _getEntryFromCache(e){let{scope:t,audience:n,clientId:r,cacheMode:i}=e,a=await this.cacheManager.get(new ft({scope:t,audience:n,clientId:r}),60,this.options.useMrrt,i);if(a&&a.access_token){let{token_type:e,access_token:t,oauthTokenScope:n,expires_in:r}=a,i=await this._getIdTokenFromCache();return i&&l(l({id_token:i.id_token,token_type:e||`Bearer`,access_token:t},n?{scope:n}:null),{},{expires_in:r})}}async _requestToken(e,t){let{nonceIn:n,organization:r,scopesToRequest:i}=t||{},a=await st(l(l({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,useMrrt:this.options.useMrrt,dpop:this.dpop},e),{},{scope:i||e.scope}),this.worker),o=await this._verifyIdToken(a.id_token,n,r);if(e.grant_type===`authorization_code`){var s;let e=await this._getIdTokenFromCache();e!=null&&(s=e.decodedToken)!=null&&(s=s.claims)!=null&&s.sub&&e.decodedToken.claims.sub!==o.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(dt))}return await this._saveEntryInCache(l(l(l({},a),{},{decodedToken:o,scope:e.scope,audience:e.audience||_},a.scope?{oauthTokenScope:a.scope}:null),{},{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(r||o.claims.org_id),l(l({},a),{},{decodedToken:o})}async loginWithCustomTokenExchange(e){return this._requestToken(l(l({},e),{},{grant_type:`urn:ietf:params:oauth:grant-type:token-exchange`,subject_token:e.subject_token,subject_token_type:e.subject_token_type,scope:lt(this.scope,e.scope,e.audience||this.options.authorizationParams.audience),audience:e.audience||this.options.authorizationParams.audience,organization:e.organization||this.options.authorizationParams.organization}))}async exchangeToken(e){return this.loginWithCustomTokenExchange(e)}_assertDpop(e){if(!e)throw Error("`useDpop` option must be enabled before using DPoP.")}getDpopNonce(e){return this._assertDpop(this.dpop),this.dpop.getNonce(e)}setDpopNonce(e,t){return this._assertDpop(this.dpop),this.dpop.setNonce(e,t)}generateDpopProof(e){return this._assertDpop(this.dpop),this.dpop.generateProof(e)}createFetcher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new Zt(e,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:e==null||(t=e.scope)==null?void 0:t.join(` `),audience:e?.audience},detailedResponse:!0})},getDpopNonce:()=>this.getDpopNonce(e.dpopNonceId),setDpopNonce:t=>this.setDpopNonce(t,e.dpopNonceId),generateDpopProof:e=>this.generateDpopProof(e)})}async connectAccountWithRedirect(e){let{openUrl:t,appState:n,connection:r,scopes:i,authorization_params:a,redirectUri:o=this.options.authorizationParams.redirect_uri||window.location.origin}=e;if(!r)throw Error(`connection is required`);let s=pe(fe()),c=fe(),l=ye(await _e(c)),{connect_uri:u,connect_params:d,auth_session:f}=await this.myAccountApi.connectAccount({connection:r,scopes:i,redirect_uri:o,state:s,code_challenge:l,code_challenge_method:`S256`,authorization_params:a});this.transactionManager.create({state:s,code_verifier:c,auth_session:f,redirect_uri:o,appState:n,connection:r,response_type:Mt.ConnectCode});let p=new URL(u);p.searchParams.set(`ticket`,d.ticket),t?await t(p.toString()):window.location.assign(p)}async _requestTokenForMfa(e,t){let{mfaToken:n}=e,r=u(e,Vo);return this._requestToken(l(l({},r),{},{mfa_token:n}),t)}};exports.Auth0Client=Ho;
5
+ //# sourceMappingURL=auth0-spa-js.production.esm-cNFf2AtX.cjs.map