@asgardeo/browser 0.7.5 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1953,7 +1953,7 @@ function inlineWorker(scriptText) {
|
|
|
1953
1953
|
|
|
1954
1954
|
// src/web.worker.ts
|
|
1955
1955
|
function Worker2() {
|
|
1956
|
-
return inlineWorker('(()=>{var Wn=Object.create;var rt=Object.defineProperty;var jn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var qn=Object.getPrototypeOf,Vn=Object.prototype.hasOwnProperty;var Vt=r=>{throw TypeError(r)};var Jn=(r,e,t)=>e in r?rt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var q=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Gn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of zn(e))!Vn.call(r,o)&&o!==t&&rt(r,o,{get:()=>e[o],enumerable:!(n=jn(e,o))||n.enumerable});return r};var _e=(r,e,t)=>(t=r!=null?Wn(qn(r)):{},Gn(e||!r||!r.__esModule?rt(t,"default",{value:r,enumerable:!0}):t,r));var w=(r,e,t)=>Jn(r,typeof e!="symbol"?e+"":e,t),Jt=(r,e,t)=>e.has(r)||Vt("Cannot "+t);var ue=(r,e,t)=>(Jt(r,e,"read from private field"),t?t.call(r):e.get(r)),He=(r,e,t)=>e.has(r)?Vt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),nt=(r,e,t,n)=>(Jt(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var Yt=q(Be=>{"use strict";Be.byteLength=Yn;Be.toByteArray=Qn;Be.fromByteArray=ro;var W=[],B=[],Xn=typeof Uint8Array<"u"?Uint8Array:Array,ot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(re=0,Gt=ot.length;re<Gt;++re)W[re]=ot[re],B[ot.charCodeAt(re)]=re;var re,Gt;B[45]=62;B[95]=63;function Xt(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function Yn(r){var e=Xt(r),t=e[0],n=e[1];return(t+n)*3/4-n}function Zn(r,e,t){return(e+t)*3/4-t}function Qn(r){var e,t=Xt(r),n=t[0],o=t[1],a=new Xn(Zn(r,n,o)),i=0,s=o>0?n-4:n,l;for(l=0;l<s;l+=4)e=B[r.charCodeAt(l)]<<18|B[r.charCodeAt(l+1)]<<12|B[r.charCodeAt(l+2)]<<6|B[r.charCodeAt(l+3)],a[i++]=e>>16&255,a[i++]=e>>8&255,a[i++]=e&255;return o===2&&(e=B[r.charCodeAt(l)]<<2|B[r.charCodeAt(l+1)]>>4,a[i++]=e&255),o===1&&(e=B[r.charCodeAt(l)]<<10|B[r.charCodeAt(l+1)]<<4|B[r.charCodeAt(l+2)]>>2,a[i++]=e>>8&255,a[i++]=e&255),a}function eo(r){return W[r>>18&63]+W[r>>12&63]+W[r>>6&63]+W[r&63]}function to(r,e,t){for(var n,o=[],a=e;a<t;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(r[a+2]&255),o.push(eo(n));return o.join("")}function ro(r){for(var e,t=r.length,n=t%3,o=[],a=16383,i=0,s=t-n;i<s;i+=a)o.push(to(r,i,i+a>s?s:i+a));return n===1?(e=r[t-1],o.push(W[e>>2]+W[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],o.push(W[e>>10]+W[e>>4&63]+W[e<<2&63]+"=")),o.join("")}});var Zt=q(at=>{at.read=function(r,e,t,n,o){var a,i,s=o*8-n-1,l=(1<<s)-1,c=l>>1,d=-7,u=t?o-1:0,p=t?-1:1,h=r[e+u];for(u+=p,a=h&(1<<-d)-1,h>>=-d,d+=s;d>0;a=a*256+r[e+u],u+=p,d-=8);for(i=a&(1<<-d)-1,a>>=-d,d+=n;d>0;i=i*256+r[e+u],u+=p,d-=8);if(a===0)a=1-c;else{if(a===l)return i?NaN:(h?-1:1)*(1/0);i=i+Math.pow(2,n),a=a-c}return(h?-1:1)*i*Math.pow(2,a-n)};at.write=function(r,e,t,n,o,a){var i,s,l,c=a*8-o-1,d=(1<<c)-1,u=d>>1,p=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,g=n?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,i=d):(i=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-i))<1&&(i--,l*=2),i+u>=1?e+=p/l:e+=p*Math.pow(2,1-u),e*l>=2&&(i++,l/=2),i+u>=d?(s=0,i=d):i+u>=1?(s=(e*l-1)*Math.pow(2,o),i=i+u):(s=e*Math.pow(2,u-1)*Math.pow(2,o),i=0));o>=8;r[t+h]=s&255,h+=g,s/=256,o-=8);for(i=i<<o|s,c+=o;c>0;r[t+h]=i&255,h+=g,i/=256,c-=8);r[t+h-g]|=m*128}});var Ke=q(he=>{"use strict";var it=Yt(),fe=Zt(),Qt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;he.Buffer=f;he.SlowBuffer=co;he.INSPECT_MAX_BYTES=50;var $e=2147483647;he.kMaxLength=$e;f.TYPED_ARRAY_SUPPORT=no();!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function no(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}});Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function V(r){if(r>$e)throw new RangeError(\'The value "\'+r+\'" is invalid for option "size"\');let e=new Uint8Array(r);return Object.setPrototypeOf(e,f.prototype),e}function f(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError(\'The "string" argument must be of type string. Received type number\');return ut(r)}return nr(r,e,t)}f.poolSize=8192;function nr(r,e,t){if(typeof r=="string")return ao(r,e);if(ArrayBuffer.isView(r))return io(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(j(r,ArrayBuffer)||r&&j(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(j(r,SharedArrayBuffer)||r&&j(r.buffer,SharedArrayBuffer)))return ct(r,e,t);if(typeof r=="number")throw new TypeError(\'The "value" argument must not be of type number. Received type number\');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return f.from(n,e,t);let o=so(r);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return f.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}f.from=function(r,e,t){return nr(r,e,t)};Object.setPrototypeOf(f.prototype,Uint8Array.prototype);Object.setPrototypeOf(f,Uint8Array);function or(r){if(typeof r!="number")throw new TypeError(\'"size" argument must be of type number\');if(r<0)throw new RangeError(\'The value "\'+r+\'" is invalid for option "size"\')}function oo(r,e,t){return or(r),r<=0?V(r):e!==void 0?typeof t=="string"?V(r).fill(e,t):V(r).fill(e):V(r)}f.alloc=function(r,e,t){return oo(r,e,t)};function ut(r){return or(r),V(r<0?0:dt(r)|0)}f.allocUnsafe=function(r){return ut(r)};f.allocUnsafeSlow=function(r){return ut(r)};function ao(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=ar(r,e)|0,n=V(t),o=n.write(r,e);return o!==t&&(n=n.slice(0,o)),n}function st(r){let e=r.length<0?0:dt(r.length)|0,t=V(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function io(r){if(j(r,Uint8Array)){let e=new Uint8Array(r);return ct(e.buffer,e.byteOffset,e.byteLength)}return st(r)}function ct(r,e,t){if(e<0||r.byteLength<e)throw new RangeError(\'"offset" is outside of buffer bounds\');if(r.byteLength<e+(t||0))throw new RangeError(\'"length" is outside of buffer bounds\');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,f.prototype),n}function so(r){if(f.isBuffer(r)){let e=dt(r.length)|0,t=V(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||pt(r.length)?V(0):st(r);if(r.type==="Buffer"&&Array.isArray(r.data))return st(r.data)}function dt(r){if(r>=$e)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+$e.toString(16)+" bytes");return r|0}function co(r){return+r!=r&&(r=0),f.alloc(+r)}f.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==f.prototype};f.compare=function(e,t){if(j(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),j(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(e)||!f.isBuffer(t))throw new TypeError(\'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array\');if(e===t)return 0;let n=e.length,o=t.length;for(let a=0,i=Math.min(n,o);a<i;++a)if(e[a]!==t[a]){n=e[a],o=t[a];break}return n<o?-1:o<n?1:0};f.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};f.concat=function(e,t){if(!Array.isArray(e))throw new TypeError(\'"list" argument must be an Array of Buffers\');if(e.length===0)return f.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let o=f.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){let i=e[n];if(j(i,Uint8Array))a+i.length>o.length?(f.isBuffer(i)||(i=f.from(i)),i.copy(o,a)):Uint8Array.prototype.set.call(o,i,a);else if(f.isBuffer(i))i.copy(o,a);else throw new TypeError(\'"list" argument must be an Array of Buffers\');a+=i.length}return o};function ar(r,e){if(f.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||j(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError(\'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type \'+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return lt(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return hr(r).length;default:if(o)return n?-1:lt(r).length;e=(""+e).toLowerCase(),o=!0}}f.byteLength=ar;function lo(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return So(this,e,t);case"utf8":case"utf-8":return sr(this,e,t);case"ascii":return wo(this,e,t);case"latin1":case"binary":return Eo(this,e,t);case"base64":return mo(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return To(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}f.prototype._isBuffer=!0;function ne(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}f.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)ne(this,t,t+1);return this};f.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)ne(this,t,t+3),ne(this,t+1,t+2);return this};f.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)ne(this,t,t+7),ne(this,t+1,t+6),ne(this,t+2,t+5),ne(this,t+3,t+4);return this};f.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?sr(this,0,e):lo.apply(this,arguments)};f.prototype.toLocaleString=f.prototype.toString;f.prototype.equals=function(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:f.compare(this,e)===0};f.prototype.inspect=function(){let e="",t=he.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Qt&&(f.prototype[Qt]=f.prototype.inspect);f.prototype.compare=function(e,t,n,o,a){if(j(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(e))throw new TypeError(\'The "target" argument must be one of type Buffer or Uint8Array. Received type \'+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),a===void 0&&(a=this.length),t<0||n>e.length||o<0||a>this.length)throw new RangeError("out of range index");if(o>=a&&t>=n)return 0;if(o>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,o>>>=0,a>>>=0,this===e)return 0;let i=a-o,s=n-t,l=Math.min(i,s),c=this.slice(o,a),d=e.slice(t,n);for(let u=0;u<l;++u)if(c[u]!==d[u]){i=c[u],s=d[u];break}return i<s?-1:s<i?1:0};function ir(r,e,t,n,o){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,pt(t)&&(t=o?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(o)return-1;t=r.length-1}else if(t<0)if(o)t=0;else return-1;if(typeof e=="string"&&(e=f.from(e,n)),f.isBuffer(e))return e.length===0?-1:er(r,e,t,n,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):er(r,[e],t,n,o);throw new TypeError("val must be string, number or Buffer")}function er(r,e,t,n,o){let a=1,i=r.length,s=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;a=2,i/=2,s/=2,t/=2}function l(d,u){return a===1?d[u]:d.readUInt16BE(u*a)}let c;if(o){let d=-1;for(c=t;c<i;c++)if(l(r,c)===l(e,d===-1?0:c-d)){if(d===-1&&(d=c),c-d+1===s)return d*a}else d!==-1&&(c-=c-d),d=-1}else for(t+s>i&&(t=i-s),c=t;c>=0;c--){let d=!0;for(let u=0;u<s;u++)if(l(r,c+u)!==l(e,u)){d=!1;break}if(d)return c}return-1}f.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};f.prototype.indexOf=function(e,t,n){return ir(this,e,t,n,!0)};f.prototype.lastIndexOf=function(e,t,n){return ir(this,e,t,n,!1)};function uo(r,e,t,n){t=Number(t)||0;let o=r.length-t;n?(n=Number(n),n>o&&(n=o)):n=o;let a=e.length;n>a/2&&(n=a/2);let i;for(i=0;i<n;++i){let s=parseInt(e.substr(i*2,2),16);if(pt(s))return i;r[t+i]=s}return i}function fo(r,e,t,n){return Fe(lt(e,r.length-t),r,t,n)}function po(r,e,t,n){return Fe(vo(e),r,t,n)}function ho(r,e,t,n){return Fe(hr(e),r,t,n)}function go(r,e,t,n){return Fe(_o(e,r.length-t),r,t,n)}f.prototype.write=function(e,t,n,o){if(t===void 0)o="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")o=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-t;if((n===void 0||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let i=!1;for(;;)switch(o){case"hex":return uo(this,e,t,n);case"utf8":case"utf-8":return fo(this,e,t,n);case"ascii":case"latin1":case"binary":return po(this,e,t,n);case"base64":return ho(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return go(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),i=!0}};f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function mo(r,e,t){return e===0&&t===r.length?it.fromByteArray(r):it.fromByteArray(r.slice(e,t))}function sr(r,e,t){t=Math.min(r.length,t);let n=[],o=e;for(;o<t;){let a=r[o],i=null,s=a>239?4:a>223?3:a>191?2:1;if(o+s<=t){let l,c,d,u;switch(s){case 1:a<128&&(i=a);break;case 2:l=r[o+1],(l&192)===128&&(u=(a&31)<<6|l&63,u>127&&(i=u));break;case 3:l=r[o+1],c=r[o+2],(l&192)===128&&(c&192)===128&&(u=(a&15)<<12|(l&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:l=r[o+1],c=r[o+2],d=r[o+3],(l&192)===128&&(c&192)===128&&(d&192)===128&&(u=(a&15)<<18|(l&63)<<12|(c&63)<<6|d&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),o+=s}return yo(n)}var tr=4096;function yo(r){let e=r.length;if(e<=tr)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=tr));return t}function wo(r,e,t){let n="";t=Math.min(r.length,t);for(let o=e;o<t;++o)n+=String.fromCharCode(r[o]&127);return n}function Eo(r,e,t){let n="";t=Math.min(r.length,t);for(let o=e;o<t;++o)n+=String.fromCharCode(r[o]);return n}function So(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let o="";for(let a=e;a<t;++a)o+=Ao[r[a]];return o}function To(r,e,t){let n=r.slice(e,t),o="";for(let a=0;a<n.length-1;a+=2)o+=String.fromCharCode(n[a]+n[a+1]*256);return o}f.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let o=this.subarray(e,t);return Object.setPrototypeOf(o,f.prototype),o};function k(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUintLE=f.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let o=this[e],a=1,i=0;for(;++i<t&&(a*=256);)o+=this[e+i]*a;return o};f.prototype.readUintBE=f.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let o=this[e+--t],a=1;for(;t>0&&(a*=256);)o+=this[e+--t]*a;return o};f.prototype.readUint8=f.prototype.readUInt8=function(e,t){return e=e>>>0,t||k(e,1,this.length),this[e]};f.prototype.readUint16LE=f.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||k(e,2,this.length),this[e]|this[e+1]<<8};f.prototype.readUint16BE=f.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||k(e,2,this.length),this[e]<<8|this[e+1]};f.prototype.readUint32LE=f.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||k(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUint32BE=f.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||k(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readBigUInt64LE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let o=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,a=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(o)+(BigInt(a)<<BigInt(32))});f.prototype.readBigUInt64BE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let o=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],a=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(o)<<BigInt(32))+BigInt(a)});f.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let o=this[e],a=1,i=0;for(;++i<t&&(a*=256);)o+=this[e+i]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*t)),o};f.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let o=t,a=1,i=this[e+--o];for(;o>0&&(a*=256);)i+=this[e+--o]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*t)),i};f.prototype.readInt8=function(e,t){return e=e>>>0,t||k(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};f.prototype.readInt16LE=function(e,t){e=e>>>0,t||k(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};f.prototype.readInt16BE=function(e,t){e=e>>>0,t||k(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};f.prototype.readInt32LE=function(e,t){return e=e>>>0,t||k(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function(e,t){return e=e>>>0,t||k(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readBigInt64LE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(o)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});f.prototype.readBigInt64BE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let o=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});f.prototype.readFloatLE=function(e,t){return e=e>>>0,t||k(e,4,this.length),fe.read(this,e,!0,23,4)};f.prototype.readFloatBE=function(e,t){return e=e>>>0,t||k(e,4,this.length),fe.read(this,e,!1,23,4)};f.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||k(e,8,this.length),fe.read(this,e,!0,52,8)};f.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||k(e,8,this.length),fe.read(this,e,!1,52,8)};function M(r,e,t,n,o,a){if(!f.isBuffer(r))throw new TypeError(\'"buffer" argument must be a Buffer instance\');if(e>o||e<a)throw new RangeError(\'"value" argument is out of bounds\');if(t+n>r.length)throw new RangeError("Index out of range")}f.prototype.writeUintLE=f.prototype.writeUIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let s=Math.pow(2,8*n)-1;M(this,e,t,n,s,0)}let a=1,i=0;for(this[t]=e&255;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n};f.prototype.writeUintBE=f.prototype.writeUIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let s=Math.pow(2,8*n)-1;M(this,e,t,n,s,0)}let a=n-1,i=1;for(this[t+a]=e&255;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n};f.prototype.writeUint8=f.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1};f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function cr(r,e,t,n,o){pr(e,n,o,r,t,7);let a=Number(e&BigInt(4294967295));r[t++]=a,a=a>>8,r[t++]=a,a=a>>8,r[t++]=a,a=a>>8,r[t++]=a;let i=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i,t}function lr(r,e,t,n,o){pr(e,n,o,r,t,7);let a=Number(e&BigInt(4294967295));r[t+7]=a,a=a>>8,r[t+6]=a,a=a>>8,r[t+5]=a,a=a>>8,r[t+4]=a;let i=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=i,i=i>>8,r[t+2]=i,i=i>>8,r[t+1]=i,i=i>>8,r[t]=i,t+8}f.prototype.writeBigUInt64LE=Y(function(e,t=0){return cr(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeBigUInt64BE=Y(function(e,t=0){return lr(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let l=Math.pow(2,8*n-1);M(this,e,t,n,l-1,-l)}let a=0,i=1,s=0;for(this[t]=e&255;++a<n&&(i*=256);)e<0&&s===0&&this[t+a-1]!==0&&(s=1),this[t+a]=(e/i>>0)-s&255;return t+n};f.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let l=Math.pow(2,8*n-1);M(this,e,t,n,l-1,-l)}let a=n-1,i=1,s=0;for(this[t+a]=e&255;--a>=0&&(i*=256);)e<0&&s===0&&this[t+a+1]!==0&&(s=1),this[t+a]=(e/i>>0)-s&255;return t+n};f.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};f.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};f.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};f.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};f.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};f.prototype.writeBigInt64LE=Y(function(e,t=0){return cr(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});f.prototype.writeBigInt64BE=Y(function(e,t=0){return lr(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ur(r,e,t,n,o,a){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function dr(r,e,t,n,o){return e=+e,t=t>>>0,o||ur(r,e,t,4,34028234663852886e22,-34028234663852886e22),fe.write(r,e,t,n,23,4),t+4}f.prototype.writeFloatLE=function(e,t,n){return dr(this,e,t,!0,n)};f.prototype.writeFloatBE=function(e,t,n){return dr(this,e,t,!1,n)};function fr(r,e,t,n,o){return e=+e,t=t>>>0,o||ur(r,e,t,8,17976931348623157e292,-17976931348623157e292),fe.write(r,e,t,n,52,8),t+8}f.prototype.writeDoubleLE=function(e,t,n){return fr(this,e,t,!0,n)};f.prototype.writeDoubleBE=function(e,t,n){return fr(this,e,t,!1,n)};f.prototype.copy=function(e,t,n,o){if(!f.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-n&&(o=e.length-t+n);let a=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),t),a};f.prototype.fill=function(e,t,n,o){if(typeof e=="string"){if(typeof t=="string"?(o=t,t=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!f.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let i=e.charCodeAt(0);(o==="utf8"&&i<128||o==="latin1")&&(e=i)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let a;if(typeof e=="number")for(a=t;a<n;++a)this[a]=e;else{let i=f.isBuffer(e)?e:f.from(e,o),s=i.length;if(s===0)throw new TypeError(\'The value "\'+e+\'" is invalid for argument "value"\');for(a=0;a<n-t;++a)this[a+t]=i[a%s]}return this};var de={};function ft(r,e,t){de[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ft("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ft("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);ft("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,o=t;return Number.isInteger(t)&&Math.abs(t)>2**32?o=rr(String(t)):typeof t=="bigint"&&(o=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(o=rr(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n},RangeError);function rr(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function bo(r,e,t){pe(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Ae(e,r.length-(t+1))}function pr(r,e,t,n,o,a){if(r>t||r<e){let i=typeof e=="bigint"?"n":"",s;throw a>3?e===0||e===BigInt(0)?s=`>= 0${i} and < 2${i} ** ${(a+1)*8}${i}`:s=`>= -(2${i} ** ${(a+1)*8-1}${i}) and < 2 ** ${(a+1)*8-1}${i}`:s=`>= ${e}${i} and <= ${t}${i}`,new de.ERR_OUT_OF_RANGE("value",s,r)}bo(n,o,a)}function pe(r,e){if(typeof r!="number")throw new de.ERR_INVALID_ARG_TYPE(e,"number",r)}function Ae(r,e,t){throw Math.floor(r)!==r?(pe(r,t),new de.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new de.ERR_BUFFER_OUT_OF_BOUNDS:new de.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Io=/[^+/0-9A-Za-z-_]/g;function Ro(r){if(r=r.split("=")[0],r=r.trim().replace(Io,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function lt(r,e){e=e||1/0;let t,n=r.length,o=null,a=[];for(let i=0;i<n;++i){if(t=r.charCodeAt(i),t>55295&&t<57344){if(!o){if(t>56319){(e-=3)>-1&&a.push(239,191,189);continue}else if(i+1===n){(e-=3)>-1&&a.push(239,191,189);continue}o=t;continue}if(t<56320){(e-=3)>-1&&a.push(239,191,189),o=t;continue}t=(o-55296<<10|t-56320)+65536}else o&&(e-=3)>-1&&a.push(239,191,189);if(o=null,t<128){if((e-=1)<0)break;a.push(t)}else if(t<2048){if((e-=2)<0)break;a.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;a.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;a.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return a}function vo(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function _o(r,e){let t,n,o,a=[];for(let i=0;i<r.length&&!((e-=2)<0);++i)t=r.charCodeAt(i),n=t>>8,o=t%256,a.push(o),a.push(n);return a}function hr(r){return it.toByteArray(Ro(r))}function Fe(r,e,t,n){let o;for(o=0;o<n&&!(o+t>=e.length||o>=r.length);++o)e[o+t]=r[o];return o}function j(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function pt(r){return r!==r}var Ao=(function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let o=0;o<16;++o)e[n+o]=r[t]+r[o]}return e})();function Y(r){return typeof BigInt>"u"?xo:r}function xo(){throw new Error("BigInt not supported")}});var Zr=q(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});function ca(r){var e=4,t=r.length,n=t%e;if(!n)return r;var o=t,a=e-n,i=t+a,s=Buffer.alloc(i);for(s.write(r);a--;)s.write("=",o++);return s.toString()}xt.default=ca});var en=q(Pt=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});var la=Zr();function Qr(r,e){return e===void 0&&(e="utf8"),Buffer.isBuffer(r)?Ct(r.toString("base64")):Ct(Buffer.from(r,e).toString("base64"))}function ua(r,e){return e===void 0&&(e="utf8"),Buffer.from(Ot(r),"base64").toString(e)}function Ot(r){return r=r.toString(),la.default(r).replace(/\\-/g,"+").replace(/_/g,"/")}function Ct(r){return r.replace(/=/g,"").replace(/\\+/g,"-").replace(/\\//g,"_")}function da(r){return Buffer.from(Ot(r),"base64")}var we=Qr;we.encode=Qr;we.decode=ua;we.toBase64=Ot;we.fromBase64=Ct;we.toBuffer=da;Pt.default=we});var tn=q((ms,Ge)=>{Ge.exports=en().default;Ge.exports.default=Ge.exports});var nn=q((rn,Xe)=>{(function(r,e){var t={};e(t);var n=t.default;for(var o in t)n[o]=t[o];typeof Xe=="object"&&typeof Xe.exports=="object"?Xe.exports=n:typeof define=="function"&&define.amd?define(function(){return n}):r.sha256=n})(rn,function(r){"use strict";r.__esModule=!0,r.digestLength=32,r.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function t(u,p,h,g,m){for(var T,b,S,_,x,v,F,C,U,O,ce,le,ve;m>=64;){for(T=p[0],b=p[1],S=p[2],_=p[3],x=p[4],v=p[5],F=p[6],C=p[7],O=0;O<16;O++)ce=g+O*4,u[O]=(h[ce]&255)<<24|(h[ce+1]&255)<<16|(h[ce+2]&255)<<8|h[ce+3]&255;for(O=16;O<64;O++)U=u[O-2],le=(U>>>17|U<<15)^(U>>>19|U<<13)^U>>>10,U=u[O-15],ve=(U>>>7|U<<25)^(U>>>18|U<<14)^U>>>3,u[O]=(le+u[O-7]|0)+(ve+u[O-16]|0);for(O=0;O<64;O++)le=(((x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7))+(x&v^~x&F)|0)+(C+(e[O]+u[O]|0)|0)|0,ve=((T>>>2|T<<30)^(T>>>13|T<<19)^(T>>>22|T<<10))+(T&b^T&S^b&S)|0,C=F,F=v,v=x,x=_+le|0,_=S,S=b,b=T,T=le+ve|0;p[0]+=T,p[1]+=b,p[2]+=S,p[3]+=_,p[4]+=x,p[5]+=v,p[6]+=F,p[7]+=C,g+=64,m-=64}return g}var n=(function(){function u(){this.digestLength=r.digestLength,this.blockSize=r.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return u.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},u.prototype.clean=function(){for(var p=0;p<this.buffer.length;p++)this.buffer[p]=0;for(var p=0;p<this.temp.length;p++)this.temp[p]=0;this.reset()},u.prototype.update=function(p,h){if(h===void 0&&(h=p.length),this.finished)throw new Error("SHA256: can\'t update because hash was finished.");var g=0;if(this.bytesHashed+=h,this.bufferLength>0){for(;this.bufferLength<64&&h>0;)this.buffer[this.bufferLength++]=p[g++],h--;this.bufferLength===64&&(t(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(h>=64&&(g=t(this.temp,this.state,p,g,h),h%=64);h>0;)this.buffer[this.bufferLength++]=p[g++],h--;return this},u.prototype.finish=function(p){if(!this.finished){var h=this.bytesHashed,g=this.bufferLength,m=h/536870912|0,T=h<<3,b=h%64<56?64:128;this.buffer[g]=128;for(var S=g+1;S<b-8;S++)this.buffer[S]=0;this.buffer[b-8]=m>>>24&255,this.buffer[b-7]=m>>>16&255,this.buffer[b-6]=m>>>8&255,this.buffer[b-5]=m>>>0&255,this.buffer[b-4]=T>>>24&255,this.buffer[b-3]=T>>>16&255,this.buffer[b-2]=T>>>8&255,this.buffer[b-1]=T>>>0&255,t(this.temp,this.state,this.buffer,0,b),this.finished=!0}for(var S=0;S<8;S++)p[S*4+0]=this.state[S]>>>24&255,p[S*4+1]=this.state[S]>>>16&255,p[S*4+2]=this.state[S]>>>8&255,p[S*4+3]=this.state[S]>>>0&255;return this},u.prototype.digest=function(){var p=new Uint8Array(this.digestLength);return this.finish(p),p},u.prototype._saveState=function(p){for(var h=0;h<this.state.length;h++)p[h]=this.state[h]},u.prototype._restoreState=function(p,h){for(var g=0;g<this.state.length;g++)this.state[g]=p[g];this.bytesHashed=h,this.finished=!1,this.bufferLength=0},u})();r.Hash=n;var o=(function(){function u(p){this.inner=new n,this.outer=new n,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var h=new Uint8Array(this.blockSize);if(p.length>this.blockSize)new n().update(p).finish(h).clean();else for(var g=0;g<p.length;g++)h[g]=p[g];for(var g=0;g<h.length;g++)h[g]^=54;this.inner.update(h);for(var g=0;g<h.length;g++)h[g]^=106;this.outer.update(h),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var g=0;g<h.length;g++)h[g]=0}return u.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},u.prototype.clean=function(){for(var p=0;p<this.istate.length;p++)this.ostate[p]=this.istate[p]=0;this.inner.clean(),this.outer.clean()},u.prototype.update=function(p){return this.inner.update(p),this},u.prototype.finish=function(p){return this.outer.finished?this.outer.finish(p):(this.inner.finish(p),this.outer.update(p,this.digestLength).finish(p)),this},u.prototype.digest=function(){var p=new Uint8Array(this.digestLength);return this.finish(p),p},u})();r.HMAC=o;function a(u){var p=new n().update(u),h=p.digest();return p.clean(),h}r.hash=a,r.default=a;function i(u,p){var h=new o(u).update(p),g=h.digest();return h.clean(),g}r.hmac=i;function s(u,p,h,g){var m=g[0];if(m===0)throw new Error("hkdf: cannot expand more");p.reset(),m>1&&p.update(u),h&&p.update(h),p.update(g),p.finish(u),g[0]++}var l=new Uint8Array(r.digestLength);function c(u,p,h,g){p===void 0&&(p=l),g===void 0&&(g=32);for(var m=new Uint8Array([1]),T=i(p,u),b=new o(T),S=new Uint8Array(b.digestLength),_=S.length,x=new Uint8Array(g),v=0;v<g;v++)_===S.length&&(s(S,b,h,m),_=0),x[v]=S[_++];return b.clean(),S.fill(0),m.fill(0),x}r.hkdf=c;function d(u,p,h,g){for(var m=new o(u),T=m.digestLength,b=new Uint8Array(4),S=new Uint8Array(T),_=new Uint8Array(T),x=new Uint8Array(g),v=0;v*T<g;v++){var F=v+1;b[0]=F>>>24&255,b[1]=F>>>16&255,b[2]=F>>>8&255,b[3]=F>>>0&255,m.reset(),m.update(p),m.update(b),m.finish(_);for(var C=0;C<T;C++)S[C]=_[C];for(var C=2;C<=h;C++){m.reset(),m.update(_).finish(_);for(var U=0;U<T;U++)S[U]^=_[U]}for(var C=0;C<T&&v*T+C<g;C++)x[v*T+C]=S[C]}for(var v=0;v<T;v++)S[v]=_[v]=0;for(var v=0;v<4;v++)b[v]=0;return m.clean(),x}r.pbkdf2=d})});var Nn=q((Kt,kn)=>{var Ze=Ke(),z=Ze.Buffer;function Un(r,e){for(var t in r)e[t]=r[t]}z.from&&z.alloc&&z.allocUnsafe&&z.allocUnsafeSlow?kn.exports=Ze:(Un(Ze,Kt),Kt.Buffer=se);function se(r,e,t){return z(r,e,t)}se.prototype=Object.create(z.prototype);Un(z,se);se.from=function(r,e,t){if(typeof r=="number")throw new TypeError("Argument must not be a number");return z(r,e,t)};se.alloc=function(r,e,t){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=z(r);return e!==void 0?typeof t=="string"?n.fill(e,t):n.fill(e):n.fill(0),n};se.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return z(r)};se.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return Ze.SlowBuffer(r)}});var Dn=q((Kc,jt)=>{"use strict";var Wt=65536,Aa=4294967295;function xa(){throw new Error(`Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11`)}var Ca=Nn().Buffer,Qe=self.crypto||self.msCrypto;Qe&&Qe.getRandomValues?jt.exports=Oa:jt.exports=xa;function Oa(r,e){if(r>Aa)throw new RangeError("requested too many random bytes");var t=Ca.allocUnsafe(r);if(r>0)if(r>Wt)for(var n=0;n<r;n+=Wt)Qe.getRandomValues(t.slice(n,n+Wt));else Qe.getRandomValues(t);return typeof e=="function"?process.nextTick(function(){e(null,t)}):t}});var Fn=_e(Ke(),1);var Co=Object.defineProperty,Oo=(r,e,t)=>e in r?Co(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,R=(r,e,t)=>Oo(r,typeof e!="symbol"?e+"":e,t),Po={Endpoints:{AUTHORIZATION:"/oauth2/authorize",END_SESSION:"/oidc/logout",ISSUER:"/oauth2/token",JWKS:"/oauth2/jwks",REVOCATION:"/oauth2/revoke",SESSION_IFRAME:"/oidc/checksession",TOKEN:"/oauth2/token",USERINFO:"/oauth2/userinfo"},Storage:{StorageKeys:{Endpoints:{AUTHORIZATION:"authorization_endpoint",END_SESSION:"end_session_endpoint",ISSUER:"issuer",JWKS:"jwks_uri",REVOCATION:"revocation_endpoint",SESSION_IFRAME:"check_session_iframe",TOKEN:"token_endpoint",USERINFO:"userinfo_endpoint"},OPENID_PROVIDER_CONFIG_INITIATED:"op_config_initiated"}}},P=Po,Uo={Placeholders:{ACCESS_TOKEN:"{{accessToken}}",CLIENT_ID:"{{clientId}}",CLIENT_SECRET:"{{clientSecret}}",SCOPES:"{{scopes}}",USERNAME:"{{username}}"}},xe=Uo,E=class{constructor(r,e,t){R(this,"name"),R(this,"code"),R(this,"message"),this.message=t,this.name=e,this.code=r,Object.setPrototypeOf(this,new.target.prototype)}};var ko=r=>{let e={...r};return["iss","aud","exp","iat","acr","amr","azp","auth_time","nonce","c_hash","at_hash","nbf","isk","sid","jti","sub"].forEach(n=>{delete e[n]}),e},No=ko,Do={INTERNAL_LOGIN:"internal_login",OPENID:"openid",PROFILE:"profile"},ht=Do,Mo={Params:{AUTHORIZATION_CODE:"code",SESSION_STATE:"session_state",SIGN_OUT_SUCCESS:"sign_out_success",STATE:"state"},SignIn:{Payload:{DEFAULT_SCOPES:[ht.OPENID,ht.PROFILE,ht.INTERNAL_LOGIN]}},SignOut:{Storage:{StorageKeys:{SIGN_OUT_URL:"sign_out_url"}}}},N=Mo,Lo=class Er extends Error{constructor(e,t,n){let o=Er.resolveOrigin(n);super(e),R(this,"code"),R(this,"origin"),this.name=new.target.name,this.code=t,this.origin=o,Error.captureStackTrace&&Error.captureStackTrace(this,new.target)}static resolveOrigin(e){return e?`@asgardeo/${e}`:"@asgardeo/javascript"}toString(){let e=`\\u{1F6E1}\\uFE0F Asgardeo - ${this.origin}:`;return`[${this.name}]\n${e} ${this.message}\n(code="${this.code}")`}},Sr=class extends Lo{constructor(r,e,t,n){super(r,e,t),this.details=n,Object.defineProperty(this,"name",{configurable:!0,value:"AsgardeoRuntimeError",writable:!0})}toString(){let r=this.details?`\nDetails: ${JSON.stringify(this.details,null,2)}`:"";return`[${this.name}] (code="${this.code}")${r}\nMessage: ${this.message}`}},Ho=r=>{let e=[],t=!1;if(r!=null)if(Array.isArray(r))e=r,t=r.length>0;else if(typeof r=="string")e=r?r.split(" "):[],t=r.length>0;else throw new Sr("Scopes must be a string or an array of strings.","processOpenIDScopes-Invalid-001","javascript","The provided scopes are not in the expected format. Please provide a string or an array of strings.");return t||N.SignIn.Payload.DEFAULT_SCOPES.forEach(n=>{e.includes(n)||e.push(n)}),e.join(" ")},mt=Ho,Bo=class{constructor(r,e){R(this,"storageManager"),R(this,"config"),R(this,"oidcProviderMetaData"),R(this,"cryptoHelper"),this.storageManager=r,this.config=async()=>this.storageManager.getConfigData(),this.oidcProviderMetaData=async()=>this.storageManager.loadOpenIDProviderConfiguration(),this.cryptoHelper=e}async resolveEndpoints(r){let e={},t=await this.config();return t.endpoints&&Object.keys(t.endpoints).forEach(n=>{let o=n.replace(/[A-Z]/g,a=>`_${a.toLowerCase()}`);e[o]=t?.endpoints?t.endpoints[n]:""}),{...r,...e}}async resolveEndpointsExplicitly(){let r={},e=await this.config(),t=[P.Storage.StorageKeys.Endpoints.AUTHORIZATION,P.Storage.StorageKeys.Endpoints.END_SESSION,P.Storage.StorageKeys.Endpoints.JWKS,P.Storage.StorageKeys.Endpoints.SESSION_IFRAME,P.Storage.StorageKeys.Endpoints.REVOCATION,P.Storage.StorageKeys.Endpoints.TOKEN,P.Storage.StorageKeys.Endpoints.ISSUER,P.Storage.StorageKeys.Endpoints.USERINFO];if(!(e.endpoints?t.every(o=>e.endpoints?Object.keys(e.endpoints).some(a=>a.replace(/[A-Z]/g,s=>`_${s.toLowerCase()}`)===o):!1):!1))throw new E("JS-AUTH_HELPER-REE-NF01","Required endpoints missing","Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object.");return e.endpoints&&Object.keys(e.endpoints).forEach(o=>{let a=o.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`);r[a]=e?.endpoints?e.endpoints[o]:""}),{...r}}async resolveEndpointsByBaseURL(){let r={},e=await this.config(),{baseUrl:t}=e;if(!t)throw new E("JS-AUTH_HELPER_REBO-NF01","Base URL not defined.","Base URL is not defined in AuthClient config.");e.endpoints&&Object.keys(e.endpoints).forEach(i=>{let s=i.replace(/[A-Z]/g,l=>`_${l.toLowerCase()}`);r[s]=e?.endpoints?e.endpoints[i]:""});let n=P.Storage.StorageKeys.Endpoints,o=P.Endpoints,a={[n.AUTHORIZATION]:`${t}${o.AUTHORIZATION}`,[n.END_SESSION]:`${t}${o.END_SESSION}`,[n.ISSUER]:`${t}${o.ISSUER}`,[n.JWKS]:`${t}${o.JWKS}`,[n.SESSION_IFRAME]:`${t}${o.SESSION_IFRAME}`,[n.REVOCATION]:`${t}${o.REVOCATION}`,[n.TOKEN]:`${t}${o.TOKEN}`,[n.USERINFO]:`${t}${o.USERINFO}`};return e.platform==="AsgardeoV2"&&(a[P.Storage.StorageKeys.Endpoints.ISSUER]=`${t}`),{...a,...r}}async validateIdToken(r){let e=(await this.storageManager.loadOpenIDProviderConfiguration()).jwks_uri,t=await this.config();if(!e||e.trim().length===0)throw new E("JS_AUTH_HELPER-VIT-NF01","JWKS endpoint not found.","No JWKS endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the JWKS endpoint passed to the SDK is empty.");let n;try{n=await fetch(e,{credentials:t.sendCookiesInRequests?"include":"same-origin"})}catch(s){throw new E("JS-AUTH_HELPER-VIT-NE02","Request to jwks endpoint failed.",s??"The request sent to get the jwks from the server failed.")}if(n.status!==200||!n.ok)throw new E("JS-AUTH_HELPER-VIT-HE03",`Invalid response status received for jwks request (${n.statusText}).`,await n.json());let{issuer:o}=await this.oidcProviderMetaData(),{keys:a}=await n.json(),i=await this.cryptoHelper.getJWKForTheIdToken(r.split(".")[0],a);return this.cryptoHelper.isValidIdToken(r,i,(await this.config()).clientId,o??"",this.cryptoHelper.decodeJwtToken(r).sub,(await this.config()).tokenValidation?.idToken?.clockTolerance,(await this.config()).tokenValidation?.idToken?.validateIssuer??!0)}getAuthenticatedUserInfo(r){let e=this.cryptoHelper.decodeJwtToken(r),t=e?.username??"",n=e?.given_name??"",o=e?.family_name??"",a=n&&o?`${n} ${o}`:n||o||"";return{displayName:e.preferred_username??a,username:t,...No(e)}}async replaceCustomGrantTemplateTags(r,e){let t=await this.config(),n=t.organizationChain?.sourceInstanceId??null,o;if(n){let{clientId:i}=t,s;if(i?s=`instance_${n}-${i}`:s=`instance_${n}`,o=await this.storageManager.getSessionData(e,s),!o||!o.access_token)throw new E("JS-AUTH_HELPER-RCGTT-NE01","No session data found for source instance.","Failed to retrieve session data from the source organization context.")}else o=await this.storageManager.getSessionData(e);let a=mt(t.scopes);return typeof r!="string"?r:r.replace(xe.Placeholders.ACCESS_TOKEN,o.access_token).replace(xe.Placeholders.USERNAME,this.getAuthenticatedUserInfo(o.id_token).username).replace(xe.Placeholders.SCOPES,a).replace(xe.Placeholders.CLIENT_ID,t.clientId).replace(xe.Placeholders.CLIENT_SECRET,t.clientSecret??"")}async clearSession(r){await this.storageManager.removeTemporaryData(r),await this.storageManager.removeSessionData(r)}async handleTokenResponse(r,e){if(r.status!==200||!r.ok)throw new E("JS-AUTH_HELPER-HTR-NE01",`Invalid response status received for token request (${r.statusText}).`,await r.json());let t=await r.json();if(t.created_at=new Date().getTime(),(await this.config()).tokenValidation?.idToken?.validate)return this.validateIdToken(t.id_token).then(async()=>{await this.storageManager.setSessionData(t,e);let a={accessToken:t.access_token,createdAt:t.created_at,expiresIn:t.expires_in,idToken:t.id_token,refreshToken:t.refresh_token,scope:t.scope,tokenType:t.token_type};return Promise.resolve(a)});let o={accessToken:t.access_token,createdAt:t.created_at,expiresIn:t.expires_in,idToken:t.id_token,refreshToken:t.refresh_token,scope:t.scope,tokenType:t.token_type};return await this.storageManager.setSessionData(t,e),Promise.resolve(o)}},$o={DEFAULT_CODE_CHALLENGE_METHOD:"S256",Storage:{StorageKeys:{CODE_VERIFIER:"pkce_code_verifier",SEPARATOR:"#"}}},Z=$o,Fo={Endpoints:{WELL_KNOWN:"/.well-known/openid-configuration"}},Ko=Fo,Wo={SignatureValidation:{SUPPORTED_ALGORITHMS:["RS256","RS512","RS384","PS256"]},Storage:{StorageKeys:{REFRESH_TOKEN_TIMER:"refresh_token_timer"}}},Ce=Wo,jo=class{constructor(r){R(this,"cryptoUtils"),this.cryptoUtils=r}getCodeVerifier(){return this.cryptoUtils.base64URLEncode(this.cryptoUtils.generateRandomBytes(32))}async getCodeChallenge(r){let e=await this.cryptoUtils.hashSha256(r);return this.cryptoUtils.base64URLEncode(e)}getJWKForTheIdToken(r,e){let t=JSON.parse(this.cryptoUtils.base64URLDecode(r)),n=e.find(o=>t.kid===o.kid);if(n)return n;throw new E("JS-CRYPTO_UTIL-GJFTIT-IV01","kid not found.",`Failed to find the \'kid\' specified in the id_token. \'kid\' found in the header : ${t.kid}, Expected values: ${e.map(o=>o.kid).join(", ")}`)}isValidIdToken(r,e,t,n,o,a,i){return this.cryptoUtils.verifyJwt(r,e,Ce.SignatureValidation.SUPPORTED_ALGORITHMS,t,n,o,a,i).then(s=>s?Promise.resolve(!0):Promise.reject(new E("JS-CRYPTO_HELPER-IVIT-IV01","Invalid ID token.","ID token validation returned false"))).catch(s=>Promise.reject(s))}decodeJwtToken(r){try{let e=this.cryptoUtils.base64URLDecode(r?.split(".")[1]);return JSON.parse(e)}catch(e){throw new E("JS-CRYPTO_UTIL-DIT-IV02","Decoding token failed.",e)}}},gt="asgardeo-session-active",zo=class We{constructor(e,t){R(this,"id"),R(this,"store"),this.id=e,this.store=t}async setDataInBulk(e,t){let n=await this.store.getData(e)??null,a={...n&&JSON.parse(n),...t},i=JSON.stringify(a);await this.store.setData(e,i)}async setValue(e,t,n){let o=await this.store.getData(e)??null,i={...o&&JSON.parse(o),[t]:n},s=JSON.stringify(i);await this.store.setData(e,s)}async removeValue(e,t){let n=await this.store.getData(e)??null,a={...n&&JSON.parse(n)};delete a[t];let i=JSON.stringify(a);await this.store.setData(e,i)}resolveKey(e,t,n){return t&&n?`${e}-${n}-${t}`:t?`${e}-${this.id}-${t}`:n?`${e}-${n}`:`${e}-${this.id}`}static isLocalStorageAvailable(){try{let e="__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}async setConfigData(e){await this.setDataInBulk(this.resolveKey("config_data"),e)}async setOIDCProviderMetaData(e){this.setDataInBulk(this.resolveKey("oidc_provider_meta_data"),e)}async setTemporaryData(e,t){this.setDataInBulk(this.resolveKey("temporary_data",t),e)}async setSessionData(e,t){this.setDataInBulk(this.resolveKey("session_data",t),e)}async setCustomData(e,t,n){this.setDataInBulk(this.resolveKey(e,n),t)}async getConfigData(e){return JSON.parse(await this.store.getData(this.resolveKey("config_data",e))??null)}async loadOpenIDProviderConfiguration(){return JSON.parse(await this.store.getData(this.resolveKey("oidc_provider_meta_data"))??null)}async getTemporaryData(e){return JSON.parse(await this.store.getData(this.resolveKey("temporary_data",e))??null)}async getPersistedData(e){return JSON.parse(await this.store.getData(this.resolveKey("persisted_data",e))??null)}async setPersistedData(e,t){this.setDataInBulk(this.resolveKey("persisted_data",t),e)}async getSessionData(e,t){return JSON.parse(await this.store.getData(this.resolveKey("session_data",e,t))??null)}async getCustomData(e,t){return JSON.parse(await this.store.getData(this.resolveKey(e,t))??null)}setSessionStatus(e){We.isLocalStorageAvailable()&&localStorage.setItem(`${gt}`,e)}getSessionStatus(){return We.isLocalStorageAvailable()?localStorage.getItem(`${gt}`)??"":""}removeSessionStatus(){We.isLocalStorageAvailable()&&localStorage.removeItem(`${gt}`)}async removeConfigData(){await this.store.removeData(this.resolveKey("config_data"))}async removeOIDCProviderMetaData(){await this.store.removeData(this.resolveKey("oidc_provider_meta_data"))}async removeTemporaryData(e){await this.store.removeData(this.resolveKey("temporary_data",e))}async removeSessionData(e){await this.store.removeData(this.resolveKey("session_data",e))}async getConfigDataParameter(e){let t=await this.store.getData(this.resolveKey("config_data"));return t&&JSON.parse(t)[e]}async getOIDCProviderMetaDataParameter(e){let t=await this.store.getData(this.resolveKey("oidc_provider_meta_data"));return t&&JSON.parse(t)[e]}async getTemporaryDataParameter(e,t){let n=await this.store.getData(this.resolveKey("temporary_data",t));return n&&JSON.parse(n)[e]}async getSessionDataParameter(e,t){let n=await this.store.getData(this.resolveKey("session_data",t));return n&&JSON.parse(n)[e]}async setConfigDataParameter(e,t){await this.setValue(this.resolveKey("config_data"),e,t)}async setOIDCProviderMetaDataParameter(e,t){await this.setValue(this.resolveKey("oidc_provider_meta_data"),e,t)}async setTemporaryDataParameter(e,t,n){await this.setValue(this.resolveKey("temporary_data",n),e,t)}async setSessionDataParameter(e,t,n){await this.setValue(this.resolveKey("session_data",n),e,t)}async removeConfigDataParameter(e){await this.removeValue(this.resolveKey("config_data"),e)}async removeOIDCProviderMetaDataParameter(e){await this.removeValue(this.resolveKey("oidc_provider_meta_data"),e)}async removeTemporaryDataParameter(e,t){await this.removeValue(this.resolveKey("temporary_data",t),e)}async removeSessionDataParameter(e,t){await this.removeValue(this.resolveKey("session_data",t),e)}},gr=zo,mr=r=>typeof r=="object"&&r!==null&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.prototype.toString.call(r)==="[object Object]",Tr=(r,...e)=>{if(!r||typeof r!="object")throw new Error("Target must be an object");let t={...r};return e.forEach(n=>{!n||typeof n!="object"||Object.keys(n).forEach(o=>{let a=n[o],i=t[o];mr(a)&&mr(i)?t[o]=Tr(i,a):a!==void 0&&(t[o]=a)})}),t},qo=Tr,Vo=r=>{let e=parseInt(r.split("request_")[1],10);return`${Z.Storage.StorageKeys.CODE_VERIFIER}${Z.Storage.StorageKeys.SEPARATOR}${e}`},oe=Vo,Jo=r=>{let e=[];Object.keys(r).forEach(o=>{o.startsWith(Z.Storage.StorageKeys.CODE_VERIFIER)&&e.push(o)});let t=e.sort().pop(),n=parseInt(t?.split(Z.Storage.StorageKeys.SEPARATOR)[1]??"-1",10);return`${Z.Storage.StorageKeys.CODE_VERIFIER}${Z.Storage.StorageKeys.SEPARATOR}${n+1}`},Go=Jo,Xo=(r,e)=>{let t=parseInt(r.split(Z.Storage.StorageKeys.SEPARATOR)[1],10);return e?`${e}_request_${t}`:`request_${t}`},Yo=Xo,Zo=(r,e,t)=>{let{redirectUri:n,clientId:o,scopes:a,responseMode:i,codeChallenge:s,codeChallengeMethod:l,prompt:c}=r,d=new Map;d.set("response_type","code"),d.set("client_id",o),d.set("scope",a),d.set("redirect_uri",n),i&&d.set("response_mode",i);let u=e?.key;if(s)if(d.set("code_challenge",s),l)d.set("code_challenge_method",l);else throw new Sr("Code challenge method is required when code challenge is provided.","getAuthorizeRequestUrlParams-ValidationError-001","javascript","When PKCE is enabled, the code challenge method must be provided along with the code challenge.");c&&d.set("prompt",c),t&&Object.entries(t).forEach(([g,m])=>{g!==""&&m!==""&&g!==N.Params.STATE&&d.set(g,m.toString())});let p="instance_",h="";return r.instanceId?h=p+r.instanceId:t&&(h=t[N.Params.STATE]?.toString()??""),d.set(N.Params.STATE,Yo(u,h)),d},Qo=Zo,ea={enablePKCE:!0,responseMode:"query",sendCookiesInRequests:!0,tokenValidation:{idToken:{clockTolerance:300,validate:!0,validateIssuer:!0}}},br=class Ir{constructor(){R(this,"storageManager"),R(this,"configProvider"),R(this,"oidcProviderMetaDataProvider"),R(this,"authHelper"),R(this,"cryptoUtils"),R(this,"cryptoHelper"),R(this,"instanceIdValue")}async initialize(e,t,n,o){let{clientId:a}=e;this.instanceIdValue?this.instanceIdValue+=1:this.instanceIdValue=0,o!==void 0&&(this.instanceIdValue=o),a?this.storageManager=new gr(`instance_${this.instanceIdValue}-${a}`,t):this.storageManager=new gr(`instance_${this.instanceIdValue}`,t),this.cryptoUtils=n,this.cryptoHelper=new jo(n),this.authHelper=new Bo(this.storageManager,this.cryptoHelper),this.configProvider=async()=>this.storageManager.getConfigData(),this.oidcProviderMetaDataProvider=async()=>this.storageManager.loadOpenIDProviderConfiguration(),Ir.authHelperInstance=this.authHelper;let{applicationId:i,platform:s,endpoints:l}=e,c=i;if(i)await this.storageManager.setPersistedData({applicationId:i});else{let u=await this.storageManager.getPersistedData();u.applicationId&&(c=u.applicationId)}let d=l||{};s==="AsgardeoV2"&&(d.wellKnown||(d.wellKnown=Ko.Endpoints.WELL_KNOWN)),await this.storageManager.setConfigData({...ea,...e,applicationId:c,endpoints:d,scope:mt(e.scopes)})}getStorageManager(){return this.storageManager}getInstanceId(){return this.instanceIdValue}async getSignInUrl(e,t){let n={...e};delete n?.forceInit;let o=async()=>{let a=await this.storageManager.getOIDCProviderMetaDataParameter(P.Storage.StorageKeys.Endpoints.AUTHORIZATION);if(!a||a.trim().length===0)throw new E("JS-AUTH_CORE-GAU-NF01","No authorization endpoint found.","No authorization endpoint was found in the OIDC provider meta data from the well-known endpoint or the authorization endpoint passed to the SDK is empty.");let i=new URL(a),s=await this.configProvider(),l=await this.storageManager.getTemporaryData(t),c=await Go(l),d,u;s.enablePKCE&&(d=this.cryptoHelper?.getCodeVerifier(),u=await this.cryptoHelper?.getCodeChallenge(d),await this.storageManager.setTemporaryDataParameter(c,d,t)),n.client_secret&&(n.client_secret=s.clientSecret);let p=Qo({clientId:s.clientId,codeChallenge:u,codeChallengeMethod:Z.DEFAULT_CODE_CHALLENGE_METHOD,instanceId:this.getInstanceId().toString(),prompt:s.prompt,redirectUri:s.afterSignInUrl,responseMode:s.responseMode,scopes:mt(s.scopes)},{key:c},n);return Array.from(p.entries()).forEach(([h,g])=>{i.searchParams.append(h,g)}),i.toString()};return await this.storageManager.getTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)?o():this.loadOpenIDProviderConfiguration(e?.forceInit).then(()=>o())}async requestAccessToken(e,t,n,o,a){await this.storageManager.getTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)||await this.loadOpenIDProviderConfiguration(!1);let i=(await this.oidcProviderMetaDataProvider()).token_endpoint,s=await this.configProvider();if(!i||i.trim().length===0)throw new E("JS-AUTH_CORE-RAT1-NF01","Token endpoint not found.","No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty.");t&&await this.storageManager.setSessionDataParameter(N.Params.SESSION_STATE,t,o);let l=new URLSearchParams;l.set("client_id",s.clientId),s.clientSecret&&s.clientSecret.trim().length>0&&l.set("client_secret",s.clientSecret);let c=e;l.set("code",c),l.set("grant_type","authorization_code"),l.set("redirect_uri",s.afterSignInUrl),a?.params&&Object.entries(a.params).forEach(([u,p])=>{l.append(u,p)}),s.enablePKCE&&(l.set("code_verifier",`${await this.storageManager.getTemporaryDataParameter(oe(n),o)}`),await this.storageManager.removeTemporaryDataParameter(oe(n),o));let d;try{d=await fetch(i,{body:l,credentials:s.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(u){throw new E("JS-AUTH_CORE-RAT1-NE02","Requesting access token failed",u??"The request to get the access token from the server failed.")}if(!d.ok)throw new E("JS-AUTH_CORE-RAT1-HE03",`Requesting access token failed with ${d.statusText}`,await d.json());return this.authHelper.handleTokenResponse(d,o)}async loadOpenIDProviderConfiguration(e){let t=await this.configProvider();if(!e&&await this.storageManager.getTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED))return Promise.resolve();let{wellKnownEndpoint:n,platform:o,discovery:a,baseUrl:i,endpoints:s}=t,l=n||(o==="AsgardeoV2"&&a?.wellKnown?.enabled?`${i}${s?.wellKnown??"/.well-known/openid-configuration"}`:void 0);if(l){let c;try{if(c=await fetch(l),c.status!==200||!c.ok)throw new Error}catch{throw new E("JS-AUTH_CORE-GOPMD-HE01","Invalid well-known response","The well known endpoint response has been failed with an error.")}return await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpoints(await c.json())),await this.storageManager.setTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}if(t.baseUrl){try{await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsByBaseURL())}catch(c){throw new E("JS-AUTH_CORE-GOPMD-IV02","Resolving endpoints failed.",c??"Resolving endpoints by base url failed.")}return await this.storageManager.setTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}return await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsExplicitly()),await this.storageManager.setTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}async getSignOutUrl(e){let t=(await this.oidcProviderMetaDataProvider())?.end_session_endpoint,n=await this.configProvider();if(!t||t.trim().length===0)throw new E("JS-AUTH_CORE-GSOU-NF01","Sign-out endpoint not found.","No sign-out endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the sign-out endpoint passed to the SDK is empty.");let o=n?.afterSignOutUrl??n?.afterSignInUrl;if(!o||o.trim().length===0)throw new E("JS-AUTH_CORE-GSOU-NF03","No sign-out redirect URL found.","The sign-out redirect URL cannot be found or the URL passed to the SDK is empty. No sign-in redirect URL has been found either. ");let a=new URLSearchParams;if(a.set("post_logout_redirect_uri",o),n.sendIdTokenInLogoutRequest){let i=(await this.storageManager.getSessionData(e))?.id_token;if(!i||i.trim().length===0)throw new E("JS-AUTH_CORE-GSOU-NF02","ID token not found.","No ID token could be found. Either the session information is lost or you have not signed in.");a.set("id_token_hint",i)}else a.set("client_id",n.clientId);return a.set("state",N.Params.SIGN_OUT_SUCCESS),`${t}?${a.toString()}`}async getOpenIDProviderEndpoints(){let e=await this.oidcProviderMetaDataProvider();return{authorizationEndpoint:e.authorization_endpoint??"",checkSessionIframe:e.check_session_iframe??"",endSessionEndpoint:e.end_session_endpoint??"",introspectionEndpoint:e.introspection_endpoint??"",issuer:e.issuer??"",jwksUri:e.jwks_uri??"",registrationEndpoint:e.registration_endpoint??"",revocationEndpoint:e.revocation_endpoint??"",tokenEndpoint:e.token_endpoint??"",userinfoEndpoint:e.userinfo_endpoint??""}}async decodeJwtToken(e){return this.cryptoHelper.decodeJwtToken(e)}async getDecodedIdToken(e,t){let n=(await this.storageManager.getSessionData(e)).id_token;return this.cryptoHelper.decodeJwtToken(n??t)}async getIdToken(e){return(await this.storageManager.getSessionData(e)).id_token}async getUser(e){let t=await this.storageManager.getSessionData(e),n=this.authHelper.getAuthenticatedUserInfo(t?.id_token);return Object.keys(n).forEach(o=>{(n[o]===void 0||n[o]===""||n[o]===null)&&delete n[o]}),n}async getUserSession(e){let t=await this.storageManager.getSessionData(e);return{scopes:t?.scope?.split(" "),sessionState:t?.session_state??""}}async getCrypto(){return this.cryptoHelper}async revokeAccessToken(e){let t=(await this.oidcProviderMetaDataProvider()).revocation_endpoint,n=await this.configProvider();if(!t||t.trim().length===0)throw new E("JS-AUTH_CORE-RAT3-NF01","No revoke access token endpoint found.","No revoke access token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the revoke access token endpoint passed to the SDK is empty.");let o=[];o.push(`client_id=${n.clientId}`),o.push(`token=${(await this.storageManager.getSessionData(e)).access_token}`),o.push("token_type_hint=access_token"),n.clientSecret&&n.clientSecret.trim().length>0&&o.push(`client_secret=${n.clientSecret}`);let a;try{a=await fetch(t,{body:o.join("&"),credentials:n.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(i){throw new E("JS-AUTH_CORE-RAT3-NE02","The request to revoke access token failed.",i??"The request sent to revoke the access token failed.")}if(a.status!==200||!a.ok)throw new E("JS-AUTH_CORE-RAT3-HE03",`Invalid response status received for revoke access token request (${a.statusText}).`,await a.json());return this.authHelper.clearSession(e),Promise.resolve(a)}async refreshAccessToken(e){let t=(await this.oidcProviderMetaDataProvider()).token_endpoint,n=await this.configProvider(),o=await this.storageManager.getSessionData(e);if(!o.refresh_token)throw new E("JS-AUTH_CORE-RAT2-NF01","No refresh token found.","There was no refresh token found. Asgardeo doesn\'t return a refresh token if the refresh token grant is not enabled.");if(!t||t.trim().length===0)throw new E("JS-AUTH_CORE-RAT2-NF02","No refresh token endpoint found.","No refresh token endpoint was in the OIDC provider meta data returned by the well-known endpoint or the refresh token endpoint passed to the SDK is empty.");let a=[];a.push(`client_id=${n.clientId}`),a.push(`refresh_token=${o.refresh_token}`),a.push("grant_type=refresh_token"),n.clientSecret&&n.clientSecret.trim().length>0&&a.push(`client_secret=${n.clientSecret}`);let i;try{i=await fetch(t,{body:a.join("&"),credentials:n.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(s){throw new E("JS-AUTH_CORE-RAT2-NR03","Refresh access token request failed.",s??"The request to refresh the access token failed.")}if(!i.ok)throw new E("JS-AUTH_CORE-RAT2-HE04",`Refreshing access token failed with ${i.statusText}`,await i.json());return this.authHelper.handleTokenResponse(i,e)}async getAccessToken(e){return(await this.storageManager.getSessionData(e))?.access_token}async exchangeToken(e,t){await this.storageManager.getTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)||await this.loadOpenIDProviderConfiguration(!1);let n=await this.oidcProviderMetaDataProvider(),o=await this.configProvider(),a;if(e.tokenEndpoint&&e.tokenEndpoint.trim().length!==0?a=e.tokenEndpoint:a=n.token_endpoint,!a||a.trim().length===0)throw new E("JS-AUTH_CORE-RCG-NF01","Token endpoint not found.","No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty.");let i=await Promise.all(Object.entries(e.data).map(async([d,u])=>{let p=await this.authHelper.replaceCustomGrantTemplateTags(u,t);return`${d}=${p}`})),s={Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"};e.attachToken&&(s={...s,Authorization:`Bearer ${(await this.storageManager.getSessionData(t)).access_token}`});let l={body:i.join("&"),credentials:o.sendCookiesInRequests?"include":"same-origin",headers:new Headers(s),method:"POST"},c;try{c=await fetch(a,l)}catch(d){throw new E("JS-AUTH_CORE-RCG-NE02","The custom grant request failed.",d??"The request sent to get the custom grant failed.")}if(c.status!==200||!c.ok)throw new E("JS-AUTH_CORE-RCG-HE03",`Invalid response status received for the custom grant request. (${c.statusText})`,await c.json());return e.returnsSession?this.authHelper.handleTokenResponse(c,t):Promise.resolve(await c.json())}async isSignedIn(e){let t=!!await this.getAccessToken(e),n=(await this.storageManager.getSessionData(e))?.created_at,o=(await this.storageManager.getSessionData(e))?.expires_in;if(!o)return!1;let a=parseInt(o,10)*1e3,i=new Date().getTime(),s=n+a>i;return t&&s}async getPKCECode(e,t){return await this.storageManager.getTemporaryDataParameter(oe(e),t)}async setPKCECode(e,t,n){return this.storageManager.setTemporaryDataParameter(oe(t),e,n)}static isSignOutSuccessful(e){let t=new URL(e),n=t.searchParams.get(N.Params.STATE),o=!!t.searchParams.get("error");return n?n===N.Params.SIGN_OUT_SUCCESS&&!o:!1}static didSignOutFail(e){let t=new URL(e),n=t.searchParams.get(N.Params.STATE),o=!!t.searchParams.get("error");return n?n===N.Params.SIGN_OUT_SUCCESS&&o:!1}async reInitialize(e){let t=this.storageManager.getConfigData(),n=qo(t,e);await this.storageManager.setConfigData(n),await this.loadOpenIDProviderConfiguration(!0)}static async clearSession(e){await this.authHelperInstance.clearSession(e)}};R(br,"authHelperInstance");var ae=br;var yr;(r=>{r.DEFAULT_AUTHENTICATOR_NAME="Username & Password"})(yr||(yr={}));var ta="\\u{1F6E1}\\uFE0F Asgardeo",ra={level:"info",prefix:`${ta}`,showLevel:!0,timestamps:!0},na=()=>typeof window<"u"&&typeof window.document<"u",oa=()=>typeof process<"u"&&process.versions&&process.versions.node,$={blue:"\\x1B[34m",bright:"\\x1B[1m",cyan:"\\x1B[36m",dim:"\\x1B[2m",gray:"\\x1B[90m",green:"\\x1B[32m",magenta:"\\x1B[35m",red:"\\x1B[31m",reset:"\\x1B[0m",white:"\\x1B[37m",yellow:"\\x1B[33m"},ge={debug:"color: #6b7280; font-weight: normal;",error:"color: #dc2626; font-weight: bold;",info:"color: #2563eb; font-weight: bold;",prefix:"color: #7c3aed; font-weight: bold;",timestamp:"color: #6b7280; font-size: 0.9em;",warn:"color: #d97706; font-weight: bold;"},wr={debug:0,error:3,info:1,warn:2},aa=class me{constructor(e={}){R(this,"config"),this.config={...ra,...e}}configure(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}shouldLog(e){return wr[e]>=wr[this.config.level]}static getTimestamp(){return new Date().toISOString()}static getLevelString(e){switch(e){case"debug":return"DEBUG";case"info":return"INFO";case"warn":return"WARN";case"error":return"ERROR";default:return"UNKNOWN"}}formatForNode(e,t){let n=[];if(this.config.timestamps&&n.push(`${$.gray}[${me.getTimestamp()}]${$.reset}`),this.config.prefix&&n.push(`${$.magenta}${this.config.prefix}${$.reset}`),this.config.showLevel){let o=me.getLevelString(e),a;switch(e){case"debug":a=`${$.gray}[${o}]${$.reset}`;break;case"info":a=`${$.blue}[${o}]${$.reset}`;break;case"warn":a=`${$.yellow}[${o}]${$.reset}`;break;case"error":a=`${$.red}[${o}]${$.reset}`;break;default:a=`[${o}]`}n.push(a)}return n.push(t),n.join(" ")}logMessage(e,t,...n){if(this.shouldLog(e)){if(this.config.formatter){this.config.formatter(e,t,...n);return}na()?this.logToBrowser(e,t,...n):oa()?this.logToNode(e,t,...n):console.log(t,...n)}}logToBrowser(e,t,...n){let o=[],a=[];if(this.config.timestamps&&(o.push(`%c[${me.getTimestamp()}]`),a.push(ge.timestamp)),this.config.prefix&&(o.push(`%c${this.config.prefix}`),a.push(ge.prefix)),this.config.showLevel){let s=me.getLevelString(e);switch(o.push(`%c[${s}]`),e){case"debug":a.push(ge.debug);break;case"info":a.push(ge.info);break;case"warn":a.push(ge.warn);break;case"error":a.push(ge.error);break;default:a.push("")}}o.push(`%c${t}`),a.push("color: inherit; font-weight: normal;");let i=o.join(" ");switch(e){case"debug":console.debug(i,...a,...n);break;case"info":console.info(i,...a,...n);break;case"warn":console.warn(i,...a,...n);break;case"error":console.error(i,...a,...n);break;default:console.log(i,...a,...n)}}logToNode(e,t,...n){let o=this.formatForNode(e,t);switch(e){case"debug":console.debug(o,...n);break;case"info":console.info(o,...n);break;case"warn":console.warn(o,...n);break;case"error":console.error(o,...n);break;default:console.log(o,...n)}}debug(e,...t){this.logMessage("debug",e,...t)}info(e,...t){this.logMessage("info",e,...t)}warn(e,...t){this.logMessage("warn",e,...t)}error(e,...t){this.logMessage("error",e,...t)}child(e){let t=this.config.prefix?`${this.config.prefix} - ${e}`:e;return new me({...this.config,prefix:t})}setLevel(e){this.config.level=e}getLevel(){return this.config.level}},ja=new aa;var ia=/\\{\\{\\s*([^}]+)\\s*\\}\\}/;var za=new RegExp(ia.source,"g");var Rr=class vr{constructor(e=!0,t=()=>Promise.resolve()){this.isHandlerEnabled=e,this.attachToken=t,R(this,"requestStartCallback",()=>null),R(this,"requestSuccessCallback",()=>null),R(this,"requestErrorCallback",()=>null),R(this,"requestFinishCallback",()=>null)}async request(e){let t=await this.requestHandler(e);try{let n=await this.transport(t);return this.successHandler(n)}catch(n){throw this.errorHandler(n),n}}enableHandler(){this.isHandlerEnabled=!0}disableHandler(){this.isHandlerEnabled=!1}disableHandlerWithTimeout(e=vr.DEFAULT_HANDLER_DISABLE_TIMEOUT){this.isHandlerEnabled=!1,setTimeout(()=>{this.isHandlerEnabled=!0},e)}setHttpRequestStartCallback(e){this.requestStartCallback=e}setHttpRequestSuccessCallback(e){this.requestSuccessCallback=e}setHttpRequestErrorCallback(e){this.requestErrorCallback=e}setHttpRequestFinishCallback(e){this.requestFinishCallback=e}all(e){return Promise.all(e)}spread(e){return t=>e(...t)}async requestHandler(e){if(await this.attachToken(e),e.shouldEncodeToFormData&&e.data){let t=new FormData;Object.keys(e.data).forEach(n=>t.append(n,e.data[n])),e.data=t}return e.startTimeInMs=Date.now(),this.isHandlerEnabled&&typeof this.requestStartCallback=="function"&&this.requestStartCallback(e),e}successHandler(e){return this.isHandlerEnabled&&(typeof this.requestSuccessCallback=="function"&&this.requestSuccessCallback(e),typeof this.requestFinishCallback=="function"&&this.requestFinishCallback()),e}errorHandler(e){this.isHandlerEnabled&&(typeof this.requestErrorCallback=="function"&&this.requestErrorCallback(e),typeof this.requestFinishCallback=="function"&&this.requestFinishCallback())}};R(Rr,"DEFAULT_HANDLER_DISABLE_TIMEOUT",1e3);var _r=Rr;var yt="init";var Ar="sign-out",xr="http-request",Cr="http-request-all",Or="request-custom-grant",Pr="revoke-access-token";var Ur="request-start",kr="request-success";var Nr="request-finish",Dr="get-oidc-service-endpoints",Mr="get-basic-user-info",Lr="get-decoded-id-token";var Hr="get-crypto-helper",Br="enable_http_handler",$r="disable_http_handler",Fr="get_auth_url",Kr="request_get_token",Wr="is_authenticated",jr="get_sign_out_url",zr="refresh_access-token",qr="refresh-access-token-error",Vr="set_session_state",Jr="start_auto_refresh_token",Gr="update_config",Xr="get_id_token",wt="check_session_signed_in",Et="check_session_signed_out",Yr="get_config_data";var St="rpIFrame",Tt="promptNoneIFrame";var bt="sign-in-silently";var It="initialized-silent-sign-in",Rt="promptNoneRequestSent";var ye="error",Oe="error_description",vt="custom_grant_config",_t="state";var At="Access token is invalid";var y=class{constructor(){}static generateSuccessMessage(e){return{blob:e?.data instanceof Blob?e?.data:null,data:JSON.stringify(e??""),success:!0}}static generateFailureMessage(e){e?.toJSON&&delete e.toJSON;let t;try{if(e instanceof Error)t=JSON.stringify({name:e.name,message:e.message,stack:e.stack,...e});else if(typeof e=="object"&&e!==null)try{t=JSON.stringify(e)}catch{t=JSON.stringify({message:e.toString?e.toString():"Unknown error",originalError:String(e)})}else t=JSON.stringify(e??"Unknown error")}catch{t=JSON.stringify({message:"Error serialization failed",originalError:String(e)})}return{error:t,success:!1}}};var Q=class Q{constructor(){}static removeAuthorizationCode(){let e=location.href;history.pushState({},document.title,e.replace(/\\?code=.*$/,""))}static getPKCE(e){return sessionStorage.getItem(e)??""}static setPKCE(e,t){sessionStorage.setItem(e,t)}static setSignOutURL(e,t,n){sessionStorage.setItem(`${N.SignOut.Storage.StorageKeys.SIGN_OUT_URL}-instance_${n}-${t}`,e)}static getSignOutUrl(e,t){return sessionStorage.getItem(`${N.SignOut.Storage.StorageKeys.SIGN_OUT_URL}-instance_${t}-${e}`)??""}static removePKCE(e){sessionStorage.removeItem(e)}static canContinueSignIn(e,t){return!(e&&!Q.hasErrorInURL()&&!Q.hasAuthSearchParamsInURL()&&!t)}static isInitializedSilentSignIn(){return Q.isSilentStatePresentInURL()}static wasSignInCalled(){return!!((Q.hasErrorInURL()||Q.hasAuthSearchParamsInURL())&&!this.isSilentStatePresentInURL())}static wasSilentSignInCalled(){let e=sessionStorage.getItem(It);return!!(e?JSON.parse(e):null)}static async isSignOutSuccessful(){if(ae.isSignOutSuccessful(window.location.href)){let e=window.location.href.split("?")[0];return history.pushState({},document.title,e),await ae.clearSession(),!0}return!1}static didSignOutFail(){if(ae.didSignOutFail(window.location.href)){let e=new URL(window.location.href),t=e.searchParams.get(ye),n=e.searchParams.get(Oe),o=window.location.href.split("?")[0];return history.pushState({},document.title,o),{description:n??"",error:t??""}}return!1}static isSilentStatePresentInURL(){return new URL(window.location.href).searchParams.get("state")?.includes(bt)??!1}static hasAuthSearchParamsInURL(e=window.location.search){return/[?&]code=[^&]+/.test(e)}static hasErrorInURL(e=window.location.href){let t=new URL(e);return!!t.searchParams.get(ye)&&t.searchParams.get(_t)!==N.Params.SIGN_OUT_SUCCESS}static canSendPromptNoneRequest(){let e=sessionStorage.getItem(Rt);return!(e?JSON.parse(e):null)}static setPromptNoneRequestSent(e){sessionStorage.setItem(Rt,JSON.stringify(e))}static async waitTillPageRedirect(e){let t=e??3e3;await new Promise(n=>setTimeout(n,t*1e3))}};w(Q,"until",(e,t=500)=>{let n=o=>e()?o():setTimeout(()=>n(o),t);return new Promise(n)});var ee=Q;var je=class{constructor(e,t){w(this,"_authenticationClient");w(this,"_storageManager");w(this,"_spaHelper");w(this,"_instanceId");w(this,"_isTokenRefreshing");this._authenticationClient=e,this._storageManager=this._authenticationClient.getStorageManager(),this._spaHelper=t,this._instanceId=this._authenticationClient.getInstanceId(),this._isTokenRefreshing=!1}enableHttpHandler(e){e?.enableHandler&&e.enableHandler()}disableHttpHandler(e){e?.disableHandler&&e.disableHandler()}initializeSessionManger(e,t,n,o,a){a.initialize(e.clientId,t.checkSessionIframe??"",n,e.checkSessionInterval??3,e.sessionRefreshInterval??300,e.afterSignInUrl,o)}async exchangeToken(e,t){let n=await this._storageManager.getConfigData(),o=!0,a=!1;if(e?.tokenEndpoint)if(o=!1,n.storage==="webWorker"){for(let i of[...n?.allowedExternalUrls??[],e.baseUrl])if(i&&e.tokenEndpoint?.startsWith(i)){a=!0;break}}else a=!0;return e.shouldReplayAfterRefresh&&this._storageManager.setTemporaryDataParameter(vt,JSON.stringify(e)),o||a?this._authenticationClient.exchangeToken(e).then(async i=>(t&&typeof t=="function"&&t(e),e.returnsSession?(this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser()):i)).catch(i=>Promise.reject(i)):Promise.reject(new E("SPA-MAIN_THREAD_CLIENT-RCG-IV01","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified token endpoint in this request cannot be found among the `allowedExternalUrls`"))}async getCustomGrantConfigData(){let e=await this._storageManager.getTemporaryDataParameter(vt);return e?JSON.parse(e):null}async refreshAccessToken(e){try{await this._authenticationClient.refreshAccessToken();let t=await this.getCustomGrantConfigData();return t&&await this.exchangeToken(t,e),this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser()}catch(t){let n={type:qr};return window.postMessage(n),Promise.reject(t)}}async retryFailedRequests(e){let t=e.httpClient,n=e.requestConfig,o=e.isHttpHandlerEnabled,a=e.httpErrorCallback,i=e.httpFinishCallback;await ee.until(()=>!this._isTokenRefreshing);try{let s=await t.request(n);return Promise.resolve(s)}catch(s){return o&&(typeof a=="function"&&await a(s),typeof i=="function"&&i()),Promise.reject(s)}}async httpRequest(e,t,n,o,a,i){let s=!1,l=await this._storageManager.getConfigData();if(l.storage==="webWorker"){for(let c of[...l?.allowedExternalUrls??[],l.baseUrl])if(c&&t?.url?.startsWith(c)){s=!0;break}}else s=!0;return s?e.request(t).then(c=>Promise.resolve(c)).catch(async c=>{if(c?.response?.status===401||!c?.response){if(this._isTokenRefreshing)return this.retryFailedRequests({enableRetrievingSignOutURLFromSession:i,httpClient:e,httpErrorCallback:o,httpFinishCallback:a,isHttpHandlerEnabled:n,requestConfig:t});this._isTokenRefreshing=!0;let d;try{d=await this.refreshAccessToken(i),this._isTokenRefreshing=!1}catch(u){throw this._isTokenRefreshing=!1,n&&(typeof o=="function"&&await o({...c,code:At}),typeof a=="function"&&a()),new E("SPA-AUTH_HELPER-HR-SE01",u?.name??"Refresh token request failed.",u?.message??"An error occurred while trying to refresh the access token following a 401 response from the server.")}if(d)try{let u=await e.request(t);return Promise.resolve(u)}catch(u){return n&&(typeof o=="function"&&await o(u),typeof a=="function"&&a()),Promise.reject(u)}}return n&&(typeof o=="function"&&await o(c),typeof a=="function"&&a()),Promise.reject(c)}):Promise.reject(new E("SPA-AUTH_HELPER-HR-IV02","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified endpoint in this request cannot be found among the `allowedExternalUrls`"))}async httpRequestAll(e,t,n,o,a){let i=!0,s=await this._storageManager.getConfigData();if(s.storage==="webWorker")for(let c of e){let d=!1;for(let u of[...s?.allowedExternalUrls??[],s.baseUrl])if(u&&c.url?.startsWith(u)){d=!0;break}if(!d){i=!1;break}}let l=[];if(i)return e.forEach(c=>{l.push(t.request(c))}),t?.all&&t.all(l).then(c=>Promise.resolve(c)).catch(async c=>{if(c?.response?.status===401||!c?.response){let d;try{d=await this._authenticationClient.refreshAccessToken()}catch(u){throw n&&(typeof o=="function"&&await o({...c,code:At}),typeof a=="function"&&a()),new E("SPA-AUTH_HELPER-HRA-SE01",u?.name??"Refresh token request failed.",u?.message??"An error occurred while trying to refresh the access token following a 401 response from the server.")}if(d)return t.all&&t.all(l).then(u=>Promise.resolve(u)).catch(async u=>(n&&(typeof o=="function"&&await o(u),typeof a=="function"&&a()),Promise.reject(u)))}return n&&(typeof o=="function"&&await o(c),typeof a=="function"&&a()),Promise.reject(c)});throw new E("SPA-AUTH_HELPER-HRA-IV02","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified endpoint in this request cannot be found among the `allowedExternalUrls`")}async requestAccessToken(e,t,n,o,a,i){let s=await this._storageManager.getConfigData();if(s.storage==="browserMemory"&&s.enablePKCE&&t){let l=ee.getPKCE(oe(t));await this._authenticationClient.setPKCECode(oe(t),l)}else s.storage==="webWorker"&&o&&await this._authenticationClient.setPKCECode(o,a??"");return e?this._authenticationClient.requestAccessToken(e,t??"",a??"",void 0,i).then(async()=>(s.storage!=="webWorker"?(ee.setSignOutURL(await this._authenticationClient.getSignOutUrl(),s.clientId,this._instanceId),this._spaHelper&&(this._spaHelper.clearRefreshTokenTimeout(),this._spaHelper.refreshAccessTokenAutomatically(this)),n&&typeof n=="function"&&s.syncSession&&n()):this._spaHelper&&this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser())).catch(l=>Promise.reject(l)):Promise.reject(new E("SPA-AUTH_HELPER-RAT1-NF01","No authorization code.","No authorization code was found."))}async signInSilently(e,t,n,o,a){if(ee.isInitializedSilentSignIn())return await n.receivePromptNoneResponse(),Promise.resolve({allowedScopes:"",displayName:"",email:"",sessionState:"",sub:"",tenantDomain:"",username:""});let s=document.getElementById(St)?.contentDocument?.getElementById(Tt);try{let l=await e(o);s.src=l}catch(l){return Promise.reject(l)}return new Promise((l,c)=>{let d=setTimeout(()=>{l(!1)},1e4),u=async p=>{let h=p.data;h?.type==Et&&(window.removeEventListener("message",u),clearTimeout(d),l(!1)),h?.type==wt&&h?.data?.code&&t(h?.data?.code,h?.data?.sessionState,h?.data?.state,a).then(g=>{window.removeEventListener("message",u),l(g)}).catch(g=>{window.removeEventListener("message",u),c(g)}).finally(()=>{clearTimeout(d)})};window.addEventListener("message",u)})}async handleSignIn(e,t,n){let o=await this._storageManager.getConfigData();if(await e())return Promise.resolve({allowedScopes:"",displayName:"",email:"",sessionState:"",sub:"",tenantDomain:"",username:""});if(o.storage!=="webWorker"&&await this._authenticationClient.isSignedIn())return this._spaHelper.clearRefreshTokenTimeout(),this._spaHelper.refreshAccessTokenAutomatically(this),o.syncSession&&t(),Promise.resolve(await this._authenticationClient.getUser());let a=new URL(window.location.href).searchParams.get(ye),i=new URL(window.location.href).searchParams.get(Oe);if(a){let s=new URL(window.location.href);throw s.searchParams.delete(ye),s.searchParams.delete(Oe),history.pushState(null,document.title,s.toString()),new E("SPA-AUTH_HELPER-SI-SE01",a,i??"")}if(o.storage==="webWorker"&&n){let s=await n();if(s)return s}return Promise.resolve(void 0)}async attachTokenToRequestConfig(e){let t={attachToken:!0,...e};t.attachToken&&(t.shouldAttachIDPAccessToken?e.headers={...e.headers,Authorization:`Bearer ${await this.getIDPAccessToken()}`}:e.headers={...e.headers,Authorization:`Bearer ${await this.getAccessToken()}`})}async getUser(){return this._authenticationClient.getUser()}async getDecodedIdToken(e){return this._authenticationClient.getDecodedIdToken(e)}async getDecodedIDPIDToken(){return this._authenticationClient.getDecodedIdToken()}async getCrypto(){return this._authenticationClient.getCrypto()}async getIdToken(){return this._authenticationClient.getIdToken()}async getOpenIDProviderEndpoints(){return this._authenticationClient.getOpenIDProviderEndpoints()}async getAccessToken(e){return this._authenticationClient.getAccessToken(e)}async getIDPAccessToken(){return(await this._storageManager.getSessionData())?.access_token}getStorageManager(){return this._storageManager}async isSignedIn(){return this._authenticationClient.isSignedIn()}};var ze=class{constructor(e){w(this,"_authenticationClient");w(this,"_storageManager");w(this,"_isTokenRefreshLoading",!1);this._authenticationClient=e,this._storageManager=this._authenticationClient.getStorageManager()}async refreshAccessTokenAutomatically(e){if(!((await this._storageManager.getConfigData())?.periodicTokenRefresh??!1))return;let n=await this._storageManager.getSessionData();if(n.refresh_token){if(n.created_at==null||n.expires_in==null)return;let o=1e4,a=Number(n.expires_in)*1e3,s=n.created_at+a-Date.now()-o;if(s<=0){if(this._isTokenRefreshLoading)return;this._isTokenRefreshLoading=!0;try{await e.refreshAccessToken()}finally{this._isTokenRefreshLoading=!1}return}let l=setTimeout(async()=>{if(!this._isTokenRefreshLoading){this._isTokenRefreshLoading=!0;try{await e.refreshAccessToken()}finally{this._isTokenRefreshLoading=!1}}},s);await this._storageManager.setTemporaryDataParameter(Ce.Storage.StorageKeys.REFRESH_TOKEN_TIMER,JSON.stringify(l))}}async getRefreshTimeoutTimer(){return await this._storageManager.getTemporaryDataParameter(Ce.Storage.StorageKeys.REFRESH_TOKEN_TIMER)?JSON.parse(await this._storageManager.getTemporaryDataParameter(Ce.Storage.StorageKeys.REFRESH_TOKEN_TIMER)):-1}async clearRefreshTokenTimeout(e){if(e){clearTimeout(e);return}let t=await this.getRefreshTimeoutTimer();t!==-1&&clearTimeout(t)}};var Ve=class Ve extends _r{static getInstance(e=0,t=!0,n=()=>Promise.resolve()){return this.instances.has(e)||this.instances.set(e,new Ve(t,n)),this.instances.get(e)}static destroyInstance(e=0){this.instances.delete(e)}async transport(e){let{attachToken:t,data:n,headers:o,method:a,params:i,shouldAttachIDPAccessToken:s,shouldEncodeToFormData:l,startTimeInMs:c,url:d,...u}=e,p=d??"";if(i){let _=new URLSearchParams(i).toString();_&&(p=`${p}${p.includes("?")?"&":"?"}${_}`)}let h={...o??{}},g;n!==void 0&&(n instanceof FormData?g=n:(g=JSON.stringify(n),!h["Content-Type"]&&!h["content-type"]&&(h["Content-Type"]="application/json")));let m;try{m=await fetch(p,{credentials:"include",...u,body:g,headers:h,method:(a??"GET").toUpperCase()})}catch(_){throw Object.assign(new Error(_.message),{code:"NETWORK_ERROR",config:e})}let b=(m.headers.get("content-type")??"").includes("application/json")?await m.json():await m.text(),S={};if(m.headers.forEach((_,x)=>{S[x]=_}),!m.ok)throw Object.assign(new Error(m.statusText),{config:e,response:{data:b,headers:S,status:m.status,statusText:m.statusText}});return{config:e,data:b,headers:S,status:m.status,statusText:m.statusText}}};w(Ve,"instances",new Map);var qe=Ve;var Je=class{constructor(){w(this,"_data");this._data=new Map}async setData(e,t){this._data.set(e,t)}async getData(e){return this._data?.get(e)??"{}"}async removeData(e){this._data.delete(e)}};var Mn=_e(Ke(),1);var zt=_e(tn(),1),Ln=_e(nn(),1);var Ee=new TextEncoder,J=new TextDecoder,ys=2**32;function on(...r){let e=r.reduce((o,{length:a})=>o+a,0),t=new Uint8Array(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function an(r){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(r);let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function te(r){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof r=="string"?r:J.decode(r),{alphabet:"base64url"});let e=r;e instanceof Uint8Array&&(e=J.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\\s/g,"");try{return an(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}var H=class extends Error{constructor(t,n){super(t,n);w(this,"code","ERR_JOSE_GENERIC");this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};w(H,"code","ERR_JOSE_GENERIC");var L=class extends H{constructor(t,n,o="unspecified",a="unspecified"){super(t,{cause:{claim:o,reason:a,payload:n}});w(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");w(this,"claim");w(this,"reason");w(this,"payload");this.claim=o,this.reason=a,this.payload=n}};w(L,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");var Se=class extends H{constructor(t,n,o="unspecified",a="unspecified"){super(t,{cause:{claim:o,reason:a,payload:n}});w(this,"code","ERR_JWT_EXPIRED");w(this,"claim");w(this,"reason");w(this,"payload");this.claim=o,this.reason=a,this.payload=n}};w(Se,"code","ERR_JWT_EXPIRED");var Pe=class extends H{constructor(){super(...arguments);w(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}};w(Pe,"code","ERR_JOSE_ALG_NOT_ALLOWED");var D=class extends H{constructor(){super(...arguments);w(this,"code","ERR_JOSE_NOT_SUPPORTED")}};w(D,"code","ERR_JOSE_NOT_SUPPORTED");var A=class extends H{constructor(){super(...arguments);w(this,"code","ERR_JWS_INVALID")}};w(A,"code","ERR_JWS_INVALID");var ie=class extends H{constructor(){super(...arguments);w(this,"code","ERR_JWT_INVALID")}};w(ie,"code","ERR_JWT_INVALID");var Te=class extends H{constructor(){super(...arguments);w(this,"code","ERR_JWKS_INVALID")}};w(Te,"code","ERR_JWKS_INVALID");var Ue=class extends H{constructor(t="no applicable key found in the JSON Web Key Set",n){super(t,n);w(this,"code","ERR_JWKS_NO_MATCHING_KEY")}};w(Ue,"code","ERR_JWKS_NO_MATCHING_KEY");var sn,cn,ke=class extends(cn=H,sn=Symbol.asyncIterator,cn){constructor(t="multiple matching keys found in the JSON Web Key Set",n){super(t,n);w(this,sn);w(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}};w(ke,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");var Ne=class extends H{constructor(t="signature verification failed",n){super(t,n);w(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}};w(Ne,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");function G(r,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${r}`)}function De(r,e){return r.name===e}function Ut(r){return parseInt(r.name.slice(4),10)}function ha(r){switch(r){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function ga(r,e){if(e&&!r.usages.includes(e))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${e}.`)}function ln(r,e,t){switch(e){case"HS256":case"HS384":case"HS512":{if(!De(r.algorithm,"HMAC"))throw G("HMAC");let n=parseInt(e.slice(2),10);if(Ut(r.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!De(r.algorithm,"RSASSA-PKCS1-v1_5"))throw G("RSASSA-PKCS1-v1_5");let n=parseInt(e.slice(2),10);if(Ut(r.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!De(r.algorithm,"RSA-PSS"))throw G("RSA-PSS");let n=parseInt(e.slice(2),10);if(Ut(r.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"Ed25519":case"EdDSA":{if(!De(r.algorithm,"Ed25519"))throw G("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!De(r.algorithm,"ECDSA"))throw G("ECDSA");let n=ha(e);if(r.algorithm.namedCurve!==n)throw G(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}ga(r,t)}function un(r,e,...t){if(t=t.filter(Boolean),t.length>2){let n=t.pop();r+=`one of type ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of type ${t[0]} or ${t[1]}.`:r+=`of type ${t[0]}.`;return e==null?r+=` Received ${e}`:typeof e=="function"&&e.name?r+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&e.constructor?.name&&(r+=` Received an instance of ${e.constructor.name}`),r}var dn=(r,...e)=>un("Key must be ",r,...e);function kt(r,e,...t){return un(`Key for the ${r} algorithm must be `,e,...t)}function Nt(r){return r?.[Symbol.toStringTag]==="CryptoKey"}function Dt(r){return r?.[Symbol.toStringTag]==="KeyObject"}var Mt=r=>Nt(r)||Dt(r);var fn=(...r)=>{let e=r.filter(Boolean);if(e.length===0||e.length===1)return!0;let t;for(let n of e){let o=Object.keys(n);if(!t||t.size===0){t=new Set(o);continue}for(let a of o){if(t.has(a))return!1;t.add(a)}}return!0};function ma(r){return typeof r=="object"&&r!==null}var K=r=>{if(!ma(r)||Object.prototype.toString.call(r)!=="[object Object]")return!1;if(Object.getPrototypeOf(r)===null)return!0;let e=r;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(r)===e};var pn=(r,e)=>{if(r.startsWith("RS")||r.startsWith("PS")){let{modulusLength:t}=e.algorithm;if(typeof t!="number"||t<2048)throw new TypeError(`${r} requires key modulusLength to be 2048 bits or larger`)}};function ya(r){let e,t;switch(r.kty){case"RSA":{switch(r.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${r.alg.slice(-3)}`},t=r.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${r.alg.slice(-3)}`},t=r.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(r.alg.slice(-3),10)||1}`},t=r.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new D(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}case"EC":{switch(r.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},t=r.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},t=r.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},t=r.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:r.crv},t=r.d?["deriveBits"]:[];break;default:throw new D(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}case"OKP":{switch(r.alg){case"Ed25519":case"EdDSA":e={name:"Ed25519"},t=r.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:r.crv},t=r.d?["deriveBits"]:[];break;default:throw new D(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}default:throw new D(\'Invalid or unsupported JWK "kty" (Key Type) Parameter value\')}return{algorithm:e,keyUsages:t}}var Ye=async r=>{if(!r.alg)throw new TypeError(\'"alg" argument is required when "jwk.alg" is not present\');let{algorithm:e,keyUsages:t}=ya(r),n={...r};return delete n.alg,delete n.use,crypto.subtle.importKey("jwk",n,e,r.ext??!r.d,r.key_ops??t)};async function hn(r,e,t){if(!K(r))throw new TypeError("JWK must be an object");let n;switch(e??(e=r.alg),n??(n=t?.extractable??r.ext),r.kty){case"oct":if(typeof r.k!="string"||!r.k)throw new TypeError(\'missing "k" (Key Value) Parameter value\');return te(r.k);case"RSA":if("oth"in r&&r.oth!==void 0)throw new D(\'RSA JWK "oth" (Other Primes Info) Parameter value is not supported\');case"EC":case"OKP":return Ye({...r,alg:e,ext:n});default:throw new D(\'Unsupported "kty" (Key Type) Parameter value\')}}var gn=(r,e,t,n,o)=>{if(o.crit!==void 0&&n?.crit===void 0)throw new r(\'"crit" (Critical) Header Parameter MUST be integrity protected\');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(i=>typeof i!="string"||i.length===0))throw new r(\'"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present\');let a;t!==void 0?a=new Map([...Object.entries(t),...e.entries()]):a=e;for(let i of n.crit){if(!a.has(i))throw new D(`Extension Header Parameter "${i}" is not recognized`);if(o[i]===void 0)throw new r(`Extension Header Parameter "${i}" is missing`);if(a.get(i)&&n[i]===void 0)throw new r(`Extension Header Parameter "${i}" MUST be integrity protected`)}return new Set(n.crit)};var mn=(r,e)=>{if(e!==void 0&&(!Array.isArray(e)||e.some(t=>typeof t!="string")))throw new TypeError(`"${r}" option must be an array of strings`);if(e)return new Set(e)};function Me(r){return K(r)&&typeof r.kty=="string"}function yn(r){return r.kty!=="oct"&&typeof r.d=="string"}function wn(r){return r.kty!=="oct"&&typeof r.d>"u"}function En(r){return r.kty==="oct"&&typeof r.k=="string"}var be,Sn=async(r,e,t,n=!1)=>{be||(be=new WeakMap);let o=be.get(r);if(o?.[t])return o[t];let a=await Ye({...e,alg:t});return n&&Object.freeze(r),o?o[t]=a:be.set(r,{[t]:a}),a},Ea=(r,e)=>{be||(be=new WeakMap);let t=be.get(r);if(t?.[e])return t[e];let n=r.type==="public",o=!!n,a;if(r.asymmetricKeyType==="x25519"){switch(e){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}a=r.toCryptoKey(r.asymmetricKeyType,o,n?[]:["deriveBits"])}if(r.asymmetricKeyType==="ed25519"){if(e!=="EdDSA"&&e!=="Ed25519")throw new TypeError("given KeyObject instance cannot be used for this algorithm");a=r.toCryptoKey(r.asymmetricKeyType,o,[n?"verify":"sign"])}if(r.asymmetricKeyType==="rsa"){let i;switch(e){case"RSA-OAEP":i="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":i="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":i="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":i="SHA-512";break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}if(e.startsWith("RSA-OAEP"))return r.toCryptoKey({name:"RSA-OAEP",hash:i},o,n?["encrypt"]:["decrypt"]);a=r.toCryptoKey({name:e.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:i},o,[n?"verify":"sign"])}if(r.asymmetricKeyType==="ec"){let s=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(r.asymmetricKeyDetails?.namedCurve);if(!s)throw new TypeError("given KeyObject instance cannot be used for this algorithm");e==="ES256"&&s==="P-256"&&(a=r.toCryptoKey({name:"ECDSA",namedCurve:s},o,[n?"verify":"sign"])),e==="ES384"&&s==="P-384"&&(a=r.toCryptoKey({name:"ECDSA",namedCurve:s},o,[n?"verify":"sign"])),e==="ES512"&&s==="P-521"&&(a=r.toCryptoKey({name:"ECDSA",namedCurve:s},o,[n?"verify":"sign"])),e.startsWith("ECDH-ES")&&(a=r.toCryptoKey({name:"ECDH",namedCurve:s},o,n?[]:["deriveBits"]))}if(!a)throw new TypeError("given KeyObject instance cannot be used for this algorithm");return t?t[e]=a:be.set(r,{[e]:a}),a},Tn=async(r,e)=>{if(r instanceof Uint8Array||Nt(r))return r;if(Dt(r)){if(r.type==="secret")return r.export();if("toCryptoKey"in r&&typeof r.toCryptoKey=="function")try{return Ea(r,e)}catch(n){if(n instanceof TypeError)throw n}let t=r.export({format:"jwk"});return Sn(r,t,e)}if(Me(r))return r.k?te(r.k):Sn(r,r,e,!0);throw new Error("unreachable")};var Ie=r=>r?.[Symbol.toStringTag],Lt=(r,e,t)=>{if(e.use!==void 0){let n;switch(t){case"sign":case"verify":n="sig";break;case"encrypt":case"decrypt":n="enc";break}if(e.use!==n)throw new TypeError(`Invalid key for this operation, its "use" must be "${n}" when present`)}if(e.alg!==void 0&&e.alg!==r)throw new TypeError(`Invalid key for this operation, its "alg" must be "${r}" when present`);if(Array.isArray(e.key_ops)){let n;switch(!0){case(t==="sign"||t==="verify"):case r==="dir":case r.includes("CBC-HS"):n=t;break;case r.startsWith("PBES2"):n="deriveBits";break;case/^A\\d{3}(?:GCM)?(?:KW)?$/.test(r):!r.includes("GCM")&&r.endsWith("KW")?n=t==="encrypt"?"wrapKey":"unwrapKey":n=t;break;case(t==="encrypt"&&r.startsWith("RSA")):n="wrapKey";break;case t==="decrypt":n=r.startsWith("RSA")?"unwrapKey":"deriveBits";break}if(n&&e.key_ops?.includes?.(n)===!1)throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${n}" when present`)}return!0},Sa=(r,e,t)=>{if(!(e instanceof Uint8Array)){if(Me(e)){if(En(e)&&Lt(r,e,t))return;throw new TypeError(\'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present\')}if(!Mt(e))throw new TypeError(kt(r,e,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(e.type!=="secret")throw new TypeError(`${Ie(e)} instances for symmetric algorithms must be of type "secret"`)}},Ta=(r,e,t)=>{if(Me(e))switch(t){case"decrypt":case"sign":if(yn(e)&&Lt(r,e,t))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"encrypt":case"verify":if(wn(e)&&Lt(r,e,t))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!Mt(e))throw new TypeError(kt(r,e,"CryptoKey","KeyObject","JSON Web Key"));if(e.type==="secret")throw new TypeError(`${Ie(e)} instances for asymmetric algorithms must not be of type "secret"`);if(e.type==="public")switch(t){case"sign":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm decryption must be of type "private"`);default:break}if(e.type==="private")switch(t){case"verify":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm encryption must be of type "public"`);default:break}},bn=(r,e,t)=>{r.startsWith("HS")||r==="dir"||r.startsWith("PBES2")||/^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(r)||/^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(r)?Sa(r,e,t):Ta(r,e,t)};var In=(r,e)=>{let t=`SHA-${r.slice(-3)}`;switch(r){case"HS256":case"HS384":case"HS512":return{hash:t,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:t,name:"RSA-PSS",saltLength:parseInt(r.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:t,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:t,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};default:throw new D(`alg ${r} is not supported either by JOSE or your javascript runtime`)}};var Rn=async(r,e,t)=>{if(e instanceof Uint8Array){if(!r.startsWith("HS"))throw new TypeError(dn(e,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",e,{hash:`SHA-${r.slice(-3)}`,name:"HMAC"},!1,[t])}return ln(e,r,t),e};var vn=async(r,e,t,n)=>{let o=await Rn(r,e,"verify");pn(r,o);let a=In(r,o.algorithm);try{return await crypto.subtle.verify(a,o,t,n)}catch{return!1}};async function _n(r,e,t){if(!K(r))throw new A("Flattened JWS must be an object");if(r.protected===void 0&&r.header===void 0)throw new A(\'Flattened JWS must have either of the "protected" or "header" members\');if(r.protected!==void 0&&typeof r.protected!="string")throw new A("JWS Protected Header incorrect type");if(r.payload===void 0)throw new A("JWS Payload missing");if(typeof r.signature!="string")throw new A("JWS Signature missing or incorrect type");if(r.header!==void 0&&!K(r.header))throw new A("JWS Unprotected Header incorrect type");let n={};if(r.protected)try{let T=te(r.protected);n=JSON.parse(J.decode(T))}catch{throw new A("JWS Protected Header is invalid")}if(!fn(n,r.header))throw new A("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let o={...n,...r.header},a=gn(A,new Map([["b64",!0]]),t?.crit,n,o),i=!0;if(a.has("b64")&&(i=n.b64,typeof i!="boolean"))throw new A(\'The "b64" (base64url-encode payload) Header Parameter must be a boolean\');let{alg:s}=o;if(typeof s!="string"||!s)throw new A(\'JWS "alg" (Algorithm) Header Parameter missing or invalid\');let l=t&&mn("algorithms",t.algorithms);if(l&&!l.has(s))throw new Pe(\'"alg" (Algorithm) Header Parameter value not allowed\');if(i){if(typeof r.payload!="string")throw new A("JWS Payload must be a string")}else if(typeof r.payload!="string"&&!(r.payload instanceof Uint8Array))throw new A("JWS Payload must be a string or an Uint8Array instance");let c=!1;typeof e=="function"&&(e=await e(n,r),c=!0),bn(s,e,"verify");let d=on(Ee.encode(r.protected??""),Ee.encode("."),typeof r.payload=="string"?Ee.encode(r.payload):r.payload),u;try{u=te(r.signature)}catch{throw new A("Failed to base64url decode the signature")}let p=await Tn(e,s);if(!await vn(s,p,u,d))throw new Ne;let g;if(i)try{g=te(r.payload)}catch{throw new A("Failed to base64url decode the payload")}else typeof r.payload=="string"?g=Ee.encode(r.payload):g=r.payload;let m={payload:g};return r.protected!==void 0&&(m.protectedHeader=n),r.header!==void 0&&(m.unprotectedHeader=r.header),c?{...m,key:p}:m}async function An(r,e,t){if(r instanceof Uint8Array&&(r=J.decode(r)),typeof r!="string")throw new A("Compact JWS must be a string or Uint8Array");let{0:n,1:o,2:a,length:i}=r.split(".");if(i!==3)throw new A("Invalid Compact JWS");let s=await _n({payload:o,protected:n,signature:a},e,t),l={payload:s.payload,protectedHeader:s.protectedHeader};return typeof e=="function"?{...l,key:s.key}:l}var xn=r=>Math.floor(r.getTime()/1e3);var ba=/^(\\+|\\-)? ?(\\d+|\\d+\\.\\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Ht=r=>{let e=ba.exec(r);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");let t=parseFloat(e[2]),n=e[3].toLowerCase(),o;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(t);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(t*60);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(t*3600);break;case"day":case"days":case"d":o=Math.round(t*86400);break;case"week":case"weeks":case"w":o=Math.round(t*604800);break;default:o=Math.round(t*31557600);break}return e[1]==="-"||e[4]==="ago"?-o:o};var Cn=r=>r.includes("/")?r.toLowerCase():`application/${r.toLowerCase()}`,Ia=(r,e)=>typeof r=="string"?e.includes(r):Array.isArray(r)?e.some(Set.prototype.has.bind(new Set(r))):!1;function On(r,e,t={}){let n;try{n=JSON.parse(J.decode(e))}catch{}if(!K(n))throw new ie("JWT Claims Set must be a top-level JSON object");let{typ:o}=t;if(o&&(typeof r.typ!="string"||Cn(r.typ)!==Cn(o)))throw new L(\'unexpected "typ" JWT header value\',n,"typ","check_failed");let{requiredClaims:a=[],issuer:i,subject:s,audience:l,maxTokenAge:c}=t,d=[...a];c!==void 0&&d.push("iat"),l!==void 0&&d.push("aud"),s!==void 0&&d.push("sub"),i!==void 0&&d.push("iss");for(let g of new Set(d.reverse()))if(!(g in n))throw new L(`missing required "${g}" claim`,n,g,"missing");if(i&&!(Array.isArray(i)?i:[i]).includes(n.iss))throw new L(\'unexpected "iss" claim value\',n,"iss","check_failed");if(s&&n.sub!==s)throw new L(\'unexpected "sub" claim value\',n,"sub","check_failed");if(l&&!Ia(n.aud,typeof l=="string"?[l]:l))throw new L(\'unexpected "aud" claim value\',n,"aud","check_failed");let u;switch(typeof t.clockTolerance){case"string":u=Ht(t.clockTolerance);break;case"number":u=t.clockTolerance;break;case"undefined":u=0;break;default:throw new TypeError("Invalid clockTolerance option type")}let{currentDate:p}=t,h=xn(p||new Date);if((n.iat!==void 0||c)&&typeof n.iat!="number")throw new L(\'"iat" claim must be a number\',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!="number")throw new L(\'"nbf" claim must be a number\',n,"nbf","invalid");if(n.nbf>h+u)throw new L(\'"nbf" claim timestamp check failed\',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!="number")throw new L(\'"exp" claim must be a number\',n,"exp","invalid");if(n.exp<=h-u)throw new Se(\'"exp" claim timestamp check failed\',n,"exp","check_failed")}if(c){let g=h-n.iat,m=typeof c=="number"?c:Ht(c);if(g-u>m)throw new Se(\'"iat" claim timestamp check failed (too far in the past)\',n,"iat","check_failed");if(g<0-u)throw new L(\'"iat" claim timestamp check failed (it should be in the past)\',n,"iat","check_failed")}return n}async function Bt(r,e,t){let n=await An(r,e,t);if(n.protectedHeader.crit?.includes("b64")&&n.protectedHeader.b64===!1)throw new ie("JWTs MUST NOT use unencoded payload");let a={payload:On(n.protectedHeader,n.payload,t),protectedHeader:n.protectedHeader};return typeof e=="function"?{...a,key:n.key}:a}function Ra(r){switch(typeof r=="string"&&r.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new D(\'Unsupported "alg" value for a JSON Web Key Set\')}}function va(r){return r&&typeof r=="object"&&Array.isArray(r.keys)&&r.keys.every(_a)}function _a(r){return K(r)}var Re,Le,$t=class{constructor(e){He(this,Re);He(this,Le,new WeakMap);if(!va(e))throw new Te("JSON Web Key Set malformed");nt(this,Re,structuredClone(e))}jwks(){return ue(this,Re)}async getKey(e,t){let{alg:n,kid:o}={...e,...t?.header},a=Ra(n),i=ue(this,Re).keys.filter(c=>{let d=a===c.kty;if(d&&typeof o=="string"&&(d=o===c.kid),d&&typeof c.alg=="string"&&(d=n===c.alg),d&&typeof c.use=="string"&&(d=c.use==="sig"),d&&Array.isArray(c.key_ops)&&(d=c.key_ops.includes("verify")),d)switch(n){case"ES256":d=c.crv==="P-256";break;case"ES384":d=c.crv==="P-384";break;case"ES512":d=c.crv==="P-521";break;case"Ed25519":case"EdDSA":d=c.crv==="Ed25519";break}return d}),{0:s,length:l}=i;if(l===0)throw new Ue;if(l!==1){let c=new ke,d=ue(this,Le);throw c[Symbol.asyncIterator]=async function*(){for(let u of i)try{yield await Pn(d,u,n)}catch{}},c}return Pn(ue(this,Le),s,n)}};Re=new WeakMap,Le=new WeakMap;async function Pn(r,e,t){let n=r.get(e)||r.set(e,{}).get(e);if(n[t]===void 0){let o=await hn({...e,ext:!0},t);if(o instanceof Uint8Array||o.type!=="public")throw new Te("JSON Web Key Set members must be public keys");n[t]=o}return n[t]}function Ft(r){let e=new $t(r),t=async(n,o)=>e.getKey(n,o);return Object.defineProperties(t,{jwks:{value:()=>structuredClone(e.jwks()),enumerable:!1,configurable:!1,writable:!1}}),t}var Hn=_e(Dn(),1),et=class{base64URLEncode(e){return zt.default.encode(e).replace(/\\+/g,"-").replace(/\\//g,"_").replace(/=/g,"")}base64URLDecode(e){return zt.default.decode(e).toString()}hashSha256(e){return Mn.Buffer.from((0,Ln.default)(new TextEncoder().encode(e)))}generateRandomBytes(e){return(0,Hn.default)(e)}verifyJwt(e,t,n,o,a,i,s,l){let c={algorithms:n,audience:[o],clockTolerance:s,subject:i};return(l??!0)&&(c.issuer=a),Bt(e,Ft({keys:[t]}),c).then(()=>Promise.resolve(!0)).catch(d=>Promise.reject(new E("SPA-CRYPTO-UTILS-VJ-IV01",d?.reason??JSON.stringify(d),`${d?.code} ${d?.claim}`)))}};var Bn=async(r,e,t)=>{let n=new Je,o=new et,a=new ae;await a.initialize(e,n,o,r);let i=new ze(a),s=t(a,i),l=a.getStorageManager(),c=async I=>{await s.attachTokenToRequestConfig(I)},d=qe.getInstance(r,!0,c);return{disableHttpHandler:()=>{s.disableHttpHandler(d)},enableHttpHandler:()=>{s.enableHttpHandler(d)},getAccessToken:()=>s.getAccessToken(),getSignInUrl:async I=>a.getSignInUrl(I).then(async X=>{let tt=new URL(X).searchParams.get(N.Params.STATE)??"",Kn=await a.getPKCECode(tt);return{authorizationURL:X,pkce:Kn}}).catch(X=>Promise.reject(X)),getUser:async()=>s.getUser(),getConfigData:async()=>l.getConfigData(),getCrypto:async()=>s.getCrypto(),getDecodedIDPIDToken:async()=>s.getDecodedIDPIDToken(),getDecodedIdToken:async I=>s.getDecodedIdToken(I),getIdToken:async()=>s.getIdToken(),getOpenIDProviderEndpoints:async()=>s.getOpenIDProviderEndpoints(),getSignOutUrl:async()=>await a.getSignOutUrl(),httpRequest:async I=>await s.httpRequest(d,I),httpRequestAll:async I=>await s.httpRequestAll(I,d),isSignedIn:()=>s.isSignedIn(),refreshAccessToken:async()=>{try{return await s.refreshAccessToken()}catch(I){return Promise.reject(I)}},requestAccessToken:async(I,X,qt,tt)=>await s.requestAccessToken(I,X,void 0,qt,tt),exchangeToken:async I=>await s.exchangeToken(I),revokeAccessToken:async()=>{let I=await i.getRefreshTimeoutTimer();return a.revokeAccessToken().then(()=>(i.clearRefreshTokenTimeout(I),Promise.resolve(!0))).catch(X=>Promise.reject(X))},setHttpRequestFinishCallback:I=>{d?.setHttpRequestFinishCallback&&d.setHttpRequestFinishCallback(I)},setHttpRequestStartCallback:I=>{d?.setHttpRequestStartCallback&&d.setHttpRequestStartCallback(I)},setHttpRequestSuccessCallback:I=>{d?.setHttpRequestSuccessCallback&&d.setHttpRequestSuccessCallback(I)},setSessionState:async I=>{await l.setSessionDataParameter(N.Params.SESSION_STATE,I)},signOut:async()=>(i.clearRefreshTokenTimeout(),await a.getSignOutUrl()),startAutoRefreshToken:async()=>{i.clearRefreshTokenTimeout(),i.refreshAccessTokenAutomatically(s)},reInitialize:async I=>{await a.reInitialize(I)}}};var $n=r=>{let e=self,t;e.onmessage=async({data:i,ports:s})=>{let l=s[0];if(i.type!==yt&&!t){l.postMessage(y.generateFailureMessage(new E("SPA-CLIENT_WORKER-ONMSG-NF01","The web worker has not been initialized yet.","The initialize method needs to be called before the specified operation can be carried out.")));return}switch(i.type){case yt:try{let c=i.instanceId??0,d={...i.data};t=await Bn(c,d,r),t.setHttpRequestFinishCallback(a),t.setHttpRequestStartCallback(n),t.setHttpRequestSuccessCallback(o),l.postMessage(y.generateSuccessMessage())}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Fr:t.getSignInUrl(i?.data).then(c=>{l.postMessage(y.generateSuccessMessage(c))}).catch(c=>{l.postMessage(y.generateFailureMessage(c))});break;case Kr:t.requestAccessToken(i?.data?.code,i?.data?.sessionState,i?.data?.pkce,i?.data?.state).then(c=>{l.postMessage(y.generateSuccessMessage(c))}).catch(c=>{l.postMessage(y.generateFailureMessage(c))});break;case xr:{let c=i.data,d=c?.data;if(i.data?.data?.formData===!0){let u=new FormData;for(let p in d)p!=="formData"&&u.append(p,d[p]);c.data=u}t.httpRequest(c).then(u=>{l.postMessage(y.generateSuccessMessage(u))}).catch(u=>{l.postMessage(y.generateFailureMessage(u))});break}case Cr:t.httpRequestAll(i.data).then(c=>{l.postMessage(y.generateSuccessMessage(c))}).catch(c=>{l.postMessage(y.generateFailureMessage(c))});break;case Ar:try{l.postMessage(y.generateSuccessMessage(await t.signOut()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Or:t.exchangeToken(i.data).then(c=>{l.postMessage(y.generateSuccessMessage(c))}).catch(c=>{l.postMessage(y.generateFailureMessage(c))});break;case Pr:t.revokeAccessToken().then(c=>{l.postMessage(y.generateSuccessMessage(c))}).catch(c=>{l.postMessage(y.generateFailureMessage(c))});break;case Dr:try{l.postMessage(y.generateSuccessMessage(await t.getOpenIDProviderEndpoints()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Mr:try{l.postMessage(y.generateSuccessMessage(await t.getUser()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Lr:try{l.postMessage(y.generateSuccessMessage(await t.getDecodedIdToken()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Hr:try{l.postMessage(y.generateSuccessMessage(await t.getCrypto()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Xr:try{l.postMessage(y.generateSuccessMessage(await t.getIdToken()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Br:t.enableHttpHandler(),l.postMessage(y.generateSuccessMessage());break;case $r:t.disableHttpHandler(),l.postMessage(y.generateSuccessMessage());break;case Wr:try{l.postMessage(y.generateSuccessMessage(await t.isSignedIn()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case jr:try{l.postMessage(y.generateSuccessMessage(await t.getSignOutUrl()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case zr:try{l.postMessage(y.generateSuccessMessage(await t.refreshAccessToken()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Jr:try{l.postMessage(y.generateSuccessMessage(t.startAutoRefreshToken()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Vr:try{l.postMessage(y.generateSuccessMessage(await t.setSessionState(i?.data)))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Gr:try{l.postMessage(y.generateSuccessMessage(await t.reInitialize(i?.data)))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Yr:try{l.postMessage(y.generateSuccessMessage(await t.getConfigData()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;default:l?.postMessage(y.generateFailureMessage(new E("SPA-CLIENT_WORKER-ONMSG-IV02","The message type is invalid.",`The message type provided, ${i.type}, is invalid.`)))}};let n=()=>{e.postMessage({type:Ur})},o=i=>{e.postMessage({data:JSON.stringify(i??""),type:kr})},a=()=>{e.postMessage({type:Nr})}};typeof self<"u"&&!self.Buffer&&(self.Buffer=Fn.Buffer);typeof self<"u"&&(self.global||(self.global=self));$n((r,e)=>new je(r,e));var Tl={};})();\n/*! Bundled license information:\n\nieee754/index.js:\n (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)\n\nbuffer/index.js:\n (*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh <https://feross.org>\n * @license MIT\n *)\n\nsafe-buffer/index.js:\n (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)\n*/\n');
|
|
1956
|
+
return inlineWorker('(()=>{var Vn=Object.create;var Be=Object.defineProperty;var Gn=Object.getOwnPropertyDescriptor;var Xn=Object.getOwnPropertyNames;var Yn=Object.getPrototypeOf,Zn=Object.prototype.hasOwnProperty;var Vt=r=>{throw TypeError(r)};var Qn=(r,e,t)=>e in r?Be(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var q=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),eo=(r,e)=>{for(var t in e)Be(r,t,{get:e[t],enumerable:!0})},to=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Xn(e))!Zn.call(r,o)&&o!==t&&Be(r,o,{get:()=>e[o],enumerable:!(n=Gn(e,o))||n.enumerable});return r};var _e=(r,e,t)=>(t=r!=null?Vn(Yn(r)):{},to(e||!r||!r.__esModule?Be(t,"default",{value:r,enumerable:!0}):t,r));var w=(r,e,t)=>Qn(r,typeof e!="symbol"?e+"":e,t),Gt=(r,e,t)=>e.has(r)||Vt("Cannot "+t);var ue=(r,e,t)=>(Gt(r,e,"read from private field"),t?t.call(r):e.get(r)),He=(r,e,t)=>e.has(r)?Vt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ot=(r,e,t,n)=>(Gt(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var Zt=q($e=>{"use strict";$e.byteLength=no;$e.toByteArray=ao;$e.fromByteArray=co;var W=[],H=[],ro=typeof Uint8Array<"u"?Uint8Array:Array,at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(re=0,Xt=at.length;re<Xt;++re)W[re]=at[re],H[at.charCodeAt(re)]=re;var re,Xt;H[45]=62;H[95]=63;function Yt(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function no(r){var e=Yt(r),t=e[0],n=e[1];return(t+n)*3/4-n}function oo(r,e,t){return(e+t)*3/4-t}function ao(r){var e,t=Yt(r),n=t[0],o=t[1],a=new ro(oo(r,n,o)),i=0,s=o>0?n-4:n,l;for(l=0;l<s;l+=4)e=H[r.charCodeAt(l)]<<18|H[r.charCodeAt(l+1)]<<12|H[r.charCodeAt(l+2)]<<6|H[r.charCodeAt(l+3)],a[i++]=e>>16&255,a[i++]=e>>8&255,a[i++]=e&255;return o===2&&(e=H[r.charCodeAt(l)]<<2|H[r.charCodeAt(l+1)]>>4,a[i++]=e&255),o===1&&(e=H[r.charCodeAt(l)]<<10|H[r.charCodeAt(l+1)]<<4|H[r.charCodeAt(l+2)]>>2,a[i++]=e>>8&255,a[i++]=e&255),a}function io(r){return W[r>>18&63]+W[r>>12&63]+W[r>>6&63]+W[r&63]}function so(r,e,t){for(var n,o=[],a=e;a<t;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(r[a+2]&255),o.push(io(n));return o.join("")}function co(r){for(var e,t=r.length,n=t%3,o=[],a=16383,i=0,s=t-n;i<s;i+=a)o.push(so(r,i,i+a>s?s:i+a));return n===1?(e=r[t-1],o.push(W[e>>2]+W[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],o.push(W[e>>10]+W[e>>4&63]+W[e<<2&63]+"=")),o.join("")}});var Qt=q(it=>{it.read=function(r,e,t,n,o){var a,i,s=o*8-n-1,l=(1<<s)-1,c=l>>1,d=-7,u=t?o-1:0,p=t?-1:1,h=r[e+u];for(u+=p,a=h&(1<<-d)-1,h>>=-d,d+=s;d>0;a=a*256+r[e+u],u+=p,d-=8);for(i=a&(1<<-d)-1,a>>=-d,d+=n;d>0;i=i*256+r[e+u],u+=p,d-=8);if(a===0)a=1-c;else{if(a===l)return i?NaN:(h?-1:1)*(1/0);i=i+Math.pow(2,n),a=a-c}return(h?-1:1)*i*Math.pow(2,a-n)};it.write=function(r,e,t,n,o,a){var i,s,l,c=a*8-o-1,d=(1<<c)-1,u=d>>1,p=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,g=n?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,i=d):(i=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-i))<1&&(i--,l*=2),i+u>=1?e+=p/l:e+=p*Math.pow(2,1-u),e*l>=2&&(i++,l/=2),i+u>=d?(s=0,i=d):i+u>=1?(s=(e*l-1)*Math.pow(2,o),i=i+u):(s=e*Math.pow(2,u-1)*Math.pow(2,o),i=0));o>=8;r[t+h]=s&255,h+=g,s/=256,o-=8);for(i=i<<o|s,c+=o;c>0;r[t+h]=i&255,h+=g,i/=256,c-=8);r[t+h-g]|=m*128}});var We=q(he=>{"use strict";var st=Zt(),fe=Qt(),er=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;he.Buffer=f;he.SlowBuffer=go;he.INSPECT_MAX_BYTES=50;var Fe=2147483647;he.kMaxLength=Fe;f.TYPED_ARRAY_SUPPORT=lo();!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function lo(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}});Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function J(r){if(r>Fe)throw new RangeError(\'The value "\'+r+\'" is invalid for option "size"\');let e=new Uint8Array(r);return Object.setPrototypeOf(e,f.prototype),e}function f(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError(\'The "string" argument must be of type string. Received type number\');return dt(r)}return or(r,e,t)}f.poolSize=8192;function or(r,e,t){if(typeof r=="string")return fo(r,e);if(ArrayBuffer.isView(r))return po(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(j(r,ArrayBuffer)||r&&j(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(j(r,SharedArrayBuffer)||r&&j(r.buffer,SharedArrayBuffer)))return lt(r,e,t);if(typeof r=="number")throw new TypeError(\'The "value" argument must not be of type number. Received type number\');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return f.from(n,e,t);let o=ho(r);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return f.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}f.from=function(r,e,t){return or(r,e,t)};Object.setPrototypeOf(f.prototype,Uint8Array.prototype);Object.setPrototypeOf(f,Uint8Array);function ar(r){if(typeof r!="number")throw new TypeError(\'"size" argument must be of type number\');if(r<0)throw new RangeError(\'The value "\'+r+\'" is invalid for option "size"\')}function uo(r,e,t){return ar(r),r<=0?J(r):e!==void 0?typeof t=="string"?J(r).fill(e,t):J(r).fill(e):J(r)}f.alloc=function(r,e,t){return uo(r,e,t)};function dt(r){return ar(r),J(r<0?0:ft(r)|0)}f.allocUnsafe=function(r){return dt(r)};f.allocUnsafeSlow=function(r){return dt(r)};function fo(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=ir(r,e)|0,n=J(t),o=n.write(r,e);return o!==t&&(n=n.slice(0,o)),n}function ct(r){let e=r.length<0?0:ft(r.length)|0,t=J(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function po(r){if(j(r,Uint8Array)){let e=new Uint8Array(r);return lt(e.buffer,e.byteOffset,e.byteLength)}return ct(r)}function lt(r,e,t){if(e<0||r.byteLength<e)throw new RangeError(\'"offset" is outside of buffer bounds\');if(r.byteLength<e+(t||0))throw new RangeError(\'"length" is outside of buffer bounds\');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,f.prototype),n}function ho(r){if(f.isBuffer(r)){let e=ft(r.length)|0,t=J(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||ht(r.length)?J(0):ct(r);if(r.type==="Buffer"&&Array.isArray(r.data))return ct(r.data)}function ft(r){if(r>=Fe)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Fe.toString(16)+" bytes");return r|0}function go(r){return+r!=r&&(r=0),f.alloc(+r)}f.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==f.prototype};f.compare=function(e,t){if(j(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),j(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(e)||!f.isBuffer(t))throw new TypeError(\'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array\');if(e===t)return 0;let n=e.length,o=t.length;for(let a=0,i=Math.min(n,o);a<i;++a)if(e[a]!==t[a]){n=e[a],o=t[a];break}return n<o?-1:o<n?1:0};f.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};f.concat=function(e,t){if(!Array.isArray(e))throw new TypeError(\'"list" argument must be an Array of Buffers\');if(e.length===0)return f.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let o=f.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){let i=e[n];if(j(i,Uint8Array))a+i.length>o.length?(f.isBuffer(i)||(i=f.from(i)),i.copy(o,a)):Uint8Array.prototype.set.call(o,i,a);else if(f.isBuffer(i))i.copy(o,a);else throw new TypeError(\'"list" argument must be an Array of Buffers\');a+=i.length}return o};function ir(r,e){if(f.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||j(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError(\'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type \'+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return ut(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return gr(r).length;default:if(o)return n?-1:ut(r).length;e=(""+e).toLowerCase(),o=!0}}f.byteLength=ir;function mo(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return _o(this,e,t);case"utf8":case"utf-8":return cr(this,e,t);case"ascii":return Ro(this,e,t);case"latin1":case"binary":return vo(this,e,t);case"base64":return bo(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xo(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}f.prototype._isBuffer=!0;function ne(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}f.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)ne(this,t,t+1);return this};f.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)ne(this,t,t+3),ne(this,t+1,t+2);return this};f.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)ne(this,t,t+7),ne(this,t+1,t+6),ne(this,t+2,t+5),ne(this,t+3,t+4);return this};f.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?cr(this,0,e):mo.apply(this,arguments)};f.prototype.toLocaleString=f.prototype.toString;f.prototype.equals=function(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:f.compare(this,e)===0};f.prototype.inspect=function(){let e="",t=he.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};er&&(f.prototype[er]=f.prototype.inspect);f.prototype.compare=function(e,t,n,o,a){if(j(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(e))throw new TypeError(\'The "target" argument must be one of type Buffer or Uint8Array. Received type \'+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),a===void 0&&(a=this.length),t<0||n>e.length||o<0||a>this.length)throw new RangeError("out of range index");if(o>=a&&t>=n)return 0;if(o>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,o>>>=0,a>>>=0,this===e)return 0;let i=a-o,s=n-t,l=Math.min(i,s),c=this.slice(o,a),d=e.slice(t,n);for(let u=0;u<l;++u)if(c[u]!==d[u]){i=c[u],s=d[u];break}return i<s?-1:s<i?1:0};function sr(r,e,t,n,o){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,ht(t)&&(t=o?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(o)return-1;t=r.length-1}else if(t<0)if(o)t=0;else return-1;if(typeof e=="string"&&(e=f.from(e,n)),f.isBuffer(e))return e.length===0?-1:tr(r,e,t,n,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):tr(r,[e],t,n,o);throw new TypeError("val must be string, number or Buffer")}function tr(r,e,t,n,o){let a=1,i=r.length,s=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;a=2,i/=2,s/=2,t/=2}function l(d,u){return a===1?d[u]:d.readUInt16BE(u*a)}let c;if(o){let d=-1;for(c=t;c<i;c++)if(l(r,c)===l(e,d===-1?0:c-d)){if(d===-1&&(d=c),c-d+1===s)return d*a}else d!==-1&&(c-=c-d),d=-1}else for(t+s>i&&(t=i-s),c=t;c>=0;c--){let d=!0;for(let u=0;u<s;u++)if(l(r,c+u)!==l(e,u)){d=!1;break}if(d)return c}return-1}f.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};f.prototype.indexOf=function(e,t,n){return sr(this,e,t,n,!0)};f.prototype.lastIndexOf=function(e,t,n){return sr(this,e,t,n,!1)};function yo(r,e,t,n){t=Number(t)||0;let o=r.length-t;n?(n=Number(n),n>o&&(n=o)):n=o;let a=e.length;n>a/2&&(n=a/2);let i;for(i=0;i<n;++i){let s=parseInt(e.substr(i*2,2),16);if(ht(s))return i;r[t+i]=s}return i}function wo(r,e,t,n){return Ke(ut(e,r.length-t),r,t,n)}function Eo(r,e,t,n){return Ke(Po(e),r,t,n)}function So(r,e,t,n){return Ke(gr(e),r,t,n)}function To(r,e,t,n){return Ke(ko(e,r.length-t),r,t,n)}f.prototype.write=function(e,t,n,o){if(t===void 0)o="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")o=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-t;if((n===void 0||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let i=!1;for(;;)switch(o){case"hex":return yo(this,e,t,n);case"utf8":case"utf-8":return wo(this,e,t,n);case"ascii":case"latin1":case"binary":return Eo(this,e,t,n);case"base64":return So(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return To(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),i=!0}};f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function bo(r,e,t){return e===0&&t===r.length?st.fromByteArray(r):st.fromByteArray(r.slice(e,t))}function cr(r,e,t){t=Math.min(r.length,t);let n=[],o=e;for(;o<t;){let a=r[o],i=null,s=a>239?4:a>223?3:a>191?2:1;if(o+s<=t){let l,c,d,u;switch(s){case 1:a<128&&(i=a);break;case 2:l=r[o+1],(l&192)===128&&(u=(a&31)<<6|l&63,u>127&&(i=u));break;case 3:l=r[o+1],c=r[o+2],(l&192)===128&&(c&192)===128&&(u=(a&15)<<12|(l&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:l=r[o+1],c=r[o+2],d=r[o+3],(l&192)===128&&(c&192)===128&&(d&192)===128&&(u=(a&15)<<18|(l&63)<<12|(c&63)<<6|d&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),o+=s}return Io(n)}var rr=4096;function Io(r){let e=r.length;if(e<=rr)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=rr));return t}function Ro(r,e,t){let n="";t=Math.min(r.length,t);for(let o=e;o<t;++o)n+=String.fromCharCode(r[o]&127);return n}function vo(r,e,t){let n="";t=Math.min(r.length,t);for(let o=e;o<t;++o)n+=String.fromCharCode(r[o]);return n}function _o(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let o="";for(let a=e;a<t;++a)o+=Uo[r[a]];return o}function xo(r,e,t){let n=r.slice(e,t),o="";for(let a=0;a<n.length-1;a+=2)o+=String.fromCharCode(n[a]+n[a+1]*256);return o}f.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let o=this.subarray(e,t);return Object.setPrototypeOf(o,f.prototype),o};function U(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUintLE=f.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e],a=1,i=0;for(;++i<t&&(a*=256);)o+=this[e+i]*a;return o};f.prototype.readUintBE=f.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e+--t],a=1;for(;t>0&&(a*=256);)o+=this[e+--t]*a;return o};f.prototype.readUint8=f.prototype.readUInt8=function(e,t){return e=e>>>0,t||U(e,1,this.length),this[e]};f.prototype.readUint16LE=f.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||U(e,2,this.length),this[e]|this[e+1]<<8};f.prototype.readUint16BE=f.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||U(e,2,this.length),this[e]<<8|this[e+1]};f.prototype.readUint32LE=f.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUint32BE=f.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readBigUInt64LE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&xe(e,this.length-8);let o=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,a=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(o)+(BigInt(a)<<BigInt(32))});f.prototype.readBigUInt64BE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&xe(e,this.length-8);let o=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],a=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(o)<<BigInt(32))+BigInt(a)});f.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e],a=1,i=0;for(;++i<t&&(a*=256);)o+=this[e+i]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*t)),o};f.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=t,a=1,i=this[e+--o];for(;o>0&&(a*=256);)i+=this[e+--o]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*t)),i};f.prototype.readInt8=function(e,t){return e=e>>>0,t||U(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};f.prototype.readInt16LE=function(e,t){e=e>>>0,t||U(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};f.prototype.readInt16BE=function(e,t){e=e>>>0,t||U(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};f.prototype.readInt32LE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readBigInt64LE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&xe(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(o)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});f.prototype.readBigInt64BE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&xe(e,this.length-8);let o=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});f.prototype.readFloatLE=function(e,t){return e=e>>>0,t||U(e,4,this.length),fe.read(this,e,!0,23,4)};f.prototype.readFloatBE=function(e,t){return e=e>>>0,t||U(e,4,this.length),fe.read(this,e,!1,23,4)};f.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||U(e,8,this.length),fe.read(this,e,!0,52,8)};f.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||U(e,8,this.length),fe.read(this,e,!1,52,8)};function M(r,e,t,n,o,a){if(!f.isBuffer(r))throw new TypeError(\'"buffer" argument must be a Buffer instance\');if(e>o||e<a)throw new RangeError(\'"value" argument is out of bounds\');if(t+n>r.length)throw new RangeError("Index out of range")}f.prototype.writeUintLE=f.prototype.writeUIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let s=Math.pow(2,8*n)-1;M(this,e,t,n,s,0)}let a=1,i=0;for(this[t]=e&255;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n};f.prototype.writeUintBE=f.prototype.writeUIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let s=Math.pow(2,8*n)-1;M(this,e,t,n,s,0)}let a=n-1,i=1;for(this[t+a]=e&255;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n};f.prototype.writeUint8=f.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1};f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function lr(r,e,t,n,o){hr(e,n,o,r,t,7);let a=Number(e&BigInt(4294967295));r[t++]=a,a=a>>8,r[t++]=a,a=a>>8,r[t++]=a,a=a>>8,r[t++]=a;let i=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i,t}function ur(r,e,t,n,o){hr(e,n,o,r,t,7);let a=Number(e&BigInt(4294967295));r[t+7]=a,a=a>>8,r[t+6]=a,a=a>>8,r[t+5]=a,a=a>>8,r[t+4]=a;let i=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=i,i=i>>8,r[t+2]=i,i=i>>8,r[t+1]=i,i=i>>8,r[t]=i,t+8}f.prototype.writeBigUInt64LE=Y(function(e,t=0){return lr(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeBigUInt64BE=Y(function(e,t=0){return ur(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let l=Math.pow(2,8*n-1);M(this,e,t,n,l-1,-l)}let a=0,i=1,s=0;for(this[t]=e&255;++a<n&&(i*=256);)e<0&&s===0&&this[t+a-1]!==0&&(s=1),this[t+a]=(e/i>>0)-s&255;return t+n};f.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let l=Math.pow(2,8*n-1);M(this,e,t,n,l-1,-l)}let a=n-1,i=1,s=0;for(this[t+a]=e&255;--a>=0&&(i*=256);)e<0&&s===0&&this[t+a+1]!==0&&(s=1),this[t+a]=(e/i>>0)-s&255;return t+n};f.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};f.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};f.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};f.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};f.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};f.prototype.writeBigInt64LE=Y(function(e,t=0){return lr(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});f.prototype.writeBigInt64BE=Y(function(e,t=0){return ur(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function dr(r,e,t,n,o,a){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function fr(r,e,t,n,o){return e=+e,t=t>>>0,o||dr(r,e,t,4,34028234663852886e22,-34028234663852886e22),fe.write(r,e,t,n,23,4),t+4}f.prototype.writeFloatLE=function(e,t,n){return fr(this,e,t,!0,n)};f.prototype.writeFloatBE=function(e,t,n){return fr(this,e,t,!1,n)};function pr(r,e,t,n,o){return e=+e,t=t>>>0,o||dr(r,e,t,8,17976931348623157e292,-17976931348623157e292),fe.write(r,e,t,n,52,8),t+8}f.prototype.writeDoubleLE=function(e,t,n){return pr(this,e,t,!0,n)};f.prototype.writeDoubleBE=function(e,t,n){return pr(this,e,t,!1,n)};f.prototype.copy=function(e,t,n,o){if(!f.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-n&&(o=e.length-t+n);let a=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),t),a};f.prototype.fill=function(e,t,n,o){if(typeof e=="string"){if(typeof t=="string"?(o=t,t=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!f.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let i=e.charCodeAt(0);(o==="utf8"&&i<128||o==="latin1")&&(e=i)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let a;if(typeof e=="number")for(a=t;a<n;++a)this[a]=e;else{let i=f.isBuffer(e)?e:f.from(e,o),s=i.length;if(s===0)throw new TypeError(\'The value "\'+e+\'" is invalid for argument "value"\');for(a=0;a<n-t;++a)this[a+t]=i[a%s]}return this};var de={};function pt(r,e,t){de[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}pt("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);pt("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);pt("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,o=t;return Number.isInteger(t)&&Math.abs(t)>2**32?o=nr(String(t)):typeof t=="bigint"&&(o=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(o=nr(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n},RangeError);function nr(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function Ao(r,e,t){pe(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&xe(e,r.length-(t+1))}function hr(r,e,t,n,o,a){if(r>t||r<e){let i=typeof e=="bigint"?"n":"",s;throw a>3?e===0||e===BigInt(0)?s=`>= 0${i} and < 2${i} ** ${(a+1)*8}${i}`:s=`>= -(2${i} ** ${(a+1)*8-1}${i}) and < 2 ** ${(a+1)*8-1}${i}`:s=`>= ${e}${i} and <= ${t}${i}`,new de.ERR_OUT_OF_RANGE("value",s,r)}Ao(n,o,a)}function pe(r,e){if(typeof r!="number")throw new de.ERR_INVALID_ARG_TYPE(e,"number",r)}function xe(r,e,t){throw Math.floor(r)!==r?(pe(r,t),new de.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new de.ERR_BUFFER_OUT_OF_BOUNDS:new de.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Co=/[^+/0-9A-Za-z-_]/g;function Oo(r){if(r=r.split("=")[0],r=r.trim().replace(Co,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function ut(r,e){e=e||1/0;let t,n=r.length,o=null,a=[];for(let i=0;i<n;++i){if(t=r.charCodeAt(i),t>55295&&t<57344){if(!o){if(t>56319){(e-=3)>-1&&a.push(239,191,189);continue}else if(i+1===n){(e-=3)>-1&&a.push(239,191,189);continue}o=t;continue}if(t<56320){(e-=3)>-1&&a.push(239,191,189),o=t;continue}t=(o-55296<<10|t-56320)+65536}else o&&(e-=3)>-1&&a.push(239,191,189);if(o=null,t<128){if((e-=1)<0)break;a.push(t)}else if(t<2048){if((e-=2)<0)break;a.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;a.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;a.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return a}function Po(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function ko(r,e){let t,n,o,a=[];for(let i=0;i<r.length&&!((e-=2)<0);++i)t=r.charCodeAt(i),n=t>>8,o=t%256,a.push(o),a.push(n);return a}function gr(r){return st.toByteArray(Oo(r))}function Ke(r,e,t,n){let o;for(o=0;o<n&&!(o+t>=e.length||o>=r.length);++o)e[o+t]=r[o];return o}function j(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function ht(r){return r!==r}var Uo=(function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let o=0;o<16;++o)e[n+o]=r[t]+r[o]}return e})();function Y(r){return typeof BigInt>"u"?No:r}function No(){throw new Error("BigInt not supported")}});var nn=q(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});function ba(r){var e=4,t=r.length,n=t%e;if(!n)return r;var o=t,a=e-n,i=t+a,s=Buffer.alloc(i);for(s.write(r);a--;)s.write("=",o++);return s.toString()}Ct.default=ba});var an=q(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});var Ia=nn();function on(r,e){return e===void 0&&(e="utf8"),Buffer.isBuffer(r)?Ot(r.toString("base64")):Ot(Buffer.from(r,e).toString("base64"))}function Ra(r,e){return e===void 0&&(e="utf8"),Buffer.from(Pt(r),"base64").toString(e)}function Pt(r){return r=r.toString(),Ia.default(r).replace(/\\-/g,"+").replace(/_/g,"/")}function Ot(r){return r.replace(/=/g,"").replace(/\\+/g,"-").replace(/\\//g,"_")}function va(r){return Buffer.from(Pt(r),"base64")}var we=on;we.encode=on;we.decode=Ra;we.toBase64=Pt;we.fromBase64=Ot;we.toBuffer=va;kt.default=we});var sn=q((Ns,Ye)=>{Ye.exports=an().default;Ye.exports.default=Ye.exports});var ln=q((cn,Ze)=>{(function(r,e){var t={};e(t);var n=t.default;for(var o in t)n[o]=t[o];typeof Ze=="object"&&typeof Ze.exports=="object"?Ze.exports=n:typeof define=="function"&&define.amd?define(function(){return n}):r.sha256=n})(cn,function(r){"use strict";r.__esModule=!0,r.digestLength=32,r.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function t(u,p,h,g,m){for(var T,b,S,_,A,v,F,C,k,O,ce,le,ve;m>=64;){for(T=p[0],b=p[1],S=p[2],_=p[3],A=p[4],v=p[5],F=p[6],C=p[7],O=0;O<16;O++)ce=g+O*4,u[O]=(h[ce]&255)<<24|(h[ce+1]&255)<<16|(h[ce+2]&255)<<8|h[ce+3]&255;for(O=16;O<64;O++)k=u[O-2],le=(k>>>17|k<<15)^(k>>>19|k<<13)^k>>>10,k=u[O-15],ve=(k>>>7|k<<25)^(k>>>18|k<<14)^k>>>3,u[O]=(le+u[O-7]|0)+(ve+u[O-16]|0);for(O=0;O<64;O++)le=(((A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7))+(A&v^~A&F)|0)+(C+(e[O]+u[O]|0)|0)|0,ve=((T>>>2|T<<30)^(T>>>13|T<<19)^(T>>>22|T<<10))+(T&b^T&S^b&S)|0,C=F,F=v,v=A,A=_+le|0,_=S,S=b,b=T,T=le+ve|0;p[0]+=T,p[1]+=b,p[2]+=S,p[3]+=_,p[4]+=A,p[5]+=v,p[6]+=F,p[7]+=C,g+=64,m-=64}return g}var n=(function(){function u(){this.digestLength=r.digestLength,this.blockSize=r.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return u.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},u.prototype.clean=function(){for(var p=0;p<this.buffer.length;p++)this.buffer[p]=0;for(var p=0;p<this.temp.length;p++)this.temp[p]=0;this.reset()},u.prototype.update=function(p,h){if(h===void 0&&(h=p.length),this.finished)throw new Error("SHA256: can\'t update because hash was finished.");var g=0;if(this.bytesHashed+=h,this.bufferLength>0){for(;this.bufferLength<64&&h>0;)this.buffer[this.bufferLength++]=p[g++],h--;this.bufferLength===64&&(t(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(h>=64&&(g=t(this.temp,this.state,p,g,h),h%=64);h>0;)this.buffer[this.bufferLength++]=p[g++],h--;return this},u.prototype.finish=function(p){if(!this.finished){var h=this.bytesHashed,g=this.bufferLength,m=h/536870912|0,T=h<<3,b=h%64<56?64:128;this.buffer[g]=128;for(var S=g+1;S<b-8;S++)this.buffer[S]=0;this.buffer[b-8]=m>>>24&255,this.buffer[b-7]=m>>>16&255,this.buffer[b-6]=m>>>8&255,this.buffer[b-5]=m>>>0&255,this.buffer[b-4]=T>>>24&255,this.buffer[b-3]=T>>>16&255,this.buffer[b-2]=T>>>8&255,this.buffer[b-1]=T>>>0&255,t(this.temp,this.state,this.buffer,0,b),this.finished=!0}for(var S=0;S<8;S++)p[S*4+0]=this.state[S]>>>24&255,p[S*4+1]=this.state[S]>>>16&255,p[S*4+2]=this.state[S]>>>8&255,p[S*4+3]=this.state[S]>>>0&255;return this},u.prototype.digest=function(){var p=new Uint8Array(this.digestLength);return this.finish(p),p},u.prototype._saveState=function(p){for(var h=0;h<this.state.length;h++)p[h]=this.state[h]},u.prototype._restoreState=function(p,h){for(var g=0;g<this.state.length;g++)this.state[g]=p[g];this.bytesHashed=h,this.finished=!1,this.bufferLength=0},u})();r.Hash=n;var o=(function(){function u(p){this.inner=new n,this.outer=new n,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var h=new Uint8Array(this.blockSize);if(p.length>this.blockSize)new n().update(p).finish(h).clean();else for(var g=0;g<p.length;g++)h[g]=p[g];for(var g=0;g<h.length;g++)h[g]^=54;this.inner.update(h);for(var g=0;g<h.length;g++)h[g]^=106;this.outer.update(h),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var g=0;g<h.length;g++)h[g]=0}return u.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},u.prototype.clean=function(){for(var p=0;p<this.istate.length;p++)this.ostate[p]=this.istate[p]=0;this.inner.clean(),this.outer.clean()},u.prototype.update=function(p){return this.inner.update(p),this},u.prototype.finish=function(p){return this.outer.finished?this.outer.finish(p):(this.inner.finish(p),this.outer.update(p,this.digestLength).finish(p)),this},u.prototype.digest=function(){var p=new Uint8Array(this.digestLength);return this.finish(p),p},u})();r.HMAC=o;function a(u){var p=new n().update(u),h=p.digest();return p.clean(),h}r.hash=a,r.default=a;function i(u,p){var h=new o(u).update(p),g=h.digest();return h.clean(),g}r.hmac=i;function s(u,p,h,g){var m=g[0];if(m===0)throw new Error("hkdf: cannot expand more");p.reset(),m>1&&p.update(u),h&&p.update(h),p.update(g),p.finish(u),g[0]++}var l=new Uint8Array(r.digestLength);function c(u,p,h,g){p===void 0&&(p=l),g===void 0&&(g=32);for(var m=new Uint8Array([1]),T=i(p,u),b=new o(T),S=new Uint8Array(b.digestLength),_=S.length,A=new Uint8Array(g),v=0;v<g;v++)_===S.length&&(s(S,b,h,m),_=0),A[v]=S[_++];return b.clean(),S.fill(0),m.fill(0),A}r.hkdf=c;function d(u,p,h,g){for(var m=new o(u),T=m.digestLength,b=new Uint8Array(4),S=new Uint8Array(T),_=new Uint8Array(T),A=new Uint8Array(g),v=0;v*T<g;v++){var F=v+1;b[0]=F>>>24&255,b[1]=F>>>16&255,b[2]=F>>>8&255,b[3]=F>>>0&255,m.reset(),m.update(p),m.update(b),m.finish(_);for(var C=0;C<T;C++)S[C]=_[C];for(var C=2;C<=h;C++){m.reset(),m.update(_).finish(_);for(var k=0;k<T;k++)S[k]^=_[k]}for(var C=0;C<T&&v*T+C<g;C++)A[v*T+C]=S[C]}for(var v=0;v<T;v++)S[v]=_[v]=0;for(var v=0;v<4;v++)b[v]=0;return m.clean(),A}r.pbkdf2=d})});var Hn=q((Wt,Bn)=>{var et=We(),z=et.Buffer;function Ln(r,e){for(var t in r)e[t]=r[t]}z.from&&z.alloc&&z.allocUnsafe&&z.allocUnsafeSlow?Bn.exports=et:(Ln(et,Wt),Wt.Buffer=se);function se(r,e,t){return z(r,e,t)}se.prototype=Object.create(z.prototype);Ln(z,se);se.from=function(r,e,t){if(typeof r=="number")throw new TypeError("Argument must not be a number");return z(r,e,t)};se.alloc=function(r,e,t){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=z(r);return e!==void 0?typeof t=="string"?n.fill(e,t):n.fill(e):n.fill(0),n};se.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return z(r)};se.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return et.SlowBuffer(r)}});var $n=q((il,zt)=>{"use strict";var jt=65536,Fa=4294967295;function Ka(){throw new Error(`Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11`)}var Wa=Hn().Buffer,tt=self.crypto||self.msCrypto;tt&&tt.getRandomValues?zt.exports=ja:zt.exports=Ka;function ja(r,e){if(r>Fa)throw new RangeError("requested too many random bytes");var t=Wa.allocUnsafe(r);if(r>0)if(r>jt)for(var n=0;n<r;n+=jt)tt.getRandomValues(t.slice(n,n+jt));else tt.getRandomValues(t);return typeof e=="function"?process.nextTick(function(){e(null,t)}):t}});var qn=_e(We(),1);var mr=new TextEncoder,yr=new TextDecoder,oi=2**32;var Do=r=>{let e=r;typeof e=="string"&&(e=mr.encode(e));let t=32768,n=[];for(let o=0;o<e.length;o+=t)n.push(String.fromCharCode.apply(null,e.subarray(o,o+t)));return btoa(n.join(""))},wr=r=>Do(r).replace(/=/g,"").replace(/\\+/g,"-").replace(/\\//g,"_"),Mo=r=>{let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t},Er=r=>{let e=r;e instanceof Uint8Array&&(e=yr.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\\s/g,"");try{return Mo(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};var je={};eo(je,{decode:()=>Ho,encode:()=>Bo});var Bo=wr,Ho=Er;var Fo=Object.defineProperty,Ko=(r,e,t)=>e in r?Fo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,R=(r,e,t)=>Ko(r,typeof e!="symbol"?e+"":e,t),Wo={Endpoints:{AUTHORIZATION:"/oauth2/authorize",END_SESSION:"/oidc/logout",ISSUER:"/oauth2/token",JWKS:"/oauth2/jwks",REVOCATION:"/oauth2/revoke",SESSION_IFRAME:"/oidc/checksession",TOKEN:"/oauth2/token",USERINFO:"/oauth2/userinfo"},Storage:{StorageKeys:{Endpoints:{AUTHORIZATION:"authorization_endpoint",END_SESSION:"end_session_endpoint",ISSUER:"issuer",JWKS:"jwks_uri",REVOCATION:"revocation_endpoint",SESSION_IFRAME:"check_session_iframe",TOKEN:"token_endpoint",USERINFO:"userinfo_endpoint"},OPENID_PROVIDER_CONFIG_INITIATED:"op_config_initiated"}}},P=Wo,jo={Placeholders:{ACCESS_TOKEN:"{{accessToken}}",CLIENT_ID:"{{clientId}}",CLIENT_SECRET:"{{clientSecret}}",SCOPES:"{{scopes}}",USERNAME:"{{username}}"}},Ae=jo,E=class{constructor(r,e,t){R(this,"name"),R(this,"code"),R(this,"message"),this.message=t,this.name=e,this.code=r,Object.setPrototypeOf(this,new.target.prototype)}};var zo=r=>{let e={...r};return["iss","aud","exp","iat","acr","amr","azp","auth_time","nonce","c_hash","at_hash","nbf","isk","sid","jti","sub"].forEach(n=>{delete e[n]}),e},qo=zo,Jo={INTERNAL_LOGIN:"internal_login",OPENID:"openid",PROFILE:"profile"},gt=Jo,Vo={Params:{AUTHORIZATION_CODE:"code",SESSION_STATE:"session_state",SIGN_OUT_SUCCESS:"sign_out_success",STATE:"state"},SignIn:{Payload:{DEFAULT_SCOPES:[gt.OPENID,gt.PROFILE,gt.INTERNAL_LOGIN]}},SignOut:{Storage:{StorageKeys:{SIGN_OUT_URL:"sign_out_url"}}}},N=Vo,Go=class Rr extends Error{constructor(e,t,n){let o=Rr.resolveOrigin(n);super(e),R(this,"code"),R(this,"origin"),this.name=new.target.name,this.code=t,this.origin=o,Error.captureStackTrace&&Error.captureStackTrace(this,new.target)}static resolveOrigin(e){return e?`@asgardeo/${e}`:"@asgardeo/javascript"}toString(){let e=`\\u{1F6E1}\\uFE0F Asgardeo - ${this.origin}:`;return`[${this.name}]\n${e} ${this.message}\n(code="${this.code}")`}},vr=class extends Go{constructor(r,e,t,n){super(r,e,t),this.details=n,Object.defineProperty(this,"name",{configurable:!0,value:"AsgardeoRuntimeError",writable:!0})}toString(){let r=this.details?`\nDetails: ${JSON.stringify(this.details,null,2)}`:"";return`[${this.name}] (code="${this.code}")${r}\nMessage: ${this.message}`}},Xo=r=>{let e=[],t=!1;if(r!=null)if(Array.isArray(r))e=r,t=r.length>0;else if(typeof r=="string")e=r?r.split(" "):[],t=r.length>0;else throw new vr("Scopes must be a string or an array of strings.","processOpenIDScopes-Invalid-001","javascript","The provided scopes are not in the expected format. Please provide a string or an array of strings.");return t||N.SignIn.Payload.DEFAULT_SCOPES.forEach(n=>{e.includes(n)||e.push(n)}),e.join(" ")},yt=Xo,Yo=class{constructor(r,e){R(this,"storageManager"),R(this,"config"),R(this,"oidcProviderMetaData"),R(this,"cryptoHelper"),this.storageManager=r,this.config=async()=>this.storageManager.getConfigData(),this.oidcProviderMetaData=async()=>this.storageManager.loadOpenIDProviderConfiguration(),this.cryptoHelper=e}async resolveEndpoints(r){let e={},t=await this.config();return t.endpoints&&Object.keys(t.endpoints).forEach(n=>{let o=n.replace(/[A-Z]/g,a=>`_${a.toLowerCase()}`);e[o]=t?.endpoints?t.endpoints[n]:""}),{...r,...e}}async resolveEndpointsExplicitly(){let r={},e=await this.config(),t=[P.Storage.StorageKeys.Endpoints.AUTHORIZATION,P.Storage.StorageKeys.Endpoints.END_SESSION,P.Storage.StorageKeys.Endpoints.JWKS,P.Storage.StorageKeys.Endpoints.SESSION_IFRAME,P.Storage.StorageKeys.Endpoints.REVOCATION,P.Storage.StorageKeys.Endpoints.TOKEN,P.Storage.StorageKeys.Endpoints.ISSUER,P.Storage.StorageKeys.Endpoints.USERINFO];if(!(e.endpoints?t.every(o=>e.endpoints?Object.keys(e.endpoints).some(a=>a.replace(/[A-Z]/g,s=>`_${s.toLowerCase()}`)===o):!1):!1))throw new E("JS-AUTH_HELPER-REE-NF01","Required endpoints missing","Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object.");return e.endpoints&&Object.keys(e.endpoints).forEach(o=>{let a=o.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`);r[a]=e?.endpoints?e.endpoints[o]:""}),{...r}}async resolveEndpointsByBaseURL(){let r={},e=await this.config(),{baseUrl:t}=e;if(!t)throw new E("JS-AUTH_HELPER_REBO-NF01","Base URL not defined.","Base URL is not defined in AuthClient config.");e.endpoints&&Object.keys(e.endpoints).forEach(i=>{let s=i.replace(/[A-Z]/g,l=>`_${l.toLowerCase()}`);r[s]=e?.endpoints?e.endpoints[i]:""});let n=P.Storage.StorageKeys.Endpoints,o=P.Endpoints,a={[n.AUTHORIZATION]:`${t}${o.AUTHORIZATION}`,[n.END_SESSION]:`${t}${o.END_SESSION}`,[n.ISSUER]:`${t}${o.ISSUER}`,[n.JWKS]:`${t}${o.JWKS}`,[n.SESSION_IFRAME]:`${t}${o.SESSION_IFRAME}`,[n.REVOCATION]:`${t}${o.REVOCATION}`,[n.TOKEN]:`${t}${o.TOKEN}`,[n.USERINFO]:`${t}${o.USERINFO}`};return e.platform==="AsgardeoV2"&&(a[P.Storage.StorageKeys.Endpoints.ISSUER]=`${t}`),{...a,...r}}async validateIdToken(r){let e=(await this.storageManager.loadOpenIDProviderConfiguration()).jwks_uri,t=await this.config();if(!e||e.trim().length===0)throw new E("JS_AUTH_HELPER-VIT-NF01","JWKS endpoint not found.","No JWKS endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the JWKS endpoint passed to the SDK is empty.");let n;try{n=await fetch(e,{credentials:t.sendCookiesInRequests?"include":"same-origin"})}catch(s){throw new E("JS-AUTH_HELPER-VIT-NE02","Request to jwks endpoint failed.",s??"The request sent to get the jwks from the server failed.")}if(n.status!==200||!n.ok)throw new E("JS-AUTH_HELPER-VIT-HE03",`Invalid response status received for jwks request (${n.statusText}).`,await n.json());let{issuer:o}=await this.oidcProviderMetaData(),{keys:a}=await n.json(),i=await this.cryptoHelper.getJWKForTheIdToken(r.split(".")[0],a);return this.cryptoHelper.isValidIdToken(r,i,(await this.config()).clientId,o??"",this.cryptoHelper.decodeJwtToken(r).sub,(await this.config()).tokenValidation?.idToken?.clockTolerance,(await this.config()).tokenValidation?.idToken?.validateIssuer??!0)}getAuthenticatedUserInfo(r){let e=this.cryptoHelper.decodeJwtToken(r),t=e?.username??"",n=e?.given_name??"",o=e?.family_name??"",a=n&&o?`${n} ${o}`:n||o||"";return{displayName:e.preferred_username??a,username:t,...qo(e)}}async replaceCustomGrantTemplateTags(r,e){let t=await this.config(),n=t.organizationChain?.sourceInstanceId??null,o;if(n){let{clientId:i}=t,s;if(i?s=`instance_${n}-${i}`:s=`instance_${n}`,o=await this.storageManager.getSessionData(e,s),!o||!o.access_token)throw new E("JS-AUTH_HELPER-RCGTT-NE01","No session data found for source instance.","Failed to retrieve session data from the source organization context.")}else o=await this.storageManager.getSessionData(e);let a=yt(t.scopes);return typeof r!="string"?r:r.replace(Ae.Placeholders.ACCESS_TOKEN,o.access_token).replace(Ae.Placeholders.USERNAME,this.getAuthenticatedUserInfo(o.id_token).username).replace(Ae.Placeholders.SCOPES,a).replace(Ae.Placeholders.CLIENT_ID,t.clientId).replace(Ae.Placeholders.CLIENT_SECRET,t.clientSecret??"")}async clearSession(r){await this.storageManager.removeTemporaryData(r),await this.storageManager.removeSessionData(r)}async handleTokenResponse(r,e){if(r.status!==200||!r.ok)throw new E("JS-AUTH_HELPER-HTR-NE01",`Invalid response status received for token request (${r.statusText}).`,await r.json());let t=await r.json();if(t.created_at=new Date().getTime(),(await this.config()).tokenValidation?.idToken?.validate)return this.validateIdToken(t.id_token).then(async()=>{await this.storageManager.setSessionData(t,e);let a={accessToken:t.access_token,createdAt:t.created_at,expiresIn:t.expires_in,idToken:t.id_token,refreshToken:t.refresh_token,scope:t.scope,tokenType:t.token_type};return Promise.resolve(a)});let o={accessToken:t.access_token,createdAt:t.created_at,expiresIn:t.expires_in,idToken:t.id_token,refreshToken:t.refresh_token,scope:t.scope,tokenType:t.token_type};return await this.storageManager.setSessionData(t,e),Promise.resolve(o)}},Zo={DEFAULT_CODE_CHALLENGE_METHOD:"S256",Storage:{StorageKeys:{CODE_VERIFIER:"pkce_code_verifier",SEPARATOR:"#"}}},Z=Zo,Qo={Endpoints:{WELL_KNOWN:"/.well-known/openid-configuration"}},ea=Qo,ta={SignatureValidation:{SUPPORTED_ALGORITHMS:["RS256","RS512","RS384","PS256"]},Storage:{StorageKeys:{REFRESH_TOKEN_TIMER:"refresh_token_timer"}}},Ce=ta,ra=class{constructor(r){R(this,"cryptoUtils"),this.cryptoUtils=r}getCodeVerifier(){return this.cryptoUtils.base64URLEncode(this.cryptoUtils.generateRandomBytes(32))}async getCodeChallenge(r){let e=await this.cryptoUtils.hashSha256(r);return this.cryptoUtils.base64URLEncode(e)}getJWKForTheIdToken(r,e){let t=JSON.parse(this.cryptoUtils.base64URLDecode(r)),n=e.find(o=>t.kid===o.kid);if(n)return n;throw new E("JS-CRYPTO_UTIL-GJFTIT-IV01","kid not found.",`Failed to find the \'kid\' specified in the id_token. \'kid\' found in the header : ${t.kid}, Expected values: ${e.map(o=>o.kid).join(", ")}`)}isValidIdToken(r,e,t,n,o,a,i){return this.cryptoUtils.verifyJwt(r,e,Ce.SignatureValidation.SUPPORTED_ALGORITHMS,t,n,o,a,i).then(s=>s?Promise.resolve(!0):Promise.reject(new E("JS-CRYPTO_HELPER-IVIT-IV01","Invalid ID token.","ID token validation returned false"))).catch(s=>Promise.reject(s))}decodeJwtToken(r){try{let e=this.cryptoUtils.base64URLDecode(r?.split(".")[1]);return JSON.parse(e)}catch(e){throw new E("JS-CRYPTO_UTIL-DIT-IV02","Decoding token failed.",e)}}},mt="asgardeo-session-active",na=class ze{constructor(e,t){R(this,"id"),R(this,"store"),this.id=e,this.store=t}async setDataInBulk(e,t){let n=await this.store.getData(e)??null,a={...n&&JSON.parse(n),...t},i=JSON.stringify(a);await this.store.setData(e,i)}async setValue(e,t,n){let o=await this.store.getData(e)??null,i={...o&&JSON.parse(o),[t]:n},s=JSON.stringify(i);await this.store.setData(e,s)}async removeValue(e,t){let n=await this.store.getData(e)??null,a={...n&&JSON.parse(n)};delete a[t];let i=JSON.stringify(a);await this.store.setData(e,i)}resolveKey(e,t,n){return t&&n?`${e}-${n}-${t}`:t?`${e}-${this.id}-${t}`:n?`${e}-${n}`:`${e}-${this.id}`}static isLocalStorageAvailable(){try{let e="__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}async setConfigData(e){await this.setDataInBulk(this.resolveKey("config_data"),e)}async setOIDCProviderMetaData(e){this.setDataInBulk(this.resolveKey("oidc_provider_meta_data"),e)}async setTemporaryData(e,t){this.setDataInBulk(this.resolveKey("temporary_data",t),e)}async setSessionData(e,t){this.setDataInBulk(this.resolveKey("session_data",t),e)}async setCustomData(e,t,n){this.setDataInBulk(this.resolveKey(e,n),t)}async getConfigData(e){return JSON.parse(await this.store.getData(this.resolveKey("config_data",e))??null)}async loadOpenIDProviderConfiguration(){return JSON.parse(await this.store.getData(this.resolveKey("oidc_provider_meta_data"))??null)}async getTemporaryData(e){return JSON.parse(await this.store.getData(this.resolveKey("temporary_data",e))??null)}async getPersistedData(e){return JSON.parse(await this.store.getData(this.resolveKey("persisted_data",e))??null)}async setPersistedData(e,t){this.setDataInBulk(this.resolveKey("persisted_data",t),e)}async getSessionData(e,t){return JSON.parse(await this.store.getData(this.resolveKey("session_data",e,t))??null)}async getCustomData(e,t){return JSON.parse(await this.store.getData(this.resolveKey(e,t))??null)}setSessionStatus(e){ze.isLocalStorageAvailable()&&localStorage.setItem(`${mt}`,e)}getSessionStatus(){return ze.isLocalStorageAvailable()?localStorage.getItem(`${mt}`)??"":""}removeSessionStatus(){ze.isLocalStorageAvailable()&&localStorage.removeItem(`${mt}`)}async removeConfigData(){await this.store.removeData(this.resolveKey("config_data"))}async removeOIDCProviderMetaData(){await this.store.removeData(this.resolveKey("oidc_provider_meta_data"))}async removeTemporaryData(e){await this.store.removeData(this.resolveKey("temporary_data",e))}async removeSessionData(e){await this.store.removeData(this.resolveKey("session_data",e))}async getConfigDataParameter(e){let t=await this.store.getData(this.resolveKey("config_data"));return t&&JSON.parse(t)[e]}async getOIDCProviderMetaDataParameter(e){let t=await this.store.getData(this.resolveKey("oidc_provider_meta_data"));return t&&JSON.parse(t)[e]}async getTemporaryDataParameter(e,t){let n=await this.store.getData(this.resolveKey("temporary_data",t));return n&&JSON.parse(n)[e]}async getSessionDataParameter(e,t){let n=await this.store.getData(this.resolveKey("session_data",t));return n&&JSON.parse(n)[e]}async setConfigDataParameter(e,t){await this.setValue(this.resolveKey("config_data"),e,t)}async setOIDCProviderMetaDataParameter(e,t){await this.setValue(this.resolveKey("oidc_provider_meta_data"),e,t)}async setTemporaryDataParameter(e,t,n){await this.setValue(this.resolveKey("temporary_data",n),e,t)}async setSessionDataParameter(e,t,n){await this.setValue(this.resolveKey("session_data",n),e,t)}async removeConfigDataParameter(e){await this.removeValue(this.resolveKey("config_data"),e)}async removeOIDCProviderMetaDataParameter(e){await this.removeValue(this.resolveKey("oidc_provider_meta_data"),e)}async removeTemporaryDataParameter(e,t){await this.removeValue(this.resolveKey("temporary_data",t),e)}async removeSessionDataParameter(e,t){await this.removeValue(this.resolveKey("session_data",t),e)}},Sr=na,oa=r=>{let e=je.encode(new TextEncoder().encode(r)),t=e.length%4;return(t===0?e:e+"=".repeat(4-t)).replace(/-/g,"+").replace(/_/g,"/")},aa=oa,Tr=r=>typeof r=="object"&&r!==null&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.prototype.toString.call(r)==="[object Object]",_r=(r,...e)=>{if(!r||typeof r!="object")throw new Error("Target must be an object");let t={...r};return e.forEach(n=>{!n||typeof n!="object"||Object.keys(n).forEach(o=>{let a=n[o],i=t[o];Tr(a)&&Tr(i)?t[o]=_r(i,a):a!==void 0&&(t[o]=a)})}),t},ia=_r,sa=r=>{let e=parseInt(r.split("request_")[1],10);return`${Z.Storage.StorageKeys.CODE_VERIFIER}${Z.Storage.StorageKeys.SEPARATOR}${e}`},oe=sa,ca=r=>{let e=[];Object.keys(r).forEach(o=>{o.startsWith(Z.Storage.StorageKeys.CODE_VERIFIER)&&e.push(o)});let t=e.sort().pop(),n=parseInt(t?.split(Z.Storage.StorageKeys.SEPARATOR)[1]??"-1",10);return`${Z.Storage.StorageKeys.CODE_VERIFIER}${Z.Storage.StorageKeys.SEPARATOR}${n+1}`},la=ca,ua=(r,e)=>{let t=parseInt(r.split(Z.Storage.StorageKeys.SEPARATOR)[1],10);return e?`${e}_request_${t}`:`request_${t}`},da=ua,fa=(r,e,t)=>{let{redirectUri:n,clientId:o,scopes:a,responseMode:i,codeChallenge:s,codeChallengeMethod:l,prompt:c}=r,d=new Map;d.set("response_type","code"),d.set("client_id",o),d.set("scope",a),d.set("redirect_uri",n),i&&d.set("response_mode",i);let u=e?.key;if(s)if(d.set("code_challenge",s),l)d.set("code_challenge_method",l);else throw new vr("Code challenge method is required when code challenge is provided.","getAuthorizeRequestUrlParams-ValidationError-001","javascript","When PKCE is enabled, the code challenge method must be provided along with the code challenge.");c&&d.set("prompt",c),t&&Object.entries(t).forEach(([g,m])=>{g!==""&&m!==""&&g!==N.Params.STATE&&d.set(g,m.toString())});let p="instance_",h="";return r.instanceId?h=p+r.instanceId:t&&(h=t[N.Params.STATE]?.toString()??""),d.set(N.Params.STATE,da(u,h)),d},pa=fa,ha={enablePKCE:!0,responseMode:"query",sendCookiesInRequests:!0,tokenValidation:{idToken:{clockTolerance:300,validate:!0,validateIssuer:!0}}},xr=class Ar{constructor(){R(this,"storageManager"),R(this,"configProvider"),R(this,"oidcProviderMetaDataProvider"),R(this,"authHelper"),R(this,"cryptoUtils"),R(this,"cryptoHelper"),R(this,"instanceIdValue")}async initialize(e,t,n,o){let{clientId:a}=e;this.instanceIdValue?this.instanceIdValue+=1:this.instanceIdValue=0,o!==void 0&&(this.instanceIdValue=o),a?this.storageManager=new Sr(`instance_${this.instanceIdValue}-${a}`,t):this.storageManager=new Sr(`instance_${this.instanceIdValue}`,t),this.cryptoUtils=n,this.cryptoHelper=new ra(n),this.authHelper=new Yo(this.storageManager,this.cryptoHelper),this.configProvider=async()=>this.storageManager.getConfigData(),this.oidcProviderMetaDataProvider=async()=>this.storageManager.loadOpenIDProviderConfiguration(),Ar.authHelperInstance=this.authHelper;let{applicationId:i,platform:s,endpoints:l}=e,c=i;if(i)await this.storageManager.setPersistedData({applicationId:i});else{let u=await this.storageManager.getPersistedData();u.applicationId&&(c=u.applicationId)}let d=l||{};s==="AsgardeoV2"&&(d.wellKnown||(d.wellKnown=ea.Endpoints.WELL_KNOWN)),await this.storageManager.setConfigData({...ha,...e,applicationId:c,endpoints:d,scope:yt(e.scopes)})}getStorageManager(){return this.storageManager}getInstanceId(){return this.instanceIdValue}async getSignInUrl(e,t){let n={...e};delete n?.forceInit;let o=async()=>{let a=await this.storageManager.getOIDCProviderMetaDataParameter(P.Storage.StorageKeys.Endpoints.AUTHORIZATION);if(!a||a.trim().length===0)throw new E("JS-AUTH_CORE-GAU-NF01","No authorization endpoint found.","No authorization endpoint was found in the OIDC provider meta data from the well-known endpoint or the authorization endpoint passed to the SDK is empty.");let i=new URL(a),s=await this.configProvider(),l=await this.storageManager.getTemporaryData(t),c=await la(l),d,u;s.enablePKCE&&(d=this.cryptoHelper?.getCodeVerifier(),u=await this.cryptoHelper?.getCodeChallenge(d),await this.storageManager.setTemporaryDataParameter(c,d,t)),n.client_secret&&(n.client_secret=s.clientSecret);let p=pa({clientId:s.clientId,codeChallenge:u,codeChallengeMethod:Z.DEFAULT_CODE_CHALLENGE_METHOD,instanceId:this.getInstanceId().toString(),prompt:s.prompt,redirectUri:s.afterSignInUrl,responseMode:s.responseMode,scopes:yt(s.scopes)},{key:c},n);return Array.from(p.entries()).forEach(([h,g])=>{i.searchParams.append(h,g)}),i.toString()};return await this.storageManager.getTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)?o():this.loadOpenIDProviderConfiguration(e?.forceInit).then(()=>o())}async requestAccessToken(e,t,n,o,a){await this.storageManager.getTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)||await this.loadOpenIDProviderConfiguration(!1);let i=(await this.oidcProviderMetaDataProvider()).token_endpoint,s=await this.configProvider();if(!i||i.trim().length===0)throw new E("JS-AUTH_CORE-RAT1-NF01","Token endpoint not found.","No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty.");t&&await this.storageManager.setSessionDataParameter(N.Params.SESSION_STATE,t,o);let l=new URLSearchParams;l.set("client_id",s.clientId);let c=!!(s.clientSecret&&s.clientSecret.trim().length>0),d=s.tokenRequest?.authMethod??(s.platform==="AsgardeoV2"?"client_secret_basic":"client_secret_post");c&&d==="client_secret_post"&&l.set("client_secret",s.clientSecret);let u=e;l.set("code",u),l.set("grant_type","authorization_code"),l.set("redirect_uri",s.afterSignInUrl),a?.params&&Object.entries(a.params).forEach(([g,m])=>{l.append(g,m)}),s.enablePKCE&&(l.set("code_verifier",`${await this.storageManager.getTemporaryDataParameter(oe(n),o)}`),await this.storageManager.removeTemporaryDataParameter(oe(n),o));let p={Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"};if(c&&d==="client_secret_basic"){let g=`${encodeURIComponent(s.clientId)}:${encodeURIComponent(s.clientSecret)}`;p.Authorization=`Basic ${aa(g)}`}let h;try{h=await fetch(i,{body:l,credentials:s.sendCookiesInRequests?"include":"same-origin",headers:p,method:"POST"})}catch(g){throw new E("JS-AUTH_CORE-RAT1-NE02","Requesting access token failed",g??"The request to get the access token from the server failed.")}if(!h.ok)throw new E("JS-AUTH_CORE-RAT1-HE03",`Requesting access token failed with ${h.statusText}`,await h.json());return this.authHelper.handleTokenResponse(h,o)}async loadOpenIDProviderConfiguration(e){let t=await this.configProvider();if(!e&&await this.storageManager.getTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED))return Promise.resolve();let{wellKnownEndpoint:n,platform:o,discovery:a,baseUrl:i,endpoints:s}=t,l=n||(o==="AsgardeoV2"&&a?.wellKnown?.enabled?`${i}${s?.wellKnown??"/.well-known/openid-configuration"}`:void 0);if(l){let c;try{if(c=await fetch(l),c.status!==200||!c.ok)throw new Error}catch{throw new E("JS-AUTH_CORE-GOPMD-HE01","Invalid well-known response","The well known endpoint response has been failed with an error.")}return await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpoints(await c.json())),await this.storageManager.setTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}if(t.baseUrl){try{await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsByBaseURL())}catch(c){throw new E("JS-AUTH_CORE-GOPMD-IV02","Resolving endpoints failed.",c??"Resolving endpoints by base url failed.")}return await this.storageManager.setTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}return await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsExplicitly()),await this.storageManager.setTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}async getSignOutUrl(e){let t=(await this.oidcProviderMetaDataProvider())?.end_session_endpoint,n=await this.configProvider();if(!t||t.trim().length===0)throw new E("JS-AUTH_CORE-GSOU-NF01","Sign-out endpoint not found.","No sign-out endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the sign-out endpoint passed to the SDK is empty.");let o=n?.afterSignOutUrl??n?.afterSignInUrl;if(!o||o.trim().length===0)throw new E("JS-AUTH_CORE-GSOU-NF03","No sign-out redirect URL found.","The sign-out redirect URL cannot be found or the URL passed to the SDK is empty. No sign-in redirect URL has been found either. ");let a=new URLSearchParams;if(a.set("post_logout_redirect_uri",o),n.sendIdTokenInLogoutRequest){let i=(await this.storageManager.getSessionData(e))?.id_token;if(!i||i.trim().length===0)throw new E("JS-AUTH_CORE-GSOU-NF02","ID token not found.","No ID token could be found. Either the session information is lost or you have not signed in.");a.set("id_token_hint",i)}else a.set("client_id",n.clientId);return a.set("state",N.Params.SIGN_OUT_SUCCESS),`${t}?${a.toString()}`}async getOpenIDProviderEndpoints(){let e=await this.oidcProviderMetaDataProvider();return{authorizationEndpoint:e.authorization_endpoint??"",checkSessionIframe:e.check_session_iframe??"",endSessionEndpoint:e.end_session_endpoint??"",introspectionEndpoint:e.introspection_endpoint??"",issuer:e.issuer??"",jwksUri:e.jwks_uri??"",registrationEndpoint:e.registration_endpoint??"",revocationEndpoint:e.revocation_endpoint??"",tokenEndpoint:e.token_endpoint??"",userinfoEndpoint:e.userinfo_endpoint??""}}async decodeJwtToken(e){return this.cryptoHelper.decodeJwtToken(e)}async getDecodedIdToken(e,t){let n=(await this.storageManager.getSessionData(e)).id_token;return this.cryptoHelper.decodeJwtToken(n??t)}async getIdToken(e){return(await this.storageManager.getSessionData(e)).id_token}async getUser(e){let t=await this.storageManager.getSessionData(e),n=this.authHelper.getAuthenticatedUserInfo(t?.id_token);return Object.keys(n).forEach(o=>{(n[o]===void 0||n[o]===""||n[o]===null)&&delete n[o]}),n}async getUserSession(e){let t=await this.storageManager.getSessionData(e);return{scopes:t?.scope?.split(" "),sessionState:t?.session_state??""}}async getCrypto(){return this.cryptoHelper}async revokeAccessToken(e){let t=(await this.oidcProviderMetaDataProvider()).revocation_endpoint,n=await this.configProvider();if(!t||t.trim().length===0)throw new E("JS-AUTH_CORE-RAT3-NF01","No revoke access token endpoint found.","No revoke access token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the revoke access token endpoint passed to the SDK is empty.");let o=[];o.push(`client_id=${n.clientId}`),o.push(`token=${(await this.storageManager.getSessionData(e)).access_token}`),o.push("token_type_hint=access_token"),n.clientSecret&&n.clientSecret.trim().length>0&&o.push(`client_secret=${n.clientSecret}`);let a;try{a=await fetch(t,{body:o.join("&"),credentials:n.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(i){throw new E("JS-AUTH_CORE-RAT3-NE02","The request to revoke access token failed.",i??"The request sent to revoke the access token failed.")}if(a.status!==200||!a.ok)throw new E("JS-AUTH_CORE-RAT3-HE03",`Invalid response status received for revoke access token request (${a.statusText}).`,await a.json());return this.authHelper.clearSession(e),Promise.resolve(a)}async refreshAccessToken(e){let t=(await this.oidcProviderMetaDataProvider()).token_endpoint,n=await this.configProvider(),o=await this.storageManager.getSessionData(e);if(!o.refresh_token)throw new E("JS-AUTH_CORE-RAT2-NF01","No refresh token found.","There was no refresh token found. Asgardeo doesn\'t return a refresh token if the refresh token grant is not enabled.");if(!t||t.trim().length===0)throw new E("JS-AUTH_CORE-RAT2-NF02","No refresh token endpoint found.","No refresh token endpoint was in the OIDC provider meta data returned by the well-known endpoint or the refresh token endpoint passed to the SDK is empty.");let a=[];a.push(`client_id=${n.clientId}`),a.push(`refresh_token=${o.refresh_token}`),a.push("grant_type=refresh_token"),n.clientSecret&&n.clientSecret.trim().length>0&&a.push(`client_secret=${n.clientSecret}`);let i;try{i=await fetch(t,{body:a.join("&"),credentials:n.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(s){throw new E("JS-AUTH_CORE-RAT2-NR03","Refresh access token request failed.",s??"The request to refresh the access token failed.")}if(!i.ok)throw new E("JS-AUTH_CORE-RAT2-HE04",`Refreshing access token failed with ${i.statusText}`,await i.json());return this.authHelper.handleTokenResponse(i,e)}async getAccessToken(e){return(await this.storageManager.getSessionData(e))?.access_token}async exchangeToken(e,t){await this.storageManager.getTemporaryDataParameter(P.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)||await this.loadOpenIDProviderConfiguration(!1);let n=await this.oidcProviderMetaDataProvider(),o=await this.configProvider(),a;if(e.tokenEndpoint&&e.tokenEndpoint.trim().length!==0?a=e.tokenEndpoint:a=n.token_endpoint,!a||a.trim().length===0)throw new E("JS-AUTH_CORE-RCG-NF01","Token endpoint not found.","No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty.");let i=await Promise.all(Object.entries(e.data).map(async([d,u])=>{let p=await this.authHelper.replaceCustomGrantTemplateTags(u,t);return`${d}=${p}`})),s={Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"};e.attachToken&&(s={...s,Authorization:`Bearer ${(await this.storageManager.getSessionData(t)).access_token}`});let l={body:i.join("&"),credentials:o.sendCookiesInRequests?"include":"same-origin",headers:new Headers(s),method:"POST"},c;try{c=await fetch(a,l)}catch(d){throw new E("JS-AUTH_CORE-RCG-NE02","The custom grant request failed.",d??"The request sent to get the custom grant failed.")}if(c.status!==200||!c.ok)throw new E("JS-AUTH_CORE-RCG-HE03",`Invalid response status received for the custom grant request. (${c.statusText})`,await c.json());return e.returnsSession?this.authHelper.handleTokenResponse(c,t):Promise.resolve(await c.json())}async isSignedIn(e){let t=!!await this.getAccessToken(e),n=(await this.storageManager.getSessionData(e))?.created_at,o=(await this.storageManager.getSessionData(e))?.expires_in;if(!o)return!1;let a=parseInt(o,10)*1e3,i=new Date().getTime(),s=n+a>i;return t&&s}async getPKCECode(e,t){return await this.storageManager.getTemporaryDataParameter(oe(e),t)}async setPKCECode(e,t,n){return this.storageManager.setTemporaryDataParameter(oe(t),e,n)}static isSignOutSuccessful(e){let t=new URL(e),n=t.searchParams.get(N.Params.STATE),o=!!t.searchParams.get("error");return n?n===N.Params.SIGN_OUT_SUCCESS&&!o:!1}static didSignOutFail(e){let t=new URL(e),n=t.searchParams.get(N.Params.STATE),o=!!t.searchParams.get("error");return n?n===N.Params.SIGN_OUT_SUCCESS&&o:!1}async reInitialize(e){let t=this.storageManager.getConfigData(),n=ia(t,e);await this.storageManager.setConfigData(n),await this.loadOpenIDProviderConfiguration(!0)}static async clearSession(e){await this.authHelperInstance.clearSession(e)}};R(xr,"authHelperInstance");var ae=xr;var ga="\\u{1F6E1}\\uFE0F Asgardeo",ma={level:"info",prefix:`${ga}`,showLevel:!0,timestamps:!0},ya=()=>typeof window<"u"&&typeof window.document<"u",wa=()=>typeof process<"u"&&process.versions&&process.versions.node,$={blue:"\\x1B[34m",bright:"\\x1B[1m",cyan:"\\x1B[36m",dim:"\\x1B[2m",gray:"\\x1B[90m",green:"\\x1B[32m",magenta:"\\x1B[35m",red:"\\x1B[31m",reset:"\\x1B[0m",white:"\\x1B[37m",yellow:"\\x1B[33m"},ge={debug:"color: #6b7280; font-weight: normal;",error:"color: #dc2626; font-weight: bold;",info:"color: #2563eb; font-weight: bold;",prefix:"color: #7c3aed; font-weight: bold;",timestamp:"color: #6b7280; font-size: 0.9em;",warn:"color: #d97706; font-weight: bold;"},br={debug:0,error:3,info:1,warn:2},Ea=class me{constructor(e={}){R(this,"config"),this.config={...ma,...e}}configure(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}shouldLog(e){return br[e]>=br[this.config.level]}static getTimestamp(){return new Date().toISOString()}static getLevelString(e){switch(e){case"debug":return"DEBUG";case"info":return"INFO";case"warn":return"WARN";case"error":return"ERROR";default:return"UNKNOWN"}}formatForNode(e,t){let n=[];if(this.config.timestamps&&n.push(`${$.gray}[${me.getTimestamp()}]${$.reset}`),this.config.prefix&&n.push(`${$.magenta}${this.config.prefix}${$.reset}`),this.config.showLevel){let o=me.getLevelString(e),a;switch(e){case"debug":a=`${$.gray}[${o}]${$.reset}`;break;case"info":a=`${$.blue}[${o}]${$.reset}`;break;case"warn":a=`${$.yellow}[${o}]${$.reset}`;break;case"error":a=`${$.red}[${o}]${$.reset}`;break;default:a=`[${o}]`}n.push(a)}return n.push(t),n.join(" ")}logMessage(e,t,...n){if(this.shouldLog(e)){if(this.config.formatter){this.config.formatter(e,t,...n);return}ya()?this.logToBrowser(e,t,...n):wa()?this.logToNode(e,t,...n):console.log(t,...n)}}logToBrowser(e,t,...n){let o=[],a=[];if(this.config.timestamps&&(o.push(`%c[${me.getTimestamp()}]`),a.push(ge.timestamp)),this.config.prefix&&(o.push(`%c${this.config.prefix}`),a.push(ge.prefix)),this.config.showLevel){let s=me.getLevelString(e);switch(o.push(`%c[${s}]`),e){case"debug":a.push(ge.debug);break;case"info":a.push(ge.info);break;case"warn":a.push(ge.warn);break;case"error":a.push(ge.error);break;default:a.push("")}}o.push(`%c${t}`),a.push("color: inherit; font-weight: normal;");let i=o.join(" ");switch(e){case"debug":console.debug(i,...a,...n);break;case"info":console.info(i,...a,...n);break;case"warn":console.warn(i,...a,...n);break;case"error":console.error(i,...a,...n);break;default:console.log(i,...a,...n)}}logToNode(e,t,...n){let o=this.formatForNode(e,t);switch(e){case"debug":console.debug(o,...n);break;case"info":console.info(o,...n);break;case"warn":console.warn(o,...n);break;case"error":console.error(o,...n);break;default:console.log(o,...n)}}debug(e,...t){this.logMessage("debug",e,...t)}info(e,...t){this.logMessage("info",e,...t)}warn(e,...t){this.logMessage("warn",e,...t)}error(e,...t){this.logMessage("error",e,...t)}child(e){let t=this.config.prefix?`${this.config.prefix} - ${e}`:e;return new me({...this.config,prefix:t})}setLevel(e){this.config.level=e}getLevel(){return this.config.level}},ci=new Ea;var Ir;(r=>{r.DEFAULT_AUTHENTICATOR_NAME="Username & Password"})(Ir||(Ir={}));var Sa=/\\{\\{\\s*([^}]+)\\s*\\}\\}/;var li=new RegExp(Sa.source,"g");var Cr=class Or{constructor(e=!0,t=()=>Promise.resolve()){this.isHandlerEnabled=e,this.attachToken=t,R(this,"requestStartCallback",()=>null),R(this,"requestSuccessCallback",()=>null),R(this,"requestErrorCallback",()=>null),R(this,"requestFinishCallback",()=>null)}async request(e){let t=await this.requestHandler(e);try{let n=await this.transport(t);return this.successHandler(n)}catch(n){throw this.errorHandler(n),n}}enableHandler(){this.isHandlerEnabled=!0}disableHandler(){this.isHandlerEnabled=!1}disableHandlerWithTimeout(e=Or.DEFAULT_HANDLER_DISABLE_TIMEOUT){this.isHandlerEnabled=!1,setTimeout(()=>{this.isHandlerEnabled=!0},e)}setHttpRequestStartCallback(e){this.requestStartCallback=e}setHttpRequestSuccessCallback(e){this.requestSuccessCallback=e}setHttpRequestErrorCallback(e){this.requestErrorCallback=e}setHttpRequestFinishCallback(e){this.requestFinishCallback=e}all(e){return Promise.all(e)}spread(e){return t=>e(...t)}async requestHandler(e){if(await this.attachToken(e),e.shouldEncodeToFormData&&e.data){let t=new FormData;Object.keys(e.data).forEach(n=>t.append(n,e.data[n])),e.data=t}return e.startTimeInMs=Date.now(),this.isHandlerEnabled&&typeof this.requestStartCallback=="function"&&this.requestStartCallback(e),e}successHandler(e){return this.isHandlerEnabled&&(typeof this.requestSuccessCallback=="function"&&this.requestSuccessCallback(e),typeof this.requestFinishCallback=="function"&&this.requestFinishCallback()),e}errorHandler(e){this.isHandlerEnabled&&(typeof this.requestErrorCallback=="function"&&this.requestErrorCallback(e),typeof this.requestFinishCallback=="function"&&this.requestFinishCallback())}};R(Cr,"DEFAULT_HANDLER_DISABLE_TIMEOUT",1e3);var Pr=Cr;var wt="init";var kr="sign-out",Ur="http-request",Nr="http-request-all",Dr="request-custom-grant",Mr="revoke-access-token";var Lr="request-start",Br="request-success";var Hr="request-finish",$r="get-oidc-service-endpoints",Fr="get-basic-user-info",Kr="get-decoded-id-token";var Wr="get-crypto-helper",jr="enable_http_handler",zr="disable_http_handler",qr="get_auth_url",Jr="request_get_token",Vr="is_authenticated",Gr="get_sign_out_url",Xr="refresh_access-token",Yr="refresh-access-token-error",Zr="set_session_state",Qr="start_auto_refresh_token",en="update_config",tn="get_id_token",Et="check_session_signed_in",St="check_session_signed_out",rn="get_config_data";var Tt="rpIFrame",bt="promptNoneIFrame";var It="sign-in-silently";var Rt="initialized-silent-sign-in",vt="promptNoneRequestSent";var ye="error",Oe="error_description",_t="custom_grant_config",xt="state";var At="Access token is invalid";var y=class{constructor(){}static generateSuccessMessage(e){return{blob:e?.data instanceof Blob?e?.data:null,data:JSON.stringify(e??""),success:!0}}static generateFailureMessage(e){e?.toJSON&&delete e.toJSON;let t;try{if(e instanceof Error)t=JSON.stringify({name:e.name,message:e.message,stack:e.stack,...e});else if(typeof e=="object"&&e!==null)try{t=JSON.stringify(e)}catch{t=JSON.stringify({message:e.toString?e.toString():"Unknown error",originalError:String(e)})}else t=JSON.stringify(e??"Unknown error")}catch{t=JSON.stringify({message:"Error serialization failed",originalError:String(e)})}return{error:t,success:!1}}};var Q=class Q{constructor(){}static removeAuthorizationCode(){let e=location.href;history.pushState({},document.title,e.replace(/\\?code=.*$/,""))}static getPKCE(e){return sessionStorage.getItem(e)??""}static setPKCE(e,t){sessionStorage.setItem(e,t)}static setSignOutURL(e,t,n){sessionStorage.setItem(`${N.SignOut.Storage.StorageKeys.SIGN_OUT_URL}-instance_${n}-${t}`,e)}static getSignOutUrl(e,t){return sessionStorage.getItem(`${N.SignOut.Storage.StorageKeys.SIGN_OUT_URL}-instance_${t}-${e}`)??""}static removePKCE(e){sessionStorage.removeItem(e)}static canContinueSignIn(e,t){return!(e&&!Q.hasErrorInURL()&&!Q.hasAuthSearchParamsInURL()&&!t)}static isInitializedSilentSignIn(){return Q.isSilentStatePresentInURL()}static wasSignInCalled(){return!!((Q.hasErrorInURL()||Q.hasAuthSearchParamsInURL())&&!this.isSilentStatePresentInURL())}static wasSilentSignInCalled(){let e=sessionStorage.getItem(Rt);return!!(e?JSON.parse(e):null)}static async isSignOutSuccessful(){if(ae.isSignOutSuccessful(window.location.href)){let e=window.location.href.split("?")[0];return history.pushState({},document.title,e),await ae.clearSession(),!0}return!1}static didSignOutFail(){if(ae.didSignOutFail(window.location.href)){let e=new URL(window.location.href),t=e.searchParams.get(ye),n=e.searchParams.get(Oe),o=window.location.href.split("?")[0];return history.pushState({},document.title,o),{description:n??"",error:t??""}}return!1}static isSilentStatePresentInURL(){return new URL(window.location.href).searchParams.get("state")?.includes(It)??!1}static hasAuthSearchParamsInURL(e=window.location.search){return/[?&]code=[^&]+/.test(e)}static hasErrorInURL(e=window.location.href){let t=new URL(e);return!!t.searchParams.get(ye)&&t.searchParams.get(xt)!==N.Params.SIGN_OUT_SUCCESS}static canSendPromptNoneRequest(){let e=sessionStorage.getItem(vt);return!(e?JSON.parse(e):null)}static setPromptNoneRequestSent(e){sessionStorage.setItem(vt,JSON.stringify(e))}static async waitTillPageRedirect(e){let t=e??3e3;await new Promise(n=>setTimeout(n,t*1e3))}};w(Q,"until",(e,t=500)=>{let n=o=>e()?o():setTimeout(()=>n(o),t);return new Promise(n)});var ee=Q;var qe=class{constructor(e,t){w(this,"_authenticationClient");w(this,"_storageManager");w(this,"_spaHelper");w(this,"_instanceId");w(this,"_isTokenRefreshing");this._authenticationClient=e,this._storageManager=this._authenticationClient.getStorageManager(),this._spaHelper=t,this._instanceId=this._authenticationClient.getInstanceId(),this._isTokenRefreshing=!1}enableHttpHandler(e){e?.enableHandler&&e.enableHandler()}disableHttpHandler(e){e?.disableHandler&&e.disableHandler()}initializeSessionManger(e,t,n,o,a){a.initialize(e.clientId,t.checkSessionIframe??"",n,e.checkSessionInterval??3,e.sessionRefreshInterval??300,e.afterSignInUrl,o)}async exchangeToken(e,t){let n=await this._storageManager.getConfigData(),o=!0,a=!1;if(e?.tokenEndpoint)if(o=!1,n.storage==="webWorker"){for(let i of[...n?.allowedExternalUrls??[],e.baseUrl])if(i&&e.tokenEndpoint?.startsWith(i)){a=!0;break}}else a=!0;return e.shouldReplayAfterRefresh&&this._storageManager.setTemporaryDataParameter(_t,JSON.stringify(e)),o||a?this._authenticationClient.exchangeToken(e).then(async i=>(t&&typeof t=="function"&&t(e),e.returnsSession?(this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser()):i)).catch(i=>Promise.reject(i)):Promise.reject(new E("SPA-MAIN_THREAD_CLIENT-RCG-IV01","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified token endpoint in this request cannot be found among the `allowedExternalUrls`"))}async getCustomGrantConfigData(){let e=await this._storageManager.getTemporaryDataParameter(_t);return e?JSON.parse(e):null}async refreshAccessToken(e){try{await this._authenticationClient.refreshAccessToken();let t=await this.getCustomGrantConfigData();return t&&await this.exchangeToken(t,e),this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser()}catch(t){let n={type:Yr};return window.postMessage(n),Promise.reject(t)}}async retryFailedRequests(e){let t=e.httpClient,n=e.requestConfig,o=e.isHttpHandlerEnabled,a=e.httpErrorCallback,i=e.httpFinishCallback;await ee.until(()=>!this._isTokenRefreshing);try{let s=await t.request(n);return Promise.resolve(s)}catch(s){return o&&(typeof a=="function"&&await a(s),typeof i=="function"&&i()),Promise.reject(s)}}async httpRequest(e,t,n,o,a,i){let s=!1,l=await this._storageManager.getConfigData();if(l.storage==="webWorker"){for(let c of[...l?.allowedExternalUrls??[],l.baseUrl])if(c&&t?.url?.startsWith(c)){s=!0;break}}else s=!0;return s?e.request(t).then(c=>Promise.resolve(c)).catch(async c=>{if(c?.response?.status===401||!c?.response){if(this._isTokenRefreshing)return this.retryFailedRequests({enableRetrievingSignOutURLFromSession:i,httpClient:e,httpErrorCallback:o,httpFinishCallback:a,isHttpHandlerEnabled:n,requestConfig:t});this._isTokenRefreshing=!0;let d;try{d=await this.refreshAccessToken(i),this._isTokenRefreshing=!1}catch(u){throw this._isTokenRefreshing=!1,n&&(typeof o=="function"&&await o({...c,code:At}),typeof a=="function"&&a()),new E("SPA-AUTH_HELPER-HR-SE01",u?.name??"Refresh token request failed.",u?.message??"An error occurred while trying to refresh the access token following a 401 response from the server.")}if(d)try{let u=await e.request(t);return Promise.resolve(u)}catch(u){return n&&(typeof o=="function"&&await o(u),typeof a=="function"&&a()),Promise.reject(u)}}return n&&(typeof o=="function"&&await o(c),typeof a=="function"&&a()),Promise.reject(c)}):Promise.reject(new E("SPA-AUTH_HELPER-HR-IV02","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified endpoint in this request cannot be found among the `allowedExternalUrls`"))}async httpRequestAll(e,t,n,o,a){let i=!0,s=await this._storageManager.getConfigData();if(s.storage==="webWorker")for(let c of e){let d=!1;for(let u of[...s?.allowedExternalUrls??[],s.baseUrl])if(u&&c.url?.startsWith(u)){d=!0;break}if(!d){i=!1;break}}let l=[];if(i)return e.forEach(c=>{l.push(t.request(c))}),t?.all&&t.all(l).then(c=>Promise.resolve(c)).catch(async c=>{if(c?.response?.status===401||!c?.response){let d;try{d=await this._authenticationClient.refreshAccessToken()}catch(u){throw n&&(typeof o=="function"&&await o({...c,code:At}),typeof a=="function"&&a()),new E("SPA-AUTH_HELPER-HRA-SE01",u?.name??"Refresh token request failed.",u?.message??"An error occurred while trying to refresh the access token following a 401 response from the server.")}if(d)return t.all&&t.all(l).then(u=>Promise.resolve(u)).catch(async u=>(n&&(typeof o=="function"&&await o(u),typeof a=="function"&&a()),Promise.reject(u)))}return n&&(typeof o=="function"&&await o(c),typeof a=="function"&&a()),Promise.reject(c)});throw new E("SPA-AUTH_HELPER-HRA-IV02","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified endpoint in this request cannot be found among the `allowedExternalUrls`")}async requestAccessToken(e,t,n,o,a,i){let s=await this._storageManager.getConfigData();if(s.storage==="browserMemory"&&s.enablePKCE&&t){let l=ee.getPKCE(oe(t));await this._authenticationClient.setPKCECode(oe(t),l)}else s.storage==="webWorker"&&o&&await this._authenticationClient.setPKCECode(o,a??"");return e?this._authenticationClient.requestAccessToken(e,t??"",a??"",void 0,i).then(async()=>(s.storage!=="webWorker"?(ee.setSignOutURL(await this._authenticationClient.getSignOutUrl(),s.clientId,this._instanceId),this._spaHelper&&(this._spaHelper.clearRefreshTokenTimeout(),this._spaHelper.refreshAccessTokenAutomatically(this)),n&&typeof n=="function"&&s.syncSession&&n()):this._spaHelper&&this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser())).catch(l=>Promise.reject(l)):Promise.reject(new E("SPA-AUTH_HELPER-RAT1-NF01","No authorization code.","No authorization code was found."))}async signInSilently(e,t,n,o,a){if(ee.isInitializedSilentSignIn())return await n.receivePromptNoneResponse(),Promise.resolve({allowedScopes:"",displayName:"",email:"",sessionState:"",sub:"",tenantDomain:"",username:""});let s=document.getElementById(Tt)?.contentDocument?.getElementById(bt);try{let l=await e(o);s.src=l}catch(l){return Promise.reject(l)}return new Promise((l,c)=>{let d=setTimeout(()=>{l(!1)},1e4),u=async p=>{let h=p.data;h?.type==St&&(window.removeEventListener("message",u),clearTimeout(d),l(!1)),h?.type==Et&&h?.data?.code&&t(h?.data?.code,h?.data?.sessionState,h?.data?.state,a).then(g=>{window.removeEventListener("message",u),l(g)}).catch(g=>{window.removeEventListener("message",u),c(g)}).finally(()=>{clearTimeout(d)})};window.addEventListener("message",u)})}async handleSignIn(e,t,n){let o=await this._storageManager.getConfigData();if(await e())return Promise.resolve({allowedScopes:"",displayName:"",email:"",sessionState:"",sub:"",tenantDomain:"",username:""});if(o.storage!=="webWorker"&&await this._authenticationClient.isSignedIn())return this._spaHelper.clearRefreshTokenTimeout(),this._spaHelper.refreshAccessTokenAutomatically(this),o.syncSession&&t(),Promise.resolve(await this._authenticationClient.getUser());let a=new URL(window.location.href).searchParams.get(ye),i=new URL(window.location.href).searchParams.get(Oe);if(a){let s=new URL(window.location.href);throw s.searchParams.delete(ye),s.searchParams.delete(Oe),history.pushState(null,document.title,s.toString()),new E("SPA-AUTH_HELPER-SI-SE01",a,i??"")}if(o.storage==="webWorker"&&n){let s=await n();if(s)return s}return Promise.resolve(void 0)}async attachTokenToRequestConfig(e){let t={attachToken:!0,...e};t.attachToken&&(t.shouldAttachIDPAccessToken?e.headers={...e.headers,Authorization:`Bearer ${await this.getIDPAccessToken()}`}:e.headers={...e.headers,Authorization:`Bearer ${await this.getAccessToken()}`})}async getUser(){return this._authenticationClient.getUser()}async getDecodedIdToken(e){return this._authenticationClient.getDecodedIdToken(e)}async getDecodedIDPIDToken(){return this._authenticationClient.getDecodedIdToken()}async getCrypto(){return this._authenticationClient.getCrypto()}async getIdToken(){return this._authenticationClient.getIdToken()}async getOpenIDProviderEndpoints(){return this._authenticationClient.getOpenIDProviderEndpoints()}async getAccessToken(e){return this._authenticationClient.getAccessToken(e)}async getIDPAccessToken(){return(await this._storageManager.getSessionData())?.access_token}getStorageManager(){return this._storageManager}async isSignedIn(){return this._authenticationClient.isSignedIn()}};var Je=class{constructor(e){w(this,"_authenticationClient");w(this,"_storageManager");w(this,"_isTokenRefreshLoading",!1);this._authenticationClient=e,this._storageManager=this._authenticationClient.getStorageManager()}async refreshAccessTokenAutomatically(e){if(!((await this._storageManager.getConfigData())?.periodicTokenRefresh??!1))return;let n=await this._storageManager.getSessionData();if(n.refresh_token){if(n.created_at==null||n.expires_in==null)return;let o=1e4,a=Number(n.expires_in)*1e3,s=n.created_at+a-Date.now()-o;if(s<=0){if(this._isTokenRefreshLoading)return;this._isTokenRefreshLoading=!0;try{await e.refreshAccessToken()}finally{this._isTokenRefreshLoading=!1}return}let l=setTimeout(async()=>{if(!this._isTokenRefreshLoading){this._isTokenRefreshLoading=!0;try{await e.refreshAccessToken()}finally{this._isTokenRefreshLoading=!1}}},s);await this._storageManager.setTemporaryDataParameter(Ce.Storage.StorageKeys.REFRESH_TOKEN_TIMER,JSON.stringify(l))}}async getRefreshTimeoutTimer(){return await this._storageManager.getTemporaryDataParameter(Ce.Storage.StorageKeys.REFRESH_TOKEN_TIMER)?JSON.parse(await this._storageManager.getTemporaryDataParameter(Ce.Storage.StorageKeys.REFRESH_TOKEN_TIMER)):-1}async clearRefreshTokenTimeout(e){if(e){clearTimeout(e);return}let t=await this.getRefreshTimeoutTimer();t!==-1&&clearTimeout(t)}};var Ge=class Ge extends Pr{static getInstance(e=0,t=!0,n=()=>Promise.resolve()){return this.instances.has(e)||this.instances.set(e,new Ge(t,n)),this.instances.get(e)}static destroyInstance(e=0){this.instances.delete(e)}async transport(e){let{attachToken:t,data:n,headers:o,method:a,params:i,shouldAttachIDPAccessToken:s,shouldEncodeToFormData:l,startTimeInMs:c,url:d,...u}=e,p=d??"";if(i){let _=new URLSearchParams(i).toString();_&&(p=`${p}${p.includes("?")?"&":"?"}${_}`)}let h={...o??{}},g;n!==void 0&&(n instanceof FormData?g=n:(g=JSON.stringify(n),!h["Content-Type"]&&!h["content-type"]&&(h["Content-Type"]="application/json")));let m;try{m=await fetch(p,{credentials:"include",...u,body:g,headers:h,method:(a??"GET").toUpperCase()})}catch(_){throw Object.assign(new Error(_.message),{code:"NETWORK_ERROR",config:e})}let b=(m.headers.get("content-type")??"").includes("application/json")?await m.json():await m.text(),S={};if(m.headers.forEach((_,A)=>{S[A]=_}),!m.ok)throw Object.assign(new Error(m.statusText),{config:e,response:{data:b,headers:S,status:m.status,statusText:m.statusText}});return{config:e,data:b,headers:S,status:m.status,statusText:m.statusText}}};w(Ge,"instances",new Map);var Ve=Ge;var Xe=class{constructor(){w(this,"_data");this._data=new Map}async setData(e,t){this._data.set(e,t)}async getData(e){return this._data?.get(e)??"{}"}async removeData(e){this._data.delete(e)}};var Fn=_e(We(),1);var qt=_e(sn(),1),Kn=_e(ln(),1);var Ee=new TextEncoder,V=new TextDecoder,Ds=2**32;function un(...r){let e=r.reduce((o,{length:a})=>o+a,0),t=new Uint8Array(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function dn(r){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(r);let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function te(r){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof r=="string"?r:V.decode(r),{alphabet:"base64url"});let e=r;e instanceof Uint8Array&&(e=V.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\\s/g,"");try{return dn(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}var B=class extends Error{constructor(t,n){super(t,n);w(this,"code","ERR_JOSE_GENERIC");this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};w(B,"code","ERR_JOSE_GENERIC");var L=class extends B{constructor(t,n,o="unspecified",a="unspecified"){super(t,{cause:{claim:o,reason:a,payload:n}});w(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");w(this,"claim");w(this,"reason");w(this,"payload");this.claim=o,this.reason=a,this.payload=n}};w(L,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");var Se=class extends B{constructor(t,n,o="unspecified",a="unspecified"){super(t,{cause:{claim:o,reason:a,payload:n}});w(this,"code","ERR_JWT_EXPIRED");w(this,"claim");w(this,"reason");w(this,"payload");this.claim=o,this.reason=a,this.payload=n}};w(Se,"code","ERR_JWT_EXPIRED");var Pe=class extends B{constructor(){super(...arguments);w(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}};w(Pe,"code","ERR_JOSE_ALG_NOT_ALLOWED");var D=class extends B{constructor(){super(...arguments);w(this,"code","ERR_JOSE_NOT_SUPPORTED")}};w(D,"code","ERR_JOSE_NOT_SUPPORTED");var x=class extends B{constructor(){super(...arguments);w(this,"code","ERR_JWS_INVALID")}};w(x,"code","ERR_JWS_INVALID");var ie=class extends B{constructor(){super(...arguments);w(this,"code","ERR_JWT_INVALID")}};w(ie,"code","ERR_JWT_INVALID");var Te=class extends B{constructor(){super(...arguments);w(this,"code","ERR_JWKS_INVALID")}};w(Te,"code","ERR_JWKS_INVALID");var ke=class extends B{constructor(t="no applicable key found in the JSON Web Key Set",n){super(t,n);w(this,"code","ERR_JWKS_NO_MATCHING_KEY")}};w(ke,"code","ERR_JWKS_NO_MATCHING_KEY");var fn,pn,Ue=class extends(pn=B,fn=Symbol.asyncIterator,pn){constructor(t="multiple matching keys found in the JSON Web Key Set",n){super(t,n);w(this,fn);w(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}};w(Ue,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");var Ne=class extends B{constructor(t="signature verification failed",n){super(t,n);w(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}};w(Ne,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");function G(r,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${r}`)}function De(r,e){return r.name===e}function Ut(r){return parseInt(r.name.slice(4),10)}function Aa(r){switch(r){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Ca(r,e){if(e&&!r.usages.includes(e))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${e}.`)}function hn(r,e,t){switch(e){case"HS256":case"HS384":case"HS512":{if(!De(r.algorithm,"HMAC"))throw G("HMAC");let n=parseInt(e.slice(2),10);if(Ut(r.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!De(r.algorithm,"RSASSA-PKCS1-v1_5"))throw G("RSASSA-PKCS1-v1_5");let n=parseInt(e.slice(2),10);if(Ut(r.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!De(r.algorithm,"RSA-PSS"))throw G("RSA-PSS");let n=parseInt(e.slice(2),10);if(Ut(r.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"Ed25519":case"EdDSA":{if(!De(r.algorithm,"Ed25519"))throw G("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!De(r.algorithm,"ECDSA"))throw G("ECDSA");let n=Aa(e);if(r.algorithm.namedCurve!==n)throw G(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Ca(r,t)}function gn(r,e,...t){if(t=t.filter(Boolean),t.length>2){let n=t.pop();r+=`one of type ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of type ${t[0]} or ${t[1]}.`:r+=`of type ${t[0]}.`;return e==null?r+=` Received ${e}`:typeof e=="function"&&e.name?r+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&e.constructor?.name&&(r+=` Received an instance of ${e.constructor.name}`),r}var mn=(r,...e)=>gn("Key must be ",r,...e);function Nt(r,e,...t){return gn(`Key for the ${r} algorithm must be `,e,...t)}function Dt(r){return r?.[Symbol.toStringTag]==="CryptoKey"}function Mt(r){return r?.[Symbol.toStringTag]==="KeyObject"}var Lt=r=>Dt(r)||Mt(r);var yn=(...r)=>{let e=r.filter(Boolean);if(e.length===0||e.length===1)return!0;let t;for(let n of e){let o=Object.keys(n);if(!t||t.size===0){t=new Set(o);continue}for(let a of o){if(t.has(a))return!1;t.add(a)}}return!0};function Oa(r){return typeof r=="object"&&r!==null}var K=r=>{if(!Oa(r)||Object.prototype.toString.call(r)!=="[object Object]")return!1;if(Object.getPrototypeOf(r)===null)return!0;let e=r;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(r)===e};var wn=(r,e)=>{if(r.startsWith("RS")||r.startsWith("PS")){let{modulusLength:t}=e.algorithm;if(typeof t!="number"||t<2048)throw new TypeError(`${r} requires key modulusLength to be 2048 bits or larger`)}};function Pa(r){let e,t;switch(r.kty){case"RSA":{switch(r.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${r.alg.slice(-3)}`},t=r.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${r.alg.slice(-3)}`},t=r.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(r.alg.slice(-3),10)||1}`},t=r.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new D(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}case"EC":{switch(r.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},t=r.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},t=r.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},t=r.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:r.crv},t=r.d?["deriveBits"]:[];break;default:throw new D(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}case"OKP":{switch(r.alg){case"Ed25519":case"EdDSA":e={name:"Ed25519"},t=r.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:r.crv},t=r.d?["deriveBits"]:[];break;default:throw new D(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}default:throw new D(\'Invalid or unsupported JWK "kty" (Key Type) Parameter value\')}return{algorithm:e,keyUsages:t}}var Qe=async r=>{if(!r.alg)throw new TypeError(\'"alg" argument is required when "jwk.alg" is not present\');let{algorithm:e,keyUsages:t}=Pa(r),n={...r};return delete n.alg,delete n.use,crypto.subtle.importKey("jwk",n,e,r.ext??!r.d,r.key_ops??t)};async function En(r,e,t){if(!K(r))throw new TypeError("JWK must be an object");let n;switch(e??(e=r.alg),n??(n=t?.extractable??r.ext),r.kty){case"oct":if(typeof r.k!="string"||!r.k)throw new TypeError(\'missing "k" (Key Value) Parameter value\');return te(r.k);case"RSA":if("oth"in r&&r.oth!==void 0)throw new D(\'RSA JWK "oth" (Other Primes Info) Parameter value is not supported\');case"EC":case"OKP":return Qe({...r,alg:e,ext:n});default:throw new D(\'Unsupported "kty" (Key Type) Parameter value\')}}var Sn=(r,e,t,n,o)=>{if(o.crit!==void 0&&n?.crit===void 0)throw new r(\'"crit" (Critical) Header Parameter MUST be integrity protected\');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(i=>typeof i!="string"||i.length===0))throw new r(\'"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present\');let a;t!==void 0?a=new Map([...Object.entries(t),...e.entries()]):a=e;for(let i of n.crit){if(!a.has(i))throw new D(`Extension Header Parameter "${i}" is not recognized`);if(o[i]===void 0)throw new r(`Extension Header Parameter "${i}" is missing`);if(a.get(i)&&n[i]===void 0)throw new r(`Extension Header Parameter "${i}" MUST be integrity protected`)}return new Set(n.crit)};var Tn=(r,e)=>{if(e!==void 0&&(!Array.isArray(e)||e.some(t=>typeof t!="string")))throw new TypeError(`"${r}" option must be an array of strings`);if(e)return new Set(e)};function Me(r){return K(r)&&typeof r.kty=="string"}function bn(r){return r.kty!=="oct"&&typeof r.d=="string"}function In(r){return r.kty!=="oct"&&typeof r.d>"u"}function Rn(r){return r.kty==="oct"&&typeof r.k=="string"}var be,vn=async(r,e,t,n=!1)=>{be||(be=new WeakMap);let o=be.get(r);if(o?.[t])return o[t];let a=await Qe({...e,alg:t});return n&&Object.freeze(r),o?o[t]=a:be.set(r,{[t]:a}),a},Ua=(r,e)=>{be||(be=new WeakMap);let t=be.get(r);if(t?.[e])return t[e];let n=r.type==="public",o=!!n,a;if(r.asymmetricKeyType==="x25519"){switch(e){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}a=r.toCryptoKey(r.asymmetricKeyType,o,n?[]:["deriveBits"])}if(r.asymmetricKeyType==="ed25519"){if(e!=="EdDSA"&&e!=="Ed25519")throw new TypeError("given KeyObject instance cannot be used for this algorithm");a=r.toCryptoKey(r.asymmetricKeyType,o,[n?"verify":"sign"])}if(r.asymmetricKeyType==="rsa"){let i;switch(e){case"RSA-OAEP":i="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":i="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":i="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":i="SHA-512";break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}if(e.startsWith("RSA-OAEP"))return r.toCryptoKey({name:"RSA-OAEP",hash:i},o,n?["encrypt"]:["decrypt"]);a=r.toCryptoKey({name:e.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:i},o,[n?"verify":"sign"])}if(r.asymmetricKeyType==="ec"){let s=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(r.asymmetricKeyDetails?.namedCurve);if(!s)throw new TypeError("given KeyObject instance cannot be used for this algorithm");e==="ES256"&&s==="P-256"&&(a=r.toCryptoKey({name:"ECDSA",namedCurve:s},o,[n?"verify":"sign"])),e==="ES384"&&s==="P-384"&&(a=r.toCryptoKey({name:"ECDSA",namedCurve:s},o,[n?"verify":"sign"])),e==="ES512"&&s==="P-521"&&(a=r.toCryptoKey({name:"ECDSA",namedCurve:s},o,[n?"verify":"sign"])),e.startsWith("ECDH-ES")&&(a=r.toCryptoKey({name:"ECDH",namedCurve:s},o,n?[]:["deriveBits"]))}if(!a)throw new TypeError("given KeyObject instance cannot be used for this algorithm");return t?t[e]=a:be.set(r,{[e]:a}),a},_n=async(r,e)=>{if(r instanceof Uint8Array||Dt(r))return r;if(Mt(r)){if(r.type==="secret")return r.export();if("toCryptoKey"in r&&typeof r.toCryptoKey=="function")try{return Ua(r,e)}catch(n){if(n instanceof TypeError)throw n}let t=r.export({format:"jwk"});return vn(r,t,e)}if(Me(r))return r.k?te(r.k):vn(r,r,e,!0);throw new Error("unreachable")};var Ie=r=>r?.[Symbol.toStringTag],Bt=(r,e,t)=>{if(e.use!==void 0){let n;switch(t){case"sign":case"verify":n="sig";break;case"encrypt":case"decrypt":n="enc";break}if(e.use!==n)throw new TypeError(`Invalid key for this operation, its "use" must be "${n}" when present`)}if(e.alg!==void 0&&e.alg!==r)throw new TypeError(`Invalid key for this operation, its "alg" must be "${r}" when present`);if(Array.isArray(e.key_ops)){let n;switch(!0){case(t==="sign"||t==="verify"):case r==="dir":case r.includes("CBC-HS"):n=t;break;case r.startsWith("PBES2"):n="deriveBits";break;case/^A\\d{3}(?:GCM)?(?:KW)?$/.test(r):!r.includes("GCM")&&r.endsWith("KW")?n=t==="encrypt"?"wrapKey":"unwrapKey":n=t;break;case(t==="encrypt"&&r.startsWith("RSA")):n="wrapKey";break;case t==="decrypt":n=r.startsWith("RSA")?"unwrapKey":"deriveBits";break}if(n&&e.key_ops?.includes?.(n)===!1)throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${n}" when present`)}return!0},Na=(r,e,t)=>{if(!(e instanceof Uint8Array)){if(Me(e)){if(Rn(e)&&Bt(r,e,t))return;throw new TypeError(\'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present\')}if(!Lt(e))throw new TypeError(Nt(r,e,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(e.type!=="secret")throw new TypeError(`${Ie(e)} instances for symmetric algorithms must be of type "secret"`)}},Da=(r,e,t)=>{if(Me(e))switch(t){case"decrypt":case"sign":if(bn(e)&&Bt(r,e,t))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"encrypt":case"verify":if(In(e)&&Bt(r,e,t))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!Lt(e))throw new TypeError(Nt(r,e,"CryptoKey","KeyObject","JSON Web Key"));if(e.type==="secret")throw new TypeError(`${Ie(e)} instances for asymmetric algorithms must not be of type "secret"`);if(e.type==="public")switch(t){case"sign":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm decryption must be of type "private"`);default:break}if(e.type==="private")switch(t){case"verify":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm encryption must be of type "public"`);default:break}},xn=(r,e,t)=>{r.startsWith("HS")||r==="dir"||r.startsWith("PBES2")||/^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(r)||/^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(r)?Na(r,e,t):Da(r,e,t)};var An=(r,e)=>{let t=`SHA-${r.slice(-3)}`;switch(r){case"HS256":case"HS384":case"HS512":return{hash:t,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:t,name:"RSA-PSS",saltLength:parseInt(r.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:t,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:t,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};default:throw new D(`alg ${r} is not supported either by JOSE or your javascript runtime`)}};var Cn=async(r,e,t)=>{if(e instanceof Uint8Array){if(!r.startsWith("HS"))throw new TypeError(mn(e,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",e,{hash:`SHA-${r.slice(-3)}`,name:"HMAC"},!1,[t])}return hn(e,r,t),e};var On=async(r,e,t,n)=>{let o=await Cn(r,e,"verify");wn(r,o);let a=An(r,o.algorithm);try{return await crypto.subtle.verify(a,o,t,n)}catch{return!1}};async function Pn(r,e,t){if(!K(r))throw new x("Flattened JWS must be an object");if(r.protected===void 0&&r.header===void 0)throw new x(\'Flattened JWS must have either of the "protected" or "header" members\');if(r.protected!==void 0&&typeof r.protected!="string")throw new x("JWS Protected Header incorrect type");if(r.payload===void 0)throw new x("JWS Payload missing");if(typeof r.signature!="string")throw new x("JWS Signature missing or incorrect type");if(r.header!==void 0&&!K(r.header))throw new x("JWS Unprotected Header incorrect type");let n={};if(r.protected)try{let T=te(r.protected);n=JSON.parse(V.decode(T))}catch{throw new x("JWS Protected Header is invalid")}if(!yn(n,r.header))throw new x("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let o={...n,...r.header},a=Sn(x,new Map([["b64",!0]]),t?.crit,n,o),i=!0;if(a.has("b64")&&(i=n.b64,typeof i!="boolean"))throw new x(\'The "b64" (base64url-encode payload) Header Parameter must be a boolean\');let{alg:s}=o;if(typeof s!="string"||!s)throw new x(\'JWS "alg" (Algorithm) Header Parameter missing or invalid\');let l=t&&Tn("algorithms",t.algorithms);if(l&&!l.has(s))throw new Pe(\'"alg" (Algorithm) Header Parameter value not allowed\');if(i){if(typeof r.payload!="string")throw new x("JWS Payload must be a string")}else if(typeof r.payload!="string"&&!(r.payload instanceof Uint8Array))throw new x("JWS Payload must be a string or an Uint8Array instance");let c=!1;typeof e=="function"&&(e=await e(n,r),c=!0),xn(s,e,"verify");let d=un(Ee.encode(r.protected??""),Ee.encode("."),typeof r.payload=="string"?Ee.encode(r.payload):r.payload),u;try{u=te(r.signature)}catch{throw new x("Failed to base64url decode the signature")}let p=await _n(e,s);if(!await On(s,p,u,d))throw new Ne;let g;if(i)try{g=te(r.payload)}catch{throw new x("Failed to base64url decode the payload")}else typeof r.payload=="string"?g=Ee.encode(r.payload):g=r.payload;let m={payload:g};return r.protected!==void 0&&(m.protectedHeader=n),r.header!==void 0&&(m.unprotectedHeader=r.header),c?{...m,key:p}:m}async function kn(r,e,t){if(r instanceof Uint8Array&&(r=V.decode(r)),typeof r!="string")throw new x("Compact JWS must be a string or Uint8Array");let{0:n,1:o,2:a,length:i}=r.split(".");if(i!==3)throw new x("Invalid Compact JWS");let s=await Pn({payload:o,protected:n,signature:a},e,t),l={payload:s.payload,protectedHeader:s.protectedHeader};return typeof e=="function"?{...l,key:s.key}:l}var Un=r=>Math.floor(r.getTime()/1e3);var Ma=/^(\\+|\\-)? ?(\\d+|\\d+\\.\\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Ht=r=>{let e=Ma.exec(r);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");let t=parseFloat(e[2]),n=e[3].toLowerCase(),o;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(t);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(t*60);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(t*3600);break;case"day":case"days":case"d":o=Math.round(t*86400);break;case"week":case"weeks":case"w":o=Math.round(t*604800);break;default:o=Math.round(t*31557600);break}return e[1]==="-"||e[4]==="ago"?-o:o};var Nn=r=>r.includes("/")?r.toLowerCase():`application/${r.toLowerCase()}`,La=(r,e)=>typeof r=="string"?e.includes(r):Array.isArray(r)?e.some(Set.prototype.has.bind(new Set(r))):!1;function Dn(r,e,t={}){let n;try{n=JSON.parse(V.decode(e))}catch{}if(!K(n))throw new ie("JWT Claims Set must be a top-level JSON object");let{typ:o}=t;if(o&&(typeof r.typ!="string"||Nn(r.typ)!==Nn(o)))throw new L(\'unexpected "typ" JWT header value\',n,"typ","check_failed");let{requiredClaims:a=[],issuer:i,subject:s,audience:l,maxTokenAge:c}=t,d=[...a];c!==void 0&&d.push("iat"),l!==void 0&&d.push("aud"),s!==void 0&&d.push("sub"),i!==void 0&&d.push("iss");for(let g of new Set(d.reverse()))if(!(g in n))throw new L(`missing required "${g}" claim`,n,g,"missing");if(i&&!(Array.isArray(i)?i:[i]).includes(n.iss))throw new L(\'unexpected "iss" claim value\',n,"iss","check_failed");if(s&&n.sub!==s)throw new L(\'unexpected "sub" claim value\',n,"sub","check_failed");if(l&&!La(n.aud,typeof l=="string"?[l]:l))throw new L(\'unexpected "aud" claim value\',n,"aud","check_failed");let u;switch(typeof t.clockTolerance){case"string":u=Ht(t.clockTolerance);break;case"number":u=t.clockTolerance;break;case"undefined":u=0;break;default:throw new TypeError("Invalid clockTolerance option type")}let{currentDate:p}=t,h=Un(p||new Date);if((n.iat!==void 0||c)&&typeof n.iat!="number")throw new L(\'"iat" claim must be a number\',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!="number")throw new L(\'"nbf" claim must be a number\',n,"nbf","invalid");if(n.nbf>h+u)throw new L(\'"nbf" claim timestamp check failed\',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!="number")throw new L(\'"exp" claim must be a number\',n,"exp","invalid");if(n.exp<=h-u)throw new Se(\'"exp" claim timestamp check failed\',n,"exp","check_failed")}if(c){let g=h-n.iat,m=typeof c=="number"?c:Ht(c);if(g-u>m)throw new Se(\'"iat" claim timestamp check failed (too far in the past)\',n,"iat","check_failed");if(g<0-u)throw new L(\'"iat" claim timestamp check failed (it should be in the past)\',n,"iat","check_failed")}return n}async function $t(r,e,t){let n=await kn(r,e,t);if(n.protectedHeader.crit?.includes("b64")&&n.protectedHeader.b64===!1)throw new ie("JWTs MUST NOT use unencoded payload");let a={payload:Dn(n.protectedHeader,n.payload,t),protectedHeader:n.protectedHeader};return typeof e=="function"?{...a,key:n.key}:a}function Ba(r){switch(typeof r=="string"&&r.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new D(\'Unsupported "alg" value for a JSON Web Key Set\')}}function Ha(r){return r&&typeof r=="object"&&Array.isArray(r.keys)&&r.keys.every($a)}function $a(r){return K(r)}var Re,Le,Ft=class{constructor(e){He(this,Re);He(this,Le,new WeakMap);if(!Ha(e))throw new Te("JSON Web Key Set malformed");ot(this,Re,structuredClone(e))}jwks(){return ue(this,Re)}async getKey(e,t){let{alg:n,kid:o}={...e,...t?.header},a=Ba(n),i=ue(this,Re).keys.filter(c=>{let d=a===c.kty;if(d&&typeof o=="string"&&(d=o===c.kid),d&&typeof c.alg=="string"&&(d=n===c.alg),d&&typeof c.use=="string"&&(d=c.use==="sig"),d&&Array.isArray(c.key_ops)&&(d=c.key_ops.includes("verify")),d)switch(n){case"ES256":d=c.crv==="P-256";break;case"ES384":d=c.crv==="P-384";break;case"ES512":d=c.crv==="P-521";break;case"Ed25519":case"EdDSA":d=c.crv==="Ed25519";break}return d}),{0:s,length:l}=i;if(l===0)throw new ke;if(l!==1){let c=new Ue,d=ue(this,Le);throw c[Symbol.asyncIterator]=async function*(){for(let u of i)try{yield await Mn(d,u,n)}catch{}},c}return Mn(ue(this,Le),s,n)}};Re=new WeakMap,Le=new WeakMap;async function Mn(r,e,t){let n=r.get(e)||r.set(e,{}).get(e);if(n[t]===void 0){let o=await En({...e,ext:!0},t);if(o instanceof Uint8Array||o.type!=="public")throw new Te("JSON Web Key Set members must be public keys");n[t]=o}return n[t]}function Kt(r){let e=new Ft(r),t=async(n,o)=>e.getKey(n,o);return Object.defineProperties(t,{jwks:{value:()=>structuredClone(e.jwks()),enumerable:!1,configurable:!1,writable:!1}}),t}var Wn=_e($n(),1),rt=class{base64URLEncode(e){return qt.default.encode(e).replace(/\\+/g,"-").replace(/\\//g,"_").replace(/=/g,"")}base64URLDecode(e){return qt.default.decode(e).toString()}hashSha256(e){return Fn.Buffer.from((0,Kn.default)(new TextEncoder().encode(e)))}generateRandomBytes(e){return(0,Wn.default)(e)}verifyJwt(e,t,n,o,a,i,s,l){let c={algorithms:n,audience:[o],clockTolerance:s,subject:i};return(l??!0)&&(c.issuer=a),$t(e,Kt({keys:[t]}),c).then(()=>Promise.resolve(!0)).catch(d=>Promise.reject(new E("SPA-CRYPTO-UTILS-VJ-IV01",d?.reason??JSON.stringify(d),`${d?.code} ${d?.claim}`)))}};var jn=async(r,e,t)=>{let n=new Xe,o=new rt,a=new ae;await a.initialize(e,n,o,r);let i=new Je(a),s=t(a,i),l=a.getStorageManager(),c=async I=>{await s.attachTokenToRequestConfig(I)},d=Ve.getInstance(r,!0,c);return{disableHttpHandler:()=>{s.disableHttpHandler(d)},enableHttpHandler:()=>{s.enableHttpHandler(d)},getAccessToken:()=>s.getAccessToken(),getSignInUrl:async I=>a.getSignInUrl(I).then(async X=>{let nt=new URL(X).searchParams.get(N.Params.STATE)??"",Jn=await a.getPKCECode(nt);return{authorizationURL:X,pkce:Jn}}).catch(X=>Promise.reject(X)),getUser:async()=>s.getUser(),getConfigData:async()=>l.getConfigData(),getCrypto:async()=>s.getCrypto(),getDecodedIDPIDToken:async()=>s.getDecodedIDPIDToken(),getDecodedIdToken:async I=>s.getDecodedIdToken(I),getIdToken:async()=>s.getIdToken(),getOpenIDProviderEndpoints:async()=>s.getOpenIDProviderEndpoints(),getSignOutUrl:async()=>await a.getSignOutUrl(),httpRequest:async I=>await s.httpRequest(d,I),httpRequestAll:async I=>await s.httpRequestAll(I,d),isSignedIn:()=>s.isSignedIn(),refreshAccessToken:async()=>{try{return await s.refreshAccessToken()}catch(I){return Promise.reject(I)}},requestAccessToken:async(I,X,Jt,nt)=>await s.requestAccessToken(I,X,void 0,Jt,nt),exchangeToken:async I=>await s.exchangeToken(I),revokeAccessToken:async()=>{let I=await i.getRefreshTimeoutTimer();return a.revokeAccessToken().then(()=>(i.clearRefreshTokenTimeout(I),Promise.resolve(!0))).catch(X=>Promise.reject(X))},setHttpRequestFinishCallback:I=>{d?.setHttpRequestFinishCallback&&d.setHttpRequestFinishCallback(I)},setHttpRequestStartCallback:I=>{d?.setHttpRequestStartCallback&&d.setHttpRequestStartCallback(I)},setHttpRequestSuccessCallback:I=>{d?.setHttpRequestSuccessCallback&&d.setHttpRequestSuccessCallback(I)},setSessionState:async I=>{await l.setSessionDataParameter(N.Params.SESSION_STATE,I)},signOut:async()=>(i.clearRefreshTokenTimeout(),await a.getSignOutUrl()),startAutoRefreshToken:async()=>{i.clearRefreshTokenTimeout(),i.refreshAccessTokenAutomatically(s)},reInitialize:async I=>{await a.reInitialize(I)}}};var zn=r=>{let e=self,t;e.onmessage=async({data:i,ports:s})=>{let l=s[0];if(i.type!==wt&&!t){l.postMessage(y.generateFailureMessage(new E("SPA-CLIENT_WORKER-ONMSG-NF01","The web worker has not been initialized yet.","The initialize method needs to be called before the specified operation can be carried out.")));return}switch(i.type){case wt:try{let c=i.instanceId??0,d={...i.data};t=await jn(c,d,r),t.setHttpRequestFinishCallback(a),t.setHttpRequestStartCallback(n),t.setHttpRequestSuccessCallback(o),l.postMessage(y.generateSuccessMessage())}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case qr:t.getSignInUrl(i?.data).then(c=>{l.postMessage(y.generateSuccessMessage(c))}).catch(c=>{l.postMessage(y.generateFailureMessage(c))});break;case Jr:t.requestAccessToken(i?.data?.code,i?.data?.sessionState,i?.data?.pkce,i?.data?.state).then(c=>{l.postMessage(y.generateSuccessMessage(c))}).catch(c=>{l.postMessage(y.generateFailureMessage(c))});break;case Ur:{let c=i.data,d=c?.data;if(i.data?.data?.formData===!0){let u=new FormData;for(let p in d)p!=="formData"&&u.append(p,d[p]);c.data=u}t.httpRequest(c).then(u=>{l.postMessage(y.generateSuccessMessage(u))}).catch(u=>{l.postMessage(y.generateFailureMessage(u))});break}case Nr:t.httpRequestAll(i.data).then(c=>{l.postMessage(y.generateSuccessMessage(c))}).catch(c=>{l.postMessage(y.generateFailureMessage(c))});break;case kr:try{l.postMessage(y.generateSuccessMessage(await t.signOut()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Dr:t.exchangeToken(i.data).then(c=>{l.postMessage(y.generateSuccessMessage(c))}).catch(c=>{l.postMessage(y.generateFailureMessage(c))});break;case Mr:t.revokeAccessToken().then(c=>{l.postMessage(y.generateSuccessMessage(c))}).catch(c=>{l.postMessage(y.generateFailureMessage(c))});break;case $r:try{l.postMessage(y.generateSuccessMessage(await t.getOpenIDProviderEndpoints()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Fr:try{l.postMessage(y.generateSuccessMessage(await t.getUser()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Kr:try{l.postMessage(y.generateSuccessMessage(await t.getDecodedIdToken()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Wr:try{l.postMessage(y.generateSuccessMessage(await t.getCrypto()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case tn:try{l.postMessage(y.generateSuccessMessage(await t.getIdToken()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case jr:t.enableHttpHandler(),l.postMessage(y.generateSuccessMessage());break;case zr:t.disableHttpHandler(),l.postMessage(y.generateSuccessMessage());break;case Vr:try{l.postMessage(y.generateSuccessMessage(await t.isSignedIn()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Gr:try{l.postMessage(y.generateSuccessMessage(await t.getSignOutUrl()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Xr:try{l.postMessage(y.generateSuccessMessage(await t.refreshAccessToken()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Qr:try{l.postMessage(y.generateSuccessMessage(t.startAutoRefreshToken()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case Zr:try{l.postMessage(y.generateSuccessMessage(await t.setSessionState(i?.data)))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case en:try{l.postMessage(y.generateSuccessMessage(await t.reInitialize(i?.data)))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;case rn:try{l.postMessage(y.generateSuccessMessage(await t.getConfigData()))}catch(c){l.postMessage(y.generateFailureMessage(c))}break;default:l?.postMessage(y.generateFailureMessage(new E("SPA-CLIENT_WORKER-ONMSG-IV02","The message type is invalid.",`The message type provided, ${i.type}, is invalid.`)))}};let n=()=>{e.postMessage({type:Lr})},o=i=>{e.postMessage({data:JSON.stringify(i??""),type:Br})},a=()=>{e.postMessage({type:Hr})}};typeof self<"u"&&!self.Buffer&&(self.Buffer=qn.Buffer);typeof self<"u"&&(self.global||(self.global=self));zn((r,e)=>new qe(r,e));var Hl={};})();\n/*! Bundled license information:\n\nieee754/index.js:\n (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)\n\nbuffer/index.js:\n (*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh <https://feross.org>\n * @license MIT\n *)\n\nsafe-buffer/index.js:\n (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)\n*/\n');
|
|
1957
1957
|
}
|
|
1958
1958
|
|
|
1959
1959
|
// src/__legacy__/clients/main-thread-client.ts
|