@descope/react-sdk 2.0.6 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Descope={},e.React)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(t);const r=o.default.createContext(void 0),i=e=>(...t)=>{if(!e)throw Error("You can only use this function after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component");return e(...t)},s=e=>(...t)=>{let n;try{n=e(...t)}catch(e){console.error(e)}return n},a={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.0.6"},c="undefined"!=typeof window;var l=function(){return l=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},l.apply(this,arguments)};function d(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function u(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function h(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function p(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function f(e){this.message=e}"function"==typeof SuppressedError&&SuppressedError,f.prototype=new Error,f.prototype.name="InvalidCharacterError";var g="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new f("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,r=0,i=0,s="";o=t.charAt(i++);~o&&(n=r%4?64*n+o:o,r++%4)?s+=String.fromCharCode(255&n>>(-2*r&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function v(e){this.message=e}function m(e,t){if("string"!=typeof e)throw new v("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(g(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return g(t)}}(e.split(".")[n]))}catch(e){throw new v("Invalid token specified: "+e.message)}}v.prototype=new Error,v.prototype.name="InvalidTokenError";var b="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function y(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var w="__lodash_hash_undefined__",k="[object Function]",E="[object GeneratorFunction]",I=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,x=/^\w*$/,O=/^\./,j=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,C=/\\(\\)?/g,S=/^\[object .+?Constructor\]$/,_="object"==typeof b&&b&&b.Object===Object&&b,A="object"==typeof self&&self&&self.Object===Object&&self,N=_||A||Function("return this")();var R,U=Array.prototype,M=Function.prototype,T=Object.prototype,D=N["__core-js_shared__"],P=(R=/[^.]+$/.exec(D&&D.keys&&D.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"",L=M.toString,$=T.hasOwnProperty,W=T.toString,z=RegExp("^"+L.call($).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),F=N.Symbol,V=U.splice,q=te(N,"Map"),H=te(Object,"create"),B=F?F.prototype:void 0,K=B?B.toString:void 0;function J(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function Y(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function G(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function X(e,t){for(var n,o,r=e.length;r--;)if((n=e[r][0])===(o=t)||n!=n&&o!=o)return r;return-1}function Z(e,t){var n;t=function(e,t){if(ie(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||ae(e))return!0;return x.test(e)||!I.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:ie(n=t)?n:ne(n);for(var o=0,r=t.length;null!=e&&o<r;)e=e[oe(t[o++])];return o&&o==r?e:void 0}function Q(e){if(!se(e)||(t=e,P&&P in t))return!1;var t,n=function(e){var t=se(e)?W.call(e):"";return t==k||t==E}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?z:S;return n.test(function(e){if(null!=e){try{return L.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function ee(e,t){var n,o,r=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof t?"string":"hash"]:r.map}function te(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Q(n)?n:void 0}J.prototype.clear=function(){this.__data__=H?H(null):{}},J.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},J.prototype.get=function(e){var t=this.__data__;if(H){var n=t[e];return n===w?void 0:n}return $.call(t,e)?t[e]:void 0},J.prototype.has=function(e){var t=this.__data__;return H?void 0!==t[e]:$.call(t,e)},J.prototype.set=function(e,t){return this.__data__[e]=H&&void 0===t?w:t,this},Y.prototype.clear=function(){this.__data__=[]},Y.prototype.delete=function(e){var t=this.__data__,n=X(t,e);return!(n<0)&&(n==t.length-1?t.pop():V.call(t,n,1),!0)},Y.prototype.get=function(e){var t=this.__data__,n=X(t,e);return n<0?void 0:t[n][1]},Y.prototype.has=function(e){return X(this.__data__,e)>-1},Y.prototype.set=function(e,t){var n=this.__data__,o=X(n,e);return o<0?n.push([e,t]):n[o][1]=t,this},G.prototype.clear=function(){this.__data__={hash:new J,map:new(q||Y),string:new J}},G.prototype.delete=function(e){return ee(this,e).delete(e)},G.prototype.get=function(e){return ee(this,e).get(e)},G.prototype.has=function(e){return ee(this,e).has(e)},G.prototype.set=function(e,t){return ee(this,e).set(e,t),this};var ne=re((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ae(e))return K?K.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return O.test(e)&&n.push(""),e.replace(j,(function(e,t,o,r){n.push(o?r.replace(C,"$1"):t||e)})),n}));function oe(e){if("string"==typeof e||ae(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function re(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var o=arguments,r=t?t.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var s=e.apply(this,o);return n.cache=i.set(r,s),s};return n.cache=new(re.Cache||G),n}re.Cache=G;var ie=Array.isArray;function se(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ae(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==W.call(e)}var ce=y((function(e,t,n){var o=null==e?void 0:Z(e,t);return void 0===o?n:o})),le="/v1/auth/accesskey/exchange",de="/v1/auth/otp/verify",ue="/v1/auth/otp/signin",he="/v1/auth/otp/signup",pe={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},fe="/v1/auth/otp/signup-in",ge="/v1/auth/magiclink/verify",ve="/v1/auth/magiclink/signin",me="/v1/auth/magiclink/signup",be={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ye="/v1/auth/magiclink/signup-in",we="/v1/auth/enchantedlink/verify",ke="/v1/auth/enchantedlink/signin",Ee="/v1/auth/enchantedlink/signup",Ie="/v1/auth/enchantedlink/pending-session",xe={email:"/v1/auth/enchantedlink/update/email"},Oe="/v1/auth/enchantedlink/signup-in",je="/v1/auth/oauth/authorize",Ce="/v1/auth/oauth/exchange",Se="v1/auth/oauth/native/start",_e="v1/auth/oauth/native/finish",Ae="/v1/auth/saml/authorize",Ne="/v1/auth/saml/exchange",Re="/v1/auth/totp/verify",Ue="/v1/auth/totp/signup",Me="/v1/auth/totp/update",Te={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},De={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Pe={start:"/v1/auth/webauthn/signup-in/start"},Le={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},$e="/v1/auth/password/signup",We="/v1/auth/password/signin",ze="/v1/auth/password/reset",Fe="/v1/auth/password/update",Ve="/v1/auth/password/replace",qe="/v1/auth/password/policy",He="/v1/auth/refresh",Be="/v1/auth/tenant/select",Ke="/v1/auth/logout",Je="/v1/auth/logoutall",Ye="/v1/auth/me",Ge="/v1/auth/me/history",Xe="/v1/flow/start",Ze="/v1/flow/next";const Qe="<region>",et=`https://api.${Qe}descope.com`,tt=6e5,nt=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};var ot;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(ot||(ot={}));const rt=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),it=e=>void 0===e?void 0:JSON.stringify(e),st=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},at=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:r,cookiePolicy:i,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>nt().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return nt().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,s),c=async o=>{const s=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:c,body:l,headers:d,queryParams:u,method:h,token:p}=s,f={headers:rt(st(t,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.10.0"},(null==n?void 0:n.baseHeaders)||{},d),method:h,body:it(l)};null!==i&&(f.credentials=i||"include");const g=await a((({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(Qe,r?r+".":"");const i=new URL(e,t);return n&&(i.search=new URLSearchParams(n).toString()),i})({path:c,baseUrl:e,queryParams:u,projectId:t}),f);return(null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==g?void 0:g.clone()),g};return{get:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:ot.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:ot.post,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:ot.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:ot.delete,token:o}),hooks:r}};var ct=429;function lt(e,t,n){var o;let r=dt(e);t&&(r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]);const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function dt(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return m(e)}function ut(e){const{exp:t}=dt(e);return(new Date).getTime()/1e3>t}function ht(e){let t=dt(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function pt(e,t){return lt(e,t,"permissions")}function ft(e,t){return lt(e,t,"roles")}const gt=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function vt(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=t?t(i):i:(r.error=i,o.status===ct&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}const mt=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),bt=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),yt=e=>t=>e.test(t),wt=yt(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),kt=yt(/^\+[1-9]{1}[0-9]{3,14}$/),Et=mt(wt,'"{val}" is not a valid email'),It=mt(kt,'"{val}" is not a valid phone number'),xt=mt((1,e=>e.length>=1),"Minimum length is 1");const Ot=mt((e=>"string"==typeof e),"Input is not a string"),jt=mt((e=>void 0===e),"Input is defined"),Ct=(St=[Ot(),jt()],"Input is not a string or undefined",(e="Input is not a string or undefined")=>t=>{const n=St.filter((e=>e(t)));return!(n.length<St.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var St;const _t=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>bt(...e).validate(n[t]))),t(...n)),At=e=>[Ot(`"${e}" must be a string`),xt(`"${e}" must not be empty`)],Nt=e=>[Ot(`"${e}" must be a string`),Et()],Rt=e=>[Ot(`"${e}" must be a string`),It()],Ut=_t(At("accessKey")),Mt=e=>({exchange:Ut((t=>vt(e.post(le,{},{token:t}))))});var Tt,Dt;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Tt||(Tt={})),function(e){e.email="email"}(Dt||(Dt={}));const Pt=Object.assign(Object.assign({},Tt),Dt);var Lt;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Lt||(Lt={}));const $t=At("loginId"),Wt=_t(At("token")),zt=_t($t),Ft=_t(At("pendingRef")),Vt=_t($t,Nt("email")),qt=e=>({verify:Wt((t=>vt(e.post(we,{token:t})))),signIn:zt(((t,n,o,r)=>vt(e.post(gt(ke,Pt.email),{loginId:t,URI:n,loginOptions:o},{token:r})))),signUpOrIn:zt(((t,n,o)=>vt(e.post(gt(Oe,Pt.email),{loginId:t,URI:n,loginOptions:o})))),signUp:zt(((t,n,o,r)=>vt(e.post(gt(Ee,Pt.email),{loginId:t,URI:n,user:o,loginOptions:r})))),waitForSession:Ft(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||tt,tt)}))(n);let s;const a=setInterval((async()=>{const n=await e.post(Ie,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(vt(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:Vt(((t,n,o,r,i)=>vt(e.post(xe.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),Ht=_t(At("flowId")),Bt=_t(At("executionId"),At("stepId"),At("interactionId")),Kt=e=>({start:Ht(((t,n,o,r,i,s,a)=>vt(e.post(Xe,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,version:i,componentsVersion:s,input:a})))),next:Bt(((t,n,o,r,i,s)=>vt(e.post(Ze,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:s}))))}),Jt=At("loginId"),Yt=_t(At("token")),Gt=_t(Jt),Xt=_t(Jt,Rt("phone")),Zt=_t(Jt,Nt("email")),Qt=e=>({verify:Yt((t=>vt(e.post(ge,{token:t})))),signIn:Object.keys(Pt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o,r,i)=>vt(e.post(gt(ve,n),{loginId:t,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:Object.keys(Pt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o,r,i)=>vt(e.post(gt(me,n),{loginId:t,URI:o,user:r,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Pt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o,r)=>vt(e.post(gt(ye,n),{loginId:t,URI:o,loginOptions:r}))))})),{}),update:{email:Zt(((t,n,o,r,i)=>vt(e.post(be.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(Tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xt(((t,o,r,i,s)=>vt(e.post(gt(be.phone,n),Object.assign({loginId:t,phone:o,URI:r},s),{token:i}))))})),{})}});var en;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(en||(en={}));const tn=_t(At("code")),nn=e=>({start:Object.assign(((t,n,o,r)=>vt(e.post(je,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:r}))),Object.keys(en).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r)=>vt(e.post(je,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:r}))})),{})),exchange:tn((t=>vt(e.post(Ce,{code:t})))),startNative:(t,n)=>vt(e.post(Se,{provider:t,loginOptions:n})),finishNative:(t,n,o,r,i)=>vt(e.post(_e,{provider:t,stateId:n,user:o,code:r,idToken:i}))}),on=At("loginId"),rn=_t(on,At("code")),sn=_t(on),an=_t(on,Rt("phone")),cn=_t(on,Nt("email")),ln=e=>({verify:Object.keys(Pt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:rn(((t,o)=>vt(e.post(gt(de,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Pt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:sn(((t,o,r)=>vt(e.post(gt(ue,n),{loginId:t,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(Pt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:sn(((t,o,r)=>vt(e.post(gt(he,n),{loginId:t,user:o,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(Pt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:sn(((t,o)=>vt(e.post(gt(fe,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:cn(((t,n,o,r)=>vt(e.post(pe.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(Tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:an(((t,o,r,i)=>vt(e.post(gt(pe.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),dn=_t(At("tenant")),un=_t(At("code")),hn=e=>({start:dn(((t,n,o,r)=>vt(e.post(Ae,o||{},{queryParams:{tenant:t,redirectURL:n},token:r})))),exchange:un((t=>vt(e.post(Ne,{code:t}))))}),pn=At("loginId"),fn=_t(pn,At("code")),gn=_t(pn),vn=_t(pn),mn=e=>({signUp:gn(((t,n)=>vt(e.post(Ue,{loginId:t,user:n})))),verify:fn(((t,n,o,r)=>vt(e.post(Re,{loginId:t,code:n,loginOptions:o},{token:r})))),update:vn(((t,n)=>vt(e.post(Me,{loginId:t},{token:n}))))}),bn=At("loginId"),yn=At("newPassword"),wn=_t(bn,At("password")),kn=_t(bn),En=_t(bn,yn),In=_t(bn,At("oldPassword"),yn),xn=e=>({signUp:wn(((t,n,o)=>vt(e.post($e,{loginId:t,password:n,user:o})))),signIn:wn(((t,n)=>vt(e.post(We,{loginId:t,password:n})))),sendReset:kn(((t,n,o)=>vt(e.post(ze,{loginId:t,redirectUrl:n,templateOptions:o})))),update:En(((t,n,o)=>vt(e.post(Fe,{loginId:t,newPassword:n},{token:o})))),replace:In(((t,n,o)=>vt(e.post(Ve,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>vt(e.get(qe))}),On=[Ot('"loginId" must be a string')],jn=At("loginId"),Cn=At("origin"),Sn=_t(jn,Cn,At("name")),_n=_t(jn,Cn),An=_t(On,Cn),Nn=_t(jn,Cn,At("token")),Rn=_t(At("transactionId"),At("response")),Un=e=>({signUp:{start:Sn(((t,n,o)=>vt(e.post(Te.start,{user:{loginId:t,name:o},origin:n})))),finish:Rn(((t,n)=>vt(e.post(Te.finish,{transactionId:t,response:n}))))},signIn:{start:An(((t,n,o,r)=>vt(e.post(De.start,{loginId:t,origin:n,loginOptions:o},{token:r})))),finish:Rn(((t,n)=>vt(e.post(De.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:_n(((t,n)=>vt(e.post(Pe.start,{loginId:t,origin:n}))))},update:{start:Nn(((t,n,o)=>vt(e.post(Le.start,{loginId:t,origin:n},{token:o})))),finish:Rn(((t,n)=>vt(e.post(Le.finish,{transactionId:t,response:n}))))}}),Mn=_t(At("token")),Tn=_t([Ct('"token" must be string or undefined')]);var Dn,Pn=_t([("projectId",Dn=At("projectId"),mt(((e,t)=>n=>bt(...t).validate(ce(n,e)))("projectId",Dn))())])((e=>(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},fetch:s})=>{return a=at({baseUrl:n||et,projectId:e,logger:t,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},fetch:s}),{accessKey:Mt(a),otp:ln(a),magicLink:Qt(a),enchantedLink:qt(a),oauth:nn(a),saml:hn(a),totp:mn(a),webauthn:Un(a),password:xn(a),flow:Kt(a),refresh:Tn((e=>vt(a.post(He,{},{token:e})))),selectTenant:_t([Ot("tenantId")],[Ct('"token" must be string or undefined')])(((e,t)=>vt(a.post(Be,{tenant:e},{token:t})))),logout:Tn((e=>vt(a.post(Ke,{},{token:e})))),logoutAll:Tn((e=>vt(a.post(Je,{},{token:e})))),me:Tn((e=>vt(a.get(Ye,{token:e})))),history:Tn((e=>vt(a.get(Ge,{token:e})))),isJwtExpired:Mn(ut),getTenants:Mn(ht),getJwtPermissions:Mn(pt),getJwtRoles:Mn(ft),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const r=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);(await Promise.allSettled(null==r?void 0:r.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))}}}))));const Ln=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const s=i[r];i[r]=n(s)})),e);var $n=Object.assign(Pn,{DeliveryMethods:Pt});var Wn="Blocked by CSP",zn="9319";function Fn(e,t){var n=[];return function(e,t){var n,o,r=(o=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0),{current:function(){return o[0]},postpone:function(){var e=o.shift();void 0!==e&&o.push(e)},exclude:function(){o.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=r.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(e,n){return t(e).catch((function(e){if(n+1>=5)throw e;!function(e){if(!(e instanceof Error))return!1;var t=e.message;return t===Wn||t===zn}(e)?r.postpone():r.exclude();var t,o=r.current();if(void 0===o)throw e;return(t=i(),new Promise((function(e){return setTimeout(e,t)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(e,(function(e){var o=new Date,r=function(t){return n.push({url:e,startedAt:o,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return r()}),r),i})).then((function(e){return[e,{attempts:n}]}))}var Vn="Failed to load the JS script of the agent";function qn(e){var t;e.scriptUrlPattern;var n=e.token,o=e.apiKey,r=void 0===o?n:o,i=d(e,["scriptUrlPattern","token","apiKey"]),s=null!==(t=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(e,"scriptUrlPattern"))&&void 0!==t?t:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";return Promise.resolve().then((function(){if(!r||"string"!=typeof r)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.8.5"):e}))}(String(e),t)}))}(s,r);return Fn(e,Hn).catch(Kn)})).then((function(e){var t=e[0],n=e[1];return t.load(l(l({},i),{ldi:n}))}))}function Hn(e){return function(e,t,n,o){var r,i=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(r=t,c())};i.addEventListener(s,a);var c=function(){return i.removeEventListener(s,a)};return Promise.resolve().then(t).then((function(e){return c(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(c(),r)return function(){throw new Error(Wn)}();throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(Vn))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)})).then(Bn)}function Bn(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(zn);return n}function Kn(e){throw e instanceof Error&&e.message===zn?new Error(Vn):e}var Jn={exports:{}};
|
|
2
|
-
/*! js-cookie v3.0.5 | MIT */!function(e,t){e.exports=function(){function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in i)i[a]&&(s+="; "+a,!0!==i[a]&&(s+="="+i[a].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+s}}function i(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=n.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}}return Object.create({set:r,get:i,remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}return t({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}()}(Jn);var Yn=y(Jn.exports);const Gn=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Xn=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},Zn=async e=>{const t=await Xn(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Qn="undefined"!=typeof localStorage,eo=(e,t)=>Qn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),to=e=>Qn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),no=e=>Qn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),oo=(...e)=>{console.debug(...e)},ro="undefined"!=typeof window,io=Math.pow(2,31)-1,so=ro&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",ao="fp",co=(e=!1)=>{const t=localStorage.getItem(ao);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},lo=async e=>{try{if(co())return;const t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=qn({apiKey:e,endpoint:so}),o=await n,{requestId:r}=await o.get({linkedId:t}),i=((e,t)=>({vsid:e,vrid:t}))(t,r);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(ao,JSON.stringify(t))})(i)}catch(e){global.FB_DEBUG&&console.error(e)}},uo=e=>{const t=co(!0);return t&&e.body&&(e.body.fpData=t),e},ho="dls_last_user_login_id",po="dls_last_user_display_name",fo=()=>to(ho),go=()=>to(po),vo=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=fo(),i=go();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await e(...t)},mo=e=>async(...t)=>{const n=await e(...t);return no(ho),no(po),n};function bo(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const yo="DS",wo="DSR";function ko(e=""){return to(`${e}${wo}`)||""}function Eo(e=""){no(`${e}${wo}`),no(`${e}${yo}`),Yn.remove(yo)}async function Io(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=_o(n.publicKey.challenge),n.publicKey.user.id=_o(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=_o(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Ao(n.rawId),type:n.type,response:{attestationObject:Ao(n.response.attestationObject),clientDataJSON:Ao(n.response.clientDataJSON)}});var n}async function xo(e){const t=Co(e);return So(await navigator.credentials.get(t))}async function Oo(e,t){const n=Co(e);return n.signal=t.signal,n.mediation="conditional",So(await navigator.credentials.get(n))}async function jo(e=!1){if(!ro)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Co(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=_o(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=_o(e.id)})),n}function So(e){return JSON.stringify({id:e.id,rawId:Ao(e.rawId),type:e.type,response:{authenticatorData:Ao(e.response.authenticatorData),clientDataJSON:Ao(e.response.clientDataJSON),signature:Ao(e.response.signature),userHandle:e.response.userHandle?Ao(e.response.userHandle):void 0}})}function _o(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ao(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var No,Ro=(No=e=>({async signUp(t,n){const o=await e.webauthn.signUp.start(t,window.location.origin,n);if(!o.ok)return o;const r=await Io(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const o=await xo(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await Io(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await xo(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n){const o=await e.webauthn.update.start(t,window.location.origin,n);if(!o.ok)return o;const r=await Io(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Io,get:xo,isSupported:jo,conditional:Oo}}),(...e)=>{const t=No(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const Uo=e=>({async oneTap(t,n,o,r){const i=null!=t?t:"google",s=await e.oauth.startNative(i,o);if(!s.ok)return s;const{clientId:a,stateId:c,nonce:l}=s.data,d=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((t=>{var o,s;d.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(s=null==n?void 0:n.use_fedcm_for_prompt)||void 0===s||s,client_id:a,callback:n=>{t(e.oauth.finishNative(i,c,"","",n.credential))},nonce:l})),d.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==r||r())}))}))}});var Mo=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await jo(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const To=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var{fpKey:n,fpLoad:o}=t,r=d(t,["fpKey","fpLoad"]);return ro?(n&&o&&lo(n).catch((()=>null)),e(Gn(r,{beforeRequest:uo}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),e(r))}),(e=>t=>{var{autoRefresh:n}=t,o=d(t,["autoRefresh"]);if(!n)return e(o);const{clearAllTimers:r,setTimer:i}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let s,a;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>s&&(oo("Expiration time passed, refreshing session"),c.refresh(a))}));const c=e(Gn(o,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:o}=await Xn(t);if(401===(null==t?void 0:t.status))oo("Received 401, canceling all timers"),r();else if(o){s=(e=>{const t=e.split(".");try{if(3===t.length){const e=JSON.parse(window.atob(t[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(e){}return null})(o),a=n;let e=((l=s)?l.getTime()-(new Date).getTime():0)-2e4;e>io&&(oo(`Timeout is too large (${e}ms), setting it to ${io}ms`),e=io),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});oo(`Setting refresh timer for ${t}. (${e}ms)`),i((()=>{oo("Refreshing session due to timer"),c.refresh(n)}),e)}var l}}));return Ln(c,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return oo("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.10.0"},t.baseHeaders)}))),(e=>t=>{const n=bo(),o=bo(),r=e(Gn(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),o.pub(null);else{const e=await Zn(t);e&&o.pub(e);const{sessionJwt:r}=await Xn(t);r&&n.pub(r)}}})),i=Ln(r,["logout","logoutAll"],(e=>async(...t)=>{const r=await e(...t);return n.pub(null),o.pub(null),r}));return Object.assign(i,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(e=>t=>{const n=e(Gn(t,{afterRequest:async(e,t)=>{var n;const o=await Zn(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((e=>{eo(ho,e)})(r),(e=>{eo(po,e)})(i))}}));let o=Ln(n,["flow.start"],vo);return o=Ln(o,["logout","logoutAll"],mo),Object.assign(o,{getLastUserLoginId:fo,getLastUserDisplayName:go})}),(e=>t=>{var{persistTokens:n,sessionTokenViaCookie:o,storagePrefix:r}=t,i=d(t,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!n||!ro)return n&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),e(i);const s=e(Gn(i,{beforeRequest:(a=r,e=>Object.assign(e,{token:e.token||ko(a)})),afterRequest:async(e,t)=>{401===(null==t?void 0:t.status)?Eo(r):((e={},t,n)=>{var{refreshJwt:o,sessionJwt:r}=e,i=d(e,["refreshJwt","sessionJwt"]);void 0===t&&(t=!1),void 0===n&&(n=""),o&&eo(`${n}${wo}`,o),r&&(t?function(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:r}){if(t){const i=new Date(1e3*r),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);Yn.set(e,t,{path:n,domain:s?o:void 0,expires:i,sameSite:"Strict",secure:!0})}}(yo,r,i):eo(`${n}${yo}`,r))})(await Xn(t),o,r)}}));var a;const c=Ln(s,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return Eo(e),o})(r));return Object.assign(c,{getRefreshToken:()=>ko(r),getSessionToken:()=>function(e=""){return Yn.get(yo)||to(`${e}${yo}`)||""}(r)})}))(((...e)=>{const t=$n(...e);return Object.assign(Object.assign({},t),{flow:Mo(t),webauthn:Ro(t),fedcm:Uo(t)})}));let Do;const Po=e=>{const t=To(Object.assign(Object.assign({},e),{persistTokens:c,autoRefresh:c}));return Do=t,t};Do=Po({projectId:"temp pid"});const Lo=()=>c?null==Do?void 0:Do.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),$o=()=>c?null==Do?void 0:Do.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),Wo=s(((e=Lo(),t)=>null==Do?void 0:Do.getJwtPermissions(e,t))),zo=s(((e=Lo(),t)=>null==Do?void 0:Do.getJwtRoles(e,t)));const Fo=t.lazy((async()=>((await Promise.resolve().then((function(){return zi}))).default.sdkConfigOverrides={baseHeaders:a,persistTokens:!1,hooks:{get beforeRequest(){return Do.httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:({projectId:e,flowId:t,baseUrl:n,innerRef:r,tenant:i,theme:s,locale:a,debug:c,redirectUrl:l,client:d,form:u,autoFocus:h})=>o.default.createElement("descope-wc",{"project-id":e,"flow-id":t,"base-url":n,ref:r,tenant:i,theme:s,locale:a,debug:c,client:d,form:u,"redirect-url":l,"auto-focus":h})}))),Vo=o.default.forwardRef((({flowId:e,onSuccess:n,onError:i,logger:s,tenant:a,theme:c,locale:l,debug:d,client:u,form:h,telemetryKey:p,redirectUrl:f,autoFocus:g,errorTransformer:v},m)=>{const[b,y]=t.useState(null);t.useImperativeHandle(m,(()=>b));const{projectId:w,baseUrl:k,sdk:E}=o.default.useContext(r),I=t.useCallback((async e=>{await E.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),n&&n(e)}),[n]);t.useEffect((()=>{const e=b;return null==e||e.addEventListener("success",I),i&&(null==e||e.addEventListener("error",i)),()=>{i&&(null==e||e.removeEventListener("error",i)),null==e||e.removeEventListener("success",I)}}),[b,i,I]),t.useEffect((()=>{b&&(b.errorTransformer=v)}),[b,v]),t.useEffect((()=>{b&&s&&(b.logger=s)}),[b,s]);const{form:x,client:O}=t.useMemo((()=>({form:JSON.stringify(h||{}),client:JSON.stringify(u||{})})),[h,u]);return o.default.createElement("form",null,o.default.createElement(t.Suspense,{fallback:null},o.default.createElement(Fo,{projectId:w,flowId:e,baseUrl:k,innerRef:y,tenant:a,theme:c,locale:l,debug:d,form:x,client:O,telemetryKey:p,redirectUrl:f,autoFocus:g})))})),qo=t.lazy((async()=>(await Promise.resolve().then((function(){return Nl})),{default:({projectId:e,baseUrl:t,innerRef:n,tenant:r,theme:i,debug:s})=>o.default.createElement("descope-user-management-widget",{"project-id":e,"base-url":t,theme:i,tenant:r,debug:s,ref:n})}))),Ho=o.default.forwardRef((({logger:e,tenant:n,theme:i,debug:s},a)=>{const[c,l]=t.useState(null);t.useImperativeHandle(a,(()=>c));const{projectId:d,baseUrl:u}=o.default.useContext(r);return t.useEffect((()=>{c&&e&&(c.logger=e)}),[c,e]),o.default.createElement(t.Suspense,{fallback:null},o.default.createElement(qo,{projectId:d,baseUrl:u,innerRef:l,tenant:n,theme:i,debug:s}))}));var Bo=()=>{const e=t.useContext(r);if(!e)throw Error("You can only use this hook in the context of <AuthProvider />");return e};const Ko=e=>`You can only use this ${e} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`,Jo={get(e,t){if("object"==typeof e[t]&&null!==e[t])return new Proxy(e[t],Jo);if("function"==typeof e[t])return()=>{throw Error(Ko("function"))};throw Error(Ko("attribute"))}},Yo="undefined"!=typeof localStorage,Go=Yo&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",Xo="config.json",Zo="base.ui.components.url",Qo=Yo&&localStorage.getItem(Zo)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",er=Yo&&localStorage.getItem(Zo)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",tr="descope-login-flow",nr="code",or="ra-challenge",rr="ra-callback",ir="ra-backup-callback",sr="ra-initiator",ar="data-exclude-field",cr="dls_last_auth",lr="state_id",dr="saml_idp_state_id",ur="saml_idp_username",hr="sso_app_id",pr="oidc_login_hint",fr="data-type",gr="poll",vr="webauthnCreate",mr="submit",br="polling";var yr;function wr(e){return new URLSearchParams(window.location.search).get(e)}function kr(e){if(window.history.replaceState&&wr(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function Er(e,t){return u(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}function Ir(e,t,n="v2-beta"){const o=new URL(Go);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}function xr(e,t){if(!Number.isNaN(e)&&!Number.isNaN(t))return e>t?yr.forward:e<t?yr.backward:void 0}!function(e){e.backward="backward",e.forward="forward"}(yr||(yr={}));const Or=()=>{const[e="",t=""]=(wr(tr)||"").split("_");return{executionId:e,stepId:t}};function jr(){kr(tr)}const Cr=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Sr=e=>{let t,n;return(...o)=>{return t&&(i=o,(r=t).length===i.length&&r.every(((e,t)=>e===i[t])))||(t=o,n=e(...o)),n;var r,i}},_r=(e,t,n,o,r,i)=>e&&!t&&e&&!n&&!o&&e&&!r&&e&&!i,Ar=e=>null==e?void 0:e.submit(),Nr=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null};var Rr,Ur,Mr,Tr;function Dr(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!Dr(i,s))return!1}else if(i!==s)return!1}return!0}class Pr{constructor(e={},{updateOnlyOnChange:t=!0}={}){Rr.set(this,void 0),Ur.set(this,{}),Mr.set(this,0),Tr.set(this,!1),this.update=e=>{const t="function"==typeof e?e(h(this,Rr,"f")):e,n=Object.assign(Object.assign({},h(this,Rr,"f")),t);if(!h(this,Tr,"f")||!Dr(h(this,Rr,"f"),n)){const e=h(this,Rr,"f");p(this,Rr,n,"f"),Object.freeze(h(this,Rr,"f")),setTimeout((()=>{Object.values(h(this,Ur,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},p(this,Rr,e,"f"),p(this,Tr,t,"f")}get current(){return Object.assign({},h(this,Rr,"f"))}subscribe(e){return p(this,Mr,h(this,Mr,"f")+1,"f"),h(this,Ur,"f")[h(this,Mr,"f")]=e,h(this,Mr,"f").toString()}unsubscribe(e){const t=!!h(this,Ur,"f")[e];return t&&delete h(this,Ur,"f")[e],t}unsubscribeAll(){return p(this,Ur,{},"f"),!0}}Rr=new WeakMap,Ur=new WeakMap,Mr=new WeakMap,Tr=new WeakMap;const Lr=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ar}])`)).forEach((e=>{e.value=n}))}))},$r=(e,t)=>e.replace(/{{(.+?)}}/g,((e,n)=>{return o=t,n.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),o);var o})),Wr=Sr((()=>u(void 0,void 0,void 0,(function*(){var e,t,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield(100,n=r,o=i,new Promise(((e,t)=>{let r=!1;const i=setTimeout((()=>{r=!0,void 0!==o?e(o):t(new Error("Promise timed out after 100 ms"))}),100);n.then((t=>{r||(clearTimeout(i),e(t))})).catch((e=>{r||(clearTimeout(i),t(e))}))})))}catch(e){return console.error("Conditional login check failed",e),!1}})))),zr={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t}};function Fr(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(cr)))}catch(e){}return t}const Vr="dls_ab_testing_id",qr=document.createElement("template");var Hr,Br,Kr,Jr,Yr,Gr,Xr,Zr,Qr,ei,ti,ni,oi,ri,ii,si,ai,ci,li,di,ui,hi,pi,fi,gi,vi,mi,bi,yi,wi,ki,Ei,Ii,xi,Oi,ji,Ci,Si,_i,Ai,Ni,Ri,Ui,Mi,Ti,Di,Pi,Li;qr.innerHTML='\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<div id="wc-root"></div>\n\t';class $i extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","locale","debug","storage-prefix","preview","redirect-url","auto-focus"]}constructor(e){super(),Hr.add(this),this.logger=console,Br.set(this,!1),this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),h(this,Hr,"m",mi).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)}},Kr.set(this,new Pr({deferredRedirect:!1})),Jr.set(this,new Pr),Yr.set(this,{}),this.getComponentsContext=()=>h(this,Yr,"f"),this.nextRequestStatus=new Pr({isLoading:!1}),Gr.set(this,void 0),Xr.set(this,{popstate:h(this,Hr,"m",oi).bind(this),visibilitychange:h(this,Hr,"m",ri).bind(this),componentsContext:h(this,Hr,"m",pi).bind(this)}),Zr.set(this,void 0),li.set(this,Sr((()=>u(this,void 0,void 0,(function*(){const e=Ir(this.projectId,Xo);try{const{body:t,headers:n}=yield Er(e,"json");return{projectConfig:t,executionContext:{geo:n["x-geo"]}}}catch(e){return{isMissingConfig:!0}}}))))),p(this,Zr,e,"f"),h(this,Hr,"m",Qr).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get form(){try{const e=JSON.parse(this.getAttribute("form"))||{};return Object.entries(e).reduce(((e,[t,n])=>Object.assign(Object.assign({},e),{[`form.${t}`]:n})),e)}catch(e){return{}}}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get baseUrl(){return this.getAttribute("base-url")||void 0}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get theme(){var e,t;const n=this.getAttribute("theme");return"os"===n?window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light":n||"light"}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}getExecutionContext(){return u(this,void 0,void 0,(function*(){const{executionContext:e}=yield h(this,li,"f").call(this);return e}))}getProjectConfig(){return u(this,void 0,void 0,(function*(){const{projectConfig:e}=yield h(this,li,"f").call(this);return e}))}getFlowConfig(){var e,t;return u(this,void 0,void 0,(function*(){const n=yield this.getProjectConfig(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}getTargetLocales(){return u(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}connectedCallback(){return u(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(h(this,Jr,"f").subscribe(h(this,Hr,"m",vi).bind(this)),h(this,Jr,"f").update({isDebug:this.debug}),h(this,Hr,"m",ei).call(this))return void h(this,Hr,"m",ti).call(this);if(h(this,Hr,"m",ni).call(this),yield h(this,Hr,"m",ai).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield h(this,li,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");yield h(this,Hr,"m",wi).call(this),yield h(this,Hr,"m",ui).call(this),h(this,Hr,"m",di).call(this),h(this,Hr,"m",bi).call(this);const{executionId:e,stepId:t,token:n,code:o,exchangeError:r,redirectAuthCallbackUrl:i,redirectAuthBackupCallbackUri:s,redirectAuthCodeChallenge:a,redirectAuthInitiator:c,oidcIdpStateId:l,samlIdpStateId:d,samlIdpUsername:u,ssoAppId:f,oidcLoginHint:g}=(()=>{const{executionId:e,stepId:t}=Or();(e||t)&&jr();const n=wr("t")||void 0;n&&kr("t");const o=wr(nr)||void 0;o&&kr(nr);const r=wr("err")||void 0;r&&kr("err");const{redirectAuthCodeChallenge:i,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:c}={redirectAuthCodeChallenge:wr(or),redirectAuthCallbackUrl:wr(rr),redirectAuthBackupCallbackUri:wr(ir),redirectAuthInitiator:wr(sr)};(i||s||a||c)&&(kr(or),kr(rr),kr(ir),kr(sr));const l=wr(lr);l&&kr(lr);const d=wr(dr);d&&kr(dr);const u=wr(ur);d&&kr(ur);const h=wr(hr);h&&kr(hr);const p=wr(pr);return p&&kr(pr),{executionId:e,stepId:t,token:n,code:o,exchangeError:r,redirectAuthCodeChallenge:i,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:c,oidcIdpStateId:l,samlIdpStateId:d,samlIdpUsername:u,ssoAppId:h,oidcLoginHint:p}})();window.addEventListener("popstate",h(this,Xr,"f").popstate),window.addEventListener("components-context",h(this,Xr,"f").componentsContext),window.addEventListener("visibilitychange",h(this,Xr,"f").visibilitychange),h(this,Kr,"f").subscribe(h(this,Hr,"m",si).bind(this)),h(this,Kr,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:t,executionId:e,token:n,code:o,exchangeError:r,redirectAuthCallbackUrl:i,redirectAuthBackupCallbackUri:s,redirectAuthCodeChallenge:a,redirectAuthInitiator:c,oidcIdpStateId:l,samlIdpStateId:d,samlIdpUsername:u,ssoAppId:f,oidcLoginHint:g}),p(this,Br,!0,"f")}}))}disconnectedCallback(){h(this,Kr,"f").unsubscribeAll(),h(this,Jr,"f").unsubscribeAll(),h(this,Hr,"m",gi).call(this),window.removeEventListener("popstate",h(this,Xr,"f").popstate),window.removeEventListener("visibilitychange",h(this,Xr,"f").visibilitychange),window.removeEventListener("components-context",h(this,Xr,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&h(this,Br,"f")&&t!==n&&$i.observedAttributes.includes(e)){h(this,Hr,"m",ni).call(this);const o=null===t;h(this,Kr,"f").update((({stepId:t,executionId:r})=>{let i=t,s=r;return o||(s=null,i=null,jr()),{[Cr(e)]:n,stepId:i,executionId:s}})),h(this,Jr,"f").update({isDebug:this.debug})}}}Br=new WeakMap,Kr=new WeakMap,Jr=new WeakMap,Yr=new WeakMap,Gr=new WeakMap,Xr=new WeakMap,Zr=new WeakMap,li=new WeakMap,Hr=new WeakSet,Qr=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(qr.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},ei=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},ti=function(){const e=this.shadowRoot.host,t=document.createElement("form");e.parentElement.appendChild(t),t.appendChild(e)},ni=function(){const e=["base-url","tenant","theme","locale","debug","redirect-url","auto-focus","preview","storage-prefix","form","client"];if($i.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Cr(t)])throw Error(`${t} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},oi=function(){const{stepId:e,executionId:t}=Or();h(this,Kr,"f").update({stepId:e,executionId:t})},ri=function(){document.hidden||setTimeout((()=>{h(this,Kr,"f").update({deferredRedirect:!1})}),300)},ii=function(e,t){this.sdk=To(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix},$i.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>u(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield t(...e)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},si=function(e,t,n){return u(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:o}=e;if(n("projectId")||n("baseUrl")){if(!t)return;h(this,Hr,"m",ii).call(this,t,o)}h(this,Zr,"f").call(this,e)}))},ai=function(){return u(this,void 0,void 0,(function*(){return(yield h(this,li,"f").call(this)).isMissingConfig&&(yield h(this,Hr,"m",ci).call(this))}))},ci=function(){return u(this,void 0,void 0,(function*(){const e=Ir(this.projectId,Xo,"v2-alpha");try{return yield Er(e,"json"),!0}catch(e){return!1}}))},di=function(){var e,t;return u(this,void 0,void 0,(function*(){const{projectConfig:n}=yield h(this,li,"f").call(this),o=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;o&&Object.values(o).forEach((e=>(e=>{if(!e)return;const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url)))}))},ui=function(){return u(this,void 0,void 0,(function*(){yield h(this,Hr,"m",hi).call(this),yield h(this,Hr,"m",fi).call(this)}))},hi=function(){var e,t,n,o;return u(this,void 0,void 0,(function*(){const r=document.createElement("style"),i=Ir(this.projectId,"theme.json");try{const{body:s}=yield Er(i,"json");r.innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(t=null==s?void 0:s.dark)||void 0===t?void 0:t.globals)||"");const a=yield $i.descopeUI;(null==a?void 0:a.componentsThemeManager)&&(a.componentsThemeManager.themes={light:null===(n=null==s?void 0:s.light)||void 0===n?void 0:n.components,dark:null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.components})}catch(r){this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(r)}))},pi=function(e){p(this,Yr,Object.assign(Object.assign({},e.detail),h(this,Yr,"f")),"f")},fi=function(){return u(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield $i.descopeUI;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},gi=function(){var e;null===(e=h(this,Gr,"f"))||void 0===e||e.remove(),p(this,Gr,null,"f")},vi=function({isDebug:e}){return u(this,void 0,void 0,(function*(){e?(p(this,Gr,document.createElement("descope-debugger"),"f"),Object.assign(h(this,Gr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Yl})),document.body.appendChild(h(this,Gr,"f"))):h(this,Hr,"m",gi).call(this)}))},mi=function(e,t){var n;e&&this.debug&&(null===(n=h(this,Gr,"f"))||void 0===n||n.updateData({title:e,description:t}))},bi=function(){this.rootElement.onkeydown=e=>{if("Enter"!==e.key)return;e.preventDefault();const t=this.rootElement.querySelectorAll("descope-button");if(1===t.length)return void t[0].click();const n=Array.from(t).filter((e=>"button"===e.getAttribute("data-type")));if(1===n.length)n[0].click();else if(0===n.length){const e=Array.from(t).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&e[0].click()}}},yi=function(){var e,t;return u(this,void 0,void 0,(function*(){return(null===(t=null===(e=yield h(this,li,"f").call(this))||void 0===e?void 0:e.projectConfig)||void 0===t?void 0:t.componentsVersion)||(this.logger.error("Did not get components version, using latest version"),"latest")}))},wi=function(){return u(this,void 0,void 0,(function*(){$i.descopeUI?this.loggerWrapper.info("DescopeUI is already loading, probably multiple flows are running on the same page"):$i.descopeUI=new Promise((e=>{if(globalThis.DescopeUI)return void e(globalThis.DescopeUI);const t=e=>{const t=document.createElement("script");return t.id="load-descope-ui",t.src=e,t},n=(e,t)=>e.replace("<version>",t),o=(t,n)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${t.src}"`),n()};t.addEventListener("load",(()=>{globalThis.DescopeUI||o(),e(globalThis.DescopeUI)})),t.addEventListener("error",o)};(()=>{u(this,void 0,void 0,(function*(){const r=yield h(this,Hr,"m",yi).call(this),i=t(n(Qo,r));o(i,(()=>{i.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const s=t(n(er,r));o(s,(()=>{e(void 0)})),document.body.append(s)})),document.body.append(i)}))})()}))}))},$i.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.8.1"}};class Wi extends $i{static set sdkConfigOverrides(e){$i.sdkConfigOverrides=e}constructor(){const e=new Pr;super(e.update.bind(e)),ki.add(this),this.stepState=new Pr({},{updateOnlyOnChange:!1}),Ei.set(this,void 0),Ii.set(this,null),xi.set(this,((e,t,n,o,r)=>{n===gr&&p(this,Ei,setTimeout((()=>u(this,void 0,void 0,(function*(){var n;const i=yield this.sdk.flow.next(e,t,br,o,r,{});h(this,ji,"f").call(this,i);const{action:s}=null!==(n=null==i?void 0:i.data)&&void 0!==n?n:{};h(this,xi,"f").call(this,e,t,s,o,r)}))),2e3),"f")})),Oi.set(this,(()=>{clearTimeout(h(this,Ei,"f")),p(this,Ei,null,"f")})),ji.set(this,(e=>{var t,n,o,r,i,s,a,c,l;if(!(null==e?void 0:e.ok)){h(this,ki,"m",Li).call(this,"error",null==e?void 0:e.error);const s=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,a=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.statusText}`;return void this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorDescription)||s,(null===(i=null==e?void 0:e.error)||void 0===i?void 0:i.errorMessage)||a)}const d=null===(c=null===(a=null===(s=e.data)||void 0===s?void 0:s.screen)||void 0===a?void 0:a.state)||void 0===c?void 0:c.errorText;(null===(l=e.data)||void 0===l?void 0:l.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${d?`${d} - `:""}${e.data.error.message}`):d&&this.loggerWrapper.error(d);const{status:u,authInfo:p,lastAuth:f}=e.data;if("completed"===u)return function(e){(null==e?void 0:e.authMethod)&&Yo&&localStorage.setItem(cr,JSON.stringify(e))}(f),void h(this,ki,"m",Li).call(this,"success",p);const{executionId:g,stepId:v,stepName:m,action:b,screen:y,redirect:w,webauthn:k,error:E,samlIdpResponse:I}=e.data;b!==gr?(this.loggerWrapper.info(`Step "${m||`#${v}`}" is ${u}`,"",{screen:y,status:u,stepId:v,stepName:m,action:b,error:E}),this.flowState.update({stepId:v,executionId:g,action:b,redirectTo:null==w?void 0:w.url,screenId:null==y?void 0:y.id,screenState:null==y?void 0:y.state,webauthnTransactionId:null==k?void 0:k.transactionId,webauthnOptions:null==k?void 0:k.options,samlIdpResponseUrl:null==I?void 0:I.url,samlIdpResponseSamlResponse:null==I?void 0:I.samlResponse,samlIdpResponseRelayState:null==I?void 0:I.relayState})):this.flowState.update({action:b})})),Ci.set(this,Sr((()=>u(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.error("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.error("Webauthn start failed",e.message)}}))))),this.flowState=e}connectedCallback(){const e=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var t,n;return u(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(n=this.stepState)||void 0===n||n.subscribe(this.onStepChange.bind(this))),yield e.connectedCallback.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=h(this,Ii,"f"))||void 0===e||e.abort(),p(this,Ii,null,"f")}getHtmlFilenameWithLocale(e,t){return u(this,void 0,void 0,(function*(){let n,o=navigator.language;o&&"zh-TW"!==o&&(o=o.split("-")[0]);const r=(e||o||"").toLowerCase();return(yield this.getTargetLocales()).includes(r)&&(n=`${t}-${r}.html`),n}))}getPageContent(e,t){return u(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield Er(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield Er(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,t,n){var o,r;return u(this,void 0,void 0,(function*(){const{projectId:i,flowId:s,tenant:a,stepId:c,executionId:l,action:d,screenId:u,screenState:f,redirectTo:g,redirectUrl:v,token:m,code:b,exchangeError:y,webauthnTransactionId:w,webauthnOptions:k,redirectAuthCodeChallenge:E,redirectAuthCallbackUrl:I,redirectAuthBackupCallbackUri:x,redirectAuthInitiator:O,oidcIdpStateId:j,locale:C,samlIdpStateId:S,samlIdpUsername:_,samlIdpResponseUrl:A,samlIdpResponseSamlResponse:N,samlIdpResponseRelayState:R,ssoAppId:U,oidcLoginHint:M}=e;let T,D;const P=(()=>{const e=localStorage.getItem(Vr);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(Vr,e.toString()),e}return Number(e)})(),L=this.sdk.getLastUserLoginId(),$=yield this.getFlowConfig(),W=yield this.getProjectConfig(),z=I&&E?{callbackUrl:I,codeChallenge:E,backupCallbackUri:x}:void 0;if(!l&&($.fingerprintEnabled&&$.fingerprintKey?lo($.fingerprintKey):localStorage.removeItem(ao),$.conditions?({startScreenId:T,conditionInteractionId:D}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var r;if("ELSE"===t)return!0;const i=null===(r=zr[t])||void 0===r?void 0:r[n];return!!(null==i?void 0:i(e,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:L,code:b,token:m,abTestingKey:P},$.conditions)):$.condition?({startScreenId:T,conditionInteractionId:D}=((e,t)=>{var n;const o=null===(n=zr[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const r=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})($.condition,{loginId:L,code:b,token:m,abTestingKey:P})):T=$.startScreenId,!_r(T,j,S,_,U,M))){const e=yield this.sdk.flow.start(s,Object.assign(Object.assign({tenant:a,redirectAuth:z,oidcIdpStateId:j,samlIdpStateId:S,samlIdpUsername:_,ssoAppId:U,oidcLoginHint:M,client:this.client},v&&{redirectUrl:v}),{lastAuth:Fr(L),abTestingKey:P}),D,"",$.version,W.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),b?{exchangeCode:b,idpInitiated:!0}:{}),m?{token:m}:{}),M?{externalId:M}:{}));return h(this,ji,"f").call(this,e),void("completed"!==(null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.status)&&this.flowState.update({code:void 0,token:void 0}))}if(l&&(n("token")&&m||n("code")&&b||n("exchangeError")&&y)){const e=yield this.sdk.flow.next(l,c,mr,$.version,W.componentsVersion,{token:m,exchangeCode:b,exchangeError:y});return h(this,ji,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if("loadForm"===d&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>n(e)))){if(!A||!N)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const r=document.createElement("form");r.method="POST",r.action=e,r.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(r),o(r)})(A,N,R||"",Ar)}if("redirect"===d&&(n("redirectTo")||n("deferredRedirect")))return g?"android"===O&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(g):void this.loggerWrapper.error("Did not get redirect url");if(d===vr||"webauthnGet"===d){if(!w||!k)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(r=h(this,Ii,"f"))||void 0===r||r.abort(),p(this,Ii,null,"f");try{e=d===vr?yield this.sdk.webauthn.helpers.create(k):yield this.sdk.webauthn.helpers.get(k)}catch(i){"InvalidStateError"===i.name?this.loggerWrapper.warn("WebAuthn operation failed",i.message):"NotAllowedError"!==i.name&&this.loggerWrapper.error(i.message),t=i.name}const n=yield this.sdk.flow.next(l,c,mr,$.version,W.componentsVersion,{transactionId:w,response:e,failure:t});h(this,ji,"f").call(this,n)}if(h(this,xi,"f").call(this,l,c,d,$.version,W.componentsVersion),!u&&!T)return void this.loggerWrapper.warn("No screen was found to show");const F=T||u,V=yield this.getHtmlFilenameWithLocale(C,F),q={direction:xr(+c,+t.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.form),null==f?void 0:f.form),lastAuth:{loginId:L,name:this.sdk.getLastUserDisplayName()||L}}),htmlUrl:Ir(i,`${F}.html`),htmlLocaleUrl:V&&Ir(i,V),samlIdpUsername:_,oidcLoginHint:M},H=Fr(L);_r(T,j,S,_,U,M)?q.next=(e,t,n,o)=>this.sdk.flow.start(s,Object.assign({tenant:a,redirectAuth:z,oidcIdpStateId:j,samlIdpStateId:S,samlIdpUsername:_,ssoAppId:U,oidcLoginHint:M,lastAuth:H,preview:this.preview,abTestingKey:P,client:this.client},v&&{redirectUrl:v}),D,e,t,n,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),o),b&&{exchangeCode:b,idpInitiated:!0}),m&&{token:m})):(n("projectId")||n("baseUrl")||n("executionId")||n("stepId"))&&(q.next=(...e)=>this.sdk.flow.next(l,c,...e)),this.stepState.update(q)}))}loadDescopeUiComponents(e){return u(this,void 0,void 0,(function*(){const t=yield $i.descopeUI;if(!t)return;const n=(e=>[...Array.from(e.querySelectorAll("*")).reduce(((e,t)=>t.tagName.startsWith("DESCOPE-")?e.add(t.tagName.toLocaleLowerCase()):e),new Set)])(e);yield Promise.all(n.map((e=>u(this,void 0,void 0,(function*(){if(!customElements.get(e))if(t[e])try{return yield t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`${e} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)})))))}))}onStepChange(e,t){var n,o;return u(this,void 0,void 0,(function*(){const{htmlUrl:r,htmlLocaleUrl:i,direction:s,next:a,screenState:c}=e,l=document.createElement("template");l.innerHTML=yield this.getPageContent(r,i);const d=l.content.cloneNode(!0),p=this.loadDescopeUiComponents(l.content);this.sdk.webauthn.helpers.isSupported()?yield h(this,ki,"m",_i).call(this,d,a):d.querySelectorAll(`descope-button[${fr}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(n=c.form)||void 0===n?void 0:n.loginId)||(null===(o=c.form)||void 0===o?void 0:o.email)||(c.form||(c.form={}),c.form.loginId=e.samlIdpUsername,c.form.email=e.samlIdpUsername),((e,t,n,o,r)=>{var i;let s=null==t?void 0:t.errorText;try{s=(null==o?void 0:o({text:null==t?void 0:t.errorText,type:null==t?void 0:t.errorType}))||(null==t?void 0:t.errorText)}catch(e){r.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${fr}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(e,"error-message",s),((e,t)=>{e.querySelectorAll(`[${fr}="totp-link"]`).forEach((e=>{e.setAttribute("href",t)}))})(e,null===(i=null==t?void 0:t.totp)||void 0===i?void 0:i.provisionUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link").forEach((e=>{e.textContent=$r(e.textContent,t)}))})(e,t),((e,t,n)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const r=t[o];Object.keys(r).forEach((t=>{let o=r[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){n.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,n,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=$r(e.value,t)}))}))})(e,t)})(d,c,c.componentsConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(d,f);const g=()=>u(this,void 0,void 0,(function*(){var e;yield p,((e,t)=>{var n,o;const r=null===(n=customElements.get("descope-totp-image"))||void 0===n?void 0:n.cssVarList.url;t&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${t})`))})(this.shadowRoot.querySelector("div"),null===(e=null==c?void 0:c.totp)||void 0===e?void 0:e.image),this.rootElement.replaceChildren(d),setTimeout((()=>((e,t)=>{Lr(e,null==t?void 0:t.inputs),Lr(e,null==t?void 0:t.form)})(this.rootElement,c)));const n=!t.htmlUrl;if(((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,n),h(this,ki,"m",Di).call(this,a),n&&h(this,ki,"m",Li).call(this,"ready",{}),h(this,ki,"m",Li).call(this,"page-updated",{}),this.rootElement.querySelector(`[${fr}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),n=yield a(br,e.version,t.componentsVersion,{});h(this,ji,"f").call(this,n)}}));s?h(this,ki,"m",Pi).call(this,g,s):g()}))}}Ei=new WeakMap,Ii=new WeakMap,xi=new WeakMap,Oi=new WeakMap,ji=new WeakMap,Ci=new WeakMap,ki=new WeakSet,Si=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},_i=function(e,t){var n;return u(this,void 0,void 0,(function*(){null===(n=h(this,Ii,"f"))||void 0===n||n.abort();const o=e.querySelector('*[autocomplete="webauthn"]');if(o&&(yield Wr())){const{options:e,transactionId:n}=(yield h(this,Ci,"f").call(this))||{};if(e&&n){h(this,ki,"m",Si).call(this,o),p(this,Ii,new AbortController,"f");const r=yield this.getFlowConfig(),i=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(e,h(this,Ii,"f")).then((e=>u(this,void 0,void 0,(function*(){const s=yield t(o.id,r.version,i.componentsVersion,{transactionId:n,response:e});h(this,ji,"f").call(this,s)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},Ai=function(){return Array.from(this.shadowRoot.querySelectorAll("*[name]")).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))},Ni=function(){return u(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${ar}])`));return(yield Promise.all(e.map((e=>u(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},Ri=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},Ui=function(e={}){var t,n;const o=Nr(e,["externalId","email","phone"]),r=Nr(e,["newPassword","password"]);if(o&&r)try{const e=new globalThis.PasswordCredential({id:o,password:r});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},Mi=function(e,t){return u(this,void 0,void 0,(function*(){if("true"===e.getAttribute("formnovalidate")||h(this,ki,"m",Ai).call(this)){const o=null==e?void 0:e.getAttribute("id");h(this,ki,"m",Ri).call(this,e);const r=yield h(this,ki,"m",Ni).call(this),i=(n=e,Array.from((null==n?void 0:n.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{})),s=this.getComponentsContext(),a=Object.assign(Object.assign(Object.assign(Object.assign({},s),i),r),{origin:window.location.origin}),c=yield this.getFlowConfig(),l=yield this.getProjectConfig(),d=yield t(o,c.version,l.componentsVersion,a);h(this,ji,"f").call(this,d),h(this,ki,"m",Ui).call(this,r)}var n}))},Ti=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&h(this,ki,"m",Mi).call(this,t,e)}))}))},Di=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((t=>{t.onclick=()=>{h(this,ki,"m",Mi).call(this,t,e)}})),h(this,ki,"m",Ti).call(this,e)},Pi=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===yr.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),this.rootElement.classList.add("fade-out")},Li=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.define("descope-wc",Wi);var zi=Object.freeze({__proto__:null,default:Wi});function Fi(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Vi=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),qi=()=>Math.random().toString(36).substring(7).split("").join("."),Hi={INIT:`@@redux/INIT${qi()}`,REPLACE:`@@redux/REPLACE${qi()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${qi()}`};function Bi(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function Ki(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function Ji(e){let t=typeof e;return"production"!==process.env.NODE_ENV&&(t=Ki(e)),t}function Yi(e,t,n){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?Fi(2):`Expected the root reducer to be a function. Instead, received: '${Ji(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("production"===process.env.NODE_ENV?Fi(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error("production"===process.env.NODE_ENV?Fi(1):`Expected the enhancer to be a function. Instead, received: '${Ji(n)}'`);return n(Yi)(e,t)}let o=e,r=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(c)throw new Error("production"===process.env.NODE_ENV?Fi(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return r}function u(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?Fi(4):`Expected the listener to be a function. Instead, received: '${Ji(e)}'`);if(c)throw new Error("production"===process.env.NODE_ENV?Fi(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("production"===process.env.NODE_ENV?Fi(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),i=null}}}function h(e){if(!Bi(e))throw new Error("production"===process.env.NODE_ENV?Fi(7):`Actions must be plain objects. Instead, the actual type was: '${Ji(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error("production"===process.env.NODE_ENV?Fi(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error("production"===process.env.NODE_ENV?Fi(17):`Action "type" property must be a string. Instead, the actual type was: '${Ji(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("production"===process.env.NODE_ENV?Fi(9):"Reducers may not dispatch actions.");try{c=!0,r=o(r,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}function p(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?Fi(10):`Expected the nextReducer to be a function. Instead, received: '${Ji(e)}`);o=e,h({type:Hi.REPLACE})}function f(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error("production"===process.env.NODE_ENV?Fi(11):`Expected the observer to be an object. Instead, received: '${Ji(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[Vi](){return this}}}h({type:Hi.INIT});const g={dispatch:h,subscribe:u,getState:d,replaceReducer:p,[Vi]:f};return g}function Gi(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Xi(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const r=t[o];"production"!==process.env.NODE_ENV&&void 0===e[r]&&Gi(`No reducer provided for key "${r}"`),"function"==typeof e[r]&&(n[r]=e[r])}const o=Object.keys(n);let r,i;"production"!==process.env.NODE_ENV&&(r={});try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:Hi.INIT}))throw new Error("production"===process.env.NODE_ENV?Fi(12):`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:Hi.PROBE_UNKNOWN_ACTION()}))throw new Error("production"===process.env.NODE_ENV?Fi(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${Hi.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){i=e}return function(e={},t){if(i)throw i;if("production"!==process.env.NODE_ENV){const o=function(e,t,n,o){const r=Object.keys(t),i=n&&n.type===Hi.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===r.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Bi(e))return`The ${i} has unexpected type of "${Ji(e)}". Expected argument to be an object with the following keys: "${r.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===Hi.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${r.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,r);o&&Gi(o)}let s=!1;const a={};for(let r=0;r<o.length;r++){const i=o[r],c=n[i],l=e[i],d=c(l,t);if(void 0===d){const e=t&&t.type;throw new Error("production"===process.env.NODE_ENV?Fi(14):`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=d,s=s||d!==l}return s=s||o.length!==Object.keys(e).length,s?a:e}}function Zi(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Qi(e){return Bi(e)&&"type"in e&&"string"==typeof e.type}var es=Symbol.for("immer-nothing"),ts=Symbol.for("immer-draftable"),ns=Symbol.for("immer-state"),os="production"!==process.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function rs(e,...t){if("production"!==process.env.NODE_ENV){const n=os[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var is=Object.getPrototypeOf;function ss(e){return!!e&&!!e[ns]}function as(e){return!!e&&(ls(e)||Array.isArray(e)||!!e[ts]||!!e.constructor?.[ts]||fs(e)||gs(e))}var cs=Object.prototype.constructor.toString();function ls(e){if(!e||"object"!=typeof e)return!1;const t=is(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===cs}function ds(e,t){0===us(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function us(e){const t=e[ns];return t?t.type_:Array.isArray(e)?1:fs(e)?2:gs(e)?3:0}function hs(e,t){return 2===us(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ps(e,t,n){const o=us(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function fs(e){return e instanceof Map}function gs(e){return e instanceof Set}function vs(e){return e.copy_||e.base_}function ms(e,t){if(fs(e))return new Map(e);if(gs(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&ls(e)){if(!is(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[ns];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const r=o[t],i=n[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[r]})}return Object.create(is(e),n)}function bs(e,t=!1){return ws(e)||ss(e)||!as(e)||(us(e)>1&&(e.set=e.add=e.clear=e.delete=ys),Object.freeze(e),t&&ds(e,((e,t)=>bs(t,!0)))),e}function ys(){rs(2)}function ws(e){return Object.isFrozen(e)}var ks,Es={};function Is(e){const t=Es[e];return t||rs(0,e),t}function xs(){return ks}function Os(e,t){t&&(Is("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function js(e){Cs(e),e.drafts_.forEach(_s),e.drafts_=null}function Cs(e){e===ks&&(ks=e.parent_)}function Ss(e){return ks={drafts_:[],parent_:ks,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function _s(e){const t=e[ns];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function As(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[ns].modified_&&(js(t),rs(4)),as(e)&&(e=Ns(t,e),t.parent_||Us(t,e)),t.patches_&&Is("Patches").generateReplacementPatches_(n[ns].base_,e,t.patches_,t.inversePatches_)):e=Ns(t,n,[]),js(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==es?e:void 0}function Ns(e,t,n){if(ws(t))return t;const o=t[ns];if(!o)return ds(t,((r,i)=>Rs(e,o,t,r,i,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return Us(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let r=t,i=!1;3===o.type_&&(r=new Set(t),t.clear(),i=!0),ds(r,((r,s)=>Rs(e,o,t,r,s,n,i))),Us(e,t,!1),n&&e.patches_&&Is("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function Rs(e,t,n,o,r,i,s){if("production"!==process.env.NODE_ENV&&r===n&&rs(5),ss(r)){const s=Ns(e,r,i&&t&&3!==t.type_&&!hs(t.assigned_,o)?i.concat(o):void 0);if(ps(n,o,s),!ss(s))return;e.canAutoFreeze_=!1}else s&&n.add(r);if(as(r)&&!ws(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ns(e,r),t&&t.scope_.parent_||Us(e,r)}}function Us(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&bs(t,n)}var Ms={get(e,t){if(t===ns)return e;const n=vs(e);if(!hs(n,t))return function(e,t,n){const o=Ps(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!as(o)?o:o===Ds(e.base_,t)?($s(e),e.copy_[t]=Ws(o,e)):o},has:(e,t)=>t in vs(e),ownKeys:e=>Reflect.ownKeys(vs(e)),set(e,t,n){const o=Ps(vs(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=Ds(vs(e),t),r=o?.[ns];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||hs(e.base_,t)))return!0;$s(e),Ls(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==Ds(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,$s(e),Ls(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=vs(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){rs(11)},getPrototypeOf:e=>is(e.base_),setPrototypeOf(){rs(12)}},Ts={};function Ds(e,t){const n=e[ns];return(n?vs(n):e)[t]}function Ps(e,t){if(!(t in e))return;let n=is(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=is(n)}}function Ls(e){e.modified_||(e.modified_=!0,e.parent_&&Ls(e.parent_))}function $s(e){e.copy_||(e.copy_=ms(e.base_,e.scope_.immer_.useStrictShallowCopy_))}ds(Ms,((e,t)=>{Ts[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Ts.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&rs(13),Ts.set.call(this,e,t,void 0)},Ts.set=function(e,t,n){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&rs(14),Ms.set.call(this,e[0],t,n,e[0])};function Ws(e,t){const n=fs(e)?Is("MapSet").proxyMap_(e,t):gs(e)?Is("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:xs(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=Ms;n&&(r=[o],i=Ts);const{revoke:s,proxy:a}=Proxy.revocable(r,i);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:xs()).drafts_.push(n),n}function zs(e){return ss(e)||rs(10,e),Fs(e)}function Fs(e){if(!as(e)||ws(e))return e;const t=e[ns];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=ms(e,t.scope_.immer_.useStrictShallowCopy_)}else n=ms(e,!0);return ds(n,((e,t)=>{ps(n,e,Fs(t))})),t&&(t.finalized_=!1),n}var Vs=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...r){return o.produce(e,(e=>t.call(this,e,...r)))}}let o;if("function"!=typeof t&&rs(6),void 0!==n&&"function"!=typeof n&&rs(7),as(e)){const r=Ss(this),i=Ws(e,void 0);let s=!0;try{o=t(i),s=!1}finally{s?js(r):Cs(r)}return Os(r,n),As(o,r)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===es&&(o=void 0),this.autoFreeze_&&bs(o,!0),n){const t=[],r=[];Is("Patches").generateReplacementPatches_(e,o,t,r),n(t,r)}return o}rs(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const r=this.produce(e,t,((e,t)=>{n=e,o=t}));return[r,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){as(e)||rs(8),ss(e)&&(e=zs(e));const t=Ss(this),n=Ws(e,void 0);return n[ns].isManual_=!0,Cs(t),n}finishDraft(e,t){const n=e&&e[ns];n&&n.isManual_||rs(9);const{scope_:o}=n;return Os(o,t),As(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Is("Patches").applyPatches_;return ss(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},qs=Vs.produce;Vs.produceWithPatches.bind(Vs),Vs.setAutoFreeze.bind(Vs),Vs.setUseStrictShallowCopy.bind(Vs),Vs.applyPatches.bind(Vs),Vs.createDraft.bind(Vs),Vs.finishDraft.bind(Vs);var Hs=e=>{let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}},Bs=(e,t,n)=>{const{memoize:o,memoizeOptions:r}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...r);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},Ks={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Js=e=>Array.isArray(e)?e:[e];function Ys(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Gs(e,t){const n=[],{length:o}=e;for(let r=0;r<o;r++)n.push(e[r].apply(null,t));return n}var Xs=(e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...Ks,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Hs},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:Bs}}},Zs="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}};function Qs(e,t={}){let n={s:0,v:void 0,o:null,p:null};const{resultEqualityCheck:o}=t;let r,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t={s:0,v:void 0,o:null,p:null},e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t={s:0,v:void 0,o:null,p:null},e.set(n,t)):t=o}}const a=t;let c;if(1===t.s?c=t.v:(c=e.apply(null,arguments),i++),a.s=1,o){const e=r?.deref()??r;null!=e&&o(e,c)&&(c=e,0!==i&&i--);r="object"==typeof c&&null!==c||"function"==typeof c?new Zs(c):c}return a.v=c,c}return s.clearCache=()=>{n={s:0,v:void 0,o:null,p:null},s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function ea(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e;return(...e)=>{let t,o=0,r=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:d=Qs,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=Js(l),f=Js(u),g=Ys(e),v=c((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){r++;const e=Gs(g,arguments);if("production"!==process.env.NODE_ENV){const{identityFunctionCheck:t,inputStabilityCheck:n}=Xs(m,h);if(t.shouldRun&&t.run(s),n.shouldRun){const t=Gs(g,arguments);n.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}m&&(m=!1)}return t=v.apply(null,e),t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:c,argsMemoize:d})}}var ta=ea(Qs);function na(e){return({dispatch:t,getState:n})=>o=>r=>"function"==typeof r?r(t,n,e):o(r)}var oa=na(),ra=na;((...e)=>{const t=ea(...e),n=Object.assign(((...e)=>{const n=t(...e),o=(e,...t)=>n(ss(e)?zs(e):e,...t);return Object.assign(o,n),o}),{withTypes:()=>n})})(Qs);var ia="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Zi:Zi.apply(null,arguments)},sa=e=>e&&"function"==typeof e.match;function aa(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("production"===process.env.NODE_ENV?Ba(0):"prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Qi(t)&&t.type===e,n}function ca(e){return"function"==typeof e&&"type"in e&&sa(e)}function la(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var da=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function ua(e){return as(e)?qs(e,(()=>{})):e}function ha(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("production"===process.env.NODE_ENV?Ba(10):"No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function pa(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function fa(e,t,n){const o=ga(e,t,n);return{detectMutations:()=>va(e,t,o,n)}}function ga(e,t=[],n,o="",r=new Set){const i={value:n};if(!e(n)&&!r.has(n)){r.add(n),i.children={};for(const r in n){const s=o?o+"."+r:r;t.length&&-1!==t.indexOf(s)||(i.children[r]=ga(e,t,n[r],s))}}return i}function va(e,t=[],n,o,r=!1,i=""){const s=n?n.value:void 0,a=s===o;if(r&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:i};if(e(s)||e(o))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let r in c){const s=i?i+"."+r:r;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=va(e,t,n.children[r],o[r],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function ma(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Bi(e)}function ba(e,t="",n=ma,o,r=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),c=r.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(r.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=ba(l,a,n,o,r,i),s))return s}return i&&ya(e)&&i.add(e),!1}function ya(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!ya(t))return!1;return!0}function wa(e){return"boolean"==typeof e}var ka=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:r=!0}=e??{};let i=new da;if(t&&(wa(t)?i.push(oa):i.push(ra(t.extraArgument))),"production"!==process.env.NODE_ENV){if(n){let e={};wa(n)||(e=n),i.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{let t=function(e,t,o,r){return JSON.stringify(e,n(t,r),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(r,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,r):o.push(r),~n.indexOf(i)&&(i=t.call(this,r,i))}else n.push(i);return null==e?i:e.call(this,r,i)}},{isImmutable:o=pa,ignoredPaths:r,warnAfter:i=32}=e;const s=fa.bind(null,o,r);return({getState:e})=>{let n,o=e(),r=s(o);return a=>c=>{const l=la(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error("production"===process.env.NODE_ENV?Ba(19):`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(c);return l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error("production"===process.env.NODE_ENV?Ba(20):`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),d}}}}(e))}if(o){let e={};wa(o)||(e=o),i.push(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{const{isSerializable:t=ma,getEntries:n,ignoredActions:o=[],ignoredActionPaths:r=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!Qi(u))return l(u);const h=l(u),p=la(s,"SerializableStateInvariantMiddleware");return c||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=ba(u,"",t,n,r,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const o=ba(e.getState(),"",t,n,i,d);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(r){let e={};wa(r)||(e=r),i.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);const{isActionCreator:t=ca}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}}return i},Ea=e=>t=>{setTimeout(t,e)},Ia="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Ea(10),xa=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new da(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let r=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?Ia:"callback"===e.type?e.queueNotification:Ea(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>r&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return r=!e?.meta?.RTK_autoBatch,i=!r,i&&(s||(s=!0,c(l))),o.dispatch(e)}finally{r=!0}}})})("object"==typeof n?n:void 0)),o},Oa="production"===process.env.NODE_ENV;function ja(e){const t=ka(),{reducer:n,middleware:o,devTools:r=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!Bi(n))throw new Error("production"===process.env.NODE_ENV?Ba(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=Xi(n)}if(!Oa&&o&&"function"!=typeof o)throw new Error("production"===process.env.NODE_ENV?Ba(2):"`middleware` field must be a callback");if("function"==typeof o){if(c=o(t),!Oa&&!Array.isArray(c))throw new Error("production"===process.env.NODE_ENV?Ba(3):"when using a middleware builder function, an array of middleware must be returned")}else c=t();if(!Oa&&c.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?Ba(4):"each middleware provided to configureStore must be a function");let l=Zi;r&&(l=ia({trace:!Oa,..."object"==typeof r&&r}));const d=function(...e){return t=>(n,o)=>{const r=t(n,o);let i=()=>{throw new Error("production"===process.env.NODE_ENV?Fi(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:r.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=Zi(...a)(r.dispatch),{...r,dispatch:i}}}(...c),u=xa(d);if(!Oa&&s&&"function"!=typeof s)throw new Error("production"===process.env.NODE_ENV?Ba(5):"`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Oa&&!Array.isArray(h))throw new Error("production"===process.env.NODE_ENV?Ba(6):"`enhancers` callback must return an array");if(!Oa&&h.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?Ba(7):"each enhancer provided to configureStore must be a function");Oa||!c.length||h.includes(d)||console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Yi(a,i,l(...h))}function Ca(e){const t={},n=[];let o;const r={addCase(e,i){if("production"!==process.env.NODE_ENV){if(n.length>0)throw new Error("production"===process.env.NODE_ENV?Ba(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("production"===process.env.NODE_ENV?Ba(27):"`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const s="string"==typeof e?e:e.type;if(!s)throw new Error("production"===process.env.NODE_ENV?Ba(28):"`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error("production"===process.env.NODE_ENV?Ba(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,r},addMatcher(e,t){if("production"!==process.env.NODE_ENV&&o)throw new Error("production"===process.env.NODE_ENV?Ba(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),r},addDefaultCase(e){if("production"!==process.env.NODE_ENV&&o)throw new Error("production"===process.env.NODE_ENV?Ba(31):"`builder.addDefaultCase` can only be called once");return o=e,r}};return e(r),[t,n,o]}var Sa=(e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t};function _a(...e){return t=>e.some((e=>((e,t)=>sa(e)?e.match(t):e(t))(e,t)))}var Aa=["name","message","stack","code"],Na=class{constructor(e,t){this.payload=e,this.meta=t}_type},Ra=class{constructor(e,t){this.payload=e,this.meta=t}_type},Ua=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Aa)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},Ma=(()=>{function e(e,t,n){const o=aa(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),r=aa(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=aa(e+"/rejected",((e,t,o,r,i)=>({payload:r,error:(n&&n.serializeError||Ua)(e||"Rejected"),meta:{...i||{},arg:o,requestId:t,rejectedWithValue:!!r,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):Sa(),d=new AbortController;let u,h;function p(e){h=e,d.abort()}const f=async function(){let f;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(g=i)&&"object"==typeof g&&"function"==typeof g.then&&(i=await i),!1===i||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const v=new Promise(((e,t)=>{u=()=>{t({name:"AbortError",message:h||"Aborted"})},d.signal.addEventListener("abort",u)}));s(r(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),f=await Promise.race([v,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:d.signal,abort:p,rejectWithValue:(e,t)=>new Na(e,t),fulfillWithValue:(e,t)=>new Ra(e,t)})).then((t=>{if(t instanceof Na)throw t;return t instanceof Ra?o(t.payload,l,e,t.meta):o(t,l,e)}))])}catch(t){f=t instanceof Na?i(null,l,e,t.payload,t.meta):i(t,l,e)}finally{u&&d.signal.removeEventListener("abort",u)}var g;return n&&!n.dispatchConditionRejection&&i.match(f)&&f.meta.condition||s(f),f}();return Object.assign(f,{abort:p,requestId:l,arg:e,unwrap:()=>f.then(Ta)})}}),{pending:r,rejected:i,fulfilled:o,settled:_a(i,o),typePrefix:e})}return e.withTypes=()=>e,e})();function Ta(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var Da=Symbol.for("rtk-slice-createasyncthunk");function Pa(e,t){return`${e}/${t}`}function La(e,t,n,o){function r(r,...i){let s=t(r);if(void 0===s)if(o)s=n();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?Ba(16):"selectState returned undefined for an uninjected slice reducer");return e(s,...i)}return r.unwrapped=e,r}var $a=function({creators:e}={}){const t=e?.asyncThunk?.[Da];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("production"===process.env.NODE_ENV?Ba(11):"`name` is a required option for createSlice");"undefined"!=typeof process&&"development"===process.env.NODE_ENV&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const r=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(r),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("production"===process.env.NODE_ENV?Ba(12):"`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("production"===process.env.NODE_ENV?Ba(13):"`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("production"!==process.env.NODE_ENV&&"object"==typeof e.extraReducers)throw new Error("production"===process.env.NODE_ENV?Ba(14):"The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?Ca(e.extraReducers):[e.extraReducers],r={...t,...s.sliceCaseReducersByType};return function(e,t){if("production"!==process.env.NODE_ENV&&"object"==typeof t)throw new Error("production"===process.env.NODE_ENV?Ba(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,r,i]=Ca(t);if(function(e){return"function"==typeof e}(e))n=()=>ua(e());else{const t=ua(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...r.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(ss(e)){const o=n(e,t);return void 0===o?e:o}if(as(e))return qs(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("production"===process.env.NODE_ENV?Ba(9):"A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in r)e.addCase(t,r[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}i.forEach((o=>{const i=r[o],s={reducerName:o,type:Pa(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,r){let i,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("production"===process.env.NODE_ENV?Ba(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=o.reducer,s=o.prepare}else i=o;r.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?aa(e,s):aa(e))}(s,i,a):function({type:e,reducerName:t},n,o,r){if(!r)throw new Error("production"===process.env.NODE_ENV?Ba(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:d}=n,u=r(e,i,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);c&&o.addCase(u.rejected,c);l&&o.addMatcher(u.settled,l);o.exposeCaseReducer(t,{fulfilled:s||Wa,pending:a||Wa,rejected:c||Wa,settled:l||Wa})}(s,i,a,t)}));const l=e=>e,d=new Map;let u;function h(e,t){return u||(u=c()),u(e,t)}function p(){return u||(u=c()),u.getInitialState()}function f(t,n=!1){function o(e){let o=e[t];if(void 0===o)if(n)o=p();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?Ba(15):"selectSlice returned undefined for an uninjected slice reducer");return o}function r(t=l){const o=ha(d,n,{insert:()=>new WeakMap});return ha(o,t,{insert:()=>{const o={};for(const[r,i]of Object.entries(e.selectors??{}))o[r]=La(i,t,p,n);return o}})}return{reducerPath:t,getSelectors:r,get selectors(){return r(o)},selectSlice:o}}const g={name:n,reducer:h,actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:p,...f(o),injectInto(e,{reducerPath:t,...n}={}){const r=t??o;return e.inject({reducerPath:r,reducer:h},n),{...g,...f(r,!0)}}};return g}}();function Wa(){}var za="listenerMiddleware",Fa=e=>{let{type:t,actionCreator:n,matcher:o,predicate:r,effect:i}=e;if(t)r=aa(t).match;else if(n)t=n.type,r=n.match;else if(o)r=o;else if(!r)throw new Error("production"===process.env.NODE_ENV?Ba(21):"Creating or removing a listener requires one of the known fields for matching an action");return((e,t)=>{if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?Ba(32):`${t} is not a function`)})(i,"options.listener"),{predicate:r,type:t,effect:i}},Va=Object.assign((e=>{const{type:t,predicate:n,effect:o}=Fa(e);return{id:Sa(),effect:o,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error("production"===process.env.NODE_ENV?Ba(22):"Unsubscribe not initialized")}}}),{withTypes:()=>Va}),qa=Object.assign(aa(`${za}/add`),{withTypes:()=>qa});aa(`${za}/removeAll`);var Ha=Object.assign(aa(`${za}/remove`),{withTypes:()=>Ha});function Ba(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}function Ka(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const Ja=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const o=e(n);return o[t]=!0,o}},Ya=Ja((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&h(this,t,"f")&&(p(this,t,!1,"f"),this.init())}init(){return u(this,void 0,void 0,(function*(){}))}},t=new WeakMap,n})),Ga=["error","warn","info","debug"],Xa=Ja((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,h(this,t,"m",o).call(this,console))}set logger(e){p(this,n,h(this,t,"m",o).call(this,e),"f")}get logger(){return h(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,o=function(e){return Ga.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},r})),Za=Ja((e=>{var t,n,o,r,i,s,a;return a=class extends(Ka(Ya,Xa)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),"debug"===e&&h(this,t,"m",i).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&h(this,t,"m",s).call(this,n[0]||"Error",n[1])}init(){const e=Object.create(null,{init:{get:()=>super.init}});var n;return u(this,void 0,void 0,(function*(){yield null===(n=e.init)||void 0===n?void 0:n.call(this),h(this,t,"m",i).call(this)}))}},n=new WeakMap,t=new WeakSet,o=function(){var e;null===(e=h(this,n,"f"))||void 0===e||e.remove(),p(this,n,null,"f")},r=function(){return u(this,void 0,void 0,(function*(){p(this,n,document.createElement("descope-debugger"),"f"),Object.assign(h(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return ud})),document.body.appendChild(h(this,n,"f"))}))},i=function(){this.debug?h(this,t,"m",r).call(this):h(this,t,"m",o).call(this)},s=function(e,t){var o;e&&(null===(o=h(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},a})),Qa=e=>{let t,n;return(...o)=>{return t&&(i=o,(r=t).length===i.length&&r.every(((e,t)=>e===i[t])))||(t=o,n=e(...o)),n;var r,i}},ec=e=>(t,...n)=>t.reduce(((t,o,r)=>{var i;return`${t}${o}${(null===(i=null==n?void 0:n[r])||void 0===i?void 0:i[e>1?1:0])||""}`}),""),tc=(e,t=500)=>{let n;return function(...o){clearTimeout(n),n=setTimeout((()=>e.apply(this,o)),t)}},nc="undefined"!=typeof localStorage,oc=nc&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",rc=(e,t)=>!t&&`${e} cannot be empty`,ic=Ja((e=>{var t,n;const o=Ka(Xa,Ya)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var n;return u(this,void 0,void 0,(function*(){var o;yield null===(n=e.init)||void 0===n?void 0:n.call(this),o=e=>{var n;null===(n=h(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(this.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(this,{attributes:!0})}))}observeAttribute(e,n){h(this,t,"f")[e]||(h(this,t,"f")[e]=[]);const o=h(this,t,"f")[e].push(n);return()=>h(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),sc=e=>t=>{var n,o,r;const i=Ka(Xa,Ya,ic)(t),s=Object.keys(e);return r=class extends i{constructor(...e){super(...e),n.add(this),this.observeAttributes(s,h(this,n,"m",o).bind(this))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return u(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),s.forEach((e=>h(this,n,"m",o).call(this,e,this.getAttribute(e))))}))}},n=new WeakSet,o=function(t,n){const o=e[t],r="function"==typeof o?o(t,n):o;r&&this.logger.error(r)},r},ac=Ja((e=>{const t=Ka(sc({"project-id":rc}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),cc=Ja((e=>{const t=Ka(Xa,ac)(e);return class extends t{fetchStaticResource(e,t){return u(this,void 0,void 0,(function*(){const n=function(e,t,n="v2-beta"){const o=new URL(oc);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}(this.projectId,e),o=yield fetch(n,{cache:"default"});return o.ok||this.logger.error(`Error fetching URL ${n} [${o.status}]`),{body:yield o[t](),headers:Object.fromEntries(o.headers.entries())}}))}}})),lc=Ja((e=>{var t,n,o;const r=Ka(cc)(e);return o=class extends r{constructor(){super(...arguments),t.set(this,void 0),n.set(this,(()=>u(this,void 0,void 0,(function*(){try{const{body:e,headers:t}=yield this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))))}get config(){return h(this,t,"f")||p(this,t,h(this,n,"f").call(this),"f"),h(this,t,"f")}},t=new WeakMap,n=new WeakMap,o})),dc="load-descope-ui-script",uc="base.ui.components.url",hc=nc&&localStorage.getItem(uc)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",pc=nc&&localStorage.getItem(uc)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",fc=e=>{const t=document.createElement("script");return t.id=e,t},gc=(e,t)=>e.replace("<version>",t),vc=Ja((e=>{var t,n,o,r,i,s,a,c,l,d,f,g;const v=Ka(Xa,lc)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),o.set(this,Symbol("loadCbs")),l.set(this,void 0)}get descopeUi(){return h(this,l,"f")||p(this,l,h(this,t,"m",f).call(this),"f"),h(this,l,"f")}loadDescopeUiComponents(e){return u(this,void 0,void 0,(function*(){const n=Array.isArray(e)?e:(o=e,[...Array.from(o.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)]);var o;return Promise.all(n.map((e=>h(this,t,"m",d).call(this,e))))}))}},n=new WeakMap,o=new WeakMap,l=new WeakMap,t=new WeakSet,r=function(){var e;return u(this,void 0,void 0,(function*(){const t=yield this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n}))},i=function(e){const t=h(this,n,"f"),r=h(this,o,"f");e[t]=[],e[r]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[r].push(t)}})},s=function(e,n){return u(this,void 0,void 0,(function*(){this.logger.debug("Trying to load DescopeUI from a fallback URL");const o=fc("load-descope-ui-fallback-script");document.body.append(o),o.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${o.src}"`)))})),o.addEventListener("load",(()=>{n.forEach((e=>e()))})),o.src=gc(pc,yield h(this,t,"m",r).call(this))}))},a=function(e){e.addEventListener("error",(()=>{e[h(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),h(this,t,"m",s).call(this,e[h(this,n,"f")],e[h(this,o,"f")])})),e.addEventListener("load",(()=>{e[h(this,o,"f")].forEach((e=>e()))}))},c=function(){return u(this,void 0,void 0,(function*(){if(document.getElementById(dc))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=fc(dc);document.body.append(e),h(this,t,"m",i).call(this,e),h(this,t,"m",a).call(this,e),e.src=gc(hc,yield h(this,t,"m",r).call(this))}return document.getElementById(dc)}))},d=function(e){return u(this,void 0,void 0,(function*(){if(customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=yield this.descopeUi;if(t[e])try{return yield t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)}))},f=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),h(this,t,"m",c).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),mc="content-root",bc="root",yc=Ja((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${bc}, #${mc} {\n height: 100%;\n }\n </style>\n <div id="${bc}">\n <div id="${mc}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(mc),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(bc)}})),wc=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',kc=Ja((e=>{var t,n,o,r,i,s,a,c,l;const d=Ka(sc({theme:wc}),cc,Ya,vc,lc,yc)(e);return l=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get theme(){var e,t;const n=this.getAttribute("theme");return"os"===n?window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light":n||"light"}init(){const e=Object.create(null,{init:{get:()=>super.init}});var n;return u(this,void 0,void 0,(function*(){yield null===(n=e.init)||void 0===n?void 0:n.call(this),h(this,t,"m",i).call(this),h(this,t,"m",s).call(this),h(this,t,"m",a).call(this),h(this,t,"m",c).call(this)}))}},n=new WeakMap,t=new WeakSet,o=function(){return u(this,void 0,void 0,(function*(){try{const{body:e}=yield this.fetchStaticResource("theme.json","json");return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},r=function(){return h(this,n,"f")||(p(this,n,h(this,t,"m",o).call(this),"f"),h(this,n,"f").then((e=>this.logger.debug("Fetched theme",e)))),h(this,n,"f")},i=function(){var e,n;return u(this,void 0,void 0,(function*(){const o=yield h(this,t,"a",r);if(!o)return;const i=document.createElement("style");i.innerText=((null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.globals)||"")+((null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.globals)||""),this.shadowRoot.appendChild(i)}))},s=function(){var e,n;return u(this,void 0,void 0,(function*(){const o=Object.assign({},yield h(this,t,"a",r));if(!o)return;const i=yield this.descopeUi;(null==i?void 0:i.componentsThemeManager)&&(i.componentsThemeManager.themes={light:null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})}))},a=function(){var e,t;return u(this,void 0,void 0,(function*(){const{projectConfig:n}=yield this.config,o=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;o&&Object.values(o).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))}))}))},c=function(){return u(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},l}));var Ec;class Ic{constructor(e,t){Ec.set(this,void 0),this.nodeName="",p(this,Ec,e,"f"),this.logger=t.logger}get ele(){var e,t;const n="function"==typeof h(this,Ec,"f")?h(this,Ec,"f").call(this):h(this,Ec,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug("no element for driver ",this.constructor.name,new Error),null)}}Ec=new WeakMap;class xc extends Ic{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}}const Oc=e=>{const t=document.createElement("template");return t.innerHTML=e,t},jc=Ja((e=>class extends(Ka(Xa)(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{e.value=t[e.getAttribute("name")]}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value=""}))}})),Cc="descope-modal";var Sc;class _c extends Ic{constructor(){super(...arguments),Sc.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}open(){var e,t;null===(e=this.beforeOpen)||void 0===e||e.call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),h(this,Sc,"f")&&(null===(e=this.ele)||void 0===e||e.append(h(this,Sc,"f").content.cloneNode(!0)))}setContent(e){p(this,Sc,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}Sc=new WeakMap;const Ac=Ja((e=>{var t,n;const o=Ka(Ya,yc,vc)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends _c{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(Cc);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(h(this,t,"f"))(n,{logger:this.logger})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return u(this,void 0,void 0,(function*(){this.loadDescopeUiComponents([Cc]),yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}},t=new WeakMap,n})),Nc=e=>Ja((t=>{const n=$a(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(Ka(Xa)(t)){constructor(...e){super(...e);const t=ja({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),r=e=>(...n)=>u(this,void 0,void 0,(function*(){const o=yield t.dispatch(e(...n));try{Ta(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o})),i=Object.keys(o).reduce(((e,t)=>(e[t]=r(o[t]),e)),{});this.actions=i,this.subscribe=(e,n=(e=>e))=>t.subscribe((()=>e(n(t.getState()))))}}})),Rc=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Uc=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Mc=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),Tc=Ma("users/create",((e,{extra:{api:t}})=>t.user.create(e))),Dc=Rc(Tc)({onFulfilled:(e,t)=>{e.usersList.data.unshift(t.payload)}},Uc((e=>e.createUser)),Mc({getSuccessMsg:()=>"User created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Pc={action:Tc,reducer:Dc},Lc=Ma("users/delete",((e,{extra:{api:t}})=>t.user.deleteBatch(e))),$c=Rc(Lc)({onFulfilled:(e,t)=>{e.usersList.data=e.usersList.data.filter((e=>!t.meta.arg.includes(e.userId))),e.selectedUsersLoginIds=[]}},Uc((e=>e.deleteUser)),Mc({getSuccessMsg:e=>ec(e.meta.arg.length)`${["",e.meta.arg.length]} ${["U","u"]}ser${["","s"]} deleted successfully`,getErrorMsg:e=>ec(e.meta.arg.length)`Failed to delete user${["","s"]}`})),Wc={action:Lc,reducer:$c},zc=Ma("users/expirePassword",((e,{extra:{api:t}})=>t.user.expirePassword(e))),Fc={action:zc,reducer:Rc(zc)(Uc((e=>e.expireUserPassword)))},Vc=Ma("users/getCustomAttributes",((e,{extra:{api:t}})=>t.user.getCustomAttributes())),qc=Rc(Vc)({onFulfilled:(e,t)=>{e.customAttributes.data=t.payload}},Uc((e=>e.customAttributes)),Uc((e=>e.customAttributes))),Hc={action:Vc,reducer:qc},Bc={enabled:"active"},Kc=e=>e.selectedUsersLoginIds,Jc=e=>e.notifications,Yc=ta((e=>e.usersList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{status:Bc[e.status]||e.status}))))),Gc=ta(Yc,Kc,((e,t)=>e.filter((e=>t.includes(e.loginIds))).map((e=>e.userId)))),Xc=ta(Kc,Yc,((e,t)=>t.filter((t=>e.includes(t.loginIds))))),Zc=ta(Kc,(e=>!!e.length)),Qc=ta(Xc,(e=>1===e.length?e[0].email:`${e.length} users`)),el=Ma("users/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.user.search(Object.assign(Object.assign({},o),e))})),tl={action:el,reducer:Rc(el)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.usersList.data=t.payload}},Uc((e=>e.usersList)))},nl={usersList:{data:[],loading:!1,error:null},createUser:{loading:!1,error:null},deleteUser:{loading:!1,error:null},expireUserPassword:{loading:!1,error:null},customAttributes:{loading:!1,error:null,data:{}},searchParams:{text:"",sort:[]},selectedUsersLoginIds:[],notifications:[]},ol="/v1/mgmt/user/search",rl="/v1/mgmt/user/delete/batch",il="/v1/mgmt/user/create",sl="/v1/mgmt/user/password/expire",al="/v1/mgmt/user/customattributes",cl=e=>u(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),ll=({httpClient:e,tenant:t})=>({search:({page:n,limit:o=1e4,customAttributes:r,statuses:i,emails:s,phones:a,text:c,sort:l}={})=>u(void 0,void 0,void 0,(function*(){const d=yield e.post(ol,{limit:o,page:n,withTestUser:!1,customAttributes:r,statuses:i,emails:s,phones:a,text:c,sort:l},{queryParams:{tenant:t}});return yield cl(d),(yield d.json()).users})),deleteBatch:n=>u(void 0,void 0,void 0,(function*(){const o=yield e.post(rl,{userIds:n},{queryParams:{tenant:t}});return yield cl(o),o.json()})),create:({loginId:n,email:o,phone:r,displayName:i,roles:s,customAttributes:a,picture:c,verifiedEmail:l,verifiedPhone:d,givenName:h,middleName:p,familyName:f,additionalLoginIds:g,sendSMS:v,sendMail:m,inviteUrl:b,invite:y})=>u(void 0,void 0,void 0,(function*(){const u=yield e.post(il,{loginId:n,email:o,phone:r,displayName:i,givenName:h,middleName:p,familyName:f,roleNames:s,userTenants:[{tenantId:t}],customAttributes:a,picture:c,verifiedEmail:l,verifiedPhone:d,additionalLoginIds:g,sendSMS:v,sendMail:m,inviteUrl:b,invite:y},{queryParams:{tenant:t}});return yield cl(u),(yield u.json()).user})),expirePassword:n=>u(void 0,void 0,void 0,(function*(){const o=yield e.post(sl,{loginId:n[0]},{queryParams:{tenant:t}});return yield cl(o),o.json()})),getCustomAttributes:()=>u(void 0,void 0,void 0,(function*(){const n=yield e.get(al,{queryParams:{tenant:t}});return yield cl(n),n.json()}))}),dl=Ja((e=>{var t,n,o,r;const i=Ka(ac,ic,Xa,sc({tenant:rc}))(e);return r=class extends i{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get baseUrl(){return this.getAttribute("base-url")}get tenant(){return this.getAttribute("tenant")}get api(){return h(this,n,"f")||h(this,t,"m",o).call(this),h(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});var r;return u(this,void 0,void 0,(function*(){yield null===(r=e.init)||void 0===r?void 0:r.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{h(this,n,"f")&&h(this,t,"m",o).call(this)}))}))}},n=new WeakMap,t=new WeakSet,o=function(){this.logger.debug("creating an sdk instance"),p(this,n,((e,t)=>{const n=To(Object.assign(Object.assign({},e),{persistTokens:!0}));return{user:ll({httpClient:n.httpClient,tenant:t})}})({projectId:this.projectId,baseUrl:this.baseUrl},this.tenant),"f")},r})),ul=Ja((e=>{const t=Ka(Nc({name:"widget",initialState:nl,reducers:{setSelectedUsersIds:(e,{payload:t})=>{e.selectedUsersLoginIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Pc.reducer(e),Wc.reducer(e),tl.reducer(e),Fc.reducer(e),Hc.reducer(e)},asyncActions:{searchUsers:tl.action,createUser:Pc.action,deleteUsers:Wc.action,expireUserPassword:Fc.action,getCustomAttributes:Hc.action}}),Ya,Xa,dl)(e);return class extends t{constructor(...e){super(...e),this.state=nl,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),hl=Ja((e=>{var t,n,o;return o=class extends(Ka(Xa,Ya,vc,yc)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return u(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var o;return u(this,void 0,void 0,(function*(){yield null===(o=e.init)||void 0===o?void 0:o.call(this),h(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return u(this,void 0,void 0,(function*(){const e=Oc('\n<descope-container\n direction="column"\n space-between="md"\n st-horizontal-padding="1rem"\n st-vertical-padding="1rem"\n st-align-items="safe center"\n st-gap="1rem"\n>\n <descope-container\n direction="row"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-align-items="safe center"\n st-gap="0rem"\n st-justify-content="space-between"\n >\n <descope-text-field data-testid="search-input" data-id="search-input" placeholder="Search" size="sm" bordered="true"></descope-text-field>\n\n <descope-container\n direction="row"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-justify-content="flex-end"\n st-gap="0.5em"\n st-host-width="auto"\n >\n <descope-button data-testid="delete-users-trigger" data-id="delete-users" mode="primary" variant="outline" size="sm">Delete</descope-button>\n <descope-button data-testid="create-user-trigger" data-id="create-user" mode="primary" variant="contained" size="sm">+ User</descope-button>\n </descope-container>\n </descope-container>\n <descope-grid\n data-id="users-table"\n size="sm"\n column-reordering-allowed\n st-host-height="300px"\n style="width: 100%"\n >\n <descope-grid-selection-column frozen auto-width></descope-grid-selection-column>\n <descope-grid-text-column path="loginIds" header="Login ID" resizable></descope-grid-text-column>\n <descope-grid-text-column sortable="true" path="name" header="Name" resizable></descope-grid-text-column>\n <descope-grid-custom-column sortable="true" path="status" header="Status" resizable>\n <descope-badge mode="default" pattern="invited" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n <descope-badge mode="primary" pattern="active" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n <descope-badge mode="error" pattern="disabled" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>\n </descope-grid-custom-column>\n <descope-grid-text-column sortable="true" path="email" header="Email" resizable></descope-grid-text-column>\n <descope-grid-text-column sortable="true" path="phone" header="Phone" resizable></descope-grid-text-column>\n </descope-grid>\n </descope-container>\n');yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0)),this.onWidgetRootReady()}))},o})),pl=Ja((e=>{var t,n,o;return o=class extends(Ka(ul,Ac,jc,Xa,hl)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var o;return u(this,void 0,void 0,(function*(){yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),h(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return u(this,void 0,void 0,(function*(){this.createUserModal=this.createModal(),this.createUserModal.setContent(Oc('\n<descope-container\n direction="column"\n st-justify-content="safe center"\n st-gap="1rem"\n st-host-width="100%"\n st-background-color="none"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-border-radius="sm"\n>\n <descope-text variant="subtitle1" mode="surface">New User</descope-text>\n <descope-text-field name="loginId" label="Login ID" bordered="true" required="true" size="sm"></descope-text-field>\n <descope-email-field name="email" label="Email" bordered="true"></descope-email-field>\n <descope-text-field name="displayName" label="Name" bordered="true"></descope-text-field>\n <descope-phone-field name="phone" label="Phone" bordered="true"></descope-phone-field>\n\n <descope-container\n direction="row"\n st-justify-content="flex-end"\n st-gap="1rem"\n st-host-width="100%"\n st-horizontal-padding="0.75rem"\n st-vertical-padding="0.75rem"\n st-background-color="none"\n >\n <descope-button data-testid="create-user-modal-cancel" data-id="modal-cancel" mode="primary" variant="link" size="sm">Cancel</descope-button>\n <descope-button data-testid="create-user-modal-submit" data-id="modal-submit" mode="primary" variant="contained" size="sm">Create</descope-button>\n </descope-container>\n</descope-container>\n'));new xc((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.createUserModal.close()));const e=new xc((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});e.onClick((()=>u(this,void 0,void 0,(function*(){this.validateForm(this.createUserModal.ele)&&(this.actions.createUser(Object.assign(Object.assign({},this.getFormData(this.createUserModal.ele)),{invite:!0,verifiedEmail:!0,verifiedPhone:!0})),this.createUserModal.close(),this.resetFormData(this.createUserModal.ele))}))))}))},o})),fl=Ja((e=>{var t,n,o;return o=class extends(Ka(Xa,pl,hl)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var o;return u(this,void 0,void 0,(function*(){yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),h(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;this.createButton=new xc(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-user"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createUserModal.open()))},o}));class gl extends Ic{constructor(){super(...arguments),this.nodeName="descope-text"}get ele(){return super.ele}get text(){var e;return null===(e=this.ele)||void 0===e?void 0:e.innerText}set text(e){this.ele&&(this.ele.innerText=e)}}const vl=Ja((e=>{var t,n,o;return o=class extends(Ka(ul,Ac,Xa,hl)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var o;return u(this,void 0,void 0,(function*(){yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),yield h(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;return u(this,void 0,void 0,(function*(){this.deleteUsersModal=this.createModal(),this.deleteUsersModal.setContent(Oc('\n<descope-container\n direction="column"\n st-justify-content="safe center"\n st-gap="1rem"\n st-host-width="100%"\n st-background-color="none"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-border-radius="sm"\n data-testid="delete-users-modal"\n>\n <descope-text variant="subtitle1" mode="surface">Delete Users</descope-text>\n <descope-text data-id="body-text" variant="body1" mode="surface">Delete user</descope-text>\n\n <descope-container \n direction="row"\n st-justify-content="flex-end"\n st-gap="1rem"\n st-host-width="100%"\n st-horizontal-padding="0rem"\n st-vertical-padding="0rem"\n st-background-color="none"\n >\n <descope-button data-testid="delete-users-modal-cancel" data-id="modal-cancel" mode="primary" variant="link" size="md">Cancel</descope-button>\n <descope-button data-testid="delete-users-modal-submit" data-id="modal-submit" mode="error" variant="contained" size="md">Delete</descope-button>\n </descope-container>\n</descope-container>\n'));const t=new xc((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteUsersModal.close()));const n=new xc((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=Gc(this.state);this.actions.deleteUsers(e),this.deleteUsersModal.close()}));const o=new gl(null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteUsersModal.beforeOpen=()=>{const e=Qc(this.state);o.text=`Delete ${e}?`}}))},o})),ml=Ja((e=>{var t,n,o,r;return r=class extends(Ka(Xa,hl,ul,vl)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Qa((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var r;return u(this,void 0,void 0,(function*(){yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),h(this,t,"m",n).call(this),this.subscribe(h(this,o,"f").bind(this),Zc)}))}},o=new WeakMap,t=new WeakSet,n=function(){var e;this.deleteButton=new xc(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-users"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteUsersModal.open()}))},r}));class bl extends Ic{constructor(){super(...arguments),this.nodeName="descope-text-field"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}}const yl=Ja((e=>{var t,n,o,r;return r=class extends(Ka(Xa,hl,ul)(e)){constructor(){super(...arguments),t.add(this),n.set(this,tc((()=>{this.actions.searchUsers({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var n;return u(this,void 0,void 0,(function*(){yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),h(this,t,"m",o).call(this)}))}},n=new WeakMap,t=new WeakSet,o=function(){var e;this.searchInput=new bl(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(h(this,n,"f"))},r})),wl="descope-notification";class kl extends Ic{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}const El=Ja((e=>{var t,n;const o=Ka(Ya,yc,vc)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends kl{setContent(t){const n="string"==typeof t?Oc(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(wl);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(h(this,t,"f"))(n,{logger:this.logger})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return u(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.loadDescopeUiComponents([wl])}))}},t=new WeakMap,n})),Il={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="white"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="#FFDFDD"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},xl=Ja((e=>{var t,n,o,r,i;return i=class extends(Ka(Xa,ul,El,Ya)(e)){constructor(){super(...arguments),t.add(this),r.set(this,Qa((e=>{e.length&&(e.forEach((({type:e,msg:r})=>{const i=h(this,t,"m",o).call(this,e);i.setContent(h(this,t,"m",n).call(this,{type:e,msg:r})),i.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return u(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(h(this,r,"f").bind(this),Jc)}))}},r=new WeakMap,t=new WeakSet,n=function({type:e,msg:t}){const n=Il[e],o=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="white"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${o.outerHTML}`},o=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},i})),Ol=/^descope-grid-([^-]+)-column$/,jl={text:class extends Ic{constructor(){super(...arguments),this.nodeName="descope-grid-text-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}},custom:class extends Ic{constructor(){super(...arguments),this.nodeName="descope-grid-custom-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}}};class Cl extends Ic{constructor(){super(...arguments),this.nodeName="descope-grid"}onSelectedItemsChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("selected-items-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get columns(){return this.ele?Array.from(this.ele.children).reduce(((e,t)=>{var n;const o=null===(n=Ol.exec(t.localName))||void 0===n?void 0:n[1],r=jl[o];return r?(e.push(new r(t,{logger:this.logger})),e):e}),[]):[]}}const Sl=Ja((e=>{var t,n,o,r,i;return i=class extends(Ka(ul,Xa,hl)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Qa((e=>{this.usersTable.data=e}))),r.set(this,tc(((e,t)=>{const n=[],{value:o}=t;if(o){const t=e.path;n.push({field:t,desc:"desc"===o})}this.actions.searchUsers({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return u(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),h(this,t,"m",n).call(this),this.usersTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{h(this,r,"f").call(this,e.target,e.detail)}))})),h(this,o,"f").call(this,Yc(this.state)),this.subscribe(h(this,o,"f").bind(this),Yc)}))}},o=new WeakMap,r=new WeakMap,t=new WeakSet,n=function(){var e;this.usersTable=new Cl(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="users-table"]'),{logger:this.logger}),this.usersTable.onSelectedItemsChange((e=>{this.actions.setSelectedUsersIds(e.detail.value.map((({loginIds:e})=>e)))}))},i})),_l=Ja((e=>class extends(Ka(Za,kc,Sl,fl,ml,yl,xl)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return u(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.actions.searchUsers()}))}})),Al=Ka((e=>class extends(Ka(_l)(e)){}))(HTMLElement);customElements.define("descope-user-management-widget",Al);var Nl=Object.freeze({__proto__:null,default:Al});const Rl=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Ul,Ml,Tl,Dl,Pl,Ll,$l,Wl,zl,Fl;const Vl=document.createElement("template");Vl.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class ql extends HTMLElement{constructor(){super(),Ul.add(this),Ml.set(this,new Pr({messages:[]})),Tl.set(this,void 0),Dl.set(this,void 0),Pl.set(this,void 0),Ll.set(this,{resize:h(this,Ul,"m",Fl).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Vl.content.cloneNode(!0)),p(this,Tl,this.shadowRoot.querySelector(".debugger"),"f"),p(this,Dl,h(this,Tl,"f").querySelector(".content"),"f"),p(this,Pl,h(this,Tl,"f").querySelector(".header"),"f")}updateData(e){h(this,Ml,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=Rl(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(h(this,Tl,"f"),h(this,Pl,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",h(this,Ll,"f").resize),(e=h(this,Tl,"f")).onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight},h(this,Tl,"f").onresize=h(this,Ul,"m",zl).bind(this),h(this,Ml,"f").subscribe(h(this,Ul,"m",$l).bind(this))}disconnectedCallback(){h(this,Ml,"f").unsubscribeAll(),window.removeEventListener("resize",h(this,Ll,"f").resize)}}Ml=new WeakMap,Tl=new WeakMap,Dl=new WeakMap,Pl=new WeakMap,Ll=new WeakMap,Ul=new WeakSet,$l=function(e){h(this,Ul,"m",Wl).call(this,e),h(this,Ul,"m",zl).call(this)},Wl=function(e){h(this,Dl,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},zl=function(){h(this,Dl,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Fl=function(){const[e,t]=Rl(h(this,Tl,"f"),Number.parseInt(h(this,Tl,"f").style.left,10),Number.parseInt(h(this,Tl,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});h(this,Tl,"f").style.top=`${t}px`,h(this,Tl,"f").style.left=`${e}px`},customElements.define("descope-debugger",ql);var Hl,Bl,Kl,Jl,Yl=Object.freeze({__proto__:null,default:ql});function Gl(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!Gl(i,s))return!1}else if(i!==s)return!1}return!0}class Xl{constructor(e={},{updateOnlyOnChange:t=!0}={}){Hl.set(this,void 0),Bl.set(this,{}),Kl.set(this,0),Jl.set(this,!1),this.update=e=>{const t="function"==typeof e?e(h(this,Hl,"f")):e,n=Object.assign(Object.assign({},h(this,Hl,"f")),t);if(!h(this,Jl,"f")||!Gl(h(this,Hl,"f"),n)){const e=h(this,Hl,"f");p(this,Hl,n,"f"),Object.freeze(h(this,Hl,"f")),setTimeout((()=>{Object.values(h(this,Bl,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},p(this,Hl,e,"f"),p(this,Jl,t,"f")}get current(){return Object.assign({},h(this,Hl,"f"))}subscribe(e){return p(this,Kl,h(this,Kl,"f")+1,"f"),h(this,Bl,"f")[h(this,Kl,"f")]=e,h(this,Kl,"f").toString()}unsubscribe(e){const t=!!h(this,Bl,"f")[e];return t&&delete h(this,Bl,"f")[e],t}unsubscribeAll(){return p(this,Bl,{},"f"),!0}}Hl=new WeakMap,Bl=new WeakMap,Kl=new WeakMap,Jl=new WeakMap;const Zl=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Ql,ed,td,nd,od,rd,id,sd,ad,cd;const ld=document.createElement("template");ld.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class dd extends HTMLElement{constructor(){var e;super(),Ql.add(this),ed.set(this,new Xl({messages:[]})),td.set(this,void 0),nd.set(this,void 0),od.set(this,void 0),rd.set(this,{resize:h(this,Ql,"m",cd).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(ld.content.cloneNode(!0)),p(this,td,this.shadowRoot.querySelector(".debugger"),"f"),p(this,nd,h(this,td,"f").querySelector(".content"),"f"),p(this,od,h(this,td,"f").querySelector(".header"),"f")}updateData(e){h(this,ed,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=Zl(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(h(this,td,"f"),h(this,od,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",h(this,rd,"f").resize),(e=h(this,td,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},h(this,td,"f").onresize=h(this,Ql,"m",ad).bind(this),h(this,ed,"f").subscribe(h(this,Ql,"m",id).bind(this))}disconnectedCallback(){h(this,ed,"f").unsubscribeAll(),window.removeEventListener("resize",h(this,rd,"f").resize)}}ed=new WeakMap,td=new WeakMap,nd=new WeakMap,od=new WeakMap,rd=new WeakMap,Ql=new WeakSet,id=function(e){h(this,Ql,"m",sd).call(this,e),h(this,Ql,"m",ad).call(this)},sd=function(e){h(this,nd,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},ad=function(){h(this,nd,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,r=n.clientHeight>20;o||r?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},cd=function(){const[e,t]=Zl(h(this,td,"f"),Number.parseInt(h(this,td,"f").style.left,10),Number.parseInt(h(this,td,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});h(this,td,"f").style.top=`${t}px`,h(this,td,"f").style.left=`${e}px`},customElements.define("descope-debugger",dd);var ud=Object.freeze({__proto__:null,default:dd});e.AuthProvider=({projectId:e,baseUrl:n="",sessionTokenViaCookie:s=!1,children:c})=>{const[l,d]=t.useState(),[u,h]=t.useState(),[p,f]=t.useState(!1),[g,v]=t.useState(!1),m=(({projectId:e,baseUrl:n,sessionTokenViaCookie:o})=>t.useMemo((()=>{if(e)return Po({projectId:e,baseUrl:n,sessionTokenViaCookie:o,baseHeaders:a,persistToken:!0,autoRefresh:!0})}),[e,n,o]))({projectId:e,baseUrl:n,sessionTokenViaCookie:s});t.useEffect((()=>{if(m){const e=m.onSessionTokenChange(h),t=m.onUserChange(d);return()=>{e(),t()}}}),[m]);const b=t.useRef(!1),y=t.useCallback((()=>{b.current||(b.current=!0,v(!0),i(null==m?void 0:m.refresh)().then((()=>{v(!1)})))}),[m]),w=t.useCallback((()=>{f(!0),i(m.me)().then((()=>{f(!1)}))}),[m]),k=t.useMemo((()=>({fetchUser:w,user:l,isUserLoading:p,fetchSession:y,session:u,isSessionLoading:g,isSessionFetched:b.current,projectId:e,baseUrl:n,setUser:d,setSession:h,sdk:m})),[w,l,p,y,u,g,b.current,e,n,d,h,m]);return o.default.createElement(r.Provider,{value:k},c)},e.Descope=Vo,e.SignInFlow=e=>o.default.createElement(Vo,Object.assign({},e,{flowId:"sign-in"})),e.SignUpFlow=e=>o.default.createElement(Vo,Object.assign({},e,{flowId:"sign-up"})),e.SignUpOrInFlow=e=>o.default.createElement(Vo,Object.assign({},e,{flowId:"sign-up-or-in"})),e.UserManagement=Ho,e.getJwtPermissions=Wo,e.getJwtRoles=zo,e.getRefreshToken=$o,e.getSessionToken=Lo,e.refresh=(e=$o())=>null==Do?void 0:Do.refresh(e),e.useDescope=()=>{const{sdk:e}=Bo();return t.useMemo((()=>e||new Proxy(Po({projectId:"dummy"}),Jo)),[e])},e.useSession=()=>{const{session:e,isSessionLoading:n,fetchSession:o,isSessionFetched:r}=Bo(),i=t.useRef(n);t.useMemo((()=>{i.current=n}),[n]);const s=!e&&!n;return t.useMemo((()=>{s&&!r&&(i.current=!0)}),[r]),t.useEffect((()=>{s&&o()}),[o]),{isSessionLoading:i.current,sessionToken:e,isAuthenticated:!!e}},e.useUser=()=>{const{user:e,fetchUser:n,isUserLoading:o,session:r}=Bo(),[i,s]=t.useState(!1),a=t.useRef(o),c=t.useMemo((()=>!e&&!o&&r&&!i),[n,r,i]);return t.useMemo((()=>{a.current=o}),[o]),t.useMemo((()=>{c&&(a.current=!0)}),[c]),t.useEffect((()=>{c&&(s(!0),n())}),[c]),{isUserLoading:a.current,user:e}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Descope={},e.React)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(t);const r=o.default.createContext(void 0),i=e=>(...t)=>{if(!e)throw Error("You can only use this function after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component");return e(...t)},s=e=>(...t)=>{let n;try{n=e(...t)}catch(e){console.error(e)}return n},a={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.0.7"},c="undefined"!=typeof window;var l=function(){return l=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},l.apply(this,arguments)};function d(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function u(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function h(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function p(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function f(e){this.message=e}"function"==typeof SuppressedError&&SuppressedError,f.prototype=new Error,f.prototype.name="InvalidCharacterError";var g="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new f("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,r=0,i=0,s="";o=t.charAt(i++);~o&&(n=r%4?64*n+o:o,r++%4)?s+=String.fromCharCode(255&n>>(-2*r&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function v(e){this.message=e}function m(e,t){if("string"!=typeof e)throw new v("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(g(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return g(t)}}(e.split(".")[n]))}catch(e){throw new v("Invalid token specified: "+e.message)}}v.prototype=new Error,v.prototype.name="InvalidTokenError";var y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var w="__lodash_hash_undefined__",k="[object Function]",E="[object GeneratorFunction]",I=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,O=/^\w*$/,x=/^\./,j=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,C=/\\(\\)?/g,S=/^\[object .+?Constructor\]$/,_="object"==typeof y&&y&&y.Object===Object&&y,A="object"==typeof self&&self&&self.Object===Object&&self,R=_||A||Function("return this")();var N,U=Array.prototype,M=Function.prototype,T=Object.prototype,P=R["__core-js_shared__"],D=(N=/[^.]+$/.exec(P&&P.keys&&P.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"",L=M.toString,$=T.hasOwnProperty,W=T.toString,F=RegExp("^"+L.call($).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),q=R.Symbol,V=U.splice,z=te(R,"Map"),H=te(Object,"create"),B=q?q.prototype:void 0,K=B?B.toString:void 0;function J(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function Y(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function G(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function X(e,t){for(var n,o,r=e.length;r--;)if((n=e[r][0])===(o=t)||n!=n&&o!=o)return r;return-1}function Z(e,t){var n;t=function(e,t){if(ie(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||ae(e))return!0;return O.test(e)||!I.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:ie(n=t)?n:ne(n);for(var o=0,r=t.length;null!=e&&o<r;)e=e[oe(t[o++])];return o&&o==r?e:void 0}function Q(e){if(!se(e)||(t=e,D&&D in t))return!1;var t,n=function(e){var t=se(e)?W.call(e):"";return t==k||t==E}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?F:S;return n.test(function(e){if(null!=e){try{return L.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function ee(e,t){var n,o,r=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof t?"string":"hash"]:r.map}function te(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Q(n)?n:void 0}J.prototype.clear=function(){this.__data__=H?H(null):{}},J.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},J.prototype.get=function(e){var t=this.__data__;if(H){var n=t[e];return n===w?void 0:n}return $.call(t,e)?t[e]:void 0},J.prototype.has=function(e){var t=this.__data__;return H?void 0!==t[e]:$.call(t,e)},J.prototype.set=function(e,t){return this.__data__[e]=H&&void 0===t?w:t,this},Y.prototype.clear=function(){this.__data__=[]},Y.prototype.delete=function(e){var t=this.__data__,n=X(t,e);return!(n<0)&&(n==t.length-1?t.pop():V.call(t,n,1),!0)},Y.prototype.get=function(e){var t=this.__data__,n=X(t,e);return n<0?void 0:t[n][1]},Y.prototype.has=function(e){return X(this.__data__,e)>-1},Y.prototype.set=function(e,t){var n=this.__data__,o=X(n,e);return o<0?n.push([e,t]):n[o][1]=t,this},G.prototype.clear=function(){this.__data__={hash:new J,map:new(z||Y),string:new J}},G.prototype.delete=function(e){return ee(this,e).delete(e)},G.prototype.get=function(e){return ee(this,e).get(e)},G.prototype.has=function(e){return ee(this,e).has(e)},G.prototype.set=function(e,t){return ee(this,e).set(e,t),this};var ne=re((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ae(e))return K?K.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return x.test(e)&&n.push(""),e.replace(j,(function(e,t,o,r){n.push(o?r.replace(C,"$1"):t||e)})),n}));function oe(e){if("string"==typeof e||ae(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function re(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var o=arguments,r=t?t.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var s=e.apply(this,o);return n.cache=i.set(r,s),s};return n.cache=new(re.Cache||G),n}re.Cache=G;var ie=Array.isArray;function se(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ae(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==W.call(e)}var ce=b((function(e,t,n){var o=null==e?void 0:Z(e,t);return void 0===o?n:o})),le="/v1/auth/accesskey/exchange",de="/v1/auth/otp/verify",ue="/v1/auth/otp/signin",he="/v1/auth/otp/signup",pe={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},fe="/v1/auth/otp/signup-in",ge="/v1/auth/magiclink/verify",ve="/v1/auth/magiclink/signin",me="/v1/auth/magiclink/signup",ye={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},be="/v1/auth/magiclink/signup-in",we="/v1/auth/enchantedlink/verify",ke="/v1/auth/enchantedlink/signin",Ee="/v1/auth/enchantedlink/signup",Ie="/v1/auth/enchantedlink/pending-session",Oe={email:"/v1/auth/enchantedlink/update/email"},xe="/v1/auth/enchantedlink/signup-in",je="/v1/auth/oauth/authorize",Ce="/v1/auth/oauth/exchange",Se="v1/auth/oauth/native/start",_e="v1/auth/oauth/native/finish",Ae="/v1/auth/saml/authorize",Re="/v1/auth/saml/exchange",Ne="/v1/auth/totp/verify",Ue="/v1/auth/totp/signup",Me="/v1/auth/totp/update",Te={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Pe={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},De={start:"/v1/auth/webauthn/signup-in/start"},Le={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},$e="/v1/auth/password/signup",We="/v1/auth/password/signin",Fe="/v1/auth/password/reset",qe="/v1/auth/password/update",Ve="/v1/auth/password/replace",ze="/v1/auth/password/policy",He="/v1/auth/refresh",Be="/v1/auth/tenant/select",Ke="/v1/auth/logout",Je="/v1/auth/logoutall",Ye="/v1/auth/me",Ge="/v1/auth/me/history",Xe="/v1/flow/start",Ze="/v1/flow/next";const Qe="<region>",et=`https://api.${Qe}descope.com`,tt=6e5,nt=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};var ot;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(ot||(ot={}));const rt=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),it=e=>void 0===e?void 0:JSON.stringify(e),st=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},at=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:r,cookiePolicy:i,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>nt().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return nt().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,s),c=async o=>{const s=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:c,body:l,headers:d,queryParams:u,method:h,token:p}=s,f={headers:rt(st(t,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.11.0"},(null==n?void 0:n.baseHeaders)||{},d),method:h,body:it(l)};null!==i&&(f.credentials=i||"include");const g=await a((({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const r=o.slice(1,-27);t=t.replace(Qe,r?r+".":"");const i=new URL(e,t);return n&&(i.search=new URLSearchParams(n).toString()),i})({path:c,baseUrl:e,queryParams:u,projectId:t}),f);return(null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==g?void 0:g.clone()),g};return{get:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:ot.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:ot.post,token:r}),put:(e,t,{headers:n,queryParams:o,token:r}={})=>c({path:e,headers:n,queryParams:o,body:t,method:ot.put,token:r}),delete:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:ot.delete,token:o}),hooks:r}};var ct=429;function lt(e,t,n){var o;let r=dt(e);t&&(r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[t]);const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function dt(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return m(e)}function ut(e){const{exp:t}=dt(e);return(new Date).getTime()/1e3>t}function ht(e){let t=dt(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function pt(e,t){return lt(e,t,"permissions")}function ft(e,t){return lt(e,t,"roles")}const gt=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function vt(e,t){var n;const o=await e,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=t?t(i):i:(r.error=i,o.status===ct&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}const mt=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),yt=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),bt=e=>t=>e.test(t),wt=bt(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),kt=bt(/^\+[1-9]{1}[0-9]{3,14}$/),Et=mt(wt,'"{val}" is not a valid email'),It=mt(kt,'"{val}" is not a valid phone number'),Ot=mt((1,e=>e.length>=1),"Minimum length is 1");const xt=mt((e=>"string"==typeof e),"Input is not a string"),jt=mt((e=>void 0===e),"Input is defined"),Ct=(St=[xt(),jt()],"Input is not a string or undefined",(e="Input is not a string or undefined")=>t=>{const n=St.filter((e=>e(t)));return!(n.length<St.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var St;const _t=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>yt(...e).validate(n[t]))),t(...n)),At=e=>[xt(`"${e}" must be a string`),Ot(`"${e}" must not be empty`)],Rt=e=>[xt(`"${e}" must be a string`),Et()],Nt=e=>[xt(`"${e}" must be a string`),It()],Ut=_t(At("accessKey")),Mt=e=>({exchange:Ut(((t,n)=>vt(e.post(le,{loginOptions:n},{token:t}))))});var Tt,Pt;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(Tt||(Tt={})),function(e){e.email="email"}(Pt||(Pt={}));const Dt=Object.assign(Object.assign({},Tt),Pt);var Lt;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Lt||(Lt={}));const $t=At("loginId"),Wt=_t(At("token")),Ft=_t($t),qt=_t(At("pendingRef")),Vt=_t($t,Rt("email")),zt=e=>({verify:Wt((t=>vt(e.post(we,{token:t})))),signIn:Ft(((t,n,o,r)=>vt(e.post(gt(ke,Dt.email),{loginId:t,URI:n,loginOptions:o},{token:r})))),signUpOrIn:Ft(((t,n,o)=>vt(e.post(gt(xe,Dt.email),{loginId:t,URI:n,loginOptions:o})))),signUp:Ft(((t,n,o,r)=>vt(e.post(gt(Ee,Dt.email),{loginId:t,URI:n,user:o,loginOptions:r})))),waitForSession:qt(((t,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||tt,tt)}))(n);let s;const a=setInterval((async()=>{const n=await e.post(Ie,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(vt(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:Vt(((t,n,o,r,i)=>vt(e.post(Oe.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r}))))}}),Ht=_t(At("flowId")),Bt=_t(At("executionId"),At("stepId"),At("interactionId")),Kt=e=>({start:Ht(((t,n,o,r,i,s,a)=>vt(e.post(Xe,{flowId:t,options:n,conditionInteractionId:o,interactionId:r,version:i,componentsVersion:s,input:a})))),next:Bt(((t,n,o,r,i,s)=>vt(e.post(Ze,{executionId:t,stepId:n,interactionId:o,version:r,componentsVersion:i,input:s}))))}),Jt=At("loginId"),Yt=_t(At("token")),Gt=_t(Jt),Xt=_t(Jt,Nt("phone")),Zt=_t(Jt,Rt("email")),Qt=e=>({verify:Yt((t=>vt(e.post(ge,{token:t})))),signIn:Object.keys(Dt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o,r,i)=>vt(e.post(gt(ve,n),{loginId:t,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:Object.keys(Dt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o,r,i)=>vt(e.post(gt(me,n),{loginId:t,URI:o,user:r,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Dt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Gt(((t,o,r)=>vt(e.post(gt(be,n),{loginId:t,URI:o,loginOptions:r}))))})),{}),update:{email:Zt(((t,n,o,r,i)=>vt(e.post(ye.email,Object.assign({loginId:t,email:n,URI:o},i),{token:r})))),phone:Object.keys(Tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Xt(((t,o,r,i,s)=>vt(e.post(gt(ye.phone,n),Object.assign({loginId:t,phone:o,URI:r},s),{token:i}))))})),{})}});var en;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(en||(en={}));const tn=_t(At("code")),nn=e=>({start:Object.assign(((t,n,o,r)=>vt(e.post(je,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:r}))),Object.keys(en).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,r)=>vt(e.post(je,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:r}))})),{})),exchange:tn((t=>vt(e.post(Ce,{code:t})))),startNative:(t,n)=>vt(e.post(Se,{provider:t,loginOptions:n})),finishNative:(t,n,o,r,i)=>vt(e.post(_e,{provider:t,stateId:n,user:o,code:r,idToken:i}))}),on=At("loginId"),rn=_t(on,At("code")),sn=_t(on),an=_t(on,Nt("phone")),cn=_t(on,Rt("email")),ln=e=>({verify:Object.keys(Dt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:rn(((t,o)=>vt(e.post(gt(de,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(Dt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:sn(((t,o,r)=>vt(e.post(gt(ue,n),{loginId:t,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(Dt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:sn(((t,o,r)=>vt(e.post(gt(he,n),{loginId:t,user:o,loginOptions:r}))))})),{}),signUpOrIn:Object.keys(Dt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:sn(((t,o)=>vt(e.post(gt(fe,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:cn(((t,n,o,r)=>vt(e.post(pe.email,Object.assign({loginId:t,email:n},r),{token:o})))),phone:Object.keys(Tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:an(((t,o,r,i)=>vt(e.post(gt(pe.phone,n),Object.assign({loginId:t,phone:o},i),{token:r}))))})),{})}}),dn=_t(At("tenant")),un=_t(At("code")),hn=e=>({start:dn(((t,n,o,r)=>vt(e.post(Ae,o||{},{queryParams:{tenant:t,redirectURL:n},token:r})))),exchange:un((t=>vt(e.post(Re,{code:t}))))}),pn=At("loginId"),fn=_t(pn,At("code")),gn=_t(pn),vn=_t(pn),mn=e=>({signUp:gn(((t,n)=>vt(e.post(Ue,{loginId:t,user:n})))),verify:fn(((t,n,o,r)=>vt(e.post(Ne,{loginId:t,code:n,loginOptions:o},{token:r})))),update:vn(((t,n)=>vt(e.post(Me,{loginId:t},{token:n}))))}),yn=At("loginId"),bn=At("newPassword"),wn=_t(yn,At("password")),kn=_t(yn),En=_t(yn,bn),In=_t(yn,At("oldPassword"),bn),On=e=>({signUp:wn(((t,n,o)=>vt(e.post($e,{loginId:t,password:n,user:o})))),signIn:wn(((t,n)=>vt(e.post(We,{loginId:t,password:n})))),sendReset:kn(((t,n,o)=>vt(e.post(Fe,{loginId:t,redirectUrl:n,templateOptions:o})))),update:En(((t,n,o)=>vt(e.post(qe,{loginId:t,newPassword:n},{token:o})))),replace:In(((t,n,o)=>vt(e.post(Ve,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>vt(e.get(ze))}),xn=[xt('"loginId" must be a string')],jn=At("loginId"),Cn=At("origin"),Sn=_t(jn,Cn,At("name")),_n=_t(jn,Cn),An=_t(xn,Cn),Rn=_t(jn,Cn,At("token")),Nn=_t(At("transactionId"),At("response")),Un=e=>({signUp:{start:Sn(((t,n,o)=>vt(e.post(Te.start,{user:{loginId:t,name:o},origin:n})))),finish:Nn(((t,n)=>vt(e.post(Te.finish,{transactionId:t,response:n}))))},signIn:{start:An(((t,n,o,r)=>vt(e.post(Pe.start,{loginId:t,origin:n,loginOptions:o},{token:r})))),finish:Nn(((t,n)=>vt(e.post(Pe.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:_n(((t,n)=>vt(e.post(De.start,{loginId:t,origin:n}))))},update:{start:Rn(((t,n,o)=>vt(e.post(Le.start,{loginId:t,origin:n},{token:o})))),finish:Nn(((t,n)=>vt(e.post(Le.finish,{transactionId:t,response:n}))))}}),Mn=_t(At("token")),Tn=_t([Ct('"token" must be string or undefined')]);var Pn,Dn=_t([("projectId",Pn=At("projectId"),mt(((e,t)=>n=>yt(...t).validate(ce(n,e)))("projectId",Pn))())])((e=>(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},fetch:s})=>{return a=at({baseUrl:n||et,projectId:e,logger:t,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},fetch:s}),{accessKey:Mt(a),otp:ln(a),magicLink:Qt(a),enchantedLink:zt(a),oauth:nn(a),saml:hn(a),totp:mn(a),webauthn:Un(a),password:On(a),flow:Kt(a),refresh:Tn((e=>vt(a.post(He,{},{token:e})))),selectTenant:_t([xt("tenantId")],[Ct('"token" must be string or undefined')])(((e,t)=>vt(a.post(Be,{tenant:e},{token:t})))),logout:Tn((e=>vt(a.post(Ke,{},{token:e})))),logoutAll:Tn((e=>vt(a.post(Je,{},{token:e})))),me:Tn((e=>vt(a.get(Ye,{token:e})))),history:Tn((e=>vt(a.get(Ge,{token:e})))),isJwtExpired:Mn(ut),getTenants:Mn(ht),getJwtPermissions:Mn(pt),getJwtRoles:Mn(ft),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const r=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);(await Promise.allSettled(null==r?void 0:r.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))}}}))));const Ln=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let r=o.shift(),i=e;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${t}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${t}" is not a function`);const s=i[r];i[r]=n(s)})),e);var $n=Object.assign(Dn,{DeliveryMethods:Dt});var Wn="Blocked by CSP",Fn="9319";function qn(e,t){var n=[];return function(e,t){var n,o,r=(o=function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0),{current:function(){return o[0]},postpone:function(){var e=o.shift();void 0!==e&&o.push(e)},exclude:function(){o.shift()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=r.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(e,n){return t(e).catch((function(e){if(n+1>=5)throw e;!function(e){if(!(e instanceof Error))return!1;var t=e.message;return t===Wn||t===Fn}(e)?r.postpone():r.exclude();var t,o=r.current();if(void 0===o)throw e;return(t=i(),new Promise((function(e){return setTimeout(e,t)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(e,(function(e){var o=new Date,r=function(t){return n.push({url:e,startedAt:o,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return r()}),r),i})).then((function(e){return[e,{attempts:n}]}))}var Vn="Failed to load the JS script of the agent";function zn(e){var t;e.scriptUrlPattern;var n=e.token,o=e.apiKey,r=void 0===o?n:o,i=d(e,["scriptUrlPattern","token","apiKey"]),s=null!==(t=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(e,"scriptUrlPattern"))&&void 0!==t?t:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";return Promise.resolve().then((function(){if(!r||"string"!=typeof r)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.8.5"):e}))}(String(e),t)}))}(s,r);return qn(e,Hn).catch(Kn)})).then((function(e){var t=e[0],n=e[1];return t.load(l(l({},i),{ldi:n}))}))}function Hn(e){return function(e,t,n,o){var r,i=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(r=t,c())};i.addEventListener(s,a);var c=function(){return i.removeEventListener(s,a)};return Promise.resolve().then(t).then((function(e){return c(),e}),(function(e){return new Promise((function(e){return setTimeout(e)})).then((function(){if(c(),r)return function(){throw new Error(Wn)}();throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){var o=document.createElement("script"),r=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),t()},o.onerror=function(){r(),n(new Error(Vn))},o.async=!0,o.src=e,i.appendChild(o)}))}(e)})).then(Bn)}function Bn(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Fn);return n}function Kn(e){throw e instanceof Error&&e.message===Fn?new Error(Vn):e}var Jn={exports:{}};
|
|
2
|
+
/*! js-cookie v3.0.5 | MIT */!function(e,t){e.exports=function(){function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in i)i[a]&&(s+="; "+a,!0!==i[a]&&(s+="="+i[a].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+s}}function i(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=n.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}}return Object.create({set:r,get:i,remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}return t({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}()}(Jn);var Yn=b(Jn.exports);const Gn=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=e.hooks)||void 0===r?void 0:r[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Xn=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},Zn=async e=>{const t=await Xn(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Qn="undefined"!=typeof localStorage,eo=(e,t)=>Qn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),to=e=>Qn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),no=e=>Qn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),oo=(...e)=>{console.debug(...e)},ro="undefined"!=typeof window,io=Math.pow(2,31)-1,so=ro&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",ao="fp",co=(e=!1)=>{const t=localStorage.getItem(ao);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},lo=async e=>{try{if(co())return;const t=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=zn({apiKey:e,endpoint:so}),o=await n,{requestId:r}=await o.get({linkedId:t}),i=((e,t)=>({vsid:e,vrid:t}))(t,r);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(ao,JSON.stringify(t))})(i)}catch(e){global.FB_DEBUG&&console.error(e)}},uo=e=>{const t=co(!0);return t&&e.body&&(e.body.fpData=t),e},ho="dls_last_user_login_id",po="dls_last_user_display_name",fo=()=>to(ho),go=()=>to(po),vo=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,r=fo(),i=go();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await e(...t)},mo=e=>async(...t)=>{const n=await e(...t);return no(ho),no(po),n};function yo(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const bo="DS",wo="DSR";function ko(e=""){return to(`${e}${wo}`)||""}function Eo(e=""){no(`${e}${wo}`),no(`${e}${bo}`),Yn.remove(bo)}async function Io(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=_o(n.publicKey.challenge),n.publicKey.user.id=_o(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=_o(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Ao(n.rawId),type:n.type,response:{attestationObject:Ao(n.response.attestationObject),clientDataJSON:Ao(n.response.clientDataJSON)}});var n}async function Oo(e){const t=Co(e);return So(await navigator.credentials.get(t))}async function xo(e,t){const n=Co(e);return n.signal=t.signal,n.mediation="conditional",So(await navigator.credentials.get(n))}async function jo(e=!1){if(!ro)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Co(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=_o(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=_o(e.id)})),n}function So(e){return JSON.stringify({id:e.id,rawId:Ao(e.rawId),type:e.type,response:{authenticatorData:Ao(e.response.authenticatorData),clientDataJSON:Ao(e.response.clientDataJSON),signature:Ao(e.response.signature),userHandle:e.response.userHandle?Ao(e.response.userHandle):void 0}})}function _o(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ao(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ro,No=(Ro=e=>({async signUp(t,n){const o=await e.webauthn.signUp.start(t,window.location.origin,n);if(!o.ok)return o;const r=await Io(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const o=await Oo(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await Io(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Oo(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n){const o=await e.webauthn.update.start(t,window.location.origin,n);if(!o.ok)return o;const r=await Io(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Io,get:Oo,isSupported:jo,conditional:xo}}),(...e)=>{const t=Ro(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const Uo=e=>({async oneTap(t,n,o,r){const i=null!=t?t:"google",s=await e.oauth.startNative(i,o);if(!s.ok)return s;const{clientId:a,stateId:c,nonce:l}=s.data,d=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((t=>{var o,s;d.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(s=null==n?void 0:n.use_fedcm_for_prompt)||void 0===s||s,client_id:a,callback:n=>{t(e.oauth.finishNative(i,c,"","",n.credential))},nonce:l})),d.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==r||r())}))}))}});var Mo=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await jo(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const To=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var{fpKey:n,fpLoad:o}=t,r=d(t,["fpKey","fpLoad"]);return ro?(n&&o&&lo(n).catch((()=>null)),e(Gn(r,{beforeRequest:uo}))):(console.warn("Fingerprint is a client side only capability and will not work when running in the server"),e(r))}),(e=>t=>{var{autoRefresh:n}=t,o=d(t,["autoRefresh"]);if(!n)return e(o);const{clearAllTimers:r,setTimer:i}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let s,a;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>s&&(oo("Expiration time passed, refreshing session"),c.refresh(a))}));const c=e(Gn(o,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:o}=await Xn(t);if(401===(null==t?void 0:t.status))oo("Received 401, canceling all timers"),r();else if(o){s=(e=>{const t=e.split(".");try{if(3===t.length){const e=JSON.parse(window.atob(t[1]));if(e.exp)return new Date(1e3*e.exp)}}catch(e){}return null})(o),a=n;let e=((l=s)?l.getTime()-(new Date).getTime():0)-2e4;e>io&&(oo(`Timeout is too large (${e}ms), setting it to ${io}ms`),e=io),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});oo(`Setting refresh timer for ${t}. (${e}ms)`),i((()=>{oo("Refreshing session due to timer"),c.refresh(n)}),e)}var l}}));return Ln(c,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return oo("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.10.1"},t.baseHeaders)}))),(e=>t=>{const n=yo(),o=yo(),r=e(Gn(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),o.pub(null);else{const e=await Zn(t);e&&o.pub(e);const{sessionJwt:r}=await Xn(t);r&&n.pub(r)}}})),i=Ln(r,["logout","logoutAll"],(e=>async(...t)=>{const r=await e(...t);return n.pub(null),o.pub(null),r}));return Object.assign(i,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(e=>t=>{const n=e(Gn(t,{afterRequest:async(e,t)=>{var n;const o=await Zn(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((e=>{eo(ho,e)})(r),(e=>{eo(po,e)})(i))}}));let o=Ln(n,["flow.start"],vo);return o=Ln(o,["logout","logoutAll"],mo),Object.assign(o,{getLastUserLoginId:fo,getLastUserDisplayName:go})}),(e=>t=>{var{persistTokens:n,sessionTokenViaCookie:o,storagePrefix:r}=t,i=d(t,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!n||!ro)return n&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),e(i);const s=e(Gn(i,{beforeRequest:(a=r,e=>Object.assign(e,{token:e.token||ko(a)})),afterRequest:async(e,t)=>{401===(null==t?void 0:t.status)?Eo(r):((e={},t,n)=>{var{refreshJwt:o,sessionJwt:r}=e,i=d(e,["refreshJwt","sessionJwt"]);void 0===t&&(t=!1),void 0===n&&(n=""),o&&eo(`${n}${wo}`,o),r&&(t?function(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:r}){if(t){const i=new Date(1e3*r),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);Yn.set(e,t,{path:n,domain:s?o:void 0,expires:i,sameSite:"Strict",secure:!0})}}(bo,r,i):eo(`${n}${bo}`,r))})(await Xn(t),o,r)}}));var a;const c=Ln(s,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return Eo(e),o})(r));return Object.assign(c,{getRefreshToken:()=>ko(r),getSessionToken:()=>function(e=""){return Yn.get(bo)||to(`${e}${bo}`)||""}(r)})}))(((...e)=>{const t=$n(...e);return Object.assign(Object.assign({},t),{flow:Mo(t),webauthn:No(t),fedcm:Uo(t)})}));let Po;const Do=e=>{const t=To(Object.assign(Object.assign({},e),{persistTokens:c,autoRefresh:c}));return Po=t,t};Po=Do({projectId:"temp pid"});const Lo=()=>c?null==Po?void 0:Po.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),$o=()=>c?null==Po?void 0:Po.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),Wo=s(((e=Lo(),t)=>null==Po?void 0:Po.getJwtPermissions(e,t))),Fo=s(((e=Lo(),t)=>null==Po?void 0:Po.getJwtRoles(e,t)));const qo=t.lazy((async()=>((await Promise.resolve().then((function(){return qi}))).default.sdkConfigOverrides={baseHeaders:a,persistTokens:!1,hooks:{get beforeRequest(){return Po.httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:({projectId:e,flowId:t,baseUrl:n,innerRef:r,tenant:i,theme:s,locale:a,debug:c,redirectUrl:l,client:d,form:u,autoFocus:h})=>o.default.createElement("descope-wc",{"project-id":e,"flow-id":t,"base-url":n,ref:r,tenant:i,theme:s,locale:a,debug:c,client:d,form:u,"redirect-url":l,"auto-focus":h})}))),Vo=o.default.forwardRef((({flowId:e,onSuccess:n,onError:i,onReady:s,logger:a,tenant:c,theme:l,locale:d,debug:u,client:h,form:p,telemetryKey:f,redirectUrl:g,autoFocus:v,errorTransformer:m},y)=>{const[b,w]=t.useState(null);t.useImperativeHandle(y,(()=>b));const{projectId:k,baseUrl:E,sdk:I}=o.default.useContext(r),O=t.useCallback((async e=>{await I.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),n&&n(e)}),[n]);t.useEffect((()=>{const e=b;return null==e||e.addEventListener("success",O),i&&(null==e||e.addEventListener("error",i)),s&&(null==e||e.addEventListener("ready",s)),()=>{i&&(null==e||e.removeEventListener("error",i)),s&&(null==e||e.removeEventListener("ready",s)),null==e||e.removeEventListener("success",O)}}),[b,i,O]),t.useEffect((()=>{const e=b;return null==e||e.addEventListener("success",O),()=>{null==e||e.removeEventListener("success",O)}}),[b,O]),t.useEffect((()=>{const e=b;return i&&(null==e||e.addEventListener("error",i)),()=>{i&&(null==e||e.removeEventListener("error",i))}}),[b,i]),t.useEffect((()=>{const e=b;return s&&(null==e||e.addEventListener("ready",s)),()=>{s&&(null==e||e.removeEventListener("error",s))}}),[b,s]),t.useEffect((()=>{b&&(b.errorTransformer=m)}),[b,m]),t.useEffect((()=>{b&&a&&(b.logger=a)}),[b,a]);const{form:x,client:j}=t.useMemo((()=>({form:JSON.stringify(p||{}),client:JSON.stringify(h||{})})),[p,h]);return o.default.createElement("form",null,o.default.createElement(t.Suspense,{fallback:null},o.default.createElement(qo,{projectId:k,flowId:e,baseUrl:E,innerRef:w,tenant:c,theme:l,locale:d,debug:u,form:x,client:j,telemetryKey:f,redirectUrl:g,autoFocus:v})))})),zo=t.lazy((async()=>(await Promise.resolve().then((function(){return ql})),{default:({projectId:e,baseUrl:t,innerRef:n,tenant:r,widgetId:i,theme:s,debug:a})=>o.default.createElement("descope-user-management-widget",{"project-id":e,"widget-id":i,"base-url":t,theme:s,tenant:r,debug:a,ref:n})}))),Ho=o.default.forwardRef((({logger:e,tenant:n,theme:i,debug:s,widgetId:a},c)=>{const[l,d]=t.useState(null);t.useImperativeHandle(c,(()=>l));const{projectId:u,baseUrl:h}=o.default.useContext(r);return t.useEffect((()=>{l&&e&&(l.logger=e)}),[l,e]),o.default.createElement(t.Suspense,{fallback:null},o.default.createElement(zo,{projectId:u,widgetId:a,baseUrl:h,innerRef:d,tenant:n,theme:i,debug:s}))}));var Bo=()=>{const e=t.useContext(r);if(!e)throw Error("You can only use this hook in the context of <AuthProvider />");return e};const Ko=e=>`You can only use this ${e} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`,Jo={get(e,t){if("object"==typeof e[t]&&null!==e[t])return new Proxy(e[t],Jo);if("function"==typeof e[t])return()=>{throw Error(Ko("function"))};throw Error(Ko("attribute"))}},Yo="undefined"!=typeof localStorage,Go=Yo&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",Xo="config.json",Zo="base.ui.components.url",Qo=Yo&&localStorage.getItem(Zo)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",er=Yo&&localStorage.getItem(Zo)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",tr="descope-login-flow",nr="code",or="ra-challenge",rr="ra-callback",ir="ra-backup-callback",sr="ra-initiator",ar="data-exclude-field",cr="dls_last_auth",lr="state_id",dr="saml_idp_state_id",ur="saml_idp_username",hr="sso_app_id",pr="oidc_login_hint",fr="data-type",gr="poll",vr="webauthnCreate",mr="submit",yr="polling";var br;function wr(e){return new URLSearchParams(window.location.search).get(e)}function kr(e){if(window.history.replaceState&&wr(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function Er(e,t){return u(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}function Ir(e,t,n="v2-beta"){const o=new URL(Go);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}function Or(e,t){if(!Number.isNaN(e)&&!Number.isNaN(t))return e>t?br.forward:e<t?br.backward:void 0}!function(e){e.backward="backward",e.forward="forward"}(br||(br={}));const xr=()=>{const[e="",t=""]=(wr(tr)||"").split("_");return{executionId:e,stepId:t}};function jr(){kr(tr)}const Cr=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Sr=e=>{let t,n;return(...o)=>{return t&&(i=o,(r=t).length===i.length&&r.every(((e,t)=>e===i[t])))||(t=o,n=e(...o)),n;var r,i}},_r=(e,t,n,o,r,i)=>e&&!t&&e&&!n&&!o&&e&&!r&&e&&!i,Ar=e=>null==e?void 0:e.submit(),Rr=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Nr=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};var Ur,Mr,Tr,Pr;function Dr(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!Dr(i,s))return!1}else if(i!==s)return!1}return!0}class Lr{constructor(e={},{updateOnlyOnChange:t=!0}={}){Ur.set(this,void 0),Mr.set(this,{}),Tr.set(this,0),Pr.set(this,!1),this.update=e=>{const t="function"==typeof e?e(h(this,Ur,"f")):e,n=Object.assign(Object.assign({},h(this,Ur,"f")),t);if(!h(this,Pr,"f")||!Dr(h(this,Ur,"f"),n)){const e=h(this,Ur,"f");p(this,Ur,n,"f"),Object.freeze(h(this,Ur,"f")),setTimeout((()=>{Object.values(h(this,Mr,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},p(this,Ur,e,"f"),p(this,Pr,t,"f")}get current(){return Object.assign({},h(this,Ur,"f"))}subscribe(e){return p(this,Tr,h(this,Tr,"f")+1,"f"),h(this,Mr,"f")[h(this,Tr,"f")]=e,h(this,Tr,"f").toString()}unsubscribe(e){const t=!!h(this,Mr,"f")[e];return t&&delete h(this,Mr,"f")[e],t}unsubscribeAll(){return p(this,Mr,{},"f"),!0}}Ur=new WeakMap,Mr=new WeakMap,Tr=new WeakMap,Pr=new WeakMap;const $r=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ar}])`)).forEach((e=>{e.value=n}))}))},Wr=(e,t)=>e.replace(/{{(.+?)}}/g,((e,n)=>{return o=t,n.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),o);var o})),Fr=Sr((()=>u(void 0,void 0,void 0,(function*(){var e,t,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield(100,n=r,o=i,new Promise(((e,t)=>{let r=!1;const i=setTimeout((()=>{r=!0,void 0!==o?e(o):t(new Error("Promise timed out after 100 ms"))}),100);n.then((t=>{r||(clearTimeout(i),e(t))})).catch((e=>{r||(clearTimeout(i),t(e))}))})))}catch(e){return console.error("Conditional login check failed",e),!1}})))),qr={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t}};function Vr(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(cr)))}catch(e){}return t}const zr="dls_ab_testing_id",Hr=document.createElement("template");var Br,Kr,Jr,Yr,Gr,Xr,Zr,Qr,ei,ti,ni,oi,ri,ii,si,ai,ci,li,di,ui,hi,pi,fi,gi,vi,mi,yi,bi,wi,ki,Ei,Ii,Oi,xi,ji,Ci,Si,_i,Ai,Ri,Ni,Ui,Mi,Ti,Pi,Di,Li,$i;Hr.innerHTML='\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<div id="wc-root"></div>\n\t';class Wi extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","locale","debug","storage-prefix","preview","redirect-url","auto-focus"]}constructor(e){super(),Br.add(this),this.logger=console,Kr.set(this,!1),this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),h(this,Br,"m",yi).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)}},Jr.set(this,new Lr({deferredRedirect:!1})),Yr.set(this,new Lr),Gr.set(this,{}),this.getComponentsContext=()=>h(this,Gr,"f"),this.nextRequestStatus=new Lr({isLoading:!1}),Xr.set(this,void 0),Zr.set(this,{popstate:h(this,Br,"m",ri).bind(this),visibilitychange:h(this,Br,"m",ii).bind(this),componentsContext:h(this,Br,"m",fi).bind(this)}),Qr.set(this,void 0),di.set(this,Sr((()=>u(this,void 0,void 0,(function*(){const e=Ir(this.projectId,Xo);try{const{body:t,headers:n}=yield Er(e,"json");return{projectConfig:t,executionContext:{geo:n["x-geo"]}}}catch(e){return{isMissingConfig:!0}}}))))),p(this,Qr,e,"f"),h(this,Br,"m",ei).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get form(){try{const e=JSON.parse(this.getAttribute("form"))||{};return Object.entries(e).reduce(((e,[t,n])=>Object.assign(Object.assign({},e),{[`form.${t}`]:n})),e)}catch(e){return{}}}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get baseUrl(){return this.getAttribute("base-url")||void 0}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get theme(){var e,t;const n=this.getAttribute("theme");return"os"===n?window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light":n||"light"}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}getExecutionContext(){return u(this,void 0,void 0,(function*(){const{executionContext:e}=yield h(this,di,"f").call(this);return e}))}getProjectConfig(){return u(this,void 0,void 0,(function*(){const{projectConfig:e}=yield h(this,di,"f").call(this);return e}))}getFlowConfig(){var e,t;return u(this,void 0,void 0,(function*(){const n=yield this.getProjectConfig(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}getTargetLocales(){return u(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}connectedCallback(){return u(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(h(this,Yr,"f").subscribe(h(this,Br,"m",mi).bind(this)),h(this,Yr,"f").update({isDebug:this.debug}),h(this,Br,"m",ti).call(this))return void h(this,Br,"m",ni).call(this);if(h(this,Br,"m",oi).call(this),yield h(this,Br,"m",ci).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield h(this,di,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");yield h(this,Br,"m",ki).call(this),yield h(this,Br,"m",hi).call(this),h(this,Br,"m",ui).call(this),h(this,Br,"m",bi).call(this);const{executionId:e,stepId:t,token:n,code:o,exchangeError:r,redirectAuthCallbackUrl:i,redirectAuthBackupCallbackUri:s,redirectAuthCodeChallenge:a,redirectAuthInitiator:c,oidcIdpStateId:l,samlIdpStateId:d,samlIdpUsername:u,ssoAppId:f,oidcLoginHint:g}=(()=>{const{executionId:e,stepId:t}=xr();(e||t)&&jr();const n=wr("t")||void 0;n&&kr("t");const o=wr(nr)||void 0;o&&kr(nr);const r=wr("err")||void 0;r&&kr("err");const{redirectAuthCodeChallenge:i,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:c}={redirectAuthCodeChallenge:wr(or),redirectAuthCallbackUrl:wr(rr),redirectAuthBackupCallbackUri:wr(ir),redirectAuthInitiator:wr(sr)};(i||s||a||c)&&(kr(or),kr(rr),kr(ir),kr(sr));const l=wr(lr);l&&kr(lr);const d=wr(dr);d&&kr(dr);const u=wr(ur);d&&kr(ur);const h=wr(hr);h&&kr(hr);const p=wr(pr);return p&&kr(pr),{executionId:e,stepId:t,token:n,code:o,exchangeError:r,redirectAuthCodeChallenge:i,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:c,oidcIdpStateId:l,samlIdpStateId:d,samlIdpUsername:u,ssoAppId:h,oidcLoginHint:p}})();window.addEventListener("popstate",h(this,Zr,"f").popstate),window.addEventListener("components-context",h(this,Zr,"f").componentsContext),window.addEventListener("visibilitychange",h(this,Zr,"f").visibilitychange),h(this,Jr,"f").subscribe(h(this,Br,"m",ai).bind(this)),h(this,Jr,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:t,executionId:e,token:n,code:o,exchangeError:r,redirectAuthCallbackUrl:i,redirectAuthBackupCallbackUri:s,redirectAuthCodeChallenge:a,redirectAuthInitiator:c,oidcIdpStateId:l,samlIdpStateId:d,samlIdpUsername:u,ssoAppId:f,oidcLoginHint:g}),p(this,Kr,!0,"f")}}))}disconnectedCallback(){h(this,Jr,"f").unsubscribeAll(),h(this,Yr,"f").unsubscribeAll(),h(this,Br,"m",vi).call(this),window.removeEventListener("popstate",h(this,Zr,"f").popstate),window.removeEventListener("visibilitychange",h(this,Zr,"f").visibilitychange),window.removeEventListener("components-context",h(this,Zr,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&h(this,Kr,"f")&&t!==n&&Wi.observedAttributes.includes(e)){h(this,Br,"m",oi).call(this);const o=null===t;h(this,Jr,"f").update((({stepId:t,executionId:r})=>{let i=t,s=r;return o||(s=null,i=null,jr()),{[Cr(e)]:n,stepId:i,executionId:s}})),h(this,Yr,"f").update({isDebug:this.debug})}}}Kr=new WeakMap,Jr=new WeakMap,Yr=new WeakMap,Gr=new WeakMap,Xr=new WeakMap,Zr=new WeakMap,Qr=new WeakMap,di=new WeakMap,Br=new WeakSet,ei=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Hr.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},ti=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},ni=function(){const e=this.shadowRoot.host,t=document.createElement("form");e.parentElement.appendChild(t),t.appendChild(e)},oi=function(){const e=["base-url","tenant","theme","locale","debug","redirect-url","auto-focus","preview","storage-prefix","form","client"];if(Wi.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Cr(t)])throw Error(`${t} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},ri=function(){const{stepId:e,executionId:t}=xr();h(this,Jr,"f").update({stepId:e,executionId:t})},ii=function(){document.hidden||setTimeout((()=>{h(this,Jr,"f").update({deferredRedirect:!1})}),300)},si=function(e,t){this.sdk=To(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix},Wi.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>u(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield t(...e)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},ai=function(e,t,n){return u(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:o}=e;if(n("projectId")||n("baseUrl")){if(!t)return;h(this,Br,"m",si).call(this,t,o)}h(this,Qr,"f").call(this,e)}))},ci=function(){return u(this,void 0,void 0,(function*(){return(yield h(this,di,"f").call(this)).isMissingConfig&&(yield h(this,Br,"m",li).call(this))}))},li=function(){return u(this,void 0,void 0,(function*(){const e=Ir(this.projectId,Xo,"v2-alpha");try{return yield Er(e,"json"),!0}catch(e){return!1}}))},ui=function(){var e,t;return u(this,void 0,void 0,(function*(){const{projectConfig:n}=yield h(this,di,"f").call(this),o=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;o&&Object.values(o).forEach((e=>(e=>{if(!e)return;const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url)))}))},hi=function(){return u(this,void 0,void 0,(function*(){yield h(this,Br,"m",pi).call(this),yield h(this,Br,"m",gi).call(this)}))},pi=function(){var e,t,n,o;return u(this,void 0,void 0,(function*(){const r=document.createElement("style"),i=Ir(this.projectId,"theme.json");try{const{body:s}=yield Er(i,"json");r.innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(t=null==s?void 0:s.dark)||void 0===t?void 0:t.globals)||"");const a=yield Wi.descopeUI;(null==a?void 0:a.componentsThemeManager)&&(a.componentsThemeManager.themes={light:null===(n=null==s?void 0:s.light)||void 0===n?void 0:n.components,dark:null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.components})}catch(r){this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(r)}))},fi=function(e){p(this,Gr,Object.assign(Object.assign({},e.detail),h(this,Gr,"f")),"f")},gi=function(){return u(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield Wi.descopeUI;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},vi=function(){var e;null===(e=h(this,Xr,"f"))||void 0===e||e.remove(),p(this,Xr,null,"f")},mi=function({isDebug:e}){return u(this,void 0,void 0,(function*(){e?(p(this,Xr,document.createElement("descope-debugger"),"f"),Object.assign(h(this,Xr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return sd})),document.body.appendChild(h(this,Xr,"f"))):h(this,Br,"m",vi).call(this)}))},yi=function(e,t){var n;e&&this.debug&&(null===(n=h(this,Xr,"f"))||void 0===n||n.updateData({title:e,description:t}))},bi=function(){this.rootElement.onkeydown=e=>{var t;const n=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href"));if("Enter"!==e.key||n)return;e.preventDefault();const o=this.rootElement.querySelectorAll("descope-button");if(1===o.length&&"false"!==o[0].getAttribute("auto-submit"))return void o[0].click();const r=Array.from(o).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===r.length)return void r[0].click();const i=Array.from(o).filter((e=>"button"===e.getAttribute("data-type")));if(1===i.length)"false"!==i[0].getAttribute("auto-submit")&&i[0].click();else if(0===i.length){const e=Array.from(o).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},wi=function(){var e,t;return u(this,void 0,void 0,(function*(){return(null===(t=null===(e=yield h(this,di,"f").call(this))||void 0===e?void 0:e.projectConfig)||void 0===t?void 0:t.componentsVersion)||(this.logger.error("Did not get components version, using latest version"),"latest")}))},ki=function(){return u(this,void 0,void 0,(function*(){Wi.descopeUI?this.loggerWrapper.info("DescopeUI is already loading, probably multiple flows are running on the same page"):Wi.descopeUI=new Promise((e=>{if(globalThis.DescopeUI)return void e(globalThis.DescopeUI);const t=e=>{const t=document.createElement("script");return t.id="load-descope-ui",t.src=e,t},n=(e,t)=>e.replace("<version>",t),o=(t,n)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${t.src}"`),n()};t.addEventListener("load",(()=>{globalThis.DescopeUI||o(),e(globalThis.DescopeUI)})),t.addEventListener("error",o)};(()=>{u(this,void 0,void 0,(function*(){const r=yield h(this,Br,"m",wi).call(this),i=t(n(Qo,r));o(i,(()=>{i.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const s=t(n(er,r));o(s,(()=>{e(void 0)})),document.body.append(s)})),document.body.append(i)}))})()}))}))},Wi.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.8.5"}};class Fi extends Wi{static set sdkConfigOverrides(e){Wi.sdkConfigOverrides=e}constructor(){const e=new Lr;super(e.update.bind(e)),Ei.add(this),this.stepState=new Lr({},{updateOnlyOnChange:!1}),Ii.set(this,void 0),Oi.set(this,null),xi.set(this,((e,t,n,o,r)=>{n===gr&&p(this,Ii,setTimeout((()=>u(this,void 0,void 0,(function*(){var n;const i=yield this.sdk.flow.next(e,t,yr,o,r,{});h(this,Ci,"f").call(this,i);const{action:s}=null!==(n=null==i?void 0:i.data)&&void 0!==n?n:{};h(this,xi,"f").call(this,e,t,s,o,r)}))),2e3),"f")})),ji.set(this,(()=>{clearTimeout(h(this,Ii,"f")),p(this,Ii,null,"f")})),Ci.set(this,(e=>{var t,n,o,r,i,s,a,c,l;if(!(null==e?void 0:e.ok)){h(this,Ei,"m",$i).call(this,"error",null==e?void 0:e.error);const s=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,a=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.statusText}`;return void this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorDescription)||s,(null===(i=null==e?void 0:e.error)||void 0===i?void 0:i.errorMessage)||a)}const d=null===(c=null===(a=null===(s=e.data)||void 0===s?void 0:s.screen)||void 0===a?void 0:a.state)||void 0===c?void 0:c.errorText;(null===(l=e.data)||void 0===l?void 0:l.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${d?`${d} - `:""}${e.data.error.message}`):d&&this.loggerWrapper.error(d);const{status:u,authInfo:p,lastAuth:f}=e.data;if("completed"===u)return function(e){(null==e?void 0:e.authMethod)&&Yo&&localStorage.setItem(cr,JSON.stringify(e))}(f),void h(this,Ei,"m",$i).call(this,"success",p);const{executionId:g,stepId:v,stepName:m,action:y,screen:b,redirect:w,webauthn:k,error:E,samlIdpResponse:I}=e.data;y!==gr?(this.loggerWrapper.info(`Step "${m||`#${v}`}" is ${u}`,"",{screen:b,status:u,stepId:v,stepName:m,action:y,error:E}),this.flowState.update({stepId:v,executionId:g,action:y,redirectTo:null==w?void 0:w.url,screenId:null==b?void 0:b.id,screenState:null==b?void 0:b.state,webauthnTransactionId:null==k?void 0:k.transactionId,webauthnOptions:null==k?void 0:k.options,samlIdpResponseUrl:null==I?void 0:I.url,samlIdpResponseSamlResponse:null==I?void 0:I.samlResponse,samlIdpResponseRelayState:null==I?void 0:I.relayState})):this.flowState.update({action:y})})),Si.set(this,Sr((()=>u(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),Ti.set(this,Nr(((e,t)=>u(this,void 0,void 0,(function*(){if("true"===e.getAttribute("formnovalidate")||h(this,Ei,"m",Ri).call(this)){const o=null==e?void 0:e.getAttribute("id");h(this,Ei,"m",Ui).call(this,e);const r=yield h(this,Ei,"m",Ni).call(this),i=(n=e,Array.from((null==n?void 0:n.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{})),s=this.getComponentsContext(),a=Object.assign(Object.assign(Object.assign(Object.assign({},s),i),r),{origin:window.location.origin}),c=yield this.getFlowConfig(),l=yield this.getProjectConfig(),d=yield t(o,c.version,l.componentsVersion,a);h(this,Ci,"f").call(this,d),h(this,Ei,"m",Mi).call(this,r)}var n}))))),this.flowState=e}connectedCallback(){const e=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var t,n;return u(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(n=this.stepState)||void 0===n||n.subscribe(this.onStepChange.bind(this))),yield e.connectedCallback.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=h(this,Oi,"f"))||void 0===e||e.abort(),p(this,Oi,null,"f")}getHtmlFilenameWithLocale(e,t){return u(this,void 0,void 0,(function*(){let n,o=navigator.language;o&&"zh-TW"!==o&&(o=o.split("-")[0]);const r=(e||o||"").toLowerCase();return(yield this.getTargetLocales()).includes(r)&&(n=`${t}-${r}.html`),n}))}getPageContent(e,t){return u(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield Er(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield Er(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,t,n){var o,r;return u(this,void 0,void 0,(function*(){const{projectId:i,flowId:s,tenant:a,stepId:c,executionId:l,action:d,screenId:u,screenState:f,redirectTo:g,redirectUrl:v,token:m,code:y,exchangeError:b,webauthnTransactionId:w,webauthnOptions:k,redirectAuthCodeChallenge:E,redirectAuthCallbackUrl:I,redirectAuthBackupCallbackUri:O,redirectAuthInitiator:x,oidcIdpStateId:j,locale:C,samlIdpStateId:S,samlIdpUsername:_,samlIdpResponseUrl:A,samlIdpResponseSamlResponse:R,samlIdpResponseRelayState:N,ssoAppId:U,oidcLoginHint:M}=e;let T,P;const D=(()=>{const e=localStorage.getItem(zr);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(zr,e.toString()),e}return Number(e)})(),L=this.sdk.getLastUserLoginId(),$=yield this.getFlowConfig(),W=yield this.getProjectConfig(),F=I&&E?{callbackUrl:I,codeChallenge:E,backupCallbackUri:O}:void 0;if(!l&&($.fingerprintEnabled&&$.fingerprintKey?lo($.fingerprintKey):localStorage.removeItem(ao),$.conditions?({startScreenId:T,conditionInteractionId:P}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var r;if("ELSE"===t)return!0;const i=null===(r=qr[t])||void 0===r?void 0:r[n];return!!(null==i?void 0:i(e,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:L,code:y,token:m,abTestingKey:D},$.conditions)):$.condition?({startScreenId:T,conditionInteractionId:P}=((e,t)=>{var n;const o=null===(n=qr[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const r=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})($.condition,{loginId:L,code:y,token:m,abTestingKey:D})):T=$.startScreenId,!_r(T,j,S,_,U,M))){const e=yield this.sdk.flow.start(s,Object.assign(Object.assign({tenant:a,redirectAuth:F,oidcIdpStateId:j,samlIdpStateId:S,samlIdpUsername:_,ssoAppId:U,oidcLoginHint:M,client:this.client},v&&{redirectUrl:v}),{lastAuth:Vr(L),abTestingKey:D}),P,"",$.version,W.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),y?{exchangeCode:y,idpInitiated:!0}:{}),m?{token:m}:{}),M?{externalId:M}:{}));return h(this,Ci,"f").call(this,e),void("completed"!==(null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.status)&&this.flowState.update({code:void 0,token:void 0}))}if(l&&(n("token")&&m||n("code")&&y||n("exchangeError")&&b)){const e=yield this.sdk.flow.next(l,c,mr,$.version,W.componentsVersion,{token:m,exchangeCode:y,exchangeError:b});return h(this,Ci,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if("loadForm"===d&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>n(e)))){if(!A||!R)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const r=document.createElement("form");r.method="POST",r.action=e,r.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(r),o(r)})(A,R,N||"",Ar)}if("redirect"===d&&(n("redirectTo")||n("deferredRedirect")))return g?"android"===x&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(g):void this.loggerWrapper.error("Did not get redirect url");if(d===vr||"webauthnGet"===d){if(!w||!k)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(r=h(this,Oi,"f"))||void 0===r||r.abort(),p(this,Oi,null,"f");try{e=d===vr?yield this.sdk.webauthn.helpers.create(k):yield this.sdk.webauthn.helpers.get(k)}catch(i){"InvalidStateError"===i.name?this.loggerWrapper.warn("WebAuthn operation failed",i.message):"NotAllowedError"!==i.name&&this.loggerWrapper.error(i.message),t=i.name}const n=yield this.sdk.flow.next(l,c,mr,$.version,W.componentsVersion,{transactionId:w,response:e,failure:t});h(this,Ci,"f").call(this,n)}if(h(this,xi,"f").call(this,l,c,d,$.version,W.componentsVersion),!u&&!T)return void this.loggerWrapper.warn("No screen was found to show");const q=T||u,V=yield this.getHtmlFilenameWithLocale(C,q),z={direction:Or(+c,+t.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.form),null==f?void 0:f.form),lastAuth:{loginId:L,name:this.sdk.getLastUserDisplayName()||L}}),htmlUrl:Ir(i,`${q}.html`),htmlLocaleUrl:V&&Ir(i,V),samlIdpUsername:_,oidcLoginHint:M},H=Vr(L);_r(T,j,S,_,U,M)?z.next=(e,t,n,o)=>this.sdk.flow.start(s,Object.assign({tenant:a,redirectAuth:F,oidcIdpStateId:j,samlIdpStateId:S,samlIdpUsername:_,ssoAppId:U,oidcLoginHint:M,lastAuth:H,preview:this.preview,abTestingKey:D,client:this.client},v&&{redirectUrl:v}),P,e,t,n,Object.assign(Object.assign(Object.assign(Object.assign({},this.form),o),y&&{exchangeCode:y,idpInitiated:!0}),m&&{token:m})):(n("projectId")||n("baseUrl")||n("executionId")||n("stepId"))&&(z.next=(...e)=>this.sdk.flow.next(l,c,...e)),this.stepState.update(z)}))}loadDescopeUiComponents(e){return u(this,void 0,void 0,(function*(){const t=yield Wi.descopeUI;if(!t)return;const n=(e=>[...Array.from(e.querySelectorAll("*")).reduce(((e,t)=>t.tagName.startsWith("DESCOPE-")?e.add(t.tagName.toLocaleLowerCase()):e),new Set)])(e);yield Promise.all(n.map((e=>u(this,void 0,void 0,(function*(){if(!customElements.get(e))if(t[e])try{return yield t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`${e} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)})))))}))}onStepChange(e,t){var n,o;return u(this,void 0,void 0,(function*(){const{htmlUrl:r,htmlLocaleUrl:i,direction:s,next:a,screenState:c}=e,l=document.createElement("template");l.innerHTML=yield this.getPageContent(r,i);const d=l.content.cloneNode(!0),p=this.loadDescopeUiComponents(l.content);this.sdk.webauthn.helpers.isSupported()?yield h(this,Ei,"m",Ai).call(this,d,a):d.querySelectorAll(`descope-button[${fr}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(n=c.form)||void 0===n?void 0:n.loginId)||(null===(o=c.form)||void 0===o?void 0:o.email)||(c.form||(c.form={}),c.form.loginId=e.samlIdpUsername,c.form.email=e.samlIdpUsername),((e,t,n,o,r)=>{var i;let s=null==t?void 0:t.errorText;try{s=(null==o?void 0:o({text:null==t?void 0:t.errorText,type:null==t?void 0:t.errorType}))||(null==t?void 0:t.errorText)}catch(e){r.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${fr}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(e,"error-message",s),((e,t)=>{e.querySelectorAll(`[${fr}="totp-link"]`).forEach((e=>{e.setAttribute("href",t)}))})(e,null===(i=null==t?void 0:t.totp)||void 0===i?void 0:i.provisionUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link").forEach((e=>{e.textContent=Wr(e.textContent,t)}))})(e,t),((e,t,n)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const r=t[o];Object.keys(r).forEach((t=>{let o=r[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){n.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,n,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=Wr(e.value,t)}))}))})(e,t)})(d,c,c.componentsConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(d,f);const g=()=>u(this,void 0,void 0,(function*(){var e;yield p,((e,t)=>{var n,o;const r=null===(n=customElements.get("descope-totp-image"))||void 0===n?void 0:n.cssVarList.url;t&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${t})`))})(this.shadowRoot.querySelector("div"),null===(e=null==c?void 0:c.totp)||void 0===e?void 0:e.image),this.rootElement.replaceChildren(d),setTimeout((()=>((e,t)=>{$r(e,null==t?void 0:t.inputs),$r(e,null==t?void 0:t.form)})(this.rootElement,c)));const n=!t.htmlUrl;if(((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,n),h(this,Ei,"m",Di).call(this,a),n&&h(this,Ei,"m",$i).call(this,"ready",{}),h(this,Ei,"m",$i).call(this,"page-updated",{}),this.rootElement.querySelector(`[${fr}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),n=yield a(yr,e.version,t.componentsVersion,{});h(this,Ci,"f").call(this,n)}}));s?h(this,Ei,"m",Li).call(this,g,s):g()}))}}Ii=new WeakMap,Oi=new WeakMap,xi=new WeakMap,ji=new WeakMap,Ci=new WeakMap,Si=new WeakMap,Ti=new WeakMap,Ei=new WeakSet,_i=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},Ai=function(e,t){var n;return u(this,void 0,void 0,(function*(){null===(n=h(this,Oi,"f"))||void 0===n||n.abort();const o=e.querySelector('*[autocomplete="webauthn"]');if(o&&(yield Fr())){const{options:e,transactionId:n}=(yield h(this,Si,"f").call(this))||{};if(e&&n){h(this,Ei,"m",_i).call(this,o),p(this,Oi,new AbortController,"f");const r=yield this.getFlowConfig(),i=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(e,h(this,Oi,"f")).then((e=>u(this,void 0,void 0,(function*(){const s=yield t(o.id,r.version,i.componentsVersion,{transactionId:n,response:e});h(this,Ci,"f").call(this,s)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},Ri=function(){return Array.from(this.shadowRoot.querySelectorAll("*[name]")).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))},Ni=function(){return u(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${ar}])`));return(yield Promise.all(e.map((e=>u(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},Ui=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},Mi=function(e={}){var t,n;const o=Rr(e,["externalId","email","phone"]),r=Rr(e,["newPassword","password"]);if(o&&r)try{const e=new globalThis.PasswordCredential({id:o,password:r});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},Pi=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&h(this,Ti,"f").call(this,t,e)}))}))},Di=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((t=>{t.onclick=()=>{h(this,Ti,"f").call(this,t,e)}})),h(this,Ei,"m",Pi).call(this,e)},Li=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===br.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),this.rootElement.classList.add("fade-out")},$i=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.define("descope-wc",Fi);var qi=Object.freeze({__proto__:null,default:Fi}),Vi=e=>{let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}},zi=(e,t,n)=>{const{memoize:o,memoizeOptions:r}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...r);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},Hi={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Bi=e=>Array.isArray(e)?e:[e];function Ki(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Ji(e,t){const n=[],{length:o}=e;for(let r=0;r<o;r++)n.push(e[r].apply(null,t));return n}var Yi=(e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...Hi,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Vi},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:zi}}},Gi="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}};function Xi(e,t={}){let n={s:0,v:void 0,o:null,p:null};const{resultEqualityCheck:o}=t;let r,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t={s:0,v:void 0,o:null,p:null},e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t={s:0,v:void 0,o:null,p:null},e.set(n,t)):t=o}}const a=t;let c;if(1===t.s?c=t.v:(c=e.apply(null,arguments),i++),a.s=1,o){const e=r?.deref()??r;null!=e&&o(e,c)&&(c=e,0!==i&&i--);r="object"==typeof c&&null!==c||"function"==typeof c?new Gi(c):c}return a.v=c,c}return s.clearCache=()=>{n={s:0,v:void 0,o:null,p:null},s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function Zi(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e;return(...e)=>{let t,o=0,r=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:d=Xi,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=Bi(l),f=Bi(u),g=Ki(e),v=c((function(){return o++,s.apply(null,arguments)}),...p);let m=!0;const y=d((function(){r++;const e=Ji(g,arguments);if("production"!==process.env.NODE_ENV){const{identityFunctionCheck:t,inputStabilityCheck:n}=Yi(m,h);if(t.shouldRun&&t.run(s),n.shouldRun){const t=Ji(g,arguments);n.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}m&&(m=!1)}return t=v.apply(null,e),t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:c,argsMemoize:d})}}var Qi=Zi(Xi);function es(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var ts=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ns=()=>Math.random().toString(36).substring(7).split("").join("."),os={INIT:`@@redux/INIT${ns()}`,REPLACE:`@@redux/REPLACE${ns()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ns()}`};function rs(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function is(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function ss(e){let t=typeof e;return"production"!==process.env.NODE_ENV&&(t=is(e)),t}function as(e,t,n){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?es(2):`Expected the root reducer to be a function. Instead, received: '${ss(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("production"===process.env.NODE_ENV?es(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error("production"===process.env.NODE_ENV?es(1):`Expected the enhancer to be a function. Instead, received: '${ss(n)}'`);return n(as)(e,t)}let o=e,r=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(c)throw new Error("production"===process.env.NODE_ENV?es(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return r}function u(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?es(4):`Expected the listener to be a function. Instead, received: '${ss(e)}'`);if(c)throw new Error("production"===process.env.NODE_ENV?es(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("production"===process.env.NODE_ENV?es(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),i=null}}}function h(e){if(!rs(e))throw new Error("production"===process.env.NODE_ENV?es(7):`Actions must be plain objects. Instead, the actual type was: '${ss(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error("production"===process.env.NODE_ENV?es(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error("production"===process.env.NODE_ENV?es(17):`Action "type" property must be a string. Instead, the actual type was: '${ss(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("production"===process.env.NODE_ENV?es(9):"Reducers may not dispatch actions.");try{c=!0,r=o(r,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}function p(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?es(10):`Expected the nextReducer to be a function. Instead, received: '${ss(e)}`);o=e,h({type:os.REPLACE})}function f(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error("production"===process.env.NODE_ENV?es(11):`Expected the observer to be an object. Instead, received: '${ss(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[ts](){return this}}}h({type:os.INIT});const g={dispatch:h,subscribe:u,getState:d,replaceReducer:p,[ts]:f};return g}function cs(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function ls(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const r=t[o];"production"!==process.env.NODE_ENV&&void 0===e[r]&&cs(`No reducer provided for key "${r}"`),"function"==typeof e[r]&&(n[r]=e[r])}const o=Object.keys(n);let r,i;"production"!==process.env.NODE_ENV&&(r={});try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:os.INIT}))throw new Error("production"===process.env.NODE_ENV?es(12):`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:os.PROBE_UNKNOWN_ACTION()}))throw new Error("production"===process.env.NODE_ENV?es(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${os.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){i=e}return function(e={},t){if(i)throw i;if("production"!==process.env.NODE_ENV){const o=function(e,t,n,o){const r=Object.keys(t),i=n&&n.type===os.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===r.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!rs(e))return`The ${i} has unexpected type of "${ss(e)}". Expected argument to be an object with the following keys: "${r.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===os.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${r.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,r);o&&cs(o)}let s=!1;const a={};for(let r=0;r<o.length;r++){const i=o[r],c=n[i],l=e[i],d=c(l,t);if(void 0===d){const e=t&&t.type;throw new Error("production"===process.env.NODE_ENV?es(14):`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=d,s=s||d!==l}return s=s||o.length!==Object.keys(e).length,s?a:e}}function ds(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function us(e){return rs(e)&&"type"in e&&"string"==typeof e.type}var hs=Symbol.for("immer-nothing"),ps=Symbol.for("immer-draftable"),fs=Symbol.for("immer-state"),gs="production"!==process.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function vs(e,...t){if("production"!==process.env.NODE_ENV){const n=gs[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ms=Object.getPrototypeOf;function ys(e){return!!e&&!!e[fs]}function bs(e){return!!e&&(ks(e)||Array.isArray(e)||!!e[ps]||!!e.constructor?.[ps]||js(e)||Cs(e))}var ws=Object.prototype.constructor.toString();function ks(e){if(!e||"object"!=typeof e)return!1;const t=ms(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===ws}function Es(e,t){0===Is(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Is(e){const t=e[fs];return t?t.type_:Array.isArray(e)?1:js(e)?2:Cs(e)?3:0}function Os(e,t){return 2===Is(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function xs(e,t,n){const o=Is(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function js(e){return e instanceof Map}function Cs(e){return e instanceof Set}function Ss(e){return e.copy_||e.base_}function _s(e,t){if(js(e))return new Map(e);if(Cs(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&ks(e)){if(!ms(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[fs];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const r=o[t],i=n[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[r]})}return Object.create(ms(e),n)}function As(e,t=!1){return Ns(e)||ys(e)||!bs(e)||(Is(e)>1&&(e.set=e.add=e.clear=e.delete=Rs),Object.freeze(e),t&&Es(e,((e,t)=>As(t,!0)))),e}function Rs(){vs(2)}function Ns(e){return Object.isFrozen(e)}var Us,Ms={};function Ts(e){const t=Ms[e];return t||vs(0,e),t}function Ps(){return Us}function Ds(e,t){t&&(Ts("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ls(e){$s(e),e.drafts_.forEach(Fs),e.drafts_=null}function $s(e){e===Us&&(Us=e.parent_)}function Ws(e){return Us={drafts_:[],parent_:Us,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Fs(e){const t=e[fs];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function qs(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[fs].modified_&&(Ls(t),vs(4)),bs(e)&&(e=Vs(t,e),t.parent_||Hs(t,e)),t.patches_&&Ts("Patches").generateReplacementPatches_(n[fs].base_,e,t.patches_,t.inversePatches_)):e=Vs(t,n,[]),Ls(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==hs?e:void 0}function Vs(e,t,n){if(Ns(t))return t;const o=t[fs];if(!o)return Es(t,((r,i)=>zs(e,o,t,r,i,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return Hs(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let r=t,i=!1;3===o.type_&&(r=new Set(t),t.clear(),i=!0),Es(r,((r,s)=>zs(e,o,t,r,s,n,i))),Hs(e,t,!1),n&&e.patches_&&Ts("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function zs(e,t,n,o,r,i,s){if("production"!==process.env.NODE_ENV&&r===n&&vs(5),ys(r)){const s=Vs(e,r,i&&t&&3!==t.type_&&!Os(t.assigned_,o)?i.concat(o):void 0);if(xs(n,o,s),!ys(s))return;e.canAutoFreeze_=!1}else s&&n.add(r);if(bs(r)&&!Ns(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Vs(e,r),t&&t.scope_.parent_||Hs(e,r)}}function Hs(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&As(t,n)}var Bs={get(e,t){if(t===fs)return e;const n=Ss(e);if(!Os(n,t))return function(e,t,n){const o=Ys(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!bs(o)?o:o===Js(e.base_,t)?(Xs(e),e.copy_[t]=Zs(o,e)):o},has:(e,t)=>t in Ss(e),ownKeys:e=>Reflect.ownKeys(Ss(e)),set(e,t,n){const o=Ys(Ss(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=Js(Ss(e),t),r=o?.[fs];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||Os(e.base_,t)))return!0;Xs(e),Gs(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==Js(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Xs(e),Gs(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ss(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){vs(11)},getPrototypeOf:e=>ms(e.base_),setPrototypeOf(){vs(12)}},Ks={};function Js(e,t){const n=e[fs];return(n?Ss(n):e)[t]}function Ys(e,t){if(!(t in e))return;let n=ms(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=ms(n)}}function Gs(e){e.modified_||(e.modified_=!0,e.parent_&&Gs(e.parent_))}function Xs(e){e.copy_||(e.copy_=_s(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Es(Bs,((e,t)=>{Ks[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Ks.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&vs(13),Ks.set.call(this,e,t,void 0)},Ks.set=function(e,t,n){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&vs(14),Bs.set.call(this,e[0],t,n,e[0])};function Zs(e,t){const n=js(e)?Ts("MapSet").proxyMap_(e,t):Cs(e)?Ts("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Ps(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=Bs;n&&(r=[o],i=Ks);const{revoke:s,proxy:a}=Proxy.revocable(r,i);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:Ps()).drafts_.push(n),n}function Qs(e){return ys(e)||vs(10,e),ea(e)}function ea(e){if(!bs(e)||Ns(e))return e;const t=e[fs];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=_s(e,t.scope_.immer_.useStrictShallowCopy_)}else n=_s(e,!0);return Es(n,((e,t)=>{xs(n,e,ea(t))})),t&&(t.finalized_=!1),n}var ta=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...r){return o.produce(e,(e=>t.call(this,e,...r)))}}let o;if("function"!=typeof t&&vs(6),void 0!==n&&"function"!=typeof n&&vs(7),bs(e)){const r=Ws(this),i=Zs(e,void 0);let s=!0;try{o=t(i),s=!1}finally{s?Ls(r):$s(r)}return Ds(r,n),qs(o,r)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===hs&&(o=void 0),this.autoFreeze_&&As(o,!0),n){const t=[],r=[];Ts("Patches").generateReplacementPatches_(e,o,t,r),n(t,r)}return o}vs(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const r=this.produce(e,t,((e,t)=>{n=e,o=t}));return[r,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){bs(e)||vs(8),ys(e)&&(e=Qs(e));const t=Ws(this),n=Zs(e,void 0);return n[fs].isManual_=!0,$s(t),n}finishDraft(e,t){const n=e&&e[fs];n&&n.isManual_||vs(9);const{scope_:o}=n;return Ds(o,t),qs(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Ts("Patches").applyPatches_;return ys(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},na=ta.produce;function oa(e){return({dispatch:t,getState:n})=>o=>r=>"function"==typeof r?r(t,n,e):o(r)}ta.produceWithPatches.bind(ta),ta.setAutoFreeze.bind(ta),ta.setUseStrictShallowCopy.bind(ta),ta.applyPatches.bind(ta),ta.createDraft.bind(ta),ta.finishDraft.bind(ta);var ra=oa(),ia=oa;((...e)=>{const t=Zi(...e),n=Object.assign(((...e)=>{const n=t(...e),o=(e,...t)=>n(ys(e)?Qs(e):e,...t);return Object.assign(o,n),o}),{withTypes:()=>n})})(Xi);var sa="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?ds:ds.apply(null,arguments)},aa=e=>e&&"function"==typeof e.match;function ca(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("production"===process.env.NODE_ENV?Ja(0):"prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>us(t)&&t.type===e,n}function la(e){return"function"==typeof e&&"type"in e&&aa(e)}function da(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var ua=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function ha(e){return bs(e)?na(e,(()=>{})):e}function pa(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("production"===process.env.NODE_ENV?Ja(10):"No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function fa(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function ga(e,t,n){const o=va(e,t,n);return{detectMutations:()=>ma(e,t,o,n)}}function va(e,t=[],n,o="",r=new Set){const i={value:n};if(!e(n)&&!r.has(n)){r.add(n),i.children={};for(const r in n){const s=o?o+"."+r:r;t.length&&-1!==t.indexOf(s)||(i.children[r]=va(e,t,n[r],s))}}return i}function ma(e,t=[],n,o,r=!1,i=""){const s=n?n.value:void 0,a=s===o;if(r&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:i};if(e(s)||e(o))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let r in c){const s=i?i+"."+r:r;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=ma(e,t,n.children[r],o[r],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function ya(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||rs(e)}function ba(e,t="",n=ya,o,r=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),c=r.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(r.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=ba(l,a,n,o,r,i),s))return s}return i&&wa(e)&&i.add(e),!1}function wa(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!wa(t))return!1;return!0}function ka(e){return"boolean"==typeof e}var Ea=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:r=!0}=e??{};let i=new ua;if(t&&(ka(t)?i.push(ra):i.push(ia(t.extraArgument))),"production"!==process.env.NODE_ENV){if(n){let e={};ka(n)||(e=n),i.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{let t=function(e,t,o,r){return JSON.stringify(e,n(t,r),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(r,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,r):o.push(r),~n.indexOf(i)&&(i=t.call(this,r,i))}else n.push(i);return null==e?i:e.call(this,r,i)}},{isImmutable:o=fa,ignoredPaths:r,warnAfter:i=32}=e;const s=ga.bind(null,o,r);return({getState:e})=>{let n,o=e(),r=s(o);return a=>c=>{const l=da(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error("production"===process.env.NODE_ENV?Ja(19):`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(c);return l.measureTime((()=>{if(o=e(),n=r.detectMutations(),r=s(o),n.wasMutated)throw new Error("production"===process.env.NODE_ENV?Ja(20):`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),d}}}}(e))}if(o){let e={};ka(o)||(e=o),i.push(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{const{isSerializable:t=ya,getEntries:n,ignoredActions:o=[],ignoredActionPaths:r=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!us(u))return l(u);const h=l(u),p=da(s,"SerializableStateInvariantMiddleware");return c||o.length&&-1!==o.indexOf(u.type)||p.measureTime((()=>{const e=ba(u,"",t,n,r,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const o=ba(e.getState(),"",t,n,i,d);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(r){let e={};ka(r)||(e=r),i.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);const{isActionCreator:t=la}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}}return i},Ia=e=>t=>{setTimeout(t,e)},Oa="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Ia(10),xa=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new ua(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let r=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?Oa:"callback"===e.type?e.queueNotification:Ia(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>r&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return r=!e?.meta?.RTK_autoBatch,i=!r,i&&(s||(s=!0,c(l))),o.dispatch(e)}finally{r=!0}}})})("object"==typeof n?n:void 0)),o},ja="production"===process.env.NODE_ENV;function Ca(e){const t=Ea(),{reducer:n,middleware:o,devTools:r=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!rs(n))throw new Error("production"===process.env.NODE_ENV?Ja(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=ls(n)}if(!ja&&o&&"function"!=typeof o)throw new Error("production"===process.env.NODE_ENV?Ja(2):"`middleware` field must be a callback");if("function"==typeof o){if(c=o(t),!ja&&!Array.isArray(c))throw new Error("production"===process.env.NODE_ENV?Ja(3):"when using a middleware builder function, an array of middleware must be returned")}else c=t();if(!ja&&c.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?Ja(4):"each middleware provided to configureStore must be a function");let l=ds;r&&(l=sa({trace:!ja,..."object"==typeof r&&r}));const d=function(...e){return t=>(n,o)=>{const r=t(n,o);let i=()=>{throw new Error("production"===process.env.NODE_ENV?es(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:r.getState,dispatch:(e,...t)=>i(e,...t)},a=e.map((e=>e(s)));return i=ds(...a)(r.dispatch),{...r,dispatch:i}}}(...c),u=xa(d);if(!ja&&s&&"function"!=typeof s)throw new Error("production"===process.env.NODE_ENV?Ja(5):"`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!ja&&!Array.isArray(h))throw new Error("production"===process.env.NODE_ENV?Ja(6):"`enhancers` callback must return an array");if(!ja&&h.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?Ja(7):"each enhancer provided to configureStore must be a function");ja||!c.length||h.includes(d)||console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return as(a,i,l(...h))}function Sa(e){const t={},n=[];let o;const r={addCase(e,i){if("production"!==process.env.NODE_ENV){if(n.length>0)throw new Error("production"===process.env.NODE_ENV?Ja(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("production"===process.env.NODE_ENV?Ja(27):"`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const s="string"==typeof e?e:e.type;if(!s)throw new Error("production"===process.env.NODE_ENV?Ja(28):"`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error("production"===process.env.NODE_ENV?Ja(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,r},addMatcher(e,t){if("production"!==process.env.NODE_ENV&&o)throw new Error("production"===process.env.NODE_ENV?Ja(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),r},addDefaultCase(e){if("production"!==process.env.NODE_ENV&&o)throw new Error("production"===process.env.NODE_ENV?Ja(31):"`builder.addDefaultCase` can only be called once");return o=e,r}};return e(r),[t,n,o]}var _a=(e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t};function Aa(...e){return t=>e.some((e=>((e,t)=>aa(e)?e.match(t):e(t))(e,t)))}var Ra=["name","message","stack","code"],Na=class{constructor(e,t){this.payload=e,this.meta=t}_type},Ua=class{constructor(e,t){this.payload=e,this.meta=t}_type},Ma=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of Ra)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},Ta=(()=>{function e(e,t,n){const o=ca(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),r=ca(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=ca(e+"/rejected",((e,t,o,r,i)=>({payload:r,error:(n&&n.serializeError||Ma)(e||"Rejected"),meta:{...i||{},arg:o,requestId:t,rejectedWithValue:!!r,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):_a(),d=new AbortController;let u,h;function p(e){h=e,d.abort()}const f=async function(){let f;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(g=i)&&"object"==typeof g&&"function"==typeof g.then&&(i=await i),!1===i||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const v=new Promise(((e,t)=>{u=()=>{t({name:"AbortError",message:h||"Aborted"})},d.signal.addEventListener("abort",u)}));s(r(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),f=await Promise.race([v,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:d.signal,abort:p,rejectWithValue:(e,t)=>new Na(e,t),fulfillWithValue:(e,t)=>new Ua(e,t)})).then((t=>{if(t instanceof Na)throw t;return t instanceof Ua?o(t.payload,l,e,t.meta):o(t,l,e)}))])}catch(t){f=t instanceof Na?i(null,l,e,t.payload,t.meta):i(t,l,e)}finally{u&&d.signal.removeEventListener("abort",u)}var g;return n&&!n.dispatchConditionRejection&&i.match(f)&&f.meta.condition||s(f),f}();return Object.assign(f,{abort:p,requestId:l,arg:e,unwrap:()=>f.then(Pa)})}}),{pending:r,rejected:i,fulfilled:o,settled:Aa(i,o),typePrefix:e})}return e.withTypes=()=>e,e})();function Pa(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var Da=Symbol.for("rtk-slice-createasyncthunk");function La(e,t){return`${e}/${t}`}function $a({creators:e}={}){const t=e?.asyncThunk?.[Da];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("production"===process.env.NODE_ENV?Ja(11):"`name` is a required option for createSlice");"undefined"!=typeof process&&"development"===process.env.NODE_ENV&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const r=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(r),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("production"===process.env.NODE_ENV?Ja(12):"`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("production"===process.env.NODE_ENV?Ja(13):"`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("production"!==process.env.NODE_ENV&&"object"==typeof e.extraReducers)throw new Error("production"===process.env.NODE_ENV?Ja(14):"The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?Sa(e.extraReducers):[e.extraReducers],r={...t,...s.sliceCaseReducersByType};return function(e,t){if("production"!==process.env.NODE_ENV&&"object"==typeof t)throw new Error("production"===process.env.NODE_ENV?Ja(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,r,i]=Sa(t);if(function(e){return"function"==typeof e}(e))n=()=>ha(e());else{const t=ha(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...r.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(ys(e)){const o=n(e,t);return void 0===o?e:o}if(bs(e))return na(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("production"===process.env.NODE_ENV?Ja(9):"A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in r)e.addCase(t,r[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}i.forEach((o=>{const i=r[o],s={reducerName:o,type:La(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,r){let i,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("production"===process.env.NODE_ENV?Ja(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=o.reducer,s=o.prepare}else i=o;r.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?ca(e,s):ca(e))}(s,i,a):function({type:e,reducerName:t},n,o,r){if(!r)throw new Error("production"===process.env.NODE_ENV?Ja(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:d}=n,u=r(e,i,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);c&&o.addCase(u.rejected,c);l&&o.addMatcher(u.settled,l);o.exposeCaseReducer(t,{fulfilled:s||qa,pending:a||qa,rejected:c||qa,settled:l||qa})}(s,i,a,t)}));const l=e=>e,d=new Map;let u;function h(e,t){return u||(u=c()),u(e,t)}function p(){return u||(u=c()),u.getInitialState()}function f(t,n=!1){function o(e){let o=e[t];if(void 0===o)if(n)o=p();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?Ja(15):"selectSlice returned undefined for an uninjected slice reducer");return o}function r(t=l){const o=pa(d,n,{insert:()=>new WeakMap});return pa(o,t,{insert:()=>{const o={};for(const[r,i]of Object.entries(e.selectors??{}))o[r]=Wa(i,t,p,n);return o}})}return{reducerPath:t,getSelectors:r,get selectors(){return r(o)},selectSlice:o}}const g={name:n,reducer:h,actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:p,...f(o),injectInto(e,{reducerPath:t,...n}={}){const r=t??o;return e.inject({reducerPath:r,reducer:h},n),{...g,...f(r,!0)}}};return g}}function Wa(e,t,n,o){function r(r,...i){let s=t(r);if(void 0===s)if(o)s=n();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?Ja(16):"selectState returned undefined for an uninjected slice reducer");return e(s,...i)}return r.unwrapped=e,r}var Fa=$a();function qa(){}var Va="listenerMiddleware",za=e=>{let{type:t,actionCreator:n,matcher:o,predicate:r,effect:i}=e;if(t)r=ca(t).match;else if(n)t=n.type,r=n.match;else if(o)r=o;else if(!r)throw new Error("production"===process.env.NODE_ENV?Ja(21):"Creating or removing a listener requires one of the known fields for matching an action");return((e,t)=>{if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?Ja(32):`${t} is not a function`)})(i,"options.listener"),{predicate:r,type:t,effect:i}},Ha=Object.assign((e=>{const{type:t,predicate:n,effect:o}=za(e);return{id:_a(),effect:o,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error("production"===process.env.NODE_ENV?Ja(22):"Unsubscribe not initialized")}}}),{withTypes:()=>Ha}),Ba=Object.assign(ca(`${Va}/add`),{withTypes:()=>Ba});ca(`${Va}/removeAll`);var Ka=Object.assign(ca(`${Va}/remove`),{withTypes:()=>Ka});function Ja(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}function Ya(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const Ga=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const o=e(n);return o[t]=!0,o}},Xa=["error","warn","info","debug"],Za=Ga((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,h(this,t,"m",o).call(this,console))}set logger(e){p(this,n,h(this,t,"m",o).call(this,e),"f")}get logger(){return h(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,o=function(e){return Xa.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},r}));var Qa;class ec{constructor(e,t){Qa.set(this,void 0),this.nodeName="",p(this,Qa,e,"f"),this.logger=t.logger}get asyncEle(){return e=h(this,Qa,"f"),1e3,u(void 0,void 0,void 0,(function*(){return new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)}))}));var e}get ele(){var e,t;const n="function"==typeof h(this,Qa,"f")?h(this,Qa,"f").call(this):h(this,Qa,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug("no element for driver ",this.constructor.name,new Error),null)}}Qa=new WeakMap;class tc extends ec{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}setData(e){var t;return u(this,void 0,void 0,(function*(){null===(t=yield this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}))}}const nc={enabled:"active"},oc=e=>e.selectedUsersLoginIds,rc=e=>e.notifications,ic=Qi((e=>e.usersList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{status:nc[e.status]||e.status,roles:e.roleNames}))))),sc=Qi((e=>e.tenantRoles.data),(e=>e)),ac=Qi(ic,oc,((e,t)=>e.filter((e=>t.includes(e.loginIds))).map((e=>e.userId)))),cc=Qi(oc,ic,((e,t)=>t.filter((t=>e.includes(t.loginIds))))),lc=Qi(oc,(e=>!!e.length)),dc=Qi(cc,(e=>1===e.length?e[0].email:`${e.length} users`)),uc=e=>Ga((t=>{const n=Fa(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(Ya(Za)(t)){constructor(...e){super(...e);const t=Ca({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),r=e=>(...n)=>u(this,void 0,void 0,(function*(){const o=yield t.dispatch(e(...n));try{Pa(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o})),i=Object.keys(o).reduce(((e,t)=>(e[t]=r(o[t]),e)),{});this.actions=i,this.subscribe=(e,n=(e=>e))=>t.subscribe((()=>e(n(t.getState()))))}}})),hc=Ga((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&h(this,t,"f")&&(p(this,t,!1,"f"),this.init())}init(){return u(this,void 0,void 0,(function*(){}))}},t=new WeakMap,n})),pc=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},fc=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),gc=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{t&&e.notifications.push({type:"success",msg:t(n)})},onRejected:(t,n)=>{e&&t.notifications.push({type:"error",msg:e(n)})}}),vc=Ta("users/create",((e,{extra:{api:t}})=>t.user.create(e))),mc=pc(vc)({onFulfilled:(e,t)=>{e.usersList.data.unshift(t.payload)}},fc((e=>e.createUser)),gc({getSuccessMsg:()=>"User created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),yc={action:vc,reducer:mc},bc=e=>{let t,n;return(...o)=>{return t&&(i=o,(r=t).length===i.length&&r.every(((e,t)=>e===i[t])))||(t=o,n=e(...o)),n;var r,i}},wc=e=>(t,...n)=>t.reduce(((t,o,r)=>{var i;return`${t}${o}${(null===(i=null==n?void 0:n[r])||void 0===i?void 0:i[e>1?1:0])||""}`}),""),kc=(e,t=500)=>{let n;return function(...o){clearTimeout(n),n=setTimeout((()=>e.apply(this,o)),t)}},Ec=Ta("users/delete",((e,{extra:{api:t}})=>t.user.deleteBatch(e))),Ic=pc(Ec)({onFulfilled:(e,t)=>{e.usersList.data=e.usersList.data.filter((e=>!t.meta.arg.includes(e.userId))),e.selectedUsersLoginIds=[]}},fc((e=>e.deleteUser)),gc({getSuccessMsg:e=>wc(e.meta.arg.length)`${["",e.meta.arg.length]} ${["U","u"]}ser${["","s"]} deleted successfully`,getErrorMsg:e=>wc(e.meta.arg.length)`Failed to delete user${["","s"]}`})),Oc={action:Ec,reducer:Ic},xc=Ta("users/expirePassword",((e,{extra:{api:t}})=>t.user.expirePassword(e))),jc={action:xc,reducer:pc(xc)(fc((e=>e.expireUserPassword)))},Cc=Ta("users/getCustomAttributes",((e,{extra:{api:t}})=>t.user.getCustomAttributes())),Sc=pc(Cc)({onFulfilled:(e,t)=>{e.customAttributes.data=t.payload}},fc((e=>e.customAttributes))),_c={action:Cc,reducer:Sc},Ac=Ta("users/search",((e,{extra:{api:t},getState:n})=>{const o=n().searchParams;return t.user.search(Object.assign(Object.assign({},o),e))})),Rc=pc(Ac)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.usersList.data=t.payload}},fc((e=>e.usersList))),Nc={action:Ac,reducer:Rc},Uc=Ta("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),Mc={action:Uc,reducer:pc(Uc)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},fc((e=>e.tenantRoles)))},Tc={usersList:{data:[],loading:!1,error:null},createUser:{loading:!1,error:null},deleteUser:{loading:!1,error:null},expireUserPassword:{loading:!1,error:null},customAttributes:{loading:!1,error:null,data:{}},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedUsersLoginIds:[],notifications:[]},Pc=Ga((e=>{var t,n;const o=Ya(Za,hc)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var n;return u(this,void 0,void 0,(function*(){var o;yield null===(n=e.init)||void 0===n?void 0:n.call(this),o=e=>{var n;null===(n=h(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(this.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(this,{attributes:!0})}))}observeAttribute(e,n){h(this,t,"f")[e]||(h(this,t,"f")[e]=[]);const o=h(this,t,"f")[e].push(n);return()=>h(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),Dc=e=>t=>{var n,o,r;const i=Ya(Za,hc,Pc)(t),s=Object.keys(e);return r=class extends i{constructor(...e){super(...e),n.add(this),this.observeAttributes(s,h(this,n,"m",o).bind(this))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return u(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),s.forEach((e=>h(this,n,"m",o).call(this,e,this.getAttribute(e))))}))}},n=new WeakSet,o=function(t,n){const o=e[t],r="function"==typeof o?o(t,n):o;r&&this.logger.error(r)},r},Lc=(e,t)=>!t&&`${e} cannot be empty`,$c=Ga((e=>{const t=Ya(Dc({"project-id":Lc}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Wc="/v1/mgmt/user/search",Fc="/v1/mgmt/user/delete/batch",qc="/v1/mgmt/user/create",Vc="/v1/mgmt/user/password/expire",zc="/v1/mgmt/user/customattributes",Hc="/v1/mgmt/role/all",Bc=e=>u(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),Kc=({httpClient:e,tenant:t})=>({search:({page:n,limit:o=1e4,customAttributes:r,statuses:i,emails:s,phones:a,text:c,sort:l}={})=>u(void 0,void 0,void 0,(function*(){const d=yield e.post(Wc,{limit:o,page:n,withTestUser:!1,customAttributes:r,statuses:i,emails:s,phones:a,text:c,sort:l},{queryParams:{tenant:t}});return yield Bc(d),(yield d.json()).users})),deleteBatch:n=>u(void 0,void 0,void 0,(function*(){const o=yield e.post(Fc,{userIds:n},{queryParams:{tenant:t}});return yield Bc(o),o.json()})),create:({loginId:n,email:o,phone:r,displayName:i,roles:s,customAttributes:a,picture:c,verifiedEmail:l,verifiedPhone:d,givenName:h,middleName:p,familyName:f,additionalLoginIds:g,sendSMS:v,sendMail:m,inviteUrl:y,invite:b})=>u(void 0,void 0,void 0,(function*(){const u=yield e.post(qc,{loginId:n,email:o,phone:r,displayName:i,givenName:h,middleName:p,familyName:f,roleNames:s,userTenants:[{tenantId:t}],customAttributes:a,picture:c,verifiedEmail:l,verifiedPhone:d,additionalLoginIds:g,sendSMS:v,sendMail:m,inviteUrl:y,invite:b},{queryParams:{tenant:t}});return yield Bc(u),(yield u.json()).user})),expirePassword:n=>u(void 0,void 0,void 0,(function*(){const o=yield e.post(Vc,{loginId:n[0]},{queryParams:{tenant:t}});return yield Bc(o),o.json()})),getCustomAttributes:()=>u(void 0,void 0,void 0,(function*(){const n=yield e.get(zc,{queryParams:{tenant:t}});return yield Bc(n),n.json()}))}),Jc=({httpClient:e,tenant:t})=>({getTenantRoles:()=>u(void 0,void 0,void 0,(function*(){const n=yield e.get(Hc,{queryParams:{tenant:t}});return yield Bc(n),n.json()}))}),Yc=Ga((e=>{var t,n,o,r;const i=Ya($c,Pc,Za,Dc({tenant:Lc}))(e);return r=class extends i{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get baseUrl(){return this.getAttribute("base-url")}get tenant(){return this.getAttribute("tenant")}get api(){return h(this,n,"f")||h(this,t,"m",o).call(this),h(this,n,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});var r;return u(this,void 0,void 0,(function*(){yield null===(r=e.init)||void 0===r?void 0:r.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{h(this,n,"f")&&h(this,t,"m",o).call(this)}))}))}},n=new WeakMap,t=new WeakSet,o=function(){this.logger.debug("creating an sdk instance"),p(this,n,((e,t)=>{const n=To(Object.assign(Object.assign({},e),{persistTokens:!0}));return{user:Kc({httpClient:n.httpClient,tenant:t}),tenant:Jc({httpClient:n.httpClient,tenant:t})}})({projectId:this.projectId,baseUrl:this.baseUrl},this.tenant),"f")},r})),Gc=Ga((e=>{const t=Ya(uc({name:"widget",initialState:Tc,reducers:{setSelectedUsersIds:(e,{payload:t})=>{e.selectedUsersLoginIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{yc.reducer(e),Oc.reducer(e),Nc.reducer(e),jc.reducer(e),_c.reducer(e),Mc.reducer(e)},asyncActions:{searchUsers:Nc.action,createUser:yc.action,deleteUsers:Oc.action,expireUserPassword:jc.action,getCustomAttributes:_c.action,getTenantRoles:Mc.action}}),hc,Za,Yc)(e);return class extends t{constructor(...e){super(...e),this.state=Tc,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Xc=e=>{const t=document.createElement("template");return t.innerHTML=e,t},Zc="undefined"!=typeof localStorage,Qc=Zc&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",el=Ga((e=>{const t=Ya(Za,$c)(e);return class extends t{fetchStaticResource(e,t){return u(this,void 0,void 0,(function*(){const n=function(e,t,n="v2-beta"){const o=new URL(Qc);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}(this.projectId,e),o=yield fetch(n,{cache:"default"});return o.ok||this.logger.error(`Error fetching URL ${n} [${o.status}]`),{body:yield o[t](),headers:Object.fromEntries(o.headers.entries())}}))}}})),tl=Ga((e=>{var t,n,o;const r=Ya(el)(e);return o=class extends r{constructor(){super(...arguments),t.set(this,void 0),n.set(this,(()=>u(this,void 0,void 0,(function*(){try{const{body:e,headers:t}=yield this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))))}get config(){return h(this,t,"f")||p(this,t,h(this,n,"f").call(this),"f"),h(this,t,"f")}},t=new WeakMap,n=new WeakMap,o})),nl="load-descope-ui",ol="base.ui.components.url",rl=Zc&&localStorage.getItem(ol)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",il=Zc&&localStorage.getItem(ol)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",sl=e=>{const t=document.createElement("script");return t.id=e,t},al=(e,t)=>e.replace("<version>",t),cl=Ga((e=>{var t,n,o,r,i,s,a,c,l,d,f,g;const v=Ya(Za,tl)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),o.set(this,Symbol("loadCbs")),l.set(this,void 0)}get descopeUi(){return h(this,l,"f")||p(this,l,h(this,t,"m",f).call(this),"f"),h(this,l,"f")}loadDescopeUiComponents(e){return u(this,void 0,void 0,(function*(){const n=Array.isArray(e)?e:(o=e,[...Array.from(o.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)]);var o;return Promise.all(n.map((e=>h(this,t,"m",d).call(this,e))))}))}},n=new WeakMap,o=new WeakMap,l=new WeakMap,t=new WeakSet,r=function(){var e;return u(this,void 0,void 0,(function*(){const t=yield this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n}))},i=function(e){const t=h(this,n,"f"),r=h(this,o,"f");e[t]=[],e[r]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[r].push(t)}})},s=function(e,n){return u(this,void 0,void 0,(function*(){this.logger.debug("Trying to load DescopeUI from a fallback URL");const o=sl("load-descope-ui-fallback-script");document.body.append(o),o.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${o.src}"`)))})),o.addEventListener("load",(()=>{n.forEach((e=>e()))})),o.src=al(il,yield h(this,t,"m",r).call(this))}))},a=function(e){e.addEventListener("error",(()=>{e[h(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),h(this,t,"m",s).call(this,e[h(this,n,"f")],e[h(this,o,"f")])})),e.addEventListener("load",(()=>{e[h(this,o,"f")].forEach((e=>e()))}))},c=function(){return u(this,void 0,void 0,(function*(){if(document.querySelector(`script#${nl}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=sl(nl);document.body.append(e),h(this,t,"m",i).call(this,e),h(this,t,"m",a).call(this,e),e.src=al(rl,yield h(this,t,"m",r).call(this))}return document.getElementById(nl)}))},d=function(e){return u(this,void 0,void 0,(function*(){if(customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=yield this.descopeUi;if(t[e])try{return yield t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)}))},f=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),h(this,t,"m",c).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),ll="content-root",dl="root",ul=Ga((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${dl}, #${ll} {\n height: 100%;\n }\n </style>\n <div id="${dl}">\n <div id="${ll}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(ll),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(dl)}})),hl=Ga((e=>{const t=Ya(el,Dc({"widget-id":Lc}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return u(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),pl=Ga((e=>{var t,n,o;return o=class extends(Ya(Za,hc,cl,ul,hl,Gc)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return u(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var o;return u(this,void 0,void 0,(function*(){yield null===(o=e.init)||void 0===o?void 0:o.call(this),yield Promise.all([h(this,t,"m",n).call(this),this.actions.searchUsers(),this.actions.getTenantRoles()]),this.onWidgetRootReady()}))}},t=new WeakSet,n=function(){return u(this,void 0,void 0,(function*(){const e=Xc(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},o})),fl=Ga((e=>{var t,n,o;return o=class extends(Ya(Za,Gc,pl)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var o;return u(this,void 0,void 0,(function*(){yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),h(this,t,"m",n).call(this),yield this.rolesMultiSelect.setData(sc(this.state).map((({name:e})=>({value:e,label:e}))))}))}},t=new WeakSet,n=function(){this.rolesMultiSelect=new tc((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger})},o})),gl=Ga((e=>{var t,n,o,r,i,s,a;return a=class extends(Ya(hc,Za)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),"debug"===e&&h(this,t,"m",i).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&h(this,t,"m",s).call(this,n[0]||"Error",n[1])}init(){const e=Object.create(null,{init:{get:()=>super.init}});var n;return u(this,void 0,void 0,(function*(){yield null===(n=e.init)||void 0===n?void 0:n.call(this),h(this,t,"m",i).call(this)}))}},n=new WeakMap,t=new WeakSet,o=function(){var e;null===(e=h(this,n,"f"))||void 0===e||e.remove(),p(this,n,null,"f")},r=function(){return u(this,void 0,void 0,(function*(){p(this,n,document.createElement("descope-debugger"),"f"),Object.assign(h(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Ed})),document.body.appendChild(h(this,n,"f"))}))},i=function(){this.debug?h(this,t,"m",r).call(this):h(this,t,"m",o).call(this)},s=function(e,t){var o;e&&(null===(o=h(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},a})),vl=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ml=Ga((e=>{var t,n,o,r,i,s,a,c,l;const d=Ya(Dc({theme:vl}),el,hc,cl,tl,ul)(e);return l=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get theme(){var e,t;const n=this.getAttribute("theme");return"os"===n?window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light":n||"light"}init(){const e=Object.create(null,{init:{get:()=>super.init}});var n;return u(this,void 0,void 0,(function*(){yield null===(n=e.init)||void 0===n?void 0:n.call(this),h(this,t,"m",i).call(this),h(this,t,"m",s).call(this),h(this,t,"m",a).call(this),h(this,t,"m",c).call(this)}))}},n=new WeakMap,t=new WeakSet,o=function(){return u(this,void 0,void 0,(function*(){try{const{body:e}=yield this.fetchStaticResource("theme.json","json");return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},r=function(){return h(this,n,"f")||(p(this,n,h(this,t,"m",o).call(this),"f"),h(this,n,"f").then((e=>this.logger.debug("Fetched theme",e)))),h(this,n,"f")},i=function(){var e,n;return u(this,void 0,void 0,(function*(){const o=yield h(this,t,"a",r);if(!o)return;const i=document.createElement("style");i.innerText=((null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.globals)||"")+((null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.globals)||""),this.shadowRoot.appendChild(i)}))},s=function(){var e,n;return u(this,void 0,void 0,(function*(){const o=Object.assign({},yield h(this,t,"a",r));if(!o)return;const i=yield this.descopeUi;(null==i?void 0:i.componentsThemeManager)&&(i.componentsThemeManager.themes={light:null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})}))},a=function(){var e,t;return u(this,void 0,void 0,(function*(){const{projectConfig:n}=yield this.config,o=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;o&&Object.values(o).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))}))}))},c=function(){return u(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},l}));class yl extends ec{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}}const bl=Ga((e=>class extends(Ya(Za)(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{e.value=t[e.getAttribute("name")]}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value=""}))}})),wl="descope-modal";var kl;class El extends ec{constructor(){super(...arguments),kl.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}open(){var e,t;null===(e=this.beforeOpen)||void 0===e||e.call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),h(this,kl,"f")&&(null===(e=this.ele)||void 0===e||e.append(h(this,kl,"f").content.cloneNode(!0)))}setContent(e){p(this,kl,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}kl=new WeakMap;const Il=Ga((e=>{var t,n;const o=Ya(hc,ul,cl)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends El{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(wl);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(h(this,t,"f"))(n,{logger:this.logger})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return u(this,void 0,void 0,(function*(){this.loadDescopeUiComponents([wl]),yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}},t=new WeakMap,n})),Ol=Ga((e=>{var t,n,o;return o=class extends(Ya(Gc,Il,bl,Za,pl)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var o;return u(this,void 0,void 0,(function*(){yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),h(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){return u(this,void 0,void 0,(function*(){this.createUserModal=this.createModal(),this.createUserModal.setContent(Xc(yield this.fetchWidgetPage("create-user-modal.html")));new yl((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.createUserModal.close(),this.resetFormData(this.createUserModal.ele)}));const e=new yl((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});e.onClick((()=>u(this,void 0,void 0,(function*(){this.validateForm(this.createUserModal.ele)&&(this.actions.createUser(Object.assign(Object.assign({},this.getFormData(this.createUserModal.ele)),{invite:!0,verifiedEmail:!0,verifiedPhone:!0})),this.createUserModal.close(),this.resetFormData(this.createUserModal.ele))}))))}))},o})),xl=Ga((e=>{var t,n,o;return o=class extends(Ya(Za,Ol,pl)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var o;return u(this,void 0,void 0,(function*(){yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),h(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;this.createButton=new yl(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-user"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createUserModal.open()))},o}));class jl extends ec{constructor(){super(...arguments),this.nodeName="descope-text"}get ele(){return super.ele}get text(){var e;return null===(e=this.ele)||void 0===e?void 0:e.innerText}set text(e){this.ele&&(this.ele.innerText=e)}}const Cl=Ga((e=>{var t,n,o;return o=class extends(Ya(Gc,Il,Za,pl)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var o;return u(this,void 0,void 0,(function*(){yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),yield h(this,t,"m",n).call(this)}))}},t=new WeakSet,n=function(){var e;return u(this,void 0,void 0,(function*(){this.deleteUsersModal=this.createModal(),this.deleteUsersModal.setContent(Xc(yield this.fetchWidgetPage("delete-users-modal.html")));const t=new yl((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteUsersModal.close()));const n=new yl((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});n.onClick((()=>{const e=ac(this.state);this.actions.deleteUsers(e),this.deleteUsersModal.close()}));const o=new jl(null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteUsersModal.beforeOpen=()=>{const e=dc(this.state);o.text=`Delete ${e}?`}}))},o})),Sl=Ga((e=>{var t,n,o,r;return r=class extends(Ya(Za,pl,Gc,Cl)(e)){constructor(){super(...arguments),t.add(this),o.set(this,bc((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var r;return u(this,void 0,void 0,(function*(){yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),h(this,t,"m",n).call(this),this.subscribe(h(this,o,"f").bind(this),lc)}))}},o=new WeakMap,t=new WeakSet,n=function(){var e;this.deleteButton=new yl(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-users"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteUsersModal.open()}))},r}));class _l extends ec{constructor(){super(...arguments),this.nodeName="descope-text-field"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}}const Al=Ga((e=>{var t,n,o,r;return r=class extends(Ya(Za,pl,Gc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,kc((()=>{this.actions.searchUsers({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var n;return u(this,void 0,void 0,(function*(){yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),h(this,t,"m",o).call(this)}))}},n=new WeakMap,t=new WeakSet,o=function(){var e;this.searchInput=new _l(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(h(this,n,"f"))},r})),Rl="descope-notification";class Nl extends ec{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}const Ul=Ga((e=>{var t,n;const o=Ya(hc,ul,cl)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Nl{setContent(t){const n="string"==typeof t?Xc(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(Rl);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(h(this,t,"f"))(n,{logger:this.logger})}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return u(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.loadDescopeUiComponents([Rl])}))}},t=new WeakMap,n})),Ml={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="white"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="#FFDFDD"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Tl=Ga((e=>{var t,n,o,r,i;return i=class extends(Ya(Za,Gc,Ul,hc)(e)){constructor(){super(...arguments),t.add(this),r.set(this,bc((e=>{e.length&&(e.forEach((({type:e,msg:r})=>{const i=h(this,t,"m",o).call(this,e);i.setContent(h(this,t,"m",n).call(this,{type:e,msg:r})),i.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return u(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(h(this,r,"f").bind(this),rc)}))}},r=new WeakMap,t=new WeakSet,n=function({type:e,msg:t}){const n=Ml[e],o=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="white"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${o.outerHTML}`},o=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},i})),Pl=/^descope-grid-([^-]+)-column$/,Dl={text:class extends ec{constructor(){super(...arguments),this.nodeName="descope-grid-text-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}},custom:class extends ec{constructor(){super(...arguments),this.nodeName="descope-grid-custom-column"}onSortDirectionChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("direction-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}}};class Ll extends ec{constructor(){super(...arguments),this.nodeName="descope-grid"}onSelectedItemsChange(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("selected-items-changed",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("selected-items-changed",e)}}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get columns(){return this.ele?Array.from(this.ele.children).reduce(((e,t)=>{var n;const o=null===(n=Pl.exec(t.localName))||void 0===n?void 0:n[1],r=Dl[o];return r?(e.push(new r(t,{logger:this.logger})),e):e}),[]):[]}}const $l=Ga((e=>{var t,n,o,r,i;return i=class extends(Ya(Gc,Za,pl)(e)){constructor(){super(...arguments),t.add(this),o.set(this,bc((e=>{this.usersTable.data=e}))),r.set(this,kc(((e,t)=>{const n=[],{value:o}=t;if(o){const t=e.path;n.push({field:t,desc:"desc"===o})}this.actions.searchUsers({sort:n})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return u(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),h(this,t,"m",n).call(this),this.usersTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{h(this,r,"f").call(this,e.target,e.detail)}))})),h(this,o,"f").call(this,ic(this.state)),this.subscribe(h(this,o,"f").bind(this),ic)}))}},o=new WeakMap,r=new WeakMap,t=new WeakSet,n=function(){var e;this.usersTable=new Ll(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="users-table"]'),{logger:this.logger}),this.usersTable.onSelectedItemsChange((e=>{this.actions.setSelectedUsersIds(e.detail.value.map((({loginIds:e})=>e)))}))},i})),Wl=Ga((e=>class extends(Ya(gl,ml,$l,xl,Sl,Al,fl,Tl)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return u(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Fl=Ya((e=>class extends(Wl(e)){}))(HTMLElement);customElements.define("descope-user-management-widget",Fl);var ql=Object.freeze({__proto__:null,default:Fl});const Vl=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var zl,Hl,Bl,Kl,Jl,Yl,Gl,Xl,Zl,Ql;const ed=document.createElement("template");ed.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class td extends HTMLElement{constructor(){super(),zl.add(this),Hl.set(this,new Lr({messages:[]})),Bl.set(this,void 0),Kl.set(this,void 0),Jl.set(this,void 0),Yl.set(this,{resize:h(this,zl,"m",Ql).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ed.content.cloneNode(!0)),p(this,Bl,this.shadowRoot.querySelector(".debugger"),"f"),p(this,Kl,h(this,Bl,"f").querySelector(".content"),"f"),p(this,Jl,h(this,Bl,"f").querySelector(".header"),"f")}updateData(e){h(this,Hl,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=Vl(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(h(this,Bl,"f"),h(this,Jl,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",h(this,Yl,"f").resize),(e=h(this,Bl,"f")).onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight},h(this,Bl,"f").onresize=h(this,zl,"m",Zl).bind(this),h(this,Hl,"f").subscribe(h(this,zl,"m",Gl).bind(this))}disconnectedCallback(){h(this,Hl,"f").unsubscribeAll(),window.removeEventListener("resize",h(this,Yl,"f").resize)}}Hl=new WeakMap,Bl=new WeakMap,Kl=new WeakMap,Jl=new WeakMap,Yl=new WeakMap,zl=new WeakSet,Gl=function(e){h(this,zl,"m",Xl).call(this,e),h(this,zl,"m",Zl).call(this)},Xl=function(e){h(this,Kl,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Zl=function(){h(this,Kl,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Ql=function(){const[e,t]=Vl(h(this,Bl,"f"),Number.parseInt(h(this,Bl,"f").style.left,10),Number.parseInt(h(this,Bl,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});h(this,Bl,"f").style.top=`${t}px`,h(this,Bl,"f").style.left=`${e}px`},customElements.define("descope-debugger",td);var nd,od,rd,id,sd=Object.freeze({__proto__:null,default:td});function ad(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const r=n[o],i=e[r],s=t[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!ad(i,s))return!1}else if(i!==s)return!1}return!0}class cd{constructor(e={},{updateOnlyOnChange:t=!0}={}){nd.set(this,void 0),od.set(this,{}),rd.set(this,0),id.set(this,!1),this.update=e=>{const t="function"==typeof e?e(h(this,nd,"f")):e,n=Object.assign(Object.assign({},h(this,nd,"f")),t);if(!h(this,id,"f")||!ad(h(this,nd,"f"),n)){const e=h(this,nd,"f");p(this,nd,n,"f"),Object.freeze(h(this,nd,"f")),setTimeout((()=>{Object.values(h(this,od,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},p(this,nd,e,"f"),p(this,id,t,"f")}get current(){return Object.assign({},h(this,nd,"f"))}subscribe(e){return p(this,rd,h(this,rd,"f")+1,"f"),h(this,od,"f")[h(this,rd,"f")]=e,h(this,rd,"f").toString()}unsubscribe(e){const t=!!h(this,od,"f")[e];return t&&delete h(this,od,"f")[e],t}unsubscribeAll(){return p(this,od,{},"f"),!0}}nd=new WeakMap,od=new WeakMap,rd=new WeakMap,id=new WeakMap;const ld=(e,t,n,o={})=>{var r,i,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(r=o.left)&&void 0!==r?r:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(i=o.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var dd,ud,hd,pd,fd,gd,vd,md,yd,bd;const wd=document.createElement("template");wd.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class kd extends HTMLElement{constructor(){var e;super(),dd.add(this),ud.set(this,new cd({messages:[]})),hd.set(this,void 0),pd.set(this,void 0),fd.set(this,void 0),gd.set(this,{resize:h(this,dd,"m",bd).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(wd.content.cloneNode(!0)),p(this,hd,this.shadowRoot.querySelector(".debugger"),"f"),p(this,pd,h(this,hd,"f").querySelector(".content"),"f"),p(this,fd,h(this,hd,"f").querySelector(".header"),"f")}updateData(e){h(this,ud,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,r=0,i=0,s=0;function a(t){t.preventDefault(),o=i-t.clientX,r=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=ld(e,e.offsetLeft-o,e.offsetTop-r,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(h(this,hd,"f"),h(this,fd,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",h(this,gd,"f").resize),(e=h(this,hd,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},h(this,hd,"f").onresize=h(this,dd,"m",yd).bind(this),h(this,ud,"f").subscribe(h(this,dd,"m",vd).bind(this))}disconnectedCallback(){h(this,ud,"f").unsubscribeAll(),window.removeEventListener("resize",h(this,gd,"f").resize)}}ud=new WeakMap,hd=new WeakMap,pd=new WeakMap,fd=new WeakMap,gd=new WeakMap,dd=new WeakSet,vd=function(e){h(this,dd,"m",md).call(this,e),h(this,dd,"m",yd).call(this)},md=function(e){h(this,pd,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},yd=function(){h(this,pd,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,r=n.clientHeight>20;o||r?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},bd=function(){const[e,t]=ld(h(this,hd,"f"),Number.parseInt(h(this,hd,"f").style.left,10),Number.parseInt(h(this,hd,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});h(this,hd,"f").style.top=`${t}px`,h(this,hd,"f").style.left=`${e}px`},customElements.define("descope-debugger",kd);var Ed=Object.freeze({__proto__:null,default:kd});e.AuthProvider=({projectId:e,baseUrl:n="",sessionTokenViaCookie:s=!1,children:c})=>{const[l,d]=t.useState(),[u,h]=t.useState(),[p,f]=t.useState(!1),[g,v]=t.useState(!1),m=(({projectId:e,baseUrl:n,sessionTokenViaCookie:o})=>t.useMemo((()=>{if(e)return Do({projectId:e,baseUrl:n,sessionTokenViaCookie:o,baseHeaders:a,persistToken:!0,autoRefresh:!0})}),[e,n,o]))({projectId:e,baseUrl:n,sessionTokenViaCookie:s});t.useEffect((()=>{if(m){const e=m.onSessionTokenChange(h),t=m.onUserChange(d);return()=>{e(),t()}}}),[m]);const y=t.useRef(!1),b=t.useCallback((()=>{y.current||(y.current=!0,v(!0),i(null==m?void 0:m.refresh)().then((()=>{v(!1)})))}),[m]),w=t.useCallback((()=>{f(!0),i(m.me)().then((()=>{f(!1)}))}),[m]),k=t.useMemo((()=>({fetchUser:w,user:l,isUserLoading:p,fetchSession:b,session:u,isSessionLoading:g,isSessionFetched:y.current,projectId:e,baseUrl:n,setUser:d,setSession:h,sdk:m})),[w,l,p,b,u,g,y.current,e,n,d,h,m]);return o.default.createElement(r.Provider,{value:k},c)},e.Descope=Vo,e.SignInFlow=e=>o.default.createElement(Vo,Object.assign({},e,{flowId:"sign-in"})),e.SignUpFlow=e=>o.default.createElement(Vo,Object.assign({},e,{flowId:"sign-up"})),e.SignUpOrInFlow=e=>o.default.createElement(Vo,Object.assign({},e,{flowId:"sign-up-or-in"})),e.UserManagement=Ho,e.baseHeaders=a,e.getJwtPermissions=Wo,e.getJwtRoles=Fo,e.getRefreshToken=$o,e.getSessionToken=Lo,e.refresh=(e=$o())=>null==Po?void 0:Po.refresh(e),e.useDescope=()=>{const{sdk:e}=Bo();return t.useMemo((()=>e||new Proxy(Do({projectId:"dummy"}),Jo)),[e])},e.useSession=()=>{const{session:e,isSessionLoading:n,fetchSession:o,isSessionFetched:r}=Bo(),i=t.useRef(n);t.useMemo((()=>{i.current=n}),[n]);const s=!e&&!n;return t.useMemo((()=>{s&&!r&&(i.current=!0)}),[r]),t.useEffect((()=>{s&&o()}),[o]),{isSessionLoading:i.current,sessionToken:e,isAuthenticated:!!e}},e.useUser=()=>{const{user:e,fetchUser:n,isUserLoading:o,session:r}=Bo(),[i,s]=t.useState(!1),a=t.useRef(o),c=t.useMemo((()=>!e&&!o&&r&&!i),[n,r,i]);return t.useMemo((()=>{a.current=o}),[o]),t.useMemo((()=>{c&&(a.current=!0)}),[c]),t.useEffect((()=>{c&&(s(!0),n())}),[c]),{isUserLoading:a.current,user:e}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
3
3
|
//# sourceMappingURL=index.umd.js.map
|