@descope/react-sdk 2.28.7 → 2.28.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants.js +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +12 -12
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";const i=t.createContext(void 0),n=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)},o=e=>(...t)=>{let i;try{i=e(...t)}catch(e){console.error(e)}return i},r=()=>"undefined"!=typeof window&&!!window.descopeBridge,s={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.28.7"},a="undefined"!=typeof window;var d=function(){return d=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var o in t=arguments[i])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},d.apply(this,arguments)};function l(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}return i}function c(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))}function u(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function h(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}"function"==typeof SuppressedError&&SuppressedError;class f extends Error{}function p(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let i=t.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i})))}(t)}catch(e){return atob(t)}}function g(e,t){if("string"!=typeof e)throw new f("Invalid token specified: must be a string");t||(t={});const i=!0===t.header?0:1,n=e.split(".")[i];if("string"!=typeof n)throw new f(`Invalid token specified: missing part #${i+1}`);let o;try{o=p(n)}catch(e){throw new f(`Invalid token specified: invalid base64 for part #${i+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new f(`Invalid token specified: invalid json for part #${i+1} (${e.message})`)}}f.prototype.name="InvalidTokenError";var v={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const m="<region>",y=`https://api.${m}descope.com`,b=6e5,$="dct",w=()=>{const e={};return{headers(t){const i="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(i),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},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},C=[503,521,522,524,530],k=[100,5e3,5e3],S=e=>new Promise((t=>setTimeout(t,e))),I=e=>async(...t)=>{let i=await e(...t),n=0;for(;C.includes(i.status)&&n<k.length;)await S(k[n]),i=await e(...t),n++;n>0&&(i.retries=n);const o=await i.text();return i.text=()=>Promise.resolve(o),i.json=()=>Promise.resolve(JSON.parse(o)),i.clone=()=>i,i};let R;const x=()=>{if(R)return R;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,i=Math.floor(1e3+9e3*Math.random());return R=`${t}-${i}`,R};var O;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(O||(O={}));const E=({path:e,baseUrl:t,queryParams:i,projectId:n})=>{const o=n.slice(1,-27);t=t.replace(m,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(i){const e=Object.keys(i);e.forEach(((t,n)=>{r=`${r}${0===n?"?":""}${t}=${encodeURIComponent(i[t])}${n===e.length-1?"":"&"}`}))}return r},A=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,i])=>{e[t]="function"==typeof i?i():i})),e)),{})),N={"Content-Type":"application/json"},j=(e,t="")=>{let i=e;return t&&(i=i+":"+t),{Authorization:`Bearer ${i}`}},M=(e,t)=>{const i={"x-descope-sdk-session-id":x(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.62.0","x-descope-project-id":e};return t&&(i["x-descope-refresh-cookie-name"]=t),i},P=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var U=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:i,refreshCookieName:n,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const d=e||y,l=((e,t)=>{const i=t||fetch;return i||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(!i)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=>w().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const n=await I(i)(...t);return e[n.ok?"log":"error"](await(async e=>{const t=await e.text();return w().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(n)),n}:I(i)})(o,a),c=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:c,body:u,headers:h,queryParams:f,method:p,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:A(j(t,g),M(t,n),(null==i?void 0:i.baseHeaders)||{},P(v)?N:{},h),method:p,body:v};null!==s&&(m.credentials=s||"include");const y=await l(E({path:c,baseUrl:d,queryParams:f,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==y?void 0:y.clone()),null==r?void 0:r.transformResponse){const e=await y.json(),t=(b=(null===(o=y.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let i=0;function n(){for(;i<e.length&&/\s/.test(e.charAt(i));)i+=1;return i<e.length}function o(){const t=e.charAt(i);return"="!==t&&";"!==t&&","!==t}for(;i<e.length;){const r=i;let s,a,d=!1;for(;n();)if(","===e.charAt(i)){for(s=i,i+=1,n(),a=i;i<e.length&&o();)i+=1;if(i<e.length&&"="===e.charAt(i)){d=!0,i=a,t.push(e.substring(r,s));break}i=s+1}else i+=1;(!d||i>=e.length)&&t.push(e.substring(r,e.length))}return t}(b).map((e=>{const t=e.split(";")[0],i=t.indexOf("=");return i<1?null:[t.substring(0,i).trim(),t.substring(i+1).trim()]})).filter(Boolean))),i=Object.assign(Object.assign({},y),{json:()=>Promise.resolve(e),cookies:t});return i.clone=()=>i,r.transformResponse(i)}var b;return y};return{get:(e,{headers:t,queryParams:i,token:n}={})=>c({path:e,headers:t,queryParams:i,body:void 0,method:O.get,token:n}),post:(e,t,{headers:i,queryParams:n,token:o}={})=>c({path:e,headers:i,queryParams:n,body:t,method:O.post,token:o}),patch:(e,t,{headers:i,queryParams:n,token:o}={})=>c({path:e,headers:i,queryParams:n,body:t,method:O.patch,token:o}),put:(e,t,{headers:i,queryParams:n,token:o}={})=>c({path:e,headers:i,queryParams:n,body:t,method:O.put,token:o}),delete:(e,{headers:t,queryParams:i,token:n}={})=>c({path:e,headers:t,queryParams:i,body:void 0,method:O.delete,token:n}),hooks:r,buildUrl:(e,i)=>E({projectId:t,baseUrl:d,path:e,queryParams:i})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var i;const n=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.beforeRequest)||[]);return null==n?void 0:n.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,i)=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==i?void 0:i.clone()))))).forEach((t=>{var i;return"rejected"===t.status&&(null===(i=e.logger)||void 0===i?void 0:i.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},T=429;function W(e,t,i){var n;let o=L(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[$])===t)return(null==o?void 0:o[i])||[];o=null===(n=null==o?void 0:o.tenants)||void 0===n?void 0:n[t]}const r=null==o?void 0:o[i];return Array.isArray(r)?r:[]}function L(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return g(e)}function D(e){const{exp:t}=L(e);return(new Date).getTime()/1e3>t}function _(e){let t=L(e);const i=Object.keys(null==t?void 0:t.tenants);return Array.isArray(i)?i:[]}function F(e,t){return W(e,t,"permissions")}function q(e,t){return W(e,t,"roles")}const B=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function V(e,t){var i;const n=await e,o={code:n.status,ok:n.ok,response:n},r=await n.clone().json();return n.ok?o.data=r:(o.error=r,n.status===T&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(i=n.headers)||void 0===i?void 0:i.get("retry-after"))||0})),o}function K(e){var t;return(null===(t=L(e))||void 0===t?void 0:t[$])||""}const H=(e,t)=>(i=t)=>t=>!e(t)&&i.replace("{val}",t),z=(e,t)=>(i=t)=>t=>{const n=e.filter((e=>e(t)));return!(n.length<e.length)&&(i?i.replace("{val}",t):n.join(" OR "))},G=(...e)=>({validate:t=>(e.forEach((e=>{const i=e(t);if(i)throw new Error(i)})),!0)}),J=e=>t=>e.test(t),Z=J(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Y=J(/^\+[1-9]{1}[0-9]{3,14}$/),X=H(Z,'"{val}" is not a valid email'),Q=H(Y,'"{val}" is not a valid phone number'),ee=H((e=>e.length>=1),"Minimum length is 1");const te=H((e=>"string"==typeof e),"Input is not a string"),ie=H((e=>Array.isArray(e)),"Input is not an array"),ne=H((e=>"boolean"==typeof e),"Input is not a boolean"),oe=H((e=>void 0===e),"Input is defined"),re=z([te(),oe()],"Input is not a string or undefined"),se=z([ie(),ne()],"Input is not an array or boolean"),ae=(...e)=>t=>(...i)=>(e.forEach(((e,t)=>G(...e).validate(i[t]))),t(...i)),de=e=>[te(`"${e}" must be a string`)],le=e=>[re(`"${e}" must be string or undefined`)],ce=e=>[te(`"${e}" must be a string`),ee(`"${e}" must not be empty`)],ue=e=>[te(`"${e}" must be a string`),X()],he=e=>[te(`"${e}" must be a string`),Q()],fe=ae(ce("accessKey")),pe=e=>({exchange:fe(((t,i)=>V(e.post(v.accessKey.exchange,{loginOptions:i},{token:t}))))}),ge=(e,t,i)=>(t.forEach((t=>{const n=t.split(".");let o=n.shift(),r=e;for(;n.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=n.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=i(s)})),e),ve=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||b,b)});var me,ye;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(me||(me={})),function(e){e.email="email"}(ye||(ye={}));const be=Object.assign(Object.assign({},me),ye);var $e;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}($e||($e={}));const we=ce("loginId"),Ce=ae(ce("token")),ke=ae(we),Se=ae(ce("pendingRef")),Ie=ae(we,ue("email")),Re=e=>({verify:Ce((t=>V(e.post(v.enchantedLink.verify,{token:t})))),signIn:ke(((t,i,n={},o)=>{var{providerId:r}=n,s=l(n,["providerId"]);return V(e.post(B(v.enchantedLink.signIn,be.email),{loginId:t,URI:i,loginOptions:s,providerId:r},{token:o}))})),signUpOrIn:ke(((t,i,n={})=>{var{providerId:o}=n,r=l(n,["providerId"]);return V(e.post(B(v.enchantedLink.signUpOrIn,be.email),{loginId:t,URI:i,loginOptions:r,providerId:o}))})),signUp:ke(((t,i,n,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return V(e.post(B(v.enchantedLink.signUp,be.email),{loginId:t,URI:i,user:n,loginOptions:s,providerId:r}))})),waitForSession:Se(((t,i)=>new Promise((n=>{const{pollingIntervalMs:o,timeoutMs:r}=ve(i);let s;const a=setInterval((async()=>{const i=await e.post(v.enchantedLink.session,{pendingRef:t});i.ok&&(clearInterval(a),s&&clearTimeout(s),n(V(Promise.resolve(i))))}),o);s=setTimeout((()=>{n({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ie(((t,i,n,o,r)=>V(e.post(v.enchantedLink.update.email,Object.assign({loginId:t,email:i,URI:n},r),{token:o}))))}}),xe=ae(ce("flowId")),Oe=ae(ce("executionId"),ce("stepId"),ce("interactionId")),Ee=e=>({start:xe(((t,i,n,o,r,s,a,d=!1)=>V(e.post(v.flow.start,{flowId:t,options:i,conditionInteractionId:n,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:d})))),next:Oe(((t,i,n,o,r,s,a=!1)=>V(e.post(v.flow.next,{executionId:t,stepId:i,interactionId:n,version:o,componentsVersion:r,input:s,isCustomScreen:a}))))}),Ae=ce("loginId"),Ne=ae(ce("token")),je=ae(Ae),Me=ae(Ae,he("phone")),Pe=ae(Ae,ue("email")),Ue=Object.keys(be).filter((e=>e!==me.voice&&e!==me.im)),Te=e=>({verify:Ne((t=>V(e.post(v.magicLink.verify,{token:t})))),signIn:Ue.reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:je(((t,n,o={},r)=>{var{providerId:s}=o,a=l(o,["providerId"]);return V(e.post(B(v.magicLink.signIn,i),{loginId:t,URI:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Ue.reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:je(((t,n,o,r={})=>{var{providerId:s}=r,a=l(r,["providerId"]);return V(e.post(B(v.magicLink.signUp,i),{loginId:t,URI:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Ue.reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:je(((t,n,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return V(e.post(B(v.magicLink.signUpOrIn,i),{loginId:t,URI:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Pe(((t,i,n,o,r)=>V(e.post(v.magicLink.update.email,Object.assign({loginId:t,email:i,URI:n},r),{token:o})))),phone:Object.keys(me).filter((e=>e!==me.voice)).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Me(((t,n,o,r,s)=>V(e.post(B(v.magicLink.update.phone,i),Object.assign({loginId:t,phone:n,URI:o},s),{token:r}))))})),{})}});var We;!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"}(We||(We={}));const Le=ae(ce("code")),De=e=>({start:Object.assign(((t,i,n,o,r)=>V(e.post(v.oauth.start,n||{},{queryParams:Object.assign(Object.assign({provider:t},i&&{redirectURL:i}),r&&{loginHint:r}),token:o}))),Object.keys(We).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:(t,n,o,r)=>V(e.post(v.oauth.start,n||{},{queryParams:Object.assign(Object.assign({provider:i},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:Le((t=>V(e.post(v.oauth.exchange,{code:t})))),startNative:(t,i,n)=>V(e.post(v.oauth.startNative,{provider:t,loginOptions:i,implicit:n})),finishNative:(t,i,n,o,r)=>V(e.post(v.oauth.finishNative,{provider:t,stateId:i,user:n,code:o,idToken:r})),getOneTapClientId:t=>V(e.get(v.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,i,n,o)=>V(e.post(v.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:i,nonce:n,loginOptions:o})),exchangeOneTapIDToken:(t,i,n,o)=>V(e.post(v.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:i,nonce:n,loginOptions:o}))}),_e=ce("appId"),Fe=ae(_e),qe=e=>({connect:Fe(((t,i,n)=>{const o=null==i?void 0:i.tenantId,r=null==i?void 0:i.tenantLevel;return null==i||delete i.tenantId,null==i||delete i.tenantLevel,V(e.post(v.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:i},{token:n}))}))}),Be=ce("loginId"),Ve=ae(Be,ce("code")),Ke=ae(Be),He=ae(Be,he("phone")),ze=ae(Be,ue("email")),Ge=e=>({verify:Object.keys(be).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Ve(((t,n)=>V(e.post(B(v.otp.verify,i),{code:n,loginId:t}))))})),{}),signIn:Object.keys(be).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Ke(((t,n={},o)=>{var{providerId:r}=n,s=l(n,["providerId"]);return V(e.post(B(v.otp.signIn,i),{loginId:t,loginOptions:s,providerId:r},{token:o}))}))})),{}),signUp:Object.keys(be).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Ke(((t,n,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return V(e.post(B(v.otp.signUp,i),{loginId:t,user:n,loginOptions:s,providerId:r}))}))})),{}),signUpOrIn:Object.keys(be).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Ke(((t,n={})=>{var{providerId:o}=n,r=l(n,["providerId"]);return V(e.post(B(v.otp.signUpOrIn,i),{loginId:t,loginOptions:r,providerId:o}))}))})),{}),update:{email:ze(((t,i,n,o)=>V(e.post(v.otp.update.email,Object.assign({loginId:t,email:i},o),{token:n})))),phone:Object.keys(me).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:He(((t,n,o,r)=>V(e.post(B(v.otp.update.phone,i),Object.assign({loginId:t,phone:n},r),{token:o}))))})),{})}}),Je=ae(ce("tenant")),Ze=ae(ce("code")),Ye=e=>({start:Je(((t,i,n,o,r,s,a,d)=>V(e.post(v.saml.start,n||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},i&&{redirectURL:i}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),d&&{initiatedEmail:t})},o&&{token:o}))))),exchange:Ze((t=>V(e.post(v.saml.exchange,{code:t}))))}),Xe=ce("loginId"),Qe=ae(Xe,ce("code")),et=ae(Xe),tt=ae(Xe),it=e=>({signUp:et(((t,i)=>V(e.post(v.totp.signUp,{loginId:t,user:i})))),verify:Qe(((t,i,n,o)=>V(e.post(v.totp.verify,{loginId:t,code:i,loginOptions:n},{token:o})))),update:tt(((t,i)=>V(e.post(v.totp.update,{loginId:t},{token:i}))))}),nt=ce("loginId"),ot=ce("newPassword"),rt=ae(nt,ce("password")),st=ae(nt),at=ae(nt,ot),dt=ae(nt,ce("oldPassword"),ot),lt=e=>({signUp:rt(((t,i,n,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return V(e.post(v.password.signUp,{loginId:t,password:i,user:n,loginOptions:s,providerId:r}))})),signIn:rt(((t,i,n={})=>{var{providerId:o}=n,r=l(n,["providerId"]);return V(e.post(v.password.signIn,{loginId:t,password:i,loginOptions:r,providerId:o}))})),sendReset:st(((t,i,n)=>V(e.post(v.password.sendReset,{loginId:t,redirectUrl:i,templateOptions:n})))),update:at(((t,i,n)=>V(e.post(v.password.update,{loginId:t,newPassword:i},{token:n})))),replace:dt(((t,i,n)=>V(e.post(v.password.replace,{loginId:t,oldPassword:i,newPassword:n})))),policy:()=>V(e.get(v.password.policy))}),ct=de("loginId"),ut=ce("loginId"),ht=ce("origin"),ft=ae(ut,ht,ce("name")),pt=ae(ut,ht),gt=ae(ct,ht),vt=ae(ut,ht,le("token")),mt=ae(ce("transactionId"),ce("response")),yt=e=>({signUp:{start:ft(((t,i,n,o,r)=>V(e.post(v.webauthn.signUp.start,{user:{loginId:t,name:n},origin:i,loginOptions:r,passkeyOptions:o})))),finish:mt(((t,i)=>V(e.post(v.webauthn.signUp.finish,{transactionId:t,response:i}))))},signIn:{start:gt(((t,i,n,o,r)=>V(e.post(v.webauthn.signIn.start,{loginId:t,origin:i,loginOptions:n,passkeyOptions:r},{token:o})))),finish:mt(((t,i)=>V(e.post(v.webauthn.signIn.finish,{transactionId:t,response:i}))))},signUpOrIn:{start:pt(((t,i,n,o)=>V(e.post(v.webauthn.signUpOrIn.start,{loginId:t,origin:i,loginOptions:o,passkeyOptions:n}))))},update:{start:vt(((t,i,n,o)=>V(e.post(v.webauthn.update.start,{loginId:t,origin:i,passkeyOptions:o},{token:n})))),finish:mt(((t,i)=>V(e.post(v.webauthn.update.finish,{transactionId:t,response:i}))))}}),bt=de("loginId"),$t=ae(bt),wt=ae(ce("pendingRef")),Ct=e=>({signUpOrIn:$t(((t,i={})=>{var{providerId:n}=i,o=l(i,["providerId"]);return V(e.post(v.notp.signUpOrIn,{loginId:t,loginOptions:o,providerId:n}))})),signUp:$t(((t,i,n={})=>{var{providerId:o}=n,r=l(n,["providerId"]);return V(e.post(v.notp.signUp,{loginId:t,user:i,providerId:o,loginOptions:r}))})),signIn:$t(((t,i={},n)=>{var{providerId:o}=i,r=l(i,["providerId"]);return V(e.post(v.notp.signIn,{loginId:t,loginOptions:r,providerId:o},{token:n}))})),waitForSession:wt(((t,i)=>new Promise((n=>{const{pollingIntervalMs:o,timeoutMs:r}=ve(i);let s;const a=setInterval((async()=>{const i=await e.post(v.notp.session,{pendingRef:t});i.ok&&(clearInterval(a),s&&clearTimeout(s),n(V(Promise.resolve(i))))}),o);s=setTimeout((()=>{n({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),kt=ae(ce("token")),St=ae(le("token"));var It,Rt=ae([(It=ce("projectId"),H(((e,t)=>i=>G(...t).validate(((e,t)=>{const i=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,i)=>"."+i)).split("."),n=i.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<n;)r=r[i[o++]];return o&&o===n&&void 0!==r?r:void 0})(i,e)))("projectId",It))())])((e=>{const{projectId:t,logger:i,baseUrl:n,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return d=U({baseUrl:n,projectId:t,logger:i,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:pe(d),otp:Ge(d),magicLink:Te(d),enchantedLink:Re(d),oauth:De(d),outbound:qe(d),saml:Ye(d),totp:it(d),notp:Ct(d),webauthn:yt(d),password:lt(d),flow:Ee(d),refresh:St(((e,t,i,n)=>{const o={};i&&(o.externalToken=i);const r=n?v.tryRefresh:v.refresh;return V(d.post(r,o,{token:e,queryParams:t}))})),selectTenant:ae([te("tenantId")],[re('"token" must be string or undefined')])(((e,t)=>V(d.post(v.selectTenant,{tenant:e},{token:t})))),logout:St((e=>V(d.post(v.logout,{},{token:e})))),logoutAll:St((e=>V(d.post(v.logoutAll,{},{token:e})))),me:St((e=>V(d.get(v.me,{token:e})))),myTenants:ae([se('"tenants" must a string array or a boolean')],[re('"token" must be string or undefined')])(((e,t)=>{const i={};return"boolean"==typeof e?i.dct=e:i.ids=e,V(d.post(v.myTenants,i,{token:t}))})),history:St((e=>V(d.get(v.history,{token:e})))),isJwtExpired:kt(D),getTenants:kt(_),getJwtPermissions:kt(F),getJwtRoles:kt(q),getCurrentTenant:kt(K),httpClient:d};var d})),xt=Object.assign(Rt,{DeliveryMethods:be});
|
|
2
|
-
/*! js-cookie v3.0.5 | MIT */function Ot(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)e[n]=i[n]}return e}var Et=function e(t,i){function n(e,n,o){if("undefined"!=typeof document){"number"==typeof(o=Ot({},i,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(n,e)+r}}return Object.create({set:n,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var i=document.cookie?document.cookie.split("; "):[],n={},o=0;o<i.length;o++){var r=i[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(n[a]=t.read(s,a),e===a)break}catch(e){}}return e?n[e]:n}},remove:function(e,t){n(e,"",Ot({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Ot({},this.attributes,t))},withConverter:function(t){return e(Ot({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(i)},converter:{value:Object.freeze(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:"/"});var At={default:"endpoint"},Nt="Blocked by CSP",jt="The endpoint parameter is not a valid URL",Mt="Failed to load the JS script of the agent",Pt="9319";function Ut(e,t){var i,n,o,r,s,a=[],d=(i=function(e){var t=function(e,t,i){if(i||2===arguments.length)for(var n,o=0,r=t.length;o<r;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,n=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[i.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Nt||s===jt)i.exclude(),r=0;else if(s===Pt)i.exclude();else if(s===Mt){var a=Date.now()-e.getTime()<50,d=i.current();d&&a&&!o.has(d)&&(o.add(d),r=0),i.postpone()}else i.postpone();var l=i.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+n()-Date.now()]}]),l=d[0],c=d[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var i=new Date,n=function(t){return a.push({url:e,startedAt:i,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return n()}),n),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=c(i,e);if(!t)throw s;var n,o=t[0],r=t[1];return(n=r,new Promise((function(e){return setTimeout(e,n)}))).then((function(){return u(o)}))}))};return u(l).then((function(e){return[e,a]}))}var Tt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Wt=Tt;function Lt(e){var t;e.scriptUrlPattern;var i=e.token,n=e.apiKey,o=void 0===n?i:n,r=l(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:Tt,a=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},i=function(e,t,i,n){return e.addEventListener(t,i,n),function(){return e.removeEventListener(t,i,n)}}(document,"visibilitychange",t);return t(),[e,i]}(),c=a[0],u=a[1];return Promise.resolve().then((function(){if(!o||"string"!=typeof o)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 i=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?i(t):"<loaderVersion>"===e?i("3.11.6"):e}))}(String(e),t)}))}(s,o);return Ut(e,Dt)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Pt?new Error(Mt):e}(e)})).then((function(e){var t=e[0],i=e[1];return u(),t.load(d(d({},r),{ldi:{attempts:i,visibilityStates:c}}))}))}function Dt(e){return function(e,t,i){var n,o=document,r="securitypolicyviolation",s=function(t){var i=new URL(e,location.href),o=t.blockedURI;o!==i.href&&o!==i.protocol.slice(0,-1)&&o!==i.origin||(n=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),n)return i(n);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,i){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(jt);var n=document.createElement("script"),o=function(){var e;return null===(e=n.parentNode)||void 0===e?void 0:e.removeChild(n)},r=document.head||document.getElementsByTagName("head")[0];n.onload=function(){o(),t()},n.onerror=function(){o(),i(new Error(Mt))},n.async=!0,n.src=e,r.appendChild(n)}))}(e)}),(function(){throw new Error(Nt)})).then(_t)}function _t(){var e=window,t="__fpjs_p_l_b",i=e[t];if(function(e,t){var i,n=null===(i=Object.getOwnPropertyDescriptor)||void 0===i?void 0:i.call(Object,e,t);(null==n?void 0:n.configurable)?delete e[t]:n&&!n.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==i?void 0:i.load))throw new Error(Pt);return i}const Ft="3.2.0",qt="undefined"!=typeof window,Bt=Math.pow(2,31)-1,Vt=`https://descopecdn.com/npm/oidc-client-ts@${Ft}/dist/browser/oidc-client-ts.min.js`,Kt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Ft}/dist/browser/oidc-client-ts.min.js`,Ht=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let zt;const Gt=e=>{try{return g(e).exp}catch(e){return null}},Jt=e=>{const{refresh_expire_in:t,refresh_token:i}=e;return t?Math.floor(Date.now()/1e3)+t:Gt(i)},Zt=e=>{const{expires_in:t,expires_at:i,access_token:n}=e;return i||(t?Math.floor(Date.now()/1e3)+t:n?Gt(n):void 0)},Yt=e=>{const{access_token:t,id_token:i,refresh_token:n,refresh_expire_in:o}=e,r=l(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||t,idToken:i,refreshJwt:e.refreshJwt||n,sessionExpiration:e.sessionExpiration||Zt(e),cookieExpiration:e.cookieExpiration||Jt(e)},r)},Xt=(e,t)=>{var i;return["beforeRequest","afterRequest"].reduce(((i,n)=>{var o;return i[n]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[n])||[]).concat((null==t?void 0:t[n])||[]),i}),null!==(i=e.hooks)&&void 0!==i?i:e.hooks={}),e},Qt=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),i=(null==t?void 0:t.authInfo)||t||{};return Yt(i)},ei=()=>qt&&!!window.descopeBridge,ti=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const i=(null==e?void 0:e.path)||"";return Ht.includes(i)},ii=void 0!==zt||qt&&void 0!==window.localStorage,ni=(e,t)=>{var i,n;return null===(n=null===(i=zt||qt&&window.localStorage)||void 0===i?void 0:i.setItem)||void 0===n?void 0:n.call(i,e,t)},oi=e=>{var t,i;return null===(i=null===(t=zt||qt&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===i?void 0:i.call(t,e)},ri=e=>{var t,i;return null===(i=null===(t=zt||qt&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===i?void 0:i.call(t,e)},si=e=>{var t,i,n,o,r;return null!==(r=null!==(i=null===(t=null==zt?void 0:zt.key)||void 0===t?void 0:t.call(zt,e))&&void 0!==i?i:qt&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.key)||void 0===o?void 0:o.call(n,e)))&&void 0!==r?r:null},ai=(...e)=>{console.debug(...e)},di=(...e)=>{console.warn(...e)},li="DS",ci="DSR",ui="DSI",hi="DSRCN";function fi(e,t,i){if(t){const{cookieDomain:n,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=i,d=new Date(1e3*s),l=pi(n);Et.set(e,t,{path:o,domain:l?n:void 0,expires:d,sameSite:r,secure:a})}}function pi(e){const t=window.location.hostname.split("."),i=null==e?void 0:e.split(".");return t.slice(-(null==i?void 0:i.length)).join(".")===e}const gi=e=>(null==e?void 0:e.cookieName)||li,vi=e=>(null==e?void 0:e.cookieName)||ci;function mi(e="",t){return Et.get(vi(t))||oi(`${e}${ci}`)||""}function yi(e="",t){return Et.get(gi(t))||oi(`${e}${li}`)||""}function bi(e=""){return oi(`${e}${ui}`)||""}function $i(e="",t,i,n){ri(`${e}${ci}`),ri(`${e}${li}`),ri(`${e}${ui}`),ri(`${e}${hi}`);const o=gi(t);Et.remove(o,null==n?void 0:n.session);const r=vi(i);Et.remove(r,null==n?void 0:n.refresh)}const wi=(e,t,i)=>n=>{const o=Object.assign(n,{token:n.token||mi(e,t)});if(!i){const t=function(e=""){return oi(`${e}${hi}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return oi(`${e}DTD`)||""}(e);return r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r})),o},Ci=qt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",ki="vsid",Si="vrid",Ii="fp",Ri=(e=!1)=>{const t=oi(Ii);if(!t)return null;const i=JSON.parse(t);return(new Date).getTime()>i.expiry&&!e?null:i.value},xi=async(e,t=Ci)=>{try{if(Ri())return;const i=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=new URL(t);n.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Lt({apiKey:e,endpoint:[n.toString(),At],scriptUrlPattern:[r,Wt]}),a=await s,{requestId:d}=await a.get({linkedId:i}),l=((e,t)=>({[ki]:e,[Si]:t}))(i,d);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};ni(Ii,JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Oi=e=>{const t=Ri(!0);return t&&e.body&&(e.body.fpData=t),e},Ei="descopeFlowNonce",Ai="X-Descope-Flow-Nonce",Ni="/v1/flow/start",ji="/v1/flow/next",Mi=(e,t=Ei)=>`${t}${e}`,Pi=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Ui=e=>{var t;return e.path===ji&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Pi(e.body.executionId):null},Ti="dls_last_user_login_id",Wi="dls_last_user_display_name",Li=e=>ni(Ti,e),Di=()=>oi(Ti),_i=()=>oi(Wi),Fi=e=>async(...t)=>{var i;t[1]=t[1]||{};const[,n={}]=t,o=Di(),r=_i();return o&&(null!==(i=n.lastAuth)&&void 0!==i||(n.lastAuth={}),n.lastAuth.loginId=o,n.lastAuth.name=r),await e(...t)},qi="DSLI",Bi=e=>async(...t)=>{const i=await e(...t);return ri(qi),i};function Vi(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const i=e.push(t)-1;return()=>e.splice(i,1)}}}async function Ki(e){const t=function(e){var t;const i=JSON.parse(e);return i.publicKey.challenge=Yi(i.publicKey.challenge),i.publicKey.user.id=Yi(i.publicKey.user.id),null===(t=i.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Yi(e.id)})),i}(e);return i=await navigator.credentials.create(t),JSON.stringify({id:i.id,rawId:Xi(i.rawId),type:i.type,response:{attestationObject:Xi(i.response.attestationObject),clientDataJSON:Xi(i.response.clientDataJSON)}});var i}async function Hi(e){const t=Ji(e);return Zi(await navigator.credentials.get(t))}async function zi(e,t){const i=Ji(e);return i.signal=t.signal,i.mediation="conditional",Zi(await navigator.credentials.get(i))}async function Gi(e=!1){var t,i;if(!qt)return Promise.resolve(!1);if(ei()){const e=null===(i=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===i?void 0:i.webauthn;if("boolean"==typeof e)return e}const n=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return n&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():n}function Ji(e){var t;const i=JSON.parse(e);return i.publicKey.challenge=Yi(i.publicKey.challenge),null===(t=i.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Yi(e.id)})),i}function Zi(e){return JSON.stringify({id:e.id,rawId:Xi(e.rawId),type:e.type,response:{authenticatorData:Xi(e.response.authenticatorData),clientDataJSON:Xi(e.response.clientDataJSON),signature:Xi(e.response.signature),userHandle:e.response.userHandle?Xi(e.response.userHandle):void 0}})}function Yi(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Xi(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Qi,en=(Qi=e=>({async signUp(t,i,n){const o=await e.webauthn.signUp.start(t,window.location.origin,i,n);if(!o.ok)return o;const r=await Ki(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,i){const n=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,i);if(!n.ok)return n;const o=await Hi(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t,i){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,i);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await Ki(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Hi(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,i,n){const o=await e.webauthn.update.start(t,window.location.origin,i,n);if(!o.ok)return o;const r=await Ki(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Ki,get:Hi,isSupported:Gi,conditional:zi}}),(...e)=>{const t=Qi(...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 tn="/fedcm/config",nn=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function on(e,t){var i;try{await rn(e,t)}catch(e){null===(i=null==t?void 0:t.onFailed)||void 0===i||i.call(t,e)}}async function rn(e,t){var i,n;const o=await async function(e,t="google",i,n,o){const r=nn(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let i=document.getElementById("google-gsi-client-script");i||(i=document.createElement("script"),document.head.appendChild(i),i.async=!0,i.defer=!0,i.id="google-gsi-client-script",i.src="https://accounts.google.com/gsi/client"),i.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},i.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const d=a.data.clientId;return new Promise((e=>{var a,l;const c=i=>{e({provider:t,nonce:r,credential:null==i?void 0:i.credential})};s.initialize(Object.assign(Object.assign({},i),{itp_support:null===(a=null==i?void 0:i.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(l=null==i?void 0:i.use_fedcm_for_prompt)||void 0===l||l,client_id:d,callback:c,nonce:r})),s.prompt((e=>{var t,i;if(o&&(null==e?void 0:e.isDismissedMoment())){const i=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(i),void c()}if(n&&(null==e?void 0:e.isSkippedMoment())){const t=null===(i=e.getSkippedReason)||void 0===i?void 0:i.call(e);return null==n||n(t),void c()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const n=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onCodeReceived)||void 0===i||i.call(t,n.data.code)}else{const i=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onAuthenticated)||void 0===n||n.call(t,i.data)}}var sn=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const i=await Gi(),n=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:i},startOptionsVersion:1});return t[1]=n,e.flow.start(...t)}});let an;const dn=(e,t)=>new Promise(((i,n)=>{if(!e.length)return n(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return i(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return i(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{dn(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),ln=(e,t,i)=>{const n=async()=>{let n,o;return n&&o||({client:n,stateUserKey:o}=await(async(e,t,i)=>{an||(an=(async()=>{try{return require("oidc-client-ts")}catch(e){return dn([Vt,Kt],(()=>window.oidc))}})());const{OidcClient:n,WebStorageStateStore:o}=await an;if(!n)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==i?void 0:i.redirectUri)||window.location.href;let s,a,d,l;if(null==i?void 0:i.issuer){if(!i.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=i.issuer,a=i.clientId,d=`${a}_user`,l="openid"}else(null==i?void 0:i.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${i.applicationId}`,a=t,d=`${a}_user`,l="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,d=`${a}_user`,l="openid email roles descope.custom_claims offline_access");const c={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==i?void 0:i.scope)||l,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==i?void 0:i.redirectUri)&&(c.redirect_uri=i.redirectUri),{client:new n(c),stateUserKey:d}})(e,t,i)),{client:n,stateUserKey:o}},o=async(t="")=>{var i;const{client:o,stateUserKey:r}=await n(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(s)))),ni(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},i=!1)=>{var o;const{client:r}=await n(),s=await r.createSigninRequest(t),{url:a}=s;return i||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var i;const{client:o,stateUserKey:r}=await n(),s=(e=>{const t=oi(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const d=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(d)))),d},logout:async(e,t=!1)=>{const{client:i,stateUserKey:o}=await n();e||(e={}),e.id_token_hint=e.id_token_hint||bi(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await i.createSignoutRequest(e),{url:s}=r;return ri(o),t||window.location.replace(s),r}}},cn=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var i;return i=t.customStorage,zt=i,e(t)}),(e=>t=>{var{fpKey:i,fpLoad:n}=t,o=l(t,["fpKey","fpLoad"]);return qt?(i&&n&&xi(i).catch((()=>null)),e(Xt(o,{beforeRequest:Oi}))):e(o)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.50.1"},t.baseHeaders)}))),(e=>t=>{const i=Vi(),n=Vi(),o=Vi(),r=Vi(),s=e(Xt(t,{afterRequest:async(e,t)=>{if(ti(e,t))ai("Session invalidated, notifying subscribers with empty values"),n.pub(null),o.pub(null),i.pub(null),r.pub(null);else{const e=await(async e=>{const t=await Qt(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:d}=await Qt(t);s&&n.pub(s),d&&r.pub(d),(a||s)&&i.pub(a||42)}}})),a=ge(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return n.pub(null),o.pub(null),i.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:n.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>i.sub((t=>{e(!!t)}))})}),(e=>t=>{var i;const{enableFlowNonce:n=!0,nonceStoragePrefix:o=Ei}=t,r=l(t,["enableFlowNonce","nonceStoragePrefix"]);if(!n)return e(r);((e=Ei)=>{try{if(!ii)return;for(let o=0;o<(void 0,i=void 0,void 0,null!==(n=null!==(t=null==zt?void 0:zt.length)&&void 0!==t?t:qt&&(null===(i=window.localStorage)||void 0===i?void 0:i.length))&&void 0!==n?n:0);o++){const t=si(o);if(t&&t.startsWith(e)){const i=oi(t);if(i)try{JSON.parse(i).expiry<Date.now()&&ri(t)}catch(e){ri(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,i,n})(o);const s=e(Xt(r,{afterRequest:async(e,t)=>{if(e.path!==Ni&&e.path!==ji)return;const{nonce:i,executionId:n}=await(async(e,t)=>{try{const i=t.headers.get(Ai);let n=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return n||(n=Ui(e)),{nonce:i,executionId:Pi(n)}}catch(e){return{nonce:null,executionId:null}}})(e,t);i&&n&&((e,t,i,n=Ei)=>{try{const o=Mi(e,n),r=i?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:i};ni(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(n,i,e.path===Ni,o)},beforeRequest:e=>{if(e.path===ji){const t=Ui(e);if(t){const i=((e,t=Ei)=>{try{const i=Mi(e,t),n=oi(i);if(!n)return null;const o=JSON.parse(n);return o.expiry<Date.now()?(((e,t=Ei)=>{try{const i=Mi(e,t);ri(i)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,o);i&&(e.headers=e.headers||{},e.headers[Ai]=i)}}return e}}));if(null===(i=s.flow)||void 0===i?void 0:i.next){let e=Promise.resolve();const t=s.flow.next.bind(s.flow);s.flow.next=async(...i)=>{const n=e;let o;e=new Promise((e=>{o=e})),await n;try{return await t(...i)}finally{o()}}}return s}),(e=>t=>{const i=e(Xt(t,{afterRequest:async(e,t)=>{if(ti(e,t))return void ri(qi);const i=await Qt(t);(null==i?void 0:i.sessionExpiration)&&ni(qi,String(i.sessionExpiration))}}));return ge(i,["logout","logoutAll","oidc.logout"],Bi)}),(e=>t=>{var{autoRefresh:i}=t,n=l(t,["autoRefresh"]);const o=!!i,r="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!o||ei())return Object.assign(e(n),{markUserActive:()=>{di("markUserActive() called but has no effect")}});const{clearAllTimers:s,setTimer:a}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,i)=>{e.push(setTimeout(t,i))}}})();let d,c,u=null,h=!1,f=!1;r&&(ai("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),qt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&d&&new Date>d&&(ai("Expiration time passed, refreshing session"),p.refresh(mi()||c))}));const p=e(Xt(n,{afterRequest:async(e,t)=>{const{sessionJwt:i,refreshJwt:n,sessionExpiration:o,nextRefreshSeconds:r}=await Qt(t);if(ti(e,t))ai("Session invalidated, canceling all timers"),s();else if(i||o){if(d=((e,t)=>{if(t)return new Date(1e3*t);ai("Could not extract expiration time from session token, trying to decode the token");try{const t=g(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(i,o),!d)return void ai("Could not extract expiration time from session token");c=n,h=r>0;const e=((e,t)=>{let i;var n;return t>0?(i=1e3*t,ai(`Using provided nextRefreshSeconds: ${t}s`)):i=((n=e)?n.getTime()-(new Date).getTime():0)-2e4,i>Bt&&(ai(`Timeout is too large (${i}ms), setting it to ${Bt}ms`),i=Bt),i})(d,r);if(s(),e<=2e4)return void ai("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});ai(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),f=!1),a((()=>{if(qt&&"hidden"===document.visibilityState)ai("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return ai("Skipping refresh due to timer - user is idle"),void(f=!0);ai("Refreshing session due to timer"),p.refresh(mi()||n)}}),e)}}}));return Object.assign(ge(p,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const i=await e(...t);return ai("Clearing all timers"),s(),i})),{markUserActive:u?()=>{ai("markUserActive() called"),h||ai("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),f&&(ai("User became active after skipped refresh, triggering refresh"),f=!1,s(),p.refresh(mi()||c))}:()=>{di("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>t=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:n=!1}=t,o=l(t,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(o),{getLastUserLoginId:Di,getLastUserDisplayName:_i});const r=e(Xt(o,{afterRequest:async(e,t)=>{var i;const{userInfo:n,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),i=Yt((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==i?void 0:i.user)||((null==i?void 0:i.hasOwnProperty("userId"))?i:void 0),lastAuth:t.lastAuth}})(t),r=null===(i=null==n?void 0:n.loginIds)||void 0===i?void 0:i[0],s=null==n?void 0:n.name;r?(Li(r),(e=>{ni(Wi,e)})(s)):(null==o?void 0:o.loginId)&&Li(o.loginId)}}));let s=ge(r,["flow.start"],Fi);return s=ge(s,["logout","logoutAll"],(e=>t=>async(...i)=>{const n=await t(...i);return e||(ri(Ti),ri(Wi)),n})(n)),Object.assign(s,{getLastUserLoginId:Di,getLastUserDisplayName:_i})}),(e=>t=>{var{persistTokens:i,sessionTokenViaCookie:n,refreshTokenViaCookie:o,storagePrefix:r,refreshCookieName:s}=t,a=l(t,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!qt)return e(Object.assign({refreshCookieName:s},a));let d;const c=e(Xt(Object.assign({refreshCookieName:s},a),{beforeRequest:wi(r,o,s),afterRequest:async(e,t)=>{if(ti(e,t))ai("Session invalidated, clearing persisted tokens"),$i(r,n,o,d);else{const e=await Qt(t);e.cookieName?ni(`${r||""}${hi}`,e.cookieName):e.refreshJwt&&ri(`${r||""}${hi}`);const i=((e={},t=!1,i="",n=!1)=>{var o,r,s,a;const{sessionJwt:d,refreshJwt:l,trustedDeviceJwt:c}=e;let u;if(l)if(n){ri(`${i}${ci}`);const t=n.sameSite||"Strict",s=null===(o=n.secure)||void 0===o||o,a=null!==(r=n.domain)&&void 0!==r?r:e.cookieDomain,d=vi(n);s&&"https:"!==window.location.protocol&&di("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});fi(d,l,c);const h=pi(a);u=Object.assign(Object.assign({},u),{refresh:{path:c.cookiePath,domain:h?a:void 0}})}else{const e=vi(n);Et.remove(e),ni(`${i}${ci}`,l)}if(d)if(t){const i=t.sameSite||"Strict",n=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=gi(t);n&&"https:"!==window.location.protocol&&di("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const l=Object.assign(Object.assign({},e),{cookieSameSite:i,cookieSecure:n,cookieDomain:o});fi(r,d,l);const c=pi(o);u=Object.assign(Object.assign({},u),{session:{path:l.cookiePath,domain:c?o:void 0}})}else ni(`${i}${li}`,d);return e.idToken&&ni(`${i}${ui}`,e.idToken),c&&ni(`${i}DTD`,c),u})(e,n,r,o);i&&(d=i)}}})),u=ge(c,["logout","logoutAll","oidc.logout"],((e,t,i,n)=>o=>async(...r)=>{const s=await o(...r);return $i(e,t,i,null==n?void 0:n()),s})(r,n,o,(()=>d)));return Object.assign(u,{getRefreshToken:()=>mi(r,o),getSessionToken:()=>yi(r,n),getIdToken:()=>bi(r)})}))((e=>{const t=xt(e),i=ln(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(n,o)=>{var r;if(ei())return ai(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await i.refreshToken(n),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&!oi(qi)&&!oi(Ti)&&!oi("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=yi(),a=mi();let d="";if(e.getExternalToken)try{d=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){ai("Error getting external token while refreshing",e)}return t.refresh(n,{dcs:s?"t":"f",dcr:a?"t":"f"},d,o)},logout:async n=>{if(e.oidcConfig)try{return await i.logout({id_token_hint:n}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(n)},flow:sn(t),webauthn:en(t),fedcm:(n=t,o=e.projectId,{onetap:{requestExchangeCode(e){on(n,e)},requestAuthentication(e){on(n,e)}},async oneTap(e,t,i,o,r){await rn(n,{provider:e,oneTapConfig:t,loginOptions:i,onSkipped:o,onDismissed:r})},async launch(e){var t;const i={identity:{context:e||"signin",providers:[{configURL:n.httpClient.buildUrl(o+tn),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return n.refresh(r.token)},isSupported:()=>qt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const i=n.httpClient.buildUrl(o+tn);try{const n={identity:{context:e||"signin",providers:[{configURL:i,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return!!r&&!!r.token}catch(e){return!1}}}),oidc:i});var n,o}));let un;const hn=e=>{const t=cn(Object.assign({persistTokens:a,autoRefresh:a},e));return un=t,t},fn=()=>hn({projectId:"temp pid",persistTokens:!1,autoRefresh:!1,storeLastAuthenticatedUser:!1});un=fn();const pn=()=>a?null==un?void 0:un.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),gn=()=>a?null==un?void 0:un.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),vn=o(((e=pn(),t)=>null==un?void 0:un.getJwtPermissions(e,t))),mn=o(((e=pn(),t)=>null==un?void 0:un.getJwtRoles(e,t))),yn=o(((e=pn())=>null==un?void 0:un.getCurrentTenant(e)));function bn(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const $n=e=>{const t=document.createElement("template");return t.innerHTML=e,t},wn=(e,t)=>e.length===t.length&&e.every(((e,i)=>e===t[i])),Cn=e=>{let t,i;return(...n)=>(t&&wn(t,n)||(t=n,i=e(...n)),i)},kn=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase(),Sn=e=>(t,...i)=>t.reduce(((t,n,o)=>{var r;return`${t}${n}${(null===(r=null==i?void 0:i[o])||void 0===r?void 0:r[e>1?1:0])||""}`}),""),In=(e,t=500)=>{let i;return function(...n){clearTimeout(i),i=setTimeout((()=>e.apply(this,n)),t)}},Rn=e=>{const t=Symbol((e=>{const t=e.toString();let i=0;for(let e=0;e<t.length;e++)i=(i<<5)-i+t.charCodeAt(e),i&=i;return i.toString(16)})(e));return i=>{if(i[t])return i;const n=e(i);return n[t]=!0,n}};var xn,On,En,An;function Nn(e,t){const i=Object.getOwnPropertyNames(e),n=Object.getOwnPropertyNames(t);if(i.length!==n.length)return!1;for(let n=0;n<i.length;n+=1){const o=i[n],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Nn(r,s))return!1}else if(r!==s)return!1}return!0}let jn=class{constructor(e={},{forceUpdate:t=!1}={}){xn.set(this,void 0),On.set(this,{}),En.set(this,0),An.set(this,!0),this.update=e=>{const t="function"==typeof e?e(u(this,xn,"f")):e,i=Object.assign(Object.assign({},u(this,xn,"f")),t);if(u(this,An,"f")||!Nn(u(this,xn,"f"),i)){const e=u(this,xn,"f");h(this,xn,i,"f"),Object.freeze(u(this,xn,"f")),setTimeout((()=>{Object.values(u(this,On,"f")).forEach((t=>t(i,e,((e,t)=>i=>e[i]!==t[i])(i,e))))}),0)}},h(this,xn,e,"f"),h(this,An,t,"f")}get current(){return Object.assign({},u(this,xn,"f"))}subscribe(e){return h(this,En,u(this,En,"f")+1,"f"),u(this,On,"f")[u(this,En,"f")]=e,u(this,En,"f").toString()}unsubscribe(e){const t=!!u(this,On,"f")[e];return t&&delete u(this,On,"f")[e],t}unsubscribeAll(){return h(this,On,{},"f"),!0}};xn=new WeakMap,On=new WeakMap,En=new WeakMap,An=new WeakMap;const Mn=["=","+","-","@","\t","\r"],Pn=e=>{const t=(e=>e.length>0&&Mn.includes(e[0])?`'${e}`:e)(Array.isArray(e)?e.join("; "):String(null!=e?e:""));return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t.replace(/"/g,'""')}"`:t},Un=e=>"string"==typeof e||null==e?e:JSON.stringify(e),Tn=e=>t.forwardRef(((i,n)=>{const{prop:o,attr:r,rest:s}=t.useMemo((()=>Object.entries(i).reduce(((e,[t,i])=>{const{trimmedKey:n,category:o}=(e=>{const[,t,i]=/(.*)\.(prop|attr)$/.exec(e)||[,e,"rest"];return{trimmedKey:t,category:i}})(t);return"prop"===o?e.prop.push([n,i]):"attr"===o?e.attr.push([kn(n),Un(i)]):Object.assign(e.rest,{[kn(n)]:i}),e}),{attr:[],prop:[],rest:{}})),[i]),a=t.useRef(null),d=t.useCallback((e=>{a.current=e,e&&(o.forEach((([e,t])=>{a.current[e]=t})),r.forEach((([t,i])=>{null==i?e.removeAttribute(t):e.setAttribute(t,i)})))}),[o,r,a]);return t.useImperativeHandle(n,(()=>a.current)),t.createElement(e,Object.assign({ref:d},s))})),Wn=t.lazy((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await Promise.resolve().then((function(){return Oa})).then((e=>e.default))).sdkConfigOverrides={baseHeaders:s,persistTokens:!1,hooks:{get beforeRequest(){return un.httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:Tn(t.forwardRef(((e,i)=>{var{"external-request-id":n}=e,o=l(e,["external-request-id"]);return t.useMemo((()=>{var e,t;e="x-external-rid",(t=n)?s[e]=t:delete s[e]}),[n]),t.createElement("descope-wc",Object.assign({ref:i},o))})))}))),Ln=t.forwardRef((({flowId:e,onSuccess:n,onError:o,onReady:r,logger:s,tenant:a,theme:d,nonce:l,locale:c,debug:u,client:h,form:f,telemetryKey:p,redirectUrl:g,autoFocus:v,validateOnBlur:m,restartOnError:y,errorTransformer:b,styleId:$,onScreenUpdate:w,dismissScreenErrorOnInput:C,outboundAppId:k,outboundAppScopes:S,popupOrigin:I,children:R,externalRequestId:x,themeOverride:O},E)=>{const[A,N]=t.useState(null);t.useImperativeHandle(E,(()=>A));const{projectId:j,baseUrl:M,baseStaticUrl:P,baseCdnUrl:U,storeLastAuthenticatedUser:T,keepLastAuthenticatedUserAfterLogout:W,refreshCookieName:L,customStorage:D,sdk:_}=t.useContext(i),F=t.useCallback((async e=>{await _.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),n&&n(e)}),[n]);return t.useEffect((()=>{const e=A;return null==e||e.addEventListener("success",F),o&&(null==e||e.addEventListener("error",o)),r&&(null==e||e.addEventListener("ready",r)),()=>{o&&(null==e||e.removeEventListener("error",o)),r&&(null==e||e.removeEventListener("ready",r)),null==e||e.removeEventListener("success",F)}}),[A,o,F]),t.useEffect((()=>{const e=A;return null==e||e.addEventListener("success",F),()=>{null==e||e.removeEventListener("success",F)}}),[A,F]),t.useEffect((()=>{const e=A;return o&&(null==e||e.addEventListener("error",o)),()=>{o&&(null==e||e.removeEventListener("error",o))}}),[A,o]),t.useEffect((()=>{const e=A;return r&&(null==e||e.addEventListener("ready",r)),()=>{r&&(null==e||e.removeEventListener("error",r))}}),[A,r]),t.createElement("form",null,t.createElement(t.Suspense,{fallback:null},t.createElement(Wn,{projectId:j,flowId:e,baseUrl:M,baseStaticUrl:P,baseCdnUrl:U,ref:N,telemetryKey:p,redirectUrl:g,autoFocus:v,styleId:$,validateOnBlur:m,restartOnError:y,keepLastAuthenticatedUserAfterLogout:W,tenant:a,externalRequestId:x,customStorage:D,themeOverride:O,"theme.attr":d,"nonce.attr":l,"locale.attr":c,"form.attr":f,"client.attr":h,"debug.attr":u,"outbound-app-id.attr":k,"outbound-app-scopes.attr":S,"popup-origin.attr":I,"store-last-authenticated-user.attr":T,"refreshCookieName.attr":L,"dismiss-screen-error-on-input.attr":C,"errorTransformer.prop":b,"logger.prop":s,"onScreenUpdate.prop":w,"customStorage.prop":D},R)))}));var Dn=()=>{const e=t.useContext(i);if(!e)throw Error("You can only use this hook in the context of <AuthProvider />");return e};const _n=e=>`You can only use this ${e} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`,Fn={get(e,t){if("object"==typeof e[t]&&null!==e[t])return new Proxy(e[t],Fn);if("function"==typeof e[t])return()=>{throw Error(_n("function"))};throw Error(_n("attribute"))}},qn=t.lazy((async()=>(await Promise.resolve().then((function(){return $u})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-access-key-management-widget",Object.assign({ref:i},e)))))}))),Bn=t.forwardRef((({logger:e,tenant:n,theme:o,debug:r,widgetId:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v}=t.useContext(i);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(qn,{ref:u,projectId:h,widgetId:s,tenant:n,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,"theme.attr":o,"debug.attr":r,"styleId.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),Vn=t.lazy((async()=>(await Promise.resolve().then((function(){return qu})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-applications-portal-widget",Object.assign({ref:i},e)))))}))),Kn=t.forwardRef((({logger:e,theme:n,debug:o,widgetId:r,styleId:s,onReady:a},d)=>{const[l,c]=t.useState(null);t.useImperativeHandle(d,(()=>l));const{projectId:u,baseUrl:h,baseStaticUrl:f,baseCdnUrl:p,refreshCookieName:g}=t.useContext(i);return t.useEffect((()=>{const e=l;return a&&(null==e||e.addEventListener("ready",a)),()=>{a&&(null==e||e.removeEventListener("ready",a))}}),[l,a]),t.createElement(t.Suspense,{fallback:null},t.createElement(Vn,{ref:c,projectId:u,widgetId:r,baseUrl:h,baseStaticUrl:f,baseCdnUrl:p,"theme.attr":n,"debug.attr":o,"styleId.attr":s,"refreshCookieName.attr":g,"logger.prop":e}))})),Hn=t.lazy((async()=>(await Promise.resolve().then((function(){return ch})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-audit-management-widget",Object.assign({ref:i},e)))))}))),zn=t.forwardRef((({logger:e,tenant:n,theme:o,debug:r,widgetId:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v}=t.useContext(i);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(Hn,{ref:u,projectId:h,widgetId:s,tenant:n,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,"theme.attr":o,"debug.attr":r,"styleId.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),Gn=t.lazy((async()=>(await Promise.resolve().then((function(){return qh})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-outbound-applications-widget",Object.assign({ref:i},e)))))}))),Jn=t.forwardRef((({logger:e,theme:n,debug:o,widgetId:r,styleId:s,onReady:a},d)=>{const[l,c]=t.useState(null);t.useImperativeHandle(d,(()=>l));const{projectId:u,baseUrl:h,baseStaticUrl:f,baseCdnUrl:p,refreshCookieName:g}=t.useContext(i);return t.useEffect((()=>{const e=l;return a&&(null==e||e.addEventListener("ready",a)),()=>{a&&(null==e||e.removeEventListener("ready",a))}}),[l,a]),t.createElement(t.Suspense,{fallback:null},t.createElement(Gn,{ref:c,projectId:u,widgetId:r,baseUrl:h,baseStaticUrl:f,baseCdnUrl:p,"theme.attr":n,"debug.attr":o,"styleId.attr":s,"refreshCookieName.attr":g,"logger.prop":e}))})),Zn=t.lazy((async()=>(await Promise.resolve().then((function(){return Kf})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-role-management-widget",Object.assign({ref:i},e)))))}))),Yn=t.forwardRef((({logger:e,tenant:n,theme:o,debug:r,widgetId:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v}=t.useContext(i);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(Zn,{ref:u,projectId:h,widgetId:s,tenant:n,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,"theme.attr":o,"debug.attr":r,"styleId.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),Xn=t.lazy((async()=>(await Promise.resolve().then((function(){return Tp})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-tenant-profile-widget",Object.assign({ref:i},e)))))}))),Qn=t.forwardRef((({logger:e,theme:n,debug:o,widgetId:r,styleId:s,tenant:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v}=t.useContext(i);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(Xn,{projectId:h,widgetId:r,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,styleId:s,tenant:a,ref:u,"theme.attr":n,"debug.attr":o,"styleId.attr":s,"tenant.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),eo=t.lazy((async()=>(await Promise.resolve().then((function(){return B$})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-user-management-widget",Object.assign({ref:i},e)))))}))),to=t.forwardRef((({logger:e,tenant:n,theme:o,debug:r,widgetId:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v}=t.useContext(i);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(eo,{projectId:h,widgetId:s,tenant:n,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,ref:u,"theme.attr":o,"debug.attr":r,"styleId.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),io=t.lazy((async()=>(await Promise.resolve().then((function(){return lC})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-user-profile-widget",Object.assign({ref:i},e)))))}))),no=t.forwardRef((({logger:e,theme:n,debug:o,widgetId:r,onLogout:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v,setSession:m,setUser:y,setIsAuthenticated:b}=t.useContext(i),$=t.useCallback((e=>{s&&s(e),b(!1),m(""),y(null)}),[s,m,b,y]);return t.useEffect((()=>{if(c)return c.addEventListener("logout",$),()=>c.removeEventListener("logout",$)}),[c,$]),t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(io,{projectId:h,widgetId:r,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,styleId:a,ref:u,"theme.attr":n,"debug.attr":o,"styleId.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),oo="undefined"!=typeof localStorage,ro="J151000",so="E103205",ao=oo&&localStorage.getItem("base.content.url")||"",lo="base.ui.components.url";oo&&localStorage.getItem(lo),oo&&localStorage.getItem(lo);const co="descope-login-flow",uo="code",ho="redirect_mode",fo="err",po="data-exclude-field",go="data-exclude-next",vo="dls_last_auth",mo="state_id",yo="saml_idp_state_id",bo="wsfed_idp_state_id",$o="saml_idp_username",wo="descope_idp_initiated",Co="sso_app_id",ko="custom_app_id",So="third_party_app_id",Io="third_party_app_state_id",Ro="oidc_login_hint",xo="oidc_prompt",Oo="oidc_resource",Eo="oidc_error_redirect_uri",Ao="application_scopes",No="data-type",jo="redirect",Mo="poll",Po="webauthnCreate",Uo="webauthnGet",To="nativeBridge",Wo="loadForm",Lo="submit",Do="polling",_o=["descope-multi-select-combo-box","descope-text-area"],Fo="dls_last_auth_in_flight",qo=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Bo;!function(e){e.backward="backward",e.forward="forward"}(Bo||(Bo={}));const Vo=["descope-enriched-text"];function Ko(e){return new URLSearchParams(window.location.search).get(e)}function Ho(e){if(window.history.replaceState&&Ko(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}function zo(e,t){if(!t)return;const i=+e,n=+t;return Number.isNaN(i)||Number.isNaN(n)?void 0:i>n?Bo.forward:i<n?Bo.backward:void 0}const Go=e=>{let[t="",i=""]=(Ko(co)||"").split("_");const n=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||n&&n!==e)&&(t="",i=""),{executionId:t,stepId:i,executionFlowId:n}};function Jo(){Ho(co)}const Zo=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Yo=(e,t)=>{const{executionId:i,stepId:n,executionFlowId:o}=Go(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(i||n)&&Jo();const r=Ko("t")||void 0;r&&Ho("t");const s=Ko(uo)||void 0;s&&Ho(uo);const a="popup"===Ko(ho);a&&Ho(ho);const d=Ko(fo)||void 0;d&&Ho(fo);const{redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:Ko("ra-challenge"),redirectAuthCallbackUrl:Ko("ra-callback"),redirectAuthBackupCallbackUri:Ko("ra-backup-callback"),redirectAuthInitiator:Ko("ra-initiator")},f=Ko(mo);f&&Ho(mo);const p=Ko(yo);p&&Ho(yo);const g=Ko(bo);g&&Ho(bo);const v=Ko($o);p&&Ho($o);const m=Ko(wo);m&&Ho(wo);const y=Ko(Co);y&&Ho(Co);const b=Ko(ko);b&&Ho(ko);const $=Ko(So);$&&Ho(So);const w=Ko(Io);w&&Ho(Io);const C=Ko(Ao);C&&Ho(Ao);const k=Ko(Ro);k&&Ho(Ro);const S=Ko(xo);S&&Ho(xo);const I=Ko(Eo);I&&Ho(Eo);const R=Ko(Oo);return R&&Ho(Oo),{executionId:i,stepId:n,token:r,code:s,isPopup:a,exchangeError:d,redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:f,samlIdpStateId:p,wsfedIdpStateId:g,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:y,customAppId:b,oidcLoginHint:k,oidcPrompt:S,oidcErrorRedirectUri:I,oidcResource:R,thirdPartyAppId:$,thirdPartyAppStateId:w,applicationScopes:C}}},Xo=e=>{let t,i;return Object.assign(((...n)=>{return t&&(r=n,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=n,i=e(...n)),i;var o,r}),{reset:()=>{t=void 0,i=void 0}})},Qo=(e,t,i)=>{if(!0===t||"skipFirstScreen"===t&&!i){const t=e.querySelector('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])');setTimeout((()=>{null==t||t.focus()}))}};function er(e,t,i){return new Promise(((n,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==i?n(i):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),n(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const tr=(e,{oidcIdpStateId:t,samlIdpStateId:i,wsfedIdpStateId:n,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:d,oidcErrorRedirectUri:l,oidcResource:c,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:f})=>!(!e||t||i||n||o||r||s||a||d||l||c||u||h||f),ir=e=>null==e?void 0:e.submit(),nr=(e,t)=>{const i=t.find((t=>e[t]));return i?e[i]:null},or=(e,t=100)=>{let i;return function(...n){i||e.apply(this,n),clearTimeout(i),i=setTimeout((()=>{i=null}),t)}};function rr(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const sr=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function ar(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var dr,lr,cr,ur;function hr(e,t){const i=Object.getOwnPropertyNames(e),n=Object.getOwnPropertyNames(t);if(i.length!==n.length)return!1;for(let n=0;n<i.length;n+=1){const o=i[n],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!hr(r,s))return!1}else if(r!==s)return!1}return!0}let fr=class{constructor(e={},{forceUpdate:t=!1}={}){dr.set(this,void 0),lr.set(this,{}),cr.set(this,0),ur.set(this,!0),this.update=e=>{const t="function"==typeof e?e(u(this,dr,"f")):e,i=Object.assign(Object.assign({},u(this,dr,"f")),t),n=u(this,dr,"f");h(this,dr,i,"f"),Object.freeze(u(this,dr,"f")),setTimeout((()=>{Object.values(u(this,lr,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const r=t(n),s=t(i);(u(this,ur,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s)?!hr(r,s):r!==s))&&e(s,r,((e,t)=>i=>e[i]!==t[i])(s,r))}))}),0)},h(this,dr,e,"f"),h(this,ur,t,"f")}get current(){return Object.assign({},u(this,dr,"f"))}set forceUpdate(e){h(this,ur,e,"f")}subscribe(e,t=e=>e,{forceUpdate:i=!1}={}){return h(this,cr,u(this,cr,"f")+1,"f"),u(this,lr,"f")[u(this,cr,"f")]={cb:e,selector:t,forceUpdate:i},u(this,cr,"f").toString()}unsubscribe(e){const t=!!u(this,lr,"f")[e];return t&&delete u(this,lr,"f")[e],t}unsubscribeAll(){return h(this,lr,{},"f"),!0}};dr=new WeakMap,lr=new WeakMap,cr=new WeakMap,ur=new WeakMap;const pr=["*","#","/","(",")","[","]","_","<",">","`"],gr=e=>"string"!=typeof e?e:e.replace((e=>{const t=pr.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),vr=["disabled"],mr=(e,t)=>{Object.entries(t||{}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${po}])`)).forEach((e=>{e.value=i}))}))},yr=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),br=(e,t,i)=>e.replace(/{{(.+?)}}/g,((e,n)=>i?gr(yr(t,n)):yr(t,n))),$r=(e,t,i)=>{e.querySelectorAll(`[${No}="${t}"]`).forEach((e=>{e.setAttribute("href",i)}))},wr=(e,t,i)=>{var n,o;const r=null===(n=customElements.get(t))||void 0===n?void 0:n.cssVarList.url;i&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${i})`))},Cr=(e,t,i,n)=>{var o,r;$r(e,"totp-link",null===(o=null==t?void 0:t.totp)||void 0===o?void 0:o.provisionUrl),$r(e,"notp-link",null===(r=null==t?void 0:t.notp)||void 0===r?void 0:r.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const i=(e=>Vo.includes(e))(e.localName);e.textContent=br(e.textContent,t,i);const n=e.getAttribute("href");n&&e.setAttribute("href",br(n,t))}))})(e,t),((e,t,i)=>{if(!t)return;const{componentsDynamicAttrs:n}=t,o=l(t,["componentsDynamicAttrs"]),r=Object.keys(o).reduce(((e,t)=>(e[`[name=${t}]`]=o[t],e)),{});n&&Object.keys(n).forEach((e=>{const t=n[e];if(t){const{attributes:i}=t;i&&Object.keys(i).length&&(r[e]=i)}})),Object.keys(r).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=r[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==t?void 0:t.componentsConfig,n),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=br(e.value,t)}))}))})(e,t),((e,t)=>{Object.entries(t).forEach((([t,i])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(i).forEach((([t,i])=>{vr.includes(t)&&e.setAttribute(t,i)}))}))}))})(e,i),((e,t={},i)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(n){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;case"read-only":e.setAttribute("readonly","true");break;default:null==i||i.error(`Unknown component state "${n}" for component with id "${t}"`,'Valid states are "disable", "hide", and "read-only"')}}))}))})(e,null==t?void 0:t.componentsState,n)},kr=Xo((()=>c(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const i=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)))),n=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,i=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return i?i.version:0})()>=108;return yield er(100,i,n)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let Sr;const Ir=(e,t)=>{Sr?Sr.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Rr=e=>Sr?Sr.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,xr="dls_ab_testing_id",Or={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.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,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[i,n]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=i?i:0)&&(e.abTestingKey||0)<=(null!=n?n:0)},"not-in-range":(e,t)=>{const[i,n]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==i&&void 0!==n&&!Number.isNaN(i)&&!Number.isNaN(n))||(e.abTestingKey||0)<i||(e.abTestingKey||0)>n},"devised-by":(e,t)=>{const i=Number(t);return!Number.isNaN(i)&&(e.abTestingKey||0)%i==0}}};function Er(e,t){const i={};try{Object.assign(i,JSON.parse(Rr(vo)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return i.loginId||e?i:{}}function Ar(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Ir(vo,JSON.stringify(e)))}function Nr(){try{return JSON.parse(Rr(Fo)||"{}")}catch(e){return{}}}function jr(e){try{(e=>{Sr?Sr.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(Fo)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const Mr=["error","warn","info","debug"],Pr={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},Ur=Rn((e=>{var t,i,n,o;return o=class extends e{constructor(){super(...arguments),t.add(this),i.set(this,u(this,t,"m",n).call(this,Pr))}set logger(e){h(this,i,u(this,t,"m",n).call(this,e||Pr),"f")}get logger(){return u(this,i,"f")}onLogEvent(e,t){}},i=new WeakMap,t=new WeakSet,n=function(e){return Mr.reduce(((t,i)=>(t[i]=(...t)=>{var n;this.onLogEvent(i,t),null===(n=e[i])||void 0===n||n.call(e,...t)},t)),{})},o})),Tr="undefined"!=typeof localStorage,Wr="https://static.descope.com/pages",Lr="https://static2.descope.com/pages",Dr=Tr&&localStorage.getItem("base.content.url")||"",_r=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Fr=Rn((e=>{var t,i;return i=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,i;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(i=this.shadowRoot)||void 0===i?void 0:i.isConnected)&&u(this,t,"f")&&(h(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,i})),qr=Rn((e=>{var t,i;const n=bn(Ur,Fr)(e);return i=class extends n{constructor(){super(...arguments),t.set(this,{})}async init(){var e,i,n;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i=this,n=e=>{var i;null===(i=u(this,t,"f")[e])||void 0===i||i.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(i.attributes).forEach((e=>n(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&n(e.attributeName)}))})).observe(i,{attributes:!0})}observeAttribute(e,i){u(this,t,"f")[e]||(u(this,t,"f")[e]=[]);const n=u(this,t,"f")[e].push(i);return()=>u(this,t,"f")[e].splice(n,1)}observeAttributes(e,t){const i=e.reduce(((e,i)=>(e.push(this.observeAttribute(i,t)),e)),[]);return()=>i.forEach((e=>e()))}},t=new WeakMap,i})),Br=e=>t=>{var i,n,o;const r=bn(Ur,Fr,qr)(t),s=Object.keys(e);return o=class extends r{constructor(...e){super(...e),i.add(this),this.observeAttributes(s,u(this,i,"m",n).bind(this))}async init(){var e;s.forEach((e=>u(this,i,"m",n).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},i=new WeakSet,n=function(t,i){const n=e[t],o="function"==typeof n?n(t,i):n;o&&this.logger.error(o)},o};Br.missingAttrValidator=_r;const Vr=Rn((e=>{const t=bn(Br({"project-id":_r}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Kr=Rn((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),Hr="Trying the next fallback URL...",zr=async(e,t,{logger:i}={})=>{try{return await fetch(e,t)}catch(n){return null==i||i.debug(`Network error fetching URL ${e} [${n.message}], retrying...`),fetch(e,t)}};const Gr=Rn((e=>{var t,i,n,o,r,s,a;const d=bn(Ur,Vr,Kr)(e);return a=class extends d{constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,new Set)}async fetchStaticResource(e,i){const s=u(this,t,"m",r).call(this,e),a=Array.isArray(s)?e=>{const{baseUrl:t}=s[e];h(this,n,t,"f");for(let t=0;t<e;t++){const e=s[t].baseUrl;u(this,o,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:i,onSuccess:n}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await zr(r.toString(),t,{logger:i});if(o.ok)return null==n||n(e),null==i||i.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==i||i.debug(`${a}. ${Hr}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==i||i.debug(`${t}. ${Hr}`)}}})(s,{cache:"default"},{logger:this.logger,onSuccess:a});return{body:await e[i](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},i=new WeakMap,n=new WeakMap,o=new WeakMap,t=new WeakSet,r=function(e){const r=Dr||this.baseStaticUrl;if(r)return u(this,t,"m",s).call(this,e,r);u(this,i,"f")!==this.baseUrl&&(h(this,i,this.baseUrl,"f"),h(this,n,void 0,"f"),u(this,o,"f").clear());const a=[];if(u(this,n,"f"))a.push(u(this,t,"m",s).call(this,e,u(this,n,"f"))),u(this,n,"f")===Wr&&a.push(u(this,t,"m",s).call(this,e,Lr));else{const i=this.baseUrl+"/pages";this.baseUrl&&!u(this,o,"f").has(i)&&a.push(u(this,t,"m",s).call(this,e,i)),u(this,o,"f").has(Wr)||a.push(u(this,t,"m",s).call(this,e,Wr)),a.push(u(this,t,"m",s).call(this,e,Lr))}return 1===a.length?a[0]:a},s=function(e,t){return function({projectId:e,filename:t,assetsFolder:i="v2-beta",baseUrl:n=Wr}){const o=new URL(n);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,i,t),o.baseUrl=n,o}({projectId:this.projectId,filename:e,baseUrl:t})},a})),Jr=Rn((e=>{var t,i;const n=bn(Br({"project-id":_r}))(e);return i=class extends n{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,i){if(u(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return u(this,t,"f").set(e,i),()=>{u(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(u(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var i;if(!u(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(i=u(this,t,"f").get(e))||void 0===i?void 0:i()})))}},t=new WeakMap,i})),Zr=Rn((e=>{var t,i,n,o,r;const s=bn(Gr,Jr,Fr)(e);return r=class extends s{constructor(){super(...arguments),t.add(this),n.set(this,void 0),o.set(this,(async()=>{try{const{body:e,headers:t}=await 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")}}))}async init(){await super.init(),this.onReset("config",u(this,t,"m",i).bind(this))}get config(){return u(this,n,"f")||h(this,n,u(this,o,"f").call(this),"f"),u(this,n,"f")}},n=new WeakMap,o=new WeakMap,t=new WeakSet,i=function(){h(this,n,void 0,"f")},r})),Yr=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],Xr=e=>{let t=0;const i=e.toString();for(let e=0;e<i.length;e++){t=(t<<5)-t+i.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},Qr=(e,t,i)=>new Promise(((n,o)=>{const r=((e,t)=>{const i=document.createElement("script");return i.id=e,t&&(i.integrity=t,i.crossOrigin="anonymous"),window.DESCOPE_NONCE&&i.setAttribute("nonce",window.DESCOPE_NONCE),i})(e,i);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),n(r)},r.src=t.toString(),document.body.appendChild(r)})),es=(e,t)=>{if(t){const i=e.integrity;if(i!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${i}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,i)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{i(e)}))}))},ts=Rn((e=>{const t=bn(Ur)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,i="",n=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const n of e){const{id:e,url:o,integrity:r}=n,s=(i=e,document.querySelector(`script#${i}`));if(s)try{return await es(s,r),n}catch(e){t(n,!0)}else try{return await Qr(e,o,r),n}catch(e){t(n,!1)}}var i;throw new Error("All scripts failed to load")})(((e,t,i,n="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${i}/${n}`);const d={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${Xr(a)}`};return o&&(d.integrity=o),[...e,d]}),[]))([...n,this.baseCdnUrl,...Yr],e,t,i,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),is="base.ui.components.url",ns=Tr&&localStorage.getItem(is),os=Rn((e=>{var t,i,n,o,r,s,a;const d=bn(Ur,Zr,ts)(e);return a=class extends d{constructor(){super(...arguments),t.add(this),o.set(this,void 0)}get descopeUi(){return u(this,o,"f")||h(this,o,u(this,t,"m",s).call(this),"f"),u(this,o,"f")}async loadDescopeUiComponents(e){const i=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(i.map((e=>u(this,t,"m",r).call(this,e))))}},o=new WeakMap,t=new WeakSet,i=async function(){var e;const t=await this.config,i=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return i?this.logger.debug(`Got component version "${i}"`):this.logger.error("Could not get components version"),i},n=async function(){var e;const t=await this.config,i=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return i&&this.logger.debug("SRI hash available for components"),i},r=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await 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(", ")}"`)},s=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await u(this,t,"m",i).call(this),o=await u(this,t,"m",n).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[ns],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},a})),rs=Rn((e=>{var t,i,n;const o=bn(Fr,qr)(e);return n=class extends o{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",u(this,t,"m",i).bind(this)),u(this,t,"m",i).call(this)}},t=new WeakSet,i=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},n}));class ss{constructor(e,t,{prepend:i=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(i?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const as=Rn((e=>{const t=bn(rs)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let i;try{i=new CSSStyleSheet}catch(e){i=new ss(this.shadowRoot,this.nonce,{prepend:t})}if(e&&i.replaceSync(e),i instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const n=[...e.adoptedStyleSheets||[]];n[t?"unshift":"push"](i),e.adoptedStyleSheets=n}}return i}}})),ds="content-root",ls="root",cs=Rn((e=>{const t=bn(as)(e);return class extends t{constructor(...e){var t,i;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${ls}">\n <div id="${ds}"></div>\n </div>\n `,this.injectStyle(`\n #${ls}, #${ds} {\n height: 100%;\n }\n #${ls} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(ds),this.rootElement=null===(i=this.shadowRoot)||void 0===i?void 0:i.getElementById(ls)}}})),us="theme",hs=(e,t,i="")=>Object.entries(e).reduce(((e,[n,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(n))return t("Ignoring invalid override-css token path segment"),e;const r=i?`${i}-${n}`:n;if("object"==typeof o&&null!==o)return e+hs(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),""),fs=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ps=Rn((e=>{var t,i,n,o,r,s,a,d,l,c,f,p,g,v,m,y,b;const $=bn(Br({theme:fs}),Gr,Fr,os,Zr,cs,qr,as)(e);return b=class extends ${constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),r.set(this,void 0),v.set(this,(()=>{u(this,t,"m",m).call(this),u(this,y,"f").call(this,"os"===this.getAttribute("theme"))})),y.set(this,(e=>{var i,n,o;const r=e?"addEventListener":"removeEventListener";null===(o=null===(n=null===(i=window.matchMedia)||void 0===i?void 0:i.call(window,"(prefers-color-scheme: dark)"))||void 0===n?void 0:n[r])||void 0===o||o.call(n,"change",(()=>u(this,t,"m",m).call(this)))}))}get theme(){var e,t;const i=this.getAttribute("theme");if("os"===i){return 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"}return i||"light"}get styleId(){return this.getAttribute("style-id")||us}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),u(this,v,"f").call(this),await Promise.all([u(this,t,"m",d).call(this),u(this,t,"m",c).call(this)]),await u(this,t,"m",l).call(this),this.observeAttributes(["theme"],u(this,v,"f")),this.observeAttributes(["theme-override"],(()=>u(this,t,"m",l).call(this))),this.observeAttributes(["style-id"],(()=>{h(this,r,null,"f"),u(this,t,"m",p).call(this),u(this,t,"m",d).call(this),u(this,t,"m",c).call(this)}))}},i=new WeakMap,n=new WeakMap,r=new WeakMap,v=new WeakMap,y=new WeakMap,t=new WeakSet,o=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var i,n,o,r,s,a;const d=null===(o=null===(n=null===(i=e[t])||void 0===i?void 0:i.globals)||void 0===n?void 0:n.colors)||void 0===o?void 0:o.primary,l=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return d||l?`[data-theme="${t}"]{${hs({colors:{primary:d,secondary:l}},(e=>this.logger.error(e)))}}`:""})).join(""):""},s=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if("development"===process.env.NODE_ENV&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(is)))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(is),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const i=document.createElement("script");if(i.src=t,document.body.appendChild(i),await new Promise(((e,t)=>{i.onload=e,i.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:i}=globalThis.DescopeDev;return{light:e(t),dark:e(i)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},a=function(){return u(this,r,"f")||(h(this,r,u(this,t,"m",s).call(this),"f"),u(this,r,"f").then((e=>this.logger.debug("Fetched theme",e)))),u(this,r,"f")},d=async function(){var e,n;const o=await u(this,t,"a",a);o&&(u(this,i,"f")||h(this,i,this.injectStyle(""),"f"),u(this,i,"f").replaceSync(((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)||"")))},l=async function(){var e;this.themeOverride?(u(this,n,"f")||h(this,n,this.injectStyle(""),"f"),u(this,n,"f").replaceSync(u(this,t,"m",o).call(this))):null===(e=u(this,n,"f"))||void 0===e||e.replaceSync("")},c=async function(){var e,i;const n=await u(this,t,"a",a);if(!n)return;const o=await this.descopeUi;(null==o?void 0:o.componentsThemeManager)&&(o.componentsThemeManager.themes={light:null===(e=null==n?void 0:n.light)||void 0===e?void 0:e.components,dark:null===(i=null==n?void 0:n.dark)||void 0===i?void 0:i.components})},f=async function(){var e,t;const{projectConfig:i}=await this.config||{},n=null===(e=null==i?void 0:i.styles)||void 0===e?void 0:e[this.styleId],o=null==i?void 0:i.cssTemplate,r=n||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},p=async function(){const e=await u(this,t,"m",f).call(this);e?Object.values(e).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))})):this.logger.debug("No fonts to load")},g=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},m=function(){u(this,t,"m",p).call(this),u(this,t,"m",g).call(this)},b})),gs=(e,t="")=>Object.keys(e).reduce(((i,n)=>{var o;if(Array.isArray(e[n]))return Object.assign(Object.assign({},i),{[n]:{value:e[n].map((e=>"object"==typeof e&&null!==e?gs(e):e))}});if("object"==typeof e[n]&&null!==e[n]&&!(null===(o=e[n])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},i),gs(e[n],`${t+n}.`));const r="object"==typeof e[n]?e[n]:{value:e[n]},s=Object.assign(Object.assign({},i),{[t+n]:r,[`form.${t}${n}`]:r});return"displayName"===n?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),vs=Rn((e=>{var t,i,n,o;return o=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;u(this,t,"m",i).call(this)&&u(this,t,"m",n).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,i=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},n=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},o}));var ms,ys,bs,$s,ws,Cs,ks,Ss,Is,Rs,xs,Os,Es,As,Ns,js,Ms,Ps,Us,Ts,Ws,Ls;const Ds=bn(ps,Gr,vs,as)(HTMLElement);let _s=class extends Ds{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),ms.add(this),bs.set(this,!1),$s.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),u(this,ms,"m",Ls).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",i={})=>{this.logger.info(e,t,i)},debug:(e,t="")=>{this.logger.debug(e,t)}},ws.set(this,new fr),Cs.set(this,new fr),ks.set(this,{}),this.getComponentsContext=()=>u(this,ks,"f"),this.nextRequestStatus=new fr({isLoading:!1}),Ss.set(this,void 0),Is.set(this,{popstate:u(this,ms,"m",As).bind(this),componentsContext:u(this,ms,"m",Us).bind(this)}),Rs.set(this,void 0),this.getConfig=()=>c(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),h(this,Rs,e,"f"),u(this,ms,"m",Os).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get tenantId(){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 autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return gs(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,i])=>[e,i[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return u(this,$s,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");h(this,$s,e,"f"),(e=>{Sr=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return c(this,void 0,void 0,(function*(){var e,t;const i=yield this.getProjectConfig(),n=(null===(e=null==i?void 0:i.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=n.version)&&void 0!==t||(n.version=0),n}))}getTargetLocales(){return c(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,i,n;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=_o.includes(null!==(n=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==n?n:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const d=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===d.length)"false"!==d[0].getAttribute("auto-submit")&&d[0].click();else if(0===d.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return c(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),u(this,Cs,"f").subscribe(u(this,ms,"m",Ws).bind(this)),u(this,Cs,"f").update({isDebug:this.debug}),u(this,ms,"m",Es).call(this),yield u(this,ms,"m",Ms).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");const i=yield this.getConfig();if("isMissingConfig"in i&&i.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:n,stepId:o,token:r,code:s,isPopup:a,exchangeError:d,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:f,redirectAuthInitiator:p,ssoQueryParams:g}=Yo(this.flowId,this.loggerWrapper);window.addEventListener("popstate",u(this,Is,"f").popstate),window.addEventListener("components-context",u(this,Is,"f").componentsContext),u(this,ws,"f").subscribe(u(this,ms,"m",js).bind(this)),u(this,ws,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:n,token:r,code:s,isPopup:a,exchangeError:d,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:f,redirectAuthInitiator:p},g)),h(this,bs,!0,"f")}))}disconnectedCallback(){u(this,ws,"f").unsubscribeAll(),u(this,Cs,"f").unsubscribeAll(),u(this,ms,"m",Ts).call(this),window.removeEventListener("popstate",u(this,Is,"f").popstate),window.removeEventListener("components-context",u(this,Is,"f").componentsContext)}attributeChangedCallback(e,t,i){if(this.shadowRoot.isConnected&&u(this,bs,"f")&&t!==i&&ys.observedAttributes.includes(e)){u(this,ms,"m",Es).call(this);const n=null===t;u(this,ws,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return n||(s=null,r=null,Jo()),{[Zo(e)]:i,stepId:r,executionId:s}})),u(this,Cs,"f").update({isDebug:this.debug})}}};var Fs,qs,Bs,Vs,Ks,Hs,zs,Gs,Js,Zs,Ys,Xs,Qs,ea,ta,ia,na,oa,ra,sa,aa,da,la,ca,ua,ha,fa,pa,ga,va,ma,ya,ba,$a,wa,Ca,ka,Sa,Ia,Ra;ys=_s,bs=new WeakMap,$s=new WeakMap,ws=new WeakMap,Cs=new WeakMap,ks=new WeakMap,Ss=new WeakMap,Is=new WeakMap,Rs=new WeakMap,ms=new WeakSet,xs=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},Os=function(){u(this,ms,"m",xs).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Es=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes","theme-override"];ys.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Zo(t)])throw Error(`${t} cannot be empty`)}))},As=function(){const{stepId:e,executionId:t}=Go(this.flowId);u(this,ws,"f").update({stepId:e,executionId:t})},Ns=function(e,t){cn&&"function"==typeof cn||this.logger.error("SDK was not loaded properly",cn,JSON.stringify(cn));const i=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},ys.sdkConfigOverrides),{projectId:e,baseUrl:t});u(this,$s,"f")&&(i.customStorage=u(this,$s,"f")),this.sdk=cn(i),["start","next"].forEach((e=>{const t=function(e,t,i){return(...n)=>c(this,void 0,void 0,(function*(){let o;const r=i+1;for(let s=0;s<r;s++)try{return yield e(...n)}catch(e){o=e,s<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw o}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...i)=>c(this,void 0,void 0,(function*(){try{return yield t(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:ro,errorDescription:t.toString()}}}}))}))},js=function(e,t,i){return c(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;u(this,ms,"m",Ns).call(this,t,n)}u(this,Rs,"f").call(this,e)}))},Ms=function(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield u(this,ms,"m",Ps).call(this))}))},Ps=function(){return c(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:i="v2-beta",baseUrl:n}){const o=new URL(ao||n||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,i,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return c(this,void 0,void 0,(function*(){const i=yield fetch(e,{cache:"default"});if(!i.ok)throw Error(`Error fetching URL ${e} [${i.status}]`);return{body:yield i[t](),headers:Object.fromEntries(i.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Us=function(e){h(this,ks,Object.assign(Object.assign({},u(this,ks,"f")),e.detail),"f")},Ts=function(){var e;null===(e=u(this,Ss,"f"))||void 0===e||e.remove(),h(this,Ss,null,"f")},Ws=function(e){return c(this,arguments,void 0,(function*({isDebug:e}){e?(h(this,Ss,document.createElement("descope-debugger"),"f"),Object.assign(u(this,Ss,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return RC})),document.body.appendChild(u(this,Ss,"f"))):u(this,ms,"m",Ts).call(this)}))},Ls=function(e,t){var i;e&&this.debug&&(null===(i=u(this,Ss,"f"))||void 0===i||i.updateData({title:e,description:t}))},_s.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.65.0"}};let xa=class extends _s{static set sdkConfigOverrides(e){_s.sdkConfigOverrides=e}static get sdkConfigOverrides(){return _s.sdkConfigOverrides}constructor(){const e=new fr({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),Fs.add(this),this.stepState=new fr({}),qs.set(this,void 0),Bs.set(this,null),Vs.set(this,null),Ks.set(this,{visibilitychange:u(this,Fs,"m",Hs).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},ea.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},ia.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?u(this,Fs,"m",na).call(this,t):t()})),oa.set(this,((e,t,i,n,o=!1)=>{const r=[so,"E103202"];if(this.flowState.current.action===Mo){if(u(this,sa,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const s=Date.now(),a=o?500:2e3;h(this,qs,setTimeout((()=>c(this,void 0,void 0,(function*(){var d,l;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,t,Do,i,n,{}),h=document.hidden&&!o&&Date.now()-s>a+500;let f;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;f=yield er(e,c)}catch(d){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void u(this,oa,"f").call(this,e,t,i,n,h)}if((null===(d=null==f?void 0:f.error)||void 0===d?void 0:d.errorCode)===ro)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void u(this,oa,"f").call(this,e,t,i,n);this.logger.debug("polling - Got a response"),(null==f?void 0:f.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(f.error,null,4)),(null===(l=null==f?void 0:f.error)||void 0===l?void 0:l.errorCode)&&r.includes(f.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):u(this,oa,"f").call(this,e,t,i,n),u(this,aa,"f").call(this,f)}))),a),"f")}})),ra.set(this,(()=>{clearTimeout(u(this,qs,"f")),h(this,qs,null,"f")})),sa.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),aa.set(this,(e=>{var t,i,n,o,r,s,a,d,l,c,f,p,g;if(!(null==e?void 0:e.ok)){const a=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,d=`${null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.status} - ${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.statusText}`;u(this,Fs,"m",Ia).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:d,errorMessage:a}),this.loggerWrapper.error((null===(o=null==e?void 0:e.error)||void 0===o?void 0:o.errorDescription)||a,(null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorMessage)||d);const l=null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorCode;return void("E102004"!==l&&l!==so||!this.isRestartOnError||u(this,Fs,"m",Qs).call(this))}null===(d=null===(a=e.data)||void 0===a?void 0:a.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:i,log:n}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,n):this.loggerWrapper.info(i,n)}));const v=null===(f=null===(c=null===(l=e.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===f?void 0:f.errorText;(null===(p=e.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:y,lastAuth:b,action:$,openInNewTabUrl:w}=e.data;if($!==Mo&&u(this,ra,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Ar(Object.assign(Object.assign({},b),{lastUsedPerScreen:Nr()})),jr(this.loggerWrapper);const t=Object.assign({},y);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void u(this,Fs,"m",Ia).call(this,"success",t)}this.storeLastAuthenticatedUser&&Ar(b,!0),w&&window.open(w,"_blank");const{executionId:C,stepId:k,stepName:S,screen:I,redirect:R,webauthn:x,error:O,samlIdpResponse:E,wsFedIdpResponse:A,nativeResponse:N}=e.data,j=Date.now();$!==Mo?(this.loggerWrapper.info(`Step "${S||`#${k}`}" is ${m}`,"",{screen:I,status:m,stepId:k,stepName:S,action:$,error:O}),(null===(g=I.state)||void 0===g?void 0:g.clientScripts)&&h(this,Vs,this.loadSdkScripts(I.state.clientScripts),"f"),this.flowState.update({stepId:k,stepName:S,executionId:C,action:$,redirectTo:null==R?void 0:R.url,redirectIsPopup:null==R?void 0:R.isPopup,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,wsFedIdpResponseUrl:null==A?void 0:A.url,wsFedIdpResponseWresult:null==A?void 0:A.wresult,wsFedIdpResponseWctx:null==A?void 0:A.wctx,nativeResponseType:null==N?void 0:N.type,nativePayload:null==N?void 0:N.payload,reqTimestamp:j})):this.flowState.update({action:$,reqTimestamp:j})})),da.set(this,Xo((()=>c(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)}}))))),pa.set(this,null),ba.set(this,or(((e,t,i)=>c(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||u(this,Fs,"m",ha).call(this)){const o=null==e?void 0:e.getAttribute("id");u(this,Fs,"m",Ca).call(this,e,o,i),u(this,Fs,"m",ga).call(this,e);const r=yield u(this,Fs,"m",fa).call(this),s=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var i;const n=null===(i=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===i?void 0:i[1];return n?Object.assign(e,{[n]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const a=Object.assign(Object.assign(Object.assign({},s),r),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(o,a),this.nextRequestStatus.update({isLoading:!1}),u(this,Fs,"m",va).call(this,r)}}))))),this.flowState=e}nativeResume(e,t){var i,n,o,r,s,a;const d=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=d;if(!t){const o=new URL(d.url);t=null===(i=o.searchParams)||void 0===i?void 0:i.get(uo),e=(null===(n=o.searchParams)||void 0===n?void 0:n.get(fo))||void 0}null===(r=(o=this.nativeCallbacks).complete)||void 0===r||r.call(o,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(d.url),t=e.searchParams.get("t"),i=e.searchParams.get(co).split("_").pop();u(this,ra,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=d;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=d,{screenNext:i}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==i||i(e,t)}else null===(a=(s=this.nativeCallbacks).complete)||void 0===a||a.call(s,d)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>i=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[ar(e.id,e.resultKey)]:i},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>c(this,void 0,void 0,(function*(){var i,n,o;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}(null===(n=globalThis.descope)||void 0===n?void 0:n[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.16",`dist/${e.id}.js`));const s=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((i,n)=>{try{const n=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,i),this.loggerWrapper);if(n){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=n,this.shadowRoot.appendChild(t);const i=this.nextRequestStatus.subscribe((()=>{var o;this.loggerWrapper.debug("Stopping script",e.id),(null===(o=n.stop)||void 0===o?void 0:o.call(n))&&(this.nextRequestStatus.unsubscribe(i),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){n(e)}}))}))))),n=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,n])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t,i;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),u(this,Fs,"m",Ys).call(this),window.addEventListener("visibilitychange",u(this,Ks,"f").visibilitychange)),yield null===(i=e.init)||void 0===i?void 0:i.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),u(this,ra,"f").call(this),null===(e=u(this,Bs,"f"))||void 0===e||e.abort(),h(this,Bs,null,"f"),window.removeEventListener("visibilitychange",u(this,Ks,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return c(this,void 0,void 0,(function*(){let i;const n=rr(e),o=yield this.getTargetLocales();return o.includes(n.locale)?i=`${t}-${n.locale}.html`:o.includes(n.fallback)&&(i=`${t}-${n.fallback}.html`),i}))}getPageContent(e,t){return c(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,t,i){return c(this,void 0,void 0,(function*(){var n,o;const{projectId:r,flowId:s,tenant:a,stepId:d,executionId:f,action:p,screenId:g,screenState:v,redirectTo:m,redirectIsPopup:y,redirectUrl:b,token:$,code:w,isPopup:C,exchangeError:k,webauthnTransactionId:S,webauthnOptions:I,redirectAuthCodeChallenge:R,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:O,redirectAuthInitiator:E,locale:A,samlIdpResponseUrl:N,samlIdpResponseSamlResponse:j,samlIdpResponseRelayState:M,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:U,wsFedIdpResponseWctx:T,nativeResponseType:W,nativePayload:L,reqTimestamp:D}=e,_=l(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let F,q,B;const V=(()=>{const e=Rr(xr);if(!e){const e=Math.floor(100*Math.random()+1);return Ir(xr,e.toString()),e}return Number(e)})(),{outboundAppId:K}=this,{outboundAppScopes:H}=this,z=this.sdk.getLastUserLoginId(),G=yield this.getFlowConfig(),J=yield this.getProjectConfig(),Z=Object.entries(J.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),Y=x&&R?{callbackUrl:x,codeChallenge:R,backupCallbackUri:O}:void 0,X=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let Q={};if(!f){jr(this.loggerWrapper);const e=[...G.clientScripts||[],...G.sdkScripts||[]];if(G.conditions){let t=[];({startScreenId:F,conditionInteractionId:B,startScreenName:q,clientScripts:t,componentsConfig:Q}=((e,t)=>{const i=null==t?void 0:t.find((({key:t,operator:i,predicate:n})=>{var o;if("ELSE"===t)return!0;const r=null===(o=Or[t])||void 0===o?void 0:o[i];return!!(null==r?void 0:r(e,n))}));return i?{startScreenId:i.met.screenId,startScreenName:i.met.screenName,conditionInteractionId:i.met.interactionId,clientScripts:i.met.clientScripts,componentsConfig:i.met.componentsConfig}:{}})({loginId:z,code:w,token:$,abTestingKey:V,lastAuth:Er(z,this.loggerWrapper)},G.conditions)),e.push(...t||[])}else G.condition?({startScreenId:F,conditionInteractionId:B}=((e,t)=>{var i;const n=null===(i=Or[null==e?void 0:e.key])||void 0===i?void 0:i[e.operator];if(!n)return{};const o=n(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(G.condition,{loginId:z,code:w,token:$,abTestingKey:V,lastAuth:Er(z,this.loggerWrapper)})):(q=G.startScreenName,F=G.startScreenId);if(h(this,Vs,this.loadSdkScripts(e),"f"),G.fingerprintEnabled&&G.fingerprintKey?yield xi(G.fingerprintKey,this.baseUrl):ri(Ii),!tr(F,_)){const e=yield this.sdk.flow.start(s,Object.assign(Object.assign(Object.assign(Object.assign({tenant:a,redirectAuth:Y},_),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:Er(z,this.loggerWrapper),abTestingKey:V,locale:rr(A).locale,nativeOptions:X,outboundAppId:K,outboundAppScopes:H}),B,"",J.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),w?{exchangeCode:w,idpInitiated:!0}:{}),_.descopeIdpInitiated&&{idpInitiated:!0}),$?{token:$}:{}),_.oidcLoginHint?{externalId:_.oidcLoginHint}:{}));return u(this,aa,"f").call(this,e),void("completed"!==(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:C,code:w,exchangeError:k,isCodeChanged:i("code"),isExchangeErrorChanged:i("exchangeError")})),C&&(i("code")&&w||i("exchangeError")&&k))return void u(this,Fs,"m",Ra).call(this,f,w,k);if(f&&(i("token")&&$||i("code")&&w||i("exchangeError")&&k)){const e=yield this.sdk.flow.next(f,d,Lo,G.version,J.componentsVersion,{token:$,exchangeCode:w,exchangeError:k});return u(this,aa,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===Wo&&N&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>i(e)))){if(!j)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,i,n)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${i}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),n(o)})(N,j,M||"",ir)}if(p===Wo&&P&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>i(e)))){if(!U)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,i,n)=>{const o=document.createElement("form");o.method="POST",o.action=e;const r=(e,t)=>{const i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,i};o.appendChild(r("wa","wsignin1.0")),o.appendChild(r("wresult",t)),o.appendChild(r("wctx",i));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",o.appendChild(s),document.body.appendChild(o),n(o)})(P,U,T||"",ir)}if(p===jo&&(i("redirectTo")||i("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===E&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${y}`),y){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,i,n)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-i)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-n)/2+r,d=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),i=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&i}()?"about:blank":"",l=window.open(d,t,`width=${i},height=${n},top=${a},left=${s},scrollbars=yes,resizable=yes`);return l.location.href=e,l.focus(),l})(m,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));const i=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const i=t?this.popupOrigin:window.location.origin;if(e.origin!==i)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${i}"`);const{action:n,data:o}=e.data||{};"code"===n&&this.flowState.update({code:o.code,exchangeError:o.exchangeError})};let n;this.loggerWrapper.debug("Starting popup closed detection");const o=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(o),u(this,Fs,"m",Ia).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==n||n())}),1e3);if(t)window.addEventListener("message",i),n=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",i)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(f);e.onmessage=i,n=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),u(this,Fs,"m",Ia).call(this,"popupclosed",{});return}if(p===Po||p===Uo){if(!S||!I)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(o=u(this,Bs,"f"))||void 0===o||o.abort(),h(this,Bs,null,"f");try{e=p===Po?yield this.sdk.webauthn.helpers.create(I):yield this.sdk.webauthn.helpers.get(I)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const i=yield this.sdk.flow.next(f,d,Lo,G.version,J.componentsVersion,{transactionId:S,response:e,failure:t});u(this,aa,"f").call(this,i)}if(p===To)return this.nativeCallbacks.complete=e=>c(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(f,d,Lo,G.version,J.componentsVersion,e);u(this,aa,"f").call(this,t)})),u(this,Fs,"m",Js).call(this,W,L),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((i("action")||i("deferredPolling"))&&u(this,oa,"f").call(this,f,d,G.version,J.componentsVersion),!g&&!F)return void this.loggerWrapper.warn("No screen was found to show");const ee=F||g,te=yield this.getHtmlFilenameWithLocale(A,ee),{oidcLoginHint:ie,oidcPrompt:ne,oidcErrorRedirectUri:oe,oidcResource:re,samlIdpUsername:se}=_,ae={direction:zo(d,t.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:z,name:this.sdk.getLastUserDisplayName()||z},componentsConfig:Object.assign(Object.assign(Object.assign({},G.componentsConfig),Q),null==v?void 0:v.componentsConfig)}),htmlFilename:`${ee}.html`,htmlLocaleFilename:te,screenId:ee,stepName:e.stepName||q,samlIdpUsername:se,oidcLoginHint:ie,oidcPrompt:ne,oidcErrorRedirectUri:oe,oidcResource:re,action:p,locale:rr(A).locale},de=Er(z,this.loggerWrapper);tr(F,_)?ae.next=(e,t)=>c(this,void 0,void 0,(function*(){const i=(null==G?void 0:G.clientScripts)||[];yield u(this,Fs,"m",$a).call(this,i);const n=yield this.sdk.flow.start(s,Object.assign(Object.assign(Object.assign(Object.assign({tenant:a,redirectAuth:Y},_),{lastAuth:de,preview:this.preview,abTestingKey:V,client:this.client}),b&&{redirectUrl:b}),{locale:rr(A).locale,nativeOptions:X,outboundAppId:K,outboundAppScopes:H}),B,e,J.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),sr(t)),w&&{exchangeCode:w,idpInitiated:!0}),_.descopeIdpInitiated&&{idpInitiated:!0}),$&&{token:$}),ae.next.isCustomScreen);return u(this,aa,"f").call(this,n),n})):(i("projectId")||i("baseUrl")||i("executionId")||i("stepId"))&&(ae.next=(e,t)=>c(this,void 0,void 0,(function*(){const i=(null==v?void 0:v.clientScripts)||[];yield u(this,Fs,"m",$a).call(this,i);const n=yield this.sdk.flow.next(f,d,e,G.version,J.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),sr(t)),ae.next.isCustomScreen);return u(this,aa,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",ae.screenId),yield u(this,Fs,"m",ta).call(this,ae),this.stepState.update(ae)}))}onStepChange(e,t){return c(this,void 0,void 0,(function*(){var i,n,o;const{htmlFilename:r,htmlLocaleFilename:s,direction:a,next:d,screenState:l,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen");const f=document.createElement("template");f.innerHTML=yield this.getPageContent(r,s);const p=f.content.cloneNode(!0),g=this.loadDescopeUiComponents(f);this.sdk.webauthn.helpers.isSupported()?yield u(this,Fs,"m",ca).call(this,p,d):(e=>{e.querySelectorAll(`descope-button[${No}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(p),!e.samlIdpUsername||(null===(i=l.form)||void 0===i?void 0:i.loginId)||(null===(n=l.form)||void 0===n?void 0:n.email)||(l.form||(l.form={}),l.form.loginId=e.samlIdpUsername,l.form.email=e.samlIdpUsername),Cr(p,l,this.formConfig,this.loggerWrapper);const{geo:v}=null!==(o=yield this.getExecutionContext())&&void 0!==o?o:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([i,n])=>{Array.from(e.querySelectorAll(`[${i}="${n}"]`)).forEach((e=>{e.setAttribute(i,t||n)}))}))})(p,v),((e,t)=>{let i=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(i=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`[${t}="${n}"]`)).forEach((e=>{e.setAttribute(t,i||n)}))}))})(p,e.locale);const m=()=>c(this,void 0,void 0,(function*(){var i,n;yield g;const o=this.contentRootElement;((e,t)=>{wr(e,"descope-totp-image",t)})(o,null===(i=null==l?void 0:l.totp)||void 0===i?void 0:i.image),((e,t)=>{wr(e,"descope-notp-image",t)})(o,null===(n=null==l?void 0:l.notp)||void 0===n?void 0:n.image),((e,t,i,n)=>{i&&Object.keys(i).forEach((o=>{if(!t.querySelector(o))return void n.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(i[o]).forEach((t=>{var s;const a=i[o],d=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!d)return void n.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const l=a[t];e.style.setProperty(d,l)})):n.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(o,p,l.cssVars,this.loggerWrapper),o.replaceChildren(p);const r=!t.htmlFilename;setTimeout((()=>{u(this,Fs,"m",ma).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var i;const n=()=>{var e;const i=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=i}))};if("true"===t.getAttribute("invalid")||(null===(i=t.value)||void 0===i?void 0:i.length))return void n();const o={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",r),n(),o.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(o),((e,t)=>{mr(e,null==t?void 0:t.inputs),mr(e,null==t?void 0:t.form)})(o,l),u(this,Fs,"m",ua).call(this,{isFirstScreen:r,isCustomScreen:!1,stepName:e.stepName}),Qo(o,this.autoFocus,r),u(this,Fs,"m",ka).call(this,h)})),u(this,Fs,"m",Sa).call(this,d,h),o.querySelector(`[${No}="polling"]`)&&d(Do,{})}));a?u(this,Fs,"m",na).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${po}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}};qs=new WeakMap,Bs=new WeakMap,Vs=new WeakMap,Ks=new WeakMap,ea=new WeakMap,ia=new WeakMap,oa=new WeakMap,ra=new WeakMap,sa=new WeakMap,aa=new WeakMap,da=new WeakMap,pa=new WeakMap,ba=new WeakMap,Fs=new WeakSet,Hs=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},zs=function(e,t,i){return c(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=i,this.nativeCallbacks.screenResolve=n,u(this,Fs,"m",Js).call(this,"beforeScreen",{screen:e,context:t})}))}))},Gs=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&u(this,Fs,"m",Js).call(this,"afterScreen",{screen:e})},Js=function(e,t){u(this,Fs,"m",Ia).call(this,"bridge",{type:e,payload:t})},Zs=function({errorText:e,errorType:t}){const i=()=>{var i;let n=e;try{n=(null===(i=this.errorTransformer)||void 0===i?void 0:i.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,i="")=>{e.querySelectorAll(`[${No}="${t}"]`).forEach((e=>{e.textContent=i,e.classList[i?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",n)};this.addEventListener("screen-updated",i,{once:!0}),i()},Ys=function(){var e,t,i;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var t=e.screenState,i=l(void 0===t?{}:t,["errorText","errorType"]),n=l(e,["screenState"]);return Object.assign(Object.assign({},n),{screenState:i})})),null===(t=this.stepState)||void 0===t||t.subscribe(u(this,Fs,"m",Zs).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0}),null===(i=this.stepState)||void 0===i||i.subscribe(u(this,Fs,"m",Xs).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0})},Xs=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Qo(this.contentRootElement,this.autoFocus,!1))},Qs=function(){return c(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},ta=function(e){return c(this,void 0,void 0,(function*(){var t;const i=Object.assign(Object.assign({},this.stepState.current),e),{next:n,stepName:o}=i,r=(e=>{var t,i,n;const o=(r=e.screenState,s=(e,t)=>qo.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(0,e)))));var r,s;const{screenState:{errorText:a,errorType:d}}=e;return(a||d)&&(o.error={text:a,type:d}),e.action&&(o.action=e.action),(null===(n=null===(i=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===i?void 0:i.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data)&&(o.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o})(l(i,["next","stepName"]));let s=yield u(this,Fs,"m",zs).call(this,o,r,n);s||(s=Boolean(yield null===(t=this.onScreenUpdate)||void 0===t?void 0:t.call(this,o,r,n,this)));const a=!this.stepState.current.htmlFilename;if(u(this,ia,"f").call(this,s),n&&(n.isCustomScreen=s),u(this,ea,"f")!==s){const[e,t]=["flow","custom"].sort((()=>s?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),h(this,ea,s,"f"),s?this.stepState.unsubscribeAll():u(this,Fs,"m",Ys).call(this)}s?(this.loggerWrapper.debug("Showing a custom screen"),u(this,Fs,"m",ua).call(this,{isFirstScreen:a,isCustomScreen:s,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=s}))},na=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},la=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},ca=function(e,t){return c(this,void 0,void 0,(function*(){var i;null===(i=u(this,Bs,"f"))||void 0===i||i.abort();const n=e.querySelector('*[autocomplete="webauthn"]');if(n&&(yield kr())){const{options:e,transactionId:i}=(yield u(this,da,"f").call(this))||{};e&&i&&(u(this,Fs,"m",la).call(this,n),h(this,Bs,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,u(this,Bs,"f")).then((e=>c(this,void 0,void 0,(function*(){t(n.id,{transactionId:i,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},ua=function({isFirstScreen:e,isCustomScreen:t,stepName:i}){e&&u(this,Fs,"m",Ia).call(this,"ready",{}),t||u(this,Fs,"m",Gs).call(this,i),u(this,Fs,"m",Ia).call(this,"page-updated",{screenName:i}),u(this,Fs,"m",Ia).call(this,"screen-updated",{screenName:i})},ha=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,n;"slot"===t.localName||t.classList.contains("hidden")||(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(n=t.checkValidity)||void 0===n?void 0:n.call(t)))})),e},fa=function(){return c(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>c(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})),{})}))},ga=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),i=()=>c(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",i),e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}));const n=yield this.getFlowConfig(),o=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(o)})),n=()=>{var e;window.removeEventListener("pageshow",u(this,pa,"f")),h(this,pa,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),i())}),"f"),window.addEventListener("pageshow",u(this,pa,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&i(),this.removeEventListener("popupclosed",i),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},o=this.nextRequestStatus.subscribe((({isLoading:r})=>{r?(this.addEventListener("popupclosed",i,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(o),n())}))},va=function(e={}){var t,i;const n=nr(e,["externalId","email","phone"]),o=nr(e,["newPassword","password"]);if(n&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:n,password:o});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},ma=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>u(this,Fs,"m",ya).call(this,e)))},ya=function(e){e&&e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),n=`input-${e.id}-${i}`,o=document.createElement("slot");o.setAttribute("name",n),o.setAttribute("slot",i),e.appendChild(o),t.setAttribute("slot",n),this.appendChild(t)}))},$a=function(e){return c(this,void 0,void 0,(function*(){if(u(this,Vs,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield u(this,Vs,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),i=e.map((e=>e.id));for(const e of t)if(i.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const n=[];for(const e of t)"function"==typeof e.refresh&&n.push(e.refresh());if(n.length>0)try{yield er(5e3,Promise.all(n),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},wa=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var n;(null===(n=i.checkValidity)||void 0===n?void 0:n.call(i))&&u(this,ba,"f").call(this,i,e,t)}))}))},Ca=function(e,t,i){t&&i&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,i){try{const i=Nr();i[e]=t,Ir(Fo,JSON.stringify(i))}catch(e){null==i||i.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(i,t,this.loggerWrapper)},ka=function(e){var t;const i=null===(t=Er(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!i)return;const n=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(i)}`);n&&o&&(o.replaceWith(n),n.appendChild(o))},Sa=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${go}]), [data-type="button"]:not([${go}]`).forEach((i=>{i.onclick=()=>{u(this,ba,"f").call(this,i,e,t)}})),u(this,Fs,"m",wa).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${po}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Ia=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Ra=function(e,t,i){var n;const[o,r]=(null===(n=window.name)||void 0===n?void 0:n.split("|"))||[],s={data:{code:t,exchangeError:i},action:"code"};if("descope-wc"===o&&r){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",r);try{window.opener.postMessage(s,r)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(s),t.close()}try{window.close()}catch(e){}},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",xa);var Oa=Object.freeze({__proto__:null,default:xa});const Ea=Rn((e=>{var t,i,n,o,r,s,a;return a=class extends(bn(Fr,Ur)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),this.attributeChangedCallback=(e,i,n)=>{var o;null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,i,n),"debug"===e&&u(this,t,"m",r).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,i){var n;null===(n=super.onLogEvent)||void 0===n||n.call(this,e,i),"error"===e&&u(this,t,"m",s).call(this,i[0]||"Error",i[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),u(this,t,"m",r).call(this)}},i=new WeakMap,t=new WeakSet,n=function(){var e;null===(e=u(this,i,"f"))||void 0===e||e.remove(),h(this,i,null,"f")},o=async function(){h(this,i,document.createElement("descope-debugger"),"f"),Object.assign(u(this,i,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return FC})),document.body.appendChild(u(this,i,"f"))},r=function(){this.debug?u(this,t,"m",o).call(this):u(this,t,"m",n).call(this)},s=function(e,t){var n;e&&(null===(n=u(this,i,"f"))||void 0===n||n.updateData({title:e,description:t}))},a})),Aa="descope-modal";var Na,ja;class Ma{constructor(e,t){Na.set(this,void 0),this.nodeName="",h(this,Na,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const i=setInterval((()=>{const n="function"==typeof e?e():e;n&&(clearInterval(i),t(n))}),100);setTimeout((()=>{clearInterval(i),t(null)}),1e3)})))(u(this,Na,"f"))}get ele(){var e,t;const i="function"==typeof u(this,Na,"f")?u(this,Na,"f").call(this):u(this,Na,"f");return i?(null==i?void 0:i.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${i.localName}" `,Error()),null):i:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}}Na=new WeakMap;class Pa extends Ma{constructor(){super(...arguments),this.nodeName="descope-apps-list"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}}let Ua=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}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)}}},Ta=class extends Ma{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")}};class Wa extends Ma{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,i;e?null===(i=this.ele)||void 0===i||i.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}}let La=class extends Ta{get flowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id"))||""}get enableMode(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("enable-mode")}};const Da=/^descope-grid-([^-]+)-column$/,_a={text:class extends Ma{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 Ma{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)}}}};let Fa=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-grid",ja.set(this,void 0)}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 i;const n=null===(i=Da.exec(t.localName))||void 0===i?void 0:i[1],o=_a[n];return o?(e.push(new o(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,i;const n=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);n&&this.ele.columns&&(wn(n,this.ele.columns)||(this.ele.columns=n,null===(i=u(this,ja,"f"))||void 0===i||i.call(this,n)))}onColumnsChange(e){h(this,ja,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};ja=new WeakMap;let qa=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-link"}get ele(){return super.ele}get href(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("href")}set href(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("href",null!=e?e:"")}};var Ba;let Va=class extends Ma{constructor(){super(...arguments),Ba.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)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),u(this,Ba,"f")&&(null===(e=this.ele)||void 0===e||e.append(u(this,Ba,"f").content.cloneNode(!0)))}setContent(e){h(this,Ba,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};Ba=new WeakMap;let Ka=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-multi-line-mappings"}setData(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("data",JSON.stringify(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)}get mergedValue(){return Object.entries(this.value.filter((({tenantId:e})=>!!e)).reduce(((e,{tenantId:t,roleNames:i})=>(e[t]=[...new Set([...e[t]||[],...i])],e)),{})).map((([e,t])=>({tenantId:e,roleNames:t})))}},Ha=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}},za=class extends Ma{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()}},Ga=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-outbound-apps"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}get connectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("connect-flow-id"))||""}get disconnectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("disconnect-flow-id"))||""}onConnectClick(e){var t;const i=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("connect-clicked",i),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("connect-clicked",i)}}onDisconnectClick(e){var t;const i=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("disconnect-clicked",i),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("disconnect-clicked",i)}}},Ja=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-combo-box"}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)}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}setAllowCustomValue(e){this.ele&&this.ele.toggleAttribute("allow-custom-value",e)}},Za=class extends Ma{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)}},Ya=class extends Ma{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)}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")}},Xa=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},Qa=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,i;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(i=this.ele)||void 0===i||i.removeAttribute("fulfilled")}onUnfulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}onFulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("fulfilled-button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("fulfilled-button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}get fulfilledFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("fulfilled-flow-id")}},ed=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-trusted-devices"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",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 flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onRemoveDeviceClick(e){var t;const i=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-device-clicked",i),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-device-clicked",i)}}},td=class extends Ja{get action(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-action"))||""}get refreshTimeout(){var e;return Number(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-refresh-timeout"))||500}get shouldReload(){return"reload"===this.action}},id=class extends Ma{constructor(){super(...arguments),this.nodeName="descope-user-passkeys"}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 addPasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("add-passkey-flow-id")}get removePasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("remove-passkey-flow-id")}onAddPasskeyClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("add-passkey-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("add-passkey-clicked",e)}}onRemovePasskeyClick(e){var t;const i=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-passkey-clicked",i),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-passkey-clicked",i)}}};const nd=Rn((e=>{var t,i;const n=bn(Fr,cs,os)(e);return i=class extends n{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Va{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const i=((e={})=>{const t=document.createElement(Aa);return Object.keys(e).forEach((i=>{t.setAttribute(i,e[i])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(i),new(u(this,t,"f"))(i,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Aa]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,i})),od="descope-notification",rd=Rn((e=>{var t,i;const n=bn(Fr,cs,os)(e);return i=class extends n{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends za{setContent(t){const i="string"==typeof t?$n(t):t;e(i),super.setContent(i)}}})())}createNotification(e){const i=((e={})=>{const t=document.createElement(od);return Object.keys(e).forEach((i=>{t.setAttribute(i,e[i])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(i),new(u(this,t,"f"))(i,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([od])}},t=new WeakMap,i}));function sd(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 ad=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),dd=()=>Math.random().toString(36).substring(7).split("").join("."),ld={INIT:`@@redux/INIT${dd()}`,REPLACE:`@@redux/REPLACE${dd()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${dd()}`};function cd(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 ud(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 i=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(i){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return i}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function hd(e){let t=typeof e;return"production"!==process.env.NODE_ENV&&(t=ud(e)),t}function fd(e,t,i){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?sd(2):`Expected the root reducer to be a function. Instead, received: '${hd(e)}'`);if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error("production"===process.env.NODE_ENV?sd(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===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error("production"===process.env.NODE_ENV?sd(1):`Expected the enhancer to be a function. Instead, received: '${hd(i)}'`);return i(fd)(e,t)}let n=e,o=t,r=new Map,s=r,a=0,d=!1;function l(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function c(){if(d)throw new Error("production"===process.env.NODE_ENV?sd(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 o}function u(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?sd(4):`Expected the listener to be a function. Instead, received: '${hd(e)}'`);if(d)throw new Error("production"===process.env.NODE_ENV?sd(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 i=a++;return s.set(i,e),function(){if(t){if(d)throw new Error("production"===process.env.NODE_ENV?sd(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(i),r=null}}}function h(e){if(!cd(e))throw new Error("production"===process.env.NODE_ENV?sd(7):`Actions must be plain objects. Instead, the actual type was: '${hd(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?sd(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?sd(17):`Action "type" property must be a string. Instead, the actual type was: '${hd(e.type)}'. Value was: '${e.type}' (stringified)`);if(d)throw new Error("production"===process.env.NODE_ENV?sd(9):"Reducers may not dispatch actions.");try{d=!0,o=n(o,e)}finally{d=!1}return(r=s).forEach((e=>{e()})),e}h({type:ld.INIT});return{dispatch:h,subscribe:u,getState:c,replaceReducer:function(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?sd(10):`Expected the nextReducer to be a function. Instead, received: '${hd(e)}`);n=e,h({type:ld.REPLACE})},[ad]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error("production"===process.env.NODE_ENV?sd(11):`Expected the observer to be an object. Instead, received: '${hd(t)}'`);function i(){const e=t;e.next&&e.next(c())}i();return{unsubscribe:e(i)}},[ad](){return this}}}}}function pd(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function gd(e){const t=Object.keys(e),i={};for(let n=0;n<t.length;n++){const o=t[n];"production"!==process.env.NODE_ENV&&void 0===e[o]&&pd(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(i[o]=e[o])}const n=Object.keys(i);let o,r;"production"!==process.env.NODE_ENV&&(o={});try{!function(e){Object.keys(e).forEach((t=>{const i=e[t];if(void 0===i(void 0,{type:ld.INIT}))throw new Error("production"===process.env.NODE_ENV?sd(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===i(void 0,{type:ld.PROBE_UNKNOWN_ACTION()}))throw new Error("production"===process.env.NODE_ENV?sd(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${ld.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.`)}))}(i)}catch(e){r=e}return function(e={},t){if(r)throw r;if("production"!==process.env.NODE_ENV){const n=function(e,t,i,n){const o=Object.keys(t),r=i&&i.type===ld.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!cd(e))return`The ${r} has unexpected type of "${hd(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!n[e]));return s.forEach((e=>{n[e]=!0})),i&&i.type===ld.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,i,t,o);n&&pd(n)}let s=!1;const a={};for(let o=0;o<n.length;o++){const r=n[o],d=i[r],l=e[r],c=d(l,t);if(void 0===c){const e=t&&t.type;throw new Error("production"===process.env.NODE_ENV?sd(14):`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" 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[r]=c,s=s||c!==l}return s=s||n.length!==Object.keys(e).length,s?a:e}}function vd(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...i)=>e(t(...i))))}function md(e){return cd(e)&&"type"in e&&"string"==typeof e.type}var yd=Symbol.for("immer-nothing"),bd=Symbol.for("immer-draftable"),$d=Symbol.for("immer-state"),wd="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 Cd(e,...t){if("production"!==process.env.NODE_ENV){const i=wd[e],n="function"==typeof i?i.apply(null,t):i;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var kd=Object.getPrototypeOf;function Sd(e){return!!e&&!!e[$d]}function Id(e){return!!e&&(xd(e)||Array.isArray(e)||!!e[bd]||!!e.constructor?.[bd]||jd(e)||Md(e))}var Rd=Object.prototype.constructor.toString();function xd(e){if(!e||"object"!=typeof e)return!1;const t=kd(e);if(null===t)return!0;const i=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return i===Object||"function"==typeof i&&Function.toString.call(i)===Rd}function Od(e,t){0===Ed(e)?Object.entries(e).forEach((([i,n])=>{t(i,n,e)})):e.forEach(((i,n)=>t(n,i,e)))}function Ed(e){const t=e[$d];return t?t.type_:Array.isArray(e)?1:jd(e)?2:Md(e)?3:0}function Ad(e,t){return 2===Ed(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Nd(e,t,i){const n=Ed(e);2===n?e.set(t,i):3===n?e.add(i):e[t]=i}function jd(e){return e instanceof Map}function Md(e){return e instanceof Set}function Pd(e){return e.copy_||e.base_}function Ud(e,t){if(jd(e))return new Map(e);if(Md(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&xd(e)){if(!kd(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const i=Object.getOwnPropertyDescriptors(e);delete i[$d];let n=Reflect.ownKeys(i);for(let t=0;t<n.length;t++){const o=n[t],r=i[o];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(i[o]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[o]})}return Object.create(kd(e),i)}function Td(e,t=!1){return Ld(e)||Sd(e)||!Id(e)||(Ed(e)>1&&(e.set=e.add=e.clear=e.delete=Wd),Object.freeze(e),t&&Od(e,((e,t)=>Td(t,!0)))),e}function Wd(){Cd(2)}function Ld(e){return Object.isFrozen(e)}var Dd,_d={};function Fd(e){const t=_d[e];return t||Cd(0,e),t}function qd(){return Dd}function Bd(e,t){t&&(Fd("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Vd(e){Kd(e),e.drafts_.forEach(zd),e.drafts_=null}function Kd(e){e===Dd&&(Dd=e.parent_)}function Hd(e){return Dd={drafts_:[],parent_:Dd,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function zd(e){const t=e[$d];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Gd(e,t){t.unfinalizedDrafts_=t.drafts_.length;const i=t.drafts_[0];return void 0!==e&&e!==i?(i[$d].modified_&&(Vd(t),Cd(4)),Id(e)&&(e=Jd(t,e),t.parent_||Yd(t,e)),t.patches_&&Fd("Patches").generateReplacementPatches_(i[$d].base_,e,t.patches_,t.inversePatches_)):e=Jd(t,i,[]),Vd(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==yd?e:void 0}function Jd(e,t,i){if(Ld(t))return t;const n=t[$d];if(!n)return Od(t,((o,r)=>Zd(e,n,t,o,r,i))),t;if(n.scope_!==e)return t;if(!n.modified_)return Yd(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const t=n.copy_;let o=t,r=!1;3===n.type_&&(o=new Set(t),t.clear(),r=!0),Od(o,((o,s)=>Zd(e,n,t,o,s,i,r))),Yd(e,t,!1),i&&e.patches_&&Fd("Patches").generatePatches_(n,i,e.patches_,e.inversePatches_)}return n.copy_}function Zd(e,t,i,n,o,r,s){if("production"!==process.env.NODE_ENV&&o===i&&Cd(5),Sd(o)){const s=Jd(e,o,r&&t&&3!==t.type_&&!Ad(t.assigned_,n)?r.concat(n):void 0);if(Nd(i,n,s),!Sd(s))return;e.canAutoFreeze_=!1}else s&&i.add(o);if(Id(o)&&!Ld(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Jd(e,o),t&&t.scope_.parent_||Yd(e,o)}}function Yd(e,t,i=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Td(t,i)}var Xd={get(e,t){if(t===$d)return e;const i=Pd(e);if(!Ad(i,t))return function(e,t,i){const n=tl(t,i);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}(e,i,t);const n=i[t];return e.finalized_||!Id(n)?n:n===el(e.base_,t)?(nl(e),e.copy_[t]=ol(n,e)):n},has:(e,t)=>t in Pd(e),ownKeys:e=>Reflect.ownKeys(Pd(e)),set(e,t,i){const n=tl(Pd(e),t);if(n?.set)return n.set.call(e.draft_,i),!0;if(!e.modified_){const n=el(Pd(e),t),o=n?.[$d];if(o&&o.base_===i)return e.copy_[t]=i,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(i,n)&&(void 0!==i||Ad(e.base_,t)))return!0;nl(e),il(e)}return e.copy_[t]===i&&(void 0!==i||t in e.copy_)||Number.isNaN(i)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=i,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==el(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,nl(e),il(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const i=Pd(e),n=Reflect.getOwnPropertyDescriptor(i,t);return n?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:n.enumerable,value:i[t]}:n},defineProperty(){Cd(11)},getPrototypeOf:e=>kd(e.base_),setPrototypeOf(){Cd(12)}},Qd={};function el(e,t){const i=e[$d];return(i?Pd(i):e)[t]}function tl(e,t){if(!(t in e))return;let i=kd(e);for(;i;){const e=Object.getOwnPropertyDescriptor(i,t);if(e)return e;i=kd(i)}}function il(e){e.modified_||(e.modified_=!0,e.parent_&&il(e.parent_))}function nl(e){e.copy_||(e.copy_=Ud(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Od(Xd,((e,t)=>{Qd[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Qd.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&Cd(13),Qd.set.call(this,e,t,void 0)},Qd.set=function(e,t,i){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Cd(14),Xd.set.call(this,e[0],t,i,e[0])};function ol(e,t){const i=jd(e)?Fd("MapSet").proxyMap_(e,t):Md(e)?Fd("MapSet").proxySet_(e,t):function(e,t){const i=Array.isArray(e),n={type_:i?1:0,scope_:t?t.scope_:qd(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=n,r=Xd;i&&(o=[n],r=Qd);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return n.draft_=a,n.revoke_=s,a}(e,t);return(t?t.scope_:qd()).drafts_.push(i),i}function rl(e){return Sd(e)||Cd(10,e),sl(e)}function sl(e){if(!Id(e)||Ld(e))return e;const t=e[$d];let i;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,i=Ud(e,t.scope_.immer_.useStrictShallowCopy_)}else i=Ud(e,!0);return Od(i,((e,t)=>{Nd(i,e,sl(t))})),t&&(t.finalized_=!1),i}var al=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,i)=>{if("function"==typeof e&&"function"!=typeof t){const i=t;t=e;const n=this;return function(e=i,...o){return n.produce(e,(e=>t.call(this,e,...o)))}}let n;if("function"!=typeof t&&Cd(6),void 0!==i&&"function"!=typeof i&&Cd(7),Id(e)){const o=Hd(this),r=ol(e,void 0);let s=!0;try{n=t(r),s=!1}finally{s?Vd(o):Kd(o)}return Bd(o,i),Gd(n,o)}if(!e||"object"!=typeof e){if(n=t(e),void 0===n&&(n=e),n===yd&&(n=void 0),this.autoFreeze_&&Td(n,!0),i){const t=[],o=[];Fd("Patches").generateReplacementPatches_(e,n,t,o),i(t,o)}return n}Cd(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...i)=>this.produceWithPatches(t,(t=>e(t,...i)));let i,n;const o=this.produce(e,t,((e,t)=>{i=e,n=t}));return[o,i,n]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Id(e)||Cd(8),Sd(e)&&(e=rl(e));const t=Hd(this),i=ol(e,void 0);return i[$d].isManual_=!0,Kd(t),i}finishDraft(e,t){const i=e&&e[$d];i&&i.isManual_||Cd(9);const{scope_:n}=i;return Bd(n,t),Gd(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let i;for(i=t.length-1;i>=0;i--){const n=t[i];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}i>-1&&(t=t.slice(i+1));const n=Fd("Patches").applyPatches_;return Sd(e)?n(e,t):this.produce(e,(e=>n(e,t)))}},dl=al.produce;al.produceWithPatches.bind(al),al.setAutoFreeze.bind(al),al.setUseStrictShallowCopy.bind(al),al.applyPatches.bind(al),al.createDraft.bind(al),al.finishDraft.bind(al);var ll=(e,t,i)=>{if(1===t.length&&t[0]===i){let t=!1;try{const i={};e(i)===i&&(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})}}},cl=(e,t,i)=>{const{memoize:n,memoizeOptions:o}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=n((()=>({})),...o);if(!(a.apply(null,r)===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:i,firstInputs:r,secondInputs:s,stack:e})}},ul={inputStabilityCheck:"once",identityFunctionCheck:"once"};var hl=e=>Array.isArray(e)?e:[e];function fl(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 i=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${i}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function pl(e,t){const i=[],{length:n}=e;for(let o=0;o<n;o++)i.push(e[o].apply(null,t));return i}var gl="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},vl=0,ml=1;function yl(){return{s:vl,v:void 0,o:null,p:null}}function bl(e,t={}){let i=yl();const{resultEqualityCheck:n}=t;let o,r=0;function s(){let t=i;const{length:s}=arguments;for(let e=0,i=s;e<i;e++){const i=arguments[e];if("function"==typeof i||"object"==typeof i&&null!==i){let e=t.o;null===e&&(t.o=e=new WeakMap);const n=e.get(i);void 0===n?(t=yl(),e.set(i,t)):t=n}else{let e=t.p;null===e&&(t.p=e=new Map);const n=e.get(i);void 0===n?(t=yl(),e.set(i,t)):t=n}}const a=t;let d;if(t.s===ml)d=t.v;else if(d=e.apply(null,arguments),r++,n){const e=o?.deref?.()??o;null!=e&&n(e,d)&&(d=e,0!==r&&r--);o="object"==typeof d&&null!==d||"function"==typeof d?new gl(d):d}return a.s=ml,a.v=d,d}return s.clearCache=()=>{i=yl(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function $l(e,...t){const i="function"==typeof e?{memoize:e,memoizeOptions:t}:e,n=(...e)=>{let t,n=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=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={...i,...r},{memoize:d,memoizeOptions:l=[],argsMemoize:c=bl,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,f=hl(l),p=hl(u),g=fl(e),v=d((function(){return n++,s.apply(null,arguments)}),...f);let m=!0;const y=c((function(){o++;const e=pl(g,arguments);if(t=v.apply(null,e),"production"!==process.env.NODE_ENV){const{identityFunctionCheck:i,inputStabilityCheck:n}=((e,t)=>{const{identityFunctionCheck:i,inputStabilityCheck:n}={...ul,...t};return{identityFunctionCheck:{shouldRun:"always"===i||"once"===i&&e,run:ll},inputStabilityCheck:{shouldRun:"always"===n||"once"===n&&e,run:cl}}})(m,h);if(i.shouldRun&&i.run(s,e,t),n.shouldRun){const t=pl(g,arguments);n.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:d,memoizeOptions:f},arguments)}m&&(m=!1)}return t}),...p);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>n,resetRecomputations:()=>{n=0},memoize:d,argsMemoize:c})};return Object.assign(n,{withTypes:()=>n}),n}var wl=$l(bl),Cl=Object.assign(((e,t=wl)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const i=Object.keys(e),n=t(i.map((t=>e[t])),((...e)=>e.reduce(((e,t,n)=>(e[i[n]]=t,e)),{})));return n}),{withTypes:()=>Cl});function kl(e){return({dispatch:t,getState:i})=>n=>o=>"function"==typeof o?o(t,i,e):n(o)}var Sl=kl(),Il=kl;((...e)=>{const t=$l(...e)})(bl);var Rl="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?vd:vd.apply(null,arguments)},xl=e=>e&&"function"==typeof e.match;function Ol(e,t){function i(...i){if(t){let n=t(...i);if(!n)throw new Error("production"===process.env.NODE_ENV?dc(0):"prepareAction did not return an object");return{type:e,payload:n.payload,..."meta"in n&&{meta:n.meta},..."error"in n&&{error:n.error}}}return{type:e,payload:i[0]}}return i.toString=()=>`${e}`,i.type=e,i.match=t=>md(t)&&t.type===e,i}function El(e){return"function"==typeof e&&"type"in e&&xl(e)}function Al(e,t){let i=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();i+=e-t}},warnIfExceeded(){i>e&&console.warn(`${t} took ${i}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 Nl=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 jl(e){return Id(e)?dl(e,(()=>{})):e}function Ml(e,t,i){if(e.has(t)){let n=e.get(t);return i.update&&(n=i.update(n,t,e),e.set(t,n)),n}if(!i.insert)throw new Error("production"===process.env.NODE_ENV?dc(10):"No insert provided for key not already in map");const n=i.insert(t,e);return e.set(t,n),n}function Pl(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Ul(e,t,i){const n=Tl(e,t,i);return{detectMutations:()=>Wl(e,t,n,i)}}function Tl(e,t=[],i,n="",o=new Set){const r={value:i};if(!e(i)&&!o.has(i)){o.add(i),r.children={};for(const o in i){const s=n?n+"."+o:o;t.length&&-1!==t.indexOf(s)||(r.children[o]=Tl(e,t,i[o],s))}}return r}function Wl(e,t=[],i,n,o=!1,r=""){const s=i?i.value:void 0,a=s===n;if(o&&!a&&!Number.isNaN(n))return{wasMutated:!0,path:r};if(e(s)||e(n))return{wasMutated:!1};const d={};for(let e in i.children)d[e]=!0;for(let e in n)d[e]=!0;const l=t.length>0;for(let o in d){const s=r?r+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const d=Wl(e,t,i.children[o],n[o],a,s);if(d.wasMutated)return d}return{wasMutated:!1}}function Ll(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||cd(e)}function Dl(e,t="",i=Ll,n,o=[],r){let s;if(!i(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=n?n(e):Object.entries(e),d=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(d){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!i(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Dl(l,a,i,n,o,r),s))return s}return r&&_l(e)&&r.add(e),!1}function _l(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!_l(t))return!1;return!0}function Fl(e){return"boolean"==typeof e}var ql=()=>function(e){const{thunk:t=!0,immutableCheck:i=!0,serializableCheck:n=!0,actionCreatorCheck:o=!0}=e??{};let r=new Nl;if(t&&(Fl(t)?r.push(Sl):r.push(Il(t.extraArgument))),"production"!==process.env.NODE_ENV){if(i){let e={};Fl(i)||(e=i),r.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{let t=function(e,t,n,o){return JSON.stringify(e,i(t,o),n)},i=function(e,t){let i=[],n=[];return t||(t=function(e,t){return i[0]===t?"[Circular ~]":"[Circular ~."+n.slice(0,i.indexOf(t)).join(".")+"]"}),function(o,r){if(i.length>0){var s=i.indexOf(this);~s?i.splice(s+1):i.push(this),~s?n.splice(s,1/0,o):n.push(o),~i.indexOf(r)&&(r=t.call(this,o,r))}else i.push(r);return null==e?r:e.call(this,o,r)}},{isImmutable:n=Pl,ignoredPaths:o,warnAfter:r=32}=e;const s=Ul.bind(null,n,o);return({getState:e})=>{let i,n=e(),o=s(n);return a=>d=>{const l=Al(r,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(n=e(),i=o.detectMutations(),o=s(n),i.wasMutated)throw new Error("production"===process.env.NODE_ENV?dc(19):`A state mutation was detected between dispatches, in the path '${i.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const c=a(d);return l.measureTime((()=>{if(n=e(),i=o.detectMutations(),o=s(n),i.wasMutated)throw new Error("production"===process.env.NODE_ENV?dc(20):`A state mutation was detected inside a dispatch, in the path: ${i.path||""}. Take a look at the reducer(s) handling the action ${t(d)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),c}}}}(e))}if(n){let e={};Fl(n)||(e=n),r.push(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{const{isSerializable:t=Ll,getEntries:i,ignoredActions:n=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:d=!1,disableCache:l=!1}=e,c=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!md(u))return l(u);const h=l(u),f=Al(s,"SerializableStateInvariantMiddleware");return d||n.length&&-1!==n.indexOf(u.type)||f.measureTime((()=>{const e=Dl(u,"",t,i,o,c);if(e){const{keyPath:t,value:i}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,i,"\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||(f.measureTime((()=>{const n=Dl(e.getState(),"",t,i,r,c);if(n){const{keyPath:e,value:t}=n;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)`)}})),f.warnIfExceeded()),h}}}(e))}if(o){let e={};Fl(o)||(e=o),r.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);const{isActionCreator:t=El}=e;return()=>e=>i=>(t(i)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],i=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(${i}())\` instead of \`dispatch(${i})\`. This is necessary even if the action has no payload.`}(i.type)),e(i))}(e))}}return r},Bl=e=>t=>{setTimeout(t,e)},Vl="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Bl(10),Kl=e=>function(t){const{autoBatch:i=!0}=t??{};let n=new Nl(e);return i&&n.push(((e={type:"raf"})=>t=>(...i)=>{const n=t(...i);let o=!0,r=!1,s=!1;const a=new Set,d="tick"===e.type?queueMicrotask:"raf"===e.type?Vl:"callback"===e.type?e.queueNotification:Bl(e.timeout),l=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},n,{subscribe(e){const t=n.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,d(l))),n.dispatch(e)}finally{o=!0}}})})("object"==typeof i?i:void 0)),n},Hl="production"===process.env.NODE_ENV;function zl(e){const t=ql(),{reducer:i,middleware:n,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,d;if("function"==typeof i)a=i;else{if(!cd(i))throw new Error("production"===process.env.NODE_ENV?dc(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=gd(i)}if(!Hl&&n&&"function"!=typeof n)throw new Error("production"===process.env.NODE_ENV?dc(2):"`middleware` field must be a callback");if("function"==typeof n){if(d=n(t),!Hl&&!Array.isArray(d))throw new Error("production"===process.env.NODE_ENV?dc(3):"when using a middleware builder function, an array of middleware must be returned")}else d=t();if(!Hl&&d.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?dc(4):"each middleware provided to configureStore must be a function");let l=vd;o&&(l=Rl({trace:!Hl,..."object"==typeof o&&o}));const c=function(...e){return t=>(i,n)=>{const o=t(i,n);let r=()=>{throw new Error("production"===process.env.NODE_ENV?sd(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=vd(...a)(o.dispatch),{...o,dispatch:r}}}(...d),u=Kl(c);if(!Hl&&s&&"function"!=typeof s)throw new Error("production"===process.env.NODE_ENV?dc(5):"`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Hl&&!Array.isArray(h))throw new Error("production"===process.env.NODE_ENV?dc(6):"`enhancers` callback must return an array");if(!Hl&&h.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?dc(7):"each enhancer provided to configureStore must be a function");Hl||!d.length||h.includes(c)||console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return fd(a,r,l(...h))}function Gl(e){const t={},i=[];let n;const o={addCase(e,r){if("production"!==process.env.NODE_ENV){if(i.length>0)throw new Error("production"===process.env.NODE_ENV?dc(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(n)throw new Error("production"===process.env.NODE_ENV?dc(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?dc(28):"`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error("production"===process.env.NODE_ENV?dc(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,o},addMatcher(e,t){if("production"!==process.env.NODE_ENV&&n)throw new Error("production"===process.env.NODE_ENV?dc(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return i.push({matcher:e,reducer:t}),o},addDefaultCase(e){if("production"!==process.env.NODE_ENV&&n)throw new Error("production"===process.env.NODE_ENV?dc(31):"`builder.addDefaultCase` can only be called once");return n=e,o}};return e(o),[t,i,n]}function Jl(...e){return t=>e.some((e=>((e,t)=>xl(e)?e.match(t):e(t))(e,t)))}var Zl=["name","message","stack","code"],Yl=class{constructor(e,t){this.payload=e,this.meta=t}_type},Xl=class{constructor(e,t){this.payload=e,this.meta=t}_type},Ql=e=>{if("object"==typeof e&&null!==e){const t={};for(const i of Zl)"string"==typeof e[i]&&(t[i]=e[i]);return t}return{message:String(e)}},ec=(()=>{function e(e,t,i){const n=Ol(e+"/fulfilled",((e,t,i,n)=>({payload:e,meta:{...n||{},arg:i,requestId:t,requestStatus:"fulfilled"}}))),o=Ol(e+"/pending",((e,t,i)=>({payload:void 0,meta:{...i||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Ol(e+"/rejected",((e,t,n,o,r)=>({payload:o,error:(i&&i.serializeError||Ql)(e||"Rejected"),meta:{...r||{},arg:n,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,d)=>{const l=i?.idGenerator?i.idGenerator(e):((e=21)=>{let t="",i=e;for(;i--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),c=new AbortController;let u;function h(e){u=e,c.abort()}const f=async function(){let f;try{let r=i?.condition?.(e,{getState:a,extra:d});if(null!==(p=r)&&"object"==typeof p&&"function"==typeof p.then&&(r=await r),!1===r||c.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>c.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(l,e,i?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:d}))),f=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:d,requestId:l,signal:c.signal,abort:h,rejectWithValue:(e,t)=>new Yl(e,t),fulfillWithValue:(e,t)=>new Xl(e,t)})).then((t=>{if(t instanceof Yl)throw t;return t instanceof Xl?n(t.payload,l,e,t.meta):n(t,l,e)}))])}catch(t){f=t instanceof Yl?r(null,l,e,t.payload,t.meta):r(t,l,e)}var p;return i&&!i.dispatchConditionRejection&&r.match(f)&&f.meta.condition||s(f),f}();return Object.assign(f,{abort:h,requestId:l,arg:e,unwrap:()=>f.then(tc)})}}),{pending:o,rejected:r,fulfilled:n,settled:Jl(r,n),typePrefix:e})}return e.withTypes=()=>e,e})();function tc(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var ic=Symbol.for("rtk-slice-createasyncthunk");function nc(e,t){return`${e}/${t}`}function oc(e,t,i,n){function o(o,...r){let s=i.call(e,o);if(void 0===s)if(n)s=e.getInitialState();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?dc(16):"selectState returned undefined for an uninjected slice reducer");return t(s,...r)}return o.unwrapped=t,o}var rc=function({creators:e}={}){const t=e?.asyncThunk?.[ic];return function(e){const{name:i,reducerPath:n=i}=e;if(!i)throw new Error("production"===process.env.NODE_ENV?dc(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 o=("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)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const i="string"==typeof e?e:e.type;if(!i)throw new Error("production"===process.env.NODE_ENV?dc(12):"`context.addCase` cannot be called with an empty action type");if(i in s.sliceCaseReducersByType)throw new Error("production"===process.env.NODE_ENV?dc(13):"`context.addCase` cannot be called with two reducers for the same action type: "+i);return s.sliceCaseReducersByType[i]=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 d(){if("production"!==process.env.NODE_ENV&&"object"==typeof e.extraReducers)throw new Error("production"===process.env.NODE_ENV?dc(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={},i=[],n]="function"==typeof e.extraReducers?Gl(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("production"!==process.env.NODE_ENV&&"object"==typeof t)throw new Error("production"===process.env.NODE_ENV?dc(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let i,[n,o,r]=Gl(t);if(function(e){return"function"==typeof e}(e))i=()=>jl(e());else{const t=jl(e);i=()=>t}function s(e=i(),t){let s=[n[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,i)=>{if(i){if(Sd(e)){const n=i(e,t);return void 0===n?e:n}if(Id(e))return dl(e,(e=>i(e,t)));{const n=i(e,t);if(void 0===n){if(null===e)return e;throw new Error("production"===process.env.NODE_ENV?dc(9):"A case reducer on a non-draftable value must not return undefined")}return n}}return e}),e)}return s.getInitialState=i,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of i)e.addMatcher(t.matcher,t.reducer);n&&e.addDefaultCase(n)}))}r.forEach((n=>{const r=o[n],s={reducerName:n,type:nc(i,n),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:i},n,o){let r,s;if("reducer"in n){if(i&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(n))throw new Error("production"===process.env.NODE_ENV?dc(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=n.reducer,s=n.prepare}else r=n;o.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Ol(e,s):Ol(e))}(s,r,a):function({type:e,reducerName:t},i,n,o){if(!o)throw new Error("production"===process.env.NODE_ENV?dc(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:d,settled:l,options:c}=i,u=o(e,r,c);n.exposeAction(t,u),s&&n.addCase(u.fulfilled,s);a&&n.addCase(u.pending,a);d&&n.addCase(u.rejected,d);l&&n.addMatcher(u.settled,l);n.exposeCaseReducer(t,{fulfilled:s||sc,pending:a||sc,rejected:d||sc,settled:l||sc})}(s,r,a,t)}));const l=e=>e,c=new WeakMap;let u;const h={name:i,reducerPath:n,reducer:(e,t)=>(u||(u=d()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=d()),u.getInitialState()),getSelectors(t=l){const i=Ml(c,this,{insert:()=>new WeakMap});return Ml(i,t,{insert:()=>{const i={};for(const[n,o]of Object.entries(e.selectors??{}))i[n]=oc(this,o,t,this!==h);return i}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t)if(this!==h)t=this.getInitialState();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?dc(15):"selectSlice returned undefined for an uninjected slice reducer");return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...i}={}){const n=t??this.reducerPath;return e.inject({reducerPath:n,reducer:this.reducer},i),{...this,reducerPath:n}}};return h}}();function sc(){}var ac="listenerMiddleware";function dc(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. `}Ol(`${ac}/add`),Ol(`${ac}/removeAll`),Ol(`${ac}/remove`);const lc=e=>Rn((t=>{const i=rc(e),n=Object.assign(Object.assign({},i.actions),e.asyncActions);return class extends(bn(Ur)(t)){constructor(...e){super(...e);const t=zl({reducer:i.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...i)=>{const n=await t.dispatch(e(...i));try{tc(n)}catch(e){this.logger.error(e.message,n.type,e.stack)}return n},r=Object.keys(n).reduce(((e,t)=>(e[t]=o(n[t]),e)),{});this.actions=r,this.subscribe=(e,i=e=>e)=>t.subscribe((()=>e(i(t.getState()))))}}})),cc=Rn((e=>class extends(Ur(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,i;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(i=e.checkValidity)||void 0===i?void 0:i.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=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var i;null===(i=this.getFormInputs(e).find((e=>e.name===t)))||void 0===i||i.setAttribute("disabled","true")}removeFormField(e,t){var i;null===(i=this.getFormInputs(e).find((e=>e.name===t)))||void 0===i||i.remove()}})),uc=Rn((e=>{const t=bn(Br({"widget-id":_r}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),hc=Rn((e=>{const t=bn(Zr,uc)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const i=await this.config;return null===(t=null===(e=null==i?void 0:i.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}})),fc=Rn((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),pc=e=>e.selectedAccessKeysIds,gc=e=>e.notifications,vc=wl((e=>e.accessKeysList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{expireTimeFormatted:(null==e?void 0:e.expireTime)?new Date(1e3*((null==e?void 0:e.expireTime)||0)).toLocaleString():"Never",createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:(null==e?void 0:e.expireTime)&&new Date(1e3*((null==e?void 0:e.expireTime)||0))<new Date?"expired":null==e?void 0:e.status}))))),mc=wl(pc,vc,((e,t)=>t.filter((t=>e.includes(t.id))))),yc=wl(pc,(e=>!!e.length)),bc=wl(mc,(e=>e.every((e=>e.editable)))),$c=wl(bc,yc,((e,t)=>e&&t)),wc=wl(mc,(e=>e.some((e=>"expired"===e.status)))),Cc=wl($c,wc,((e,t)=>e&&!t));wl(pc,(e=>1===e.length));const kc=wl(mc,(e=>1===e.length?e[0].name:`${e.length} access keys`)),Sc=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},Ic=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),Rc=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{t&&e.notifications.push({type:"success",msg:t(i)})},onRejected:(t,i)=>{e&&t.notifications.push({type:"error",msg:e(i)})}}),xc=ec("accessKeys/create",((e,{extra:{api:t}})=>t.accesskey.create(e))),Oc=Sc(xc)({onFulfilled:(e,t)=>{e.accessKeysList.data.unshift(t.payload.key)}},Ic((e=>e.createAccessKey)),Rc({getSuccessMsg:()=>"Access Key created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create access key</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Ec={action:xc,reducer:Oc},Ac=ec("accessKeys/delete",((e,{extra:{api:t}})=>t.accesskey.deleteBatch(e))),Nc=Sc(Ac)({onFulfilled:(e,t)=>{e.accessKeysList.data=e.accessKeysList.data.filter((e=>!t.meta.arg.includes(e.id))),e.selectedAccessKeysIds=[]}},Ic((e=>e.deleteAccessKey)),Rc({getSuccessMsg:e=>Sn(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deleted successfully`,getErrorMsg:e=>Sn(e.meta.arg.length)`Failed to delete access key${["","s"]}`})),jc={action:Ac,reducer:Nc},Mc=ec("accessKeys/search",((e,{extra:{api:t},getState:i})=>{const n=i().searchParams;return t.accesskey.search(Object.assign(Object.assign({},n),e))})),Pc=Sc(Mc)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.accessKeysList.data=t.payload}},Ic((e=>e.accessKeysList))),Uc={action:Mc,reducer:Pc},Tc=ec("accessKeys/activate",((e,{extra:{api:t}})=>t.accesskey.activate(e))),Wc=Sc(Tc)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="active")}))}},Ic((e=>e.activateAccessKey)),Rc({getSuccessMsg:e=>Sn(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} activated successfully`,getErrorMsg:e=>Sn(e.meta.arg.length)`Failed to activate access key${["","s"]}`})),Lc={action:Tc,reducer:Wc},Dc=ec("accessKeys/deactivate",((e,{extra:{api:t}})=>t.accesskey.deactivate(e))),_c=Sc(Dc)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="inactive")}))}},Ic((e=>e.deactivateAccessKey)),Rc({getSuccessMsg:e=>Sn(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deactivated successfully`,getErrorMsg:e=>Sn(e.meta.arg.length)`Failed to deactivate access key${["","s"]}`})),Fc={action:Dc,reducer:_c},qc=ec("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),Bc={action:qc,reducer:Sc(qc)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},Ic((e=>e.tenantRoles)))},Vc={accessKeysList:{data:[],loading:!1,error:null},createAccessKey:{loading:!1,error:null},activateAccessKey:{loading:!1,error:null},deactivateAccessKey:{loading:!1,error:null},deleteAccessKey:{loading:!1,error:null},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedAccessKeysIds:[],notifications:[]},Kc="/v1/mgmt/accesskey/search",Hc="/v1/mgmt/accesskey/delete/batch",zc="/v1/mgmt/accesskey/create",Gc="/v1/mgmt/accesskey/deactivate/batch",Jc="/v1/mgmt/accesskey/activate/batch",Zc="/v1/mgmt/role/all",Yc=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),Xc=({httpClient:e,tenant:t,mock:i})=>({search:(...n)=>c(void 0,[...n],void 0,(function*({page:n,limit:o=1e4,text:r,sort:s}={}){if(i)return((...e)=>c(void 0,[...e],void 0,(function*({text:e,sort:t}={}){return new Promise((i=>{const n=[],o=(new Date).getTime()/1e3+2592e3,r=new Date(o).toLocaleString();for(let e=1;e<10;e+=1)n.push({id:`access-key-id-${e}`,name:`Access Key ${e}`,createdBy:`User ${e}`,editable:!0,expireTime:o,expireTimeFormatted:r,createdTime:o,createdTimeFormatted:r,roleNames:[`Role ${e}`],permittedIps:["127.1.2.3"],status:"active",clientId:`Client ID ${e}`,boundUserId:`User ${e}`});t.forEach((e=>{n.sort(((t,i)=>{var n,o;return e.desc?null===(o=i[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(n=t[e.field])||void 0===n?void 0:n.localeCompare(i[e.field])}))})),i(n.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.createdBy.toLowerCase().includes(e.toLowerCase()))))}))})))({page:n,limit:o,text:r,sort:s});const a=yield e.post(Kc,{limit:o,page:n,text:r,sort:s},{queryParams:{tenant:t}});return yield Yc(a),(yield a.json()).keys})),deleteBatch:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Hc,{ids:n},{queryParams:{tenant:t}});return yield Yc(o),o.json()})),create:n=>c(void 0,[n],void 0,(function*({name:n,expiration:o,roleNames:r,userId:s,permittedIps:a}){const d=new Date;d.setDate(d.getDate()+ +o);const l="0"===o[0]?0:Math.floor(d.getTime()/1e3);if(i)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,roleNames:t,userId:i,permittedIps:n},o){const r=Math.random().toString(10).substring(15);return new Promise((s=>{s({cleartext:Math.random().toString(20).substring(2),key:{id:`access-key-id-${r}`,name:e||`Access Key ${r}`,createdBy:i||`User ${r}`,editable:!0,expireTime:o,createdTime:(new Date).getTime()/1e3,roleNames:t,permittedIps:n,status:"active",clientId:`Client ID ${r}`,boundUserId:i||`User ${r}`}})}))})))({name:n,expiration:o,roleNames:r,userId:s,permittedIps:a},l);const u=yield e.post(zc,{name:n,expireTime:l,roleNames:r,userId:s,permittedIps:a},{queryParams:{tenant:t}});return yield Yc(u),yield u.json()})),activate:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Jc,{ids:n},{queryParams:{tenant:t}});return yield Yc(o),yield o.json()})),deactivate:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Gc,{ids:n},{queryParams:{tenant:t}});return yield Yc(o),yield o.json()}))}),Qc=({httpClient:e,tenant:t,mock:i})=>({getTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(i)return(e=>new Promise((t=>{const i=[];for(let t=1;t<5;t+=1)i.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:i})})))(t);const n=yield e.get(Zc,{queryParams:{tenant:t}});return yield Yc(n),n.json()}))}),eu=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,Kr,fc,Br({tenant:Br.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i,n)=>{const o=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"access-key-management-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.6.2"}}));return{accesskey:Xc({httpClient:o.httpClient,tenant:t,mock:i}),tenant:Qc({httpClient:o.httpClient,tenant:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),tu=Rn((e=>{const t=bn(lc({name:"widget",initialState:Vc,reducers:{setSelectedAccessKeysIds:(e,{payload:t})=>{e.selectedAccessKeysIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Ec.reducer(e),jc.reducer(e),Uc.reducer(e),Lc.reducer(e),Fc.reducer(e),Bc.reducer(e)},asyncActions:{searchAccessKeys:Uc.action,createAccessKey:Ec.action,activateAccessKeys:Lc.action,deactivateAccessKeys:Fc.action,deleteAccessKeys:jc.action,getTenantRoles:Bc.action}}),Fr,Ur,eu)(e);return class extends t{constructor(...e){super(...e),this.state=Vc,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),iu=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){const t=yield this.fetchStaticResource(`access-key-management-widget/${this.widgetId}/${e}`,"text");return null==t?void 0:t.body}))}}})),nu=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,iu,tu)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([u(this,t,"m",i).call(this),this.actions.searchAccessKeys(),this.actions.getTenantRoles()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),ou=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(tu,Ur,nu)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{this.accessKeysTable.data=e}))),o.set(this,In(((e,t)=>{const i=[],{value:n}=t;if(n){const t=e.path;i.push({field:t,desc:"desc"===n})}this.actions.searchAccessKeys({sort:i})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),u(this,t,"m",i).call(this),this.accessKeysTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,o,"f").call(this,e.target,e.detail)}))})),u(this,n,"f").call(this,vc(this.state)),this.subscribe(u(this,n,"f").bind(this),vc)}))}},n=new WeakMap,o=new WeakMap,t=new WeakSet,i=function(){var e;this.accessKeysTable=new Fa(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="access-keys-table"]'),{logger:this.logger}),this.accessKeysTable.onSelectedItemsChange((e=>{this.actions.setSelectedAccessKeysIds(e.detail.value.map((({id:e})=>e)))}))},r})),ru=Rn((e=>{var t,i,n;return n=class extends(bn(tu,nd,Ur,nu)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){var e;this.activateAccessKeysModal=this.createModal(),this.activateAccessKeysModal.setContent($n(yield this.fetchWidgetPage("activate-access-keys-modal.html")));const t=new Ta((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.activateAccessKeysModal.close()));const i=new Ta((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=mc(this.state);this.actions.activateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.activateAccessKeysModal.close()}));const n=new Za(null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.activateAccessKeysModal.beforeOpen=()=>{const e=kc(this.state);n.text=`Activate ${e}?`}}))},n})),su=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,nu,tu,ru)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.activateButton.enable():this.activateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),Cc)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.activateButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="activate-access-keys"]'),{logger:this.logger}),this.activateButton.disable(),this.activateButton.onClick((()=>{this.activateAccessKeysModal.open()}))},o})),au=Rn((e=>{var t,i,n;return n=class extends(bn(tu,nd,cc,Ur,nu)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){this.createdAccessKeyModal=this.createModal(),this.createdAccessKeyModal.setContent($n(yield this.fetchWidgetPage("created-access-key-modal.html"))),new Ta((()=>{var e;return null===(e=this.createdAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.createdAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.createdAccessKeyModal.ele),this.createdAccessKeyModal.close()}))}))},n})),du=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(tu,nd,cc,Ur,nu,au)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),o.set(this,(()=>c(this,void 0,void 0,(function*(){var e,t;yield u(this,i,"f").setData(null===(t=this.state,e=t.tenantRoles.data||[])||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},i=new WeakMap,o=new WeakMap,t=new WeakSet,n=function e(){return c(this,void 0,void 0,(function*(){this.createAccessKeyModal=this.createModal(),this.createAccessKeyModal.setContent($n(yield this.fetchWidgetPage("create-access-key-modal.html"))),new Ta((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.createAccessKeyModal.close(),this.resetFormData(this.createAccessKeyModal.ele)})),new Ta((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){var e,t;if(this.validateForm(this.createAccessKeyModal.ele)){const i=yield this.actions.createAccessKey(Object.assign({},this.getFormData(this.createAccessKeyModal.ele)));this.createAccessKeyModal.close(),(null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e.cleartext)&&(this.setFormData(this.createdAccessKeyModal.ele,{"generated-key":null===(t=null==i?void 0:i.payload)||void 0===t?void 0:t.cleartext}),this.createdAccessKeyModal.open())}})))),h(this,i,new Ha((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),u(this,o,"f").call(this),this.createAccessKeyModal.afterClose=()=>{u(this,t,"m",e).call(this)}}))},r})),lu=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,du,nu)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.createButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-access-key"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createAccessKeyModal.open()))},n})),cu=Rn((e=>{var t,i,n;return n=class extends(bn(tu,nd,Ur,nu)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){var e;this.deactivateAccessKeysModal=this.createModal(),this.deactivateAccessKeysModal.setContent($n(yield this.fetchWidgetPage("deactivate-access-keys-modal.html")));const t=new Ta((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deactivateAccessKeysModal.close()));const i=new Ta((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=mc(this.state);this.actions.deactivateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deactivateAccessKeysModal.close()}));const n=new Za(null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deactivateAccessKeysModal.beforeOpen=()=>{const e=kc(this.state);n.text=`Deactivate ${e}?`}}))},n})),uu=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,nu,tu,cu)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.deactivateButton.enable():this.deactivateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),Cc)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.deactivateButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="deactivate-access-keys"]'),{logger:this.logger}),this.deactivateButton.disable(),this.deactivateButton.onClick((()=>{this.deactivateAccessKeysModal.open()}))},o})),hu=Rn((e=>{var t,i,n;return n=class extends(bn(tu,nd,Ur,nu)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteAccessKeysModal=this.createModal(),this.deleteAccessKeysModal.setContent($n(yield this.fetchWidgetPage("delete-access-keys-modal.html")));const t=new Ta((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteAccessKeysModal.close()));const i=new Ta((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=mc(this.state);this.actions.deleteAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deleteAccessKeysModal.close()}));const n=new Za(null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteAccessKeysModal.beforeOpen=()=>{const e=kc(this.state);n.text=`Delete ${e}?`}}))},n})),fu=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,nu,tu,hu)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),$c)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.deleteButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-access-keys"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteAccessKeysModal.open()}))},o})),pu=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,nu,tu)(e)){constructor(){super(...arguments),t.add(this),i.set(this,In((()=>{this.actions.searchAccessKeys({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.searchInput=new Ya(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,i,"f"))},o})),gu={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="currentcolor"/>\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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},vu=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,tu,rd,Fr)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Cn((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",n).call(this,e);r.setContent(u(this,t,"m",i).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),gc)}))}},o=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const i=gu[e],n=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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${n.outerHTML}`},n=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),mu=Rn((e=>class extends(bn(Ea,ps,ou,lu,fu,pu,su,uu,vu)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),yu=bn((e=>class extends(mu(e)){}))(HTMLElement);customElements.define("descope-access-key-management-widget",yu);var bu,$u=Object.freeze({__proto__:null,default:yu});!function(e){e.oidc="oidc",e.saml="saml",e.wsfed="wsfed",e.custom="custom"}(bu||(bu={}));const wu=e=>e.ssoAppsList.data,Cu=wl(wu,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>e.appType===bu.saml))})),ku=wl(wu,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>{var t;return e.appType===bu.oidc&&(null===(t=e.oidcSettings)||void 0===t?void 0:t.customIdpInitiatedLoginPageUrl)}))})),Su=wl(wu,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>{var t;return e.appType===bu.wsfed&&(null===(t=e.wsfedSettings)||void 0===t?void 0:t.idpInitiatedUrl)}))})),Iu=wl(wu,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>e.appType===bu.custom))})),Ru=e=>{var t,i,n,o;switch(e.appType){case bu.saml:return null===(t=e.samlSettings)||void 0===t?void 0:t.idpInitiatedUrl;case bu.oidc:return null===(i=e.oidcSettings)||void 0===i?void 0:i.customIdpInitiatedLoginPageUrl;case bu.wsfed:return null===(n=e.wsfedSettings)||void 0===n?void 0:n.idpInitiatedUrl;case bu.custom:return null===(o=e.customSettings)||void 0===o?void 0:o.loginPageUrl;default:return}},xu=wl(Cu,ku,Su,Iu,((e,t,i,n)=>[...e,...t,...i,...n].map((e=>({name:e.name,icon:e.logo,url:Ru(e)}))))),Ou=ec("ssoApps/load",((e,{extra:{api:t}})=>t.ssoApps.load())),Eu=(e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))})(Ou)({onFulfilled:(e,t)=>{var i;e.ssoAppsList.data=null===(i=t.payload)||void 0===i?void 0:i.apps}},(Au=e=>e.ssoAppsList,{onFulfilled:e=>{Au(e).loading=!1},onPending:e=>{Au(e).loading=!0,Au(e).error=null},onRejected:(e,t)=>{Au(e).loading=!1,Au(e).error=t.error}}));var Au;const Nu={action:Ou,reducer:Eu},ju={ssoAppsList:{data:[],loading:!1,error:null}},Mu="/v1/mgmt/sso/idp/apps/load",Pu=({httpClient:e,mock:t})=>({load:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"ssoapp1",name:"App 1",description:"This is the first SAML app",enabled:!0,appType:bu.saml,logo:"logo1",samlSettings:{idpInitiatedUrl:""}},{id:"ssoapp2",name:"App 2",description:"This is the first OIDC app",enabled:!0,appType:bu.oidc,logo:"logo2"},{id:"ssoapp3",name:"App 3",description:"This is the second SAML app",enabled:!0,appType:bu.saml,logo:"logo3",samlSettings:{idpInitiatedUrl:""}},{id:"ssoapp4",name:"App 4",description:"This is a WS-Fed app",enabled:!0,appType:bu.wsfed,logo:"logo4",wsfedSettings:{idpInitiatedUrl:"http://localhost/wsfed/idp-initiated",realm:"urn:mock:realm",replyUrl:"http://localhost/reply",loginPageUrl:"http://localhost/login"}}]})}))}));const i=yield e.get(Mu);return yield(e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})))(i),i.json()}))}),Uu=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,fc,Kr)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i)=>{const n=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"applications-portal-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.7.2"}}));return{ssoApps:Pu({httpClient:n.httpClient,mock:t})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},o})),Tu=Rn((e=>{const t=bn(lc({name:"widget",initialState:ju,reducers:{},extraReducers:e=>{Nu.reducer(e)},asyncActions:{loadSSOApps:Nu.action}}),Fr,Ur,Uu)(e);return class extends t{constructor(...e){super(...e),this.state=ju,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Wu=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`applications-portal-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Lu=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,Fr,os,cs,Wu,Tu)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this);const[r]=yield Promise.all([u(this,t,"m",i).call(this),this.actions.loadSSOApps()]);u(this,t,"m",n).call(this,r),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},n=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},o})),Du=Rn((e=>{var t,i,n;return n=class extends(bn(Tu,Ur,Lu)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this,xu(this.state))}))}},t=new WeakSet,i=function(e){this.appsList=new Pa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-apps-list")}),{logger:this.logger}),this.appsList.data=e},n})),_u=Rn((e=>class extends(bn(Ea,ps,Du)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Fu=bn((e=>class extends(_u(e)){}))(HTMLElement);customElements.define("descope-applications-portal-widget",Fu);var qu=Object.freeze({__proto__:null,default:Fu});const Bu=(e,t)=>t?{[e]:t}:{},Vu=e=>{if(!e)return;const t=JSON.parse(e);return Array.isArray(t)&&0===t.length?void 0:t},Ku=e=>e.selectedAuditId,Hu=wl((e=>e.auditList.data),(e=>e.map((e=>{const t=e||{},{occurred:i,ID:n,type:o}=t,r=t.data,s=void 0===r?{saml_request:"",saml_response:"",saml_generated_user:"",saml_generated_roles:"",oidc_response:"",oidc_generated_user:"",scim_request:"",scim_result:"",Change:""}:r,{saml_request:a,saml_response:d,saml_generated_user:c,saml_generated_roles:u,oidc_response:h,oidc_generated_user:f,scim_request:p,scim_result:g,Change:v}=s,m=l(s,["saml_request","saml_response","saml_generated_user","saml_generated_roles","oidc_response","oidc_generated_user","scim_request","scim_result","Change"]),y=l(t,["occurred","ID","type","data"]);var b;return(e=>Object.fromEntries(Object.entries(e).filter((([e,t])=>!!t))))(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},y),{data:m}),Bu("type",(b=o)&&b[0].toUpperCase()+b.slice(1))),Bu("saml_request",a)),Bu("saml_response",d)),Bu("saml_generated_user",Vu(c))),Bu("saml_generated_roles",Vu(u))),Bu("oidc_response",Vu(h))),Bu("oidc_generated_user",Vu(f))),Bu("scim_request",p)),Bu("scim_result",g)),Bu("Change",v)),{occurredFormatted:i?new Date(Number(i)||0).toLocaleString():"N/A"}))}))));wl(Ku,Hu,((e,t)=>t.find((t=>e===t.id)))),wl(Ku,(e=>!!e));const zu=ec("audit/search",((e,{extra:{api:t},getState:i})=>{const n=i().searchParams;return t.audit.search(Object.assign(Object.assign({},n),e))})),Gu=(e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))})(zu)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(Ju=e=>e.auditList,{onFulfilled:e=>{Ju(e).loading=!1},onPending:e=>{Ju(e).loading=!0,Ju(e).error=null},onRejected:(e,t)=>{Ju(e).loading=!1,Ju(e).error=t.error}}));var Ju;const Zu={action:zu,reducer:Gu},Yu={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""},Xu="/v1/mgmt/audit/search",Qu=({httpClient:e,tenant:t,mock:i})=>({search:(...n)=>c(void 0,[...n],void 0,(function*({page:n,limit:o=1e4,text:r,sort:s,from:a}={}){if(i)return(e=>c(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((i=>{const n=[],o=(new Date).getTime()/1e3+2592e3,r=new Date(o).toLocaleString();for(let e=1;e<9;e+=1)n.push({id:`Audit ${e}`,action:`Action ${e}`,actorId:`Actor ${e}`,type:"info",method:`Method ${e}`,userId:`User ${e}`,device:`Device ${e}`,geo:`Geo ${e}`,remoteAddress:`127.0.0.${e}`,externalIds:[`Login ID ${e}`],occurred:o,occurredFormatted:r});t.forEach((e=>{n.sort(((t,i)=>{var n,o;return e.desc?null===(o=i[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(n=t[e.field])||void 0===n?void 0:n.localeCompare(i[e.field])}))})),i(n.filter((t=>t.id.toLowerCase().includes(e.toLowerCase())||t.action.toLowerCase().includes(e.toLowerCase())||t.type.toLowerCase().includes(e.toLowerCase())||t.device.toLowerCase().includes(e.toLowerCase())||t.method.toLowerCase().includes(e.toLowerCase())||t.geo.toLowerCase().includes(e.toLowerCase())||t.remoteAddress.toLowerCase().includes(e.toLowerCase())||t.externalIds.includes(e.toLowerCase())||t.userId.toLowerCase().includes(e.toLowerCase()))))}))})))({page:n,limit:o,text:r,sort:s});const d=yield e.post(Xu,{limit:o,page:n,text:r,sort:s,from:a},{queryParams:{tenant:t}});return yield(e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})))(d),(yield d.json()).audits}))}),eh=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,Kr,fc,Br({tenant:Br.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i,n)=>{const o=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"audit-management-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.7.2"}}));return{audit:Qu({httpClient:o.httpClient,tenant:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),th=Rn((e=>{const t=bn(lc({name:"widget",initialState:Yu,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{Zu.reducer(e)},asyncActions:{searchAudit:Zu.action}}),Fr,Ur,eh)(e);return class extends t{constructor(...e){super(...e),this.state=Yu,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),ih=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`audit-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),nh=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,ih,th)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([u(this,t,"m",i).call(this)]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),oh=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,nh,th)(e)){constructor(){super(...arguments),t.add(this),i.set(this,In((()=>{const e=this.rangeInput.value,t=new Date;let i;switch(e){case"minuets15":i=t.setMinutes(t.getMinutes()-15);break;case"hour":i=t.setHours(t.getHours()-1);break;case"hour6":i=t.setHours(t.getHours()-6);break;case"day":default:i=t.setDate(t.getDate()-1);break;case"day3":i=t.setDate(t.getDate()-3);break;case"week":i=t.setDate(t.getDate()-7);break;case"week2":i=t.setDate(t.getDate()-14);break;case"month":i=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(i).getTime())})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this),u(this,t,"m",o).call(this)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.searchInput=new Ya(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,i,"f")),u(this,i,"f").call(this)},o=function(){var e;this.rangeInput=new Ja(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(u(this,i,"f"))},r})),rh=Rn((e=>{var t,i,n,o;return o=class extends(bn(th,Ur,nh)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),u(this,n,"f").call(this,Hu(this.state)),this.subscribe(u(this,n,"f").bind(this),Hu)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.auditTable=new Fa(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="audit-table"]'),{logger:this.logger}),this.auditTable.onSelectedItemsChange((e=>{this.actions.setSelectedAuditId(e.detail.value.map((({id:e})=>e)))}))},o})),sh=[{header:"Occurred",path:"occurredFormatted"},{header:"User ID",path:"userId"},{header:"Actor",path:"actorId"},{header:"Login IDs",path:"externalIds"},{header:"Remote Address",path:"remoteAddress"},{header:"Type",path:"type"},{header:"Action",path:"action"},{header:"Device",path:"device"},{header:"Method",path:"method"},{header:"Geo",path:"geo"}],ah=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,nh,th)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.exportButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="export-button"]'),{logger:this.logger}),this.exportButton.onClick((()=>{const e=Hu(this.state);if(!e.length)return void this.logger.warn("No audit data to export");const t=((e,t)=>[t.map((e=>Pn(e.header))).join(","),...e.map((e=>t.map((t=>Pn(e[t.path]))).join(",")))].join("\n"))(e,sh);((e,t)=>{const i=new Blob(["\ufeff"+e],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.setAttribute("download",t),document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)})(t,`audit_logs_${(new Date).toISOString().slice(0,10)}.csv`)}))},n})),dh=Rn((e=>class extends(bn(Ea,ps,rh,oh,ah)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),lh=bn((e=>class extends(dh(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",lh);var ch=Object.freeze({__proto__:null,default:lh});const uh=(e={})=>{const t=$n("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,i])=>{t.content.querySelector("descope-wc").setAttribute(kn(e),i)})),t};function hh(e){return new URLSearchParams(window.location.search).get(e)}const fh=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},ph=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),gh=ec("outboundApps/load",((e,{extra:{api:t}})=>t.outboundApps.getAllOutboundApps())),vh=fh(gh)({onFulfilled:(e,t)=>{var i;e.outboundAppsList.data=null===(i=t.payload)||void 0===i?void 0:i.apps}},ph((e=>e.outboundAppsList))),mh={action:gh,reducer:vh},yh=ec("outboundApps/getConnectedOutboundApps",((e,{extra:{api:t}})=>t.outboundApps.getConnectedOutboundApps(e))),bh=fh(yh)({onFulfilled:(e,t)=>{var i;e.connectedOutboundAppsIds.data=null===(i=t.payload)||void 0===i?void 0:i.appIds}},ph((e=>e.connectedOutboundAppsIds))),$h={action:yh,reducer:bh},wh={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}},Ch="/v1/mgmt/outbound/apps",kh="/v1/mgmt/outbound/apps-with-user-token",Sh="/v1/auth/me",Ih=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),Rh=({httpClient:e,mock:t})=>({getAllOutboundApps:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"appId1",name:"Application 1",description:"Description"},{id:"appId2",name:"Application 2",description:"Description"},{id:"appId3",name:"Application 3",description:"Description"}]})}))}));const i=yield e.get(Ch);return yield Ih(i),i.json()})),getConnectedOutboundApps:i=>c(void 0,[i],void 0,(function*({userId:i,tenantId:n}){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:["outboundApp3"]})}))}));const o=yield e.get(kh,{queryParams:n?{userId:i,tenantId:n}:{userId:i}});return yield Ih(o),o.json()}))}),xh=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({userId:"user-1"})}))}));const i=yield e.get(Sh);return yield Ih(i),i.json()}))}),Oh=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,fc,Kr)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||us}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i)=>{const n=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.3.3"}}));return{outboundApps:Rh({httpClient:n.httpClient,mock:t}),user:Object.assign({},xh({httpClient:n.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},o})),Eh=ec("users/me",((e,{extra:{api:t}})=>t.user.me())),Ah={action:Eh,reducer:fh(Eh)({onFulfilled:(e,t)=>{e.me.data=t.payload}},ph((e=>e.me)))},Nh=Rn((e=>{const t=bn(lc({name:"widget",initialState:wh,reducers:{setAllowedAppsIds:(e,{payload:t})=>{e.allowedAppsIds.data=t}},extraReducers:e=>{Ah.reducer(e),$h.reducer(e),mh.reducer(e)},asyncActions:{getMe:Ah.action,getOutboundApps:mh.action,getConnectedOutboundApps:$h.action}}),Fr,Ur,Oh)(e);return class extends t{constructor(...e){super(...e),this.state=wh,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),jh="widget-flow",Mh=Rn((e=>{var t,i,n;return n=class extends(bn(Fr,nd,Nh,fc,Ur,ps)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const o=hh(jh);o&&(function(e){if(window.history.replaceState&&hh(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(jh),u(this,t,"m",i).call(this,o))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(uh({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),new Wa((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},n})),Ph=wl((e=>e.outboundAppsList.data),(e=>e.connectedOutboundAppsIds.data),(e=>e.allowedAppsIds.data),((e,t,i)=>e.filter((e=>void 0===i||i.includes(e.id))).map((e=>{const i=(null==t?void 0:t.includes(e.id))||!1;return Object.assign(Object.assign({},e),{appId:e.id,isConnected:i})})).sort(((e,t)=>e.name.localeCompare(t.name))))),Uh=wl((e=>e.me.data),(e=>e.userId)),Th=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`outbound-applications-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Wh=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,Fr,os,cs,Th,Nh)(e)){constructor(){super(...arguments),t.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(e,i,n){"allowed-outbound-apps-ids"===e&&i!==n&&this.actions.setAllowedAppsIds(u(this,t,"a",o))}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.init)||void 0===r?void 0:r.call(this),yield this.actions.getMe(),yield this.actions.setAllowedAppsIds(u(this,t,"a",o)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:Uh(this.state),tenantId:this.tenantId})]);const s=yield u(this,t,"m",i).call(this);u(this,t,"m",n).call(this,s),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},n=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},o=function(){var e;if(!this.hasAttribute("allowed-outbound-apps-ids"))return;const t=null===(e=this.getAttribute("allowed-outbound-apps-ids"))||void 0===e?void 0:e.trim();return t?t.split(",").map((e=>e.trim())).filter(Boolean):[]},r})),Lh=Rn((e=>class extends(bn(ps,qr)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Dh=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g,v,m,y,b,$;return $=class extends(bn(Lh,Nh,Ur,Wh,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),s.set(this,void 0),a.set(this,null),d.set(this,null),b.set(this,Cn((e=>{u(this,i,"f").data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",y).call(this,Ph(this.state)),u(this,t,"m",l).call(this),u(this,t,"m",g).call(this),this.subscribe(u(this,b,"f").bind(this),Ph)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,d=new WeakMap,b=new WeakMap,t=new WeakSet,l=function(){u(this,i,"f").connectFlowId&&(h(this,n,this.createModal({"data-id":"outbound-apps-connect"}),"f"),u(this,n,"f").afterClose=()=>{var e;if(u(this,a,"f")){const t=null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",u(this,a,"f")),h(this,a,null,"f")}},h(this,r,new Wa((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,r,"f")))},f=function(e,t,i){e.open(),t.removeEventListener("page-updated",i)},p=function(e,i){var n;const o=null===(n=e.ele)||void 0===n?void 0:n.querySelector("descope-wc"),r=()=>u(this,t,"m",f).call(this,e,o,r);i=r,null==o||o.addEventListener("page-updated",i)},g=function(){h(this,o,this.createModal({"data-id":"outbound-apps-disconnect"}),"f"),h(this,s,new Wa((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=()=>{var e;if(u(this,d,"f")){const t=null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",u(this,d,"f")),h(this,d,null,"f")}},this.syncFlowTheme(u(this,s,"f"))},v=function(e){u(this,n,"f").setContent(uh({projectId:this.projectId,flowId:u(this,i,"f").connectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:e})),u(this,t,"m",p).call(this,u(this,n,"f"),u(this,a,"f")),u(this,r,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getConnectedOutboundApps({userId:Uh(this.state),tenantId:this.tenantId})}))},m=function(e){u(this,o,"f").setContent(uh({projectId:this.projectId,flowId:u(this,i,"f").disconnectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:e})),u(this,t,"m",p).call(this,u(this,o,"f"),u(this,d,"f")),u(this,s,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getConnectedOutboundApps({userId:Uh(this.state)})}))},y=function(e){h(this,i,new Ga((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),u(this,i,"f").onConnectClick((({id:e})=>{u(this,t,"m",v).call(this,e)})),u(this,i,"f").onDisconnectClick((({id:e})=>{u(this,t,"m",m).call(this,e)})),u(this,i,"f").data=e},$})),_h=Rn((e=>class extends(bn(Ea,ps,Mh,Dh)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Fh=bn((e=>class extends(_h(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Oa})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.3.3"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",Fh);var qh=Object.freeze({__proto__:null,default:Fh});const Bh=e=>e.selectedRolesIds,Vh=e=>e.notifications,Kh=e=>e.tenantPermissions.data||[],Hh=wl((e=>e.rolesList.data),(e=>e.map((e=>{var t;return Object.assign(Object.assign({},e),{editable:0===(null===(t=null==e?void 0:e.tenantId)||void 0===t?void 0:t.length)?"no":"yes"})})))),zh=wl(Bh,Hh,((e,t)=>t.filter((t=>e.includes(t.name))))),Gh=wl(Bh,(e=>!!e.length)),Jh=wl(Bh,(e=>1===e.length)),Zh=wl(zh,Jh,((e,t)=>t&&"yes"===e[0].editable)),Yh=wl(zh,(e=>1===e.length?e[0].name:`${e.length} roles`)),Xh=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},Qh=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),ef=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{t&&e.notifications.push({type:"success",msg:t(i)})},onRejected:(t,i)=>{e&&t.notifications.push({type:"error",msg:e(i)})}}),tf=ec("roles/create",((e,{extra:{api:t}})=>t.role.create(e))),nf=Xh(tf)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Qh((e=>e.createRole)),ef({getSuccessMsg:()=>"Role created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),of={action:tf,reducer:nf},rf=ec("roles/delete",((e,{extra:{api:t}})=>t.role.deleteBatch(e))),sf=Xh(rf)({onFulfilled:(e,t)=>{e.rolesList.data=e.rolesList.data.filter((e=>{var i;return 0===(null===(i=null==e?void 0:e.tenantId)||void 0===i?void 0:i.length)||!t.meta.arg.includes(e.name)})),e.selectedRolesIds=[]}},Qh((e=>e.deleteRole)),ef({getSuccessMsg:e=>Sn(e.meta.arg.length)`${["",e.meta.arg.length]} ${["R","r"]}ole${["","s"]} deleted successfully`,getErrorMsg:e=>Sn(e.meta.arg.length)`Failed to delete role${["","s"]}`})),af={action:rf,reducer:sf},df=ec("roles/duplicate",((e,{extra:{api:t}})=>t.role.create(e))),lf=Xh(df)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},Qh((e=>e.duplicateRole)),ef({getSuccessMsg:()=>"Role duplicated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to duplicate role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),cf={action:df,reducer:lf},uf=ec("roles/search",((e,{extra:{api:t},getState:i})=>{const n=i().searchParams;return t.role.search(Object.assign(Object.assign({},n),e))})),hf=Xh(uf)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.rolesList.data=t.payload}},Qh((e=>e.rolesList))),ff={action:uf,reducer:hf},pf=ec("roles/update",((e,{extra:{api:t}})=>t.role.update(e))),gf=Xh(pf)({onFulfilled:(e,t)=>{const i=e.rolesList.data.findIndex((e=>e.name===t.payload.oldName));-1!==i&&(e.rolesList.data[i]=t.payload)}},Qh((e=>e.updateRole)),ef({getSuccessMsg:()=>"Role updated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to update role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),vf={action:pf,reducer:gf},mf=ec("tenant/getTenantPermissions",((e,{extra:{api:t}})=>t.tenant.getTenantPermissions())),yf={action:mf,reducer:Xh(mf)({onFulfilled:(e,t)=>{e.tenantPermissions.data=t.payload.permissions}},Qh((e=>e.tenantPermissions)))},bf={rolesList:{data:[],loading:!1,error:null},createRole:{loading:!1,error:null},duplicateRole:{loading:!1,error:null},updateRole:{loading:!1,error:null},deleteRole:{loading:!1,error:null},tenantPermissions:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedRolesIds:[],notifications:[]},$f="/v1/mgmt/role/search",wf="/v1/mgmt/role/delete/batch",Cf="/v1/mgmt/role/create",kf="/v1/mgmt/role/update",Sf="/v1/mgmt/permission/all",If=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),Rf=({httpClient:e,tenant:t,mock:i})=>({search:(...n)=>c(void 0,[...n],void 0,(function*({page:n,limit:o=1e4,text:r,sort:s}={}){if(i)return((e,t)=>c(void 0,[e,t],void 0,(function*({text:e,sort:t},i){return new Promise((n=>{const o=[];for(let e=1;e<10;e+=1)o.push({name:`Role ${e}`,description:`Role description ${e}`,permissionNames:[`Permission ${e}`],createdTime:new Date,tenantId:i});t.forEach((e=>{o.sort(((t,i)=>{var n,o;return e.desc?null===(o=i[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(n=t[e.field])||void 0===n?void 0:n.localeCompare(i[e.field])}))})),n(o.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()))))}))})))({page:n,limit:o,text:r,sort:s},t);const a=yield e.post($f,{limit:o,page:n,text:r,sort:s},{queryParams:{tenant:t}});return yield If(a),(yield a.json()).roles})),deleteBatch:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(wf,{roleNames:n},{queryParams:{tenant:t}});return yield If(o),o.json()})),create:n=>c(void 0,[n],void 0,(function*({name:n,description:o,permissionNames:r}){if(i)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,description:t,permissionNames:i},n){return new Promise((o=>{o({name:e,description:t,permissionNames:i,createdTime:new Date,tenantId:n})}))})))({name:n,description:o,permissionNames:r},t);const s=yield e.post(Cf,{name:n,description:o,permissionNames:r,tenantId:t},{queryParams:{tenant:t}});return yield If(s),yield s.json()})),update:n=>c(void 0,[n],void 0,(function*({name:n,newName:o,description:r,permissionNames:s}){if(i)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,newName:t,description:i,permissionNames:n},o){return new Promise((r=>{r({name:t,description:i,permissionNames:n,createdTime:new Date,oldName:e,tenantId:o})}))})))({name:n,newName:o,description:r,permissionNames:s},t);const a=yield e.post(kf,{name:n,newName:o,description:r,permissionNames:s,tenantId:t},{queryParams:{tenant:t}});yield If(a);const d=yield a.json();return d.oldName=n,d}))}),xf=({httpClient:e,tenant:t,mock:i})=>({getTenantPermissions:()=>c(void 0,void 0,void 0,(function*(){if(i)return new Promise((e=>{const t=[];for(let e=1;e<5;e+=1)t.push({name:`Permission ${e}`});e({permissions:t})}));const n=yield e.get(Sf,{queryParams:{tenant:t}});return yield If(n),n.json()}))}),Of=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,Kr,fc,Br({tenant:Br.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i,n)=>{const o=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"role-management-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.7.0"}}));return{role:Rf({httpClient:o.httpClient,tenant:t,mock:i}),tenant:xf({httpClient:o.httpClient,tenant:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),Ef=Rn((e=>{const t=bn(lc({name:"widget",initialState:bf,reducers:{setSelectedRolesIds:(e,{payload:t})=>{e.selectedRolesIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{of.reducer(e),cf.reducer(e),vf.reducer(e),af.reducer(e),ff.reducer(e),yf.reducer(e)},asyncActions:{searchRoles:ff.action,createRole:of.action,duplicateRole:cf.action,updateRole:vf.action,deleteRoles:af.action,getTenantPermissions:yf.action}}),Fr,Ur,Of)(e);return class extends t{constructor(...e){super(...e),this.state=bf,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Af=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`role-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Nf=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,Af,Ef)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([u(this,t,"m",i).call(this),this.actions.searchRoles(),this.actions.getTenantPermissions()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),jf=Rn((e=>{var t,i,n,o,r,s,a;return a=class extends(bn(Ef,nd,cc,Ur,Nf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,"create"),o.set(this,null),s.set(this,(()=>c(this,void 0,void 0,(function*(){var e;yield u(this,i,"f").setData(null===(e=Kh(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}openRoleModal(e="create",t){h(this,n,e,"f"),h(this,o,null!=t?t:null,"f"),this.roleFormModal.open()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",r).call(this)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,s=new WeakMap,t=new WeakSet,r=function(){return c(this,void 0,void 0,(function*(){this.roleFormModal=this.createModal(),this.roleFormModal.setContent($n(yield this.fetchWidgetPage("create-role-modal.html"))),new Ta((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)})),new Ta((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){if(this.validateForm(this.roleFormModal.ele)){const e=this.getFormData(this.roleFormModal.ele);"duplicate"===u(this,n,"f")?this.actions.duplicateRole(Object.assign({},e)):this.actions.createRole(Object.assign({},e)),this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}})))),h(this,i,new Ha((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),u(this,s,"f").call(this),this.roleFormModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){yield u(this,s,"f").call(this),u(this,o,"f")&&(this.setFormData(this.roleFormModal.ele,u(this,o,"f")),h(this,o,null,"f"))}))}))},a})),Mf=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,jf,Nf)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.createButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-role"]'),{logger:this.logger}),this.createButton.onClick((()=>this.openRoleModal()))},n})),Pf=Rn((e=>{var t,i,n;return n=class extends(bn(Ef,nd,Ur,Nf)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteRolesModal=this.createModal(),this.deleteRolesModal.setContent($n(yield this.fetchWidgetPage("delete-roles-modal.html")));const t=new Ta((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteRolesModal.close()));const i=new Ta((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=zh(this.state);this.actions.deleteRoles(null==e?void 0:e.map((e=>e.name))),this.deleteRolesModal.close()}));const n=new Za(null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteRolesModal.beforeOpen=()=>{const e=Yh(this.state);n.text=`Delete ${e}?`}}))},n})),Uf=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,Nf,Ef,Pf)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),Gh)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.deleteButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-roles"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteRolesModal.open()}))},o})),Tf=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,Nf,Ef,jf)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.duplicateButton.enable():this.duplicateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),Jh)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.duplicateButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="duplicate-role"]'),{logger:this.logger}),this.duplicateButton.disable(),this.duplicateButton.onClick((()=>{var e,t,i;const n=null===(e=zh(this.state))||void 0===e?void 0:e[0];n&&this.openRoleModal("duplicate",{name:`${n.name} Copy`,description:null!==(t=n.description)&&void 0!==t?t:"",permissionNames:null!==(i=n.permissionNames)&&void 0!==i?i:[]})}))},o})),Wf=Rn((e=>{var t,i,n,o,r,s,a,d;return d=class extends(bn(Ef,nd,Ur,cc,Nf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),r.set(this,(()=>c(this,void 0,void 0,(function*(){var e;yield u(this,i,"f").setData(null===(e=Kh(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))})))),s.set(this,(()=>{var e;const t=null===(e=zh(this.state))||void 0===e?void 0:e[0],i={name:null==t?void 0:t.name,description:null==t?void 0:t.description,permissionNames:null==t?void 0:t.permissionNames};this.setFormData(this.editRoleModal.ele,i)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",a).call(this)}))}},i=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,n=function(){new Ta((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editRoleModal.close()))},o=function(){new Ta((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{var e;if(this.validateForm(this.editRoleModal.ele)){const t=this.getFormData(this.editRoleModal.ele),{name:i}=t,n=l(t,["name"]),o=null===(e=zh(this.state))||void 0===e?void 0:e[0];this.actions.updateRole(Object.assign({newName:i,name:o.name},n)),this.editRoleModal.close(),this.resetFormData(this.editRoleModal.ele)}}))},a=function(){return c(this,void 0,void 0,(function*(){this.editRoleModal=this.createModal(),this.editRoleModal.setContent($n(yield this.fetchWidgetPage("edit-role-modal.html"))),u(this,t,"m",n).call(this),u(this,t,"m",o).call(this),h(this,i,new Ha((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),this.editRoleModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){yield u(this,r,"f").call(this),u(this,s,"f").call(this)}))}))},d})),Lf=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,Nf,Ef,Wf,cc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),Zh)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.editButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-role"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editRoleModal.open()}))},o})),Df=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,Nf,Ef)(e)){constructor(){super(...arguments),t.add(this),i.set(this,In((()=>{this.actions.searchRoles({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.searchInput=new Ya(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,i,"f"))},o})),_f={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="currentcolor"/>\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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Ff=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,Ef,rd,Fr)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Cn((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",n).call(this,e);r.setContent(u(this,t,"m",i).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),Vh)}))}},o=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const i=_f[e],n=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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${n.outerHTML}`},n=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),qf=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ef,Ur,Nf)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{this.rolesTable.data=e}))),o.set(this,In(((e,t)=>{const i=[],{value:n}=t;if(n){const t=e.path;i.push({field:t,desc:"desc"===n})}this.actions.searchRoles({sort:i})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),u(this,t,"m",i).call(this),this.rolesTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,o,"f").call(this,e.target,e.detail)}))})),u(this,n,"f").call(this,Hh(this.state)),this.subscribe(u(this,n,"f").bind(this),Hh)}))}},n=new WeakMap,o=new WeakMap,t=new WeakSet,i=function(){var e;this.rolesTable=new Fa(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="roles-table"]'),{logger:this.logger}),this.rolesTable.onSelectedItemsChange((e=>{this.actions.setSelectedRolesIds(e.detail.value.map((({name:e})=>e)))}))},r})),Bf=Rn((e=>class extends(bn(Ea,ps,qf,Mf,Uf,Tf,Lf,Df,Ff)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Vf=bn((e=>class extends(Bf(e)){}))(HTMLElement);customElements.define("descope-role-management-widget",Vf);var Kf=Object.freeze({__proto__:null,default:Vf});const Hf=(e={})=>{const t=$n("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,i])=>{t.content.querySelector("descope-wc").setAttribute(kn(e),i)})),t};function zf(e){return new URLSearchParams(window.location.search).get(e)}const Gf=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},Jf=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),Zf=ec("users/me",((e,{extra:{api:t}})=>t.user.me())),Yf=Gf(Zf)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Jf((e=>e.me))),Xf={action:Zf,reducer:Yf},Qf=ec("tenant/details",((e,{extra:{api:t}})=>t.tenant.details())),ep=Gf(Qf)({onFulfilled:(e,t)=>{e.tenant.data=t.payload}},Jf((e=>e.tenant))),tp={action:Qf,reducer:ep},ip=ec("tenant/adminLinkSso",((e,{extra:{api:t}})=>t.tenant.adminLinkSso())),np={action:ip,reducer:Gf(ip)({onFulfilled:(e,t)=>{var i;e.tenantAdminLinkSSO.data=(null===(i=t.payload)||void 0===i?void 0:i.adminSSOConfigurationLink)||""}},Jf((e=>e.tenantAdminLinkSSO)))},op={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:""}},rp="/v1/auth/me",sp="/v1/mgmt/tenant",ap="/v1/mgmt/tenant/adminlinks/sso/authenticated",dp=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),lp=({httpClient:e,tenantId:t,mock:i})=>{const n=encodeURIComponent(t||""),o=`?tenant=${n}&id=${n}`;return{details:()=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))}));if(!t)throw new Error("tenantId is not defined");const n=`${sp}${o}`,r=yield e.get(n);return yield dp(r),yield r.json()})),adminLinkSso:()=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({adminSSOConfigurationLink:"_blank"})}))}));if(!t)throw new Error("tenantId is not defined");const o=yield e.post(`${ap}?tenant=${n}`,{tenantId:n},{headers:{"Content-Type":"application/json"}});return yield dp(o),yield o.json()}))}},cp=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))}));const i=yield e.get(rp);return yield dp(i),i.json()}))}),up=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,Kr,fc)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||us}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i,n)=>{const o=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.6.3"}}));return{user:cp({httpClient:o.httpClient,mock:i}),tenant:lp({httpClient:o.httpClient,tenantId:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),hp=Rn((e=>{const t=bn(lc({name:"widget",initialState:op,reducers:{},extraReducers:e=>{Xf.reducer(e),tp.reducer(e),np.reducer(e)},asyncActions:{getMe:Xf.action,getTenant:tp.action,getTenantAdminLinkSSO:np.action}}),Fr,Ur,up)(e);return class extends t{constructor(...e){super(...e),this.state=op,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),fp="widget-flow",pp=Rn((e=>{var t,i,n;return n=class extends(bn(Fr,nd,hp,fc,Ur,ps)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const o=zf(fp);o&&(function(e){if(window.history.replaceState&&zf(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(fp),u(this,t,"m",i).call(this,o))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(Hf({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),new Wa((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()})),t.afterClose=()=>{t.remove()},t.open()},n})),gp=e=>e.tenant.data,vp=e=>e.tenantAdminLinkSSO.data,mp=wl(gp,(e=>e.customAttributes||{})),yp=wl(gp,(e=>e.name||"")),bp=wl(gp,(e=>e.selfProvisioningDomains||[])),$p=wl(gp,(e=>e.enforceSSOExclusions||[])),wp=wl(gp,(e=>e.enforceSSO||!1)),Cp=Rn((e=>class extends(bn(ps,qr)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),kp=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`tenant-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Sp=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,kp,hp)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()])}catch(n){}const o=this.state.me.error||(()=>this.state.tenant.error)()||(()=>this.state.tenantAdminLinkSSO.error)();if(o){this.contentRootElement.innerHTML="";const e="object"==typeof o&&null!==o&&"message"in o?o.message:String(o)||"An error occurred";this.contentRootElement.append(function({mainMessage:e="An error occurred"}){const t=document.createElement("div");t.setAttribute("data-id","widget-error"),t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="72px 36px",t.style.background="#fff",t.style.borderRadius="12px",t.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",t.style.margin="32px auto",t.style.maxWidth="400px";const i=document.createElement("div");i.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',i.style.marginBottom="12px",t.appendChild(i);const n=document.createElement("div");return n.textContent=e,n.style.fontWeight="bold",n.style.fontSize="20px",n.style.color="#222",n.style.textAlign="center",n.style.marginTop="8px",t.appendChild(n),t}({mainMessage:e}))}else yield u(this,t,"m",i).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),Ip=Rn((e=>{var t,i,n,o;return o=class extends(bn(Cp,hp,Ur,Sp,fc,nd)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{this.tenantAdminLinkSSODriver.href=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),u(this,n,"f").call(this,vp(this.state)),this.subscribe(u(this,n,"f").bind(this),vp)}))}},n=new WeakMap,t=new WeakSet,i=function(){this.tenantAdminLinkSSODriver=new qa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},o}));var Rp;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Rp||(Rp={}));const xp=Rn((e=>{var t,i,n,o,r,s,a,d,l,h,f;return f=class extends(bn(Cp,hp,Ur,Sp,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,{}),n.set(this,{}),o.set(this,{}),r.set(this,{}),d.set(this,Cn((e=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||Rp.TEXT,r=e[n],s=new Xa(i,{logger:this.logger});s.value=((e,t)=>e===Rp.DATE&&t?new Date(t).toLocaleString():e===Rp.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString())(o,r),u(this,t,"m",l).call(this,i,n,s,o,n),u(this,t,"m",h).call(this,i,n,s)}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),u(this,d,"f").call(this,mp(this.state)),this.subscribe(u(this,d,"f").bind(this),mp)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,d=new WeakMap,t=new WeakSet,s=function(e,t,o){var r,s;const a=mp(this.state)[o],d=t===Rp.ARRAY?(a||[]).join(","):a;null===(r=u(this,i,"f")[e])||void 0===r||r.setContent(Hf({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({customAttributes:{[o]:d}})})),null===(s=u(this,n,"f")[e])||void 0===s||s.onSuccess((()=>{var t;null===(t=u(this,i,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},a=function(e){var t,i;null===(t=u(this,o,"f")[e])||void 0===t||t.setContent(Hf({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(i=u(this,r,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=u(this,o,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},l=function(e,o,r,a,d){const l=e.getAttribute("edit-flow-id");l&&(u(this,i,"f")[l]||(u(this,i,"f")[l]=this.createModal({"data-id":`edit-${o}`}),u(this,n,"f")[l]=new Wa((()=>{var e,t;return null===(t=null===(e=u(this,i,"f")[l])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,i,"f")[l].beforeOpen=u(this,t,"m",s).bind(this,l,a,d),r.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,i,"f"))||void 0===e?void 0:e[l])||void 0===t||t.open()})),this.syncFlowTheme(u(this,n,"f")[l])))},h=function(e,i,n){const s=e.getAttribute("delete-flow-id");s&&(u(this,o,"f")[s]||(u(this,o,"f")[s]=this.createModal({"data-id":`delete-${i}`}),u(this,r,"f")[s]=new Wa((()=>{var e,t;return null===(t=null===(e=u(this,o,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,o,"f")[s].beforeOpen=u(this,t,"m",a).bind(this,s),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,o,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),this.syncFlowTheme(u(this,r,"f")[s])))},f})),Op=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Cp,hp,Ur,Sp,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.tenantEmailDomainsDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,bp(this.state)),this.subscribe(u(this,p,"f").bind(this),bp)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantEmailDomainsDriver.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(Hf({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({tenantEmailDomains:bp(this.state)})})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),h(this,r,new Wa((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(Hf({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEmailDomainsDriver=new Xa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),Ep=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Cp,hp,Ur,Sp,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.tenantSSOExclusionsDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,$p(this.state)),this.subscribe(u(this,p,"f").bind(this),$p)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantSSOExclusionsDriver.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(Hf({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({enforceSSOExclusions:$p(this.state)})})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),h(this,r,new Wa((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(Hf({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantSSOExclusionsDriver=new Xa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),Ap=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Cp,hp,Ur,Sp,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.tenantEnforceSSODriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,wp(this.state)),this.subscribe(u(this,p,"f").bind(this),wp)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantEnforceSSODriver.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(Hf({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({enforceSSO:wp(this.state)})})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantEnforceSSODriver.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),h(this,r,new Wa((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(Hf({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEnforceSSODriver=new Xa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),Np=Rn((e=>{var t,i,n,o,r,s,a,d;return d=class extends(bn(Cp,hp,Ur,Sp,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),a.set(this,Cn((e=>{this.tenantNameDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this),u(this,a,"f").call(this,yp(this.state)),this.subscribe(u(this,a,"f").bind(this),yp)}))}},i=new WeakMap,n=new WeakMap,a=new WeakMap,t=new WeakSet,o=function(){this.tenantNameDriver.editFlowId&&(h(this,i,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").beforeOpen=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,n,"f")))},r=function(){u(this,i,"f").setContent(Hf({projectId:this.projectId,flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({tenantName:yp(this.state)})})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},s=function(){this.tenantNameDriver=new Xa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},d})),jp=Rn((e=>{var t,i,n,o,r,s,a;return a=class extends(bn(Cp,hp,Ur,Sp,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this)}))}},i=new WeakMap,n=new WeakMap,t=new WeakSet,o=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(h(this,i,this.createModal({"data-id":"password-policy"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,n,"f")))},r=function(){u(this,i,"f").setContent(Hf({projectId:this.projectId,flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},s=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new Qa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},a})),Mp=Rn((e=>{var t,i,n,o,r,s,a;return a=class extends(bn(Cp,hp,Ur,Sp,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this)}))}},i=new WeakMap,n=new WeakMap,t=new WeakSet,o=function(){this.TenantSessionSettingsUserAuthMethodDriver.flowId&&(h(this,i,this.createModal({"data-id":"session-settings"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,n,"f")))},r=function(){u(this,i,"f").setContent(Hf({projectId:this.projectId,flowId:this.TenantSessionSettingsUserAuthMethodDriver.flowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},s=function(){this.TenantSessionSettingsUserAuthMethodDriver=new Qa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="session-settings"]')}),{logger:this.logger}),this.TenantSessionSettingsUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},a})),Pp=Rn((e=>class extends(bn(Ea,ps,pp,Sp,Np,Op,Ep,Ap,xp,Ip,jp,Mp)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Up=bn((e=>class extends(Pp(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Oa})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.6.3"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",Up);var Tp=Object.freeze({__proto__:null,default:Up}),Wp={version:4,country_calling_codes:{1:["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],383:["XK"],385:["HR"],386:["SI"],387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"],692:["MH"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],880:["BD"],886:["TW"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},countries:{AC:["247","00","(?:[01589]\\d|[46])\\d{4}",[5,6]],AD:["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]]],AE:["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0"],AF:["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0"],AG:["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([457]\\d{6})$|1","268$1",0,"268"],AI:["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2457]\\d{6})$|1","264$1",0,"264"],AL:["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0"],AM:["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0"],AO:["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]]],AR:["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1"],AS:["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"([267]\\d{6})$|1","684$1",0,"684"],AT:["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0"],AU:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"(183[12])|0",0,0,0,[["(?:(?:(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|7(?:[013-57-9]\\d|2[0-8]))\\d|3(?:(?:[0-3589]\\d|6[1-9]|7[0-35-9])\\d|4(?:[0-578]\\d|90)))\\d\\d|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4])|3\\d\\d)|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],AW:["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],AX:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],AZ:["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],BA:["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],BB:["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246"],BD:["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|2[23]"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],BE:["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],BF:["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],BG:["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],BH:["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[02-4679]"]]]],BI:["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]]],BJ:["229","00","(?:01\\d|[24-689])\\d{7}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["0"]]]],BL:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:2[7-9]|3[3-7]|5[12]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],BM:["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441"],BN:["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],BO:["591","00(?:1\\d)?","8001\\d{5}|(?:[2-467]\\d|50)\\d{6}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[235]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],BQ:["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],BR:["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-46-9]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37)","4(?:02|37)0|[34]00"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],BS:["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242"],BT:["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],BW:["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-9]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],BY:["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],BZ:["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],CA:["1","011","[2-9]\\d{9}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|9(?:0[25]|42))[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:2[125-9]|33|44|66|77|88)|6(?:22|33))[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CD:["243","00","(?:(?:[189]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["5"],"0$1"]],"0"],CF:["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],CG:["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],CH:["41","00","8\\d{11}|[2-9]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],CI:["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],CK:["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],CL:["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],CM:["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],CN:["86","00|1(?:[12]\\d|79)\\d\\d00","(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]","(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,0,"00"],CO:["57","00(?:4(?:[14]4|56)|[579])","(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["46"]],["(\\d{3})(\\d{7})","$1 $2",["6|90"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|91"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?"],CR:["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))"],CU:["53","119","(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["[56]"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],CV:["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],CW:["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],CX:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CY:["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],CZ:["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9,10,11,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],DE:["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[03568]","15(?:[0568]|31)"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8})","$1 $2 $3",["15"],"0$1"]],"0"],DJ:["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]]],DK:["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]]],DM:["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","767$1",0,"767"],DO:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9"],DZ:["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0"],EC:["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0"],EE:["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],EG:["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{8})","$1 $2",["1"],"0$1"]],"0"],EH:["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,"528[89]"],ER:["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0"],ES:["34","00","[5-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-9]"]]]],ET:["251","00","(?:11|[2-579]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-579]"],"0$1"]],"0"],FI:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d{5})","$1",["20[2-59]"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]0|[68])0|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[14]|2[09]|50|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"],["(\\d)(\\d{4,9})","$1 $2",["(?:19|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",0,"00"],FJ:["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,0,"00"],FK:["500","00","[2-7]\\d{4}",[5]],FM:["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]]],FO:["298","00","[2-9]\\d{5}",[6],[["(\\d{6})","$1",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))"],FR:["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0"],GA:["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})","$1"],GB:["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,0,0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0-35])|4(?:(?:[0-5]\\d|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|50))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-3]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],GD:["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473"],GE:["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],GF:["594","00","(?:[56]94\\d|7093)\\d{5}|(?:80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0"],GG:["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],GH:["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],GI:["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],GL:["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],GM:["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],GN:["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],GP:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],GQ:["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],GR:["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],GT:["502","00","80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-8]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],GU:["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","671$1",0,"671"],GW:["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]]],GY:["592","001","(?:[2-8]\\d{3}|9008)\\d{3}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],HK:["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,0,"00"],HN:["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]]],HR:["385","00","(?:[24-69]\\d|3[0-79])\\d{7}|80\\d{5,7}|[1-79]\\d{7}|6\\d{5,6}",[6,7,8,9],[["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6|7[245]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-57]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0"],HT:["509","00","(?:[2-489]\\d|55)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-589]"]]]],HU:["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06"],ID:["62","00[89]","00[1-9]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13,14,15,16,17],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0"],IE:["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0"],IL:["972","0(?:0|1[2-9])","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["15"]]],"0"],IM:["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([25-8]\\d{5})$|0","1624$1",0,"74576|(?:16|7[56])24"],IN:["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-7]|80[2-46]","11|2[02]|33|4[04]|79(?:[1-6]|7[19])|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9])|7(?:1|9[1-6]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|4[47]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67|72)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:2[14]|3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31|4[47])|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:(?:2[14]|5[15])[2-6]|3171|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|(?:74[47]|8(?:16|2[014]|3[126]|6[136]|7[78]|83))(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|28|3[129]|4[1-35689]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1(?:[013-8]|9[6-9])|28[6-8]|3(?:17|2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|83)|73179|807(?:1|9[1-3])|(?:1552|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[124-6])\\d|7(?:1(?:[013-8]\\d|9[6-9])|28[6-8]|3(?:2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]\\d|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["1(?:6|8[06])","1(?:6|8[06]0)"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0"],IO:["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]]],IQ:["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],IR:["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0"],IS:["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,0,"00"],IT:["39","00","0\\d{5,10}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:43|55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11,12],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[378]|43"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["3"]]],0,0,0,0,0,0,[["0669[0-79]\\d{1,6}|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}",[6,7,8,9,10,11]],["3[2-9]\\d{7,8}|(?:31|43)\\d{8}",[9,10]],["80(?:0\\d{3}|3)\\d{3}",[6,9]],["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}",[6,8,9,10]],["1(?:78\\d|99)\\d{6}",[9,10]],["3[2-8]\\d{9,10}",[11,12]],0,0,["55\\d{8}",[10]],["84(?:[08]\\d{3}|[17])\\d{3}",[6,9]]]],JE:["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([0-24-8]\\d{5})$|0","1534$1",0,0,[["1534[0-24-8]\\d{5}"],["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97\\d))\\d{5}"],["80(?:07(?:35|81)|8901)\\d{4}"],["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"],["701511\\d{4}"],0,["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}"],["56\\d{8}"]]],JM:["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876"],JO:["962","00","(?:(?:[2689]|7\\d)\\d|32|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],JP:["81","010","00[1-9]\\d{6,14}|[25-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51)|9(?:80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["3|4(?:2[09]|7[01])|6[1-9]","3|4(?:2(?:0|9[02-69])|7(?:0[019]|1))|6[1-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[0459]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[26-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9]|9[29])|5(?:2|3(?:[045]|9[0-8])|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3(?:[045]|9(?:[0-58]|6[4-9]|7[0-35689]))|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[25-9]"],"0$1"]],"0",0,"(000[259]\\d{6})$|(?:(?:003768)0?)|0","$1"],KE:["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0"],KG:["996","00","8\\d{9}|[235-9]\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0"],KH:["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],KI:["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0"],KM:["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]]],KN:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","869$1",0,"869"],KP:["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0"],KR:["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[36]0|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?"],KW:["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]]],KY:["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","345$1",0,"345"],KZ:["7","810","(?:33622|8\\d{8})\\d{5}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"33|7",0,"8~10"],LA:["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["30[0135-9]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0"],LB:["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-7]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0"],LC:["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"([2-8]\\d{6})$|1","758$1",0,"758"],LI:["423","00","[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2379]|8(?:0[09]|7)","[2379]|8(?:0(?:02|9)|7)"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"(1001)|0"],LK:["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0"],LR:["231","00","(?:[245]\\d|33|77|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["4[67]|[56]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-578]"],"0$1"]],"0"],LS:["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]]],LT:["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(0-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"0 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(0-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(0-$1)",1]],"0",0,"[08]"],LU:["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],LV:["371","00","(?:[268]\\d|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[269]|8[01]"]]]],LY:["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0"],MA:["212","00","[5-8]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-46-9]|3[3-9]|9)|8(?:0[89]|92)"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8"],"0$1"],["(\\d{3})(\\d{6})","$1-$2",["[5-7]"],"0$1"]],"0",0,0,0,0,0,[["5(?:2(?:[0-25-79]\\d|3[1-578]|4[02-46-8]|8[0235-7])|3(?:[0-47]\\d|5[02-9]|6[02-8]|8[014-9]|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-4]|5[01]|8[0-3]))\\d{6}"],["80[0-7]\\d{6}"],["89\\d{7}"],0,0,0,0,["(?:592(?:4[0-2]|93)|80[89]\\d\\d)\\d{4}"]]],MC:["377","00","(?:[3489]|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1"]],"0"],MD:["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0"],ME:["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0"],MF:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:0[079]|[14]3|[27][79]|3[03-7]|5[0-268]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],MG:["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1"],MH:["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],MK:["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],ML:["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],MM:["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|452|678|86","[12]|452|6788|86"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],MN:["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],MO:["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],MP:["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670"],MQ:["596","00","(?:596\\d|7091)\\d{5}|(?:69|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|8(?:0[6-9]|[36])"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],MR:["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],MS:["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664"],MT:["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],MU:["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],MV:["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],MW:["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],MX:["52","0[09]","[2-9]\\d{9}",[10],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"]]],0,0,0,0,0,0,0,"00"],MY:["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9]|53)|8","1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1(?:[367]|80)"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0"],MZ:["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-79]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],NA:["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],NC:["687","00","(?:050|[2-57-9]\\d\\d)\\d{3}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[02-57-9]"]]]],NE:["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[0467]"]]]],NF:["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1"],NG:["234","009","38\\d{6}|[78]\\d{9,13}|(?:20|9\\d)\\d{8}",[8,10,11,12,13,14],[["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["3"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["20[129]"],"0$1"],["(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],NI:["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],NL:["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],NP:["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],NR:["674","00","(?:444|(?:55|8\\d)\\d|666)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[4-68]"]]]],NU:["683","00","(?:[4-7]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],NZ:["64","0(?:0|161)","[1289]\\d{9}|50\\d{5}(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|8|90","50(?:[0367]|88)|8|90"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[589]"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7"],"0$1"]],"0",0,0,0,0,0,0,"00"],OM:["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]]],PA:["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]]],PE:["51","00|19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,0,"00"," Anexo "],PF:["689","00","4\\d{5}(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],PG:["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,0,"00"],PH:["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0"],PK:["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0"],PL:["48","00","(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|20|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]]],PM:["508","00","[45]\\d{5}|(?:708|8\\d\\d)\\d{6}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[45]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],PR:["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939"],PS:["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],PT:["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]]],PW:["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],PY:["595","00","59\\d{4,6}|9\\d{5,10}|(?:[2-46-8]\\d|5[0-8])\\d{4,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[26]1|3[289]|4[1246-8]|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0"],QA:["974","00","800\\d{4}|(?:2|800)\\d{6}|(?:0080|[3-7])\\d{7}",[7,8,9,11],[["(\\d{3})(\\d{4})","$1 $2",["2[16]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]]],RE:["262","00","709\\d{6}|(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"],"0$1"]],"0",0,0,0,0,0,[["26(?:2\\d\\d|3(?:0\\d|1[0-6]))\\d{4}"],["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[013]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-5]|76(?:2[278]|3[0-37]))\\d{4}"],["8(?:1[019]|2[0156]|84|90)\\d{6}"]]],RO:["40","00","(?:[236-8]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[236-9]"],"0$1"]],"0",0,0,0,0,0,0,0," int "],RS:["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0"],RU:["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"3[04-689]|[489]",0,"8~10"],RW:["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"]],"0"],SA:["966","00","92\\d{7}|(?:[15]|8\\d)\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0"],SB:["677","0[01]","[6-9]\\d{6}|[1-6]\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],SC:["248","010|0[0-2]","(?:[2489]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,0,"00"],SD:["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0"],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10,12],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0"],SG:["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-9]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],SH:["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]"],SI:["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[0139]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,0,"00"],SJ:["47","00","0\\d{4}|(?:[489]\\d|79)\\d{6}",[5,8],0,0,0,0,0,0,"79"],SK:["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1"]],"0"],SL:["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0"],SM:["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1"],SN:["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]]]],SO:["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d)(\\d{7})","$1 $2",["(?:2|90)4|[67]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[348]|64|79|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6[0-35-9]|77|9[2-9]"]]],"0"],SR:["597","00","(?:[2-5]|68|[78]\\d)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-8]"]]]],SS:["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0"],ST:["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]]],SV:["503","00","[267]\\d{7}|(?:80\\d|900)\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],SX:["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721"],SY:["963","00","[1-359]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-4]|5[1-3]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[59]"],"0$1",1]],"0"],SZ:["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],TA:["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],TC:["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649"],TD:["235","00|16","(?:22|[689]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"]]],0,0,0,0,0,0,0,"00"],TG:["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],TH:["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],TJ:["992","810","[0-57-9]\\d{8}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["44[02-479]|[34]7"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3(?:[1245]|3[12])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[0-57-9]"]]],0,0,0,0,0,0,0,"8~10"],TK:["690","00","[2-47]\\d{3,6}",[4,5,6,7]],TL:["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]]],TM:["993","810","(?:[1-6]\\d|71)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["[67]"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],TN:["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]]],TO:["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]]],TR:["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5(?:[0-59]|61)","5(?:[0-59]|61[06])","5(?:[0-59]|61[06]1)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],TT:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868"],TV:["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],TW:["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],TZ:["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],UA:["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],UG:["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],US:["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["(?:3052(?:0[0-8]|[1-9]\\d)|5056(?:[0-35-9]\\d|4[468]))\\d{4}|(?:305[3-9]|472[24]|505[2-57-9]|983[2-47-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[125-9]|33|44|66|77|88)[2-9]\\d{6}"],0,0,0,["305209\\d{4}"]]],UY:["598","0(?:0|1[3-9]\\d)","0004\\d{2,9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[6,7,8,9,10,11,12,13],[["(\\d{3})(\\d{3,4})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[49]0|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,0,"00"," int. "],UZ:["998","00","(?:20|33|[5-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-9]"]]]],VA:["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11,12],0,0,0,0,0,0,"06698"],VC:["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","784$1",0,"784"],VE:["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0"],VG:["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-578]\\d{6})$|1","284$1",0,"284"],VI:["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","340$1",0,"340"],VN:["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{7}|[16-8]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["80"],"0$1",1],["(\\d{4})(\\d{4,6})","$1 $2",["1"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["6"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[357-9]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0"],VU:["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]]],WF:["681","00","(?:40|72|8\\d{4})\\d{4}|[89]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[47-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],WS:["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],XK:["383","00","2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}",[8,9,10,11,12],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2|39"],"0$1"],["(\\d{2})(\\d{7,10})","$1 $2",["3"],"0$1"]],"0"],YE:["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7(?:[24-6]|8[0-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0"],YT:["262","00","7093\\d{5}|(?:80|9\\d)\\d{7}|(?:26|63)9\\d{6}",[9],0,"0",0,0,0,0,0,[["269(?:0[0-467]|15|5[0-4]|6\\d|[78]0)\\d{4}"],["(?:639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])|7093[5-7])\\d{4}"],["80\\d{7}"],0,0,0,0,0,["9(?:(?:39|47)8[01]|769\\d)\\d{4}"]]],ZA:["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],ZM:["260","00","800\\d{6}|(?:21|63|[79]\\d)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[79]"],"0$1"]],"0"],ZW:["263","00","2(?:[0-57-9]\\d{6,8}|6[0-24-9]\\d{6,7})|[38]\\d{9}|[35-8]\\d{8}|[3-6]\\d{7}|[1-689]\\d{6}|[1-3569]\\d{5}|[1356]\\d{4}",[5,6,7,8,9,10],[["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|2[278]|[49]8)|3(?:[09]8|17)|6(?:[29]8|37|75)|[23][78]|(?:33|5[15]|6[68])[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["24|8[13-59]|(?:2[05-79]|39|5[45]|6[15-8])2","2(?:02[014]|4|[56]20|[79]2)|392|5(?:42|525)|6(?:[16-8]21|52[013])|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[39]|2[0157]|[378]|[56][14])|3(?:12|29)","2(?:1[39]|2[0157]|[378]|[56][14])|3(?:123|29)"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|12|29|[56])|3(?:1[0-689]|[24-6])|5(?:[0236-9]|1[2-4])|6(?:[013-59]|7[0-46-9])|(?:33|55|6[68])[0-69]|(?:29|3[09]|62)[0-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]|39|54"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["(?:25|54)8","258|5483"],"0$1"]],"0"]},nonGeographic:{800:["800",0,"(?:00|[1-9]\\d)\\d{6}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:00|[1-9]\\d)\\d{6}"]]],808:["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],870:["870",0,"7\\d{11}|[235-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"],0,0,0,0,0,0,["2\\d{8}",[9]]]],878:["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],881:["881",0,"6\\d{9}|[0-36-9]\\d{8}",[9,10],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-37-9]"]],["(\\d)(\\d{3})(\\d{5,6})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["6\\d{9}|[0-36-9]\\d{8}"]]],882:["882",0,"[13]\\d{6}(?:\\d{2,5})?|[19]\\d{7}|(?:[25]\\d\\d|4)\\d{7}(?:\\d{2})?",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["49"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1[36]|9"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|23|3(?:[15]|4[57])|4|51"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-35]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|(?:3(?:2|47|7\\d{3})|50\\d{3})\\d{7}",[7,8,9,10,12]],0,0,0,["348[57]\\d{7}",[11]],0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:345\\d|9[89])\\d{6}|(?:10|2(?:3|85\\d)|3(?:[15]|[69]\\d\\d)|4[15-8]|51)\\d{8}"]]],883:["883",0,"(?:[1-4]\\d|51)\\d{6,10}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,8})","$1 $2 $3",["[14]|2[24-689]|3[02-689]|51[24-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["21"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[235]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:2(?:00\\d\\d|10)|(?:370[1-9]|51\\d0)\\d)\\d{7}|51(?:00\\d{5}|[24-9]0\\d{4,7})|(?:1[0-79]|2[24-689]|3[02-689]|4[0-4])0\\d{5,9}"]]],888:["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],979:["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};function Lp(e){return Lp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Lp(e)}function Dp(e){var t=Bp();return function(){var i,n=Kp(e);if(t){var o=Kp(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return function(e,t){if(t&&("object"===Lp(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _p(e)}(this,i)}}function _p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Fp(e){var t="function"==typeof Map?new Map:void 0;return Fp=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return qp(e,arguments,Kp(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Vp(n,e)},Fp(e)}function qp(e,t,i){return qp=Bp()?Reflect.construct:function(e,t,i){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return i&&Vp(o,i.prototype),o},qp.apply(null,arguments)}function Bp(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function Vp(e,t){return Vp=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Vp(e,t)}function Kp(e){return Kp=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Kp(e)}var Hp=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Vp(e,t)}(n,e);var t,i=Dp(n);function n(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),t=i.call(this,e),Object.setPrototypeOf(_p(t),n.prototype),t.name=t.constructor.name,t}return t=n,Object.defineProperty(t,"prototype",{writable:!1}),t}(Fp(Error)),zp=2,Gp=17,Jp=3,Zp="0-90-9٠-٩۰-۹",Yp="".concat("-‐-―−ー-").concat("//").concat("..").concat(" ").concat("()()[]\\[\\]").concat("~⁓∼~"),Xp="++";function Qp(e,t){e=e.split("-"),t=t.split("-");for(var i=e[0].split("."),n=t[0].split("."),o=0;o<3;o++){var r=Number(i[o]),s=Number(n[o]);if(r>s)return 1;if(s>r)return-1;if(!isNaN(r)&&isNaN(s))return 1;if(isNaN(r)&&!isNaN(s))return-1}return e[1]&&t[1]?e[1]>t[1]?1:e[1]<t[1]?-1:0:!e[1]&&t[1]?1:e[1]&&!t[1]?-1:0}var eg={}.constructor;function tg(e){return null!=e&&e.constructor===eg}function ig(e){return ig="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ig(e)}function ng(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function og(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var rg=" ext. ",sg=/^\d+$/,ag=function(){function e(t){ng(this,e),function(e){if(!e)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!tg(e)||!tg(e.countries))throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(tg(e)?"an object of shape: { "+Object.keys(e).join(", ")+" }":"a "+fg(e)+": "+e,"."))}(t),this.metadata=t,vg.call(this,t)}return og(e,[{key:"getCountries",value:function(){return Object.keys(this.metadata.countries).filter((function(e){return"001"!==e}))}},{key:"getCountryMetadata",value:function(e){return this.metadata.countries[e]}},{key:"nonGeographic",value:function(){if(!(this.v1||this.v2||this.v3))return this.metadata.nonGeographic||this.metadata.nonGeographical}},{key:"hasCountry",value:function(e){return void 0!==this.getCountryMetadata(e)}},{key:"hasCallingCode",value:function(e){if(this.getCountryCodesForCallingCode(e))return!0;if(this.nonGeographic()){if(this.nonGeographic()[e])return!0}else{var t=this.countryCallingCodes()[e];if(t&&1===t.length&&"001"===t[0])return!0}}},{key:"isNonGeographicCallingCode",value:function(e){return this.nonGeographic()?!!this.nonGeographic()[e]:!this.getCountryCodesForCallingCode(e)}},{key:"country",value:function(e){return this.selectNumberingPlan(e)}},{key:"selectNumberingPlan",value:function(e,t){if(e&&sg.test(e)&&(t=e,e=null),e&&"001"!==e){if(!this.hasCountry(e))throw new Error("Unknown country: ".concat(e));this.numberingPlan=new dg(this.getCountryMetadata(e),this)}else if(t){if(!this.hasCallingCode(t))throw new Error("Unknown calling code: ".concat(t));this.numberingPlan=new dg(this.getNumberingPlanMetadata(t),this)}else this.numberingPlan=void 0;return this}},{key:"getCountryCodesForCallingCode",value:function(e){var t=this.countryCallingCodes()[e];if(t){if(1===t.length&&3===t[0].length)return;return t}}},{key:"getCountryCodeForCallingCode",value:function(e){var t=this.getCountryCodesForCallingCode(e);if(t)return t[0]}},{key:"getNumberingPlanMetadata",value:function(e){var t=this.getCountryCodeForCallingCode(e);if(t)return this.getCountryMetadata(t);if(this.nonGeographic()){var i=this.nonGeographic()[e];if(i)return i}else{var n=this.countryCallingCodes()[e];if(n&&1===n.length&&"001"===n[0])return this.metadata.countries["001"]}}},{key:"countryCallingCode",value:function(){return this.numberingPlan.callingCode()}},{key:"IDDPrefix",value:function(){return this.numberingPlan.IDDPrefix()}},{key:"defaultIDDPrefix",value:function(){return this.numberingPlan.defaultIDDPrefix()}},{key:"nationalNumberPattern",value:function(){return this.numberingPlan.nationalNumberPattern()}},{key:"possibleLengths",value:function(){return this.numberingPlan.possibleLengths()}},{key:"formats",value:function(){return this.numberingPlan.formats()}},{key:"nationalPrefixForParsing",value:function(){return this.numberingPlan.nationalPrefixForParsing()}},{key:"nationalPrefixTransformRule",value:function(){return this.numberingPlan.nationalPrefixTransformRule()}},{key:"leadingDigits",value:function(){return this.numberingPlan.leadingDigits()}},{key:"hasTypes",value:function(){return this.numberingPlan.hasTypes()}},{key:"type",value:function(e){return this.numberingPlan.type(e)}},{key:"ext",value:function(){return this.numberingPlan.ext()}},{key:"countryCallingCodes",value:function(){return this.v1?this.metadata.country_phone_code_to_countries:this.metadata.country_calling_codes}},{key:"chooseCountryByCountryCallingCode",value:function(e){return this.selectNumberingPlan(e)}},{key:"hasSelectedNumberingPlan",value:function(){return void 0!==this.numberingPlan}}]),e}(),dg=function(){function e(t,i){ng(this,e),this.globalMetadataObject=i,this.metadata=t,vg.call(this,i.metadata)}return og(e,[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"IDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[1]}},{key:"defaultIDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[12]}},{key:"nationalNumberPattern",value:function(){return this.v1||this.v2?this.metadata[1]:this.metadata[2]}},{key:"possibleLengths",value:function(){if(!this.v1)return this.metadata[this.v2?2:3]}},{key:"_getFormats",value:function(e){return e[this.v1?2:this.v2?3:4]}},{key:"formats",value:function(){var e=this,t=this._getFormats(this.metadata)||this._getFormats(this.getDefaultCountryMetadataForRegion())||[];return t.map((function(t){return new lg(t,e)}))}},{key:"nationalPrefix",value:function(){return this.metadata[this.v1?3:this.v2?4:5]}},{key:"_getNationalPrefixFormattingRule",value:function(e){return e[this.v1?4:this.v2?5:6]}},{key:"nationalPrefixFormattingRule",value:function(){return this._getNationalPrefixFormattingRule(this.metadata)||this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion())}},{key:"_nationalPrefixForParsing",value:function(){return this.metadata[this.v1?5:this.v2?6:7]}},{key:"nationalPrefixForParsing",value:function(){return this._nationalPrefixForParsing()||this.nationalPrefix()}},{key:"nationalPrefixTransformRule",value:function(){return this.metadata[this.v1?6:this.v2?7:8]}},{key:"_getNationalPrefixIsOptionalWhenFormatting",value:function(){return!!this.metadata[this.v1?7:this.v2?8:9]}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata)||this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion())}},{key:"leadingDigits",value:function(){return this.metadata[this.v1?8:this.v2?9:10]}},{key:"types",value:function(){return this.metadata[this.v1?9:this.v2?10:11]}},{key:"hasTypes",value:function(){return(!this.types()||0!==this.types().length)&&!!this.types()}},{key:"type",value:function(e){if(this.hasTypes()&&hg(this.types(),e))return new ug(hg(this.types(),e),this)}},{key:"ext",value:function(){return this.v1||this.v2?rg:this.metadata[13]||rg}}]),e}(),lg=function(){function e(t,i){ng(this,e),this._format=t,this.metadata=i}return og(e,[{key:"pattern",value:function(){return this._format[0]}},{key:"format",value:function(){return this._format[1]}},{key:"leadingDigitsPatterns",value:function(){return this._format[2]||[]}},{key:"nationalPrefixFormattingRule",value:function(){return this._format[3]||this.metadata.nationalPrefixFormattingRule()}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return!!this._format[4]||this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"nationalPrefixIsMandatoryWhenFormattingInNationalFormat",value:function(){return this.usesNationalPrefix()&&!this.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"usesNationalPrefix",value:function(){return!(!this.nationalPrefixFormattingRule()||cg.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}]),e}(),cg=/^\(?\$1\)?$/,ug=function(){function e(t,i){ng(this,e),this.type=t,this.metadata=i}return og(e,[{key:"pattern",value:function(){return this.metadata.v1?this.type:this.type[0]}},{key:"possibleLengths",value:function(){if(!this.metadata.v1)return this.type[1]||this.metadata.possibleLengths()}}]),e}();function hg(e,t){switch(t){case"FIXED_LINE":return e[0];case"MOBILE":return e[1];case"TOLL_FREE":return e[2];case"PREMIUM_RATE":return e[3];case"PERSONAL_NUMBER":return e[4];case"VOICEMAIL":return e[5];case"UAN":return e[6];case"PAGER":return e[7];case"VOIP":return e[8];case"SHARED_COST":return e[9]}}var fg=function(e){return ig(e)};function pg(e,t){if((t=new ag(t)).hasCountry(e))return t.country(e).countryCallingCode();throw new Error("Unknown country: ".concat(e))}function gg(e,t){return t.countries.hasOwnProperty(e)}function vg(e){var t=e.version;"number"==typeof t?(this.v1=1===t,this.v2=2===t,this.v3=3===t,this.v4=4===t):t?-1===Qp(t,"1.2.0")?this.v2=!0:-1===Qp(t,"1.7.35")?this.v3=!0:this.v4=!0:this.v1=!0}var mg=function(e){return"([".concat(Zp,"]{1,").concat(e,"})")};function yg(e){var t="[ \\t,]*",i="[:\\..]?[ \\t,-]*",n="#?",o="[ \\t]*";return";ext="+mg("20")+"|"+(t+"(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)"+i+mg("20")+n)+"|"+(t+"(?:[xx##~~]|int|int)"+i+mg("9")+n)+"|"+("[- ]+"+mg("6")+"#")+"|"+(o+"(?:,{2}|;)"+i+mg("15")+n)+"|"+(o+"(?:,)+"+i+mg("9")+n)}var bg="["+Zp+"]{"+zp+"}",$g="[++]{0,1}(?:["+Yp+"]*["+Zp+"]){3,}["+Yp+Zp+"]*",wg=new RegExp("^[++]{0,1}(?:["+Yp+"]*["+Zp+"]){1,2}$","i"),Cg=$g+"(?:"+yg()+")?",kg=new RegExp("^"+bg+"$|^"+Cg+"$","i");var Sg=new RegExp("(?:"+yg()+")$","i");function Ig(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Rg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Rg(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Rg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var xg={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"};function Og(e){return xg[e]}function Eg(e){for(var t,i="",n=Ig(e.split(""));!(t=n()).done;){var o=Og(t.value);o&&(i+=o)}return i}function Ag(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Ng(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Ng(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ng(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function jg(e){for(var t,i="",n=Ag(e.split(""));!(t=n()).done;){i+=Mg(t.value,i)||""}return i}function Mg(e,t,i){if("+"===e){if(t)return;return"+"}return Og(e)}function Pg(e,t){return function(e,t,i){var n=i.type(t),o=n&&n.possibleLengths()||i.possibleLengths();if(!o)return"IS_POSSIBLE";var r=e.length,s=o[0];if(s===r)return"IS_POSSIBLE";if(s>r)return"TOO_SHORT";if(o[o.length-1]<r)return"TOO_LONG";return o.indexOf(r,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}(e,void 0,t)}function Ug(e,t){return"IS_POSSIBLE"===Pg(e,t)}function Tg(e,t){return e=e||"",new RegExp("^(?:"+t+")$").test(e)}function Wg(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Lg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Lg(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Lg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var Dg=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function _g(e,t,i){if(t=t||{},e.country||e.countryCallingCode){(i=new ag(i)).selectNumberingPlan(e.country,e.countryCallingCode);var n=t.v2?e.nationalNumber:e.phone;if(Tg(n,i.nationalNumberPattern())){if(Fg(n,"FIXED_LINE",i))return i.type("MOBILE")&&""===i.type("MOBILE").pattern()?"FIXED_LINE_OR_MOBILE":i.type("MOBILE")?Fg(n,"MOBILE",i)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE":"FIXED_LINE_OR_MOBILE";for(var o,r=Wg(Dg);!(o=r()).done;){var s=o.value;if(Fg(n,s,i))return s}}}}function Fg(e,t,i){return!(!(t=i.type(t))||!t.pattern())&&(!(t.possibleLengths()&&t.possibleLengths().indexOf(e.length)<0)&&Tg(e,t.pattern()))}function qg(e,t,i){var n=new ag(i).getCountryCodesForCallingCode(e);return n?n.filter((function(e){return function(e,t,i){var n=new ag(i);if(n.selectNumberingPlan(t),n.numberingPlan.possibleLengths().indexOf(e.length)>=0)return!0;return!1}(t,e,i)})):[]}function Bg(e){return e.replace(new RegExp("[".concat(Yp,"]+"),"g")," ").trim()}var Vg=/(\$\d)/;function Kg(e,t,i){var n=i.useInternationalFormat,o=i.withNationalPrefix;i.carrierCode,i.metadata;var r=e.replace(new RegExp(t.pattern()),n?t.internationalFormat():o&&t.nationalPrefixFormattingRule()?t.format().replace(Vg,t.nationalPrefixFormattingRule()):t.format());return n?Bg(r):r}var Hg=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function zg(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Gg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Gg(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Gg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Jg(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Zg(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Jg(Object(i),!0).forEach((function(t){Yg(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Jg(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Yg(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var Xg={formatExtension:function(e,t,i){return"".concat(e).concat(i.ext()).concat(t)}};function Qg(e,t,i,n){if(i=i?Zg(Zg({},Xg),i):Xg,n=new ag(n),e.country&&"001"!==e.country){if(!n.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));n.country(e.country)}else{if(!e.countryCallingCode)return e.phone||"";n.selectNumberingPlan(e.countryCallingCode)}var o,r=n.countryCallingCode(),s=i.v2?e.nationalNumber:e.phone;switch(t){case"NATIONAL":return s?iv(o=ev(s,e.carrierCode,"NATIONAL",n,i),e.ext,n,i.formatExtension):"";case"INTERNATIONAL":return s?(o=ev(s,null,"INTERNATIONAL",n,i),iv(o="+".concat(r," ").concat(o),e.ext,n,i.formatExtension)):"+".concat(r);case"E.164":return"+".concat(r).concat(s);case"RFC3966":return function(e){var t=e.number,i=e.ext;if(!t)return"";if("+"!==t[0])throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(t).concat(i?";ext="+i:"")}({number:"+".concat(r).concat(s),ext:e.ext});case"IDD":if(!i.fromCountry)return;var a=function(e,t,i,n,o){var r=pg(n,o.metadata);if(r===i){var s=ev(e,t,"NATIONAL",o);return"1"===i?i+" "+s:s}var a=function(e,t,i){var n=new ag(i);return n.selectNumberingPlan(e,t),n.defaultIDDPrefix()?n.defaultIDDPrefix():Hg.test(n.IDDPrefix())?n.IDDPrefix():void 0}(n,void 0,o.metadata);if(a)return"".concat(a," ").concat(i," ").concat(ev(e,null,"INTERNATIONAL",o))}(s,e.carrierCode,r,i.fromCountry,n);return iv(a,e.ext,n,i.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(t,'"'))}}function ev(e,t,i,n,o){var r=tv(n.formats(),e);return r?Kg(e,r,{useInternationalFormat:"INTERNATIONAL"===i,withNationalPrefix:!r.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||!o||!1!==o.nationalPrefix,carrierCode:t,metadata:n}):e}function tv(e,t){for(var i,n=zg(e);!(i=n()).done;){var o=i.value;if(o.leadingDigitsPatterns().length>0){var r=o.leadingDigitsPatterns()[o.leadingDigitsPatterns().length-1];if(0!==t.search(r))continue}if(Tg(t,o.pattern()))return o}}function iv(e,t,i,n){return t?n(e,t,i):e}function nv(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function ov(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?nv(Object(i),!0).forEach((function(t){rv(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):nv(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function rv(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function sv(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var av=function(){function e(t,i,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw new TypeError("`country` or `countryCallingCode` not passed");if(!i)throw new TypeError("`nationalNumber` not passed");if(!n)throw new TypeError("`metadata` not passed");var o=function(e,t){var i,n,o=new ag(t);dv(e)?(i=e,o.selectNumberingPlan(i),n=o.countryCallingCode()):n=e;return{country:i,countryCallingCode:n}}(t,n),r=o.country,s=o.countryCallingCode;this.country=r,this.countryCallingCode=s,this.nationalNumber=i,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return n}}return sv(e,[{key:"setExt",value:function(e){this.ext=e}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:qg(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return function(e,t,i){if(void 0===t&&(t={}),i=new ag(i),t.v2){if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");i.selectNumberingPlan(e.countryCallingCode)}else{if(!e.phone)return!1;if(e.country){if(!i.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));i.country(e.country)}else{if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");i.selectNumberingPlan(e.countryCallingCode)}}if(i.possibleLengths())return Ug(e.phone||e.nationalNumber,i);if(e.countryCallingCode&&i.isNonGeographicCallingCode(e.countryCallingCode))return!0;throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return function(e,t,i){return t=t||{},(i=new ag(i)).selectNumberingPlan(e.country,e.countryCallingCode),i.hasTypes()?void 0!==_g(e,t,i.metadata):Tg(t.v2?e.nationalNumber:e.phone,i.nationalNumberPattern())}(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){return new ag(this.getMetadata()).isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(e){return this.number===e.number&&this.ext===e.ext}},{key:"getType",value:function(){return _g(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(e,t){return Qg(this,e,t?ov(ov({},t),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(e){return this.format("NATIONAL",e)}},{key:"formatInternational",value:function(e){return this.format("INTERNATIONAL",e)}},{key:"getURI",value:function(e){return this.format("RFC3966",e)}}]),e}(),dv=function(e){return/^[A-Z]{2}$/.test(e)};var lv=new RegExp("(["+Zp+"])");function cv(e,t,i,n){if(t){var o=new ag(n);o.selectNumberingPlan(t,i);var r=new RegExp(o.IDDPrefix());if(0===e.search(r)){var s=(e=e.slice(e.match(r)[0].length)).match(lv);if(!(s&&null!=s[1]&&s[1].length>0&&"0"===s[1]))return e}}}function uv(e,t){if(e&&t.numberingPlan.nationalPrefixForParsing()){var i=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")"),n=i.exec(e);if(n){var o,r,s,a=n.length-1,d=a>0&&n[a];if(t.nationalPrefixTransformRule()&&d)o=e.replace(i,t.nationalPrefixTransformRule()),a>1&&(r=n[1]);else{var l=n[0];o=e.slice(l.length),d&&(r=n[1])}if(d){var c=e.indexOf(n[1]);e.slice(0,c)===t.numberingPlan.nationalPrefix()&&(s=t.numberingPlan.nationalPrefix())}else s=n[0];return{nationalNumber:o,nationalPrefix:s,carrierCode:r}}}return{nationalNumber:e}}function hv(e,t){var i=uv(e,t),n=i.carrierCode,o=i.nationalNumber;if(o!==e){if(!function(e,t,i){if(Tg(e,i.nationalNumberPattern())&&!Tg(t,i.nationalNumberPattern()))return!1;return!0}(e,o,t))return{nationalNumber:e};if(t.possibleLengths()&&!function(e,t){switch(Pg(e,t)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}(o,t))return{nationalNumber:e}}return{nationalNumber:o,carrierCode:n}}function fv(e,t,i,n){var o=t?pg(t,n):i;if(0===e.indexOf(o)){(n=new ag(n)).selectNumberingPlan(t,i);var r=e.slice(o.length),s=hv(r,n).nationalNumber,a=hv(e,n).nationalNumber;if(!Tg(a,n.nationalNumberPattern())&&Tg(s,n.nationalNumberPattern())||"TOO_LONG"===Pg(a,n))return{countryCallingCode:o,number:r}}return{number:e}}function pv(e,t,i,n){if(!e)return{};var o;if("+"!==e[0]){var r=cv(e,t,i,n);if(!r||r===e){if(t||i){var s=fv(e,t,i,n),a=s.countryCallingCode,d=s.number;if(a)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:a,number:d}}return{number:e}}o=!0,e="+"+r}if("0"===e[1])return{};n=new ag(n);for(var l=2;l-1<=Jp&&l<=e.length;){var c=e.slice(1,l);if(n.hasCallingCode(c))return n.selectNumberingPlan(c),{countryCallingCodeSource:o?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:c,number:e.slice(l)};l++}return{}}function gv(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return vv(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return vv(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function vv(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function mv(e,t){var i=t.countries;t.defaultCountry;var n=t.metadata;n=new ag(n);for(var o,r=gv(i);!(o=r()).done;){var s=o.value;if(n.country(s),n.leadingDigits()){if(e&&0===e.search(n.leadingDigits()))return s}else if(_g({phone:e,country:s},void 0,n.metadata))return s}}function yv(e,t){var i=t.nationalNumber,n=t.defaultCountry,o=t.metadata,r=o.getCountryCodesForCallingCode(e);if(r)return 1===r.length?r[0]:mv(i,{countries:r,defaultCountry:n,metadata:o.metadata})}var bv="+",$v="(["+Zp+"]|[\\-\\.\\(\\)]?)",wv=new RegExp("^\\"+bv+$v+"*["+Zp+"]"+$v+"*$","g"),Cv=new RegExp("^("+("["+Zp+"]+((\\-)*["+Zp+"])*")+"\\.)*"+("[a-zA-Z]+((\\-)*["+Zp+"])*")+"\\.?$","g"),kv="tel:",Sv=";phone-context=",Iv=";isub=";function Rv(e,t){var i,n=t.extractFormattedPhoneNumber,o=function(e){var t=e.indexOf(Sv);if(t<0)return null;var i=t+Sv.length;if(i>=e.length)return"";var n=e.indexOf(";",i);return n>=0?e.substring(i,n):e.substring(i)}(e);if(!function(e){return null===e||0!==e.length&&(wv.test(e)||Cv.test(e))}(o))throw new Hp("NOT_A_NUMBER");if(null===o)i=n(e)||"";else{i="",o.charAt(0)===bv&&(i+=o);var r,s=e.indexOf(kv);r=s>=0?s+kv.length:0;var a=e.indexOf(Sv);i+=e.substring(r,a)}var d=i.indexOf(Iv);if(d>0&&(i=i.substring(0,d)),""!==i)return i}var xv=250,Ov=new RegExp("[++"+Zp+"]"),Ev=new RegExp("[^"+Zp+"#]+$");function Av(e,t,i){if(t=t||{},i=new ag(i),t.defaultCountry&&!i.hasCountry(t.defaultCountry)){if(t.v2)throw new Hp("INVALID_COUNTRY");throw new Error("Unknown country: ".concat(t.defaultCountry))}var n=function(e,t,i){var n=Rv(e,{extractFormattedPhoneNumber:function(e){return function(e,t,i){if(!e)return;if(e.length>xv){if(i)throw new Hp("TOO_LONG");return}if(!1===t)return e;var n=e.search(Ov);if(n<0)return;return e.slice(n).replace(Ev,"")}(e,i,t)}});if(!n)return{};if(!function(e){return e.length>=zp&&kg.test(e)}(n))return function(e){return wg.test(e)}(n)?{error:"TOO_SHORT"}:{};var o=function(e){var t=e.search(Sg);if(t<0)return{};for(var i=e.slice(0,t),n=e.match(Sg),o=1;o<n.length;){if(n[o])return{number:i,ext:n[o]};o++}}(n);if(o.ext)return o;return{number:n}}(e,t.v2,t.extract),o=n.number,r=n.ext,s=n.error;if(!o){if(t.v2){if("TOO_SHORT"===s)throw new Hp("TOO_SHORT");throw new Hp("NOT_A_NUMBER")}return{}}var a=function(e,t,i,n){var o,r=pv(jg(e),t,i,n.metadata),s=r.countryCallingCodeSource,a=r.countryCallingCode,d=r.number;if(a)n.selectNumberingPlan(a);else{if(!d||!t&&!i)return{};n.selectNumberingPlan(t,i),t&&(o=t),a=i||pg(t,n.metadata)}if(!d)return{countryCallingCodeSource:s,countryCallingCode:a};var l=hv(jg(d),n),c=l.nationalNumber,u=l.carrierCode,h=yv(a,{nationalNumber:c,defaultCountry:t,metadata:n});h&&(o=h,"001"===h||n.country(o));return{country:o,countryCallingCode:a,countryCallingCodeSource:s,nationalNumber:c,carrierCode:u}}(o,t.defaultCountry,t.defaultCallingCode,i),d=a.country,l=a.nationalNumber,c=a.countryCallingCode,u=a.countryCallingCodeSource,h=a.carrierCode;if(!i.hasSelectedNumberingPlan()){if(t.v2)throw new Hp("INVALID_COUNTRY");return{}}if(!l||l.length<zp){if(t.v2)throw new Hp("TOO_SHORT");return{}}if(l.length>Gp){if(t.v2)throw new Hp("TOO_LONG");return{}}if(t.v2){var f=new av(c,l,i.metadata);return d&&(f.country=d),h&&(f.carrierCode=h),r&&(f.ext=r),f.__countryCallingCodeSource=u,f}var p=!!(t.extended?i.hasSelectedNumberingPlan():d)&&Tg(l,i.nationalNumberPattern());return t.extended?{country:d,countryCallingCode:c,carrierCode:h,valid:p,possible:!!p||!(!0!==t.extended||!i.possibleLengths()||!Ug(l,i)),phone:l,ext:r}:p?function(e,t,i){var n={country:e,phone:t};i&&(n.ext=i);return n}(d,l,r):{}}function Nv(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function jv(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Nv(Object(i),!0).forEach((function(t){Mv(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Nv(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Mv(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Pv(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Uv(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Tv(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,o,r=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(r.push(n.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Wv(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Wv(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wv(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Lv(e){var t,i,n,o=Tv(Array.prototype.slice.call(e),4),r=o[0],s=o[1],a=o[2],d=o[3];if("string"!=typeof r)throw new TypeError("A text for parsing must be a string.");if(t=r,s&&"string"!=typeof s){if(!tg(s))throw new Error("Invalid second argument: ".concat(s));a?(i=s,n=a):n=s}else d?(i=a,n=d):(i=void 0,n=a),s&&(i=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Pv(Object(i),!0).forEach((function(t){Uv(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Pv(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({defaultCountry:s},i));return{text:t,options:i,metadata:n}}function Dv(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function _v(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Dv(Object(i),!0).forEach((function(t){Fv(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Dv(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Fv(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function qv(e,t,i){t&&t.defaultCountry&&!gg(t.defaultCountry,i)&&(t=_v(_v({},t),{},{defaultCountry:void 0}));try{return function(e,t,i){return Av(e,jv(jv({},t),{},{v2:!0}),i)}(e,t,i)}catch(e){if(!(e instanceof Hp))throw e}}function Bv(){var e=Lv(arguments);return qv(e.text,e.options,e.metadata)}function Vv(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Kv(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Hv=Vv((function e(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;Kv(this,e),this.key=t,this.value=i,this.next=n,this.prev=o})),zv=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;Kv(this,e),this.size=0,this.limit=t,this.head=null,this.tail=null,this.cache={}}return Vv(e,[{key:"put",value:function(e,t){if(this.ensureLimit(),this.head){var i=new Hv(e,t,this.head);this.head.prev=i,this.head=i}else this.head=this.tail=new Hv(e,t);this.cache[e]=this.head,this.size++}},{key:"get",value:function(e){if(this.cache[e]){var t=this.cache[e].value;return this.remove(e),this.put(e,t),t}console.log("Item not available in cache for key ".concat(e))}},{key:"ensureLimit",value:function(){this.size===this.limit&&this.remove(this.tail.key)}},{key:"remove",value:function(e){var t=this.cache[e];null!==t.prev?t.prev.next=t.next:this.head=t.next,null!==t.next?t.next.prev=t.prev:this.tail=t.prev,delete this.cache[e],this.size--}},{key:"clear",value:function(){this.head=null,this.tail=null,this.size=0,this.cache={}}}]),e}();function Gv(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Jv=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.cache=new zv(t)}return Gv(e,[{key:"getPatternForRegExp",value:function(e){var t=this.cache.get(e);return t||(t=new RegExp("^"+e),this.cache.put(e,t)),t}}]),e}();function Zv(e,t){if(e<0||t<=0||t<e)throw new TypeError;return"{".concat(e,",").concat(t,"}")}function Yv(e,t){var i=t.search(e);return i>=0?t.slice(0,i):t}var Xv=" - \u2028\u2029 ",Qv="[".concat(Xv,"]"),em="[^".concat(Xv,"]"),tm="[".concat("0-9٠-٩۰-۹߀-߉०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯๐-๙໐-໙༠-༩၀-၉႐-႙០-៩᠐-᠙᥆-᥏᧐-᧙᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙꘠-꘩꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹0-9","]"),im="A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",nm="[".concat(im,"]"),om=new RegExp(nm),rm="[".concat("$¢-¥֏؋৲৳৻૱௹฿៛₠-₹꠸﷼﹩$¢£¥₩","]"),sm=new RegExp(rm),am="[".concat("̀-ͯ҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ࣾऀ-ंऺ़ु-ै्॑-ॗॢॣঁ়ু-ৄ্ৢৣਁਂ਼ੁੂੇੈੋ-੍ੑੰੱੵઁં઼ુ-ૅેૈ્ૢૣଁ଼ିୁ-ୄ୍ୖୢୣஂீ்ా-ీె-ైొ-్ౕౖౢౣ಼ಿೆೌ್ೢೣു-ൄ്ൢൣ්ි-ුූัิ-ฺ็-๎ັິ-ູົຼ່-ໍཱ༹༘༙༵༷-ཾྀ-྄྆྇ྍ-ྗྙ-ྼ࿆ိ-ူဲ-့္်ွှၘၙၞ-ၠၱ-ၴႂႅႆႍႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴឵ិ-ួំ៉-៓៝᠋-᠍ᢩᤠ-ᤢᤧᤨᤲ᤹-᤻ᨘᨗᩖᩘ-ᩞ᩠ᩢᩥ-ᩬᩳ-᩿᩼ᬀ-ᬃ᬴ᬶ-ᬺᬼᭂ᭫-᭳ᮀᮁᮢ-ᮥᮨᮩ᯦᮫ᯨᯩᯭᯯ-ᯱᰬ-ᰳᰶ᰷᳐-᳔᳒-᳢᳠-᳨᳭᳴᷀-ᷦ᷼-᷿⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〭꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠥꠦ꣄꣠-꣱ꤦ-꤭ꥇ-ꥑꦀ-ꦂ꦳ꦶ-ꦹꦼꨩ-ꨮꨱꨲꨵꨶꩃꩌꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫬꫭ꫶ꯥꯨ꯭ﬞ︀-️︠-︦","]"),dm=new RegExp(am),lm=new RegExp("[\0--ÿĀ-ſḀ-ỿƀ-ɏ̀-ͯ]");function cm(e){return!(!om.test(e)&&!dm.test(e))&&lm.test(e)}function um(e){return"%"===e||sm.test(e)}function hm(e,t,i){var n=!0,o=Bv(e,i);if(o||(n=!1,o=Bv(e,{defaultCallingCode:t.countryCallingCode},i)),!o)return"INVALID_NUMBER";if(t.ext){if(o.ext!==t.ext)return"NO_MATCH"}else if(o.ext)return"NO_MATCH";return n&&t.countryCallingCode!==o.countryCallingCode?"NO_MATCH":t.number===o.number?n?"EXACT_MATCH":"NSN_MATCH":0===t.nationalNumber.indexOf(o.nationalNumber)||0===o.nationalNumber.indexOf(t.nationalNumber)?"SHORT_NSN_MATCH":"NO_MATCH"}var fm={POSSIBLE:function(e,t){return t.candidate,t.metadata,!0},VALID:function(e,t){var i=t.candidate;t.defaultCountry;var n=t.metadata;return!(!e.isValid()||!pm(e,i,n))},STRICT_GROUPING:function(e,t){var i=t.candidate,n=t.defaultCountry,o=t.metadata;return t.regExpCache,!(!e.isValid()||!pm(e,i,o)||vm(e,i)||!gm(e,{defaultCountry:n,metadata:o}))&&mm()},EXACT_GROUPING:function(e,t){var i=t.candidate,n=t.defaultCountry,o=t.metadata;return t.regExpCache,!(!e.isValid()||!pm(e,i,o)||vm(e,i)||!gm(e,{defaultCountry:n,metadata:o}))&&mm()}};function pm(e,t,i){for(var n=0;n<t.length-1;n++){var o=t.charAt(n);if("x"===o||"X"===o){var r=t.charAt(n+1);if("x"===r||"X"===r){if(n++,"NSN_MATCH"!==hm(t.substring(n),e,i))return!1}else{var s=Eg(t.substring(n));if(s){if(e.ext!==s)return!1}else if(e.ext)return!1}}}return!0}function gm(e,t){var i=t.defaultCountry,n=t.metadata;if("FROM_DEFAULT_COUNTRY"!==e.__countryCallingCodeSource)return!0;var o=new ag(n);o.selectNumberingPlan(e.countryCallingCode),e.country||yv(e.countryCallingCode,{nationalNumber:e.nationalNumber,defaultCountry:i,metadata:o});var r=e.nationalNumber,s=tv(o.numberingPlan.formats(),r);return!s.nationalPrefixFormattingRule()||(!!o.numberingPlan.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||(!s.usesNationalPrefix()||Boolean(e.nationalPrefix)))}function vm(e,t){var i=t.indexOf("/");if(i<0)return!1;var n=t.indexOf("/",i+1);return!(n<0)&&(!("FROM_NUMBER_WITH_PLUS_SIGN"===e.__countryCallingCodeSource||"FROM_NUMBER_WITHOUT_PLUS_SIGN"===e.__countryCallingCodeSource)||Eg(t.substring(0,i))!==e.countryCallingCode||t.slice(n+1).indexOf("/")>=0)}function mm(e,t,i,n,o){throw new Error("This part of code hasn't been ported")}var ym=/[\\/] *x/;function bm(e){return Yv(ym,e)}var $m=/(?:(?:[0-3]?\d\/[01]?\d)|(?:[01]?\d\/[0-3]?\d))\/(?:[12]\d)?\d{2}/,wm=/[12]\d{3}[-/]?[01]\d[-/]?[0-3]\d +[0-2]\d$/,Cm=/^:[0-5]\d/;function km(e,t,i){if($m.test(e))return!1;if(wm.test(e)){var n=i.slice(t+e.length);if(Cm.test(n))return!1}return!0}var Sm="(\\[([",Im=")\\])]",Rm="[^".concat(Sm).concat(Im,"]"),xm="[".concat(Sm).concat(Xp,"]"),Om=new RegExp("^"+xm),Em=Zv(0,3),Am=new RegExp("^(?:[(\\[([])?(?:"+Rm+"+["+Im+"])?"+Rm+"+(?:["+Sm+"]"+Rm+"+["+Im+"])"+Em+Rm+"*$"),Nm=/\d{1,5}-+\d{1,5}\s{0,4}\(\d{1,4}/;function jm(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Mm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Mm(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Mm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Pm(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Um=yg(),Tm=["\\/+(.*)/","(\\([^(]*)","(?:".concat(Qv,"-|-").concat(Qv,")").concat(Qv,"*(.+)"),"[‒-―-]".concat(Qv,"*(.+)"),"\\.+".concat(Qv,"*([^.]+)"),"".concat(Qv,"+(").concat(em,"+)")],Wm=Zv(0,2),Lm=Zv(0,4),Dm=Gp+Jp,_m=Zv(0,Dm),Fm="[".concat(Yp,"]")+Lm,qm=tm+Zv(1,Dm),Bm="(?:"+xm+Fm+")"+Wm+qm+"(?:"+Fm+qm+")"+_m+"(?:"+Um+")?",Vm=new RegExp("[^".concat("0-9²³¹¼-¾٠-٩۰-۹߀-߉०-९০-৯৴-৹੦-੯૦-૯୦-୯୲-୷௦-௲౦-౯౸-౾೦-೯൦-൵๐-๙໐-໙༠-༳၀-၉႐-႙፩-፼ᛮ-ᛰ០-៩៰-៹᠐-᠙᥆-᥏᧐-᧚᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙⁰⁴-⁹₀-₉⅐-ↂↅ-↉①-⒛⓪-⓿❶-➓⳽〇〡-〩〸-〺㆒-㆕㈠-㈩㉈-㉏㉑-㉟㊀-㊉㊱-㊿꘠-꘩ꛦ-ꛯ꠰-꠵꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹0-9").concat(im,"#]+$")),Km=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,Hm=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!(i={v2:i.v2,defaultCallingCode:i.defaultCallingCode,defaultCountry:i.defaultCountry&&gg(i.defaultCountry,n)?i.defaultCountry:void 0,leniency:i.leniency||(i.extended?"POSSIBLE":"VALID"),maxTries:i.maxTries||Km}).leniency)throw new TypeError("`leniency` is required");if("POSSIBLE"!==i.leniency&&"VALID"!==i.leniency)throw new TypeError('Invalid `leniency`: "'.concat(i.leniency,'". Supported values: "POSSIBLE", "VALID".'));if(i.maxTries<0)throw new TypeError("`maxTries` must be `>= 0`");if(this.text=t,this.options=i,this.metadata=n,this.leniency=fm[i.leniency],!this.leniency)throw new TypeError('Unknown leniency: "'.concat(i.leniency,'"'));this.maxTries=i.maxTries,this.PATTERN=new RegExp(Bm,"ig"),this.state="NOT_READY",this.searchIndex=0,this.regExpCache=new Jv(32)}return Pm(e,[{key:"find",value:function(){for(var e;this.maxTries>0&&null!==(e=this.PATTERN.exec(this.text));){var t=e[0],i=e.index;if(km(t=bm(t),i,this.text)){var n=this.parseAndVerify(t,i,this.text)||this.extractInnerMatch(t,i,this.text);if(n){if(this.options.v2)return{startsAt:n.startsAt,endsAt:n.endsAt,number:n.phoneNumber};var o=n.phoneNumber,r={startsAt:n.startsAt,endsAt:n.endsAt,phone:o.nationalNumber};return o.country?r.country=o.country:r.countryCallingCode=o.countryCallingCode,o.ext&&(r.ext=o.ext),r}}this.maxTries--}}},{key:"extractInnerMatch",value:function(e,t,i){for(var n,o=jm(Tm);!(n=o()).done;)for(var r=n.value,s=!0,a=void 0,d=new RegExp(r,"g");this.maxTries>0&&null!==(a=d.exec(e));){if(s){var l=Yv(Vm,e.slice(0,a.index)),c=this.parseAndVerify(l,t,i);if(c)return c;this.maxTries--,s=!1}var u=Yv(Vm,a[1]),h=e.indexOf(u,a.index),f=this.parseAndVerify(u,t+h,i);if(f)return f;this.maxTries--}}},{key:"parseAndVerify",value:function(e,t,i){if(function(e,t,i,n){if(Am.test(e)&&!Nm.test(e)){if("POSSIBLE"!==n){if(t>0&&!Om.test(e)){var o=i[t-1];if(um(o)||cm(o))return!1}var r=t+e.length;if(r<i.length){var s=i[r];if(um(s)||cm(s))return!1}}return!0}}(e,t,i,this.options.leniency)){var n=Bv(e,{extended:!0,defaultCountry:this.options.defaultCountry,defaultCallingCode:this.options.defaultCallingCode},this.metadata);if(n&&n.isPossible())return this.leniency(n,{candidate:e,defaultCountry:this.options.defaultCountry,metadata:this.metadata,regExpCache:this.regExpCache})?{startsAt:t,endsAt:t+e.length,phoneNumber:n}:void 0}}},{key:"hasNext",value:function(){return"NOT_READY"===this.state&&(this.lastMatch=this.find(),this.lastMatch?this.state="READY":this.state="DONE"),"READY"===this.state}},{key:"next",value:function(){if(!this.hasNext())throw new Error("No next element");var e=this.lastMatch;return this.lastMatch=null,this.state="NOT_READY",e}}]),e}();function zm(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Gm=function(){function e(t){var i=t.onCountryChange,n=t.onCallingCodeChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.onCountryChange=i,this.onCallingCodeChange=n}return zm(e,[{key:"reset",value:function(e){var t=e.country,i=e.callingCode;this.international=!1,this.missingPlus=!1,this.IDDPrefix=void 0,this.callingCode=void 0,this.digits="",this.resetNationalSignificantNumber(),this.initCountryAndCallingCode(t,i)}},{key:"resetNationalSignificantNumber",value:function(){this.nationalSignificantNumber=this.getNationalDigits(),this.nationalSignificantNumberMatchesInput=!0,this.nationalPrefix=void 0,this.carrierCode=void 0,this.complexPrefixBeforeNationalSignificantNumber=void 0}},{key:"update",value:function(e){for(var t=0,i=Object.keys(e);t<i.length;t++){var n=i[t];this[n]=e[n]}}},{key:"initCountryAndCallingCode",value:function(e,t){this.setCountry(e),this.setCallingCode(t)}},{key:"setCountry",value:function(e){this.country=e,this.onCountryChange(e)}},{key:"setCallingCode",value:function(e){this.callingCode=e,this.onCallingCodeChange(e,this.country)}},{key:"startInternationalNumber",value:function(e,t){this.international=!0,this.initCountryAndCallingCode(e,t)}},{key:"appendDigits",value:function(e){this.digits+=e}},{key:"appendNationalSignificantNumberDigits",value:function(e){this.nationalSignificantNumber+=e}},{key:"getNationalDigits",value:function(){return this.international?this.digits.slice((this.IDDPrefix?this.IDDPrefix.length:0)+(this.callingCode?this.callingCode.length:0)):this.digits}},{key:"getDigitsWithoutInternationalPrefix",value:function(){return this.international&&this.IDDPrefix?this.digits.slice(this.IDDPrefix.length):this.digits}}]),e}();function Jm(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Zm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Zm(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Zm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var Ym="x",Xm=new RegExp(Ym);function Qm(e,t){if(t<1)return"";for(var i="";t>1;)1&t&&(i+=e),t>>=1,e+=e;return i+e}function ey(e,t){return")"===e[t]&&t++,function(e){var t=[],i=0;for(;i<e.length;)"("===e[i]?t.push(i):")"===e[i]&&t.pop(),i++;var n=0,o="";t.push(e.length);for(var r=0,s=t;r<s.length;r++){var a=s[r];o+=e.slice(n,a),n=a+1}return o}(e.slice(0,t))}function ty(e,t,i){var n=i.metadata,o=i.shouldTryNationalPrefixFormattingRule,r=i.getSeparatorAfterNationalPrefix;if(new RegExp("^(?:".concat(t.pattern(),")$")).test(e.nationalSignificantNumber))return function(e,t,i){var n=i.metadata,o=i.shouldTryNationalPrefixFormattingRule,r=i.getSeparatorAfterNationalPrefix;if(e.nationalSignificantNumber,e.international,e.nationalPrefix,e.carrierCode,o(t)){var s=iy(e,t,{useNationalPrefixFormattingRule:!0,getSeparatorAfterNationalPrefix:r,metadata:n});if(s)return s}return iy(e,t,{useNationalPrefixFormattingRule:!1,getSeparatorAfterNationalPrefix:r,metadata:n})}(e,t,{metadata:n,shouldTryNationalPrefixFormattingRule:o,getSeparatorAfterNationalPrefix:r})}function iy(e,t,i){var n=i.metadata,o=i.useNationalPrefixFormattingRule,r=i.getSeparatorAfterNationalPrefix,s=Kg(e.nationalSignificantNumber,t,{carrierCode:e.carrierCode,useInternationalFormat:e.international,withNationalPrefix:o,metadata:n});if(o||(e.nationalPrefix?s=e.nationalPrefix+r(t)+s:e.complexPrefixBeforeNationalSignificantNumber&&(s=e.complexPrefixBeforeNationalSignificantNumber+" "+s)),function(e,t){return Eg(e)===t.getNationalDigits()}(s,e))return s}function ny(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var oy=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return ny(e,[{key:"parse",value:function(e){if(this.context=[{or:!0,instructions:[]}],this.parsePattern(e),1!==this.context.length)throw new Error("Non-finalized contexts left when pattern parse ended");var t=this.context[0],i=t.branches,n=t.instructions;if(i)return{op:"|",args:i.concat([dy(n)])};if(0===n.length)throw new Error("Pattern is required");return 1===n.length?n[0]:n}},{key:"startContext",value:function(e){this.context.push(e)}},{key:"endContext",value:function(){this.context.pop()}},{key:"getContext",value:function(){return this.context[this.context.length-1]}},{key:"parsePattern",value:function(e){if(!e)throw new Error("Pattern is required");var t=e.match(ay);if(t){var i=t[1],n=e.slice(0,t.index),o=e.slice(t.index+i.length);switch(i){case"(?:":n&&this.parsePattern(n),this.startContext({or:!0,instructions:[],branches:[]});break;case")":if(!this.getContext().or)throw new Error('")" operator must be preceded by "(?:" operator');if(n&&this.parsePattern(n),0===this.getContext().instructions.length)throw new Error('No instructions found after "|" operator in an "or" group');var r=this.getContext().branches;r.push(dy(this.getContext().instructions)),this.endContext(),this.getContext().instructions.push({op:"|",args:r});break;case"|":if(!this.getContext().or)throw new Error('"|" operator can only be used inside "or" groups');if(n&&this.parsePattern(n),!this.getContext().branches){if(1!==this.context.length)throw new Error('"branches" not found in an "or" group context');this.getContext().branches=[]}this.getContext().branches.push(dy(this.getContext().instructions)),this.getContext().instructions=[];break;case"[":n&&this.parsePattern(n),this.startContext({oneOfSet:!0});break;case"]":if(!this.getContext().oneOfSet)throw new Error('"]" operator must be preceded by "[" operator');this.endContext(),this.getContext().instructions.push({op:"[]",args:ry(n)});break;default:throw new Error("Unknown operator: ".concat(i))}o&&this.parsePattern(o)}else{if(sy.test(e))throw new Error("Illegal characters found in a pattern: ".concat(e));this.getContext().instructions=this.getContext().instructions.concat(e.split(""))}}}]),e}();function ry(e){for(var t=[],i=0;i<e.length;){if("-"===e[i]){if(0===i||i===e.length-1)throw new Error("Couldn't parse a one-of set pattern: ".concat(e));for(var n=e[i-1].charCodeAt(0)+1,o=e[i+1].charCodeAt(0)-1,r=n;r<=o;)t.push(String.fromCharCode(r)),r++}else t.push(e[i]);i++}return t}var sy=/[\(\)\[\]\?\:\|]/,ay=new RegExp("(\\||\\(\\?\\:|\\)|\\[|\\])");function dy(e){return 1===e.length?e[0]:e}function ly(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return cy(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return cy(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function cy(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function uy(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var hy=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.matchTree=(new oy).parse(t)}return uy(e,[{key:"match",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).allowOverflow;if(!e)throw new Error("String is required");var i=fy(e.split(""),this.matchTree,!0);if(i&&i.match&&delete i.matchedChars,!i||!i.overflow||t)return i}}]),e}();function fy(e,t,i){if("string"==typeof t){var n=e.join("");return 0===t.indexOf(n)?e.length===t.length?{match:!0,matchedChars:e}:{partialMatch:!0}:0===n.indexOf(t)?i&&e.length>t.length?{overflow:!0}:{match:!0,matchedChars:e.slice(0,t.length)}:void 0}if(Array.isArray(t)){for(var o=e.slice(),r=0;r<t.length;){var s=fy(o,t[r],i&&r===t.length-1);if(!s)return;if(s.overflow)return s;if(!s.match){if(s.partialMatch)return{partialMatch:!0};throw new Error("Unsupported match result:\n".concat(JSON.stringify(s,null,2)))}if(0===(o=o.slice(s.matchedChars.length)).length)return r===t.length-1?{match:!0,matchedChars:e}:{partialMatch:!0};r++}return i?{overflow:!0}:{match:!0,matchedChars:e.slice(0,e.length-o.length)}}switch(t.op){case"|":for(var a,d,l=ly(t.args);!(d=l()).done;){var c=fy(e,d.value,i);if(c){if(c.overflow)return c;if(c.match)return{match:!0,matchedChars:c.matchedChars};if(!c.partialMatch)throw new Error("Unsupported match result:\n".concat(JSON.stringify(c,null,2)));a=!0}}return a?{partialMatch:!0}:void 0;case"[]":for(var u,h=ly(t.args);!(u=h()).done;){var f=u.value;if(e[0]===f)return 1===e.length?{match:!0,matchedChars:e}:i?{overflow:!0}:{match:!0,matchedChars:[f]}}return;default:throw new Error("Unsupported instruction tree: ".concat(t))}}function py(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return gy(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return gy(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function gy(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function vy(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var my=Qm("9",15),yy=/[- ]/,by=new RegExp("["+Yp+"]*\\$1["+Yp+"]*(\\$\\d["+Yp+"]*)*$"),$y=function(){function e(t){t.state;var i=t.metadata;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=i,this.resetFormat()}return vy(e,[{key:"resetFormat",value:function(){this.chosenFormat=void 0,this.template=void 0,this.nationalNumberTemplate=void 0,this.populatedNationalNumberTemplate=void 0,this.populatedNationalNumberTemplatePosition=-1}},{key:"reset",value:function(e,t){this.resetFormat(),e?(this.isNANP="1"===e.callingCode(),this.matchingFormats=e.formats(),t.nationalSignificantNumber&&this.narrowDownMatchingFormats(t)):(this.isNANP=void 0,this.matchingFormats=[])}},{key:"format",value:function(e,t){var i=this;if(function(e,t){return"IS_POSSIBLE"===Pg(e,t)}(t.nationalSignificantNumber,this.metadata))for(var n,o=py(this.matchingFormats);!(n=o()).done;){var r=n.value,s=ty(t,r,{metadata:this.metadata,shouldTryNationalPrefixFormattingRule:function(e){return i.shouldTryNationalPrefixFormattingRule(e,{international:t.international,nationalPrefix:t.nationalPrefix})},getSeparatorAfterNationalPrefix:function(e){return i.getSeparatorAfterNationalPrefix(e)}});if(s)return this.resetFormat(),this.chosenFormat=r,this.setNationalNumberTemplate(s.replace(/\d/g,Ym),t),this.populatedNationalNumberTemplate=s,this.populatedNationalNumberTemplatePosition=this.template.lastIndexOf(Ym),s}return this.formatNationalNumberWithNextDigits(e,t)}},{key:"formatNationalNumberWithNextDigits",value:function(e,t){var i=this.chosenFormat,n=this.chooseFormat(t);if(n)return n===i?this.formatNextNationalNumberDigits(e):this.formatNextNationalNumberDigits(t.getNationalDigits())}},{key:"narrowDownMatchingFormats",value:function(e){var t=this,i=e.nationalSignificantNumber,n=e.nationalPrefix,o=e.international,r=i,s=r.length-3;s<0&&(s=0),this.matchingFormats=this.matchingFormats.filter((function(e){return t.formatSuits(e,o,n)&&t.formatMatches(e,r,s)})),this.chosenFormat&&-1===this.matchingFormats.indexOf(this.chosenFormat)&&this.resetFormat()}},{key:"formatSuits",value:function(e,t,i){return!(i&&!e.usesNationalPrefix()&&!e.nationalPrefixIsOptionalWhenFormattingInNationalFormat())&&!(!t&&!i&&e.nationalPrefixIsMandatoryWhenFormattingInNationalFormat())}},{key:"formatMatches",value:function(e,t,i){var n=e.leadingDigitsPatterns().length;if(0===n)return!0;i=Math.min(i,n-1);var o=e.leadingDigitsPatterns()[i];if(t.length<3)try{return void 0!==new hy(o).match(t,{allowOverflow:!0})}catch(e){return console.error(e),!0}return new RegExp("^(".concat(o,")")).test(t)}},{key:"getFormatFormat",value:function(e,t){return t?e.internationalFormat():e.format()}},{key:"chooseFormat",value:function(e){for(var t,i=this,n=function(){var n=t.value;return i.chosenFormat===n?"break":by.test(i.getFormatFormat(n,e.international))?i.createTemplateForFormat(n,e)?(i.chosenFormat=n,"break"):(i.matchingFormats=i.matchingFormats.filter((function(e){return e!==n})),"continue"):"continue"},o=py(this.matchingFormats.slice());!(t=o()).done;){var r=n();if("break"===r)break}return this.chosenFormat||this.resetFormat(),this.chosenFormat}},{key:"createTemplateForFormat",value:function(e,t){if(!(e.pattern().indexOf("|")>=0)){var i=this.getTemplateForFormat(e,t);return i?(this.setNationalNumberTemplate(i,t),!0):void 0}}},{key:"getSeparatorAfterNationalPrefix",value:function(e){return this.isNANP||e&&e.nationalPrefixFormattingRule()&&yy.test(e.nationalPrefixFormattingRule())?" ":""}},{key:"getInternationalPrefixBeforeCountryCallingCode",value:function(e,t){var i=e.IDDPrefix,n=e.missingPlus;return i?t&&!1===t.spacing?i:i+" ":n?"":"+"}},{key:"getTemplate",value:function(e){if(this.template){for(var t=-1,i=0,n=e.international?this.getInternationalPrefixBeforeCountryCallingCode(e,{spacing:!1}):"";i<n.length+e.getDigitsWithoutInternationalPrefix().length;)t=this.template.indexOf(Ym,t+1),i++;return ey(this.template,t+1)}}},{key:"setNationalNumberTemplate",value:function(e,t){this.nationalNumberTemplate=e,this.populatedNationalNumberTemplate=e,this.populatedNationalNumberTemplatePosition=-1,t.international?this.template=this.getInternationalPrefixBeforeCountryCallingCode(t).replace(/[\d\+]/g,Ym)+Qm(Ym,t.callingCode.length)+" "+e:this.template=e}},{key:"getTemplateForFormat",value:function(e,t){var i=t.nationalSignificantNumber,n=t.international,o=t.nationalPrefix,r=t.complexPrefixBeforeNationalSignificantNumber,s=e.pattern();s=s.replace(/\[([^\[\]])*\]/g,"\\d").replace(/\d(?=[^,}][^,}])/g,"\\d");var a=my.match(s)[0];if(!(i.length>a.length)){var d=new RegExp("^"+s+"$"),l=i.replace(/\d/g,"9");d.test(l)&&(a=l);var c,u=this.getFormatFormat(e,n);if(this.shouldTryNationalPrefixFormattingRule(e,{international:n,nationalPrefix:o})){var h=u.replace(Vg,e.nationalPrefixFormattingRule());if(Eg(e.nationalPrefixFormattingRule())===(o||"")+Eg("$1")&&(u=h,c=!0,o))for(var f=o.length;f>0;)u=u.replace(/\d/,Ym),f--}var p=a.replace(new RegExp(s),u).replace(new RegExp("9","g"),Ym);return c||(r?p=Qm(Ym,r.length)+" "+p:o&&(p=Qm(Ym,o.length)+this.getSeparatorAfterNationalPrefix(e)+p)),n&&(p=Bg(p)),p}}},{key:"formatNextNationalNumberDigits",value:function(e){var t=function(e,t,i){for(var n,o=Jm(i.split(""));!(n=o()).done;){var r=n.value;if(e.slice(t+1).search(Xm)<0)return;t=e.search(Xm),e=e.replace(Xm,r)}return[e,t]}(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition,e);if(t)return this.populatedNationalNumberTemplate=t[0],this.populatedNationalNumberTemplatePosition=t[1],ey(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition+1);this.resetFormat()}},{key:"shouldTryNationalPrefixFormattingRule",value:function(e,t){var i=t.international,n=t.nationalPrefix;if(e.nationalPrefixFormattingRule()){var o=e.usesNationalPrefix();if(o&&n||!o&&!i)return!0}}}]),e}();function wy(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,o,r=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(r.push(n.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Cy(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Cy(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Cy(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function ky(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Sy=new RegExp("^"+("["+Yp+Zp+"]+")+"$","i"),Iy="(?:[++]["+Yp+Zp+"]*|["+Yp+Zp+"]+)",Ry=new RegExp("[^"+Yp+Zp+"]+.*$"),xy=/[^\d\[\]]/,Oy=function(){function e(t){var i=t.defaultCountry,n=t.defaultCallingCode,o=t.metadata,r=t.onNationalSignificantNumberChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.defaultCountry=i,this.defaultCallingCode=n,this.metadata=o,this.onNationalSignificantNumberChange=r}return ky(e,[{key:"input",value:function(e,t){var i,n=function(e){var t=function(e){var t=function(e){var t,i=e.search(Iy);if(i<0)return;e=e.slice(i),"+"===e[0]&&(t=!0,e=e.slice(1));e=e.replace(Ry,""),t&&(e="+"+e);return e}(e)||"";if("+"===t[0])return[t.slice(1),!0];return[t]}(e),i=wy(t,2),n=i[0],o=i[1];Sy.test(n)||(n="");return[n,o]}(e),o=wy(n,2),r=o[0],s=o[1],a=Eg(r);return s&&(t.digits||(t.startInternationalNumber(),a||(i=!0))),a&&this.inputDigits(a,t),{digits:a,justLeadingPlus:i}}},{key:"inputDigits",value:function(e,t){var i=t.digits,n=i.length<3&&i.length+e.length>=3;if(t.appendDigits(e),n&&this.extractIddPrefix(t),this.isWaitingForCountryCallingCode(t)){if(!this.extractCountryCallingCode(t))return}else t.appendNationalSignificantNumberDigits(e);t.international||this.hasExtractedNationalSignificantNumber||this.extractNationalSignificantNumber(t.getNationalDigits(),(function(e){return t.update(e)}))}},{key:"isWaitingForCountryCallingCode",value:function(e){var t=e.international,i=e.callingCode;return t&&!i}},{key:"extractCountryCallingCode",value:function(e){var t=pv("+"+e.getDigitsWithoutInternationalPrefix(),this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),i=t.countryCallingCode,n=t.number;if(i)return e.setCallingCode(i),e.update({nationalSignificantNumber:n}),!0}},{key:"reset",value:function(e){if(e){this.hasSelectedNumberingPlan=!0;var t=e._nationalPrefixForParsing();this.couldPossiblyExtractAnotherNationalSignificantNumber=t&&xy.test(t)}else this.hasSelectedNumberingPlan=void 0,this.couldPossiblyExtractAnotherNationalSignificantNumber=void 0}},{key:"extractNationalSignificantNumber",value:function(e,t){if(this.hasSelectedNumberingPlan){var i=uv(e,this.metadata),n=i.nationalPrefix,o=i.nationalNumber,r=i.carrierCode;if(o!==e)return this.onExtractedNationalNumber(n,r,o,e,t),!0}}},{key:"extractAnotherNationalSignificantNumber",value:function(e,t,i){if(!this.hasExtractedNationalSignificantNumber)return this.extractNationalSignificantNumber(e,i);if(this.couldPossiblyExtractAnotherNationalSignificantNumber){var n=uv(e,this.metadata),o=n.nationalPrefix,r=n.nationalNumber,s=n.carrierCode;if(r!==t)return this.onExtractedNationalNumber(o,s,r,e,i),!0}}},{key:"onExtractedNationalNumber",value:function(e,t,i,n,o){var r,s,a=n.lastIndexOf(i);if(a>=0&&a===n.length-i.length){s=!0;var d=n.slice(0,a);d!==e&&(r=d)}o({nationalPrefix:e,carrierCode:t,nationalSignificantNumber:i,nationalSignificantNumberMatchesInput:s,complexPrefixBeforeNationalSignificantNumber:r}),this.hasExtractedNationalSignificantNumber=!0,this.onNationalSignificantNumberChange()}},{key:"reExtractNationalSignificantNumber",value:function(e){return!!this.extractAnotherNationalSignificantNumber(e.getNationalDigits(),e.nationalSignificantNumber,(function(t){return e.update(t)}))||(this.extractIddPrefix(e)||this.fixMissingPlus(e)?(this.extractCallingCodeAndNationalSignificantNumber(e),!0):void 0)}},{key:"extractIddPrefix",value:function(e){var t=e.international,i=e.IDDPrefix,n=e.digits;if(e.nationalSignificantNumber,!t&&!i){var o=cv(n,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata);return void 0!==o&&o!==n?(e.update({IDDPrefix:n.slice(0,n.length-o.length)}),this.startInternationalNumber(e,{country:void 0,callingCode:void 0}),!0):void 0}}},{key:"fixMissingPlus",value:function(e){if(!e.international){var t=fv(e.digits,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),i=t.countryCallingCode;if(t.number,i)return e.update({missingPlus:!0}),this.startInternationalNumber(e,{country:e.country,callingCode:i}),!0}}},{key:"startInternationalNumber",value:function(e,t){var i=t.country,n=t.callingCode;e.startInternationalNumber(i,n),e.nationalSignificantNumber&&(e.resetNationalSignificantNumber(),this.onNationalSignificantNumberChange(),this.hasExtractedNationalSignificantNumber=void 0)}},{key:"extractCallingCodeAndNationalSignificantNumber",value:function(e){this.extractCountryCallingCode(e)&&this.extractNationalSignificantNumber(e.getNationalDigits(),(function(t){return e.update(t)}))}}]),e}();function Ey(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,o,r=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(r.push(n.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Ay(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Ay(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ay(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Ny(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var jy,My=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=new ag(i);var n=Ey(this.getCountryAndCallingCode(t),2),o=n[0],r=n[1];this.defaultCountry=o,this.defaultCallingCode=r,this.reset()}return Ny(e,[{key:"getCountryAndCallingCode",value:function(e){var t,i;return e&&(tg(e)?(t=e.defaultCountry,i=e.defaultCallingCode):t=e),t&&!this.metadata.hasCountry(t)&&(t=void 0),[t,i]}},{key:"input",value:function(e){var t=this.parser.input(e,this.state),i=t.digits;if(t.justLeadingPlus)this.formattedOutput="+";else if(i){var n;if(this.determineTheCountryIfNeeded(),this.state.nationalSignificantNumber&&this.formatter.narrowDownMatchingFormats(this.state),this.metadata.hasSelectedNumberingPlan()&&(n=this.formatter.format(i,this.state)),void 0===n&&this.parser.reExtractNationalSignificantNumber(this.state)){this.determineTheCountryIfNeeded();var o=this.state.getNationalDigits();o&&(n=this.formatter.format(o,this.state))}this.formattedOutput=n?this.getFullNumber(n):this.getNonFormattedNumber()}return this.formattedOutput}},{key:"reset",value:function(){var e=this;return this.state=new Gm({onCountryChange:function(t){e.country=t},onCallingCodeChange:function(t,i){e.metadata.selectNumberingPlan(i,t),e.formatter.reset(e.metadata.numberingPlan,e.state),e.parser.reset(e.metadata.numberingPlan)}}),this.formatter=new $y({state:this.state,metadata:this.metadata}),this.parser=new Oy({defaultCountry:this.defaultCountry,defaultCallingCode:this.defaultCallingCode,metadata:this.metadata,state:this.state,onNationalSignificantNumberChange:function(){e.determineTheCountryIfNeeded(),e.formatter.reset(e.metadata.numberingPlan,e.state)}}),this.state.reset({country:this.defaultCountry,callingCode:this.defaultCallingCode}),this.formattedOutput="",this}},{key:"isInternational",value:function(){return this.state.international}},{key:"getCallingCode",value:function(){if(this.isInternational())return this.state.callingCode}},{key:"getCountryCallingCode",value:function(){return this.getCallingCode()}},{key:"getCountry",value:function(){if(this.state.digits)return this._getCountry()}},{key:"_getCountry",value:function(){return this.state.country}},{key:"determineTheCountryIfNeeded",value:function(){this.state.country&&!this.isCountryCallingCodeAmbiguous()||this.determineTheCountry()}},{key:"getFullNumber",value:function(e){var t=this;if(this.isInternational()){var i=function(e){return t.formatter.getInternationalPrefixBeforeCountryCallingCode(t.state,{spacing:!!e})+e},n=this.state.callingCode;return i(n?e?"".concat(n," ").concat(e):n:"".concat(this.state.getDigitsWithoutInternationalPrefix()))}return e}},{key:"getNonFormattedNationalNumberWithPrefix",value:function(){var e=this.state,t=e.nationalSignificantNumber,i=e.complexPrefixBeforeNationalSignificantNumber,n=e.nationalPrefix,o=t,r=i||n;return r&&(o=r+o),o}},{key:"getNonFormattedNumber",value:function(){var e=this.state.nationalSignificantNumberMatchesInput;return this.getFullNumber(e?this.getNonFormattedNationalNumberWithPrefix():this.state.getNationalDigits())}},{key:"getNonFormattedTemplate",value:function(){var e=this.getNonFormattedNumber();if(e)return e.replace(/[\+\d]/g,Ym)}},{key:"isCountryCallingCodeAmbiguous",value:function(){var e=this.state.callingCode,t=this.metadata.getCountryCodesForCallingCode(e);return t&&t.length>1}},{key:"determineTheCountry",value:function(){this.state.setCountry(yv(this.isInternational()?this.state.callingCode:this.defaultCallingCode,{nationalNumber:this.state.nationalSignificantNumber,defaultCountry:this.defaultCountry,metadata:this.metadata}))}},{key:"getNumberValue",value:function(){var e=this.state,t=e.digits,i=e.callingCode,n=e.country,o=e.nationalSignificantNumber;if(t)return this.isInternational()?i?"+"+i+o:"+"+t:n||i?"+"+(n?this.metadata.countryCallingCode():i)+o:void 0}},{key:"getNumber",value:function(){var e=this.state,t=e.nationalSignificantNumber,i=e.carrierCode,n=e.callingCode,o=this._getCountry();if(t&&(o||n)){if(o&&o===this.defaultCountry){var r=new ag(this.metadata.metadata);r.selectNumberingPlan(o);var s=r.numberingPlan.callingCode(),a=this.metadata.getCountryCodesForCallingCode(s);if(a.length>1){var d=mv(t,{countries:a,defaultCountry:this.defaultCountry,metadata:this.metadata.metadata});d&&(o=d)}}var l=new av(o||n,t,this.metadata.metadata);return i&&(l.carrierCode=i),l}}},{key:"isPossible",value:function(){var e=this.getNumber();return!!e&&e.isPossible()}},{key:"isValid",value:function(){var e=this.getNumber();return!!e&&e.isValid()}},{key:"getNationalNumber",value:function(){return this.state.nationalSignificantNumber}},{key:"getChars",value:function(){return(this.state.international?"+":"")+this.state.digits}},{key:"getTemplate",value:function(){return this.formatter.getTemplate(this.state)||this.getNonFormattedTemplate()||""}}]),e}();function Py(){return function(e,t){var i=Array.prototype.slice.call(t);return i.push(Wp),e.apply(this,i)}(Bv,arguments)}function Uy(e,t){return Hm.call(this,e,t,Wp)}function Ty(e){return My.call(this,e,Wp)}function Wy(){return ag.call(this,Wp)}Uy.prototype=Object.create(Hm.prototype,{}),Uy.prototype.constructor=Uy,Ty.prototype=Object.create(My.prototype,{}),Ty.prototype.constructor=Ty,Wy.prototype=Object.create(ag.prototype,{}),Wy.prototype.constructor=Wy,function(e){e[e.text=1]="text",e[e.numeric=2]="numeric",e[e.bool=3]="bool",e[e.singleSelect=4]="singleSelect",e[e.array=5]="array",e[e.date=6]="date"}(jy||(jy={}));const Ly=(e,t)=>Object.entries(e).reduce(((e,[i,n])=>{const[o,...r]=i.split(".");return t!==o?Object.assign(e,{[i]:n}):(e[o]||(e[o]={}),e[o][r.join(".")]=n,e)}),{}),Dy=(e,t)=>Object.fromEntries(Object.entries(e||{}).map((([e,i])=>[`${t}.${e}`,i]))),_y=(e,t)=>e===jy.date?(e=>new Date(Number(e)).toLocaleDateString("en-US"))(`${t}`):t,Fy=(e={})=>{const t=$n("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,i])=>{t.content.querySelector("descope-wc").setAttribute(kn(e),i)})),t};function qy(e){return new URLSearchParams(window.location.search).get(e)}const By={enabled:"active",disabled:"disabled",invited:"invited"},Vy=e=>e.tenantRoles.data,Ky=e=>e.selectedUsersLoginIds,Hy=e=>e.notifications,zy=e=>e.customAttributes.data,Gy=wl((e=>e.subTenantRoles.data),(e=>Object.fromEntries(e.map((({tenantId:e,tenantName:t,roleNames:i})=>[e,t?{label:t,options:i}:i]))))),Jy=wl(Gy,(e=>Object.keys(e).length>0)),Zy=wl(zy,(e=>Object.fromEntries(e.map((e=>[e.name,e.type]))))),Yy=wl((e=>e.usersList.data),Zy,((e,t)=>e.map((e=>Object.assign(Object.assign({},e),{customAttributes:Object.fromEntries(Object.entries(e.customAttributes||{}).map((([e,i])=>[e,_y(t[e],i)])))}))))),Xy=e=>{const t=[e.roleNames||[],...(e.userTenants||[]).map((e=>e.roleNames||[]))].filter((e=>e.length>0));if(0===t.length)return e.roleNames||[];const i=t.map((e=>[...e].sort().join("\0")));return i.every((e=>e===i[0]))?t[0]:"Multiple roles"},Qy=wl(Yy,(e=>e.map((e=>{var t;return Object.assign(Object.assign(Object.assign({},e),Dy(null==e?void 0:e.customAttributes,"customAttributes")),{createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:By[e.status]||e.status,roles:Xy(e),tenants:null===(t=e.userTenants)||void 0===t?void 0:t.map((e=>e.tenantName||e.tenantId))})})))),eb=wl(Ky,Qy,((e,t)=>t.filter((t=>e.includes(t.loginIds))))),tb=wl(eb,(e=>e.map((e=>e.userId)))),ib=wl(eb,(e=>e.map((({userId:e,loginIds:t})=>({userId:e,loginIds:t}))))),nb=wl(eb,(e=>e.map((e=>({userId:e.userId,roles:e.roleNames}))))),ob=wl(eb,(e=>e.map((e=>e.status)))),rb=wl(eb,(e=>e.every((e=>e.editable)))),sb=wl(Ky,(e=>!!e.length)),ab=wl(Ky,(e=>1===e.length)),db=wl(Ky,(e=>{var t;return null===(t=null==e?void 0:e[0])||void 0===t?void 0:t[0]})),lb=wl(ab,ob,((e,t)=>e&&t.every((e=>e===By.enabled)))),cb=wl(ob,(e=>e.every((e=>e===By.disabled)))),ub=wl(eb,(e=>{var t;return 1===e.length?e[0].name||e[0].email||(null===(t=e[0].loginIds)||void 0===t?void 0:t[0]):`${e.length} users`})),hb=wl(ab,cb,rb,((e,t,i)=>e&&t&&i)),fb=wl(ab,lb,rb,((e,t,i)=>e&&t&&i)),pb=wl(ab,rb,((e,t)=>e&&t)),gb=wl(ab,rb,((e,t)=>e&&t)),vb=wl(ab,rb,((e,t)=>e&&t)),mb=sb,yb=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},bb=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),$b=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{t&&e.notifications.push({type:"success",msg:t(i)})},onRejected:(t,i)=>{e&&t.notifications.push({type:"error",msg:e(i)})}}),wb=ec("users/create",((e,{extra:{api:t}})=>t.user.create(e))),Cb=yb(wb)({onFulfilled:(e,t)=>{e.usersList.data.unshift(t.payload)}},bb((e=>e.createUser)),$b({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>`}})),kb={action:wb,reducer:Cb},Sb=ec("users/delete",((e,{extra:{api:t}})=>t.user.deleteBatch(e))),Ib=yb(Sb)({onFulfilled:(e,t)=>{e.usersList.data=e.usersList.data.filter((e=>!t.meta.arg.includes(e.userId))),e.selectedUsersLoginIds=[]}},bb((e=>e.deleteUser)),$b({getSuccessMsg:e=>Sn(e.meta.arg.length)`${["",e.meta.arg.length]} ${["U","u"]}ser${["","s"]} deleted successfully`,getErrorMsg:e=>Sn(e.meta.arg.length)`Failed to delete user${["","s"]}`})),Rb={action:Sb,reducer:Ib},xb=ec("users/setTempPassword",((e,{extra:{api:t}})=>t.user.setTempPassword(e))),Ob=yb(xb)(bb((e=>e.setTempUserPassword)),$b({getSuccessMsg:()=>"Successfully reset user password",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to reset user's password</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Eb={action:xb,reducer:Ob},Ab=ec("users/getCustomAttributes",((e,{extra:{api:t}})=>t.user.getCustomAttributes())),Nb=yb(Ab)({onFulfilled:(e,t)=>{e.customAttributes.data=t.payload}},bb((e=>e.customAttributes))),jb={action:Ab,reducer:Nb},Mb=ec("users/search",((e,{extra:{api:t},getState:i})=>{const n=i().searchParams;return t.user.search(Object.assign(Object.assign({},n),e))})),Pb=yb(Mb)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.usersList.data=t.payload}},bb((e=>e.usersList))),Ub={action:Mb,reducer:Pb},Tb=ec("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),Wb=yb(Tb)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},bb((e=>e.tenantRoles))),Lb={action:Tb,reducer:Wb},Db=ec("tenant/getSubTenantRoles",((e,{extra:{api:t}})=>t.tenant.getSubTenantRoles())),_b=yb(Db)({onFulfilled:(e,t)=>{e.subTenantRoles.data=t.payload.roles},onRejected:e=>{e.subTenantRoles.data=[]}},bb((e=>e.subTenantRoles))),Fb={action:Db,reducer:_b},qb=ec("users/update",((e,{extra:{api:t}})=>t.user.update(e))),Bb=yb(qb)({onFulfilled:(e,t)=>{const i=e.usersList.data.findIndex((e=>wn(e.loginIds,t.payload.loginIds)));-1!==i&&(e.usersList.data[i]=t.payload)}},bb((e=>e.updateUser)),$b({getSuccessMsg:()=>"User updated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to update user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Vb={action:qb,reducer:Bb},Kb=ec("users/enable",((e,{extra:{api:t}})=>t.user.enable(e))),Hb=yb(Kb)({onFulfilled:(e,t)=>{var i;const n=e.usersList.data.findIndex((e=>{var i;return wn(e.loginIds,null===(i=t.payload.user)||void 0===i?void 0:i.loginIds)}));-1!==n&&(e.usersList.data[n].status=null===(i=t.payload.user)||void 0===i?void 0:i.status)}},bb((e=>e.enableUser)),$b({getSuccessMsg:()=>"User enabled successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to enable user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),zb={action:Kb,reducer:Hb},Gb=ec("users/disable",((e,{extra:{api:t}})=>t.user.disable(e))),Jb=yb(Gb)({onFulfilled:(e,t)=>{var i;const n=e.usersList.data.findIndex((e=>{var i;return wn(e.loginIds,null===(i=t.payload.user)||void 0===i?void 0:i.loginIds)}));-1!==n&&(e.usersList.data[n].status=null===(i=t.payload.user)||void 0===i?void 0:i.status)}},bb((e=>e.disableUser)),$b({getSuccessMsg:()=>"User disabled successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to disable user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Zb={action:Gb,reducer:Jb},Yb=ec("users/removePasskey",((e,{extra:{api:t}})=>t.user.removePasskey(e))),Xb={action:Yb,reducer:yb(Yb)(bb((e=>e.removePasskey)),$b({getSuccessMsg:()=>"Successfully removed user's passkey",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to remove user's passkey</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}}))},Qb={usersList:{data:[],loading:!1,error:null},createUser:{loading:!1,error:null},updateUser:{loading:!1,error:null},deleteUser:{loading:!1,error:null},enableUser:{loading:!1,error:null},disableUser:{loading:!1,error:null},removePasskey:{loading:!1,error:null},setTempUserPassword:{loading:!1,error:null},customAttributes:{loading:!1,error:null,data:[]},tenantRoles:{loading:!1,error:null,data:[]},subTenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedUsersLoginIds:[],notifications:[]},e$="/v1/mgmt/user/search",t$="/v1/mgmt/user/delete/batch",i$="/v1/mgmt/user/create",n$="/v1/mgmt/user/patch",o$="/v1/mgmt/user/update/status",r$="/v1/mgmt/user/password/set/temporary",s$="/v1/mgmt/user/passkeys/delete",a$="/v1/mgmt/user/customattributes",d$="/v1/mgmt/role/all",l$="/v1/mgmt/role/subtenant/all",c$=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),u$=({httpClient:e,tenant:t,mock:i})=>({search:(...n)=>c(void 0,[...n],void 0,(function*({page:n,limit:o=1e4,customAttributes:r,statuses:s,emails:a,phones:d,text:l,sort:u}={}){if(i)return(e=>c(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((i=>{const n=[],o=(new Date).getTime();for(let e=1;e<10;e+=1)n.push({loginIds:[`user${e}@company.com`],externalIds:[`user${e}@company.com`],userId:`user-${e}`,name:`User ${e}`,email:`user${e}@company.com`,roleNames:[`Role ${e}`],phone:`+1-202-555-010${e}`,verifiedEmail:!0,verifiedPhone:!0,userTenants:[{tenantId:"sub-tenant-1",tenantName:"Hurray",roleNames:["Role 1","Role 2"]}],status:"enabled",editable:!0,createdTime:o,createdTimeFormatted:new Date(1e3*(o||0)).toLocaleString(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:"",password:!0,SAML:e%3==0,OIDC:e%3==1,SCIM:e%3==2,test:!1,TOTP:!1,webauthn:!1});t.forEach((e=>{n.sort(((t,i)=>((e,t,i)=>{if("boolean"==typeof e&&"boolean"==typeof t){const n=e?1:0,o=t?1:0;return i?n-o:o-n}const n=(null==e?void 0:e.toString())||"",o=(null==t?void 0:t.toString())||"";return i?o.localeCompare(n):n.localeCompare(o)})(t[e.field],i[e.field],e.desc)))})),i(n.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.phone.toLowerCase().includes(e.toLowerCase())||t.status.toLowerCase().includes(e.toLowerCase())||"active"===e.toLowerCase()||t.familyName.toLowerCase().includes(e.toLowerCase())||t.givenName.toLowerCase().includes(e.toLowerCase())||t.middleName.toLowerCase().includes(e.toLowerCase())||t.email.toLowerCase().includes(e.toLowerCase()))))}))})))({page:n,limit:o,customAttributes:r,statuses:s,emails:a,phones:d,text:l,sort:u});const h=yield e.post(e$,{limit:o,page:n,withTestUser:!1,customAttributes:r,statuses:s,emails:a,phones:d,text:l,sort:u},{queryParams:{tenant:t}});return yield c$(h),(yield h.json()).users})),deleteBatch:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(t$,{userIds:n},{queryParams:{tenant:t}});return yield c$(o),o.json()})),create:n=>c(void 0,[n],void 0,(function*({loginId:n,email:o,phone:r,displayName:s,roles:a,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,givenName:f,middleName:p,familyName:g,additionalLoginIds:v,sendSMS:m,sendMail:y,inviteUrl:b,invite:$,userTenants:w}){if(i)return(e=>c(void 0,[e],void 0,(function*({loginId:e,email:t,phone:i,displayName:n,roles:o,customAttributes:r,picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,userTenants:h}){return new Promise((f=>{const p=Math.random().toString(10).substring(15);f({loginIds:[e],externalIds:[e],userId:`user-${p}`,email:t,phone:i,name:n,roleNames:o,customAttributes:r,picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,createdTime:(new Date).getTime(),editable:!0,password:!0,SAML:!1,SCIM:!1,OIDC:!1,status:"enabled",test:!1,TOTP:!1,userTenants:h||[],webauthn:!1})}))})))({loginId:n,email:o,phone:r,displayName:s,roles:a,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,givenName:f,middleName:p,familyName:g,additionalLoginIds:v,sendSMS:m,sendMail:y,inviteUrl:b,invite:$,userTenants:w});const C=yield e.post(i$,{loginId:n,email:o,phone:r,displayName:s,givenName:f,middleName:p,familyName:g,roleNames:a,userTenants:w,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,additionalLoginIds:v,sendSMS:m,sendMail:y,inviteUrl:b,invite:$},{queryParams:{tenant:t}});return yield c$(C),(yield C.json()).user})),update:n=>c(void 0,[n],void 0,(function*({loginId:n,email:o,phone:r,displayName:s,roles:a,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,givenName:f,middleName:p,familyName:g,additionalLoginIds:v,userTenants:m}){if(i)return(e=>c(void 0,[e],void 0,(function*({loginId:e,email:t,phone:i,displayName:n,roles:o,customAttributes:r,picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,userTenants:h}){return new Promise((f=>{f({loginIds:[e],externalIds:[e],userId:e,email:t,phone:i,name:n,roleNames:o,customAttributes:r||{},picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,createdTime:(new Date).getTime(),editable:!0,password:!0,SAML:!1,SCIM:!1,OIDC:!1,status:"enabled",test:!1,TOTP:!1,userTenants:h||[],webauthn:!1})}))})))({loginId:n,email:o,phone:r,displayName:s,roles:a,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,givenName:f,middleName:p,familyName:g,additionalLoginIds:v,userTenants:m});const y=yield e.patch(n$,{loginId:n,email:o,phone:r,displayName:s,givenName:f,middleName:p,familyName:g,roleNames:a,userTenants:m,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,additionalLoginIds:v},{queryParams:{tenant:t}});return yield c$(y),(yield y.json()).user})),enable:n=>c(void 0,void 0,void 0,(function*(){if(i)return(e=>c(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({user:{loginIds:[e],status:"enabled"}})}))})))(n);const o=yield e.post(o$,{loginId:n,status:"enabled"},{queryParams:{tenant:t}});return yield c$(o),o.json()})),disable:n=>c(void 0,void 0,void 0,(function*(){if(i)return(e=>c(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({user:{loginIds:[e],status:"disabled"}})}))})))(n);const o=yield e.post(o$,{loginId:n,status:"disabled"},{queryParams:{tenant:t}});return yield c$(o),o.json()})),removePasskey:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(s$,{loginId:n},{queryParams:{tenant:t}});return yield c$(o),o.json()})),setTempPassword:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({cleartext:Math.random().toString(20).substring(2)})}))}));const o=yield e.post(r$,{loginId:n},{queryParams:{tenant:t}});return yield c$(o),o.json()})),getCustomAttributes:()=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e([])}))}));const n=yield e.get(a$,{queryParams:{tenant:t}});return yield c$(n),(yield n.json()).data}))}),h$=({httpClient:e,tenant:t,mock:i})=>({getTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(i)return(e=>new Promise((t=>{const i=[];for(let t=1;t<5;t+=1)i.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:i})})))(t);const n=yield e.get(d$,{queryParams:{tenant:t}});return yield c$(n),n.json()})),getSubTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(i)return new Promise((e=>{e({roles:[{tenantId:"sub-tenant-1",tenantName:"Sub Tenant 1",roleNames:["Role 1","Role 2"]},{tenantId:"sub-tenant-2",tenantName:"Sub Tenant 2",roleNames:["Role 1","Role 3"]},{tenantId:"sub-tenant-3",tenantName:"Sub Tenant 3",roleNames:["Role 2"]}]})}));const n=yield e.get(l$,{queryParams:{tenant:t}});return yield c$(n),n.json()}))}),f$=Rn((e=>{var t,i,n,o;const r=bn(Vr,uc,qr,Ur,Kr,fc,Br({tenant:Br.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||us}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i,n)=>{const o=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-management-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.13.1"}}));return{user:u$({httpClient:o.httpClient,tenant:t,mock:i}),tenant:h$({httpClient:o.httpClient,tenant:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),p$=Rn((e=>{const t=bn(lc({name:"widget",initialState:Qb,reducers:{setSelectedUsersIds:(e,{payload:t})=>{e.selectedUsersLoginIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{kb.reducer(e),Vb.reducer(e),zb.reducer(e),Zb.reducer(e),Rb.reducer(e),Ub.reducer(e),Eb.reducer(e),Xb.reducer(e),jb.reducer(e),Lb.reducer(e),Fb.reducer(e)},asyncActions:{searchUsers:Ub.action,createUser:kb.action,updateUser:Vb.action,enableUser:zb.action,disableUser:Zb.action,deleteUsers:Rb.action,removePasskey:Xb.action,getCustomAttributes:jb.action,getTenantRoles:Lb.action,getSubTenantRoles:Fb.action,setTempUserPassword:Eb.action}}),Fr,Ur,f$)(e);return class extends t{constructor(...e){super(...e),this.state=Qb,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),g$=Rn((e=>{const t=bn(Gr,uc)(e);return class extends t{fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),v$=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,g$,p$,hc)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.injectStyle(".hidden { display: none; }");const o=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([u(this,t,"m",i).call(this),this.actions.searchUsers(),this.actions.getTenantRoles(),this.actions.getCustomAttributes(),o]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),m$=Rn((e=>{var t,i,n,o,r,s,a,d,l;return l=class extends(bn(p$,nd,cc,Ur,hc,v$)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),a.set(this,(()=>c(this,void 0,void 0,(function*(){yield u(this,i,"f").setData(Vy(this.state).map((({name:e})=>({value:e,label:e}))))})))),d.set(this,(()=>{var e;const t=Jy(this.state);null===(e=u(this,n,"f"))||void 0===e||e.classList.toggle("hidden",!t),t&&u(this,o,"f").setData(Gy(this.state))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",r).call(this)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,a=new WeakMap,d=new WeakMap,t=new WeakSet,r=function(){return c(this,void 0,void 0,(function*(){var e;this.createUserModal=this.createModal(),this.createUserModal.setContent($n(yield this.fetchWidgetPage("create-user-modal.html")));const r=new Ta((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}),l=()=>{this.resetFormData(this.createUserModal.ele),u(this,o,"f").value=[]};r.onClick((()=>{this.createUserModal.close(),l()}));const f=new Ta((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});f.onClick((()=>c(this,void 0,void 0,(function*(){if(this.validateForm(this.createUserModal.ele)){const e=this.getFormData(this.createUserModal.ele),t=u(this,o,"f").mergedValue;this.actions.createUser(Object.assign(Object.assign({},Ly(e,"customAttributes")),{userTenants:t,invite:!0,verifiedEmail:!0,verifiedPhone:!0})),this.createUserModal.close(),l()}})))),h(this,i,new Ha((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),h(this,n,null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-section"]'),"f"),h(this,o,new Ka((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-mappings"]')}),{logger:this.logger}),"f"),u(this,a,"f").call(this),this.createUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([this.actions.getTenantRoles(),e]),yield u(this,a,"f").call(this),u(this,d,"f").call(this),u(this,t,"m",s).call(this)}))}))},s=function(){const e=zy(this.state);this.getFormFieldNames(this.createUserModal.ele).forEach((t=>{const[i,n]=t.split(".");if("customAttributes"!==i)return;const o=e.find((e=>e.name===n));o?o.editable||this.disableFormField(this.createUserModal.ele,t):this.removeFormField(this.createUserModal.ele,t)}))},l})),y$=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,m$,v$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.createButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-user"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createUserModal.open()))},n})),b$=Rn((e=>{var t,i,n;return n=class extends(bn(p$,nd,Ur,v$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteUsersModal=this.createModal(),this.deleteUsersModal.setContent($n(yield this.fetchWidgetPage("delete-users-modal.html")));const t=new Ta((()=>{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 i=new Ta((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=tb(this.state);this.actions.deleteUsers(e),this.deleteUsersModal.close()}));const n=new Za(null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteUsersModal.beforeOpen=()=>{const e=ub(this.state);n.text=`Delete ${e}?`}}))},n})),$$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,v$,p$,b$)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),mb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.deleteButton=new Ta(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()}))},o})),w$=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(p$,nd,Ur,cc,v$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,i=function(){new Ta((()=>{var e;return null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.disableUserModal.close()))},n=function(){new Ta((()=>{var e;return null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=db(this.state);this.actions.disableUser(e),this.disableUserModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.disableUserModal=this.createModal(),this.disableUserModal.setContent($n(yield this.fetchWidgetPage("disable-user-modal.html"))),u(this,t,"m",i).call(this),u(this,t,"m",n).call(this);const o=new Za(null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.disableUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=ub(this.state);o.text=`Disable ${e}?`}))}))},r})),C$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,v$,p$,w$,cc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.disableButton.enable():this.disableButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),fb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.disableButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="disable-user"]'),{logger:this.logger}),this.disableButton.disable(),this.disableButton.onClick((()=>{this.disableUserModal.open()}))},o})),k$=e=>{if(!e)return e;const t=Py(e.startsWith("+")?e:`+${e}`);if(!t)return e;const i=new RegExp(`(\\+?${null==t?void 0:t.countryCallingCode})(.*)`);return(null==t?void 0:t.number.replace(i,"$1-$2"))||e},S$=Rn((e=>{var t,i,n,o,r,s,a,d,f,p,g,v,m;return m=class extends(bn(p$,nd,Ur,cc,hc,v$)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),d.set(this,(()=>c(this,void 0,void 0,(function*(){yield u(this,n,"f").setData(Vy(this.state).map((({name:e})=>({value:e,label:e}))))})))),f.set(this,(()=>{var e;const t=Jy(this.state);null===(e=u(this,o,"f"))||void 0===e||e.classList.toggle("hidden",!t),t&&u(this,r,"f").setData(Gy(this.state))})),g.set(this,(()=>{var e,t;const i=null===(e=eb(this.state))||void 0===e?void 0:e[0],n=Object.assign({loginId:null===(t=null==i?void 0:i.loginIds)||void 0===t?void 0:t.join(", "),displayName:null==i?void 0:i.name,email:null==i?void 0:i.email,phone:k$(null==i?void 0:i.phone),roles:null==i?void 0:i.roleNames,givenName:null==i?void 0:i.givenName,familyName:null==i?void 0:i.familyName,middleName:null==i?void 0:i.middleName},Dy(i.customAttributes,"customAttributes"));this.setFormData(this.editUserModal.ele,n),u(this,r,"f").value=(null==i?void 0:i.userTenants)||[]}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",v).call(this)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,d=new WeakMap,f=new WeakMap,g=new WeakMap,t=new WeakSet,s=function(){new Ta((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editUserModal.close()))},a=function(){new Ta((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{if(this.validateForm(this.editUserModal.ele)){const e=this.getFormData(this.editUserModal.ele),{loginId:t}=e,i=l(e,["loginId"]),n=u(this,o,"f")&&!u(this,o,"f").classList.contains("hidden")?u(this,r,"f").mergedValue:void 0;this.actions.updateUser(Object.assign(Object.assign({loginId:t.split(", ")[0]},Ly(i,"customAttributes")),void 0!==n&&{userTenants:n})),this.editUserModal.close(),this.resetFormData(this.editUserModal.ele)}}))},p=function(){const e=zy(this.state);this.getFormFieldNames(this.editUserModal.ele).forEach((t=>{const[i,n]=t.split(".");if("customAttributes"!==i)return;const o=e.find((e=>e.name===n));o?o.editable||this.disableFormField(this.editUserModal.ele,t):this.removeFormField(this.editUserModal.ele,t)}))},v=function(){return c(this,void 0,void 0,(function*(){var e,l;this.editUserModal=this.createModal(),this.editUserModal.setContent($n(yield this.fetchWidgetPage("edit-user-modal.html"))),u(this,t,"m",s).call(this),u(this,t,"m",a).call(this),h(this,i,new Ya(null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[name="loginId"]'),{logger:this.logger}),"f"),h(this,n,new Ha((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),h(this,o,null===(l=this.editUserModal.ele)||void 0===l?void 0:l.querySelector('[data-id="sub-tenant-section"]'),"f"),h(this,r,new Ka((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-mappings"]')}),{logger:this.logger}),"f"),this.editUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([this.actions.getTenantRoles(),e]),yield u(this,d,"f").call(this),u(this,i,"f").disable(),u(this,f,"f").call(this),u(this,g,"f").call(this),u(this,t,"m",p).call(this)}))}))},m})),I$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,v$,p$,S$,cc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),pb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.editButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-user"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editUserModal.open()}))},o})),R$=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(p$,nd,Ur,cc,v$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,i=function(){new Ta((()=>{var e;return null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.enableUserModal.close()))},n=function(){new Ta((()=>{var e;return null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=db(this.state);this.actions.enableUser(e),this.enableUserModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.enableUserModal=this.createModal(),this.enableUserModal.setContent($n(yield this.fetchWidgetPage("enable-user-modal.html"))),u(this,t,"m",i).call(this),u(this,t,"m",n).call(this);const o=new Za(null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.enableUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=ub(this.state);o.text=`Activate ${e}?`}))}))},r})),x$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,v$,p$,R$,cc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.enableButton.enable():this.enableButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),hb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.enableButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="enable-user"]'),{logger:this.logger}),this.enableButton.disable(),this.enableButton.onClick((()=>{this.enableUserModal.open()}))},o})),O$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,v$,p$)(e)){constructor(){super(...arguments),t.add(this),i.set(this,In((()=>{this.actions.searchUsers({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.searchInput=new Ya(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,i,"f"))},o})),E$={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="currentcolor"/>\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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},A$=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,p$,rd,Fr)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Cn((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",n).call(this,e);r.setContent(u(this,t,"m",i).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),Hy)}))}},o=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const i=E$[e],n=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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${n.outerHTML}`},n=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),N$=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(p$,nd,Ur,cc,v$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,i=function(){new Ta((()=>{var e;return null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.removePasskeyModal.close()))},n=function(){new Ta((()=>{var e;return null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=db(this.state);this.actions.removePasskey(e),this.removePasskeyModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.removePasskeyModal=this.createModal(),this.removePasskeyModal.setContent($n(yield this.fetchWidgetPage("remove-passkey-modal.html"))),u(this,t,"m",i).call(this),u(this,t,"m",n).call(this);const o=new Za(null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.removePasskeyModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=ub(this.state);o.text=`Remove passkey for ${e}?`}))}))},r})),j$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,v$,p$,N$,cc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.removePasskeyButton.enable():this.removePasskeyButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),gb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.removePasskeyButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="remove-passkey"]'),{logger:this.logger}),this.removePasskeyButton.disable(),this.removePasskeyButton.onClick((()=>{this.removePasskeyModal.open()}))},o})),M$=Rn((e=>{var t,i,n,o,r,s,a,d;return d=class extends(bn(p$,Ur,v$)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Cn((e=>{this.usersTable.data=e}))),r.set(this,In(((e,t)=>{const i=[],{value:n}=t;if(n){const t=e.path;i.push({field:t,desc:"desc"===n})}this.actions.searchUsers({sort:i})}))),s.set(this,Cn((e=>{this.usersTable.filterColumns((t=>{var i;const[n,o]=(null===(i=t.path)||void 0===i?void 0:i.split("."))||[];return"customAttributes"!==n||!!(null==e?void 0:e.find((e=>e.name===o)))}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this),u(this,o,"f").call(this,Qy(this.state)),u(this,s,"f").call(this,zy(this.state)),this.subscribe(u(this,s,"f").bind(this),zy),this.subscribe(u(this,o,"f").bind(this),Qy)}))}},o=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,i=function(){const e=e=>{var t;return null===(t=this.usersTable.ele)||void 0===t?void 0:t.querySelector(`[path="${e}"]`)},t=e=>{var t;const i=`descope-grid-${e}-column`;return null===(t=this.usersTable.ele)||void 0===t?void 0:t.querySelector(i)},i=this.usersTable.renderColumn;this.usersTable.renderColumn=({path:n,header:o,type:r,attrs:s})=>{const a=e(n)||t(r);if(!a)return i({path:n,header:o,type:r,attrs:s});const d=a.cloneNode(!0),l=Object.assign(Object.assign({},s),{header:o});return Object.entries(l).forEach((([e,t])=>{d.setAttribute(e,t)})),d.outerHTML}},n=function(){var e;this.usersTable=new Fa(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)))})),this.usersTable.onColumnsChange(u(this,t,"m",a).bind(this)),u(this,t,"m",i).call(this),u(this,t,"m",a).call(this)},a=function(){this.usersTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,r,"f").call(this,e.target,e.detail)}))}))},d})),P$=Rn((e=>{var t,i,n;return n=class extends(bn(p$,nd,Ur,cc,v$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){this.generatedPasswordModal=this.createModal(),this.generatedPasswordModal.setContent($n(yield this.fetchWidgetPage("generated-password-modal.html"))),new Ta((()=>{var e;return null===(e=this.generatedPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.generatedPasswordModal.ele)["generated-password"]),this.resetFormData(this.generatedPasswordModal.ele),this.generatedPasswordModal.close()}))}))},n})),U$=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(p$,nd,Ur,cc,v$,P$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,i=function(){new Ta((()=>{var e;return null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.resetPasswordModal.close()))},n=function(){new Ta((()=>{var e;return null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){var e;const t=db(this.state),i=yield this.actions.setTempUserPassword(t);this.resetPasswordModal.close(),this.setFormData(this.generatedPasswordModal.ele,{"generated-password":null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e.cleartext}),this.generatedPasswordModal.open()}))))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.resetPasswordModal=this.createModal(),this.resetPasswordModal.setContent($n(yield this.fetchWidgetPage("reset-password-modal.html"))),u(this,t,"m",i).call(this),u(this,t,"m",n).call(this);const o=new Za(null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.resetPasswordModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=ub(this.state);o.text=`This will generate a new temporary password for ${e}?`}))}))},r})),T$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,v$,p$,U$,cc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.resetPasswordButton.enable():this.resetPasswordButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),vb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.resetPasswordButton=new Ta(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="reset-password"]'),{logger:this.logger}),this.resetPasswordButton.disable(),this.resetPasswordButton.onClick((()=>{this.resetPasswordModal.open()}))},o})),W$=Rn((e=>class extends(bn(ps,qr)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),L$=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g,v,m;return m=class extends(bn(W$,p$,nd,Ur,cc,v$)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,[]),r.set(this,null),s.set(this,null),v.set(this,Cn((e=>{u(this,o,"f").forEach((t=>{"onlyOne"===t.enableMode&&1===e.length||"oneOrMore"===t.enableMode&&e.length>0||"always"===t.enableMode?t.enable():t.disable()}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",l).call(this),u(this,t,"m",d).call(this),u(this,v,"f").call(this,Ky(this.state))}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,v=new WeakMap,t=new WeakSet,a=function(e){const i=new La(e,{logger:this.logger});i.onClick((()=>{u(this,t,"m",g).call(this,i.flowId)})),this.subscribe(u(this,v,"f").bind(this),Ky),u(this,o,"f").push(i)},d=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(i).forEach((e=>{u(this,t,"m",a).call(this,e)}))},l=function(){h(this,i,this.createModal({"data-id":"generic-flow-modal"}),"f"),u(this,i,"f").afterClose=()=>{var e;u(this,r,"f")&&(null===(e=u(this,s,"f"))||void 0===e||e.call(this),h(this,r,null,"f"))},h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,n,"f"))},f=function(){var e;u(this,i,"f").open(),null===(e=u(this,s,"f"))||void 0===e||e.call(this)},p=function(e,i){i=()=>u(this,t,"m",f).call(this),h(this,s,u(this,n,"f").onPageUpdated(i),"f")},g=function(e){u(this,i,"f").setContent(Fy({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,client:JSON.stringify({userIds:tb(this.state),loginIds:ib(this.state),usersAndRoles:nb(this.state)}),tenant:this.tenantId})),u(this,t,"m",p).call(this,u(this,i,"f"),u(this,r,"f")),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.searchUsers()}))},m})),D$="widget-flow",_$=Rn((e=>{var t,i,n;return n=class extends(bn(Fr,nd,p$,fc,Ur,ps)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const o=qy(D$);o&&(function(e){if(window.history.replaceState&&qy(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(D$),u(this,t,"m",i).call(this,o))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(Fy({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),new Wa((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close()})),t.afterClose=()=>{t.remove()},t.open()},n})),F$=Rn((e=>class extends(bn(Ea,ps,_$,M$,y$,$$,I$,x$,C$,T$,j$,O$,A$,L$)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),q$=bn((e=>class extends(F$(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Oa})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-management-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.13.1"}}}))}}))(HTMLElement);customElements.define("descope-user-management-widget",q$);var B$=Object.freeze({__proto__:null,default:q$});const V$=(e={})=>{const t=$n("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,i])=>{t.content.querySelector("descope-wc").setAttribute(kn(e),(e=>"string"==typeof e?e:(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(i))})),t};function K$(e){return new URLSearchParams(window.location.search).get(e)}const H$=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},z$=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),G$=ec("users/me",((e,{extra:{api:t}})=>t.user.me())),J$=H$(G$)({onFulfilled:(e,t)=>{e.me.data=t.payload}},z$((e=>e.me))),Z$={action:G$,reducer:J$},Y$=ec("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),X$=H$(Y$)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},z$((e=>e.devices))),Q$={action:Y$,reducer:X$},ew=ec("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),tw=H$(ew)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},z$((e=>e.passkeys))),iw={action:ew,reducer:tw},nw=ec("users/logout",((e,{extra:{api:t}})=>t.user.logout())),ow={action:nw,reducer:H$(nw)({})},rw=e=>{if(!e)return null;const t=(e=>{try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(t).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""));return JSON.parse(i)}catch(e){return null}})(e);return(null==t?void 0:t.dct)||null},sw=e=>e.me.data,aw=wl(sw,(e=>e.userId)),dw=wl(sw,(e=>e.picture)),lw=wl(sw,(e=>e.email)),cw=wl(sw,(e=>e.verifiedEmail)),uw=wl(sw,(e=>e.name)),hw=wl(sw,(e=>e.phone)),fw=wl(sw,(e=>e.verifiedPhone)),pw=wl(lw,cw,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),gw=wl(hw,fw,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),vw=wl(sw,(e=>e.webauthn));wl(sw,(e=>e.password));const mw=wl(sw,(e=>e.TOTP)),yw=wl(sw,(e=>e.customAttributes)),bw=wl(sw,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),$w=wl((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:i,lastLoginTime:n,isCurrentDevice:o})=>({id:e,name:t,deviceType:i,lastLoginDate:1e3*parseInt(n,10),isCurrent:o}))))),ww=wl((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:i,createdTime:n})=>({id:e,name:t,passkeyType:i,createdAt:1e3*n}))))),Cw=e=>e.notifications,kw=wl(sw,(e=>e.userTenants||[])),Sw=e=>e.tenant.currentTenantId,Iw=ec("tenant/select",((e,t)=>c(void 0,[e,t],void 0,(function*(e,{extra:{api:t},getState:i}){if(e===Sw(i()))return null;const n=yield t.user.setCurrentTenant(e),o=n.sessionJwt||n.sessionToken;try{return{tenantId:rw(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),Rw={action:Iw,reducer:H$(Iw)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var i;e.tenant.currentTenantId=null===(i=t.payload)||void 0===i?void 0:i.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},z$((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{if(t){const n=t(i);n&&e.notifications.push({type:"success",msg:n})}},onRejected:(t,i)=>{if(e){const n=e(i);n&&t.notifications.push({type:"error",msg:n})}}}))({getErrorMsg:e=>{var t,i;const n=(null===(t=e.error)||void 0===t?void 0:t.message)||"";return"Error"===(null===(i=e.error)||void 0===i?void 0:i.name)?n:`${n||"Error"}`}}))},xw={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},Ow="/v1/auth/me",Ew="/v1/mgmt/user/trusteddevices/list",Aw="/v1/mgmt/user/passkeys/list",Nw="/v1/auth/tenant/select",jw=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),Mw=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],Pw=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:Mw,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))}));const i=yield e.get(Ow);return yield jw(i),i.json()})),setCurrentTenant:t=>c(void 0,void 0,void 0,(function*(){const i=yield e.post(Nw,{tenant:t});return yield jw(i),i.json()}))}),Uw=({httpClient:e,mock:t})=>({devices:i=>c(void 0,[i],void 0,(function*({userId:i}){if(t)return{devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]};const n=yield e.post(Ew,{identifiers:[i]});return yield jw(n),n.json()}))}),Tw=({httpClient:e,mock:t})=>({listPasskeys:i=>c(void 0,[i],void 0,(function*({userId:i}){if(t)return{passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]};const n=yield e.post(Aw,{loginId:i});return yield jw(n),n.json()}))}),Ww=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,Kr,fc)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||us}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i)=>{const n=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.11.3"}}));return{user:Object.assign(Object.assign({},Pw({httpClient:n.httpClient,mock:t})),{logout:t?()=>c(void 0,void 0,void 0,(function*(){})):n.logout}),device:Object.assign({},Uw({httpClient:n.httpClient,mock:t})),passkey:Object.assign({},Tw({httpClient:n.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},o})),Lw=Rn((e=>{const t=bn(lc({name:"widget",initialState:xw,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{Z$.reducer(e),Q$.reducer(e),iw.reducer(e),ow.reducer(e),Rw.reducer(e)},asyncActions:{getMe:Z$.action,listDevices:Q$.action,listPasskeys:iw.action,logout:ow.action,selectTenant:Rw.action}}),Fr,Ur,Ww)(e);return class extends t{constructor(...e){super(...e),this.state=xw,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Dw="widget-flow",_w=Rn((e=>{var t,i,n;return n=class extends(bn(Fr,nd,Lw,fc,Ur,ps)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const o=K$(Dw);o&&(function(e){if(window.history.replaceState&&K$(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(Dw),u(this,t,"m",i).call(this,o))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(V$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),new Wa((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},n})),Fw=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),qw=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,Fw,Lw)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield this.actions.getMe(),yield u(this,t,"m",i).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),Bw=Rn((e=>class extends(bn(ps,qr)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Vw=Rn((e=>{var t,i,n,o,r,s,a,d,l;return l=class extends(bn(Bw,ps,Lw,Ur,fc,qw,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),a.set(this,Cn((e=>{this.avatar.image=e}))),d.set(this,Cn((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this),u(this,a,"f").call(this,dw(this.state)),u(this,d,"f").call(this,uw(this.state)),this.subscribe(u(this,a,"f").bind(this),dw),this.subscribe(u(this,d,"f").bind(this),uw)}))}},i=new WeakMap,n=new WeakMap,a=new WeakMap,d=new WeakMap,t=new WeakSet,o=function(){this.avatar.flowId&&(h(this,i,this.createModal({"data-id":"update-pic"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,n,"f")))},r=function(){u(this,i,"f").setContent(V$({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},s=function(){this.avatar=new Ua((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},l})),Kw=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g,v;return v=class extends(bn(Bw,Lw,Ur,qw,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.emailUserAttr.value=e}))),g.set(this,Cn((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,lw(this.state)),u(this,g,"f").call(this,pw(this.state)),this.subscribe(u(this,p,"f").bind(this),lw),this.subscribe(u(this,g,"f").bind(this),pw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,g=new WeakMap,t=new WeakSet,s=function(){this.emailUserAttr.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-email"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(V$({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},d=function(){this.emailUserAttr.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-email"}),"f"),h(this,r,new Wa((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(V$({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe()}))},f=function(){this.emailUserAttr=new Xa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},v})),Hw=Rn((e=>{var t,i,n;return n=class extends(bn(Lw,Ur,qw,nd)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){this.logout=new Ta((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>c(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},n})),zw=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Bw,Lw,Ur,qw,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,uw(this.state)),this.subscribe(u(this,p,"f").bind(this),uw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.nameUserAttr.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-name"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(V$({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},d=function(){this.nameUserAttr.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-name"}),"f"),h(this,r,new Wa((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(V$({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe()}))},f=function(){this.nameUserAttr=new Xa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),Gw=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Bw,Lw,Ur,qw,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,vw(this.state)),this.subscribe(u(this,p,"f").bind(this),vw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.passkeyUserAuthMethod.flowId&&(h(this,i,this.createModal({"data-id":"add-passkey"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(V$({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},d=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(h(this,o,this.createModal({"data-id":"remove-passkey"}),"f"),h(this,r,new Wa((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(V$({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe()}))},f=function(){this.passkeyUserAuthMethod=new Qa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),Jw=Rn((e=>{var t,i,n,o,r,s;return s=class extends(bn(Bw,Lw,Ur,qw,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new Qa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.initPasswordAuthMethod(),u(this,t,"m",o).call(this)}))}},i=new WeakMap,n=new WeakMap,t=new WeakSet,o=function(){this.passwordUserAuthMethod.flowId&&(h(this,i,this.createModal({"data-id":"password"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,n,"f")))},r=function(){u(this,i,"f").setContent(V$({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close()}))},s})),Zw=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g,v;return v=class extends(bn(Bw,Lw,Ur,qw,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.phoneUserAttr.value=e}))),g.set(this,Cn((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,hw(this.state)),u(this,g,"f").call(this,gw(this.state)),this.subscribe(u(this,p,"f").bind(this),hw),this.subscribe(u(this,g,"f").bind(this),gw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,g=new WeakMap,t=new WeakSet,s=function(){this.phoneUserAttr.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-phone"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(V$({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},d=function(){this.phoneUserAttr.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-phone"}),"f"),h(this,r,new Wa((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(V$({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe()}))},f=function(){this.phoneUserAttr=new Xa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},v})),Yw=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Bw,Lw,Ur,qw,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,mw(this.state)),this.subscribe(u(this,p,"f").bind(this),mw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.totpUserAuthMethod.flowId&&(h(this,i,this.createModal({"data-id":"totp"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(V$({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},d=function(){this.totpUserAuthMethod.fulfilledFlowId&&(h(this,o,this.createModal({"data-id":"remove-totp"}),"f"),h(this,r,new Wa((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(V$({projectId:this.projectId,flowId:this.totpUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe()}))},f=function(){this.totpUserAuthMethod=new Qa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),Xw=Rn((e=>{var t,i,n,o,r,s,a,d,l,h,f;return f=class extends(bn(Bw,Lw,Ur,qw,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,{}),n.set(this,{}),o.set(this,{}),r.set(this,{}),d.set(this,Cn((e=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("builtin.",""),o=e[n],r=new Xa(i,{logger:this.logger});r.value=(o||"").toString(),u(this,t,"m",l).call(this,i,n,r),u(this,t,"m",h).call(this,i,n,r)}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),u(this,d,"f").call(this,bw(this.state)),this.subscribe(u(this,d,"f").bind(this),bw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,d=new WeakMap,t=new WeakSet,s=function(e){var t,o;null===(t=u(this,i,"f")[e])||void 0===t||t.setContent(V$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(o=u(this,n,"f")[e])||void 0===o||o.onSuccess((()=>{var t;null===(t=u(this,i,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},a=function(e){var t,i;null===(t=u(this,o,"f")[e])||void 0===t||t.setContent(V$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(i=u(this,r,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=u(this,o,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},l=function(e,o,r){const a=e.getAttribute("edit-flow-id");a&&(u(this,i,"f")[a]=this.createModal({"data-id":`edit-${o}`}),u(this,n,"f")[a]=new Wa((()=>{var e,t;return null===(t=null===(e=u(this,i,"f")[a])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,i,"f")[a].afterClose=u(this,t,"m",s).bind(this,a),r.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,i,"f"))||void 0===e?void 0:e[a])||void 0===t||t.open()})),u(this,t,"m",s).call(this,a),this.syncFlowTheme(u(this,n,"f")[a]))},h=function(e,i,n){const s=e.getAttribute("delete-flow-id");s&&(u(this,o,"f")[s]=this.createModal({"data-id":`delete-${i}`}),u(this,r,"f")[s]=new Wa((()=>{var e,t;return null===(t=null===(e=u(this,o,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,o,"f")[s].afterClose=u(this,t,"m",a).bind(this,s),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,o,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),u(this,t,"m",a).call(this,s),this.syncFlowTheme(u(this,r,"f")[s]))},f}));var Qw;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Qw||(Qw={}));const eC=Rn((e=>{var t,i,n,o,r,s,a,d,l,h,f;return i=class extends(bn(Bw,Lw,Ur,qw,fc,nd)(e)){constructor(){super(...arguments),t.add(this),n.set(this,{}),o.set(this,{}),r.set(this,{}),s.set(this,{}),l.set(this,Cn((e=>{var n;const o=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(o).forEach((n=>{const o=n.getAttribute("data-id").replace("customAttributes.",""),r=n.getAttribute("data-type")||Qw.TEXT,s=e[o],a=new Xa(n,{logger:this.logger});a.value=i.getFormattedValue(r,s),u(this,t,"m",h).call(this,n,o,a),u(this,t,"m",f).call(this,n,o,a)}))})))}static getFormattedValue(e,t){return e===Qw.DATE&&t?new Date(t).toLocaleString():e===Qw.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),u(this,l,"f").call(this,yw(this.state)),this.subscribe(u(this,l,"f").bind(this),yw)}))}},n=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,l=new WeakMap,t=new WeakSet,a=function(e){var t,i;null===(t=u(this,n,"f")[e])||void 0===t||t.setContent(V$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(i=u(this,o,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=u(this,n,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},d=function(e){var t,i;null===(t=u(this,r,"f")[e])||void 0===t||t.setContent(V$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(i=u(this,s,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=u(this,r,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e,i,r){const s=e.getAttribute("edit-flow-id");s&&(u(this,n,"f")[s]=this.createModal({"data-id":`edit-${i}`}),u(this,o,"f")[s]=new Wa((()=>{var e,t;return null===(t=null===(e=u(this,n,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,n,"f")[s].afterClose=u(this,t,"m",a).bind(this,s),r.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,n,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),u(this,t,"m",a).call(this,s),this.syncFlowTheme(u(this,o,"f")[s]))},f=function(e,i,n){const o=e.getAttribute("delete-flow-id");o&&(u(this,r,"f")[o]=this.createModal({"data-id":`delete-${i}`}),u(this,s,"f")[o]=new Wa((()=>{var e,t;return null===(t=null===(e=u(this,r,"f")[o])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,r,"f")[o].afterClose=u(this,t,"m",d).bind(this,o),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,r,"f"))||void 0===e?void 0:e[o])||void 0===t||t.open()})),u(this,t,"m",d).call(this,o),this.syncFlowTheme(u(this,s,"f")[o]))},i})),tC=Rn((e=>{var t,i,n,o,r,s,a,d;return d=class extends(bn(Bw,ps,Lw,Ur,fc,qw,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),this.updateDeviceList=Cn((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.deviceList=new ed((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield u(this,t,"m",a).call(this),u(this,t,"m",s).call(this,$w(this.state)),u(this,t,"m",o).call(this),this.subscribe(this.updateDeviceList.bind(this),$w))}))}},i=new WeakMap,n=new WeakMap,t=new WeakSet,o=function(){this.deviceList.flowId&&(h(this,i,this.createModal({"data-id":"untrust-device"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=()=>u(this,t,"m",r).call(this,""),this.syncFlowTheme(u(this,n,"f")))},r=function(e=""){u(this,i,"f").setContent(V$({projectId:this.projectId,flowId:this.deviceList.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{deviceId:e}})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.listDevices({userId:aw(this.state)})}))},s=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var n;u(this,t,"m",r).call(this,e),null===(n=u(this,i,"f"))||void 0===n||n.open()})),this.deviceList.data=e},a=function(){return c(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:aw(this.state)})}))},d})),iC=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Bw,Lw,Ur,qw,fc,nd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),f.set(this,Cn((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=Cn((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.userPasskeys=new id((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(u(this,t,"m",p).call(this,ww(this.state)),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),this.subscribe(u(this,f,"f").bind(this),aw),this.subscribe(this.updatePasskeyList.bind(this),ww))}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,f=new WeakMap,t=new WeakSet,s=function(){this.userPasskeys.addPasskeyFlowId&&(h(this,i,this.createModal({"data-id":"add-user-passkey"}),"f"),h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(V$({projectId:this.projectId,flowId:this.userPasskeys.addPasskeyFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:aw(this.state)})}))},d=function(){this.userPasskeys.removePasskeyFlowId&&(h(this,o,this.createModal({"data-id":"remove-user-passkey"}),"f"),h(this,r,new Wa((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,r,"f")))},l=function({externalId:e,credentialId:t}){u(this,o,"f").setContent(V$({projectId:this.projectId,flowId:this.userPasskeys.removePasskeyFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{externalId:e,credentialId:t}})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:aw(this.state)})}))},p=function(e){this.updatePasskeyList(e),this.userPasskeys.onAddPasskeyClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.userPasskeys.onRemovePasskeyClick((({id:e})=>{var i;const n=aw(this.state);u(this,t,"m",l).call(this,{externalId:n,credentialId:e}),null===(i=u(this,o,"f"))||void 0===i||i.open()}))},g})),nC={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="currentcolor"/>\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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},oC=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,Lw,rd,Fr)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Cn((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",n).call(this,e);r.setContent(u(this,t,"m",i).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),Cw)}))}},o=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const i=nC[e],n=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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${n.outerHTML}`},n=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),rC=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p;return p=class extends(bn(Lw,Ur,qw)(e)){constructor(){super(...arguments),t.add(this),i.set(this,null),o.set(this,(e=>c(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),r.set(this,(e=>{const n=Sw(e);this.tenantSelector.value!==n&&u(this,t,"m",l).call(this,n);const{loading:o,error:r}=e.selectTenant,a=null!==e.tenant.previousTenantId,d=n!==u(this,i,"f");!n||o||r||a||!d||(h(this,i,n,"f"),u(this,t,"m",s).call(this))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.actions.setCurrentTenantId((()=>{const e=yi();return rw(e)})()),u(this,t,"m",n).call(this),u(this,t,"m",f).call(this),u(this,t,"m",d).call(this,kw(this.state)),this.subscribe(u(this,r,"f").bind(this))}))}},i=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,n=function(){this.tenantSelector=new td((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(u(this,o,"f"))},s=function(){const e=Sw(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&u(this,t,"m",a).call(this)},a=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},d=function(e){return c(this,void 0,void 0,(function*(){const t=e.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(t)}))},l=function(e){e&&(this.tenantSelector.value=e)},f=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{u(this,t,"m",l).call(this,Sw(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},p})),sC=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p;return p=class extends(bn(Bw,Lw,nd,Ur,qw)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,[]),r.set(this,null)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",d).call(this),u(this,t,"m",a).call(this),u(this,o,"f").forEach((e=>e.enable()))}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,s=function(e){const i=new La(e,{logger:this.logger});i.onClick((()=>{u(this,t,"m",f).call(this,i.flowId,aw(this.state))})),u(this,o,"f").push(i)},a=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(i).forEach((e=>{u(this,t,"m",s).call(this,e)}))},d=function(){h(this,i,this.createModal({"data-id":"generic-flow-modal"}),"f"),u(this,i,"f").afterClose=()=>{var e;null===(e=u(this,r,"f"))||void 0===e||e.call(this),h(this,r,null,"f")},h(this,n,new Wa((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,n,"f"))},l=function(){var e;u(this,i,"f").open(),null===(e=u(this,r,"f"))||void 0===e||e.call(this)},f=function(e,o){u(this,i,"f").setContent(V$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,client:{userId:o}})),h(this,r,u(this,n,"f").onPageUpdated((()=>u(this,t,"m",l).call(this))),"f"),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},p})),aC=Rn((e=>class extends(bn(Ea,ps,_w,eC,Kw,Vw,zw,Zw,Gw,Jw,Yw,Xw,Hw,tC,iC,oC,rC,sC)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),dC=bn((e=>class extends(aC(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Oa})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.11.3"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",dC);var lC=Object.freeze({__proto__:null,default:dC});const cC=(e,t,i,n={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===n.left?e.offsetWidth:null!==(o=n.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===n.right?e.offsetWidth:null!==(r=n.right)&&void 0!==r?r:0)),Math.min(Math.max(i,("all"===n.top?e.offsetHeight:null!==(s=n.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===n.bottom?e.offsetHeight:null!==(a=n.bottom)&&void 0!==a?a:0))]},uC=(e,t,i)=>{let n=0,o=0,r=0,s=0;function a(t){t.preventDefault(),n=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,d]=cC(e,e.offsetLeft-n,e.offsetTop-o,i);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=d,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l};var hC,fC,pC,gC,vC,mC,yC,bC,$C,wC,CC;const kC=document.createElement("template");kC.innerHTML='\n<div 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';const SC=bn(as)(HTMLElement);class IC extends SC{constructor(){super(),hC.add(this),fC.set(this,new fr({messages:[]})),pC.set(this,void 0),gC.set(this,void 0),vC.set(this,void 0),mC.set(this,{resize:u(this,hC,"m",CC).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(kC.content.cloneNode(!0)),h(this,pC,this.shadowRoot.querySelector(".debugger"),"f"),h(this,gC,u(this,pC,"f").querySelector(".content"),"f"),h(this,vC,u(this,pC,"f").querySelector(".header"),"f"),u(this,hC,"m",yC).call(this)}updateData(e){u(this,fC,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),uC(u(this,pC,"f"),u(this,vC,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",u(this,mC,"f").resize),(e=>{e.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}})(u(this,pC,"f")),u(this,pC,"f").onresize=u(this,hC,"m",wC).bind(this),u(this,fC,"f").subscribe(u(this,hC,"m",bC).bind(this))}))}disconnectedCallback(){u(this,fC,"f").unsubscribeAll(),window.removeEventListener("resize",u(this,mC,"f").resize)}}fC=new WeakMap,pC=new WeakMap,gC=new WeakMap,vC=new WeakMap,mC=new WeakMap,hC=new WeakSet,yC=function(){this.injectStyle('\n .debugger {\n all: initial;\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'),u(this,pC,"f").style.top="32px",u(this,pC,"f").style.left=window.innerWidth-300-32+"px"},bC=function(e){u(this,hC,"m",$C).call(this,e),u(this,hC,"m",wC).call(this)},$C=function(e){u(this,gC,"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("")},wC=function(){u(this,gC,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),i=t.scrollWidth>t.clientWidth,n=t.clientHeight>20;i||n?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},CC=function(){const[e,t]=cC(u(this,pC,"f"),Number.parseInt(u(this,pC,"f").style.left,10),Number.parseInt(u(this,pC,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});u(this,pC,"f").style.top=`${t}px`,u(this,pC,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",IC);var RC=Object.freeze({__proto__:null,default:IC});const xC=(e,t,i,n={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===n.left?e.offsetWidth:null!==(o=n.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===n.right?e.offsetWidth:null!==(r=n.right)&&void 0!==r?r:0)),Math.min(Math.max(i,("all"===n.top?e.offsetHeight:null!==(s=n.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===n.bottom?e.offsetHeight:null!==(a=n.bottom)&&void 0!==a?a:0))]};var OC,EC,AC,NC,jC,MC,PC,UC,TC,WC;const LC=document.createElement("template");LC.innerHTML=`\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`;const DC=bn(as)(HTMLElement);class _C extends DC{constructor(){var e;super(),OC.add(this),EC.set(this,new jn({messages:[]})),AC.set(this,void 0),NC.set(this,void 0),jC.set(this,void 0),MC.set(this,{resize:u(this,OC,"m",WC).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(LC.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\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'),h(this,AC,this.shadowRoot.querySelector(".debugger"),"f"),h(this,NC,u(this,AC,"f").querySelector(".content"),"f"),h(this,jC,u(this,AC,"f").querySelector(".header"),"f")}updateData(e){u(this,EC,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,i)=>{let n=0,o=0,r=0,s=0;function a(t){t.preventDefault(),n=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,d]=xC(e,e.offsetLeft-n,e.offsetTop-o,i);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=d,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(u(this,AC,"f"),u(this,jC,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",u(this,MC,"f").resize),(e=u(this,AC,"f")).onmousemove=t=>{var i;const n=t.target;(n.w&&n.w!==n.offsetWidth||n.h&&n.h!==n.offsetHeight)&&(null===(i=e.onresize)||void 0===i||i.call(e,t)),n.w=n.offsetWidth,n.h=n.offsetHeight},u(this,AC,"f").onresize=u(this,OC,"m",TC).bind(this),u(this,EC,"f").subscribe(u(this,OC,"m",PC).bind(this))}disconnectedCallback(){u(this,EC,"f").unsubscribeAll(),window.removeEventListener("resize",u(this,MC,"f").resize)}}EC=new WeakMap,AC=new WeakMap,NC=new WeakMap,jC=new WeakMap,MC=new WeakMap,OC=new WeakSet,PC=function(e){u(this,OC,"m",UC).call(this,e),u(this,OC,"m",TC).call(this)},UC=function(e){u(this,NC,"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("")},TC=function(){u(this,NC,"f").querySelectorAll(".msg").forEach((e=>{const t=e,i=t.querySelector(".msg_desc"),n=i.scrollWidth>i.clientWidth,o=i.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},WC=function(){const[e,t]=xC(u(this,AC,"f"),Number.parseInt(u(this,AC,"f").style.left,10),Number.parseInt(u(this,AC,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});u(this,AC,"f").style.top=`${t}px`,u(this,AC,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",_C);var FC=Object.freeze({__proto__:null,default:_C});e.AccessKeyManagement=Bn,e.ApplicationsPortal=Kn,e.AuditManagement=zn,e.AuthProvider=({projectId:e,baseUrl:o="",baseStaticUrl:a="",baseCdnUrl:d="",sessionTokenViaCookie:l=!1,refreshTokenViaCookie:c=!1,hooks:u,persistTokens:h=!0,autoRefresh:f=!0,oidcConfig:p,storeLastAuthenticatedUser:g=!0,keepLastAuthenticatedUserAfterLogout:v=!1,refreshCookieName:m="",getExternalToken:y,customStorage:b,children:$})=>{const[w,C]=t.useState(),[k,S]=t.useState(),[I,R]=t.useState(),[x,O]=t.useState(!1),[E,A]=t.useState(!1),[N,j]=t.useState(!1),[M,P]=t.useState(!!p),U=t.useRef(!1),T=(({projectId:e,baseUrl:i,persistTokens:n,autoRefresh:o,sessionTokenViaCookie:r,refreshTokenViaCookie:a,refreshCookieName:d,oidcConfig:l,storeLastAuthenticatedUser:c,keepLastAuthenticatedUserAfterLogout:u,getExternalToken:h,hooks:f,customStorage:p})=>t.useMemo((()=>{if(e)return hn({projectId:e,baseUrl:i,sessionTokenViaCookie:r,refreshTokenViaCookie:a,baseHeaders:s,persistTokens:n,autoRefresh:o,refreshCookieName:d,oidcConfig:l,storeLastAuthenticatedUser:c,keepLastAuthenticatedUserAfterLogout:u,hooks:f,getExternalToken:h,customStorage:p})}),[e,i,JSON.stringify(r),JSON.stringify(a),h,p]))({projectId:e,baseUrl:o,persistTokens:h,autoRefresh:f,sessionTokenViaCookie:l,refreshTokenViaCookie:c,hooks:u,oidcConfig:p,storeLastAuthenticatedUser:g,keepLastAuthenticatedUserAfterLogout:v,refreshCookieName:m,getExternalToken:y,customStorage:b});t.useEffect((()=>{if(T){const e=T.onSessionTokenChange(S),t=T.onUserChange(C),i=T.onIsAuthenticatedChange(O),n=T.onClaimsChange(R);return()=>{e(),t(),i(),n()}}}),[T]);const W=t.useRef(!1),L=t.useRef(!1);t.useEffect((()=>{T&&p&&!U.current&&(U.current=!0,T.oidc.finishLoginIfNeed().finally((()=>{P(!1),W.current=!0})))}),[]);const D=t.useCallback((()=>{r()||W.current||(W.current=!0,j(!0),n(null==T?void 0:T.refresh)(void 0,!0).then((()=>{requestAnimationFrame((()=>{setTimeout((()=>{j(!1)}),0)}))})))}),[T]),_=t.useCallback((()=>{L.current||(L.current=!0,A(!0),n(T.me)().then((()=>{A(!1)})))}),[T]),F=t.useMemo((()=>({fetchUser:_,user:w,isUserLoading:E,isUserFetched:L.current,fetchSession:D,session:k,isAuthenticated:x,isSessionLoading:N,isOidcLoading:M,isSessionFetched:W.current,projectId:e,baseUrl:o,baseStaticUrl:a,baseCdnUrl:d,storeLastAuthenticatedUser:g,keepLastAuthenticatedUserAfterLogout:v,refreshCookieName:m,customStorage:b,setUser:C,setSession:S,setIsAuthenticated:O,claims:I,sdk:T})),[_,w,E,L.current,D,k,x,N,M,W.current,e,o,a,d,v,m,b,C,S,O,I,T]);return t.createElement(i.Provider,{value:F},$)},e.Descope=Ln,e.OutboundApplications=Jn,e.RoleManagement=Yn,e.SignInFlow=e=>t.createElement(Ln,Object.assign({},e,{flowId:"sign-in"})),e.SignUpFlow=e=>t.createElement(Ln,Object.assign({},e,{flowId:"sign-up"})),e.SignUpOrInFlow=e=>t.createElement(Ln,Object.assign({},e,{flowId:"sign-up-or-in"})),e.TenantProfile=Qn,e.UserManagement=to,e.UserProfile=no,e.baseHeaders=s,e.getCurrentTenant=yn,e.getJwtPermissions=vn,e.getJwtRoles=mn,e.getRefreshToken=gn,e.getSessionToken=pn,e.isRefreshTokenExpired=(e=gn())=>null==un?void 0:un.isJwtExpired(e),e.isSessionTokenExpired=(e=pn())=>null==un?void 0:un.isJwtExpired(e),e.refresh=(e=gn())=>null==un?void 0:un.refresh(e),e.useDescope=()=>{const{sdk:e}=Dn();return t.useMemo((()=>e||new Proxy(fn(),Fn)),[e])},e.useSession=()=>{const{session:e,claims:i,isSessionLoading:n,isOidcLoading:o,fetchSession:s,isSessionFetched:a,isAuthenticated:d}=Dn(),l=t.useRef(n||o);t.useMemo((()=>{l.current=n||o}),[n,o]);const c=!d&&!n&&!r();return t.useMemo((()=>{c&&!a&&(l.current=!0)}),[a]),t.useEffect((()=>{c&&s()}),[s]),{isSessionLoading:l.current,sessionToken:e,claims:i,isAuthenticated:d}},e.useUser=()=>{const{user:e,fetchUser:i,isUserLoading:n,isAuthenticated:o,isUserFetched:r}=Dn(),[s,a]=t.useState(!1),d=t.useRef(n),l=t.useMemo((()=>!e&&!n&&o&&!s),[i,o,s]);return t.useMemo((()=>{d.current=n}),[n]),t.useMemo((()=>{l&&!r&&(d.current=!0)}),[l,r]),t.useEffect((()=>{l&&(a(!0),i())}),[l]),{isUserLoading:d.current,user:e}}}));
|
|
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";const i=t.createContext(void 0),n=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)},o=e=>(...t)=>{let i;try{i=e(...t)}catch(e){console.error(e)}return i},r=()=>"undefined"!=typeof window&&!!window.descopeBridge,s={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.28.9"},a="undefined"!=typeof window;var d=function(){return d=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var o in t=arguments[i])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},d.apply(this,arguments)};function l(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}return i}function c(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))}function u(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function h(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}"function"==typeof SuppressedError&&SuppressedError;class f extends Error{}function p(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let i=t.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i})))}(t)}catch(e){return atob(t)}}function g(e,t){if("string"!=typeof e)throw new f("Invalid token specified: must be a string");t||(t={});const i=!0===t.header?0:1,n=e.split(".")[i];if("string"!=typeof n)throw new f(`Invalid token specified: missing part #${i+1}`);let o;try{o=p(n)}catch(e){throw new f(`Invalid token specified: invalid base64 for part #${i+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new f(`Invalid token specified: invalid json for part #${i+1} (${e.message})`)}}f.prototype.name="InvalidTokenError";var v={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const m="<region>",y=`https://api.${m}descope.com`,b=6e5,$="dct",w=()=>{const e={};return{headers(t){const i="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(i),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},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},C=[503,521,522,524,530],k=[100,5e3,5e3],S=e=>new Promise((t=>setTimeout(t,e))),I=e=>async function(...t){let i=await e(...t),n=0;for(;C.includes(i.status)&&n<k.length;)await S(k[n]),i=await e(...t),n++;n>0&&(i.retries=n);const o=await i.text();return i.text=()=>Promise.resolve(o),i.json=()=>Promise.resolve(JSON.parse(o)),i.clone=()=>i,i};let R;const x=()=>{if(R)return R;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,i=Math.floor(1e3+9e3*Math.random());return R=`${t}-${i}`,R};var O;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(O||(O={}));const E=({path:e,baseUrl:t,queryParams:i,projectId:n})=>{const o=n.slice(1,-27);t=t.replace(m,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(i){const e=Object.keys(i);e.forEach(((t,n)=>{r=`${r}${0===n?"?":""}${t}=${encodeURIComponent(i[t])}${n===e.length-1?"":"&"}`}))}return r},A=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,i])=>{e[t]="function"==typeof i?i():i})),e)),{})),N={"Content-Type":"application/json"},j=(e,t="")=>{let i=e;return t&&(i=i+":"+t),{Authorization:`Bearer ${i}`}},M=(e,t)=>{const i={"x-descope-sdk-session-id":x(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.62.1","x-descope-project-id":e};return t&&(i["x-descope-refresh-cookie-name"]=t),i},P=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var U=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:i,refreshCookieName:n,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const d=e||y,l=((e,t)=>{const i=t||fetch;return i||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 function(...t){if(!i)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=>w().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const n=await I(i)(...t);return e[n.ok?"log":"error"](await(async e=>{const t=await e.text();return w().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(n)),n}:I(i)})(o,a),c=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:c,body:u,headers:h,queryParams:f,method:p,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:A(j(t,g),M(t,n),(null==i?void 0:i.baseHeaders)||{},P(v)?N:{},h),method:p,body:v};null!==s&&(m.credentials=s||"include");const y=await l(E({path:c,baseUrl:d,queryParams:f,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==y?void 0:y.clone()),null==r?void 0:r.transformResponse){const e=await y.json(),t=(b=(null===(o=y.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let i=0;function n(){for(;i<e.length&&/\s/.test(e.charAt(i));)i+=1;return i<e.length}function o(){const t=e.charAt(i);return"="!==t&&";"!==t&&","!==t}for(;i<e.length;){const r=i;let s,a,d=!1;for(;n();)if(","===e.charAt(i)){for(s=i,i+=1,n(),a=i;i<e.length&&o();)i+=1;if(i<e.length&&"="===e.charAt(i)){d=!0,i=a,t.push(e.substring(r,s));break}i=s+1}else i+=1;(!d||i>=e.length)&&t.push(e.substring(r,e.length))}return t}(b).map((e=>{const t=e.split(";")[0],i=t.indexOf("=");return i<1?null:[t.substring(0,i).trim(),t.substring(i+1).trim()]})).filter(Boolean))),i=Object.assign(Object.assign({},y),{json:()=>Promise.resolve(e),cookies:t});return i.clone=()=>i,r.transformResponse(i)}var b;return y};return{get:(e,{headers:t,queryParams:i,token:n}={})=>c({path:e,headers:t,queryParams:i,body:void 0,method:O.get,token:n}),post:(e,t,{headers:i,queryParams:n,token:o}={})=>c({path:e,headers:i,queryParams:n,body:t,method:O.post,token:o}),patch:(e,t,{headers:i,queryParams:n,token:o}={})=>c({path:e,headers:i,queryParams:n,body:t,method:O.patch,token:o}),put:(e,t,{headers:i,queryParams:n,token:o}={})=>c({path:e,headers:i,queryParams:n,body:t,method:O.put,token:o}),delete:(e,{headers:t,queryParams:i,token:n}={})=>c({path:e,headers:t,queryParams:i,body:void 0,method:O.delete,token:n}),hooks:r,buildUrl:(e,i)=>E({projectId:t,baseUrl:d,path:e,queryParams:i})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var i;const n=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.beforeRequest)||[]);return null==n?void 0:n.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,i)=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==i?void 0:i.clone()))))).forEach((t=>{var i;return"rejected"===t.status&&(null===(i=e.logger)||void 0===i?void 0:i.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},T=429;function W(e,t,i){var n;let o=L(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[$])===t)return(null==o?void 0:o[i])||[];o=null===(n=null==o?void 0:o.tenants)||void 0===n?void 0:n[t]}const r=null==o?void 0:o[i];return Array.isArray(r)?r:[]}function L(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return g(e)}function D(e){const{exp:t}=L(e);return(new Date).getTime()/1e3>t}function _(e){let t=L(e);const i=Object.keys(null==t?void 0:t.tenants);return Array.isArray(i)?i:[]}function F(e,t){return W(e,t,"permissions")}function q(e,t){return W(e,t,"roles")}const B=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function V(e,t){var i;const n=await e,o={code:n.status,ok:n.ok,response:n},r=await n.clone().json();return n.ok?o.data=r:(o.error=r,n.status===T&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(i=n.headers)||void 0===i?void 0:i.get("retry-after"))||0})),o}function K(e){var t;return(null===(t=L(e))||void 0===t?void 0:t[$])||""}const H=(e,t)=>(i=t)=>t=>!e(t)&&i.replace("{val}",t),z=(e,t)=>(i=t)=>t=>{const n=e.filter((e=>e(t)));return!(n.length<e.length)&&(i?i.replace("{val}",t):n.join(" OR "))},G=(...e)=>({validate:t=>(e.forEach((e=>{const i=e(t);if(i)throw new Error(i)})),!0)}),J=e=>t=>e.test(t),Z=J(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Y=J(/^\+[1-9]{1}[0-9]{3,14}$/),X=H(Z,'"{val}" is not a valid email'),Q=H(Y,'"{val}" is not a valid phone number'),ee=H((e=>e.length>=1),"Minimum length is 1");const te=H((e=>"string"==typeof e),"Input is not a string"),ie=H((e=>Array.isArray(e)),"Input is not an array"),ne=H((e=>"boolean"==typeof e),"Input is not a boolean"),oe=H((e=>void 0===e),"Input is defined"),re=z([te(),oe()],"Input is not a string or undefined"),se=z([ie(),ne()],"Input is not an array or boolean"),ae=(...e)=>t=>(...i)=>(e.forEach(((e,t)=>G(...e).validate(i[t]))),t(...i)),de=e=>[te(`"${e}" must be a string`)],le=e=>[re(`"${e}" must be string or undefined`)],ce=e=>[te(`"${e}" must be a string`),ee(`"${e}" must not be empty`)],ue=e=>[te(`"${e}" must be a string`),X()],he=e=>[te(`"${e}" must be a string`),Q()],fe=ae(ce("accessKey")),pe=e=>({exchange:fe(((t,i)=>V(e.post(v.accessKey.exchange,{loginOptions:i},{token:t}))))}),ge=(e,t,i)=>(t.forEach((t=>{const n=t.split(".");let o=n.shift(),r=e;for(;n.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=n.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=i(s)})),e),ve=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||b,b)});var me,ye;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(me||(me={})),function(e){e.email="email"}(ye||(ye={}));const be=Object.assign(Object.assign({},me),ye);var $e;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}($e||($e={}));const we=ce("loginId"),Ce=ae(ce("token")),ke=ae(we),Se=ae(ce("pendingRef")),Ie=ae(we,ue("email")),Re=e=>({verify:Ce((t=>V(e.post(v.enchantedLink.verify,{token:t})))),signIn:ke(((t,i,n={},o)=>{var{providerId:r}=n,s=l(n,["providerId"]);return V(e.post(B(v.enchantedLink.signIn,be.email),{loginId:t,URI:i,loginOptions:s,providerId:r},{token:o}))})),signUpOrIn:ke(((t,i,n={})=>{var{providerId:o}=n,r=l(n,["providerId"]);return V(e.post(B(v.enchantedLink.signUpOrIn,be.email),{loginId:t,URI:i,loginOptions:r,providerId:o}))})),signUp:ke(((t,i,n,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return V(e.post(B(v.enchantedLink.signUp,be.email),{loginId:t,URI:i,user:n,loginOptions:s,providerId:r}))})),waitForSession:Se(((t,i)=>new Promise((n=>{const{pollingIntervalMs:o,timeoutMs:r}=ve(i);let s;const a=setInterval((async()=>{const i=await e.post(v.enchantedLink.session,{pendingRef:t});i.ok&&(clearInterval(a),s&&clearTimeout(s),n(V(Promise.resolve(i))))}),o);s=setTimeout((()=>{n({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Ie(((t,i,n,o,r)=>V(e.post(v.enchantedLink.update.email,Object.assign({loginId:t,email:i,URI:n},r),{token:o}))))}}),xe=ae(ce("flowId")),Oe=ae(ce("executionId"),ce("stepId"),ce("interactionId")),Ee=e=>({start:xe(((t,i,n,o,r,s,a,d=!1)=>V(e.post(v.flow.start,{flowId:t,options:i,conditionInteractionId:n,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:d})))),next:Oe(((t,i,n,o,r,s,a=!1)=>V(e.post(v.flow.next,{executionId:t,stepId:i,interactionId:n,version:o,componentsVersion:r,input:s,isCustomScreen:a}))))}),Ae=ce("loginId"),Ne=ae(ce("token")),je=ae(Ae),Me=ae(Ae,he("phone")),Pe=ae(Ae,ue("email")),Ue=Object.keys(be).filter((e=>e!==me.voice&&e!==me.im)),Te=e=>({verify:Ne((t=>V(e.post(v.magicLink.verify,{token:t})))),signIn:Ue.reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:je(((t,n,o={},r)=>{var{providerId:s}=o,a=l(o,["providerId"]);return V(e.post(B(v.magicLink.signIn,i),{loginId:t,URI:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Ue.reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:je(((t,n,o,r={})=>{var{providerId:s}=r,a=l(r,["providerId"]);return V(e.post(B(v.magicLink.signUp,i),{loginId:t,URI:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Ue.reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:je(((t,n,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return V(e.post(B(v.magicLink.signUpOrIn,i),{loginId:t,URI:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Pe(((t,i,n,o,r)=>V(e.post(v.magicLink.update.email,Object.assign({loginId:t,email:i,URI:n},r),{token:o})))),phone:Object.keys(me).filter((e=>e!==me.voice)).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Me(((t,n,o,r,s)=>V(e.post(B(v.magicLink.update.phone,i),Object.assign({loginId:t,phone:n,URI:o},s),{token:r}))))})),{})}});var We;!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"}(We||(We={}));const Le=ae(ce("code")),De=e=>({start:Object.assign(((t,i,n,o,r)=>V(e.post(v.oauth.start,n||{},{queryParams:Object.assign(Object.assign({provider:t},i&&{redirectURL:i}),r&&{loginHint:r}),token:o}))),Object.keys(We).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:(t,n,o,r)=>V(e.post(v.oauth.start,n||{},{queryParams:Object.assign(Object.assign({provider:i},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:Le((t=>V(e.post(v.oauth.exchange,{code:t})))),startNative:(t,i,n)=>V(e.post(v.oauth.startNative,{provider:t,loginOptions:i,implicit:n})),finishNative:(t,i,n,o,r)=>V(e.post(v.oauth.finishNative,{provider:t,stateId:i,user:n,code:o,idToken:r})),getOneTapClientId:t=>V(e.get(v.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,i,n,o)=>V(e.post(v.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:i,nonce:n,loginOptions:o})),exchangeOneTapIDToken:(t,i,n,o)=>V(e.post(v.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:i,nonce:n,loginOptions:o}))}),_e=ce("appId"),Fe=ae(_e),qe=e=>({connect:Fe(((t,i,n)=>{const o=null==i?void 0:i.tenantId,r=null==i?void 0:i.tenantLevel;return null==i||delete i.tenantId,null==i||delete i.tenantLevel,V(e.post(v.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:i},{token:n}))}))}),Be=ce("loginId"),Ve=ae(Be,ce("code")),Ke=ae(Be),He=ae(Be,he("phone")),ze=ae(Be,ue("email")),Ge=e=>({verify:Object.keys(be).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Ve(((t,n)=>V(e.post(B(v.otp.verify,i),{code:n,loginId:t}))))})),{}),signIn:Object.keys(be).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Ke(((t,n={},o)=>{var{providerId:r}=n,s=l(n,["providerId"]);return V(e.post(B(v.otp.signIn,i),{loginId:t,loginOptions:s,providerId:r},{token:o}))}))})),{}),signUp:Object.keys(be).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Ke(((t,n,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return V(e.post(B(v.otp.signUp,i),{loginId:t,user:n,loginOptions:s,providerId:r}))}))})),{}),signUpOrIn:Object.keys(be).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Ke(((t,n={})=>{var{providerId:o}=n,r=l(n,["providerId"]);return V(e.post(B(v.otp.signUpOrIn,i),{loginId:t,loginOptions:r,providerId:o}))}))})),{}),update:{email:ze(((t,i,n,o)=>V(e.post(v.otp.update.email,Object.assign({loginId:t,email:i},o),{token:n})))),phone:Object.keys(me).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:He(((t,n,o,r)=>V(e.post(B(v.otp.update.phone,i),Object.assign({loginId:t,phone:n},r),{token:o}))))})),{})}}),Je=ae(ce("tenant")),Ze=ae(ce("code")),Ye=e=>({start:Je(((t,i,n,o,r,s,a,d)=>V(e.post(v.saml.start,n||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},i&&{redirectURL:i}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),d&&{initiatedEmail:t})},o&&{token:o}))))),exchange:Ze((t=>V(e.post(v.saml.exchange,{code:t}))))}),Xe=ce("loginId"),Qe=ae(Xe,ce("code")),et=ae(Xe),tt=ae(Xe),it=e=>({signUp:et(((t,i)=>V(e.post(v.totp.signUp,{loginId:t,user:i})))),verify:Qe(((t,i,n,o)=>V(e.post(v.totp.verify,{loginId:t,code:i,loginOptions:n},{token:o})))),update:tt(((t,i)=>V(e.post(v.totp.update,{loginId:t},{token:i}))))}),nt=ce("loginId"),ot=ce("newPassword"),rt=ae(nt,ce("password")),st=ae(nt),at=ae(nt,ot),dt=ae(nt,ce("oldPassword"),ot),lt=e=>({signUp:rt(((t,i,n,o={})=>{var{providerId:r}=o,s=l(o,["providerId"]);return V(e.post(v.password.signUp,{loginId:t,password:i,user:n,loginOptions:s,providerId:r}))})),signIn:rt(((t,i,n={})=>{var{providerId:o}=n,r=l(n,["providerId"]);return V(e.post(v.password.signIn,{loginId:t,password:i,loginOptions:r,providerId:o}))})),sendReset:st(((t,i,n)=>V(e.post(v.password.sendReset,{loginId:t,redirectUrl:i,templateOptions:n})))),update:at(((t,i,n)=>V(e.post(v.password.update,{loginId:t,newPassword:i},{token:n})))),replace:dt(((t,i,n)=>V(e.post(v.password.replace,{loginId:t,oldPassword:i,newPassword:n})))),policy:()=>V(e.get(v.password.policy))}),ct=de("loginId"),ut=ce("loginId"),ht=ce("origin"),ft=ae(ut,ht,ce("name")),pt=ae(ut,ht),gt=ae(ct,ht),vt=ae(ut,ht,le("token")),mt=ae(ce("transactionId"),ce("response")),yt=e=>({signUp:{start:ft(((t,i,n,o,r)=>V(e.post(v.webauthn.signUp.start,{user:{loginId:t,name:n},origin:i,loginOptions:r,passkeyOptions:o})))),finish:mt(((t,i)=>V(e.post(v.webauthn.signUp.finish,{transactionId:t,response:i}))))},signIn:{start:gt(((t,i,n,o,r)=>V(e.post(v.webauthn.signIn.start,{loginId:t,origin:i,loginOptions:n,passkeyOptions:r},{token:o})))),finish:mt(((t,i)=>V(e.post(v.webauthn.signIn.finish,{transactionId:t,response:i}))))},signUpOrIn:{start:pt(((t,i,n,o)=>V(e.post(v.webauthn.signUpOrIn.start,{loginId:t,origin:i,loginOptions:o,passkeyOptions:n}))))},update:{start:vt(((t,i,n,o)=>V(e.post(v.webauthn.update.start,{loginId:t,origin:i,passkeyOptions:o},{token:n})))),finish:mt(((t,i)=>V(e.post(v.webauthn.update.finish,{transactionId:t,response:i}))))}}),bt=de("loginId"),$t=ae(bt),wt=ae(ce("pendingRef")),Ct=e=>({signUpOrIn:$t(((t,i={})=>{var{providerId:n}=i,o=l(i,["providerId"]);return V(e.post(v.notp.signUpOrIn,{loginId:t,loginOptions:o,providerId:n}))})),signUp:$t(((t,i,n={})=>{var{providerId:o}=n,r=l(n,["providerId"]);return V(e.post(v.notp.signUp,{loginId:t,user:i,providerId:o,loginOptions:r}))})),signIn:$t(((t,i={},n)=>{var{providerId:o}=i,r=l(i,["providerId"]);return V(e.post(v.notp.signIn,{loginId:t,loginOptions:r,providerId:o},{token:n}))})),waitForSession:wt(((t,i)=>new Promise((n=>{const{pollingIntervalMs:o,timeoutMs:r}=ve(i);let s;const a=setInterval((async()=>{const i=await e.post(v.notp.session,{pendingRef:t});i.ok&&(clearInterval(a),s&&clearTimeout(s),n(V(Promise.resolve(i))))}),o);s=setTimeout((()=>{n({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),kt=ae(ce("token")),St=ae(le("token"));var It,Rt=ae([(It=ce("projectId"),H(((e,t)=>i=>G(...t).validate(((e,t)=>{const i=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,i)=>"."+i)).split("."),n=i.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<n;)r=r[i[o++]];return o&&o===n&&void 0!==r?r:void 0})(i,e)))("projectId",It))())])((e=>{const{projectId:t,logger:i,baseUrl:n,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return d=U({baseUrl:n,projectId:t,logger:i,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:pe(d),otp:Ge(d),magicLink:Te(d),enchantedLink:Re(d),oauth:De(d),outbound:qe(d),saml:Ye(d),totp:it(d),notp:Ct(d),webauthn:yt(d),password:lt(d),flow:Ee(d),refresh:St(((e,t,i,n)=>{const o={};i&&(o.externalToken=i);const r=n?v.tryRefresh:v.refresh;return V(d.post(r,o,{token:e,queryParams:t}))})),selectTenant:ae([te("tenantId")],[re('"token" must be string or undefined')])(((e,t)=>V(d.post(v.selectTenant,{tenant:e},{token:t})))),logout:St((e=>V(d.post(v.logout,{},{token:e})))),logoutAll:St((e=>V(d.post(v.logoutAll,{},{token:e})))),me:St((e=>V(d.get(v.me,{token:e})))),myTenants:ae([se('"tenants" must a string array or a boolean')],[re('"token" must be string or undefined')])(((e,t)=>{const i={};return"boolean"==typeof e?i.dct=e:i.ids=e,V(d.post(v.myTenants,i,{token:t}))})),history:St((e=>V(d.get(v.history,{token:e})))),isJwtExpired:kt(D),getTenants:kt(_),getJwtPermissions:kt(F),getJwtRoles:kt(q),getCurrentTenant:kt(K),httpClient:d};var d})),xt=Object.assign(Rt,{DeliveryMethods:be});
|
|
2
|
+
/*! js-cookie v3.0.5 | MIT */function Ot(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)e[n]=i[n]}return e}var Et=function e(t,i){function n(e,n,o){if("undefined"!=typeof document){"number"==typeof(o=Ot({},i,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(n,e)+r}}return Object.create({set:n,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var i=document.cookie?document.cookie.split("; "):[],n={},o=0;o<i.length;o++){var r=i[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(n[a]=t.read(s,a),e===a)break}catch(e){}}return e?n[e]:n}},remove:function(e,t){n(e,"",Ot({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Ot({},this.attributes,t))},withConverter:function(t){return e(Ot({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(i)},converter:{value:Object.freeze(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:"/"});var At={default:"endpoint"},Nt="Blocked by CSP",jt="The endpoint parameter is not a valid URL",Mt="Failed to load the JS script of the agent",Pt="9319";function Ut(e,t){var i,n,o,r,s,a=[],d=(i=function(e){var t=function(e,t,i){if(i||2===arguments.length)for(var n,o=0,r=t.length;o<r;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,n=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[i.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Nt||s===jt)i.exclude(),r=0;else if(s===Pt)i.exclude();else if(s===Mt){var a=Date.now()-e.getTime()<50,d=i.current();d&&a&&!o.has(d)&&(o.add(d),r=0),i.postpone()}else i.postpone();var l=i.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+n()-Date.now()]}]),l=d[0],c=d[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var i=new Date,n=function(t){return a.push({url:e,startedAt:i,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return n()}),n),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=c(i,e);if(!t)throw s;var n,o=t[0],r=t[1];return(n=r,new Promise((function(e){return setTimeout(e,n)}))).then((function(){return u(o)}))}))};return u(l).then((function(e){return[e,a]}))}var Tt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Wt=Tt;function Lt(e){var t;e.scriptUrlPattern;var i=e.token,n=e.apiKey,o=void 0===n?i:n,r=l(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:Tt,a=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},i=function(e,t,i,n){return e.addEventListener(t,i,n),function(){return e.removeEventListener(t,i,n)}}(document,"visibilitychange",t);return t(),[e,i]}(),c=a[0],u=a[1];return Promise.resolve().then((function(){if(!o||"string"!=typeof o)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 i=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?i(t):"<loaderVersion>"===e?i("3.11.6"):e}))}(String(e),t)}))}(s,o);return Ut(e,Dt)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Pt?new Error(Mt):e}(e)})).then((function(e){var t=e[0],i=e[1];return u(),t.load(d(d({},r),{ldi:{attempts:i,visibilityStates:c}}))}))}function Dt(e){return function(e,t,i){var n,o=document,r="securitypolicyviolation",s=function(t){var i=new URL(e,location.href),o=t.blockedURI;o!==i.href&&o!==i.protocol.slice(0,-1)&&o!==i.origin||(n=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),n)return i(n);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,i){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(jt);var n=document.createElement("script"),o=function(){var e;return null===(e=n.parentNode)||void 0===e?void 0:e.removeChild(n)},r=document.head||document.getElementsByTagName("head")[0];n.onload=function(){o(),t()},n.onerror=function(){o(),i(new Error(Mt))},n.async=!0,n.src=e,r.appendChild(n)}))}(e)}),(function(){throw new Error(Nt)})).then(_t)}function _t(){var e=window,t="__fpjs_p_l_b",i=e[t];if(function(e,t){var i,n=null===(i=Object.getOwnPropertyDescriptor)||void 0===i?void 0:i.call(Object,e,t);(null==n?void 0:n.configurable)?delete e[t]:n&&!n.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==i?void 0:i.load))throw new Error(Pt);return i}const Ft="3.2.0",qt="undefined"!=typeof window,Bt=Math.pow(2,31)-1,Vt=`https://descopecdn.com/npm/oidc-client-ts@${Ft}/dist/browser/oidc-client-ts.min.js`,Kt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Ft}/dist/browser/oidc-client-ts.min.js`,Ht=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let zt;const Gt=e=>{try{return g(e).exp}catch(e){return null}},Jt=e=>{const{refresh_expire_in:t,refresh_token:i}=e;return t?Math.floor(Date.now()/1e3)+t:Gt(i)},Zt=e=>{const{expires_in:t,expires_at:i,access_token:n}=e;return i||(t?Math.floor(Date.now()/1e3)+t:n?Gt(n):void 0)},Yt=e=>{const{access_token:t,id_token:i,refresh_token:n,refresh_expire_in:o}=e,r=l(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||t,idToken:i,refreshJwt:e.refreshJwt||n,sessionExpiration:e.sessionExpiration||Zt(e),cookieExpiration:e.cookieExpiration||Jt(e)},r)},Xt=(e,t)=>{var i;return["beforeRequest","afterRequest"].reduce(((i,n)=>{var o;return i[n]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[n])||[]).concat((null==t?void 0:t[n])||[]),i}),null!==(i=e.hooks)&&void 0!==i?i:e.hooks={}),e},Qt=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),i=(null==t?void 0:t.authInfo)||t||{};return Yt(i)},ei=()=>qt&&!!window.descopeBridge,ti=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const i=(null==e?void 0:e.path)||"";return Ht.includes(i)},ii=void 0!==zt||qt&&void 0!==window.localStorage,ni=(e,t)=>{var i,n;return null===(n=null===(i=zt||qt&&window.localStorage)||void 0===i?void 0:i.setItem)||void 0===n?void 0:n.call(i,e,t)},oi=e=>{var t,i;return null===(i=null===(t=zt||qt&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===i?void 0:i.call(t,e)},ri=e=>{var t,i;return null===(i=null===(t=zt||qt&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===i?void 0:i.call(t,e)},si=e=>{var t,i,n,o,r;return null!==(r=null!==(i=null===(t=null==zt?void 0:zt.key)||void 0===t?void 0:t.call(zt,e))&&void 0!==i?i:qt&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.key)||void 0===o?void 0:o.call(n,e)))&&void 0!==r?r:null},ai=(...e)=>{console.debug(...e)},di=(...e)=>{console.warn(...e)},li="DS",ci="DSR",ui="DSI",hi="DSRCN";function fi(e,t,i){if(t){const{cookieDomain:n,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=i,d=new Date(1e3*s),l=pi(n);Et.set(e,t,{path:o,domain:l?n:void 0,expires:d,sameSite:r,secure:a})}}function pi(e){const t=window.location.hostname.split("."),i=null==e?void 0:e.split(".");return t.slice(-(null==i?void 0:i.length)).join(".")===e}const gi=e=>(null==e?void 0:e.cookieName)||li,vi=e=>(null==e?void 0:e.cookieName)||ci;function mi(e="",t){return Et.get(vi(t))||oi(`${e}${ci}`)||""}function yi(e="",t){return Et.get(gi(t))||oi(`${e}${li}`)||""}function bi(e=""){return oi(`${e}${ui}`)||""}function $i(e="",t,i,n){ri(`${e}${ci}`),ri(`${e}${li}`),ri(`${e}${ui}`),ri(`${e}${hi}`);const o=gi(t);Et.remove(o,null==n?void 0:n.session);const r=vi(i);Et.remove(r,null==n?void 0:n.refresh)}const wi=(e,t,i)=>n=>{const o=Object.assign(n,{token:n.token||mi(e,t)});if(!i){const t=function(e=""){return oi(`${e}${hi}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return oi(`${e}DTD`)||""}(e);return r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r})),o},Ci=qt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",ki="vsid",Si="vrid",Ii="fp",Ri=(e=!1)=>{const t=oi(Ii);if(!t)return null;const i=JSON.parse(t);return(new Date).getTime()>i.expiry&&!e?null:i.value},xi=async(e,t=Ci)=>{try{if(Ri())return;const i=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=new URL(t);n.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Lt({apiKey:e,endpoint:[n.toString(),At],scriptUrlPattern:[r,Wt]}),a=await s,{requestId:d}=await a.get({linkedId:i}),l=((e,t)=>({[ki]:e,[Si]:t}))(i,d);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};ni(Ii,JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Oi=e=>{const t=Ri(!0);return t&&e.body&&(e.body.fpData=t),e},Ei="descopeFlowNonce",Ai="X-Descope-Flow-Nonce",Ni="/v1/flow/start",ji="/v1/flow/next",Mi=(e,t=Ei)=>`${t}${e}`,Pi=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Ui=e=>{var t;return e.path===ji&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Pi(e.body.executionId):null},Ti="dls_last_user_login_id",Wi="dls_last_user_display_name",Li=e=>ni(Ti,e),Di=()=>oi(Ti),_i=()=>oi(Wi),Fi=e=>async(...t)=>{var i;t[1]=t[1]||{};const[,n={}]=t,o=Di(),r=_i();return o&&(null!==(i=n.lastAuth)&&void 0!==i||(n.lastAuth={}),n.lastAuth.loginId=o,n.lastAuth.name=r),await e(...t)},qi="DSLI",Bi=e=>async(...t)=>{const i=await e(...t);return ri(qi),i};function Vi(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const i=e.push(t)-1;return()=>e.splice(i,1)}}}async function Ki(e){const t=function(e){var t;const i=JSON.parse(e);return i.publicKey.challenge=Yi(i.publicKey.challenge),i.publicKey.user.id=Yi(i.publicKey.user.id),null===(t=i.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Yi(e.id)})),i}(e);return i=await navigator.credentials.create(t),JSON.stringify({id:i.id,rawId:Xi(i.rawId),type:i.type,response:{attestationObject:Xi(i.response.attestationObject),clientDataJSON:Xi(i.response.clientDataJSON)}});var i}async function Hi(e){const t=Ji(e);return Zi(await navigator.credentials.get(t))}async function zi(e,t){const i=Ji(e);return i.signal=t.signal,i.mediation="conditional",Zi(await navigator.credentials.get(i))}async function Gi(e=!1){var t,i;if(!qt)return Promise.resolve(!1);if(ei()){const e=null===(i=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===i?void 0:i.webauthn;if("boolean"==typeof e)return e}const n=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return n&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():n}function Ji(e){var t;const i=JSON.parse(e);return i.publicKey.challenge=Yi(i.publicKey.challenge),null===(t=i.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Yi(e.id)})),i}function Zi(e){return JSON.stringify({id:e.id,rawId:Xi(e.rawId),type:e.type,response:{authenticatorData:Xi(e.response.authenticatorData),clientDataJSON:Xi(e.response.clientDataJSON),signature:Xi(e.response.signature),userHandle:e.response.userHandle?Xi(e.response.userHandle):void 0}})}function Yi(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Xi(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Qi,en=(Qi=e=>({async signUp(t,i,n){const o=await e.webauthn.signUp.start(t,window.location.origin,i,n);if(!o.ok)return o;const r=await Ki(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,i){const n=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,i);if(!n.ok)return n;const o=await Hi(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t,i){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,i);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await Ki(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Hi(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,i,n){const o=await e.webauthn.update.start(t,window.location.origin,i,n);if(!o.ok)return o;const r=await Ki(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Ki,get:Hi,isSupported:Gi,conditional:zi}}),(...e)=>{const t=Qi(...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 tn="/fedcm/config",nn=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function on(e,t){var i;try{await rn(e,t)}catch(e){null===(i=null==t?void 0:t.onFailed)||void 0===i||i.call(t,e)}}async function rn(e,t){var i,n;const o=await async function(e,t="google",i,n,o){const r=nn(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let i=document.getElementById("google-gsi-client-script");i||(i=document.createElement("script"),document.head.appendChild(i),i.async=!0,i.defer=!0,i.id="google-gsi-client-script",i.src="https://accounts.google.com/gsi/client"),i.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},i.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const d=a.data.clientId;return new Promise((e=>{var a,l;const c=i=>{e({provider:t,nonce:r,credential:null==i?void 0:i.credential})};s.initialize(Object.assign(Object.assign({},i),{itp_support:null===(a=null==i?void 0:i.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(l=null==i?void 0:i.use_fedcm_for_prompt)||void 0===l||l,client_id:d,callback:c,nonce:r})),s.prompt((e=>{var t,i;if(o&&(null==e?void 0:e.isDismissedMoment())){const i=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(i),void c()}if(n&&(null==e?void 0:e.isSkippedMoment())){const t=null===(i=e.getSkippedReason)||void 0===i?void 0:i.call(e);return null==n||n(t),void c()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const n=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onCodeReceived)||void 0===i||i.call(t,n.data.code)}else{const i=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onAuthenticated)||void 0===n||n.call(t,i.data)}}var sn=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const i=await Gi(),n=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:i},startOptionsVersion:1});return t[1]=n,e.flow.start(...t)}});let an;const dn=(e,t)=>new Promise(((i,n)=>{if(!e.length)return n(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return i(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return i(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{dn(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),ln=(e,t,i)=>{const n=async()=>{let n,o;return n&&o||({client:n,stateUserKey:o}=await(async(e,t,i)=>{an||(an=(async()=>{try{return require("oidc-client-ts")}catch(e){return dn([Vt,Kt],(()=>window.oidc))}})());const{OidcClient:n,WebStorageStateStore:o}=await an;if(!n)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==i?void 0:i.redirectUri)||window.location.href;let s,a,d,l;if(null==i?void 0:i.issuer){if(!i.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=i.issuer,a=i.clientId,d=`${a}_user`,l="openid"}else(null==i?void 0:i.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${i.applicationId}`,a=t,d=`${a}_user`,l="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,d=`${a}_user`,l="openid email roles descope.custom_claims offline_access");const c={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==i?void 0:i.scope)||l,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==i?void 0:i.redirectUri)&&(c.redirect_uri=i.redirectUri),{client:new n(c),stateUserKey:d}})(e,t,i)),{client:n,stateUserKey:o}},o=async(t="")=>{var i;const{client:o,stateUserKey:r}=await n(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(s)))),ni(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},i=!1)=>{var o;const{client:r}=await n(),s=await r.createSigninRequest(t),{url:a}=s;return i||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var i;const{client:o,stateUserKey:r}=await n(),s=(e=>{const t=oi(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const d=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(d)))),d},logout:async(e,t=!1)=>{const{client:i,stateUserKey:o}=await n();e||(e={}),e.id_token_hint=e.id_token_hint||bi(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await i.createSignoutRequest(e),{url:s}=r;return ri(o),t||window.location.replace(s),r}}},cn=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var i;return i=t.customStorage,zt=i,e(t)}),(e=>t=>{var{fpKey:i,fpLoad:n}=t,o=l(t,["fpKey","fpLoad"]);return qt?(i&&n&&xi(i).catch((()=>null)),e(Xt(o,{beforeRequest:Oi}))):e(o)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.50.2"},t.baseHeaders)}))),(e=>t=>{const i=Vi(),n=Vi(),o=Vi(),r=Vi(),s=e(Xt(t,{afterRequest:async(e,t)=>{if(ti(e,t))ai("Session invalidated, notifying subscribers with empty values"),n.pub(null),o.pub(null),i.pub(null),r.pub(null);else{const e=await(async e=>{const t=await Qt(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:d}=await Qt(t);s&&n.pub(s),d&&r.pub(d),(a||s)&&i.pub(a||42)}}})),a=ge(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return n.pub(null),o.pub(null),i.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:n.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>i.sub((t=>{e(!!t)}))})}),(e=>t=>{var i;const{enableFlowNonce:n=!0,nonceStoragePrefix:o=Ei}=t,r=l(t,["enableFlowNonce","nonceStoragePrefix"]);if(!n)return e(r);((e=Ei)=>{try{if(!ii)return;for(let o=0;o<(void 0,i=void 0,void 0,null!==(n=null!==(t=null==zt?void 0:zt.length)&&void 0!==t?t:qt&&(null===(i=window.localStorage)||void 0===i?void 0:i.length))&&void 0!==n?n:0);o++){const t=si(o);if(t&&t.startsWith(e)){const i=oi(t);if(i)try{JSON.parse(i).expiry<Date.now()&&ri(t)}catch(e){ri(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,i,n})(o);const s=e(Xt(r,{afterRequest:async(e,t)=>{if(e.path!==Ni&&e.path!==ji)return;const{nonce:i,executionId:n}=await(async(e,t)=>{try{const i=t.headers.get(Ai);let n=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return n||(n=Ui(e)),{nonce:i,executionId:Pi(n)}}catch(e){return{nonce:null,executionId:null}}})(e,t);i&&n&&((e,t,i,n=Ei)=>{try{const o=Mi(e,n),r=i?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:i};ni(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(n,i,e.path===Ni,o)},beforeRequest:e=>{if(e.path===ji){const t=Ui(e);if(t){const i=((e,t=Ei)=>{try{const i=Mi(e,t),n=oi(i);if(!n)return null;const o=JSON.parse(n);return o.expiry<Date.now()?(((e,t=Ei)=>{try{const i=Mi(e,t);ri(i)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,o);i&&(e.headers=e.headers||{},e.headers[Ai]=i)}}return e}}));if(null===(i=s.flow)||void 0===i?void 0:i.next){let e=Promise.resolve();const t=s.flow.next.bind(s.flow);s.flow.next=async(...i)=>{const n=e;let o;e=new Promise((e=>{o=e})),await n;try{return await t(...i)}finally{o()}}}return s}),(e=>t=>{const i=e(Xt(t,{afterRequest:async(e,t)=>{if(ti(e,t))return void ri(qi);const i=await Qt(t);(null==i?void 0:i.sessionExpiration)&&ni(qi,String(i.sessionExpiration))}}));return ge(i,["logout","logoutAll","oidc.logout"],Bi)}),(e=>t=>{var{autoRefresh:i}=t,n=l(t,["autoRefresh"]);const o=!!i,r="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!o||ei())return Object.assign(e(n),{markUserActive:()=>{di("markUserActive() called but has no effect")}});const{clearAllTimers:s,setTimer:a}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,i)=>{e.push(setTimeout(t,i))}}})();let d,c,u=null,h=!1,f=!1;r&&(ai("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),qt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&d&&new Date>d&&(ai("Expiration time passed, refreshing session"),p.refresh(mi()||c))}));const p=e(Xt(n,{afterRequest:async(e,t)=>{const{sessionJwt:i,refreshJwt:n,sessionExpiration:o,nextRefreshSeconds:r}=await Qt(t);if(ti(e,t))ai("Session invalidated, canceling all timers"),s();else if(i||o){if(d=((e,t)=>{if(t)return new Date(1e3*t);ai("Could not extract expiration time from session token, trying to decode the token");try{const t=g(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(i,o),!d)return void ai("Could not extract expiration time from session token");c=n,h=r>0;const e=((e,t)=>{let i;var n;return t>0?(i=1e3*t,ai(`Using provided nextRefreshSeconds: ${t}s`)):i=((n=e)?n.getTime()-(new Date).getTime():0)-2e4,i>Bt&&(ai(`Timeout is too large (${i}ms), setting it to ${Bt}ms`),i=Bt),i})(d,r);if(s(),e<=2e4)return void ai("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});ai(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),f=!1),a((()=>{if(qt&&"hidden"===document.visibilityState)ai("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return ai("Skipping refresh due to timer - user is idle"),void(f=!0);ai("Refreshing session due to timer"),p.refresh(mi()||n)}}),e)}}}));return Object.assign(ge(p,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const i=await e(...t);return ai("Clearing all timers"),s(),i})),{markUserActive:u?()=>{ai("markUserActive() called"),h||ai("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),f&&(ai("User became active after skipped refresh, triggering refresh"),f=!1,s(),p.refresh(mi()||c))}:()=>{di("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>t=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:n=!1}=t,o=l(t,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(o),{getLastUserLoginId:Di,getLastUserDisplayName:_i});const r=e(Xt(o,{afterRequest:async(e,t)=>{var i;const{userInfo:n,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),i=Yt((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==i?void 0:i.user)||((null==i?void 0:i.hasOwnProperty("userId"))?i:void 0),lastAuth:t.lastAuth}})(t),r=null===(i=null==n?void 0:n.loginIds)||void 0===i?void 0:i[0],s=null==n?void 0:n.name;r?(Li(r),(e=>{ni(Wi,e)})(s)):(null==o?void 0:o.loginId)&&Li(o.loginId)}}));let s=ge(r,["flow.start"],Fi);return s=ge(s,["logout","logoutAll"],(e=>t=>async(...i)=>{const n=await t(...i);return e||(ri(Ti),ri(Wi)),n})(n)),Object.assign(s,{getLastUserLoginId:Di,getLastUserDisplayName:_i})}),(e=>t=>{var{persistTokens:i,sessionTokenViaCookie:n,refreshTokenViaCookie:o,storagePrefix:r,refreshCookieName:s}=t,a=l(t,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!qt)return e(Object.assign({refreshCookieName:s},a));let d;const c=e(Xt(Object.assign({refreshCookieName:s},a),{beforeRequest:wi(r,o,s),afterRequest:async(e,t)=>{if(ti(e,t))ai("Session invalidated, clearing persisted tokens"),$i(r,n,o,d);else{const e=await Qt(t);e.cookieName?ni(`${r||""}${hi}`,e.cookieName):e.refreshJwt&&ri(`${r||""}${hi}`);const i=((e={},t=!1,i="",n=!1)=>{var o,r,s,a;const{sessionJwt:d,refreshJwt:l,trustedDeviceJwt:c}=e;let u;if(l)if(n){ri(`${i}${ci}`);const t=n.sameSite||"Strict",s=null===(o=n.secure)||void 0===o||o,a=null!==(r=n.domain)&&void 0!==r?r:e.cookieDomain,d=vi(n);s&&"https:"!==window.location.protocol&&di("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});fi(d,l,c);const h=pi(a);u=Object.assign(Object.assign({},u),{refresh:{path:c.cookiePath,domain:h?a:void 0}})}else{const e=vi(n);Et.remove(e),ni(`${i}${ci}`,l)}if(d)if(t){const i=t.sameSite||"Strict",n=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=gi(t);n&&"https:"!==window.location.protocol&&di("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const l=Object.assign(Object.assign({},e),{cookieSameSite:i,cookieSecure:n,cookieDomain:o});fi(r,d,l);const c=pi(o);u=Object.assign(Object.assign({},u),{session:{path:l.cookiePath,domain:c?o:void 0}})}else ni(`${i}${li}`,d);return e.idToken&&ni(`${i}${ui}`,e.idToken),c&&ni(`${i}DTD`,c),u})(e,n,r,o);i&&(d=i)}}})),u=ge(c,["logout","logoutAll","oidc.logout"],((e,t,i,n)=>o=>async(...r)=>{const s=await o(...r);return $i(e,t,i,null==n?void 0:n()),s})(r,n,o,(()=>d)));return Object.assign(u,{getRefreshToken:()=>mi(r,o),getSessionToken:()=>yi(r,n),getIdToken:()=>bi(r)})}))((e=>{const t=xt(e),i=ln(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(n,o)=>{var r;if(ei())return ai(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await i.refreshToken(n),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&!oi(qi)&&!oi(Ti)&&!oi("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=yi(),a=mi();let d="";if(e.getExternalToken)try{d=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){ai("Error getting external token while refreshing",e)}return t.refresh(n,{dcs:s?"t":"f",dcr:a?"t":"f"},d,o)},logout:async n=>{if(e.oidcConfig)try{return await i.logout({id_token_hint:n}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(n)},flow:sn(t),webauthn:en(t),fedcm:(n=t,o=e.projectId,{onetap:{requestExchangeCode(e){on(n,e)},requestAuthentication(e){on(n,e)}},async oneTap(e,t,i,o,r){await rn(n,{provider:e,oneTapConfig:t,loginOptions:i,onSkipped:o,onDismissed:r})},async launch(e){var t;const i={identity:{context:e||"signin",providers:[{configURL:n.httpClient.buildUrl(o+tn),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return n.refresh(r.token)},isSupported:()=>qt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const i=n.httpClient.buildUrl(o+tn);try{const n={identity:{context:e||"signin",providers:[{configURL:i,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return!!r&&!!r.token}catch(e){return!1}}}),oidc:i});var n,o}));let un;const hn=e=>{const t=cn(Object.assign({persistTokens:a,autoRefresh:a},e));return un=t,t},fn=()=>hn({projectId:"temp pid",persistTokens:!1,autoRefresh:!1,storeLastAuthenticatedUser:!1});un=fn();const pn=()=>a?null==un?void 0:un.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),gn=()=>a?null==un?void 0:un.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),vn=o(((e=pn(),t)=>null==un?void 0:un.getJwtPermissions(e,t))),mn=o(((e=pn(),t)=>null==un?void 0:un.getJwtRoles(e,t))),yn=o(((e=pn())=>null==un?void 0:un.getCurrentTenant(e)));function bn(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const $n=e=>{const t=document.createElement("template");return t.innerHTML=e,t},wn=(e,t)=>e.length===t.length&&e.every(((e,i)=>e===t[i])),Cn=e=>{let t,i;return(...n)=>(t&&wn(t,n)||(t=n,i=e(...n)),i)},kn=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase(),Sn=e=>(t,...i)=>t.reduce(((t,n,o)=>{var r;return`${t}${n}${(null===(r=null==i?void 0:i[o])||void 0===r?void 0:r[e>1?1:0])||""}`}),""),In=(e,t=500)=>{let i;return function(...n){clearTimeout(i),i=setTimeout((()=>e.apply(this,n)),t)}},Rn=e=>{const t=Symbol((e=>{const t=e.toString();let i=0;for(let e=0;e<t.length;e++)i=(i<<5)-i+t.charCodeAt(e),i&=i;return i.toString(16)})(e));return i=>{if(i[t])return i;const n=e(i);return n[t]=!0,n}};var xn,On,En,An;function Nn(e,t){const i=Object.getOwnPropertyNames(e),n=Object.getOwnPropertyNames(t);if(i.length!==n.length)return!1;for(let n=0;n<i.length;n+=1){const o=i[n],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Nn(r,s))return!1}else if(r!==s)return!1}return!0}let jn=class{constructor(e={},{forceUpdate:t=!1}={}){xn.set(this,void 0),On.set(this,{}),En.set(this,0),An.set(this,!0),this.update=e=>{const t="function"==typeof e?e(u(this,xn,"f")):e,i=Object.assign(Object.assign({},u(this,xn,"f")),t);if(u(this,An,"f")||!Nn(u(this,xn,"f"),i)){const e=u(this,xn,"f");h(this,xn,i,"f"),Object.freeze(u(this,xn,"f")),setTimeout((()=>{Object.values(u(this,On,"f")).forEach((t=>t(i,e,((e,t)=>i=>e[i]!==t[i])(i,e))))}),0)}},h(this,xn,e,"f"),h(this,An,t,"f")}get current(){return Object.assign({},u(this,xn,"f"))}subscribe(e){return h(this,En,u(this,En,"f")+1,"f"),u(this,On,"f")[u(this,En,"f")]=e,u(this,En,"f").toString()}unsubscribe(e){const t=!!u(this,On,"f")[e];return t&&delete u(this,On,"f")[e],t}unsubscribeAll(){return h(this,On,{},"f"),!0}};xn=new WeakMap,On=new WeakMap,En=new WeakMap,An=new WeakMap;const Mn=["=","+","-","@","\t","\r"],Pn=e=>{const t=(e=>e.length>0&&Mn.includes(e[0])?`'${e}`:e)(Array.isArray(e)?e.join("; "):String(null!=e?e:""));return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t.replace(/"/g,'""')}"`:t},Un=e=>"string"==typeof e||null==e?e:JSON.stringify(e),Tn=e=>t.forwardRef(((i,n)=>{const{prop:o,attr:r,rest:s}=t.useMemo((()=>Object.entries(i).reduce(((e,[t,i])=>{const{trimmedKey:n,category:o}=(e=>{const[,t,i]=/(.*)\.(prop|attr)$/.exec(e)||[,e,"rest"];return{trimmedKey:t,category:i}})(t);return"prop"===o?e.prop.push([n,i]):"attr"===o?e.attr.push([kn(n),Un(i)]):Object.assign(e.rest,{[kn(n)]:i}),e}),{attr:[],prop:[],rest:{}})),[i]),a=t.useRef(null),d=t.useCallback((e=>{a.current=e,e&&(o.forEach((([e,t])=>{a.current[e]=t})),r.forEach((([t,i])=>{null==i?e.removeAttribute(t):e.setAttribute(t,i)})))}),[o,r,a]);return t.useImperativeHandle(n,(()=>a.current)),t.createElement(e,Object.assign({ref:d},s))})),Wn=t.lazy((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await Promise.resolve().then((function(){return Na})).then((e=>e.default))).sdkConfigOverrides={baseHeaders:s,persistTokens:!1,hooks:{get beforeRequest(){return un.httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:Tn(t.forwardRef(((e,i)=>{var{"external-request-id":n}=e,o=l(e,["external-request-id"]);return t.useMemo((()=>{var e,t;e="x-external-rid",(t=n)?s[e]=t:delete s[e]}),[n]),t.createElement("descope-wc",Object.assign({ref:i},o))})))}))),Ln=t.forwardRef((({flowId:e,onSuccess:n,onError:o,onReady:r,logger:s,tenant:a,theme:d,nonce:l,locale:c,debug:u,client:h,form:f,telemetryKey:p,redirectUrl:g,autoFocus:v,validateOnBlur:m,restartOnError:y,errorTransformer:b,styleId:$,onScreenUpdate:w,dismissScreenErrorOnInput:C,outboundAppId:k,outboundAppScopes:S,popupOrigin:I,children:R,externalRequestId:x,themeOverride:O},E)=>{const[A,N]=t.useState(null);t.useImperativeHandle(E,(()=>A));const{projectId:j,baseUrl:M,baseStaticUrl:P,baseCdnUrl:U,storeLastAuthenticatedUser:T,keepLastAuthenticatedUserAfterLogout:W,refreshCookieName:L,customStorage:D,sdk:_}=t.useContext(i),F=t.useCallback((async e=>{await _.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),n&&n(e)}),[n]);return t.useEffect((()=>{const e=A;return null==e||e.addEventListener("success",F),o&&(null==e||e.addEventListener("error",o)),r&&(null==e||e.addEventListener("ready",r)),()=>{o&&(null==e||e.removeEventListener("error",o)),r&&(null==e||e.removeEventListener("ready",r)),null==e||e.removeEventListener("success",F)}}),[A,o,F]),t.useEffect((()=>{const e=A;return null==e||e.addEventListener("success",F),()=>{null==e||e.removeEventListener("success",F)}}),[A,F]),t.useEffect((()=>{const e=A;return o&&(null==e||e.addEventListener("error",o)),()=>{o&&(null==e||e.removeEventListener("error",o))}}),[A,o]),t.useEffect((()=>{const e=A;return r&&(null==e||e.addEventListener("ready",r)),()=>{r&&(null==e||e.removeEventListener("error",r))}}),[A,r]),t.createElement("form",null,t.createElement(t.Suspense,{fallback:null},t.createElement(Wn,{projectId:j,flowId:e,baseUrl:M,baseStaticUrl:P,baseCdnUrl:U,ref:N,telemetryKey:p,redirectUrl:g,autoFocus:v,styleId:$,validateOnBlur:m,restartOnError:y,keepLastAuthenticatedUserAfterLogout:W,tenant:a,externalRequestId:x,customStorage:D,themeOverride:O,"theme.attr":d,"nonce.attr":l,"locale.attr":c,"form.attr":f,"client.attr":h,"debug.attr":u,"outbound-app-id.attr":k,"outbound-app-scopes.attr":S,"popup-origin.attr":I,"store-last-authenticated-user.attr":T,"refreshCookieName.attr":L,"dismiss-screen-error-on-input.attr":C,"errorTransformer.prop":b,"logger.prop":s,"onScreenUpdate.prop":w,"customStorage.prop":D},R)))}));var Dn=()=>{const e=t.useContext(i);if(!e)throw Error("You can only use this hook in the context of <AuthProvider />");return e};const _n=e=>`You can only use this ${e} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`,Fn={get(e,t){if("object"==typeof e[t]&&null!==e[t])return new Proxy(e[t],Fn);if("function"==typeof e[t])return()=>{throw Error(_n("function"))};throw Error(_n("attribute"))}},qn=t.lazy((async()=>(await Promise.resolve().then((function(){return ku})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-access-key-management-widget",Object.assign({ref:i},e)))))}))),Bn=t.forwardRef((({logger:e,tenant:n,theme:o,debug:r,widgetId:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v}=t.useContext(i);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(qn,{ref:u,projectId:h,widgetId:s,tenant:n,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,"theme.attr":o,"debug.attr":r,"styleId.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),Vn=t.lazy((async()=>(await Promise.resolve().then((function(){return Ku})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-applications-portal-widget",Object.assign({ref:i},e)))))}))),Kn=t.forwardRef((({logger:e,theme:n,debug:o,widgetId:r,styleId:s,onReady:a},d)=>{const[l,c]=t.useState(null);t.useImperativeHandle(d,(()=>l));const{projectId:u,baseUrl:h,baseStaticUrl:f,baseCdnUrl:p,refreshCookieName:g}=t.useContext(i);return t.useEffect((()=>{const e=l;return a&&(null==e||e.addEventListener("ready",a)),()=>{a&&(null==e||e.removeEventListener("ready",a))}}),[l,a]),t.createElement(t.Suspense,{fallback:null},t.createElement(Vn,{ref:c,projectId:u,widgetId:r,baseUrl:h,baseStaticUrl:f,baseCdnUrl:p,"theme.attr":n,"debug.attr":o,"styleId.attr":s,"refreshCookieName.attr":g,"logger.prop":e}))})),Hn=t.lazy((async()=>(await Promise.resolve().then((function(){return fh})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-audit-management-widget",Object.assign({ref:i},e)))))}))),zn=t.forwardRef((({logger:e,tenant:n,theme:o,debug:r,widgetId:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v}=t.useContext(i);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(Hn,{ref:u,projectId:h,widgetId:s,tenant:n,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,"theme.attr":o,"debug.attr":r,"styleId.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),Gn=t.lazy((async()=>(await Promise.resolve().then((function(){return Kh})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-outbound-applications-widget",Object.assign({ref:i},e)))))}))),Jn=t.forwardRef((({logger:e,theme:n,debug:o,widgetId:r,styleId:s,onReady:a},d)=>{const[l,c]=t.useState(null);t.useImperativeHandle(d,(()=>l));const{projectId:u,baseUrl:h,baseStaticUrl:f,baseCdnUrl:p,refreshCookieName:g}=t.useContext(i);return t.useEffect((()=>{const e=l;return a&&(null==e||e.addEventListener("ready",a)),()=>{a&&(null==e||e.removeEventListener("ready",a))}}),[l,a]),t.createElement(t.Suspense,{fallback:null},t.createElement(Gn,{ref:c,projectId:u,widgetId:r,baseUrl:h,baseStaticUrl:f,baseCdnUrl:p,"theme.attr":n,"debug.attr":o,"styleId.attr":s,"refreshCookieName.attr":g,"logger.prop":e}))})),Zn=t.lazy((async()=>(await Promise.resolve().then((function(){return Gf})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-role-management-widget",Object.assign({ref:i},e)))))}))),Yn=t.forwardRef((({logger:e,tenant:n,theme:o,debug:r,widgetId:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v}=t.useContext(i);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(Zn,{ref:u,projectId:h,widgetId:s,tenant:n,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,"theme.attr":o,"debug.attr":r,"styleId.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),Xn=t.lazy((async()=>(await Promise.resolve().then((function(){return Dp})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-tenant-profile-widget",Object.assign({ref:i},e)))))}))),Qn=t.forwardRef((({logger:e,theme:n,debug:o,widgetId:r,styleId:s,tenant:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v}=t.useContext(i);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(Xn,{projectId:h,widgetId:r,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,styleId:s,tenant:a,ref:u,"theme.attr":n,"debug.attr":o,"styleId.attr":s,"tenant.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),eo=t.lazy((async()=>(await Promise.resolve().then((function(){return H$})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-user-management-widget",Object.assign({ref:i},e)))))}))),to=t.forwardRef((({logger:e,tenant:n,theme:o,debug:r,widgetId:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v}=t.useContext(i);return t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(eo,{projectId:h,widgetId:s,tenant:n,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,ref:u,"theme.attr":o,"debug.attr":r,"styleId.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),io=t.lazy((async()=>(await Promise.resolve().then((function(){return hC})),{default:Tn(t.forwardRef(((e,i)=>t.createElement("descope-user-profile-widget",Object.assign({ref:i},e)))))}))),no=t.forwardRef((({logger:e,theme:n,debug:o,widgetId:r,onLogout:s,styleId:a,onReady:d},l)=>{const[c,u]=t.useState(null);t.useImperativeHandle(l,(()=>c));const{projectId:h,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,refreshCookieName:v,setSession:m,setUser:y,setIsAuthenticated:b}=t.useContext(i),$=t.useCallback((e=>{s&&s(e),b(!1),m(""),y(null)}),[s,m,b,y]);return t.useEffect((()=>{if(c)return c.addEventListener("logout",$),()=>c.removeEventListener("logout",$)}),[c,$]),t.useEffect((()=>{const e=c;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("ready",d))}}),[c,d]),t.createElement(t.Suspense,{fallback:null},t.createElement(io,{projectId:h,widgetId:r,baseUrl:f,baseStaticUrl:p,baseCdnUrl:g,styleId:a,ref:u,"theme.attr":n,"debug.attr":o,"styleId.attr":a,"refreshCookieName.attr":v,"logger.prop":e}))})),oo="undefined"!=typeof localStorage,ro="J151000",so="E103205",ao=oo&&localStorage.getItem("base.content.url")||"",lo="base.ui.components.url";oo&&localStorage.getItem(lo),oo&&localStorage.getItem(lo);const co="descope-login-flow",uo="code",ho="redirect_mode",fo="err",po="data-exclude-field",go="data-exclude-next",vo="dls_last_auth",mo="state_id",yo="saml_idp_state_id",bo="wsfed_idp_state_id",$o="saml_idp_username",wo="descope_idp_initiated",Co="sso_app_id",ko="custom_app_id",So="third_party_app_id",Io="third_party_app_state_id",Ro="oidc_login_hint",xo="oidc_prompt",Oo="oidc_resource",Eo="oidc_error_redirect_uri",Ao="application_scopes",No="data-type",jo="redirect",Mo="poll",Po="webauthnCreate",Uo="webauthnGet",To="nativeBridge",Wo="loadForm",Lo="submit",Do="polling",_o=["descope-multi-select-combo-box","descope-text-area"],Fo="dls_last_auth_in_flight",qo=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Bo;!function(e){e.backward="backward",e.forward="forward"}(Bo||(Bo={}));const Vo=["descope-enriched-text"];function Ko(e){return new URLSearchParams(window.location.search).get(e)}function Ho(e){if(window.history.replaceState&&Ko(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}function zo(e,t){if(!t)return;const i=+e,n=+t;return Number.isNaN(i)||Number.isNaN(n)?void 0:i>n?Bo.forward:i<n?Bo.backward:void 0}const Go=e=>{let[t="",i=""]=(Ko(co)||"").split("_");const n=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||n&&n!==e)&&(t="",i=""),{executionId:t,stepId:i,executionFlowId:n}};function Jo(){Ho(co)}const Zo=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Yo=(e,t)=>{const{executionId:i,stepId:n,executionFlowId:o}=Go(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(i||n)&&Jo();const r=Ko("t")||void 0;r&&Ho("t");const s=Ko(uo)||void 0;s&&Ho(uo);const a="popup"===Ko(ho);a&&Ho(ho);const d=Ko(fo)||void 0;d&&Ho(fo);const{redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:Ko("ra-challenge"),redirectAuthCallbackUrl:Ko("ra-callback"),redirectAuthBackupCallbackUri:Ko("ra-backup-callback"),redirectAuthInitiator:Ko("ra-initiator")},f=Ko(mo);f&&Ho(mo);const p=Ko(yo);p&&Ho(yo);const g=Ko(bo);g&&Ho(bo);const v=Ko($o);p&&Ho($o);const m=Ko(wo);m&&Ho(wo);const y=Ko(Co);y&&Ho(Co);const b=Ko(ko);b&&Ho(ko);const $=Ko(So);$&&Ho(So);const w=Ko(Io);w&&Ho(Io);const C=Ko(Ao);C&&Ho(Ao);const k=Ko(Ro);k&&Ho(Ro);const S=Ko(xo);S&&Ho(xo);const I=Ko(Eo);I&&Ho(Eo);const R=Ko(Oo);return R&&Ho(Oo),{executionId:i,stepId:n,token:r,code:s,isPopup:a,exchangeError:d,redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:f,samlIdpStateId:p,wsfedIdpStateId:g,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:y,customAppId:b,oidcLoginHint:k,oidcPrompt:S,oidcErrorRedirectUri:I,oidcResource:R,thirdPartyAppId:$,thirdPartyAppStateId:w,applicationScopes:C}}},Xo=e=>{let t,i;return Object.assign(((...n)=>{return t&&(r=n,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=n,i=e(...n)),i;var o,r}),{reset:()=>{t=void 0,i=void 0}})},Qo=(e,t,i)=>{if(!0===t||"skipFirstScreen"===t&&!i){const t=e.querySelector('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])');setTimeout((()=>{null==t||t.focus()}))}};function er(e,t,i){return new Promise(((n,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==i?n(i):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),n(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const tr=(e,{oidcIdpStateId:t,samlIdpStateId:i,wsfedIdpStateId:n,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:d,oidcErrorRedirectUri:l,oidcResource:c,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:f})=>!(!e||t||i||n||o||r||s||a||d||l||c||u||h||f),ir=e=>null==e?void 0:e.submit(),nr=(e,t)=>{const i=t.find((t=>e[t]));return i?e[i]:null},or=(e,t=100)=>{let i;return function(...n){i||e.apply(this,n),clearTimeout(i),i=setTimeout((()=>{i=null}),t)}};function rr(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const sr=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function ar(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var dr,lr,cr,ur;function hr(e,t){const i=Object.getOwnPropertyNames(e),n=Object.getOwnPropertyNames(t);if(i.length!==n.length)return!1;for(let n=0;n<i.length;n+=1){const o=i[n],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!hr(r,s))return!1}else if(r!==s)return!1}return!0}let fr=class{constructor(e={},{forceUpdate:t=!1}={}){dr.set(this,void 0),lr.set(this,{}),cr.set(this,0),ur.set(this,!0),this.update=e=>{const t="function"==typeof e?e(u(this,dr,"f")):e,i=Object.assign(Object.assign({},u(this,dr,"f")),t),n=u(this,dr,"f");h(this,dr,i,"f"),Object.freeze(u(this,dr,"f")),setTimeout((()=>{Object.values(u(this,lr,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const r=t(n),s=t(i);(u(this,ur,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s)?!hr(r,s):r!==s))&&e(s,r,((e,t)=>i=>e[i]!==t[i])(s,r))}))}),0)},h(this,dr,e,"f"),h(this,ur,t,"f")}get current(){return Object.assign({},u(this,dr,"f"))}set forceUpdate(e){h(this,ur,e,"f")}subscribe(e,t=e=>e,{forceUpdate:i=!1}={}){return h(this,cr,u(this,cr,"f")+1,"f"),u(this,lr,"f")[u(this,cr,"f")]={cb:e,selector:t,forceUpdate:i},u(this,cr,"f").toString()}unsubscribe(e){const t=!!u(this,lr,"f")[e];return t&&delete u(this,lr,"f")[e],t}unsubscribeAll(){return h(this,lr,{},"f"),!0}};dr=new WeakMap,lr=new WeakMap,cr=new WeakMap,ur=new WeakMap;const pr=["*","#","/","(",")","[","]","_","<",">","`"],gr=e=>"string"!=typeof e?e:e.replace((e=>{const t=pr.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),vr=["disabled"],mr=(e,t)=>{Object.entries(t||{}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${po}])`)).forEach((e=>{e.value=i}))}))},yr=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),br=(e,t,i)=>e.replace(/{{(.+?)}}/g,((e,n)=>i?gr(yr(t,n)):yr(t,n))),$r=(e,t,i)=>{e.querySelectorAll(`[${No}="${t}"]`).forEach((e=>{e.setAttribute("href",i)}))},wr=(e,t,i)=>{var n,o;const r=null===(n=customElements.get(t))||void 0===n?void 0:n.cssVarList.url;i&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${i})`))},Cr=(e,t,i,n)=>{var o,r;$r(e,"totp-link",null===(o=null==t?void 0:t.totp)||void 0===o?void 0:o.provisionUrl),$r(e,"notp-link",null===(r=null==t?void 0:t.notp)||void 0===r?void 0:r.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const i=(e=>Vo.includes(e))(e.localName);e.textContent=br(e.textContent,t,i);const n=e.getAttribute("href");n&&e.setAttribute("href",br(n,t))}))})(e,t),((e,t,i)=>{if(!t)return;const{componentsDynamicAttrs:n}=t,o=l(t,["componentsDynamicAttrs"]),r=Object.keys(o).reduce(((e,t)=>(e[`[name=${t}]`]=o[t],e)),{});n&&Object.keys(n).forEach((e=>{const t=n[e];if(t){const{attributes:i}=t;i&&Object.keys(i).length&&(r[e]=i)}})),Object.keys(r).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=r[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==t?void 0:t.componentsConfig,n),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=br(e.value,t)}))}))})(e,t),((e,t)=>{Object.entries(t).forEach((([t,i])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(i).forEach((([t,i])=>{vr.includes(t)&&e.setAttribute(t,i)}))}))}))})(e,i),((e,t={},i)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[id="${CSS.escape(t)}"]`).forEach((e=>{switch(n){case"disable":e.setAttribute("disabled","true");break;case"hide":e.classList.add("hidden");break;case"read-only":e.setAttribute("readonly","true");break;default:null==i||i.error(`Unknown component state "${n}" for component with id "${t}"`,'Valid states are "disable", "hide", and "read-only"')}}))}))})(e,null==t?void 0:t.componentsState,n)},kr=Xo((()=>c(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const i=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)))),n=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,i=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return i?i.version:0})()>=108;return yield er(100,i,n)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let Sr;const Ir=(e,t)=>{Sr?Sr.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Rr=e=>Sr?Sr.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,xr="dls_ab_testing_id",Or={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.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,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[i,n]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=i?i:0)&&(e.abTestingKey||0)<=(null!=n?n:0)},"not-in-range":(e,t)=>{const[i,n]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==i&&void 0!==n&&!Number.isNaN(i)&&!Number.isNaN(n))||(e.abTestingKey||0)<i||(e.abTestingKey||0)>n},"devised-by":(e,t)=>{const i=Number(t);return!Number.isNaN(i)&&(e.abTestingKey||0)%i==0}}};function Er(e,t){const i={};try{Object.assign(i,JSON.parse(Rr(vo)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return i.loginId||e?i:{}}function Ar(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Ir(vo,JSON.stringify(e)))}function Nr(){try{return JSON.parse(Rr(Fo)||"{}")}catch(e){return{}}}function jr(e){try{(e=>{Sr?Sr.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(Fo)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const Mr=["error","warn","info","debug"],Pr={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},Ur=Rn((e=>{var t,i,n,o;return o=class extends e{constructor(){super(...arguments),t.add(this),i.set(this,u(this,t,"m",n).call(this,Pr))}set logger(e){h(this,i,u(this,t,"m",n).call(this,e||Pr),"f")}get logger(){return u(this,i,"f")}onLogEvent(e,t){}},i=new WeakMap,t=new WeakSet,n=function(e){return Mr.reduce(((t,i)=>(t[i]=(...t)=>{var n;this.onLogEvent(i,t),null===(n=e[i])||void 0===n||n.call(e,...t)},t)),{})},o})),Tr="undefined"!=typeof localStorage,Wr="https://static.descope.com/pages",Lr="https://static2.descope.com/pages",Dr=Tr&&localStorage.getItem("base.content.url")||"",_r=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Fr=Rn((e=>{var t,i;return i=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,i;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(i=this.shadowRoot)||void 0===i?void 0:i.isConnected)&&u(this,t,"f")&&(h(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,i})),qr=Rn((e=>{var t,i;const n=bn(Ur,Fr)(e);return i=class extends n{constructor(){super(...arguments),t.set(this,{})}async init(){var e,i,n;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i=this,n=e=>{var i;null===(i=u(this,t,"f")[e])||void 0===i||i.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(i.attributes).forEach((e=>n(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&n(e.attributeName)}))})).observe(i,{attributes:!0})}observeAttribute(e,i){u(this,t,"f")[e]||(u(this,t,"f")[e]=[]);const n=u(this,t,"f")[e].push(i);return()=>u(this,t,"f")[e].splice(n,1)}observeAttributes(e,t){const i=e.reduce(((e,i)=>(e.push(this.observeAttribute(i,t)),e)),[]);return()=>i.forEach((e=>e()))}},t=new WeakMap,i})),Br=e=>t=>{var i,n,o;const r=bn(Ur,Fr,qr)(t),s=Object.keys(e);return o=class extends r{constructor(...e){super(...e),i.add(this),this.observeAttributes(s,u(this,i,"m",n).bind(this))}async init(){var e;s.forEach((e=>u(this,i,"m",n).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},i=new WeakSet,n=function(t,i){const n=e[t],o="function"==typeof n?n(t,i):n;o&&this.logger.error(o)},o};Br.missingAttrValidator=_r;const Vr=Rn((e=>{const t=bn(Br({"project-id":_r}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Kr=Rn((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),Hr="Trying the next fallback URL...",zr=async(e,t,{logger:i}={})=>{try{return await fetch(e,t)}catch(n){return null==i||i.debug(`Network error fetching URL ${e} [${n.message}], retrying...`),fetch(e,t)}};const Gr=Rn((e=>{var t,i,n,o,r,s,a;const d=bn(Ur,Vr,Kr)(e);return a=class extends d{constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,new Set)}async fetchStaticResource(e,i){const s=u(this,t,"m",r).call(this,e),a=Array.isArray(s)?e=>{const{baseUrl:t}=s[e];h(this,n,t,"f");for(let t=0;t<e;t++){const e=s[t].baseUrl;u(this,o,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:i,onSuccess:n}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await zr(r.toString(),t,{logger:i});if(o.ok)return null==n||n(e),null==i||i.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==i||i.debug(`${a}. ${Hr}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==i||i.debug(`${t}. ${Hr}`)}}})(s,{cache:"default"},{logger:this.logger,onSuccess:a});return{body:await e[i](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},i=new WeakMap,n=new WeakMap,o=new WeakMap,t=new WeakSet,r=function(e){const r=Dr||this.baseStaticUrl;if(r)return u(this,t,"m",s).call(this,e,r);u(this,i,"f")!==this.baseUrl&&(h(this,i,this.baseUrl,"f"),h(this,n,void 0,"f"),u(this,o,"f").clear());const a=[];if(u(this,n,"f"))a.push(u(this,t,"m",s).call(this,e,u(this,n,"f"))),u(this,n,"f")===Wr&&a.push(u(this,t,"m",s).call(this,e,Lr));else{const i=this.baseUrl+"/pages";this.baseUrl&&!u(this,o,"f").has(i)&&a.push(u(this,t,"m",s).call(this,e,i)),u(this,o,"f").has(Wr)||a.push(u(this,t,"m",s).call(this,e,Wr)),a.push(u(this,t,"m",s).call(this,e,Lr))}return 1===a.length?a[0]:a},s=function(e,t){return function({projectId:e,filename:t,assetsFolder:i="v2-beta",baseUrl:n=Wr}){const o=new URL(n);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,i,t),o.baseUrl=n,o}({projectId:this.projectId,filename:e,baseUrl:t})},a})),Jr=Rn((e=>{var t,i;const n=bn(Br({"project-id":_r}))(e);return i=class extends n{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,i){if(u(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return u(this,t,"f").set(e,i),()=>{u(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(u(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var i;if(!u(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(i=u(this,t,"f").get(e))||void 0===i?void 0:i()})))}},t=new WeakMap,i})),Zr=Rn((e=>{var t,i,n,o,r;const s=bn(Gr,Jr,Fr)(e);return r=class extends s{constructor(){super(...arguments),t.add(this),n.set(this,void 0),o.set(this,(async()=>{try{const{body:e,headers:t}=await 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")}}))}async init(){await super.init(),this.onReset("config",u(this,t,"m",i).bind(this))}get config(){return u(this,n,"f")||h(this,n,u(this,o,"f").call(this),"f"),u(this,n,"f")}},n=new WeakMap,o=new WeakMap,t=new WeakSet,i=function(){h(this,n,void 0,"f")},r})),Yr=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],Xr=e=>{let t=0;const i=e.toString();for(let e=0;e<i.length;e++){t=(t<<5)-t+i.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},Qr=(e,t,i)=>new Promise(((n,o)=>{const r=((e,t)=>{const i=document.createElement("script");return i.id=e,t&&(i.integrity=t,i.crossOrigin="anonymous"),window.DESCOPE_NONCE&&i.setAttribute("nonce",window.DESCOPE_NONCE),i})(e,i);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),n(r)},r.src=t.toString(),document.body.appendChild(r)})),es=(e,t)=>{if(t){const i=e.integrity;if(i!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${i}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,i)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{i(e)}))}))},ts=Rn((e=>{const t=bn(Ur)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,i="",n=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const n of e){const{id:e,url:o,integrity:r}=n,s=(i=e,document.querySelector(`script#${i}`));if(s)try{return await es(s,r),n}catch(e){t(n,!0)}else try{return await Qr(e,o,r),n}catch(e){t(n,!1)}}var i;throw new Error("All scripts failed to load")})(((e,t,i,n="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${i}/${n}`);const d={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${Xr(a)}`};return o&&(d.integrity=o),[...e,d]}),[]))([...n,this.baseCdnUrl,...Yr],e,t,i,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),is="base.ui.components.url",ns=Tr&&localStorage.getItem(is),os=Rn((e=>{var t,i,n,o,r,s,a;const d=bn(Ur,Zr,ts)(e);return a=class extends d{constructor(){super(...arguments),t.add(this),o.set(this,void 0)}get descopeUi(){return u(this,o,"f")||h(this,o,u(this,t,"m",s).call(this),"f"),u(this,o,"f")}async loadDescopeUiComponents(e){const i=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(i.map((e=>u(this,t,"m",r).call(this,e))))}},o=new WeakMap,t=new WeakSet,i=async function(){var e;const t=await this.config,i=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return i?this.logger.debug(`Got component version "${i}"`):this.logger.error("Could not get components version"),i},n=async function(){var e;const t=await this.config,i=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return i&&this.logger.debug("SRI hash available for components"),i},r=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await 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(", ")}"`)},s=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await u(this,t,"m",i).call(this),o=await u(this,t,"m",n).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[ns],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},a})),rs=Rn((e=>{var t,i,n;const o=bn(Fr,qr)(e);return n=class extends o{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",u(this,t,"m",i).bind(this)),u(this,t,"m",i).call(this)}},t=new WeakSet,i=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},n}));class ss{constructor(e,t,{prepend:i=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(i?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const as=Rn((e=>{const t=bn(rs)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let i;try{i=new CSSStyleSheet}catch(e){i=new ss(this.shadowRoot,this.nonce,{prepend:t})}if(e&&i.replaceSync(e),i instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const n=[...e.adoptedStyleSheets||[]];n[t?"unshift":"push"](i),e.adoptedStyleSheets=n}}return i}}})),ds="content-root",ls="root",cs=Rn((e=>{const t=bn(as)(e);return class extends t{constructor(...e){var t,i;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${ls}">\n <div id="${ds}"></div>\n </div>\n `,this.injectStyle(`\n #${ls}, #${ds} {\n height: 100%;\n }\n #${ls} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(ds),this.rootElement=null===(i=this.shadowRoot)||void 0===i?void 0:i.getElementById(ls)}}})),us="theme",hs=(e,t,i="")=>Object.entries(e).reduce(((e,[n,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(n))return t("Ignoring invalid override-css token path segment"),e;const r=i?`${i}-${n}`:n;if("object"==typeof o&&null!==o)return e+hs(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),"");function fs(e,t){const i=Object.assign({},e);for(const[e,n]of Object.entries(t||{}))if(null!=n)if("object"==typeof n){if(0===Object.keys(n).length)continue;i[e]=fs(i[e]||{},n)}else i[e]="string"==typeof n?(i[e]||"")+n:n;return i}const ps=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",gs=Rn((e=>{const t=bn(Br({tenant:ps}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),vs=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ms=Rn((e=>{var t,i,n,o,r,s,a,d,l,c,f,p,g,v,m,y,b,$,w,C,k,S;const I=bn(Br({theme:vs}),gs,Gr,Fr,os,Zr,cs,qr,as)(e);return S=class extends I{constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),s.set(this,void 0),a.set(this,void 0),w.set(this,(()=>{u(this,t,"m",C).call(this),u(this,k,"f").call(this,"os"===this.getAttribute("theme"))})),k.set(this,(e=>{var i,n,o;const r=e?"addEventListener":"removeEventListener";null===(o=null===(n=null===(i=window.matchMedia)||void 0===i?void 0:i.call(window,"(prefers-color-scheme: dark)"))||void 0===n?void 0:n[r])||void 0===o||o.call(n,"change",(()=>u(this,t,"m",C).call(this)))}))}get theme(){var e,t;const i=this.getAttribute("theme");if("os"===i){return 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"}return i||"light"}get styleId(){return this.getAttribute("style-id")||us}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),u(this,w,"f").call(this),await Promise.all([u(this,t,"m",c).call(this),u(this,t,"m",g).call(this),u(this,t,"m",m).call(this)]),u(this,t,"m",v).call(this),this.observeAttributes(["theme"],u(this,w,"f")),this.observeAttributes(["theme-override"],(()=>u(this,t,"m",v).call(this))),this.observeAttributes(["tenant"],(()=>{h(this,a,null,"f"),u(this,t,"m",g).call(this),u(this,t,"m",m).call(this)})),this.observeAttributes(["style-id"],(()=>{h(this,s,null,"f"),u(this,t,"m",b).call(this),u(this,t,"m",c).call(this),u(this,t,"m",m).call(this)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,s=new WeakMap,a=new WeakMap,w=new WeakMap,k=new WeakMap,t=new WeakSet,r=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var i,n,o,r,s,a;const d=null===(o=null===(n=null===(i=e[t])||void 0===i?void 0:i.globals)||void 0===n?void 0:n.colors)||void 0===o?void 0:o.primary,l=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return d||l?`[data-theme="${t}"]{${hs({colors:{primary:d,secondary:l}},(e=>this.logger.error(e)))}}`:""})).join(""):""},d=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if("development"===process.env.NODE_ENV&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(is)))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(is),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const i=document.createElement("script");if(i.src=t,document.body.appendChild(i),await new Promise(((e,t)=>{i.onload=e,i.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:i}=globalThis.DescopeDev;return{light:e(t),dark:e(i)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},l=function(){return u(this,s,"f")||(h(this,s,u(this,t,"m",d).call(this),"f"),u(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),u(this,s,"f")},c=async function(){var e,n;const o=await u(this,t,"a",l);if(!o)return;const r=((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)||"");u(this,i,"f")?u(this,i,"f").replaceSync(r):h(this,i,this.injectStyle(r,{prepend:!0}),"f")},f=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.error("Cannot fetch tenant theme file","make sure that your tenantId, projectId & flowId are correct")}},p=function(){return u(this,a,"f")||h(this,a,u(this,t,"m",f).call(this),"f"),u(this,a,"f")},g=async function(){var e,i,o,r;if(!this.tenantId)return void(null===(e=u(this,n,"f"))||void 0===e||e.replaceSync(""));const s=await u(this,t,"a",p);if(!s)return void(null===(i=u(this,n,"f"))||void 0===i||i.replaceSync(""));const a=((null===(o=s.light)||void 0===o?void 0:o.globals)||"")+((null===(r=s.dark)||void 0===r?void 0:r.globals)||"");u(this,n,"f")?u(this,n,"f").replaceSync(a):h(this,n,this.injectStyle(a),"f")},v=async function(){var e;if(!this.themeOverride)return void(null===(e=u(this,o,"f"))||void 0===e||e.replaceSync(""));const i=u(this,t,"m",r).call(this);u(this,o,"f")?u(this,o,"f").replaceSync(i):h(this,o,this.injectStyle(i),"f")},m=async function(){var e,i,n,o;const r=await u(this,t,"a",l);if(!r)return;const s=await this.descopeUi;if(!(null==s?void 0:s.componentsThemeManager))return;const a=await u(this,t,"a",p);s.componentsThemeManager.themes={light:fs((null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.components)||{},(null===(i=null==a?void 0:a.light)||void 0===i?void 0:i.components)||{}),dark:fs((null===(n=null==r?void 0:r.dark)||void 0===n?void 0:n.components)||{},(null===(o=null==a?void 0:a.dark)||void 0===o?void 0:o.components)||{})}},y=async function(){var e,t;const{projectConfig:i}=await this.config||{},n=null===(e=null==i?void 0:i.styles)||void 0===e?void 0:e[this.styleId],o=null==i?void 0:i.cssTemplate,r=n||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},b=async function(){const e=await u(this,t,"m",y).call(this);e?Object.values(e).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))})):this.logger.debug("No fonts to load")},$=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},C=function(){u(this,t,"m",b).call(this),u(this,t,"m",$).call(this)},S})),ys=(e,t="")=>Object.keys(e).reduce(((i,n)=>{var o;if(Array.isArray(e[n]))return Object.assign(Object.assign({},i),{[n]:{value:e[n].map((e=>"object"==typeof e&&null!==e?ys(e):e))}});if("object"==typeof e[n]&&null!==e[n]&&!(null===(o=e[n])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},i),ys(e[n],`${t+n}.`));const r="object"==typeof e[n]?e[n]:{value:e[n]},s=Object.assign(Object.assign({},i),{[t+n]:r,[`form.${t}${n}`]:r});return"displayName"===n?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),bs=Rn((e=>{var t,i,n,o;return o=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;u(this,t,"m",i).call(this)&&u(this,t,"m",n).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,i=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},n=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},o}));var $s,ws,Cs,ks,Ss,Is,Rs,xs,Os,Es,As,Ns,js,Ms,Ps,Us,Ts,Ws,Ls,Ds,_s,Fs;const qs=bn(ms,Gr,bs,as)(HTMLElement);let Bs=class extends qs{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),$s.add(this),Cs.set(this,!1),ks.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),u(this,$s,"m",Fs).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",i={})=>{this.logger.info(e,t,i)},debug:(e,t="")=>{this.logger.debug(e,t)}},Ss.set(this,new fr),Is.set(this,new fr),Rs.set(this,{}),this.getComponentsContext=()=>u(this,Rs,"f"),this.nextRequestStatus=new fr({isLoading:!1}),xs.set(this,void 0),Os.set(this,{popstate:u(this,$s,"m",Ms).bind(this),componentsContext:u(this,$s,"m",Ls).bind(this)}),Es.set(this,void 0),this.getConfig=()=>c(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),h(this,Es,e,"f"),u(this,$s,"m",Ns).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}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 autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return ys(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,i])=>[e,i[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return u(this,ks,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");h(this,ks,e,"f"),(e=>{Sr=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return c(this,void 0,void 0,(function*(){var e,t;const i=yield this.getProjectConfig(),n=(null===(e=null==i?void 0:i.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=n.version)&&void 0!==t||(n.version=0),n}))}getTargetLocales(){return c(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,i,n;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=_o.includes(null!==(n=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==n?n:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const d=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===d.length)"false"!==d[0].getAttribute("auto-submit")&&d[0].click();else if(0===d.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return c(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),u(this,Is,"f").subscribe(u(this,$s,"m",_s).bind(this)),u(this,Is,"f").update({isDebug:this.debug}),u(this,$s,"m",js).call(this),yield u(this,$s,"m",Ts).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");const i=yield this.getConfig();if("isMissingConfig"in i&&i.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:n,stepId:o,token:r,code:s,isPopup:a,exchangeError:d,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:f,redirectAuthInitiator:p,ssoQueryParams:g}=Yo(this.flowId,this.loggerWrapper);window.addEventListener("popstate",u(this,Os,"f").popstate),window.addEventListener("components-context",u(this,Os,"f").componentsContext),u(this,Ss,"f").subscribe(u(this,$s,"m",Us).bind(this)),u(this,Ss,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:n,token:r,code:s,isPopup:a,exchangeError:d,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:f,redirectAuthInitiator:p},g)),h(this,Cs,!0,"f")}))}disconnectedCallback(){u(this,Ss,"f").unsubscribeAll(),u(this,Is,"f").unsubscribeAll(),u(this,$s,"m",Ds).call(this),window.removeEventListener("popstate",u(this,Os,"f").popstate),window.removeEventListener("components-context",u(this,Os,"f").componentsContext)}attributeChangedCallback(e,t,i){if(this.shadowRoot.isConnected&&u(this,Cs,"f")&&t!==i&&ws.observedAttributes.includes(e)){u(this,$s,"m",js).call(this);const n=null===t;u(this,Ss,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return n||(s=null,r=null,Jo()),{[Zo(e)]:i,stepId:r,executionId:s}})),u(this,Is,"f").update({isDebug:this.debug})}}};var Vs,Ks,Hs,zs,Gs,Js,Zs,Ys,Xs,Qs,ea,ta,ia,na,oa,ra,sa,aa,da,la,ca,ua,ha,fa,pa,ga,va,ma,ya,ba,$a,wa,Ca,ka,Sa,Ia,Ra,xa,Oa,Ea;ws=Bs,Cs=new WeakMap,ks=new WeakMap,Ss=new WeakMap,Is=new WeakMap,Rs=new WeakMap,xs=new WeakMap,Os=new WeakMap,Es=new WeakMap,$s=new WeakSet,As=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},Ns=function(){u(this,$s,"m",As).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},js=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes","theme-override"];ws.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Zo(t)])throw Error(`${t} cannot be empty`)}))},Ms=function(){const{stepId:e,executionId:t}=Go(this.flowId);u(this,Ss,"f").update({stepId:e,executionId:t})},Ps=function(e,t){cn&&"function"==typeof cn||this.logger.error("SDK was not loaded properly",cn,JSON.stringify(cn));const i=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},ws.sdkConfigOverrides),{projectId:e,baseUrl:t});u(this,ks,"f")&&(i.customStorage=u(this,ks,"f")),this.sdk=cn(i),["start","next"].forEach((e=>{const t=function(e,t,i){return(...n)=>c(this,void 0,void 0,(function*(){let o;const r=i+1;for(let s=0;s<r;s++)try{return yield e(...n)}catch(e){o=e,s<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw o}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...i)=>c(this,void 0,void 0,(function*(){try{return yield t(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:ro,errorDescription:t.toString()}}}}))}))},Us=function(e,t,i){return c(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;u(this,$s,"m",Ps).call(this,t,n)}u(this,Es,"f").call(this,e)}))},Ts=function(){return c(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield u(this,$s,"m",Ws).call(this))}))},Ws=function(){return c(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:i="v2-beta",baseUrl:n}){const o=new URL(ao||n||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,i,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return c(this,void 0,void 0,(function*(){const i=yield fetch(e,{cache:"default"});if(!i.ok)throw Error(`Error fetching URL ${e} [${i.status}]`);return{body:yield i[t](),headers:Object.fromEntries(i.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Ls=function(e){h(this,Rs,Object.assign(Object.assign({},u(this,Rs,"f")),e.detail),"f")},Ds=function(){var e;null===(e=u(this,xs,"f"))||void 0===e||e.remove(),h(this,xs,null,"f")},_s=function(e){return c(this,arguments,void 0,(function*({isDebug:e}){e?(h(this,xs,document.createElement("descope-debugger"),"f"),Object.assign(u(this,xs,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return EC})),document.body.appendChild(u(this,xs,"f"))):u(this,$s,"m",Ds).call(this)}))},Fs=function(e,t){var i;e&&this.debug&&(null===(i=u(this,xs,"f"))||void 0===i||i.updateData({title:e,description:t}))},Bs.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.66.1"}};let Aa=class extends Bs{static set sdkConfigOverrides(e){Bs.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Bs.sdkConfigOverrides}constructor(){const e=new fr({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),Vs.add(this),this.stepState=new fr({}),Ks.set(this,void 0),Hs.set(this,null),zs.set(this,null),Gs.set(this,{visibilitychange:u(this,Vs,"m",Js).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},na.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},ra.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?u(this,Vs,"m",sa).call(this,t):t()})),aa.set(this,((e,t,i,n,o=!1)=>{const r=[so,"E103202"];if(this.flowState.current.action===Mo){if(u(this,la,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const s=Date.now(),a=o?500:2e3;h(this,Ks,setTimeout((()=>c(this,void 0,void 0,(function*(){var d,l;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,t,Do,i,n,{}),h=document.hidden&&!o&&Date.now()-s>a+500;let f;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;f=yield er(e,c)}catch(d){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void u(this,aa,"f").call(this,e,t,i,n,h)}if((null===(d=null==f?void 0:f.error)||void 0===d?void 0:d.errorCode)===ro)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void u(this,aa,"f").call(this,e,t,i,n);this.logger.debug("polling - Got a response"),(null==f?void 0:f.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(f.error,null,4)),(null===(l=null==f?void 0:f.error)||void 0===l?void 0:l.errorCode)&&r.includes(f.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):u(this,aa,"f").call(this,e,t,i,n),u(this,ca,"f").call(this,f)}))),a),"f")}})),da.set(this,(()=>{clearTimeout(u(this,Ks,"f")),h(this,Ks,null,"f")})),la.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),ca.set(this,(e=>{var t,i,n,o,r,s,a,d,l,c,f,p,g;if(!(null==e?void 0:e.ok)){const a=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,d=`${null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.status} - ${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.statusText}`;u(this,Vs,"m",Oa).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:d,errorMessage:a}),this.loggerWrapper.error((null===(o=null==e?void 0:e.error)||void 0===o?void 0:o.errorDescription)||a,(null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorMessage)||d);const l=null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorCode;return void("E102004"!==l&&l!==so||!this.isRestartOnError||u(this,Vs,"m",ia).call(this))}null===(d=null===(a=e.data)||void 0===a?void 0:a.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:i,log:n}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,n):this.loggerWrapper.info(i,n)}));const v=null===(f=null===(c=null===(l=e.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===f?void 0:f.errorText;(null===(p=e.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:y,lastAuth:b,action:$,openInNewTabUrl:w}=e.data;if($!==Mo&&u(this,da,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Ar(Object.assign(Object.assign({},b),{lastUsedPerScreen:Nr()})),jr(this.loggerWrapper);const t=Object.assign({},y);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void u(this,Vs,"m",Oa).call(this,"success",t)}this.storeLastAuthenticatedUser&&Ar(b,!0),w&&window.open(w,"_blank");const{executionId:C,stepId:k,stepName:S,screen:I,redirect:R,webauthn:x,error:O,samlIdpResponse:E,wsFedIdpResponse:A,nativeResponse:N}=e.data,j=Date.now();$!==Mo?(this.loggerWrapper.info(`Step "${S||`#${k}`}" is ${m}`,"",{screen:I,status:m,stepId:k,stepName:S,action:$,error:O}),(null===(g=I.state)||void 0===g?void 0:g.clientScripts)&&h(this,zs,this.loadSdkScripts(I.state.clientScripts),"f"),this.flowState.update({stepId:k,stepName:S,executionId:C,action:$,redirectTo:null==R?void 0:R.url,redirectIsPopup:null==R?void 0:R.isPopup,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,wsFedIdpResponseUrl:null==A?void 0:A.url,wsFedIdpResponseWresult:null==A?void 0:A.wresult,wsFedIdpResponseWctx:null==A?void 0:A.wctx,nativeResponseType:null==N?void 0:N.type,nativePayload:null==N?void 0:N.payload,reqTimestamp:j})):this.flowState.update({action:$,reqTimestamp:j})})),ua.set(this,Xo((()=>c(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)}}))))),ma.set(this,null),Ca.set(this,or(((e,t,i)=>c(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||u(this,Vs,"m",ga).call(this)){const o=null==e?void 0:e.getAttribute("id");u(this,Vs,"m",Ia).call(this,e,o,i),u(this,Vs,"m",ya).call(this,e);const r=yield u(this,Vs,"m",va).call(this),s=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var i;const n=null===(i=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===i?void 0:i[1];return n?Object.assign(e,{[n]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const a=Object.assign(Object.assign(Object.assign({},s),r),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(o,a),this.nextRequestStatus.update({isLoading:!1}),u(this,Vs,"m",ba).call(this,r)}}))))),this.flowState=e}nativeResume(e,t){var i,n,o,r,s,a;const d=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=d;if(!t){const o=new URL(d.url);t=null===(i=o.searchParams)||void 0===i?void 0:i.get(uo),e=(null===(n=o.searchParams)||void 0===n?void 0:n.get(fo))||void 0}null===(r=(o=this.nativeCallbacks).complete)||void 0===r||r.call(o,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(d.url),t=e.searchParams.get("t"),i=e.searchParams.get(co).split("_").pop();u(this,da,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=d;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=d,{screenNext:i}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==i||i(e,t)}else null===(a=(s=this.nativeCallbacks).complete)||void 0===a||a.call(s,d)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>i=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[ar(e.id,e.resultKey)]:i},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>c(this,void 0,void 0,(function*(){var i,n,o;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}(null===(n=globalThis.descope)||void 0===n?void 0:n[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.16",`dist/${e.id}.js`));const s=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((i,n)=>{try{const n=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,i),this.loggerWrapper);if(n){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=n,this.shadowRoot.appendChild(t);const i=this.nextRequestStatus.subscribe((()=>{var o;this.loggerWrapper.debug("Stopping script",e.id),(null===(o=n.stop)||void 0===o?void 0:o.call(n))&&(this.nextRequestStatus.unsubscribe(i),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){n(e)}}))}))))),n=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,n])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t,i;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),u(this,Vs,"m",ea).call(this),window.addEventListener("visibilitychange",u(this,Gs,"f").visibilitychange)),yield null===(i=e.init)||void 0===i?void 0:i.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),u(this,da,"f").call(this),null===(e=u(this,Hs,"f"))||void 0===e||e.abort(),h(this,Hs,null,"f"),window.removeEventListener("visibilitychange",u(this,Gs,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return c(this,void 0,void 0,(function*(){let i;const n=rr(e),o=yield this.getTargetLocales();return o.includes(n.locale)?i=`${t}-${n.locale}.html`:o.includes(n.fallback)&&(i=`${t}-${n.fallback}.html`),i}))}getPageContent(e,t){return c(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,t,i){return c(this,void 0,void 0,(function*(){var n,o;const{projectId:r,flowId:s,tenant:a,stepId:d,executionId:f,action:p,screenId:g,screenState:v,redirectTo:m,redirectIsPopup:y,redirectUrl:b,token:$,code:w,isPopup:C,exchangeError:k,webauthnTransactionId:S,webauthnOptions:I,redirectAuthCodeChallenge:R,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:O,redirectAuthInitiator:E,locale:A,samlIdpResponseUrl:N,samlIdpResponseSamlResponse:j,samlIdpResponseRelayState:M,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:U,wsFedIdpResponseWctx:T,nativeResponseType:W,nativePayload:L,reqTimestamp:D}=e,_=l(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let F,q,B;const V=(()=>{const e=Rr(xr);if(!e){const e=Math.floor(100*Math.random()+1);return Ir(xr,e.toString()),e}return Number(e)})(),{outboundAppId:K}=this,{outboundAppScopes:H}=this,z=this.sdk.getLastUserLoginId(),G=yield this.getFlowConfig(),J=yield this.getProjectConfig(),Z=Object.entries(J.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),Y=x&&R?{callbackUrl:x,codeChallenge:R,backupCallbackUri:O}:void 0,X=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let Q={};if(!f){jr(this.loggerWrapper);const e=[...G.clientScripts||[],...G.sdkScripts||[]];if(G.conditions){let t=[];({startScreenId:F,conditionInteractionId:B,startScreenName:q,clientScripts:t,componentsConfig:Q}=((e,t)=>{const i=null==t?void 0:t.find((({key:t,operator:i,predicate:n})=>{var o;if("ELSE"===t)return!0;const r=null===(o=Or[t])||void 0===o?void 0:o[i];return!!(null==r?void 0:r(e,n))}));return i?{startScreenId:i.met.screenId,startScreenName:i.met.screenName,conditionInteractionId:i.met.interactionId,clientScripts:i.met.clientScripts,componentsConfig:i.met.componentsConfig}:{}})({loginId:z,code:w,token:$,abTestingKey:V,lastAuth:Er(z,this.loggerWrapper)},G.conditions)),e.push(...t||[])}else G.condition?({startScreenId:F,conditionInteractionId:B}=((e,t)=>{var i;const n=null===(i=Or[null==e?void 0:e.key])||void 0===i?void 0:i[e.operator];if(!n)return{};const o=n(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(G.condition,{loginId:z,code:w,token:$,abTestingKey:V,lastAuth:Er(z,this.loggerWrapper)})):(q=G.startScreenName,F=G.startScreenId);if(h(this,zs,this.loadSdkScripts(e),"f"),G.fingerprintEnabled&&G.fingerprintKey?yield xi(G.fingerprintKey,this.baseUrl):ri(Ii),!tr(F,_)){const e=yield this.sdk.flow.start(s,Object.assign(Object.assign(Object.assign(Object.assign({tenant:a,redirectAuth:Y},_),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:Er(z,this.loggerWrapper),abTestingKey:V,locale:rr(A).locale,nativeOptions:X,outboundAppId:K,outboundAppScopes:H}),B,"",J.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),w?{exchangeCode:w,idpInitiated:!0}:{}),_.descopeIdpInitiated&&{idpInitiated:!0}),$?{token:$}:{}),_.oidcLoginHint?{externalId:_.oidcLoginHint}:{}));return u(this,ca,"f").call(this,e),void("completed"!==(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:C,code:w,exchangeError:k,isCodeChanged:i("code"),isExchangeErrorChanged:i("exchangeError")})),C&&(i("code")&&w||i("exchangeError")&&k))return void u(this,Vs,"m",Ea).call(this,f,w,k);if(f&&(i("token")&&$||i("code")&&w||i("exchangeError")&&k)){const e=yield this.sdk.flow.next(f,d,Lo,G.version,J.componentsVersion,{token:$,exchangeCode:w,exchangeError:k});return u(this,ca,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===Wo&&N&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>i(e)))){if(!j)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,i,n)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${i}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),n(o)})(N,j,M||"",ir)}if(p===Wo&&P&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>i(e)))){if(!U)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,i,n)=>{const o=document.createElement("form");o.method="POST",o.action=e;const r=(e,t)=>{const i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,i};o.appendChild(r("wa","wsignin1.0")),o.appendChild(r("wresult",t)),o.appendChild(r("wctx",i));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",o.appendChild(s),document.body.appendChild(o),n(o)})(P,U,T||"",ir)}if(p===jo&&(i("redirectTo")||i("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===m)return;if("android"===E&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${y}`),y){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,i,n)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-i)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-n)/2+r,d=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),i=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&i}()?"about:blank":"",l=window.open(d,t,`width=${i},height=${n},top=${a},left=${s},scrollbars=yes,resizable=yes`);return l.location.href=e,l.focus(),l})(m,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));const i=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const i=t?this.popupOrigin:window.location.origin;if(e.origin!==i)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${i}"`);const{action:n,data:o}=e.data||{};"code"===n&&this.flowState.update({code:o.code,exchangeError:o.exchangeError})};let n;this.loggerWrapper.debug("Starting popup closed detection");const o=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(o),u(this,Vs,"m",Oa).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==n||n())}),1e3);if(t)window.addEventListener("message",i),n=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",i)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(f);e.onmessage=i,n=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(m),this.flowState.update({redirectTo:"no-op"}),u(this,Vs,"m",Oa).call(this,"popupclosed",{});return}if(p===Po||p===Uo){if(!S||!I)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(o=u(this,Hs,"f"))||void 0===o||o.abort(),h(this,Hs,null,"f");try{e=p===Po?yield this.sdk.webauthn.helpers.create(I):yield this.sdk.webauthn.helpers.get(I)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const i=yield this.sdk.flow.next(f,d,Lo,G.version,J.componentsVersion,{transactionId:S,response:e,failure:t});u(this,ca,"f").call(this,i)}if(p===To)return this.nativeCallbacks.complete=e=>c(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(f,d,Lo,G.version,J.componentsVersion,e);u(this,ca,"f").call(this,t)})),u(this,Vs,"m",Xs).call(this,W,L),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((i("action")||i("deferredPolling"))&&u(this,aa,"f").call(this,f,d,G.version,J.componentsVersion),!g&&!F)return void this.loggerWrapper.warn("No screen was found to show");const ee=F||g,te=yield this.getHtmlFilenameWithLocale(A,ee),{oidcLoginHint:ie,oidcPrompt:ne,oidcErrorRedirectUri:oe,oidcResource:re,samlIdpUsername:se}=_,ae={direction:zo(d,t.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:z,name:this.sdk.getLastUserDisplayName()||z},componentsConfig:Object.assign(Object.assign(Object.assign({},G.componentsConfig),Q),null==v?void 0:v.componentsConfig)}),htmlFilename:`${ee}.html`,htmlLocaleFilename:te,screenId:ee,stepName:e.stepName||q,samlIdpUsername:se,oidcLoginHint:ie,oidcPrompt:ne,oidcErrorRedirectUri:oe,oidcResource:re,action:p,locale:rr(A).locale},de=Er(z,this.loggerWrapper);tr(F,_)?ae.next=(e,t)=>c(this,void 0,void 0,(function*(){const i=(null==G?void 0:G.clientScripts)||[];yield u(this,Vs,"m",ka).call(this,i);const n=yield this.sdk.flow.start(s,Object.assign(Object.assign(Object.assign(Object.assign({tenant:a,redirectAuth:Y},_),{lastAuth:de,preview:this.preview,abTestingKey:V,client:this.client}),b&&{redirectUrl:b}),{locale:rr(A).locale,nativeOptions:X,outboundAppId:K,outboundAppScopes:H}),B,e,J.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),sr(t)),w&&{exchangeCode:w,idpInitiated:!0}),_.descopeIdpInitiated&&{idpInitiated:!0}),$&&{token:$}),ae.next.isCustomScreen);return u(this,ca,"f").call(this,n),n})):(i("projectId")||i("baseUrl")||i("executionId")||i("stepId"))&&(ae.next=(e,t)=>c(this,void 0,void 0,(function*(){const i=(null==v?void 0:v.clientScripts)||[];yield u(this,Vs,"m",ka).call(this,i);const n=yield this.sdk.flow.next(f,d,e,G.version,J.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),sr(t)),ae.next.isCustomScreen);return u(this,ca,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",ae.screenId),yield u(this,Vs,"m",oa).call(this,ae),this.stepState.update(ae)}))}onStepChange(e,t){return c(this,void 0,void 0,(function*(){var i,n,o;const{htmlFilename:r,htmlLocaleFilename:s,direction:a,next:d,screenState:l,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen");const f=document.createElement("template");f.innerHTML=yield this.getPageContent(r,s);const p=f.content.cloneNode(!0),g=this.loadDescopeUiComponents(f);this.sdk.webauthn.helpers.isSupported()?yield u(this,Vs,"m",fa).call(this,p,d):(e=>{e.querySelectorAll(`descope-button[${No}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(p),!e.samlIdpUsername||(null===(i=l.form)||void 0===i?void 0:i.loginId)||(null===(n=l.form)||void 0===n?void 0:n.email)||(l.form||(l.form={}),l.form.loginId=e.samlIdpUsername,l.form.email=e.samlIdpUsername),Cr(p,l,this.formConfig,this.loggerWrapper);const{geo:v}=null!==(o=yield this.getExecutionContext())&&void 0!==o?o:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([i,n])=>{Array.from(e.querySelectorAll(`[${i}="${n}"]`)).forEach((e=>{e.setAttribute(i,t||n)}))}))})(p,v),((e,t)=>{let i=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(i=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`[${t}="${n}"]`)).forEach((e=>{e.setAttribute(t,i||n)}))}))})(p,e.locale);const m=()=>c(this,void 0,void 0,(function*(){var i,n;yield g;const o=this.contentRootElement;((e,t)=>{wr(e,"descope-totp-image",t)})(o,null===(i=null==l?void 0:l.totp)||void 0===i?void 0:i.image),((e,t)=>{wr(e,"descope-notp-image",t)})(o,null===(n=null==l?void 0:l.notp)||void 0===n?void 0:n.image),((e,t,i,n)=>{i&&Object.keys(i).forEach((o=>{if(!t.querySelector(o))return void n.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(i[o]).forEach((t=>{var s;const a=i[o],d=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!d)return void n.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const l=a[t];e.style.setProperty(d,l)})):n.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(o,p,l.cssVars,this.loggerWrapper),o.replaceChildren(p);const r=!t.htmlFilename;setTimeout((()=>{u(this,Vs,"m",$a).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var i;const n=()=>{var e;const i=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=i}))};if("true"===t.getAttribute("invalid")||(null===(i=t.value)||void 0===i?void 0:i.length))return void n();const o={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",r),n(),o.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(o),((e,t)=>{mr(e,null==t?void 0:t.inputs),mr(e,null==t?void 0:t.form)})(o,l),u(this,Vs,"m",pa).call(this,{isFirstScreen:r,isCustomScreen:!1,stepName:e.stepName}),Qo(o,this.autoFocus,r),u(this,Vs,"m",Ra).call(this,h)})),u(this,Vs,"m",xa).call(this,d,h),o.querySelector(`[${No}="polling"]`)&&d(Do,{})}));a?u(this,Vs,"m",sa).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${po}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}};Ks=new WeakMap,Hs=new WeakMap,zs=new WeakMap,Gs=new WeakMap,na=new WeakMap,ra=new WeakMap,aa=new WeakMap,da=new WeakMap,la=new WeakMap,ca=new WeakMap,ua=new WeakMap,ma=new WeakMap,Ca=new WeakMap,Vs=new WeakSet,Js=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},Zs=function(e,t,i){return c(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=i,this.nativeCallbacks.screenResolve=n,u(this,Vs,"m",Xs).call(this,"beforeScreen",{screen:e,context:t})}))}))},Ys=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&u(this,Vs,"m",Xs).call(this,"afterScreen",{screen:e})},Xs=function(e,t){u(this,Vs,"m",Oa).call(this,"bridge",{type:e,payload:t})},Qs=function({errorText:e,errorType:t}){const i=()=>{var i;let n=e;try{n=(null===(i=this.errorTransformer)||void 0===i?void 0:i.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,i="")=>{e.querySelectorAll(`[${No}="${t}"]`).forEach((e=>{e.textContent=i,e.classList[i?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",n)};this.addEventListener("screen-updated",i,{once:!0}),i()},ea=function(){var e,t,i;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var t=e.screenState,i=l(void 0===t?{}:t,["errorText","errorType"]),n=l(e,["screenState"]);return Object.assign(Object.assign({},n),{screenState:i})})),null===(t=this.stepState)||void 0===t||t.subscribe(u(this,Vs,"m",Qs).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0}),null===(i=this.stepState)||void 0===i||i.subscribe(u(this,Vs,"m",ta).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0})},ta=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Qo(this.contentRootElement,this.autoFocus,!1))},ia=function(){return c(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},oa=function(e){return c(this,void 0,void 0,(function*(){var t;const i=Object.assign(Object.assign({},this.stepState.current),e),{next:n,stepName:o}=i,r=(e=>{var t,i,n;const o=(r=e.screenState,s=(e,t)=>qo.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(0,e)))));var r,s;const{screenState:{errorText:a,errorType:d}}=e;return(a||d)&&(o.error={text:a,type:d}),e.action&&(o.action=e.action),(null===(n=null===(i=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===i?void 0:i.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data)&&(o.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o})(l(i,["next","stepName"]));let s=yield u(this,Vs,"m",Zs).call(this,o,r,n);s||(s=Boolean(yield null===(t=this.onScreenUpdate)||void 0===t?void 0:t.call(this,o,r,n,this)));const a=!this.stepState.current.htmlFilename;if(u(this,ra,"f").call(this,s),n&&(n.isCustomScreen=s),u(this,na,"f")!==s){const[e,t]=["flow","custom"].sort((()=>s?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),h(this,na,s,"f"),s?this.stepState.unsubscribeAll():u(this,Vs,"m",ea).call(this)}s?(this.loggerWrapper.debug("Showing a custom screen"),u(this,Vs,"m",pa).call(this,{isFirstScreen:a,isCustomScreen:s,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=s}))},sa=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},ha=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},fa=function(e,t){return c(this,void 0,void 0,(function*(){var i;null===(i=u(this,Hs,"f"))||void 0===i||i.abort();const n=e.querySelector('*[autocomplete="webauthn"]');if(n&&(yield kr())){const{options:e,transactionId:i}=(yield u(this,ua,"f").call(this))||{};e&&i&&(u(this,Vs,"m",ha).call(this,n),h(this,Hs,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,u(this,Hs,"f")).then((e=>c(this,void 0,void 0,(function*(){t(n.id,{transactionId:i,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},pa=function({isFirstScreen:e,isCustomScreen:t,stepName:i}){e&&u(this,Vs,"m",Oa).call(this,"ready",{}),t||u(this,Vs,"m",Ys).call(this,i),u(this,Vs,"m",Oa).call(this,"page-updated",{screenName:i}),u(this,Vs,"m",Oa).call(this,"screen-updated",{screenName:i})},ga=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,n;"slot"===t.localName||t.classList.contains("hidden")||(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(n=t.checkValidity)||void 0===n?void 0:n.call(t)))})),e},va=function(){return c(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>c(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})),{})}))},ya=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),i=()=>c(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",i),e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}));const n=yield this.getFlowConfig(),o=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(o)})),n=()=>{var e;window.removeEventListener("pageshow",u(this,ma,"f")),h(this,ma,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),i())}),"f"),window.addEventListener("pageshow",u(this,ma,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&i(),this.removeEventListener("popupclosed",i),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},o=this.nextRequestStatus.subscribe((({isLoading:r})=>{r?(this.addEventListener("popupclosed",i,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(o),n())}))},ba=function(e={}){var t,i;const n=nr(e,["externalId","email","phone"]),o=nr(e,["newPassword","password"]);if(n&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:n,password:o});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},$a=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>u(this,Vs,"m",wa).call(this,e)))},wa=function(e){e&&e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),n=`input-${e.id}-${i}`,o=document.createElement("slot");o.setAttribute("name",n),o.setAttribute("slot",i),e.appendChild(o),t.setAttribute("slot",n),this.appendChild(t)}))},ka=function(e){return c(this,void 0,void 0,(function*(){if(u(this,zs,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield u(this,zs,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),i=e.map((e=>e.id));for(const e of t)if(i.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const n=[];for(const e of t)"function"==typeof e.refresh&&n.push(e.refresh());if(n.length>0)try{yield er(5e3,Promise.all(n),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Sa=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var n;(null===(n=i.checkValidity)||void 0===n?void 0:n.call(i))&&u(this,Ca,"f").call(this,i,e,t)}))}))},Ia=function(e,t,i){t&&i&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,i){try{const i=Nr();i[e]=t,Ir(Fo,JSON.stringify(i))}catch(e){null==i||i.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(i,t,this.loggerWrapper)},Ra=function(e){var t;const i=null===(t=Er(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!i)return;const n=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(i)}`);n&&o&&(o.replaceWith(n),n.appendChild(o))},xa=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${go}]), [data-type="button"]:not([${go}]`).forEach((i=>{i.onclick=()=>{u(this,Ca,"f").call(this,i,e,t)}})),u(this,Vs,"m",Sa).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${po}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Oa=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Ea=function(e,t,i){var n;const[o,r]=(null===(n=window.name)||void 0===n?void 0:n.split("|"))||[],s={data:{code:t,exchangeError:i},action:"code"};if("descope-wc"===o&&r){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",r);try{window.opener.postMessage(s,r)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(s),t.close()}try{window.close()}catch(e){}},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Aa);var Na=Object.freeze({__proto__:null,default:Aa});const ja=Rn((e=>{var t,i,n,o,r,s,a;return a=class extends(bn(Fr,Ur)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),this.attributeChangedCallback=(e,i,n)=>{var o;null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,i,n),"debug"===e&&u(this,t,"m",r).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,i){var n;null===(n=super.onLogEvent)||void 0===n||n.call(this,e,i),"error"===e&&u(this,t,"m",s).call(this,i[0]||"Error",i[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),u(this,t,"m",r).call(this)}},i=new WeakMap,t=new WeakSet,n=function(){var e;null===(e=u(this,i,"f"))||void 0===e||e.remove(),h(this,i,null,"f")},o=async function(){h(this,i,document.createElement("descope-debugger"),"f"),Object.assign(u(this,i,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return VC})),document.body.appendChild(u(this,i,"f"))},r=function(){this.debug?u(this,t,"m",o).call(this):u(this,t,"m",n).call(this)},s=function(e,t){var n;e&&(null===(n=u(this,i,"f"))||void 0===n||n.updateData({title:e,description:t}))},a})),Ma="descope-modal";var Pa,Ua;class Ta{constructor(e,t){Pa.set(this,void 0),this.nodeName="",h(this,Pa,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const i=setInterval((()=>{const n="function"==typeof e?e():e;n&&(clearInterval(i),t(n))}),100);setTimeout((()=>{clearInterval(i),t(null)}),1e3)})))(u(this,Pa,"f"))}get ele(){var e,t;const i="function"==typeof u(this,Pa,"f")?u(this,Pa,"f").call(this):u(this,Pa,"f");return i?(null==i?void 0:i.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${i.localName}" `,Error()),null):i:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}}Pa=new WeakMap;class Wa extends Ta{constructor(){super(...arguments),this.nodeName="descope-apps-list"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}}let La=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}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)}}},Da=class extends Ta{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")}};class _a extends Ta{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,i;e?null===(i=this.ele)||void 0===i||i.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}}let Fa=class extends Da{get flowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id"))||""}get enableMode(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("enable-mode")}};const qa=/^descope-grid-([^-]+)-column$/,Ba={text:class extends Ta{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 Ta{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)}}}};let Va=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-grid",Ua.set(this,void 0)}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 i;const n=null===(i=qa.exec(t.localName))||void 0===i?void 0:i[1],o=Ba[n];return o?(e.push(new o(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,i;const n=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);n&&this.ele.columns&&(wn(n,this.ele.columns)||(this.ele.columns=n,null===(i=u(this,Ua,"f"))||void 0===i||i.call(this,n)))}onColumnsChange(e){h(this,Ua,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};Ua=new WeakMap;let Ka=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-link"}get ele(){return super.ele}get href(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("href")}set href(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("href",null!=e?e:"")}};var Ha;let za=class extends Ta{constructor(){super(...arguments),Ha.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)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),u(this,Ha,"f")&&(null===(e=this.ele)||void 0===e||e.append(u(this,Ha,"f").content.cloneNode(!0)))}setContent(e){h(this,Ha,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};Ha=new WeakMap;let Ga=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-multi-line-mappings"}setData(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("data",JSON.stringify(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)}get mergedValue(){return Object.entries(this.value.filter((({tenantId:e})=>!!e)).reduce(((e,{tenantId:t,roleNames:i})=>(e[t]=[...new Set([...e[t]||[],...i])],e)),{})).map((([e,t])=>({tenantId:e,roleNames:t})))}},Ja=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-multi-select-combo-box"}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}},Za=class extends Ta{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()}},Ya=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-outbound-apps"}set data(e){this.ele&&(this.ele.data=e)}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}get ele(){return super.ele}get connectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("connect-flow-id"))||""}get disconnectFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("disconnect-flow-id"))||""}onConnectClick(e){var t;const i=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("connect-clicked",i),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("connect-clicked",i)}}onDisconnectClick(e){var t;const i=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("disconnect-clicked",i),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("disconnect-clicked",i)}}},Xa=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-combo-box"}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)}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}setAllowCustomValue(e){this.ele&&this.ele.toggleAttribute("allow-custom-value",e)}},Qa=class extends Ta{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)}},ed=class extends Ta{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)}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")}},td=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},id=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,i;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(i=this.ele)||void 0===i||i.removeAttribute("fulfilled")}onUnfulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}onFulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("fulfilled-button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("fulfilled-button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}get fulfilledFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("fulfilled-flow-id")}},nd=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-trusted-devices"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",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 flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onRemoveDeviceClick(e){var t;const i=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-device-clicked",i),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-device-clicked",i)}}},od=class extends Xa{get action(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-action"))||""}get refreshTimeout(){var e;return Number(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-refresh-timeout"))||500}get shouldReload(){return"reload"===this.action}},rd=class extends Ta{constructor(){super(...arguments),this.nodeName="descope-user-passkeys"}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 addPasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("add-passkey-flow-id")}get removePasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("remove-passkey-flow-id")}onAddPasskeyClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("add-passkey-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("add-passkey-clicked",e)}}onRemovePasskeyClick(e){var t;const i=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-passkey-clicked",i),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-passkey-clicked",i)}}};const sd=Rn((e=>{var t,i;const n=bn(Fr,cs,os)(e);return i=class extends n{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends za{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const i=((e={})=>{const t=document.createElement(Ma);return Object.keys(e).forEach((i=>{t.setAttribute(i,e[i])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(i),new(u(this,t,"f"))(i,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Ma]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,i})),ad="descope-notification",dd=Rn((e=>{var t,i;const n=bn(Fr,cs,os)(e);return i=class extends n{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Za{setContent(t){const i="string"==typeof t?$n(t):t;e(i),super.setContent(i)}}})())}createNotification(e){const i=((e={})=>{const t=document.createElement(ad);return Object.keys(e).forEach((i=>{t.setAttribute(i,e[i])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(i),new(u(this,t,"f"))(i,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([ad])}},t=new WeakMap,i}));function ld(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 cd=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),ud=()=>Math.random().toString(36).substring(7).split("").join("."),hd={INIT:`@@redux/INIT${ud()}`,REPLACE:`@@redux/REPLACE${ud()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ud()}`};function fd(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 pd(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 i=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(i){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return i}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function gd(e){let t=typeof e;return"production"!==process.env.NODE_ENV&&(t=pd(e)),t}function vd(e,t,i){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?ld(2):`Expected the root reducer to be a function. Instead, received: '${gd(e)}'`);if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error("production"===process.env.NODE_ENV?ld(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===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error("production"===process.env.NODE_ENV?ld(1):`Expected the enhancer to be a function. Instead, received: '${gd(i)}'`);return i(vd)(e,t)}let n=e,o=t,r=new Map,s=r,a=0,d=!1;function l(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function c(){if(d)throw new Error("production"===process.env.NODE_ENV?ld(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 o}function u(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?ld(4):`Expected the listener to be a function. Instead, received: '${gd(e)}'`);if(d)throw new Error("production"===process.env.NODE_ENV?ld(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 i=a++;return s.set(i,e),function(){if(t){if(d)throw new Error("production"===process.env.NODE_ENV?ld(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(i),r=null}}}function h(e){if(!fd(e))throw new Error("production"===process.env.NODE_ENV?ld(7):`Actions must be plain objects. Instead, the actual type was: '${gd(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?ld(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?ld(17):`Action "type" property must be a string. Instead, the actual type was: '${gd(e.type)}'. Value was: '${e.type}' (stringified)`);if(d)throw new Error("production"===process.env.NODE_ENV?ld(9):"Reducers may not dispatch actions.");try{d=!0,o=n(o,e)}finally{d=!1}return(r=s).forEach((e=>{e()})),e}h({type:hd.INIT});return{dispatch:h,subscribe:u,getState:c,replaceReducer:function(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?ld(10):`Expected the nextReducer to be a function. Instead, received: '${gd(e)}`);n=e,h({type:hd.REPLACE})},[cd]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error("production"===process.env.NODE_ENV?ld(11):`Expected the observer to be an object. Instead, received: '${gd(t)}'`);function i(){const e=t;e.next&&e.next(c())}i();return{unsubscribe:e(i)}},[cd](){return this}}}}}function md(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function yd(e){const t=Object.keys(e),i={};for(let n=0;n<t.length;n++){const o=t[n];"production"!==process.env.NODE_ENV&&void 0===e[o]&&md(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(i[o]=e[o])}const n=Object.keys(i);let o,r;"production"!==process.env.NODE_ENV&&(o={});try{!function(e){Object.keys(e).forEach((t=>{const i=e[t];if(void 0===i(void 0,{type:hd.INIT}))throw new Error("production"===process.env.NODE_ENV?ld(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===i(void 0,{type:hd.PROBE_UNKNOWN_ACTION()}))throw new Error("production"===process.env.NODE_ENV?ld(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${hd.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.`)}))}(i)}catch(e){r=e}return function(e={},t){if(r)throw r;if("production"!==process.env.NODE_ENV){const n=function(e,t,i,n){const o=Object.keys(t),r=i&&i.type===hd.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!fd(e))return`The ${r} has unexpected type of "${gd(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!n[e]));return s.forEach((e=>{n[e]=!0})),i&&i.type===hd.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,i,t,o);n&&md(n)}let s=!1;const a={};for(let o=0;o<n.length;o++){const r=n[o],d=i[r],l=e[r],c=d(l,t);if(void 0===c){const e=t&&t.type;throw new Error("production"===process.env.NODE_ENV?ld(14):`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" 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[r]=c,s=s||c!==l}return s=s||n.length!==Object.keys(e).length,s?a:e}}function bd(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...i)=>e(t(...i))))}function $d(e){return fd(e)&&"type"in e&&"string"==typeof e.type}var wd=Symbol.for("immer-nothing"),Cd=Symbol.for("immer-draftable"),kd=Symbol.for("immer-state"),Sd="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 Id(e,...t){if("production"!==process.env.NODE_ENV){const i=Sd[e],n="function"==typeof i?i.apply(null,t):i;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Rd=Object.getPrototypeOf;function xd(e){return!!e&&!!e[kd]}function Od(e){return!!e&&(Ad(e)||Array.isArray(e)||!!e[Cd]||!!e.constructor?.[Cd]||Ud(e)||Td(e))}var Ed=Object.prototype.constructor.toString();function Ad(e){if(!e||"object"!=typeof e)return!1;const t=Rd(e);if(null===t)return!0;const i=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return i===Object||"function"==typeof i&&Function.toString.call(i)===Ed}function Nd(e,t){0===jd(e)?Object.entries(e).forEach((([i,n])=>{t(i,n,e)})):e.forEach(((i,n)=>t(n,i,e)))}function jd(e){const t=e[kd];return t?t.type_:Array.isArray(e)?1:Ud(e)?2:Td(e)?3:0}function Md(e,t){return 2===jd(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Pd(e,t,i){const n=jd(e);2===n?e.set(t,i):3===n?e.add(i):e[t]=i}function Ud(e){return e instanceof Map}function Td(e){return e instanceof Set}function Wd(e){return e.copy_||e.base_}function Ld(e,t){if(Ud(e))return new Map(e);if(Td(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ad(e)){if(!Rd(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const i=Object.getOwnPropertyDescriptors(e);delete i[kd];let n=Reflect.ownKeys(i);for(let t=0;t<n.length;t++){const o=n[t],r=i[o];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(i[o]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[o]})}return Object.create(Rd(e),i)}function Dd(e,t=!1){return Fd(e)||xd(e)||!Od(e)||(jd(e)>1&&(e.set=e.add=e.clear=e.delete=_d),Object.freeze(e),t&&Nd(e,((e,t)=>Dd(t,!0)))),e}function _d(){Id(2)}function Fd(e){return Object.isFrozen(e)}var qd,Bd={};function Vd(e){const t=Bd[e];return t||Id(0,e),t}function Kd(){return qd}function Hd(e,t){t&&(Vd("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function zd(e){Gd(e),e.drafts_.forEach(Zd),e.drafts_=null}function Gd(e){e===qd&&(qd=e.parent_)}function Jd(e){return qd={drafts_:[],parent_:qd,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Zd(e){const t=e[kd];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Yd(e,t){t.unfinalizedDrafts_=t.drafts_.length;const i=t.drafts_[0];return void 0!==e&&e!==i?(i[kd].modified_&&(zd(t),Id(4)),Od(e)&&(e=Xd(t,e),t.parent_||el(t,e)),t.patches_&&Vd("Patches").generateReplacementPatches_(i[kd].base_,e,t.patches_,t.inversePatches_)):e=Xd(t,i,[]),zd(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==wd?e:void 0}function Xd(e,t,i){if(Fd(t))return t;const n=t[kd];if(!n)return Nd(t,((o,r)=>Qd(e,n,t,o,r,i))),t;if(n.scope_!==e)return t;if(!n.modified_)return el(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const t=n.copy_;let o=t,r=!1;3===n.type_&&(o=new Set(t),t.clear(),r=!0),Nd(o,((o,s)=>Qd(e,n,t,o,s,i,r))),el(e,t,!1),i&&e.patches_&&Vd("Patches").generatePatches_(n,i,e.patches_,e.inversePatches_)}return n.copy_}function Qd(e,t,i,n,o,r,s){if("production"!==process.env.NODE_ENV&&o===i&&Id(5),xd(o)){const s=Xd(e,o,r&&t&&3!==t.type_&&!Md(t.assigned_,n)?r.concat(n):void 0);if(Pd(i,n,s),!xd(s))return;e.canAutoFreeze_=!1}else s&&i.add(o);if(Od(o)&&!Fd(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Xd(e,o),t&&t.scope_.parent_||el(e,o)}}function el(e,t,i=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Dd(t,i)}var tl={get(e,t){if(t===kd)return e;const i=Wd(e);if(!Md(i,t))return function(e,t,i){const n=ol(t,i);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}(e,i,t);const n=i[t];return e.finalized_||!Od(n)?n:n===nl(e.base_,t)?(sl(e),e.copy_[t]=al(n,e)):n},has:(e,t)=>t in Wd(e),ownKeys:e=>Reflect.ownKeys(Wd(e)),set(e,t,i){const n=ol(Wd(e),t);if(n?.set)return n.set.call(e.draft_,i),!0;if(!e.modified_){const n=nl(Wd(e),t),o=n?.[kd];if(o&&o.base_===i)return e.copy_[t]=i,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(i,n)&&(void 0!==i||Md(e.base_,t)))return!0;sl(e),rl(e)}return e.copy_[t]===i&&(void 0!==i||t in e.copy_)||Number.isNaN(i)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=i,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==nl(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,sl(e),rl(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const i=Wd(e),n=Reflect.getOwnPropertyDescriptor(i,t);return n?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:n.enumerable,value:i[t]}:n},defineProperty(){Id(11)},getPrototypeOf:e=>Rd(e.base_),setPrototypeOf(){Id(12)}},il={};function nl(e,t){const i=e[kd];return(i?Wd(i):e)[t]}function ol(e,t){if(!(t in e))return;let i=Rd(e);for(;i;){const e=Object.getOwnPropertyDescriptor(i,t);if(e)return e;i=Rd(i)}}function rl(e){e.modified_||(e.modified_=!0,e.parent_&&rl(e.parent_))}function sl(e){e.copy_||(e.copy_=Ld(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Nd(tl,((e,t)=>{il[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),il.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&Id(13),il.set.call(this,e,t,void 0)},il.set=function(e,t,i){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Id(14),tl.set.call(this,e[0],t,i,e[0])};function al(e,t){const i=Ud(e)?Vd("MapSet").proxyMap_(e,t):Td(e)?Vd("MapSet").proxySet_(e,t):function(e,t){const i=Array.isArray(e),n={type_:i?1:0,scope_:t?t.scope_:Kd(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=n,r=tl;i&&(o=[n],r=il);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return n.draft_=a,n.revoke_=s,a}(e,t);return(t?t.scope_:Kd()).drafts_.push(i),i}function dl(e){return xd(e)||Id(10,e),ll(e)}function ll(e){if(!Od(e)||Fd(e))return e;const t=e[kd];let i;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,i=Ld(e,t.scope_.immer_.useStrictShallowCopy_)}else i=Ld(e,!0);return Nd(i,((e,t)=>{Pd(i,e,ll(t))})),t&&(t.finalized_=!1),i}var cl=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,i)=>{if("function"==typeof e&&"function"!=typeof t){const i=t;t=e;const n=this;return function(e=i,...o){return n.produce(e,(e=>t.call(this,e,...o)))}}let n;if("function"!=typeof t&&Id(6),void 0!==i&&"function"!=typeof i&&Id(7),Od(e)){const o=Jd(this),r=al(e,void 0);let s=!0;try{n=t(r),s=!1}finally{s?zd(o):Gd(o)}return Hd(o,i),Yd(n,o)}if(!e||"object"!=typeof e){if(n=t(e),void 0===n&&(n=e),n===wd&&(n=void 0),this.autoFreeze_&&Dd(n,!0),i){const t=[],o=[];Vd("Patches").generateReplacementPatches_(e,n,t,o),i(t,o)}return n}Id(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...i)=>this.produceWithPatches(t,(t=>e(t,...i)));let i,n;const o=this.produce(e,t,((e,t)=>{i=e,n=t}));return[o,i,n]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Od(e)||Id(8),xd(e)&&(e=dl(e));const t=Jd(this),i=al(e,void 0);return i[kd].isManual_=!0,Gd(t),i}finishDraft(e,t){const i=e&&e[kd];i&&i.isManual_||Id(9);const{scope_:n}=i;return Hd(n,t),Yd(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let i;for(i=t.length-1;i>=0;i--){const n=t[i];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}i>-1&&(t=t.slice(i+1));const n=Vd("Patches").applyPatches_;return xd(e)?n(e,t):this.produce(e,(e=>n(e,t)))}},ul=cl.produce;cl.produceWithPatches.bind(cl),cl.setAutoFreeze.bind(cl),cl.setUseStrictShallowCopy.bind(cl),cl.applyPatches.bind(cl),cl.createDraft.bind(cl),cl.finishDraft.bind(cl);var hl=(e,t,i)=>{if(1===t.length&&t[0]===i){let t=!1;try{const i={};e(i)===i&&(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})}}},fl=(e,t,i)=>{const{memoize:n,memoizeOptions:o}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=n((()=>({})),...o);if(!(a.apply(null,r)===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:i,firstInputs:r,secondInputs:s,stack:e})}},pl={inputStabilityCheck:"once",identityFunctionCheck:"once"};var gl=e=>Array.isArray(e)?e:[e];function vl(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 i=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${i}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function ml(e,t){const i=[],{length:n}=e;for(let o=0;o<n;o++)i.push(e[o].apply(null,t));return i}var yl="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},bl=0,$l=1;function wl(){return{s:bl,v:void 0,o:null,p:null}}function Cl(e,t={}){let i=wl();const{resultEqualityCheck:n}=t;let o,r=0;function s(){let t=i;const{length:s}=arguments;for(let e=0,i=s;e<i;e++){const i=arguments[e];if("function"==typeof i||"object"==typeof i&&null!==i){let e=t.o;null===e&&(t.o=e=new WeakMap);const n=e.get(i);void 0===n?(t=wl(),e.set(i,t)):t=n}else{let e=t.p;null===e&&(t.p=e=new Map);const n=e.get(i);void 0===n?(t=wl(),e.set(i,t)):t=n}}const a=t;let d;if(t.s===$l)d=t.v;else if(d=e.apply(null,arguments),r++,n){const e=o?.deref?.()??o;null!=e&&n(e,d)&&(d=e,0!==r&&r--);o="object"==typeof d&&null!==d||"function"==typeof d?new yl(d):d}return a.s=$l,a.v=d,d}return s.clearCache=()=>{i=wl(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function kl(e,...t){const i="function"==typeof e?{memoize:e,memoizeOptions:t}:e,n=(...e)=>{let t,n=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=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={...i,...r},{memoize:d,memoizeOptions:l=[],argsMemoize:c=Cl,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,f=gl(l),p=gl(u),g=vl(e),v=d((function(){return n++,s.apply(null,arguments)}),...f);let m=!0;const y=c((function(){o++;const e=ml(g,arguments);if(t=v.apply(null,e),"production"!==process.env.NODE_ENV){const{identityFunctionCheck:i,inputStabilityCheck:n}=((e,t)=>{const{identityFunctionCheck:i,inputStabilityCheck:n}={...pl,...t};return{identityFunctionCheck:{shouldRun:"always"===i||"once"===i&&e,run:hl},inputStabilityCheck:{shouldRun:"always"===n||"once"===n&&e,run:fl}}})(m,h);if(i.shouldRun&&i.run(s,e,t),n.shouldRun){const t=ml(g,arguments);n.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:d,memoizeOptions:f},arguments)}m&&(m=!1)}return t}),...p);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>n,resetRecomputations:()=>{n=0},memoize:d,argsMemoize:c})};return Object.assign(n,{withTypes:()=>n}),n}var Sl=kl(Cl),Il=Object.assign(((e,t=Sl)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const i=Object.keys(e),n=t(i.map((t=>e[t])),((...e)=>e.reduce(((e,t,n)=>(e[i[n]]=t,e)),{})));return n}),{withTypes:()=>Il});function Rl(e){return({dispatch:t,getState:i})=>n=>o=>"function"==typeof o?o(t,i,e):n(o)}var xl=Rl(),Ol=Rl;((...e)=>{const t=kl(...e)})(Cl);var El="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?bd:bd.apply(null,arguments)},Al=e=>e&&"function"==typeof e.match;function Nl(e,t){function i(...i){if(t){let n=t(...i);if(!n)throw new Error("production"===process.env.NODE_ENV?uc(0):"prepareAction did not return an object");return{type:e,payload:n.payload,..."meta"in n&&{meta:n.meta},..."error"in n&&{error:n.error}}}return{type:e,payload:i[0]}}return i.toString=()=>`${e}`,i.type=e,i.match=t=>$d(t)&&t.type===e,i}function jl(e){return"function"==typeof e&&"type"in e&&Al(e)}function Ml(e,t){let i=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();i+=e-t}},warnIfExceeded(){i>e&&console.warn(`${t} took ${i}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 Pl=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 Ul(e){return Od(e)?ul(e,(()=>{})):e}function Tl(e,t,i){if(e.has(t)){let n=e.get(t);return i.update&&(n=i.update(n,t,e),e.set(t,n)),n}if(!i.insert)throw new Error("production"===process.env.NODE_ENV?uc(10):"No insert provided for key not already in map");const n=i.insert(t,e);return e.set(t,n),n}function Wl(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Ll(e,t,i){const n=Dl(e,t,i);return{detectMutations:()=>_l(e,t,n,i)}}function Dl(e,t=[],i,n="",o=new Set){const r={value:i};if(!e(i)&&!o.has(i)){o.add(i),r.children={};for(const o in i){const s=n?n+"."+o:o;t.length&&-1!==t.indexOf(s)||(r.children[o]=Dl(e,t,i[o],s))}}return r}function _l(e,t=[],i,n,o=!1,r=""){const s=i?i.value:void 0,a=s===n;if(o&&!a&&!Number.isNaN(n))return{wasMutated:!0,path:r};if(e(s)||e(n))return{wasMutated:!1};const d={};for(let e in i.children)d[e]=!0;for(let e in n)d[e]=!0;const l=t.length>0;for(let o in d){const s=r?r+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const d=_l(e,t,i.children[o],n[o],a,s);if(d.wasMutated)return d}return{wasMutated:!1}}function Fl(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||fd(e)}function ql(e,t="",i=Fl,n,o=[],r){let s;if(!i(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=n?n(e):Object.entries(e),d=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(d){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!i(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=ql(l,a,i,n,o,r),s))return s}return r&&Bl(e)&&r.add(e),!1}function Bl(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Bl(t))return!1;return!0}function Vl(e){return"boolean"==typeof e}var Kl=()=>function(e){const{thunk:t=!0,immutableCheck:i=!0,serializableCheck:n=!0,actionCreatorCheck:o=!0}=e??{};let r=new Pl;if(t&&(Vl(t)?r.push(xl):r.push(Ol(t.extraArgument))),"production"!==process.env.NODE_ENV){if(i){let e={};Vl(i)||(e=i),r.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{let t=function(e,t,n,o){return JSON.stringify(e,i(t,o),n)},i=function(e,t){let i=[],n=[];return t||(t=function(e,t){return i[0]===t?"[Circular ~]":"[Circular ~."+n.slice(0,i.indexOf(t)).join(".")+"]"}),function(o,r){if(i.length>0){var s=i.indexOf(this);~s?i.splice(s+1):i.push(this),~s?n.splice(s,1/0,o):n.push(o),~i.indexOf(r)&&(r=t.call(this,o,r))}else i.push(r);return null==e?r:e.call(this,o,r)}},{isImmutable:n=Wl,ignoredPaths:o,warnAfter:r=32}=e;const s=Ll.bind(null,n,o);return({getState:e})=>{let i,n=e(),o=s(n);return a=>d=>{const l=Ml(r,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(n=e(),i=o.detectMutations(),o=s(n),i.wasMutated)throw new Error("production"===process.env.NODE_ENV?uc(19):`A state mutation was detected between dispatches, in the path '${i.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const c=a(d);return l.measureTime((()=>{if(n=e(),i=o.detectMutations(),o=s(n),i.wasMutated)throw new Error("production"===process.env.NODE_ENV?uc(20):`A state mutation was detected inside a dispatch, in the path: ${i.path||""}. Take a look at the reducer(s) handling the action ${t(d)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),c}}}}(e))}if(n){let e={};Vl(n)||(e=n),r.push(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);{const{isSerializable:t=Fl,getEntries:i,ignoredActions:n=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:d=!1,disableCache:l=!1}=e,c=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!$d(u))return l(u);const h=l(u),f=Ml(s,"SerializableStateInvariantMiddleware");return d||n.length&&-1!==n.indexOf(u.type)||f.measureTime((()=>{const e=ql(u,"",t,i,o,c);if(e){const{keyPath:t,value:i}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,i,"\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||(f.measureTime((()=>{const n=ql(e.getState(),"",t,i,r,c);if(n){const{keyPath:e,value:t}=n;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)`)}})),f.warnIfExceeded()),h}}}(e))}if(o){let e={};Vl(o)||(e=o),r.unshift(function(e={}){if("production"===process.env.NODE_ENV)return()=>e=>t=>e(t);const{isActionCreator:t=jl}=e;return()=>e=>i=>(t(i)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],i=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(${i}())\` instead of \`dispatch(${i})\`. This is necessary even if the action has no payload.`}(i.type)),e(i))}(e))}}return r},Hl=e=>t=>{setTimeout(t,e)},zl="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Hl(10),Gl=e=>function(t){const{autoBatch:i=!0}=t??{};let n=new Pl(e);return i&&n.push(((e={type:"raf"})=>t=>(...i)=>{const n=t(...i);let o=!0,r=!1,s=!1;const a=new Set,d="tick"===e.type?queueMicrotask:"raf"===e.type?zl:"callback"===e.type?e.queueNotification:Hl(e.timeout),l=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},n,{subscribe(e){const t=n.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,d(l))),n.dispatch(e)}finally{o=!0}}})})("object"==typeof i?i:void 0)),n},Jl="production"===process.env.NODE_ENV;function Zl(e){const t=Kl(),{reducer:i,middleware:n,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,d;if("function"==typeof i)a=i;else{if(!fd(i))throw new Error("production"===process.env.NODE_ENV?uc(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=yd(i)}if(!Jl&&n&&"function"!=typeof n)throw new Error("production"===process.env.NODE_ENV?uc(2):"`middleware` field must be a callback");if("function"==typeof n){if(d=n(t),!Jl&&!Array.isArray(d))throw new Error("production"===process.env.NODE_ENV?uc(3):"when using a middleware builder function, an array of middleware must be returned")}else d=t();if(!Jl&&d.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?uc(4):"each middleware provided to configureStore must be a function");let l=bd;o&&(l=El({trace:!Jl,..."object"==typeof o&&o}));const c=function(...e){return t=>(i,n)=>{const o=t(i,n);let r=()=>{throw new Error("production"===process.env.NODE_ENV?ld(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=bd(...a)(o.dispatch),{...o,dispatch:r}}}(...d),u=Gl(c);if(!Jl&&s&&"function"!=typeof s)throw new Error("production"===process.env.NODE_ENV?uc(5):"`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Jl&&!Array.isArray(h))throw new Error("production"===process.env.NODE_ENV?uc(6):"`enhancers` callback must return an array");if(!Jl&&h.some((e=>"function"!=typeof e)))throw new Error("production"===process.env.NODE_ENV?uc(7):"each enhancer provided to configureStore must be a function");Jl||!d.length||h.includes(c)||console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return vd(a,r,l(...h))}function Yl(e){const t={},i=[];let n;const o={addCase(e,r){if("production"!==process.env.NODE_ENV){if(i.length>0)throw new Error("production"===process.env.NODE_ENV?uc(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(n)throw new Error("production"===process.env.NODE_ENV?uc(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?uc(28):"`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error("production"===process.env.NODE_ENV?uc(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,o},addMatcher(e,t){if("production"!==process.env.NODE_ENV&&n)throw new Error("production"===process.env.NODE_ENV?uc(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return i.push({matcher:e,reducer:t}),o},addDefaultCase(e){if("production"!==process.env.NODE_ENV&&n)throw new Error("production"===process.env.NODE_ENV?uc(31):"`builder.addDefaultCase` can only be called once");return n=e,o}};return e(o),[t,i,n]}function Xl(...e){return t=>e.some((e=>((e,t)=>Al(e)?e.match(t):e(t))(e,t)))}var Ql=["name","message","stack","code"],ec=class{constructor(e,t){this.payload=e,this.meta=t}_type},tc=class{constructor(e,t){this.payload=e,this.meta=t}_type},ic=e=>{if("object"==typeof e&&null!==e){const t={};for(const i of Ql)"string"==typeof e[i]&&(t[i]=e[i]);return t}return{message:String(e)}},nc=(()=>{function e(e,t,i){const n=Nl(e+"/fulfilled",((e,t,i,n)=>({payload:e,meta:{...n||{},arg:i,requestId:t,requestStatus:"fulfilled"}}))),o=Nl(e+"/pending",((e,t,i)=>({payload:void 0,meta:{...i||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Nl(e+"/rejected",((e,t,n,o,r)=>({payload:o,error:(i&&i.serializeError||ic)(e||"Rejected"),meta:{...r||{},arg:n,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,d)=>{const l=i?.idGenerator?i.idGenerator(e):((e=21)=>{let t="",i=e;for(;i--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),c=new AbortController;let u;function h(e){u=e,c.abort()}const f=async function(){let f;try{let r=i?.condition?.(e,{getState:a,extra:d});if(null!==(p=r)&&"object"==typeof p&&"function"==typeof p.then&&(r=await r),!1===r||c.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>c.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(l,e,i?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:d}))),f=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:d,requestId:l,signal:c.signal,abort:h,rejectWithValue:(e,t)=>new ec(e,t),fulfillWithValue:(e,t)=>new tc(e,t)})).then((t=>{if(t instanceof ec)throw t;return t instanceof tc?n(t.payload,l,e,t.meta):n(t,l,e)}))])}catch(t){f=t instanceof ec?r(null,l,e,t.payload,t.meta):r(t,l,e)}var p;return i&&!i.dispatchConditionRejection&&r.match(f)&&f.meta.condition||s(f),f}();return Object.assign(f,{abort:h,requestId:l,arg:e,unwrap:()=>f.then(oc)})}}),{pending:o,rejected:r,fulfilled:n,settled:Xl(r,n),typePrefix:e})}return e.withTypes=()=>e,e})();function oc(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var rc=Symbol.for("rtk-slice-createasyncthunk");function sc(e,t){return`${e}/${t}`}function ac(e,t,i,n){function o(o,...r){let s=i.call(e,o);if(void 0===s)if(n)s=e.getInitialState();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?uc(16):"selectState returned undefined for an uninjected slice reducer");return t(s,...r)}return o.unwrapped=t,o}var dc=function({creators:e}={}){const t=e?.asyncThunk?.[rc];return function(e){const{name:i,reducerPath:n=i}=e;if(!i)throw new Error("production"===process.env.NODE_ENV?uc(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 o=("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)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const i="string"==typeof e?e:e.type;if(!i)throw new Error("production"===process.env.NODE_ENV?uc(12):"`context.addCase` cannot be called with an empty action type");if(i in s.sliceCaseReducersByType)throw new Error("production"===process.env.NODE_ENV?uc(13):"`context.addCase` cannot be called with two reducers for the same action type: "+i);return s.sliceCaseReducersByType[i]=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 d(){if("production"!==process.env.NODE_ENV&&"object"==typeof e.extraReducers)throw new Error("production"===process.env.NODE_ENV?uc(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={},i=[],n]="function"==typeof e.extraReducers?Yl(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("production"!==process.env.NODE_ENV&&"object"==typeof t)throw new Error("production"===process.env.NODE_ENV?uc(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let i,[n,o,r]=Yl(t);if(function(e){return"function"==typeof e}(e))i=()=>Ul(e());else{const t=Ul(e);i=()=>t}function s(e=i(),t){let s=[n[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,i)=>{if(i){if(xd(e)){const n=i(e,t);return void 0===n?e:n}if(Od(e))return ul(e,(e=>i(e,t)));{const n=i(e,t);if(void 0===n){if(null===e)return e;throw new Error("production"===process.env.NODE_ENV?uc(9):"A case reducer on a non-draftable value must not return undefined")}return n}}return e}),e)}return s.getInitialState=i,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of i)e.addMatcher(t.matcher,t.reducer);n&&e.addDefaultCase(n)}))}r.forEach((n=>{const r=o[n],s={reducerName:n,type:sc(i,n),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:i},n,o){let r,s;if("reducer"in n){if(i&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(n))throw new Error("production"===process.env.NODE_ENV?uc(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=n.reducer,s=n.prepare}else r=n;o.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Nl(e,s):Nl(e))}(s,r,a):function({type:e,reducerName:t},i,n,o){if(!o)throw new Error("production"===process.env.NODE_ENV?uc(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:d,settled:l,options:c}=i,u=o(e,r,c);n.exposeAction(t,u),s&&n.addCase(u.fulfilled,s);a&&n.addCase(u.pending,a);d&&n.addCase(u.rejected,d);l&&n.addMatcher(u.settled,l);n.exposeCaseReducer(t,{fulfilled:s||lc,pending:a||lc,rejected:d||lc,settled:l||lc})}(s,r,a,t)}));const l=e=>e,c=new WeakMap;let u;const h={name:i,reducerPath:n,reducer:(e,t)=>(u||(u=d()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=d()),u.getInitialState()),getSelectors(t=l){const i=Tl(c,this,{insert:()=>new WeakMap});return Tl(i,t,{insert:()=>{const i={};for(const[n,o]of Object.entries(e.selectors??{}))i[n]=ac(this,o,t,this!==h);return i}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t)if(this!==h)t=this.getInitialState();else if("production"!==process.env.NODE_ENV)throw new Error("production"===process.env.NODE_ENV?uc(15):"selectSlice returned undefined for an uninjected slice reducer");return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...i}={}){const n=t??this.reducerPath;return e.inject({reducerPath:n,reducer:this.reducer},i),{...this,reducerPath:n}}};return h}}();function lc(){}var cc="listenerMiddleware";function uc(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. `}Nl(`${cc}/add`),Nl(`${cc}/removeAll`),Nl(`${cc}/remove`);const hc=e=>Rn((t=>{const i=dc(e),n=Object.assign(Object.assign({},i.actions),e.asyncActions);return class extends(bn(Ur)(t)){constructor(...e){super(...e);const t=Zl({reducer:i.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...i)=>{const n=await t.dispatch(e(...i));try{oc(n)}catch(e){this.logger.error(e.message,n.type,e.stack)}return n},r=Object.keys(n).reduce(((e,t)=>(e[t]=o(n[t]),e)),{});this.actions=r,this.subscribe=(e,i=e=>e)=>t.subscribe((()=>e(i(t.getState()))))}}})),fc=Rn((e=>class extends(Ur(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,i;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(i=e.checkValidity)||void 0===i?void 0:i.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=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var i;null===(i=this.getFormInputs(e).find((e=>e.name===t)))||void 0===i||i.setAttribute("disabled","true")}removeFormField(e,t){var i;null===(i=this.getFormInputs(e).find((e=>e.name===t)))||void 0===i||i.remove()}})),pc=Rn((e=>{const t=bn(Br({"widget-id":_r}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),gc=Rn((e=>{const t=bn(Zr,pc)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const i=await this.config;return null===(t=null===(e=null==i?void 0:i.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}})),vc=Rn((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),mc=e=>e.selectedAccessKeysIds,yc=e=>e.notifications,bc=Sl((e=>e.accessKeysList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{expireTimeFormatted:(null==e?void 0:e.expireTime)?new Date(1e3*((null==e?void 0:e.expireTime)||0)).toLocaleString():"Never",createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:(null==e?void 0:e.expireTime)&&new Date(1e3*((null==e?void 0:e.expireTime)||0))<new Date?"expired":null==e?void 0:e.status}))))),$c=Sl(mc,bc,((e,t)=>t.filter((t=>e.includes(t.id))))),wc=Sl(mc,(e=>!!e.length)),Cc=Sl($c,(e=>e.every((e=>e.editable)))),kc=Sl(Cc,wc,((e,t)=>e&&t)),Sc=Sl($c,(e=>e.some((e=>"expired"===e.status)))),Ic=Sl(kc,Sc,((e,t)=>e&&!t));Sl(mc,(e=>1===e.length));const Rc=Sl($c,(e=>1===e.length?e[0].name:`${e.length} access keys`)),xc=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},Oc=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),Ec=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{t&&e.notifications.push({type:"success",msg:t(i)})},onRejected:(t,i)=>{e&&t.notifications.push({type:"error",msg:e(i)})}}),Ac=nc("accessKeys/create",((e,{extra:{api:t}})=>t.accesskey.create(e))),Nc=xc(Ac)({onFulfilled:(e,t)=>{e.accessKeysList.data.unshift(t.payload.key)}},Oc((e=>e.createAccessKey)),Ec({getSuccessMsg:()=>"Access Key created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create access key</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),jc={action:Ac,reducer:Nc},Mc=nc("accessKeys/delete",((e,{extra:{api:t}})=>t.accesskey.deleteBatch(e))),Pc=xc(Mc)({onFulfilled:(e,t)=>{e.accessKeysList.data=e.accessKeysList.data.filter((e=>!t.meta.arg.includes(e.id))),e.selectedAccessKeysIds=[]}},Oc((e=>e.deleteAccessKey)),Ec({getSuccessMsg:e=>Sn(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deleted successfully`,getErrorMsg:e=>Sn(e.meta.arg.length)`Failed to delete access key${["","s"]}`})),Uc={action:Mc,reducer:Pc},Tc=nc("accessKeys/search",((e,{extra:{api:t},getState:i})=>{const n=i().searchParams;return t.accesskey.search(Object.assign(Object.assign({},n),e))})),Wc=xc(Tc)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.accessKeysList.data=t.payload}},Oc((e=>e.accessKeysList))),Lc={action:Tc,reducer:Wc},Dc=nc("accessKeys/activate",((e,{extra:{api:t}})=>t.accesskey.activate(e))),_c=xc(Dc)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="active")}))}},Oc((e=>e.activateAccessKey)),Ec({getSuccessMsg:e=>Sn(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} activated successfully`,getErrorMsg:e=>Sn(e.meta.arg.length)`Failed to activate access key${["","s"]}`})),Fc={action:Dc,reducer:_c},qc=nc("accessKeys/deactivate",((e,{extra:{api:t}})=>t.accesskey.deactivate(e))),Bc=xc(qc)({onFulfilled:(e,t)=>{e.accessKeysList.data.forEach((e=>{t.meta.arg.includes(e.id)&&(e.status="inactive")}))}},Oc((e=>e.deactivateAccessKey)),Ec({getSuccessMsg:e=>Sn(e.meta.arg.length)`${["",e.meta.arg.length]} ${["A","a"]}ccess key${["","s"]} deactivated successfully`,getErrorMsg:e=>Sn(e.meta.arg.length)`Failed to deactivate access key${["","s"]}`})),Vc={action:qc,reducer:Bc},Kc=nc("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),Hc={action:Kc,reducer:xc(Kc)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},Oc((e=>e.tenantRoles)))},zc={accessKeysList:{data:[],loading:!1,error:null},createAccessKey:{loading:!1,error:null},activateAccessKey:{loading:!1,error:null},deactivateAccessKey:{loading:!1,error:null},deleteAccessKey:{loading:!1,error:null},tenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedAccessKeysIds:[],notifications:[]},Gc="/v1/mgmt/accesskey/search",Jc="/v1/mgmt/accesskey/delete/batch",Zc="/v1/mgmt/accesskey/create",Yc="/v1/mgmt/accesskey/deactivate/batch",Xc="/v1/mgmt/accesskey/activate/batch",Qc="/v1/mgmt/role/all",eu=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),tu=({httpClient:e,tenant:t,mock:i})=>({search:(...n)=>c(void 0,[...n],void 0,(function*({page:n,limit:o=1e4,text:r,sort:s}={}){if(i)return((...e)=>c(void 0,[...e],void 0,(function*({text:e,sort:t}={}){return new Promise((i=>{const n=[],o=(new Date).getTime()/1e3+2592e3,r=new Date(o).toLocaleString();for(let e=1;e<10;e+=1)n.push({id:`access-key-id-${e}`,name:`Access Key ${e}`,createdBy:`User ${e}`,editable:!0,expireTime:o,expireTimeFormatted:r,createdTime:o,createdTimeFormatted:r,roleNames:[`Role ${e}`],permittedIps:["127.1.2.3"],status:"active",clientId:`Client ID ${e}`,boundUserId:`User ${e}`});t.forEach((e=>{n.sort(((t,i)=>{var n,o;return e.desc?null===(o=i[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(n=t[e.field])||void 0===n?void 0:n.localeCompare(i[e.field])}))})),i(n.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.createdBy.toLowerCase().includes(e.toLowerCase()))))}))})))({page:n,limit:o,text:r,sort:s});const a=yield e.post(Gc,{limit:o,page:n,text:r,sort:s},{queryParams:{tenant:t}});return yield eu(a),(yield a.json()).keys})),deleteBatch:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Jc,{ids:n},{queryParams:{tenant:t}});return yield eu(o),o.json()})),create:n=>c(void 0,[n],void 0,(function*({name:n,expiration:o,roleNames:r,userId:s,permittedIps:a}){const d=new Date;d.setDate(d.getDate()+ +o);const l="0"===o[0]?0:Math.floor(d.getTime()/1e3);if(i)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,roleNames:t,userId:i,permittedIps:n},o){const r=Math.random().toString(10).substring(15);return new Promise((s=>{s({cleartext:Math.random().toString(20).substring(2),key:{id:`access-key-id-${r}`,name:e||`Access Key ${r}`,createdBy:i||`User ${r}`,editable:!0,expireTime:o,createdTime:(new Date).getTime()/1e3,roleNames:t,permittedIps:n,status:"active",clientId:`Client ID ${r}`,boundUserId:i||`User ${r}`}})}))})))({name:n,expiration:o,roleNames:r,userId:s,permittedIps:a},l);const u=yield e.post(Zc,{name:n,expireTime:l,roleNames:r,userId:s,permittedIps:a},{queryParams:{tenant:t}});return yield eu(u),yield u.json()})),activate:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Xc,{ids:n},{queryParams:{tenant:t}});return yield eu(o),yield o.json()})),deactivate:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Yc,{ids:n},{queryParams:{tenant:t}});return yield eu(o),yield o.json()}))}),iu=({httpClient:e,tenant:t,mock:i})=>({getTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(i)return(e=>new Promise((t=>{const i=[];for(let t=1;t<5;t+=1)i.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:i})})))(t);const n=yield e.get(Qc,{queryParams:{tenant:t}});return yield eu(n),n.json()}))}),nu=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,Kr,vc,Br({tenant:Br.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i,n)=>{const o=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"access-key-management-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.6.4"}}));return{accesskey:tu({httpClient:o.httpClient,tenant:t,mock:i}),tenant:iu({httpClient:o.httpClient,tenant:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),ou=Rn((e=>{const t=bn(hc({name:"widget",initialState:zc,reducers:{setSelectedAccessKeysIds:(e,{payload:t})=>{e.selectedAccessKeysIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{jc.reducer(e),Uc.reducer(e),Lc.reducer(e),Fc.reducer(e),Vc.reducer(e),Hc.reducer(e)},asyncActions:{searchAccessKeys:Lc.action,createAccessKey:jc.action,activateAccessKeys:Fc.action,deactivateAccessKeys:Vc.action,deleteAccessKeys:Uc.action,getTenantRoles:Hc.action}}),Fr,Ur,nu)(e);return class extends t{constructor(...e){super(...e),this.state=zc,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),ru=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){const t=yield this.fetchStaticResource(`access-key-management-widget/${this.widgetId}/${e}`,"text");return null==t?void 0:t.body}))}}})),su=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,ru,ou)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([u(this,t,"m",i).call(this),this.actions.searchAccessKeys(),this.actions.getTenantRoles()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),au=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(ou,Ur,su)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{this.accessKeysTable.data=e}))),o.set(this,In(((e,t)=>{const i=[],{value:n}=t;if(n){const t=e.path;i.push({field:t,desc:"desc"===n})}this.actions.searchAccessKeys({sort:i})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),u(this,t,"m",i).call(this),this.accessKeysTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,o,"f").call(this,e.target,e.detail)}))})),u(this,n,"f").call(this,bc(this.state)),this.subscribe(u(this,n,"f").bind(this),bc)}))}},n=new WeakMap,o=new WeakMap,t=new WeakSet,i=function(){var e;this.accessKeysTable=new Va(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="access-keys-table"]'),{logger:this.logger}),this.accessKeysTable.onSelectedItemsChange((e=>{this.actions.setSelectedAccessKeysIds(e.detail.value.map((({id:e})=>e)))}))},r})),du=Rn((e=>{var t,i,n;return n=class extends(bn(ou,sd,Ur,su)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){var e;this.activateAccessKeysModal=this.createModal(),this.activateAccessKeysModal.setContent($n(yield this.fetchWidgetPage("activate-access-keys-modal.html")));const t=new Da((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.activateAccessKeysModal.close()));const i=new Da((()=>{var e;return null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=$c(this.state);this.actions.activateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.activateAccessKeysModal.close()}));const n=new Qa(null===(e=this.activateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.activateAccessKeysModal.beforeOpen=()=>{const e=Rc(this.state);n.text=`Activate ${e}?`}}))},n})),lu=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,su,ou,du)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.activateButton.enable():this.activateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),Ic)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.activateButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="activate-access-keys"]'),{logger:this.logger}),this.activateButton.disable(),this.activateButton.onClick((()=>{this.activateAccessKeysModal.open()}))},o})),cu=Rn((e=>{var t,i,n;return n=class extends(bn(ou,sd,fc,Ur,su)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){this.createdAccessKeyModal=this.createModal(),this.createdAccessKeyModal.setContent($n(yield this.fetchWidgetPage("created-access-key-modal.html"))),new Da((()=>{var e;return null===(e=this.createdAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.createdAccessKeyModal.ele)["generated-key"]),this.resetFormData(this.createdAccessKeyModal.ele),this.createdAccessKeyModal.close()}))}))},n})),uu=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(ou,sd,fc,Ur,su,cu)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),o.set(this,(()=>c(this,void 0,void 0,(function*(){var e,t;yield u(this,i,"f").setData(null===(t=this.state,e=t.tenantRoles.data||[])||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},i=new WeakMap,o=new WeakMap,t=new WeakSet,n=function e(){return c(this,void 0,void 0,(function*(){this.createAccessKeyModal=this.createModal(),this.createAccessKeyModal.setContent($n(yield this.fetchWidgetPage("create-access-key-modal.html"))),new Da((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.createAccessKeyModal.close(),this.resetFormData(this.createAccessKeyModal.ele)})),new Da((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){var e,t;if(this.validateForm(this.createAccessKeyModal.ele)){const i=yield this.actions.createAccessKey(Object.assign({},this.getFormData(this.createAccessKeyModal.ele)));this.createAccessKeyModal.close(),(null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e.cleartext)&&(this.setFormData(this.createdAccessKeyModal.ele,{"generated-key":null===(t=null==i?void 0:i.payload)||void 0===t?void 0:t.cleartext}),this.createdAccessKeyModal.open())}})))),h(this,i,new Ja((()=>{var e;return null===(e=this.createAccessKeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),u(this,o,"f").call(this),this.createAccessKeyModal.afterClose=()=>{u(this,t,"m",e).call(this)}}))},r})),hu=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,uu,su)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.createButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-access-key"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createAccessKeyModal.open()))},n})),fu=Rn((e=>{var t,i,n;return n=class extends(bn(ou,sd,Ur,su)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){var e;this.deactivateAccessKeysModal=this.createModal(),this.deactivateAccessKeysModal.setContent($n(yield this.fetchWidgetPage("deactivate-access-keys-modal.html")));const t=new Da((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deactivateAccessKeysModal.close()));const i=new Da((()=>{var e;return null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=$c(this.state);this.actions.deactivateAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deactivateAccessKeysModal.close()}));const n=new Qa(null===(e=this.deactivateAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deactivateAccessKeysModal.beforeOpen=()=>{const e=Rc(this.state);n.text=`Deactivate ${e}?`}}))},n})),pu=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,su,ou,fu)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.deactivateButton.enable():this.deactivateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),Ic)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.deactivateButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="deactivate-access-keys"]'),{logger:this.logger}),this.deactivateButton.disable(),this.deactivateButton.onClick((()=>{this.deactivateAccessKeysModal.open()}))},o})),gu=Rn((e=>{var t,i,n;return n=class extends(bn(ou,sd,Ur,su)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteAccessKeysModal=this.createModal(),this.deleteAccessKeysModal.setContent($n(yield this.fetchWidgetPage("delete-access-keys-modal.html")));const t=new Da((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteAccessKeysModal.close()));const i=new Da((()=>{var e;return null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=$c(this.state);this.actions.deleteAccessKeys(null==e?void 0:e.map((e=>e.id))),this.deleteAccessKeysModal.close()}));const n=new Qa(null===(e=this.deleteAccessKeysModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteAccessKeysModal.beforeOpen=()=>{const e=Rc(this.state);n.text=`Delete ${e}?`}}))},n})),vu=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,su,ou,gu)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),kc)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.deleteButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-access-keys"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteAccessKeysModal.open()}))},o})),mu=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,su,ou)(e)){constructor(){super(...arguments),t.add(this),i.set(this,In((()=>{this.actions.searchAccessKeys({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.searchInput=new ed(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,i,"f"))},o})),yu={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="currentcolor"/>\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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},bu=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,ou,dd,Fr)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Cn((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",n).call(this,e);r.setContent(u(this,t,"m",i).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),yc)}))}},o=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const i=yu[e],n=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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${n.outerHTML}`},n=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),$u=Rn((e=>class extends(bn(ja,ms,au,hu,vu,mu,lu,pu,bu)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),wu=bn((e=>class extends($u(e)){}))(HTMLElement);customElements.define("descope-access-key-management-widget",wu);var Cu,ku=Object.freeze({__proto__:null,default:wu});!function(e){e.oidc="oidc",e.saml="saml",e.wsfed="wsfed",e.custom="custom"}(Cu||(Cu={}));const Su=e=>e.ssoAppsList.data,Iu=Sl(Su,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>e.appType===Cu.saml))})),Ru=Sl(Su,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>{var t;return e.appType===Cu.oidc&&(null===(t=e.oidcSettings)||void 0===t?void 0:t.customIdpInitiatedLoginPageUrl)}))})),xu=Sl(Su,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>{var t;return e.appType===Cu.wsfed&&(null===(t=e.wsfedSettings)||void 0===t?void 0:t.idpInitiatedUrl)}))})),Ou=Sl(Su,(e=>{var t;return null===(t=null==e?void 0:e.filter)||void 0===t?void 0:t.call(e,(e=>e.appType===Cu.custom))})),Eu=e=>{var t,i,n,o;switch(e.appType){case Cu.saml:return null===(t=e.samlSettings)||void 0===t?void 0:t.idpInitiatedUrl;case Cu.oidc:return null===(i=e.oidcSettings)||void 0===i?void 0:i.customIdpInitiatedLoginPageUrl;case Cu.wsfed:return null===(n=e.wsfedSettings)||void 0===n?void 0:n.idpInitiatedUrl;case Cu.custom:return null===(o=e.customSettings)||void 0===o?void 0:o.loginPageUrl;default:return}},Au=Sl(Iu,Ru,xu,Ou,((e,t,i,n)=>[...e,...t,...i,...n].map((e=>({name:e.name,icon:e.logo,url:Eu(e)}))))),Nu=nc("ssoApps/load",((e,{extra:{api:t}})=>t.ssoApps.load())),ju=(e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))})(Nu)({onFulfilled:(e,t)=>{var i;e.ssoAppsList.data=null===(i=t.payload)||void 0===i?void 0:i.apps}},(Mu=e=>e.ssoAppsList,{onFulfilled:e=>{Mu(e).loading=!1},onPending:e=>{Mu(e).loading=!0,Mu(e).error=null},onRejected:(e,t)=>{Mu(e).loading=!1,Mu(e).error=t.error}}));var Mu;const Pu={action:Nu,reducer:ju},Uu={ssoAppsList:{data:[],loading:!1,error:null}},Tu="/v1/mgmt/sso/idp/apps/load",Wu=({httpClient:e,mock:t})=>({load:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"ssoapp1",name:"App 1",description:"This is the first SAML app",enabled:!0,appType:Cu.saml,logo:"logo1",samlSettings:{idpInitiatedUrl:""}},{id:"ssoapp2",name:"App 2",description:"This is the first OIDC app",enabled:!0,appType:Cu.oidc,logo:"logo2"},{id:"ssoapp3",name:"App 3",description:"This is the second SAML app",enabled:!0,appType:Cu.saml,logo:"logo3",samlSettings:{idpInitiatedUrl:""}},{id:"ssoapp4",name:"App 4",description:"This is a WS-Fed app",enabled:!0,appType:Cu.wsfed,logo:"logo4",wsfedSettings:{idpInitiatedUrl:"http://localhost/wsfed/idp-initiated",realm:"urn:mock:realm",replyUrl:"http://localhost/reply",loginPageUrl:"http://localhost/login"}}]})}))}));const i=yield e.get(Tu);return yield(e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})))(i),i.json()}))}),Lu=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,vc,Kr)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i)=>{const n=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"applications-portal-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.7.4"}}));return{ssoApps:Wu({httpClient:n.httpClient,mock:t})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},o})),Du=Rn((e=>{const t=bn(hc({name:"widget",initialState:Uu,reducers:{},extraReducers:e=>{Pu.reducer(e)},asyncActions:{loadSSOApps:Pu.action}}),Fr,Ur,Lu)(e);return class extends t{constructor(...e){super(...e),this.state=Uu,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),_u=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`applications-portal-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Fu=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,Fr,os,cs,_u,Du)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this);const[r]=yield Promise.all([u(this,t,"m",i).call(this),this.actions.loadSSOApps()]);u(this,t,"m",n).call(this,r),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},n=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},o})),qu=Rn((e=>{var t,i,n;return n=class extends(bn(Du,Ur,Fu)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this,Au(this.state))}))}},t=new WeakSet,i=function(e){this.appsList=new Wa((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-apps-list")}),{logger:this.logger}),this.appsList.data=e},n})),Bu=Rn((e=>class extends(bn(ja,ms,qu)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Vu=bn((e=>class extends(Bu(e)){}))(HTMLElement);customElements.define("descope-applications-portal-widget",Vu);var Ku=Object.freeze({__proto__:null,default:Vu});const Hu=(e,t)=>t?{[e]:t}:{},zu=e=>{if(!e)return;const t=JSON.parse(e);return Array.isArray(t)&&0===t.length?void 0:t},Gu=e=>e.selectedAuditId,Ju=Sl((e=>e.auditList.data),(e=>e.map((e=>{const t=e||{},{occurred:i,ID:n,type:o}=t,r=t.data,s=void 0===r?{saml_request:"",saml_response:"",saml_generated_user:"",saml_generated_roles:"",oidc_response:"",oidc_generated_user:"",scim_request:"",scim_result:"",Change:""}:r,{saml_request:a,saml_response:d,saml_generated_user:c,saml_generated_roles:u,oidc_response:h,oidc_generated_user:f,scim_request:p,scim_result:g,Change:v}=s,m=l(s,["saml_request","saml_response","saml_generated_user","saml_generated_roles","oidc_response","oidc_generated_user","scim_request","scim_result","Change"]),y=l(t,["occurred","ID","type","data"]);var b;return(e=>Object.fromEntries(Object.entries(e).filter((([e,t])=>!!t))))(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},y),{data:m}),Hu("type",(b=o)&&b[0].toUpperCase()+b.slice(1))),Hu("saml_request",a)),Hu("saml_response",d)),Hu("saml_generated_user",zu(c))),Hu("saml_generated_roles",zu(u))),Hu("oidc_response",zu(h))),Hu("oidc_generated_user",zu(f))),Hu("scim_request",p)),Hu("scim_result",g)),Hu("Change",v)),{occurredFormatted:i?new Date(Number(i)||0).toLocaleString():"N/A"}))}))));Sl(Gu,Ju,((e,t)=>t.find((t=>e===t.id)))),Sl(Gu,(e=>!!e));const Zu=nc("audit/search",((e,{extra:{api:t},getState:i})=>{const n=i().searchParams;return t.audit.search(Object.assign(Object.assign({},n),e))})),Yu=(e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))})(Zu)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(Xu=e=>e.auditList,{onFulfilled:e=>{Xu(e).loading=!1},onPending:e=>{Xu(e).loading=!0,Xu(e).error=null},onRejected:(e,t)=>{Xu(e).loading=!1,Xu(e).error=t.error}}));var Xu;const Qu={action:Zu,reducer:Yu},eh={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""},th="/v1/mgmt/audit/search",ih=({httpClient:e,tenant:t,mock:i})=>({search:(...n)=>c(void 0,[...n],void 0,(function*({page:n,limit:o=1e4,text:r,sort:s,from:a}={}){if(i)return(e=>c(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((i=>{const n=[],o=(new Date).getTime()/1e3+2592e3,r=new Date(o).toLocaleString();for(let e=1;e<9;e+=1)n.push({id:`Audit ${e}`,action:`Action ${e}`,actorId:`Actor ${e}`,type:"info",method:`Method ${e}`,userId:`User ${e}`,device:`Device ${e}`,geo:`Geo ${e}`,remoteAddress:`127.0.0.${e}`,externalIds:[`Login ID ${e}`],occurred:o,occurredFormatted:r});t.forEach((e=>{n.sort(((t,i)=>{var n,o;return e.desc?null===(o=i[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(n=t[e.field])||void 0===n?void 0:n.localeCompare(i[e.field])}))})),i(n.filter((t=>t.id.toLowerCase().includes(e.toLowerCase())||t.action.toLowerCase().includes(e.toLowerCase())||t.type.toLowerCase().includes(e.toLowerCase())||t.device.toLowerCase().includes(e.toLowerCase())||t.method.toLowerCase().includes(e.toLowerCase())||t.geo.toLowerCase().includes(e.toLowerCase())||t.remoteAddress.toLowerCase().includes(e.toLowerCase())||t.externalIds.includes(e.toLowerCase())||t.userId.toLowerCase().includes(e.toLowerCase()))))}))})))({page:n,limit:o,text:r,sort:s});const d=yield e.post(th,{limit:o,page:n,text:r,sort:s,from:a},{queryParams:{tenant:t}});return yield(e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})))(d),(yield d.json()).audits}))}),nh=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,Kr,vc,Br({tenant:Br.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i,n)=>{const o=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"audit-management-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.7.4"}}));return{audit:ih({httpClient:o.httpClient,tenant:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),oh=Rn((e=>{const t=bn(hc({name:"widget",initialState:eh,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{Qu.reducer(e)},asyncActions:{searchAudit:Qu.action}}),Fr,Ur,nh)(e);return class extends t{constructor(...e){super(...e),this.state=eh,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),rh=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`audit-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),sh=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,rh,oh)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([u(this,t,"m",i).call(this)]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),ah=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,sh,oh)(e)){constructor(){super(...arguments),t.add(this),i.set(this,In((()=>{const e=this.rangeInput.value,t=new Date;let i;switch(e){case"minuets15":i=t.setMinutes(t.getMinutes()-15);break;case"hour":i=t.setHours(t.getHours()-1);break;case"hour6":i=t.setHours(t.getHours()-6);break;case"day":default:i=t.setDate(t.getDate()-1);break;case"day3":i=t.setDate(t.getDate()-3);break;case"week":i=t.setDate(t.getDate()-7);break;case"week2":i=t.setDate(t.getDate()-14);break;case"month":i=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(i).getTime())})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this),u(this,t,"m",o).call(this)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.searchInput=new ed(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,i,"f")),u(this,i,"f").call(this)},o=function(){var e;this.rangeInput=new Xa(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(u(this,i,"f"))},r})),dh=Rn((e=>{var t,i,n,o;return o=class extends(bn(oh,Ur,sh)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),u(this,n,"f").call(this,Ju(this.state)),this.subscribe(u(this,n,"f").bind(this),Ju)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.auditTable=new Va(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="audit-table"]'),{logger:this.logger}),this.auditTable.onSelectedItemsChange((e=>{this.actions.setSelectedAuditId(e.detail.value.map((({id:e})=>e)))}))},o})),lh=[{header:"Occurred",path:"occurredFormatted"},{header:"User ID",path:"userId"},{header:"Actor",path:"actorId"},{header:"Login IDs",path:"externalIds"},{header:"Remote Address",path:"remoteAddress"},{header:"Type",path:"type"},{header:"Action",path:"action"},{header:"Device",path:"device"},{header:"Method",path:"method"},{header:"Geo",path:"geo"}],ch=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,sh,oh)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.exportButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="export-button"]'),{logger:this.logger}),this.exportButton.onClick((()=>{const e=Ju(this.state);if(!e.length)return void this.logger.warn("No audit data to export");const t=((e,t)=>[t.map((e=>Pn(e.header))).join(","),...e.map((e=>t.map((t=>Pn(e[t.path]))).join(",")))].join("\n"))(e,lh);((e,t)=>{const i=new Blob(["\ufeff"+e],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.setAttribute("download",t),document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)})(t,`audit_logs_${(new Date).toISOString().slice(0,10)}.csv`)}))},n})),uh=Rn((e=>class extends(bn(ja,ms,dh,ah,ch)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),hh=bn((e=>class extends(uh(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",hh);var fh=Object.freeze({__proto__:null,default:hh});const ph=(e={})=>{const t=$n("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,i])=>{t.content.querySelector("descope-wc").setAttribute(kn(e),i)})),t};function gh(e){return new URLSearchParams(window.location.search).get(e)}const vh=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},mh=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),yh=nc("outboundApps/load",((e,{extra:{api:t}})=>t.outboundApps.getAllOutboundApps())),bh=vh(yh)({onFulfilled:(e,t)=>{var i;e.outboundAppsList.data=null===(i=t.payload)||void 0===i?void 0:i.apps}},mh((e=>e.outboundAppsList))),$h={action:yh,reducer:bh},wh=nc("outboundApps/getConnectedOutboundApps",((e,{extra:{api:t}})=>t.outboundApps.getConnectedOutboundApps(e))),Ch=vh(wh)({onFulfilled:(e,t)=>{var i;e.connectedOutboundAppsIds.data=null===(i=t.payload)||void 0===i?void 0:i.appIds}},mh((e=>e.connectedOutboundAppsIds))),kh={action:wh,reducer:Ch},Sh={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}},Ih="/v1/mgmt/outbound/apps",Rh="/v1/mgmt/outbound/apps-with-user-token",xh="/v1/auth/me",Oh=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),Eh=({httpClient:e,mock:t})=>({getAllOutboundApps:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:[{id:"appId1",name:"Application 1",description:"Description"},{id:"appId2",name:"Application 2",description:"Description"},{id:"appId3",name:"Application 3",description:"Description"}]})}))}));const i=yield e.get(Ih);return yield Oh(i),i.json()})),getConnectedOutboundApps:i=>c(void 0,[i],void 0,(function*({userId:i,tenantId:n}){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({apps:["outboundApp3"]})}))}));const o=yield e.get(Rh,{queryParams:n?{userId:i,tenantId:n}:{userId:i}});return yield Oh(o),o.json()}))}),Ah=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({userId:"user-1"})}))}));const i=yield e.get(xh);return yield Oh(i),i.json()}))}),Nh=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,vc,Kr)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||us}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i)=>{const n=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.3.5"}}));return{outboundApps:Eh({httpClient:n.httpClient,mock:t}),user:Object.assign({},Ah({httpClient:n.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},o})),jh=nc("users/me",((e,{extra:{api:t}})=>t.user.me())),Mh={action:jh,reducer:vh(jh)({onFulfilled:(e,t)=>{e.me.data=t.payload}},mh((e=>e.me)))},Ph=Rn((e=>{const t=bn(hc({name:"widget",initialState:Sh,reducers:{setAllowedAppsIds:(e,{payload:t})=>{e.allowedAppsIds.data=t}},extraReducers:e=>{Mh.reducer(e),kh.reducer(e),$h.reducer(e)},asyncActions:{getMe:Mh.action,getOutboundApps:$h.action,getConnectedOutboundApps:kh.action}}),Fr,Ur,Nh)(e);return class extends t{constructor(...e){super(...e),this.state=Sh,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Uh="widget-flow",Th=Rn((e=>{var t,i,n;return n=class extends(bn(Fr,sd,Ph,vc,Ur,ms)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const o=gh(Uh);o&&(function(e){if(window.history.replaceState&&gh(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(Uh),u(this,t,"m",i).call(this,o))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(ph({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),new _a((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},n})),Wh=Sl((e=>e.outboundAppsList.data),(e=>e.connectedOutboundAppsIds.data),(e=>e.allowedAppsIds.data),((e,t,i)=>e.filter((e=>void 0===i||i.includes(e.id))).map((e=>{const i=(null==t?void 0:t.includes(e.id))||!1;return Object.assign(Object.assign({},e),{appId:e.id,isConnected:i})})).sort(((e,t)=>e.name.localeCompare(t.name))))),Lh=Sl((e=>e.me.data),(e=>e.userId)),Dh=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`outbound-applications-widget/${this.widgetId}/${e}`,"text")).body}))}}})),_h=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,Fr,os,cs,Dh,Ph)(e)){constructor(){super(...arguments),t.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(e,i,n){"allowed-outbound-apps-ids"===e&&i!==n&&this.actions.setAllowedAppsIds(u(this,t,"a",o))}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.init)||void 0===r?void 0:r.call(this),yield this.actions.getMe(),yield this.actions.setAllowedAppsIds(u(this,t,"a",o)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:Lh(this.state),tenantId:this.tenantId})]);const s=yield u(this,t,"m",i).call(this);u(this,t,"m",n).call(this,s),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(e),e}))},n=function(e){this.contentRootElement.append(e.content.cloneNode(!0))},o=function(){var e;if(!this.hasAttribute("allowed-outbound-apps-ids"))return;const t=null===(e=this.getAttribute("allowed-outbound-apps-ids"))||void 0===e?void 0:e.trim();return t?t.split(",").map((e=>e.trim())).filter(Boolean):[]},r})),Fh=Rn((e=>class extends(bn(ms,qr)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),qh=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g,v,m,y,b,$;return $=class extends(bn(Fh,Ph,Ur,_h,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),s.set(this,void 0),a.set(this,null),d.set(this,null),b.set(this,Cn((e=>{u(this,i,"f").data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",y).call(this,Wh(this.state)),u(this,t,"m",l).call(this),u(this,t,"m",g).call(this),this.subscribe(u(this,b,"f").bind(this),Wh)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,d=new WeakMap,b=new WeakMap,t=new WeakSet,l=function(){u(this,i,"f").connectFlowId&&(h(this,n,this.createModal({"data-id":"outbound-apps-connect"}),"f"),u(this,n,"f").afterClose=()=>{var e;if(u(this,a,"f")){const t=null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",u(this,a,"f")),h(this,a,null,"f")}},h(this,r,new _a((()=>{var e;return null===(e=u(this,n,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,r,"f")))},f=function(e,t,i){e.open(),t.removeEventListener("page-updated",i)},p=function(e,i){var n;const o=null===(n=e.ele)||void 0===n?void 0:n.querySelector("descope-wc"),r=()=>u(this,t,"m",f).call(this,e,o,r);i=r,null==o||o.addEventListener("page-updated",i)},g=function(){h(this,o,this.createModal({"data-id":"outbound-apps-disconnect"}),"f"),h(this,s,new _a((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=()=>{var e;if(u(this,d,"f")){const t=null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc");null==t||t.removeEventListener("page-updated",u(this,d,"f")),h(this,d,null,"f")}},this.syncFlowTheme(u(this,s,"f"))},v=function(e){u(this,n,"f").setContent(ph({projectId:this.projectId,flowId:u(this,i,"f").connectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:e})),u(this,t,"m",p).call(this,u(this,n,"f"),u(this,a,"f")),u(this,r,"f").onSuccess((()=>{u(this,n,"f").close(),this.actions.getConnectedOutboundApps({userId:Lh(this.state),tenantId:this.tenantId})}))},m=function(e){u(this,o,"f").setContent(ph({projectId:this.projectId,flowId:u(this,i,"f").disconnectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:e})),u(this,t,"m",p).call(this,u(this,o,"f"),u(this,d,"f")),u(this,s,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getConnectedOutboundApps({userId:Lh(this.state)})}))},y=function(e){h(this,i,new Ya((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),u(this,i,"f").onConnectClick((({id:e})=>{u(this,t,"m",v).call(this,e)})),u(this,i,"f").onDisconnectClick((({id:e})=>{u(this,t,"m",m).call(this,e)})),u(this,i,"f").data=e},$})),Bh=Rn((e=>class extends(bn(ja,ms,Th,qh)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Vh=bn((e=>class extends(Bh(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Na})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.3.5"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",Vh);var Kh=Object.freeze({__proto__:null,default:Vh});const Hh=e=>e.selectedRolesIds,zh=e=>e.notifications,Gh=e=>e.tenantPermissions.data||[],Jh=Sl((e=>e.rolesList.data),(e=>e.map((e=>{var t;return Object.assign(Object.assign({},e),{editable:0===(null===(t=null==e?void 0:e.tenantId)||void 0===t?void 0:t.length)?"no":"yes"})})))),Zh=Sl(Hh,Jh,((e,t)=>t.filter((t=>e.includes(t.name))))),Yh=Sl(Hh,(e=>!!e.length)),Xh=Sl(Hh,(e=>1===e.length)),Qh=Sl(Zh,Xh,((e,t)=>t&&"yes"===e[0].editable)),ef=Sl(Zh,(e=>1===e.length?e[0].name:`${e.length} roles`)),tf=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},nf=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),of=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{t&&e.notifications.push({type:"success",msg:t(i)})},onRejected:(t,i)=>{e&&t.notifications.push({type:"error",msg:e(i)})}}),rf=nc("roles/create",((e,{extra:{api:t}})=>t.role.create(e))),sf=tf(rf)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},nf((e=>e.createRole)),of({getSuccessMsg:()=>"Role created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),af={action:rf,reducer:sf},df=nc("roles/delete",((e,{extra:{api:t}})=>t.role.deleteBatch(e))),lf=tf(df)({onFulfilled:(e,t)=>{e.rolesList.data=e.rolesList.data.filter((e=>{var i;return 0===(null===(i=null==e?void 0:e.tenantId)||void 0===i?void 0:i.length)||!t.meta.arg.includes(e.name)})),e.selectedRolesIds=[]}},nf((e=>e.deleteRole)),of({getSuccessMsg:e=>Sn(e.meta.arg.length)`${["",e.meta.arg.length]} ${["R","r"]}ole${["","s"]} deleted successfully`,getErrorMsg:e=>Sn(e.meta.arg.length)`Failed to delete role${["","s"]}`})),cf={action:df,reducer:lf},uf=nc("roles/duplicate",((e,{extra:{api:t}})=>t.role.create(e))),hf=tf(uf)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},nf((e=>e.duplicateRole)),of({getSuccessMsg:()=>"Role duplicated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to duplicate role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),ff={action:uf,reducer:hf},pf=nc("roles/search",((e,{extra:{api:t},getState:i})=>{const n=i().searchParams;return t.role.search(Object.assign(Object.assign({},n),e))})),gf=tf(pf)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.rolesList.data=t.payload}},nf((e=>e.rolesList))),vf={action:pf,reducer:gf},mf=nc("roles/update",((e,{extra:{api:t}})=>t.role.update(e))),yf=tf(mf)({onFulfilled:(e,t)=>{const i=e.rolesList.data.findIndex((e=>e.name===t.payload.oldName));-1!==i&&(e.rolesList.data[i]=t.payload)}},nf((e=>e.updateRole)),of({getSuccessMsg:()=>"Role updated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to update role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),bf={action:mf,reducer:yf},$f=nc("tenant/getTenantPermissions",((e,{extra:{api:t}})=>t.tenant.getTenantPermissions())),wf={action:$f,reducer:tf($f)({onFulfilled:(e,t)=>{e.tenantPermissions.data=t.payload.permissions}},nf((e=>e.tenantPermissions)))},Cf={rolesList:{data:[],loading:!1,error:null},createRole:{loading:!1,error:null},duplicateRole:{loading:!1,error:null},updateRole:{loading:!1,error:null},deleteRole:{loading:!1,error:null},tenantPermissions:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedRolesIds:[],notifications:[]},kf="/v1/mgmt/role/search",Sf="/v1/mgmt/role/delete/batch",If="/v1/mgmt/role/create",Rf="/v1/mgmt/role/update",xf="/v1/mgmt/permission/all",Of=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),Ef=({httpClient:e,tenant:t,mock:i})=>({search:(...n)=>c(void 0,[...n],void 0,(function*({page:n,limit:o=1e4,text:r,sort:s}={}){if(i)return((e,t)=>c(void 0,[e,t],void 0,(function*({text:e,sort:t},i){return new Promise((n=>{const o=[];for(let e=1;e<10;e+=1)o.push({name:`Role ${e}`,description:`Role description ${e}`,permissionNames:[`Permission ${e}`],createdTime:new Date,tenantId:i});t.forEach((e=>{o.sort(((t,i)=>{var n,o;return e.desc?null===(o=i[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(n=t[e.field])||void 0===n?void 0:n.localeCompare(i[e.field])}))})),n(o.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()))))}))})))({page:n,limit:o,text:r,sort:s},t);const a=yield e.post(kf,{limit:o,page:n,text:r,sort:s},{queryParams:{tenant:t}});return yield Of(a),(yield a.json()).roles})),deleteBatch:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(Sf,{roleNames:n},{queryParams:{tenant:t}});return yield Of(o),o.json()})),create:n=>c(void 0,[n],void 0,(function*({name:n,description:o,permissionNames:r}){if(i)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,description:t,permissionNames:i},n){return new Promise((o=>{o({name:e,description:t,permissionNames:i,createdTime:new Date,tenantId:n})}))})))({name:n,description:o,permissionNames:r},t);const s=yield e.post(If,{name:n,description:o,permissionNames:r,tenantId:t},{queryParams:{tenant:t}});return yield Of(s),yield s.json()})),update:n=>c(void 0,[n],void 0,(function*({name:n,newName:o,description:r,permissionNames:s}){if(i)return((e,t)=>c(void 0,[e,t],void 0,(function*({name:e,newName:t,description:i,permissionNames:n},o){return new Promise((r=>{r({name:t,description:i,permissionNames:n,createdTime:new Date,oldName:e,tenantId:o})}))})))({name:n,newName:o,description:r,permissionNames:s},t);const a=yield e.post(Rf,{name:n,newName:o,description:r,permissionNames:s,tenantId:t},{queryParams:{tenant:t}});yield Of(a);const d=yield a.json();return d.oldName=n,d}))}),Af=({httpClient:e,tenant:t,mock:i})=>({getTenantPermissions:()=>c(void 0,void 0,void 0,(function*(){if(i)return new Promise((e=>{const t=[];for(let e=1;e<5;e+=1)t.push({name:`Permission ${e}`});e({permissions:t})}));const n=yield e.get(xf,{queryParams:{tenant:t}});return yield Of(n),n.json()}))}),Nf=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,Kr,vc,Br({tenant:Br.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i,n)=>{const o=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"role-management-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.7.2"}}));return{role:Ef({httpClient:o.httpClient,tenant:t,mock:i}),tenant:Af({httpClient:o.httpClient,tenant:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),jf=Rn((e=>{const t=bn(hc({name:"widget",initialState:Cf,reducers:{setSelectedRolesIds:(e,{payload:t})=>{e.selectedRolesIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{af.reducer(e),ff.reducer(e),bf.reducer(e),cf.reducer(e),vf.reducer(e),wf.reducer(e)},asyncActions:{searchRoles:vf.action,createRole:af.action,duplicateRole:ff.action,updateRole:bf.action,deleteRoles:cf.action,getTenantPermissions:wf.action}}),Fr,Ur,Nf)(e);return class extends t{constructor(...e){super(...e),this.state=Cf,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Mf=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`role-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Pf=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,Mf,jf)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([u(this,t,"m",i).call(this),this.actions.searchRoles(),this.actions.getTenantPermissions()]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),Uf=Rn((e=>{var t,i,n,o,r,s,a;return a=class extends(bn(jf,sd,fc,Ur,Pf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,"create"),o.set(this,null),s.set(this,(()=>c(this,void 0,void 0,(function*(){var e;yield u(this,i,"f").setData(null===(e=Gh(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}openRoleModal(e="create",t){h(this,n,e,"f"),h(this,o,null!=t?t:null,"f"),this.roleFormModal.open()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",r).call(this)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,s=new WeakMap,t=new WeakSet,r=function(){return c(this,void 0,void 0,(function*(){this.roleFormModal=this.createModal(),this.roleFormModal.setContent($n(yield this.fetchWidgetPage("create-role-modal.html"))),new Da((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>{this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)})),new Da((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){if(this.validateForm(this.roleFormModal.ele)){const e=this.getFormData(this.roleFormModal.ele);"duplicate"===u(this,n,"f")?this.actions.duplicateRole(Object.assign({},e)):this.actions.createRole(Object.assign({},e)),this.roleFormModal.close(),this.resetFormData(this.roleFormModal.ele)}})))),h(this,i,new Ja((()=>{var e;return null===(e=this.roleFormModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),u(this,s,"f").call(this),this.roleFormModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){yield u(this,s,"f").call(this),u(this,o,"f")&&(this.setFormData(this.roleFormModal.ele,u(this,o,"f")),h(this,o,null,"f"))}))}))},a})),Tf=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Uf,Pf)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.createButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-role"]'),{logger:this.logger}),this.createButton.onClick((()=>this.openRoleModal()))},n})),Wf=Rn((e=>{var t,i,n;return n=class extends(bn(jf,sd,Ur,Pf)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteRolesModal=this.createModal(),this.deleteRolesModal.setContent($n(yield this.fetchWidgetPage("delete-roles-modal.html")));const t=new Da((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteRolesModal.close()));const i=new Da((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=Zh(this.state);this.actions.deleteRoles(null==e?void 0:e.map((e=>e.name))),this.deleteRolesModal.close()}));const n=new Qa(null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteRolesModal.beforeOpen=()=>{const e=ef(this.state);n.text=`Delete ${e}?`}}))},n})),Lf=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,Pf,jf,Wf)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),Yh)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.deleteButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-roles"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteRolesModal.open()}))},o})),Df=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,Pf,jf,Uf)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.duplicateButton.enable():this.duplicateButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),Xh)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.duplicateButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="duplicate-role"]'),{logger:this.logger}),this.duplicateButton.disable(),this.duplicateButton.onClick((()=>{var e,t,i;const n=null===(e=Zh(this.state))||void 0===e?void 0:e[0];n&&this.openRoleModal("duplicate",{name:`${n.name} Copy`,description:null!==(t=n.description)&&void 0!==t?t:"",permissionNames:null!==(i=n.permissionNames)&&void 0!==i?i:[]})}))},o})),_f=Rn((e=>{var t,i,n,o,r,s,a,d;return d=class extends(bn(jf,sd,Ur,fc,Pf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),r.set(this,(()=>c(this,void 0,void 0,(function*(){var e;yield u(this,i,"f").setData(null===(e=Gh(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))})))),s.set(this,(()=>{var e;const t=null===(e=Zh(this.state))||void 0===e?void 0:e[0],i={name:null==t?void 0:t.name,description:null==t?void 0:t.description,permissionNames:null==t?void 0:t.permissionNames};this.setFormData(this.editRoleModal.ele,i)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",a).call(this)}))}},i=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,n=function(){new Da((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editRoleModal.close()))},o=function(){new Da((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{var e;if(this.validateForm(this.editRoleModal.ele)){const t=this.getFormData(this.editRoleModal.ele),{name:i}=t,n=l(t,["name"]),o=null===(e=Zh(this.state))||void 0===e?void 0:e[0];this.actions.updateRole(Object.assign({newName:i,name:o.name},n)),this.editRoleModal.close(),this.resetFormData(this.editRoleModal.ele)}}))},a=function(){return c(this,void 0,void 0,(function*(){this.editRoleModal=this.createModal(),this.editRoleModal.setContent($n(yield this.fetchWidgetPage("edit-role-modal.html"))),u(this,t,"m",n).call(this),u(this,t,"m",o).call(this),h(this,i,new Ja((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),this.editRoleModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){yield u(this,r,"f").call(this),u(this,s,"f").call(this)}))}))},d})),Ff=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,Pf,jf,_f,fc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),this.subscribe(u(this,n,"f").bind(this),Qh)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.editButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-role"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editRoleModal.open()}))},o})),qf=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,Pf,jf)(e)){constructor(){super(...arguments),t.add(this),i.set(this,In((()=>{this.actions.searchRoles({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.searchInput=new ed(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,i,"f"))},o})),Bf={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="currentcolor"/>\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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Vf=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,jf,dd,Fr)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Cn((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",n).call(this,e);r.setContent(u(this,t,"m",i).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),zh)}))}},o=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const i=Bf[e],n=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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${n.outerHTML}`},n=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),Kf=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(jf,Ur,Pf)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{this.rolesTable.data=e}))),o.set(this,In(((e,t)=>{const i=[],{value:n}=t;if(n){const t=e.path;i.push({field:t,desc:"desc"===n})}this.actions.searchRoles({sort:i})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var r;yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this),u(this,t,"m",i).call(this),this.rolesTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,o,"f").call(this,e.target,e.detail)}))})),u(this,n,"f").call(this,Jh(this.state)),this.subscribe(u(this,n,"f").bind(this),Jh)}))}},n=new WeakMap,o=new WeakMap,t=new WeakSet,i=function(){var e;this.rolesTable=new Va(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="roles-table"]'),{logger:this.logger}),this.rolesTable.onSelectedItemsChange((e=>{this.actions.setSelectedRolesIds(e.detail.value.map((({name:e})=>e)))}))},r})),Hf=Rn((e=>class extends(bn(ja,ms,Kf,Tf,Lf,Df,Ff,qf,Vf)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),zf=bn((e=>class extends(Hf(e)){}))(HTMLElement);customElements.define("descope-role-management-widget",zf);var Gf=Object.freeze({__proto__:null,default:zf});const Jf=(e={})=>{const t=$n("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,i])=>{t.content.querySelector("descope-wc").setAttribute(kn(e),i)})),t};function Zf(e){return new URLSearchParams(window.location.search).get(e)}const Yf=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},Xf=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),Qf=nc("users/me",((e,{extra:{api:t}})=>t.user.me())),ep=Yf(Qf)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Xf((e=>e.me))),tp={action:Qf,reducer:ep},ip=nc("tenant/details",((e,{extra:{api:t}})=>t.tenant.details())),np=Yf(ip)({onFulfilled:(e,t)=>{e.tenant.data=t.payload}},Xf((e=>e.tenant))),op={action:ip,reducer:np},rp=nc("tenant/adminLinkSso",((e,{extra:{api:t}})=>t.tenant.adminLinkSso())),sp={action:rp,reducer:Yf(rp)({onFulfilled:(e,t)=>{var i;e.tenantAdminLinkSSO.data=(null===(i=t.payload)||void 0===i?void 0:i.adminSSOConfigurationLink)||""}},Xf((e=>e.tenantAdminLinkSSO)))},ap={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:""}},dp="/v1/auth/me",lp="/v1/mgmt/tenant",cp="/v1/mgmt/tenant/adminlinks/sso/authenticated",up=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),hp=({httpClient:e,tenantId:t,mock:i})=>{const n=encodeURIComponent(t||""),o=`?tenant=${n}&id=${n}`;return{details:()=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))}));if(!t)throw new Error("tenantId is not defined");const n=`${lp}${o}`,r=yield e.get(n);return yield up(r),yield r.json()})),adminLinkSso:()=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({adminSSOConfigurationLink:"_blank"})}))}));if(!t)throw new Error("tenantId is not defined");const o=yield e.post(`${cp}?tenant=${n}`,{tenantId:n},{headers:{"Content-Type":"application/json"}});return yield up(o),yield o.json()}))}},fp=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))}));const i=yield e.get(dp);return yield up(i),i.json()}))}),pp=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,Kr,vc)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||us}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i,n)=>{const o=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.6.5"}}));return{user:fp({httpClient:o.httpClient,mock:i}),tenant:hp({httpClient:o.httpClient,tenantId:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),gp=Rn((e=>{const t=bn(hc({name:"widget",initialState:ap,reducers:{},extraReducers:e=>{tp.reducer(e),op.reducer(e),sp.reducer(e)},asyncActions:{getMe:tp.action,getTenant:op.action,getTenantAdminLinkSSO:sp.action}}),Fr,Ur,pp)(e);return class extends t{constructor(...e){super(...e),this.state=ap,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),vp="widget-flow",mp=Rn((e=>{var t,i,n;return n=class extends(bn(Fr,sd,gp,vc,Ur,ms)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const o=Zf(vp);o&&(function(e){if(window.history.replaceState&&Zf(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(vp),u(this,t,"m",i).call(this,o))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(Jf({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),new _a((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()})),t.afterClose=()=>{t.remove()},t.open()},n})),yp=e=>e.tenant.data,bp=e=>e.tenantAdminLinkSSO.data,$p=Sl(yp,(e=>e.customAttributes||{})),wp=Sl(yp,(e=>e.name||"")),Cp=Sl(yp,(e=>e.selfProvisioningDomains||[])),kp=Sl(yp,(e=>e.enforceSSOExclusions||[])),Sp=Sl(yp,(e=>e.enforceSSO||!1)),Ip=Rn((e=>class extends(bn(ms,qr)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Rp=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`tenant-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),xp=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,Rp,gp)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()])}catch(n){}const o=this.state.me.error||(()=>this.state.tenant.error)()||(()=>this.state.tenantAdminLinkSSO.error)();if(o){this.contentRootElement.innerHTML="";const e="object"==typeof o&&null!==o&&"message"in o?o.message:String(o)||"An error occurred";this.contentRootElement.append(function({mainMessage:e="An error occurred"}){const t=document.createElement("div");t.setAttribute("data-id","widget-error"),t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="72px 36px",t.style.background="#fff",t.style.borderRadius="12px",t.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",t.style.margin="32px auto",t.style.maxWidth="400px";const i=document.createElement("div");i.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',i.style.marginBottom="12px",t.appendChild(i);const n=document.createElement("div");return n.textContent=e,n.style.fontWeight="bold",n.style.fontSize="20px",n.style.color="#222",n.style.textAlign="center",n.style.marginTop="8px",t.appendChild(n),t}({mainMessage:e}))}else yield u(this,t,"m",i).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),Op=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ip,gp,Ur,xp,vc,sd)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{this.tenantAdminLinkSSODriver.href=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),u(this,t,"m",i).call(this),u(this,n,"f").call(this,bp(this.state)),this.subscribe(u(this,n,"f").bind(this),bp)}))}},n=new WeakMap,t=new WeakSet,i=function(){this.tenantAdminLinkSSODriver=new Ka((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},o}));var Ep;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Ep||(Ep={}));const Ap=Rn((e=>{var t,i,n,o,r,s,a,d,l,h,f;return f=class extends(bn(Ip,gp,Ur,xp,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,{}),n.set(this,{}),o.set(this,{}),r.set(this,{}),d.set(this,Cn((e=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||Ep.TEXT,r=e[n],s=new td(i,{logger:this.logger});s.value=((e,t)=>e===Ep.DATE&&t?new Date(t).toLocaleString():e===Ep.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString())(o,r),u(this,t,"m",l).call(this,i,n,s,o,n),u(this,t,"m",h).call(this,i,n,s)}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),u(this,d,"f").call(this,$p(this.state)),this.subscribe(u(this,d,"f").bind(this),$p)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,d=new WeakMap,t=new WeakSet,s=function(e,t,o){var r,s;const a=$p(this.state)[o],d=t===Ep.ARRAY?(a||[]).join(","):a;null===(r=u(this,i,"f")[e])||void 0===r||r.setContent(Jf({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({customAttributes:{[o]:d}})})),null===(s=u(this,n,"f")[e])||void 0===s||s.onSuccess((()=>{var t;null===(t=u(this,i,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},a=function(e){var t,i;null===(t=u(this,o,"f")[e])||void 0===t||t.setContent(Jf({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(i=u(this,r,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=u(this,o,"f")[e])||void 0===t||t.close(),this.actions.getTenant()}))},l=function(e,o,r,a,d){const l=e.getAttribute("edit-flow-id");l&&(u(this,i,"f")[l]||(u(this,i,"f")[l]=this.createModal({"data-id":`edit-${o}`}),u(this,n,"f")[l]=new _a((()=>{var e,t;return null===(t=null===(e=u(this,i,"f")[l])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,i,"f")[l].beforeOpen=u(this,t,"m",s).bind(this,l,a,d),r.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,i,"f"))||void 0===e?void 0:e[l])||void 0===t||t.open()})),this.syncFlowTheme(u(this,n,"f")[l])))},h=function(e,i,n){const s=e.getAttribute("delete-flow-id");s&&(u(this,o,"f")[s]||(u(this,o,"f")[s]=this.createModal({"data-id":`delete-${i}`}),u(this,r,"f")[s]=new _a((()=>{var e,t;return null===(t=null===(e=u(this,o,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,o,"f")[s].beforeOpen=u(this,t,"m",a).bind(this,s),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,o,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),this.syncFlowTheme(u(this,r,"f")[s])))},f})),Np=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Ip,gp,Ur,xp,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.tenantEmailDomainsDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,Cp(this.state)),this.subscribe(u(this,p,"f").bind(this),Cp)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantEmailDomainsDriver.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(Jf({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({tenantEmailDomains:Cp(this.state)})})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),h(this,r,new _a((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(Jf({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEmailDomainsDriver=new td((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),jp=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Ip,gp,Ur,xp,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.tenantSSOExclusionsDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,kp(this.state)),this.subscribe(u(this,p,"f").bind(this),kp)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantSSOExclusionsDriver.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(Jf({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({enforceSSOExclusions:kp(this.state)})})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),h(this,r,new _a((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(Jf({projectId:this.projectId,flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantSSOExclusionsDriver=new td((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),Mp=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Ip,gp,Ur,xp,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.tenantEnforceSSODriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,Sp(this.state)),this.subscribe(u(this,p,"f").bind(this),Sp)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.tenantEnforceSSODriver.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").beforeOpen=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(Jf({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({enforceSSO:Sp(this.state)})})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},d=function(){this.tenantEnforceSSODriver.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),h(this,r,new _a((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").beforeOpen=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(Jf({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEnforceSSODriver=new td((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),Pp=Rn((e=>{var t,i,n,o,r,s,a,d;return d=class extends(bn(Ip,gp,Ur,xp,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),a.set(this,Cn((e=>{this.tenantNameDriver.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this),u(this,a,"f").call(this,wp(this.state)),this.subscribe(u(this,a,"f").bind(this),wp)}))}},i=new WeakMap,n=new WeakMap,a=new WeakMap,t=new WeakSet,o=function(){this.tenantNameDriver.editFlowId&&(h(this,i,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").beforeOpen=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,n,"f")))},r=function(){u(this,i,"f").setContent(Jf({projectId:this.projectId,flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:JSON.stringify({tenantName:wp(this.state)})})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},s=function(){this.tenantNameDriver=new td((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},d})),Up=Rn((e=>{var t,i,n,o,r,s,a;return a=class extends(bn(Ip,gp,Ur,xp,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this)}))}},i=new WeakMap,n=new WeakMap,t=new WeakSet,o=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(h(this,i,this.createModal({"data-id":"password-policy"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,n,"f")))},r=function(){u(this,i,"f").setContent(Jf({projectId:this.projectId,flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},s=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new id((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},a})),Tp=Rn((e=>{var t,i,n,o,r,s,a;return a=class extends(bn(Ip,gp,Ur,xp,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this)}))}},i=new WeakMap,n=new WeakMap,t=new WeakSet,o=function(){this.TenantSessionSettingsUserAuthMethodDriver.flowId&&(h(this,i,this.createModal({"data-id":"session-settings"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,n,"f")))},r=function(){u(this,i,"f").setContent(Jf({projectId:this.projectId,flowId:this.TenantSessionSettingsUserAuthMethodDriver.flowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getTenant()}))},s=function(){this.TenantSessionSettingsUserAuthMethodDriver=new id((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="session-settings"]')}),{logger:this.logger}),this.TenantSessionSettingsUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},a})),Wp=Rn((e=>class extends(bn(ja,ms,mp,xp,Pp,Np,jp,Mp,Ap,Op,Up,Tp)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Lp=bn((e=>class extends(Wp(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Na})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.6.5"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",Lp);var Dp=Object.freeze({__proto__:null,default:Lp}),_p={version:4,country_calling_codes:{1:["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],383:["XK"],385:["HR"],386:["SI"],387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"],692:["MH"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],880:["BD"],886:["TW"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},countries:{AC:["247","00","(?:[01589]\\d|[46])\\d{4}",[5,6]],AD:["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]]],AE:["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0"],AF:["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0"],AG:["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([457]\\d{6})$|1","268$1",0,"268"],AI:["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2457]\\d{6})$|1","264$1",0,"264"],AL:["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0"],AM:["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0"],AO:["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]]],AR:["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1"],AS:["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"([267]\\d{6})$|1","684$1",0,"684"],AT:["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0"],AU:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"(183[12])|0",0,0,0,[["(?:(?:(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|7(?:[013-57-9]\\d|2[0-8]))\\d|3(?:(?:[0-3589]\\d|6[1-9]|7[0-35-9])\\d|4(?:[0-578]\\d|90)))\\d\\d|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4])|3\\d\\d)|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],AW:["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],AX:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],AZ:["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],BA:["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],BB:["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246"],BD:["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|2[23]"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],BE:["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],BF:["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],BG:["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],BH:["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[02-4679]"]]]],BI:["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]]],BJ:["229","00","(?:01\\d|[24-689])\\d{7}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["0"]]]],BL:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:2[7-9]|3[3-7]|5[12]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],BM:["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441"],BN:["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],BO:["591","00(?:1\\d)?","8001\\d{5}|(?:[2-467]\\d|50)\\d{6}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[235]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],BQ:["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],BR:["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-46-9]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37)","4(?:02|37)0|[34]00"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],BS:["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242"],BT:["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],BW:["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-9]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],BY:["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],BZ:["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],CA:["1","011","[2-9]\\d{9}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|9(?:0[25]|42))[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:2[125-9]|33|44|66|77|88)|6(?:22|33))[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CD:["243","00","(?:(?:[189]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["5"],"0$1"]],"0"],CF:["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],CG:["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],CH:["41","00","8\\d{11}|[2-9]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],CI:["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],CK:["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],CL:["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],CM:["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],CN:["86","00|1(?:[12]\\d|79)\\d\\d00","(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]","(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,0,"00"],CO:["57","00(?:4(?:[14]4|56)|[579])","(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["46"]],["(\\d{3})(\\d{7})","$1 $2",["6|90"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|91"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?"],CR:["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))"],CU:["53","119","(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["[56]"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],CV:["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],CW:["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],CX:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CY:["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],CZ:["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9,10,11,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],DE:["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[03568]","15(?:[0568]|31)"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8})","$1 $2 $3",["15"],"0$1"]],"0"],DJ:["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]]],DK:["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]]],DM:["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","767$1",0,"767"],DO:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9"],DZ:["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0"],EC:["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0"],EE:["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],EG:["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{8})","$1 $2",["1"],"0$1"]],"0"],EH:["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,"528[89]"],ER:["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0"],ES:["34","00","[5-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-9]"]]]],ET:["251","00","(?:11|[2-579]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-579]"],"0$1"]],"0"],FI:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d{5})","$1",["20[2-59]"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]0|[68])0|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[14]|2[09]|50|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"],["(\\d)(\\d{4,9})","$1 $2",["(?:19|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",0,"00"],FJ:["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,0,"00"],FK:["500","00","[2-7]\\d{4}",[5]],FM:["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]]],FO:["298","00","[2-9]\\d{5}",[6],[["(\\d{6})","$1",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))"],FR:["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0"],GA:["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})","$1"],GB:["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,0,0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0-35])|4(?:(?:[0-5]\\d|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|50))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-3]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],GD:["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473"],GE:["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],GF:["594","00","(?:[56]94\\d|7093)\\d{5}|(?:80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0"],GG:["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],GH:["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],GI:["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],GL:["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],GM:["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],GN:["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],GP:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],GQ:["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],GR:["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],GT:["502","00","80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-8]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],GU:["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","671$1",0,"671"],GW:["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]]],GY:["592","001","(?:[2-8]\\d{3}|9008)\\d{3}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],HK:["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,0,"00"],HN:["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]]],HR:["385","00","(?:[24-69]\\d|3[0-79])\\d{7}|80\\d{5,7}|[1-79]\\d{7}|6\\d{5,6}",[6,7,8,9],[["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6|7[245]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-57]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0"],HT:["509","00","(?:[2-489]\\d|55)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-589]"]]]],HU:["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06"],ID:["62","00[89]","00[1-9]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13,14,15,16,17],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0"],IE:["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0"],IL:["972","0(?:0|1[2-9])","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["15"]]],"0"],IM:["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([25-8]\\d{5})$|0","1624$1",0,"74576|(?:16|7[56])24"],IN:["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-7]|80[2-46]","11|2[02]|33|4[04]|79(?:[1-6]|7[19])|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9])|7(?:1|9[1-6]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|4[47]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67|72)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:2[14]|3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31|4[47])|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:(?:2[14]|5[15])[2-6]|3171|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|(?:74[47]|8(?:16|2[014]|3[126]|6[136]|7[78]|83))(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|28|3[129]|4[1-35689]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1(?:[013-8]|9[6-9])|28[6-8]|3(?:17|2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|83)|73179|807(?:1|9[1-3])|(?:1552|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[124-6])\\d|7(?:1(?:[013-8]\\d|9[6-9])|28[6-8]|3(?:2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]\\d|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["1(?:6|8[06])","1(?:6|8[06]0)"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0"],IO:["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]]],IQ:["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],IR:["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0"],IS:["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,0,"00"],IT:["39","00","0\\d{5,10}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:43|55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11,12],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[378]|43"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["3"]]],0,0,0,0,0,0,[["0669[0-79]\\d{1,6}|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}",[6,7,8,9,10,11]],["3[2-9]\\d{7,8}|(?:31|43)\\d{8}",[9,10]],["80(?:0\\d{3}|3)\\d{3}",[6,9]],["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}",[6,8,9,10]],["1(?:78\\d|99)\\d{6}",[9,10]],["3[2-8]\\d{9,10}",[11,12]],0,0,["55\\d{8}",[10]],["84(?:[08]\\d{3}|[17])\\d{3}",[6,9]]]],JE:["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([0-24-8]\\d{5})$|0","1534$1",0,0,[["1534[0-24-8]\\d{5}"],["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97\\d))\\d{5}"],["80(?:07(?:35|81)|8901)\\d{4}"],["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"],["701511\\d{4}"],0,["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}"],["56\\d{8}"]]],JM:["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876"],JO:["962","00","(?:(?:[2689]|7\\d)\\d|32|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],JP:["81","010","00[1-9]\\d{6,14}|[25-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51)|9(?:80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["3|4(?:2[09]|7[01])|6[1-9]","3|4(?:2(?:0|9[02-69])|7(?:0[019]|1))|6[1-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[0459]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[26-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9]|9[29])|5(?:2|3(?:[045]|9[0-8])|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3(?:[045]|9(?:[0-58]|6[4-9]|7[0-35689]))|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[25-9]"],"0$1"]],"0",0,"(000[259]\\d{6})$|(?:(?:003768)0?)|0","$1"],KE:["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0"],KG:["996","00","8\\d{9}|[235-9]\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0"],KH:["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],KI:["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0"],KM:["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]]],KN:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","869$1",0,"869"],KP:["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0"],KR:["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[36]0|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?"],KW:["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]]],KY:["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","345$1",0,"345"],KZ:["7","810","(?:33622|8\\d{8})\\d{5}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"33|7",0,"8~10"],LA:["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["30[0135-9]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0"],LB:["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-7]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0"],LC:["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"([2-8]\\d{6})$|1","758$1",0,"758"],LI:["423","00","[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2379]|8(?:0[09]|7)","[2379]|8(?:0(?:02|9)|7)"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"(1001)|0"],LK:["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0"],LR:["231","00","(?:[245]\\d|33|77|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["4[67]|[56]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-578]"],"0$1"]],"0"],LS:["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]]],LT:["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(0-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"0 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(0-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(0-$1)",1]],"0",0,"[08]"],LU:["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],LV:["371","00","(?:[268]\\d|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[269]|8[01]"]]]],LY:["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0"],MA:["212","00","[5-8]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-46-9]|3[3-9]|9)|8(?:0[89]|92)"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8"],"0$1"],["(\\d{3})(\\d{6})","$1-$2",["[5-7]"],"0$1"]],"0",0,0,0,0,0,[["5(?:2(?:[0-25-79]\\d|3[1-578]|4[02-46-8]|8[0235-7])|3(?:[0-47]\\d|5[02-9]|6[02-8]|8[014-9]|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-4]|5[01]|8[0-3]))\\d{6}"],["80[0-7]\\d{6}"],["89\\d{7}"],0,0,0,0,["(?:592(?:4[0-2]|93)|80[89]\\d\\d)\\d{4}"]]],MC:["377","00","(?:[3489]|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1"]],"0"],MD:["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0"],ME:["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0"],MF:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:0[079]|[14]3|[27][79]|3[03-7]|5[0-268]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],MG:["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1"],MH:["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],MK:["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],ML:["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],MM:["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|452|678|86","[12]|452|6788|86"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],MN:["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],MO:["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],MP:["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670"],MQ:["596","00","(?:596\\d|7091)\\d{5}|(?:69|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|8(?:0[6-9]|[36])"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],MR:["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],MS:["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664"],MT:["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],MU:["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],MV:["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],MW:["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],MX:["52","0[09]","[2-9]\\d{9}",[10],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"]]],0,0,0,0,0,0,0,"00"],MY:["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9]|53)|8","1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1(?:[367]|80)"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0"],MZ:["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-79]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],NA:["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],NC:["687","00","(?:050|[2-57-9]\\d\\d)\\d{3}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[02-57-9]"]]]],NE:["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[0467]"]]]],NF:["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1"],NG:["234","009","38\\d{6}|[78]\\d{9,13}|(?:20|9\\d)\\d{8}",[8,10,11,12,13,14],[["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["3"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["20[129]"],"0$1"],["(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],NI:["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],NL:["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],NP:["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],NR:["674","00","(?:444|(?:55|8\\d)\\d|666)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[4-68]"]]]],NU:["683","00","(?:[4-7]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],NZ:["64","0(?:0|161)","[1289]\\d{9}|50\\d{5}(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|8|90","50(?:[0367]|88)|8|90"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[589]"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7"],"0$1"]],"0",0,0,0,0,0,0,"00"],OM:["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]]],PA:["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]]],PE:["51","00|19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,0,"00"," Anexo "],PF:["689","00","4\\d{5}(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],PG:["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,0,"00"],PH:["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0"],PK:["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0"],PL:["48","00","(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|20|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]]],PM:["508","00","[45]\\d{5}|(?:708|8\\d\\d)\\d{6}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[45]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],PR:["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939"],PS:["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],PT:["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]]],PW:["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],PY:["595","00","59\\d{4,6}|9\\d{5,10}|(?:[2-46-8]\\d|5[0-8])\\d{4,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[26]1|3[289]|4[1246-8]|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0"],QA:["974","00","800\\d{4}|(?:2|800)\\d{6}|(?:0080|[3-7])\\d{7}",[7,8,9,11],[["(\\d{3})(\\d{4})","$1 $2",["2[16]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]]],RE:["262","00","709\\d{6}|(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"],"0$1"]],"0",0,0,0,0,0,[["26(?:2\\d\\d|3(?:0\\d|1[0-6]))\\d{4}"],["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[013]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-5]|76(?:2[278]|3[0-37]))\\d{4}"],["8(?:1[019]|2[0156]|84|90)\\d{6}"]]],RO:["40","00","(?:[236-8]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[236-9]"],"0$1"]],"0",0,0,0,0,0,0,0," int "],RS:["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0"],RU:["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"3[04-689]|[489]",0,"8~10"],RW:["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"]],"0"],SA:["966","00","92\\d{7}|(?:[15]|8\\d)\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0"],SB:["677","0[01]","[6-9]\\d{6}|[1-6]\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],SC:["248","010|0[0-2]","(?:[2489]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,0,"00"],SD:["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0"],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10,12],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0"],SG:["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-9]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],SH:["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]"],SI:["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[0139]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,0,"00"],SJ:["47","00","0\\d{4}|(?:[489]\\d|79)\\d{6}",[5,8],0,0,0,0,0,0,"79"],SK:["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1"]],"0"],SL:["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0"],SM:["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1"],SN:["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]]]],SO:["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d)(\\d{7})","$1 $2",["(?:2|90)4|[67]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[348]|64|79|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6[0-35-9]|77|9[2-9]"]]],"0"],SR:["597","00","(?:[2-5]|68|[78]\\d)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-8]"]]]],SS:["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0"],ST:["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]]],SV:["503","00","[267]\\d{7}|(?:80\\d|900)\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],SX:["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721"],SY:["963","00","[1-359]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-4]|5[1-3]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[59]"],"0$1",1]],"0"],SZ:["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],TA:["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],TC:["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649"],TD:["235","00|16","(?:22|[689]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"]]],0,0,0,0,0,0,0,"00"],TG:["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],TH:["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],TJ:["992","810","[0-57-9]\\d{8}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["44[02-479]|[34]7"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3(?:[1245]|3[12])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[0-57-9]"]]],0,0,0,0,0,0,0,"8~10"],TK:["690","00","[2-47]\\d{3,6}",[4,5,6,7]],TL:["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]]],TM:["993","810","(?:[1-6]\\d|71)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["[67]"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],TN:["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]]],TO:["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]]],TR:["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5(?:[0-59]|61)","5(?:[0-59]|61[06])","5(?:[0-59]|61[06]1)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],TT:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868"],TV:["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],TW:["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],TZ:["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],UA:["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],UG:["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],US:["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["(?:3052(?:0[0-8]|[1-9]\\d)|5056(?:[0-35-9]\\d|4[468]))\\d{4}|(?:305[3-9]|472[24]|505[2-57-9]|983[2-47-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[125-9]|33|44|66|77|88)[2-9]\\d{6}"],0,0,0,["305209\\d{4}"]]],UY:["598","0(?:0|1[3-9]\\d)","0004\\d{2,9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[6,7,8,9,10,11,12,13],[["(\\d{3})(\\d{3,4})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[49]0|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,0,"00"," int. "],UZ:["998","00","(?:20|33|[5-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-9]"]]]],VA:["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11,12],0,0,0,0,0,0,"06698"],VC:["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","784$1",0,"784"],VE:["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0"],VG:["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-578]\\d{6})$|1","284$1",0,"284"],VI:["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","340$1",0,"340"],VN:["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{7}|[16-8]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["80"],"0$1",1],["(\\d{4})(\\d{4,6})","$1 $2",["1"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["6"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[357-9]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0"],VU:["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]]],WF:["681","00","(?:40|72|8\\d{4})\\d{4}|[89]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[47-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],WS:["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],XK:["383","00","2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}",[8,9,10,11,12],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2|39"],"0$1"],["(\\d{2})(\\d{7,10})","$1 $2",["3"],"0$1"]],"0"],YE:["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7(?:[24-6]|8[0-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0"],YT:["262","00","7093\\d{5}|(?:80|9\\d)\\d{7}|(?:26|63)9\\d{6}",[9],0,"0",0,0,0,0,0,[["269(?:0[0-467]|15|5[0-4]|6\\d|[78]0)\\d{4}"],["(?:639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])|7093[5-7])\\d{4}"],["80\\d{7}"],0,0,0,0,0,["9(?:(?:39|47)8[01]|769\\d)\\d{4}"]]],ZA:["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],ZM:["260","00","800\\d{6}|(?:21|63|[79]\\d)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[79]"],"0$1"]],"0"],ZW:["263","00","2(?:[0-57-9]\\d{6,8}|6[0-24-9]\\d{6,7})|[38]\\d{9}|[35-8]\\d{8}|[3-6]\\d{7}|[1-689]\\d{6}|[1-3569]\\d{5}|[1356]\\d{4}",[5,6,7,8,9,10],[["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|2[278]|[49]8)|3(?:[09]8|17)|6(?:[29]8|37|75)|[23][78]|(?:33|5[15]|6[68])[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["24|8[13-59]|(?:2[05-79]|39|5[45]|6[15-8])2","2(?:02[014]|4|[56]20|[79]2)|392|5(?:42|525)|6(?:[16-8]21|52[013])|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[39]|2[0157]|[378]|[56][14])|3(?:12|29)","2(?:1[39]|2[0157]|[378]|[56][14])|3(?:123|29)"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|12|29|[56])|3(?:1[0-689]|[24-6])|5(?:[0236-9]|1[2-4])|6(?:[013-59]|7[0-46-9])|(?:33|55|6[68])[0-69]|(?:29|3[09]|62)[0-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]|39|54"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["(?:25|54)8","258|5483"],"0$1"]],"0"]},nonGeographic:{800:["800",0,"(?:00|[1-9]\\d)\\d{6}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:00|[1-9]\\d)\\d{6}"]]],808:["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],870:["870",0,"7\\d{11}|[235-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"],0,0,0,0,0,0,["2\\d{8}",[9]]]],878:["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],881:["881",0,"6\\d{9}|[0-36-9]\\d{8}",[9,10],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-37-9]"]],["(\\d)(\\d{3})(\\d{5,6})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["6\\d{9}|[0-36-9]\\d{8}"]]],882:["882",0,"[13]\\d{6}(?:\\d{2,5})?|[19]\\d{7}|(?:[25]\\d\\d|4)\\d{7}(?:\\d{2})?",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["49"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1[36]|9"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|23|3(?:[15]|4[57])|4|51"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-35]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|(?:3(?:2|47|7\\d{3})|50\\d{3})\\d{7}",[7,8,9,10,12]],0,0,0,["348[57]\\d{7}",[11]],0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:345\\d|9[89])\\d{6}|(?:10|2(?:3|85\\d)|3(?:[15]|[69]\\d\\d)|4[15-8]|51)\\d{8}"]]],883:["883",0,"(?:[1-4]\\d|51)\\d{6,10}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,8})","$1 $2 $3",["[14]|2[24-689]|3[02-689]|51[24-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["21"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[235]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:2(?:00\\d\\d|10)|(?:370[1-9]|51\\d0)\\d)\\d{7}|51(?:00\\d{5}|[24-9]0\\d{4,7})|(?:1[0-79]|2[24-689]|3[02-689]|4[0-4])0\\d{5,9}"]]],888:["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],979:["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};function Fp(e){return Fp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fp(e)}function qp(e){var t=Hp();return function(){var i,n=Gp(e);if(t){var o=Gp(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return function(e,t){if(t&&("object"===Fp(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Bp(e)}(this,i)}}function Bp(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Vp(e){var t="function"==typeof Map?new Map:void 0;return Vp=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return Kp(e,arguments,Gp(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),zp(n,e)},Vp(e)}function Kp(e,t,i){return Kp=Hp()?Reflect.construct:function(e,t,i){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return i&&zp(o,i.prototype),o},Kp.apply(null,arguments)}function Hp(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function zp(e,t){return zp=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},zp(e,t)}function Gp(e){return Gp=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Gp(e)}var Jp=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&zp(e,t)}(n,e);var t,i=qp(n);function n(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),t=i.call(this,e),Object.setPrototypeOf(Bp(t),n.prototype),t.name=t.constructor.name,t}return t=n,Object.defineProperty(t,"prototype",{writable:!1}),t}(Vp(Error)),Zp=2,Yp=17,Xp=3,Qp="0-90-9٠-٩۰-۹",eg="".concat("-‐-―−ー-").concat("//").concat("..").concat(" ").concat("()()[]\\[\\]").concat("~⁓∼~"),tg="++";function ig(e,t){e=e.split("-"),t=t.split("-");for(var i=e[0].split("."),n=t[0].split("."),o=0;o<3;o++){var r=Number(i[o]),s=Number(n[o]);if(r>s)return 1;if(s>r)return-1;if(!isNaN(r)&&isNaN(s))return 1;if(isNaN(r)&&!isNaN(s))return-1}return e[1]&&t[1]?e[1]>t[1]?1:e[1]<t[1]?-1:0:!e[1]&&t[1]?1:e[1]&&!t[1]?-1:0}var ng={}.constructor;function og(e){return null!=e&&e.constructor===ng}function rg(e){return rg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rg(e)}function sg(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ag(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var dg=" ext. ",lg=/^\d+$/,cg=function(){function e(t){sg(this,e),function(e){if(!e)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!og(e)||!og(e.countries))throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(og(e)?"an object of shape: { "+Object.keys(e).join(", ")+" }":"a "+vg(e)+": "+e,"."))}(t),this.metadata=t,bg.call(this,t)}return ag(e,[{key:"getCountries",value:function(){return Object.keys(this.metadata.countries).filter((function(e){return"001"!==e}))}},{key:"getCountryMetadata",value:function(e){return this.metadata.countries[e]}},{key:"nonGeographic",value:function(){if(!(this.v1||this.v2||this.v3))return this.metadata.nonGeographic||this.metadata.nonGeographical}},{key:"hasCountry",value:function(e){return void 0!==this.getCountryMetadata(e)}},{key:"hasCallingCode",value:function(e){if(this.getCountryCodesForCallingCode(e))return!0;if(this.nonGeographic()){if(this.nonGeographic()[e])return!0}else{var t=this.countryCallingCodes()[e];if(t&&1===t.length&&"001"===t[0])return!0}}},{key:"isNonGeographicCallingCode",value:function(e){return this.nonGeographic()?!!this.nonGeographic()[e]:!this.getCountryCodesForCallingCode(e)}},{key:"country",value:function(e){return this.selectNumberingPlan(e)}},{key:"selectNumberingPlan",value:function(e,t){if(e&&lg.test(e)&&(t=e,e=null),e&&"001"!==e){if(!this.hasCountry(e))throw new Error("Unknown country: ".concat(e));this.numberingPlan=new ug(this.getCountryMetadata(e),this)}else if(t){if(!this.hasCallingCode(t))throw new Error("Unknown calling code: ".concat(t));this.numberingPlan=new ug(this.getNumberingPlanMetadata(t),this)}else this.numberingPlan=void 0;return this}},{key:"getCountryCodesForCallingCode",value:function(e){var t=this.countryCallingCodes()[e];if(t){if(1===t.length&&3===t[0].length)return;return t}}},{key:"getCountryCodeForCallingCode",value:function(e){var t=this.getCountryCodesForCallingCode(e);if(t)return t[0]}},{key:"getNumberingPlanMetadata",value:function(e){var t=this.getCountryCodeForCallingCode(e);if(t)return this.getCountryMetadata(t);if(this.nonGeographic()){var i=this.nonGeographic()[e];if(i)return i}else{var n=this.countryCallingCodes()[e];if(n&&1===n.length&&"001"===n[0])return this.metadata.countries["001"]}}},{key:"countryCallingCode",value:function(){return this.numberingPlan.callingCode()}},{key:"IDDPrefix",value:function(){return this.numberingPlan.IDDPrefix()}},{key:"defaultIDDPrefix",value:function(){return this.numberingPlan.defaultIDDPrefix()}},{key:"nationalNumberPattern",value:function(){return this.numberingPlan.nationalNumberPattern()}},{key:"possibleLengths",value:function(){return this.numberingPlan.possibleLengths()}},{key:"formats",value:function(){return this.numberingPlan.formats()}},{key:"nationalPrefixForParsing",value:function(){return this.numberingPlan.nationalPrefixForParsing()}},{key:"nationalPrefixTransformRule",value:function(){return this.numberingPlan.nationalPrefixTransformRule()}},{key:"leadingDigits",value:function(){return this.numberingPlan.leadingDigits()}},{key:"hasTypes",value:function(){return this.numberingPlan.hasTypes()}},{key:"type",value:function(e){return this.numberingPlan.type(e)}},{key:"ext",value:function(){return this.numberingPlan.ext()}},{key:"countryCallingCodes",value:function(){return this.v1?this.metadata.country_phone_code_to_countries:this.metadata.country_calling_codes}},{key:"chooseCountryByCountryCallingCode",value:function(e){return this.selectNumberingPlan(e)}},{key:"hasSelectedNumberingPlan",value:function(){return void 0!==this.numberingPlan}}]),e}(),ug=function(){function e(t,i){sg(this,e),this.globalMetadataObject=i,this.metadata=t,bg.call(this,i.metadata)}return ag(e,[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"IDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[1]}},{key:"defaultIDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[12]}},{key:"nationalNumberPattern",value:function(){return this.v1||this.v2?this.metadata[1]:this.metadata[2]}},{key:"possibleLengths",value:function(){if(!this.v1)return this.metadata[this.v2?2:3]}},{key:"_getFormats",value:function(e){return e[this.v1?2:this.v2?3:4]}},{key:"formats",value:function(){var e=this,t=this._getFormats(this.metadata)||this._getFormats(this.getDefaultCountryMetadataForRegion())||[];return t.map((function(t){return new hg(t,e)}))}},{key:"nationalPrefix",value:function(){return this.metadata[this.v1?3:this.v2?4:5]}},{key:"_getNationalPrefixFormattingRule",value:function(e){return e[this.v1?4:this.v2?5:6]}},{key:"nationalPrefixFormattingRule",value:function(){return this._getNationalPrefixFormattingRule(this.metadata)||this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion())}},{key:"_nationalPrefixForParsing",value:function(){return this.metadata[this.v1?5:this.v2?6:7]}},{key:"nationalPrefixForParsing",value:function(){return this._nationalPrefixForParsing()||this.nationalPrefix()}},{key:"nationalPrefixTransformRule",value:function(){return this.metadata[this.v1?6:this.v2?7:8]}},{key:"_getNationalPrefixIsOptionalWhenFormatting",value:function(){return!!this.metadata[this.v1?7:this.v2?8:9]}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata)||this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion())}},{key:"leadingDigits",value:function(){return this.metadata[this.v1?8:this.v2?9:10]}},{key:"types",value:function(){return this.metadata[this.v1?9:this.v2?10:11]}},{key:"hasTypes",value:function(){return(!this.types()||0!==this.types().length)&&!!this.types()}},{key:"type",value:function(e){if(this.hasTypes()&&gg(this.types(),e))return new pg(gg(this.types(),e),this)}},{key:"ext",value:function(){return this.v1||this.v2?dg:this.metadata[13]||dg}}]),e}(),hg=function(){function e(t,i){sg(this,e),this._format=t,this.metadata=i}return ag(e,[{key:"pattern",value:function(){return this._format[0]}},{key:"format",value:function(){return this._format[1]}},{key:"leadingDigitsPatterns",value:function(){return this._format[2]||[]}},{key:"nationalPrefixFormattingRule",value:function(){return this._format[3]||this.metadata.nationalPrefixFormattingRule()}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return!!this._format[4]||this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"nationalPrefixIsMandatoryWhenFormattingInNationalFormat",value:function(){return this.usesNationalPrefix()&&!this.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"usesNationalPrefix",value:function(){return!(!this.nationalPrefixFormattingRule()||fg.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}]),e}(),fg=/^\(?\$1\)?$/,pg=function(){function e(t,i){sg(this,e),this.type=t,this.metadata=i}return ag(e,[{key:"pattern",value:function(){return this.metadata.v1?this.type:this.type[0]}},{key:"possibleLengths",value:function(){if(!this.metadata.v1)return this.type[1]||this.metadata.possibleLengths()}}]),e}();function gg(e,t){switch(t){case"FIXED_LINE":return e[0];case"MOBILE":return e[1];case"TOLL_FREE":return e[2];case"PREMIUM_RATE":return e[3];case"PERSONAL_NUMBER":return e[4];case"VOICEMAIL":return e[5];case"UAN":return e[6];case"PAGER":return e[7];case"VOIP":return e[8];case"SHARED_COST":return e[9]}}var vg=function(e){return rg(e)};function mg(e,t){if((t=new cg(t)).hasCountry(e))return t.country(e).countryCallingCode();throw new Error("Unknown country: ".concat(e))}function yg(e,t){return t.countries.hasOwnProperty(e)}function bg(e){var t=e.version;"number"==typeof t?(this.v1=1===t,this.v2=2===t,this.v3=3===t,this.v4=4===t):t?-1===ig(t,"1.2.0")?this.v2=!0:-1===ig(t,"1.7.35")?this.v3=!0:this.v4=!0:this.v1=!0}var $g=function(e){return"([".concat(Qp,"]{1,").concat(e,"})")};function wg(e){var t="[ \\t,]*",i="[:\\..]?[ \\t,-]*",n="#?",o="[ \\t]*";return";ext="+$g("20")+"|"+(t+"(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)"+i+$g("20")+n)+"|"+(t+"(?:[xx##~~]|int|int)"+i+$g("9")+n)+"|"+("[- ]+"+$g("6")+"#")+"|"+(o+"(?:,{2}|;)"+i+$g("15")+n)+"|"+(o+"(?:,)+"+i+$g("9")+n)}var Cg="["+Qp+"]{"+Zp+"}",kg="[++]{0,1}(?:["+eg+"]*["+Qp+"]){3,}["+eg+Qp+"]*",Sg=new RegExp("^[++]{0,1}(?:["+eg+"]*["+Qp+"]){1,2}$","i"),Ig=kg+"(?:"+wg()+")?",Rg=new RegExp("^"+Cg+"$|^"+Ig+"$","i");var xg=new RegExp("(?:"+wg()+")$","i");function Og(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Eg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Eg(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Eg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var Ag={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"};function Ng(e){return Ag[e]}function jg(e){for(var t,i="",n=Og(e.split(""));!(t=n()).done;){var o=Ng(t.value);o&&(i+=o)}return i}function Mg(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Pg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Pg(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Pg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Ug(e){for(var t,i="",n=Mg(e.split(""));!(t=n()).done;){i+=Tg(t.value,i)||""}return i}function Tg(e,t,i){if("+"===e){if(t)return;return"+"}return Ng(e)}function Wg(e,t){return function(e,t,i){var n=i.type(t),o=n&&n.possibleLengths()||i.possibleLengths();if(!o)return"IS_POSSIBLE";var r=e.length,s=o[0];if(s===r)return"IS_POSSIBLE";if(s>r)return"TOO_SHORT";if(o[o.length-1]<r)return"TOO_LONG";return o.indexOf(r,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}(e,void 0,t)}function Lg(e,t){return"IS_POSSIBLE"===Wg(e,t)}function Dg(e,t){return e=e||"",new RegExp("^(?:"+t+")$").test(e)}function _g(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Fg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Fg(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Fg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var qg=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function Bg(e,t,i){if(t=t||{},e.country||e.countryCallingCode){(i=new cg(i)).selectNumberingPlan(e.country,e.countryCallingCode);var n=t.v2?e.nationalNumber:e.phone;if(Dg(n,i.nationalNumberPattern())){if(Vg(n,"FIXED_LINE",i))return i.type("MOBILE")&&""===i.type("MOBILE").pattern()?"FIXED_LINE_OR_MOBILE":i.type("MOBILE")?Vg(n,"MOBILE",i)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE":"FIXED_LINE_OR_MOBILE";for(var o,r=_g(qg);!(o=r()).done;){var s=o.value;if(Vg(n,s,i))return s}}}}function Vg(e,t,i){return!(!(t=i.type(t))||!t.pattern())&&(!(t.possibleLengths()&&t.possibleLengths().indexOf(e.length)<0)&&Dg(e,t.pattern()))}function Kg(e,t,i){var n=new cg(i).getCountryCodesForCallingCode(e);return n?n.filter((function(e){return function(e,t,i){var n=new cg(i);if(n.selectNumberingPlan(t),n.numberingPlan.possibleLengths().indexOf(e.length)>=0)return!0;return!1}(t,e,i)})):[]}function Hg(e){return e.replace(new RegExp("[".concat(eg,"]+"),"g")," ").trim()}var zg=/(\$\d)/;function Gg(e,t,i){var n=i.useInternationalFormat,o=i.withNationalPrefix;i.carrierCode,i.metadata;var r=e.replace(new RegExp(t.pattern()),n?t.internationalFormat():o&&t.nationalPrefixFormattingRule()?t.format().replace(zg,t.nationalPrefixFormattingRule()):t.format());return n?Hg(r):r}var Jg=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function Zg(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Yg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Yg(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Yg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Xg(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Qg(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Xg(Object(i),!0).forEach((function(t){ev(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Xg(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function ev(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var tv={formatExtension:function(e,t,i){return"".concat(e).concat(i.ext()).concat(t)}};function iv(e,t,i,n){if(i=i?Qg(Qg({},tv),i):tv,n=new cg(n),e.country&&"001"!==e.country){if(!n.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));n.country(e.country)}else{if(!e.countryCallingCode)return e.phone||"";n.selectNumberingPlan(e.countryCallingCode)}var o,r=n.countryCallingCode(),s=i.v2?e.nationalNumber:e.phone;switch(t){case"NATIONAL":return s?rv(o=nv(s,e.carrierCode,"NATIONAL",n,i),e.ext,n,i.formatExtension):"";case"INTERNATIONAL":return s?(o=nv(s,null,"INTERNATIONAL",n,i),rv(o="+".concat(r," ").concat(o),e.ext,n,i.formatExtension)):"+".concat(r);case"E.164":return"+".concat(r).concat(s);case"RFC3966":return function(e){var t=e.number,i=e.ext;if(!t)return"";if("+"!==t[0])throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(t).concat(i?";ext="+i:"")}({number:"+".concat(r).concat(s),ext:e.ext});case"IDD":if(!i.fromCountry)return;var a=function(e,t,i,n,o){var r=mg(n,o.metadata);if(r===i){var s=nv(e,t,"NATIONAL",o);return"1"===i?i+" "+s:s}var a=function(e,t,i){var n=new cg(i);return n.selectNumberingPlan(e,t),n.defaultIDDPrefix()?n.defaultIDDPrefix():Jg.test(n.IDDPrefix())?n.IDDPrefix():void 0}(n,void 0,o.metadata);if(a)return"".concat(a," ").concat(i," ").concat(nv(e,null,"INTERNATIONAL",o))}(s,e.carrierCode,r,i.fromCountry,n);return rv(a,e.ext,n,i.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(t,'"'))}}function nv(e,t,i,n,o){var r=ov(n.formats(),e);return r?Gg(e,r,{useInternationalFormat:"INTERNATIONAL"===i,withNationalPrefix:!r.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||!o||!1!==o.nationalPrefix,carrierCode:t,metadata:n}):e}function ov(e,t){for(var i,n=Zg(e);!(i=n()).done;){var o=i.value;if(o.leadingDigitsPatterns().length>0){var r=o.leadingDigitsPatterns()[o.leadingDigitsPatterns().length-1];if(0!==t.search(r))continue}if(Dg(t,o.pattern()))return o}}function rv(e,t,i,n){return t?n(e,t,i):e}function sv(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function av(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?sv(Object(i),!0).forEach((function(t){dv(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):sv(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function dv(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function lv(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var cv=function(){function e(t,i,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw new TypeError("`country` or `countryCallingCode` not passed");if(!i)throw new TypeError("`nationalNumber` not passed");if(!n)throw new TypeError("`metadata` not passed");var o=function(e,t){var i,n,o=new cg(t);uv(e)?(i=e,o.selectNumberingPlan(i),n=o.countryCallingCode()):n=e;return{country:i,countryCallingCode:n}}(t,n),r=o.country,s=o.countryCallingCode;this.country=r,this.countryCallingCode=s,this.nationalNumber=i,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return n}}return lv(e,[{key:"setExt",value:function(e){this.ext=e}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:Kg(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return function(e,t,i){if(void 0===t&&(t={}),i=new cg(i),t.v2){if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");i.selectNumberingPlan(e.countryCallingCode)}else{if(!e.phone)return!1;if(e.country){if(!i.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));i.country(e.country)}else{if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");i.selectNumberingPlan(e.countryCallingCode)}}if(i.possibleLengths())return Lg(e.phone||e.nationalNumber,i);if(e.countryCallingCode&&i.isNonGeographicCallingCode(e.countryCallingCode))return!0;throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return function(e,t,i){return t=t||{},(i=new cg(i)).selectNumberingPlan(e.country,e.countryCallingCode),i.hasTypes()?void 0!==Bg(e,t,i.metadata):Dg(t.v2?e.nationalNumber:e.phone,i.nationalNumberPattern())}(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){return new cg(this.getMetadata()).isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(e){return this.number===e.number&&this.ext===e.ext}},{key:"getType",value:function(){return Bg(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(e,t){return iv(this,e,t?av(av({},t),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(e){return this.format("NATIONAL",e)}},{key:"formatInternational",value:function(e){return this.format("INTERNATIONAL",e)}},{key:"getURI",value:function(e){return this.format("RFC3966",e)}}]),e}(),uv=function(e){return/^[A-Z]{2}$/.test(e)};var hv=new RegExp("(["+Qp+"])");function fv(e,t,i,n){if(t){var o=new cg(n);o.selectNumberingPlan(t,i);var r=new RegExp(o.IDDPrefix());if(0===e.search(r)){var s=(e=e.slice(e.match(r)[0].length)).match(hv);if(!(s&&null!=s[1]&&s[1].length>0&&"0"===s[1]))return e}}}function pv(e,t){if(e&&t.numberingPlan.nationalPrefixForParsing()){var i=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")"),n=i.exec(e);if(n){var o,r,s,a=n.length-1,d=a>0&&n[a];if(t.nationalPrefixTransformRule()&&d)o=e.replace(i,t.nationalPrefixTransformRule()),a>1&&(r=n[1]);else{var l=n[0];o=e.slice(l.length),d&&(r=n[1])}if(d){var c=e.indexOf(n[1]);e.slice(0,c)===t.numberingPlan.nationalPrefix()&&(s=t.numberingPlan.nationalPrefix())}else s=n[0];return{nationalNumber:o,nationalPrefix:s,carrierCode:r}}}return{nationalNumber:e}}function gv(e,t){var i=pv(e,t),n=i.carrierCode,o=i.nationalNumber;if(o!==e){if(!function(e,t,i){if(Dg(e,i.nationalNumberPattern())&&!Dg(t,i.nationalNumberPattern()))return!1;return!0}(e,o,t))return{nationalNumber:e};if(t.possibleLengths()&&!function(e,t){switch(Wg(e,t)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}(o,t))return{nationalNumber:e}}return{nationalNumber:o,carrierCode:n}}function vv(e,t,i,n){var o=t?mg(t,n):i;if(0===e.indexOf(o)){(n=new cg(n)).selectNumberingPlan(t,i);var r=e.slice(o.length),s=gv(r,n).nationalNumber,a=gv(e,n).nationalNumber;if(!Dg(a,n.nationalNumberPattern())&&Dg(s,n.nationalNumberPattern())||"TOO_LONG"===Wg(a,n))return{countryCallingCode:o,number:r}}return{number:e}}function mv(e,t,i,n){if(!e)return{};var o;if("+"!==e[0]){var r=fv(e,t,i,n);if(!r||r===e){if(t||i){var s=vv(e,t,i,n),a=s.countryCallingCode,d=s.number;if(a)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:a,number:d}}return{number:e}}o=!0,e="+"+r}if("0"===e[1])return{};n=new cg(n);for(var l=2;l-1<=Xp&&l<=e.length;){var c=e.slice(1,l);if(n.hasCallingCode(c))return n.selectNumberingPlan(c),{countryCallingCodeSource:o?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:c,number:e.slice(l)};l++}return{}}function yv(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return bv(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return bv(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function bv(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function $v(e,t){var i=t.countries;t.defaultCountry;var n=t.metadata;n=new cg(n);for(var o,r=yv(i);!(o=r()).done;){var s=o.value;if(n.country(s),n.leadingDigits()){if(e&&0===e.search(n.leadingDigits()))return s}else if(Bg({phone:e,country:s},void 0,n.metadata))return s}}function wv(e,t){var i=t.nationalNumber,n=t.defaultCountry,o=t.metadata,r=o.getCountryCodesForCallingCode(e);if(r)return 1===r.length?r[0]:$v(i,{countries:r,defaultCountry:n,metadata:o.metadata})}var Cv="+",kv="(["+Qp+"]|[\\-\\.\\(\\)]?)",Sv=new RegExp("^\\"+Cv+kv+"*["+Qp+"]"+kv+"*$","g"),Iv=new RegExp("^("+("["+Qp+"]+((\\-)*["+Qp+"])*")+"\\.)*"+("[a-zA-Z]+((\\-)*["+Qp+"])*")+"\\.?$","g"),Rv="tel:",xv=";phone-context=",Ov=";isub=";function Ev(e,t){var i,n=t.extractFormattedPhoneNumber,o=function(e){var t=e.indexOf(xv);if(t<0)return null;var i=t+xv.length;if(i>=e.length)return"";var n=e.indexOf(";",i);return n>=0?e.substring(i,n):e.substring(i)}(e);if(!function(e){return null===e||0!==e.length&&(Sv.test(e)||Iv.test(e))}(o))throw new Jp("NOT_A_NUMBER");if(null===o)i=n(e)||"";else{i="",o.charAt(0)===Cv&&(i+=o);var r,s=e.indexOf(Rv);r=s>=0?s+Rv.length:0;var a=e.indexOf(xv);i+=e.substring(r,a)}var d=i.indexOf(Ov);if(d>0&&(i=i.substring(0,d)),""!==i)return i}var Av=250,Nv=new RegExp("[++"+Qp+"]"),jv=new RegExp("[^"+Qp+"#]+$");function Mv(e,t,i){if(t=t||{},i=new cg(i),t.defaultCountry&&!i.hasCountry(t.defaultCountry)){if(t.v2)throw new Jp("INVALID_COUNTRY");throw new Error("Unknown country: ".concat(t.defaultCountry))}var n=function(e,t,i){var n=Ev(e,{extractFormattedPhoneNumber:function(e){return function(e,t,i){if(!e)return;if(e.length>Av){if(i)throw new Jp("TOO_LONG");return}if(!1===t)return e;var n=e.search(Nv);if(n<0)return;return e.slice(n).replace(jv,"")}(e,i,t)}});if(!n)return{};if(!function(e){return e.length>=Zp&&Rg.test(e)}(n))return function(e){return Sg.test(e)}(n)?{error:"TOO_SHORT"}:{};var o=function(e){var t=e.search(xg);if(t<0)return{};for(var i=e.slice(0,t),n=e.match(xg),o=1;o<n.length;){if(n[o])return{number:i,ext:n[o]};o++}}(n);if(o.ext)return o;return{number:n}}(e,t.v2,t.extract),o=n.number,r=n.ext,s=n.error;if(!o){if(t.v2){if("TOO_SHORT"===s)throw new Jp("TOO_SHORT");throw new Jp("NOT_A_NUMBER")}return{}}var a=function(e,t,i,n){var o,r=mv(Ug(e),t,i,n.metadata),s=r.countryCallingCodeSource,a=r.countryCallingCode,d=r.number;if(a)n.selectNumberingPlan(a);else{if(!d||!t&&!i)return{};n.selectNumberingPlan(t,i),t&&(o=t),a=i||mg(t,n.metadata)}if(!d)return{countryCallingCodeSource:s,countryCallingCode:a};var l=gv(Ug(d),n),c=l.nationalNumber,u=l.carrierCode,h=wv(a,{nationalNumber:c,defaultCountry:t,metadata:n});h&&(o=h,"001"===h||n.country(o));return{country:o,countryCallingCode:a,countryCallingCodeSource:s,nationalNumber:c,carrierCode:u}}(o,t.defaultCountry,t.defaultCallingCode,i),d=a.country,l=a.nationalNumber,c=a.countryCallingCode,u=a.countryCallingCodeSource,h=a.carrierCode;if(!i.hasSelectedNumberingPlan()){if(t.v2)throw new Jp("INVALID_COUNTRY");return{}}if(!l||l.length<Zp){if(t.v2)throw new Jp("TOO_SHORT");return{}}if(l.length>Yp){if(t.v2)throw new Jp("TOO_LONG");return{}}if(t.v2){var f=new cv(c,l,i.metadata);return d&&(f.country=d),h&&(f.carrierCode=h),r&&(f.ext=r),f.__countryCallingCodeSource=u,f}var p=!!(t.extended?i.hasSelectedNumberingPlan():d)&&Dg(l,i.nationalNumberPattern());return t.extended?{country:d,countryCallingCode:c,carrierCode:h,valid:p,possible:!!p||!(!0!==t.extended||!i.possibleLengths()||!Lg(l,i)),phone:l,ext:r}:p?function(e,t,i){var n={country:e,phone:t};i&&(n.ext=i);return n}(d,l,r):{}}function Pv(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Uv(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Pv(Object(i),!0).forEach((function(t){Tv(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Pv(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Tv(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Wv(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Lv(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Dv(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,o,r=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(r.push(n.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return _v(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return _v(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _v(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Fv(e){var t,i,n,o=Dv(Array.prototype.slice.call(e),4),r=o[0],s=o[1],a=o[2],d=o[3];if("string"!=typeof r)throw new TypeError("A text for parsing must be a string.");if(t=r,s&&"string"!=typeof s){if(!og(s))throw new Error("Invalid second argument: ".concat(s));a?(i=s,n=a):n=s}else d?(i=a,n=d):(i=void 0,n=a),s&&(i=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Wv(Object(i),!0).forEach((function(t){Lv(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Wv(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({defaultCountry:s},i));return{text:t,options:i,metadata:n}}function qv(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Bv(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?qv(Object(i),!0).forEach((function(t){Vv(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):qv(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Vv(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Kv(e,t,i){t&&t.defaultCountry&&!yg(t.defaultCountry,i)&&(t=Bv(Bv({},t),{},{defaultCountry:void 0}));try{return function(e,t,i){return Mv(e,Uv(Uv({},t),{},{v2:!0}),i)}(e,t,i)}catch(e){if(!(e instanceof Jp))throw e}}function Hv(){var e=Fv(arguments);return Kv(e.text,e.options,e.metadata)}function zv(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Gv(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Jv=zv((function e(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;Gv(this,e),this.key=t,this.value=i,this.next=n,this.prev=o})),Zv=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;Gv(this,e),this.size=0,this.limit=t,this.head=null,this.tail=null,this.cache={}}return zv(e,[{key:"put",value:function(e,t){if(this.ensureLimit(),this.head){var i=new Jv(e,t,this.head);this.head.prev=i,this.head=i}else this.head=this.tail=new Jv(e,t);this.cache[e]=this.head,this.size++}},{key:"get",value:function(e){if(this.cache[e]){var t=this.cache[e].value;return this.remove(e),this.put(e,t),t}console.log("Item not available in cache for key ".concat(e))}},{key:"ensureLimit",value:function(){this.size===this.limit&&this.remove(this.tail.key)}},{key:"remove",value:function(e){var t=this.cache[e];null!==t.prev?t.prev.next=t.next:this.head=t.next,null!==t.next?t.next.prev=t.prev:this.tail=t.prev,delete this.cache[e],this.size--}},{key:"clear",value:function(){this.head=null,this.tail=null,this.size=0,this.cache={}}}]),e}();function Yv(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Xv=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.cache=new Zv(t)}return Yv(e,[{key:"getPatternForRegExp",value:function(e){var t=this.cache.get(e);return t||(t=new RegExp("^"+e),this.cache.put(e,t)),t}}]),e}();function Qv(e,t){if(e<0||t<=0||t<e)throw new TypeError;return"{".concat(e,",").concat(t,"}")}function em(e,t){var i=t.search(e);return i>=0?t.slice(0,i):t}var tm=" - \u2028\u2029 ",im="[".concat(tm,"]"),nm="[^".concat(tm,"]"),om="[".concat("0-9٠-٩۰-۹߀-߉०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯๐-๙໐-໙༠-༩၀-၉႐-႙០-៩᠐-᠙᥆-᥏᧐-᧙᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙꘠-꘩꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹0-9","]"),rm="A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",sm="[".concat(rm,"]"),am=new RegExp(sm),dm="[".concat("$¢-¥֏؋৲৳৻૱௹฿៛₠-₹꠸﷼﹩$¢£¥₩","]"),lm=new RegExp(dm),cm="[".concat("̀-ͯ҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ࣾऀ-ंऺ़ु-ै्॑-ॗॢॣঁ়ু-ৄ্ৢৣਁਂ਼ੁੂੇੈੋ-੍ੑੰੱੵઁં઼ુ-ૅેૈ્ૢૣଁ଼ିୁ-ୄ୍ୖୢୣஂீ்ా-ీె-ైొ-్ౕౖౢౣ಼ಿೆೌ್ೢೣു-ൄ്ൢൣ්ි-ුූัิ-ฺ็-๎ັິ-ູົຼ່-ໍཱ༹༘༙༵༷-ཾྀ-྄྆྇ྍ-ྗྙ-ྼ࿆ိ-ူဲ-့္်ွှၘၙၞ-ၠၱ-ၴႂႅႆႍႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴឵ិ-ួំ៉-៓៝᠋-᠍ᢩᤠ-ᤢᤧᤨᤲ᤹-᤻ᨘᨗᩖᩘ-ᩞ᩠ᩢᩥ-ᩬᩳ-᩿᩼ᬀ-ᬃ᬴ᬶ-ᬺᬼᭂ᭫-᭳ᮀᮁᮢ-ᮥᮨᮩ᯦᮫ᯨᯩᯭᯯ-ᯱᰬ-ᰳᰶ᰷᳐-᳔᳒-᳢᳠-᳨᳭᳴᷀-ᷦ᷼-᷿⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〭꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠥꠦ꣄꣠-꣱ꤦ-꤭ꥇ-ꥑꦀ-ꦂ꦳ꦶ-ꦹꦼꨩ-ꨮꨱꨲꨵꨶꩃꩌꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫬꫭ꫶ꯥꯨ꯭ﬞ︀-️︠-︦","]"),um=new RegExp(cm),hm=new RegExp("[\0--ÿĀ-ſḀ-ỿƀ-ɏ̀-ͯ]");function fm(e){return!(!am.test(e)&&!um.test(e))&&hm.test(e)}function pm(e){return"%"===e||lm.test(e)}function gm(e,t,i){var n=!0,o=Hv(e,i);if(o||(n=!1,o=Hv(e,{defaultCallingCode:t.countryCallingCode},i)),!o)return"INVALID_NUMBER";if(t.ext){if(o.ext!==t.ext)return"NO_MATCH"}else if(o.ext)return"NO_MATCH";return n&&t.countryCallingCode!==o.countryCallingCode?"NO_MATCH":t.number===o.number?n?"EXACT_MATCH":"NSN_MATCH":0===t.nationalNumber.indexOf(o.nationalNumber)||0===o.nationalNumber.indexOf(t.nationalNumber)?"SHORT_NSN_MATCH":"NO_MATCH"}var vm={POSSIBLE:function(e,t){return t.candidate,t.metadata,!0},VALID:function(e,t){var i=t.candidate;t.defaultCountry;var n=t.metadata;return!(!e.isValid()||!mm(e,i,n))},STRICT_GROUPING:function(e,t){var i=t.candidate,n=t.defaultCountry,o=t.metadata;return t.regExpCache,!(!e.isValid()||!mm(e,i,o)||bm(e,i)||!ym(e,{defaultCountry:n,metadata:o}))&&$m()},EXACT_GROUPING:function(e,t){var i=t.candidate,n=t.defaultCountry,o=t.metadata;return t.regExpCache,!(!e.isValid()||!mm(e,i,o)||bm(e,i)||!ym(e,{defaultCountry:n,metadata:o}))&&$m()}};function mm(e,t,i){for(var n=0;n<t.length-1;n++){var o=t.charAt(n);if("x"===o||"X"===o){var r=t.charAt(n+1);if("x"===r||"X"===r){if(n++,"NSN_MATCH"!==gm(t.substring(n),e,i))return!1}else{var s=jg(t.substring(n));if(s){if(e.ext!==s)return!1}else if(e.ext)return!1}}}return!0}function ym(e,t){var i=t.defaultCountry,n=t.metadata;if("FROM_DEFAULT_COUNTRY"!==e.__countryCallingCodeSource)return!0;var o=new cg(n);o.selectNumberingPlan(e.countryCallingCode),e.country||wv(e.countryCallingCode,{nationalNumber:e.nationalNumber,defaultCountry:i,metadata:o});var r=e.nationalNumber,s=ov(o.numberingPlan.formats(),r);return!s.nationalPrefixFormattingRule()||(!!o.numberingPlan.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||(!s.usesNationalPrefix()||Boolean(e.nationalPrefix)))}function bm(e,t){var i=t.indexOf("/");if(i<0)return!1;var n=t.indexOf("/",i+1);return!(n<0)&&(!("FROM_NUMBER_WITH_PLUS_SIGN"===e.__countryCallingCodeSource||"FROM_NUMBER_WITHOUT_PLUS_SIGN"===e.__countryCallingCodeSource)||jg(t.substring(0,i))!==e.countryCallingCode||t.slice(n+1).indexOf("/")>=0)}function $m(e,t,i,n,o){throw new Error("This part of code hasn't been ported")}var wm=/[\\/] *x/;function Cm(e){return em(wm,e)}var km=/(?:(?:[0-3]?\d\/[01]?\d)|(?:[01]?\d\/[0-3]?\d))\/(?:[12]\d)?\d{2}/,Sm=/[12]\d{3}[-/]?[01]\d[-/]?[0-3]\d +[0-2]\d$/,Im=/^:[0-5]\d/;function Rm(e,t,i){if(km.test(e))return!1;if(Sm.test(e)){var n=i.slice(t+e.length);if(Im.test(n))return!1}return!0}var xm="(\\[([",Om=")\\])]",Em="[^".concat(xm).concat(Om,"]"),Am="[".concat(xm).concat(tg,"]"),Nm=new RegExp("^"+Am),jm=Qv(0,3),Mm=new RegExp("^(?:[(\\[([])?(?:"+Em+"+["+Om+"])?"+Em+"+(?:["+xm+"]"+Em+"+["+Om+"])"+jm+Em+"*$"),Pm=/\d{1,5}-+\d{1,5}\s{0,4}\(\d{1,4}/;function Um(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Tm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Tm(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Tm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Wm(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Lm=wg(),Dm=["\\/+(.*)/","(\\([^(]*)","(?:".concat(im,"-|-").concat(im,")").concat(im,"*(.+)"),"[‒-―-]".concat(im,"*(.+)"),"\\.+".concat(im,"*([^.]+)"),"".concat(im,"+(").concat(nm,"+)")],_m=Qv(0,2),Fm=Qv(0,4),qm=Yp+Xp,Bm=Qv(0,qm),Vm="[".concat(eg,"]")+Fm,Km=om+Qv(1,qm),Hm="(?:"+Am+Vm+")"+_m+Km+"(?:"+Vm+Km+")"+Bm+"(?:"+Lm+")?",zm=new RegExp("[^".concat("0-9²³¹¼-¾٠-٩۰-۹߀-߉०-९০-৯৴-৹੦-੯૦-૯୦-୯୲-୷௦-௲౦-౯౸-౾೦-೯൦-൵๐-๙໐-໙༠-༳၀-၉႐-႙፩-፼ᛮ-ᛰ០-៩៰-៹᠐-᠙᥆-᥏᧐-᧚᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙⁰⁴-⁹₀-₉⅐-ↂↅ-↉①-⒛⓪-⓿❶-➓⳽〇〡-〩〸-〺㆒-㆕㈠-㈩㉈-㉏㉑-㉟㊀-㊉㊱-㊿꘠-꘩ꛦ-ꛯ꠰-꠵꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹0-9").concat(rm,"#]+$")),Gm=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,Jm=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!(i={v2:i.v2,defaultCallingCode:i.defaultCallingCode,defaultCountry:i.defaultCountry&&yg(i.defaultCountry,n)?i.defaultCountry:void 0,leniency:i.leniency||(i.extended?"POSSIBLE":"VALID"),maxTries:i.maxTries||Gm}).leniency)throw new TypeError("`leniency` is required");if("POSSIBLE"!==i.leniency&&"VALID"!==i.leniency)throw new TypeError('Invalid `leniency`: "'.concat(i.leniency,'". Supported values: "POSSIBLE", "VALID".'));if(i.maxTries<0)throw new TypeError("`maxTries` must be `>= 0`");if(this.text=t,this.options=i,this.metadata=n,this.leniency=vm[i.leniency],!this.leniency)throw new TypeError('Unknown leniency: "'.concat(i.leniency,'"'));this.maxTries=i.maxTries,this.PATTERN=new RegExp(Hm,"ig"),this.state="NOT_READY",this.searchIndex=0,this.regExpCache=new Xv(32)}return Wm(e,[{key:"find",value:function(){for(var e;this.maxTries>0&&null!==(e=this.PATTERN.exec(this.text));){var t=e[0],i=e.index;if(Rm(t=Cm(t),i,this.text)){var n=this.parseAndVerify(t,i,this.text)||this.extractInnerMatch(t,i,this.text);if(n){if(this.options.v2)return{startsAt:n.startsAt,endsAt:n.endsAt,number:n.phoneNumber};var o=n.phoneNumber,r={startsAt:n.startsAt,endsAt:n.endsAt,phone:o.nationalNumber};return o.country?r.country=o.country:r.countryCallingCode=o.countryCallingCode,o.ext&&(r.ext=o.ext),r}}this.maxTries--}}},{key:"extractInnerMatch",value:function(e,t,i){for(var n,o=Um(Dm);!(n=o()).done;)for(var r=n.value,s=!0,a=void 0,d=new RegExp(r,"g");this.maxTries>0&&null!==(a=d.exec(e));){if(s){var l=em(zm,e.slice(0,a.index)),c=this.parseAndVerify(l,t,i);if(c)return c;this.maxTries--,s=!1}var u=em(zm,a[1]),h=e.indexOf(u,a.index),f=this.parseAndVerify(u,t+h,i);if(f)return f;this.maxTries--}}},{key:"parseAndVerify",value:function(e,t,i){if(function(e,t,i,n){if(Mm.test(e)&&!Pm.test(e)){if("POSSIBLE"!==n){if(t>0&&!Nm.test(e)){var o=i[t-1];if(pm(o)||fm(o))return!1}var r=t+e.length;if(r<i.length){var s=i[r];if(pm(s)||fm(s))return!1}}return!0}}(e,t,i,this.options.leniency)){var n=Hv(e,{extended:!0,defaultCountry:this.options.defaultCountry,defaultCallingCode:this.options.defaultCallingCode},this.metadata);if(n&&n.isPossible())return this.leniency(n,{candidate:e,defaultCountry:this.options.defaultCountry,metadata:this.metadata,regExpCache:this.regExpCache})?{startsAt:t,endsAt:t+e.length,phoneNumber:n}:void 0}}},{key:"hasNext",value:function(){return"NOT_READY"===this.state&&(this.lastMatch=this.find(),this.lastMatch?this.state="READY":this.state="DONE"),"READY"===this.state}},{key:"next",value:function(){if(!this.hasNext())throw new Error("No next element");var e=this.lastMatch;return this.lastMatch=null,this.state="NOT_READY",e}}]),e}();function Zm(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Ym=function(){function e(t){var i=t.onCountryChange,n=t.onCallingCodeChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.onCountryChange=i,this.onCallingCodeChange=n}return Zm(e,[{key:"reset",value:function(e){var t=e.country,i=e.callingCode;this.international=!1,this.missingPlus=!1,this.IDDPrefix=void 0,this.callingCode=void 0,this.digits="",this.resetNationalSignificantNumber(),this.initCountryAndCallingCode(t,i)}},{key:"resetNationalSignificantNumber",value:function(){this.nationalSignificantNumber=this.getNationalDigits(),this.nationalSignificantNumberMatchesInput=!0,this.nationalPrefix=void 0,this.carrierCode=void 0,this.complexPrefixBeforeNationalSignificantNumber=void 0}},{key:"update",value:function(e){for(var t=0,i=Object.keys(e);t<i.length;t++){var n=i[t];this[n]=e[n]}}},{key:"initCountryAndCallingCode",value:function(e,t){this.setCountry(e),this.setCallingCode(t)}},{key:"setCountry",value:function(e){this.country=e,this.onCountryChange(e)}},{key:"setCallingCode",value:function(e){this.callingCode=e,this.onCallingCodeChange(e,this.country)}},{key:"startInternationalNumber",value:function(e,t){this.international=!0,this.initCountryAndCallingCode(e,t)}},{key:"appendDigits",value:function(e){this.digits+=e}},{key:"appendNationalSignificantNumberDigits",value:function(e){this.nationalSignificantNumber+=e}},{key:"getNationalDigits",value:function(){return this.international?this.digits.slice((this.IDDPrefix?this.IDDPrefix.length:0)+(this.callingCode?this.callingCode.length:0)):this.digits}},{key:"getDigitsWithoutInternationalPrefix",value:function(){return this.international&&this.IDDPrefix?this.digits.slice(this.IDDPrefix.length):this.digits}}]),e}();function Xm(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Qm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Qm(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Qm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var ey="x",ty=new RegExp(ey);function iy(e,t){if(t<1)return"";for(var i="";t>1;)1&t&&(i+=e),t>>=1,e+=e;return i+e}function ny(e,t){return")"===e[t]&&t++,function(e){var t=[],i=0;for(;i<e.length;)"("===e[i]?t.push(i):")"===e[i]&&t.pop(),i++;var n=0,o="";t.push(e.length);for(var r=0,s=t;r<s.length;r++){var a=s[r];o+=e.slice(n,a),n=a+1}return o}(e.slice(0,t))}function oy(e,t,i){var n=i.metadata,o=i.shouldTryNationalPrefixFormattingRule,r=i.getSeparatorAfterNationalPrefix;if(new RegExp("^(?:".concat(t.pattern(),")$")).test(e.nationalSignificantNumber))return function(e,t,i){var n=i.metadata,o=i.shouldTryNationalPrefixFormattingRule,r=i.getSeparatorAfterNationalPrefix;if(e.nationalSignificantNumber,e.international,e.nationalPrefix,e.carrierCode,o(t)){var s=ry(e,t,{useNationalPrefixFormattingRule:!0,getSeparatorAfterNationalPrefix:r,metadata:n});if(s)return s}return ry(e,t,{useNationalPrefixFormattingRule:!1,getSeparatorAfterNationalPrefix:r,metadata:n})}(e,t,{metadata:n,shouldTryNationalPrefixFormattingRule:o,getSeparatorAfterNationalPrefix:r})}function ry(e,t,i){var n=i.metadata,o=i.useNationalPrefixFormattingRule,r=i.getSeparatorAfterNationalPrefix,s=Gg(e.nationalSignificantNumber,t,{carrierCode:e.carrierCode,useInternationalFormat:e.international,withNationalPrefix:o,metadata:n});if(o||(e.nationalPrefix?s=e.nationalPrefix+r(t)+s:e.complexPrefixBeforeNationalSignificantNumber&&(s=e.complexPrefixBeforeNationalSignificantNumber+" "+s)),function(e,t){return jg(e)===t.getNationalDigits()}(s,e))return s}function sy(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var ay=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return sy(e,[{key:"parse",value:function(e){if(this.context=[{or:!0,instructions:[]}],this.parsePattern(e),1!==this.context.length)throw new Error("Non-finalized contexts left when pattern parse ended");var t=this.context[0],i=t.branches,n=t.instructions;if(i)return{op:"|",args:i.concat([uy(n)])};if(0===n.length)throw new Error("Pattern is required");return 1===n.length?n[0]:n}},{key:"startContext",value:function(e){this.context.push(e)}},{key:"endContext",value:function(){this.context.pop()}},{key:"getContext",value:function(){return this.context[this.context.length-1]}},{key:"parsePattern",value:function(e){if(!e)throw new Error("Pattern is required");var t=e.match(cy);if(t){var i=t[1],n=e.slice(0,t.index),o=e.slice(t.index+i.length);switch(i){case"(?:":n&&this.parsePattern(n),this.startContext({or:!0,instructions:[],branches:[]});break;case")":if(!this.getContext().or)throw new Error('")" operator must be preceded by "(?:" operator');if(n&&this.parsePattern(n),0===this.getContext().instructions.length)throw new Error('No instructions found after "|" operator in an "or" group');var r=this.getContext().branches;r.push(uy(this.getContext().instructions)),this.endContext(),this.getContext().instructions.push({op:"|",args:r});break;case"|":if(!this.getContext().or)throw new Error('"|" operator can only be used inside "or" groups');if(n&&this.parsePattern(n),!this.getContext().branches){if(1!==this.context.length)throw new Error('"branches" not found in an "or" group context');this.getContext().branches=[]}this.getContext().branches.push(uy(this.getContext().instructions)),this.getContext().instructions=[];break;case"[":n&&this.parsePattern(n),this.startContext({oneOfSet:!0});break;case"]":if(!this.getContext().oneOfSet)throw new Error('"]" operator must be preceded by "[" operator');this.endContext(),this.getContext().instructions.push({op:"[]",args:dy(n)});break;default:throw new Error("Unknown operator: ".concat(i))}o&&this.parsePattern(o)}else{if(ly.test(e))throw new Error("Illegal characters found in a pattern: ".concat(e));this.getContext().instructions=this.getContext().instructions.concat(e.split(""))}}}]),e}();function dy(e){for(var t=[],i=0;i<e.length;){if("-"===e[i]){if(0===i||i===e.length-1)throw new Error("Couldn't parse a one-of set pattern: ".concat(e));for(var n=e[i-1].charCodeAt(0)+1,o=e[i+1].charCodeAt(0)-1,r=n;r<=o;)t.push(String.fromCharCode(r)),r++}else t.push(e[i]);i++}return t}var ly=/[\(\)\[\]\?\:\|]/,cy=new RegExp("(\\||\\(\\?\\:|\\)|\\[|\\])");function uy(e){return 1===e.length?e[0]:e}function hy(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return fy(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return fy(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function fy(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function py(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var gy=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.matchTree=(new ay).parse(t)}return py(e,[{key:"match",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).allowOverflow;if(!e)throw new Error("String is required");var i=vy(e.split(""),this.matchTree,!0);if(i&&i.match&&delete i.matchedChars,!i||!i.overflow||t)return i}}]),e}();function vy(e,t,i){if("string"==typeof t){var n=e.join("");return 0===t.indexOf(n)?e.length===t.length?{match:!0,matchedChars:e}:{partialMatch:!0}:0===n.indexOf(t)?i&&e.length>t.length?{overflow:!0}:{match:!0,matchedChars:e.slice(0,t.length)}:void 0}if(Array.isArray(t)){for(var o=e.slice(),r=0;r<t.length;){var s=vy(o,t[r],i&&r===t.length-1);if(!s)return;if(s.overflow)return s;if(!s.match){if(s.partialMatch)return{partialMatch:!0};throw new Error("Unsupported match result:\n".concat(JSON.stringify(s,null,2)))}if(0===(o=o.slice(s.matchedChars.length)).length)return r===t.length-1?{match:!0,matchedChars:e}:{partialMatch:!0};r++}return i?{overflow:!0}:{match:!0,matchedChars:e.slice(0,e.length-o.length)}}switch(t.op){case"|":for(var a,d,l=hy(t.args);!(d=l()).done;){var c=vy(e,d.value,i);if(c){if(c.overflow)return c;if(c.match)return{match:!0,matchedChars:c.matchedChars};if(!c.partialMatch)throw new Error("Unsupported match result:\n".concat(JSON.stringify(c,null,2)));a=!0}}return a?{partialMatch:!0}:void 0;case"[]":for(var u,h=hy(t.args);!(u=h()).done;){var f=u.value;if(e[0]===f)return 1===e.length?{match:!0,matchedChars:e}:i?{overflow:!0}:{match:!0,matchedChars:[f]}}return;default:throw new Error("Unsupported instruction tree: ".concat(t))}}function my(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return yy(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return yy(e,t)}(e))||t){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function yy(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function by(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var $y=iy("9",15),wy=/[- ]/,Cy=new RegExp("["+eg+"]*\\$1["+eg+"]*(\\$\\d["+eg+"]*)*$"),ky=function(){function e(t){t.state;var i=t.metadata;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=i,this.resetFormat()}return by(e,[{key:"resetFormat",value:function(){this.chosenFormat=void 0,this.template=void 0,this.nationalNumberTemplate=void 0,this.populatedNationalNumberTemplate=void 0,this.populatedNationalNumberTemplatePosition=-1}},{key:"reset",value:function(e,t){this.resetFormat(),e?(this.isNANP="1"===e.callingCode(),this.matchingFormats=e.formats(),t.nationalSignificantNumber&&this.narrowDownMatchingFormats(t)):(this.isNANP=void 0,this.matchingFormats=[])}},{key:"format",value:function(e,t){var i=this;if(function(e,t){return"IS_POSSIBLE"===Wg(e,t)}(t.nationalSignificantNumber,this.metadata))for(var n,o=my(this.matchingFormats);!(n=o()).done;){var r=n.value,s=oy(t,r,{metadata:this.metadata,shouldTryNationalPrefixFormattingRule:function(e){return i.shouldTryNationalPrefixFormattingRule(e,{international:t.international,nationalPrefix:t.nationalPrefix})},getSeparatorAfterNationalPrefix:function(e){return i.getSeparatorAfterNationalPrefix(e)}});if(s)return this.resetFormat(),this.chosenFormat=r,this.setNationalNumberTemplate(s.replace(/\d/g,ey),t),this.populatedNationalNumberTemplate=s,this.populatedNationalNumberTemplatePosition=this.template.lastIndexOf(ey),s}return this.formatNationalNumberWithNextDigits(e,t)}},{key:"formatNationalNumberWithNextDigits",value:function(e,t){var i=this.chosenFormat,n=this.chooseFormat(t);if(n)return n===i?this.formatNextNationalNumberDigits(e):this.formatNextNationalNumberDigits(t.getNationalDigits())}},{key:"narrowDownMatchingFormats",value:function(e){var t=this,i=e.nationalSignificantNumber,n=e.nationalPrefix,o=e.international,r=i,s=r.length-3;s<0&&(s=0),this.matchingFormats=this.matchingFormats.filter((function(e){return t.formatSuits(e,o,n)&&t.formatMatches(e,r,s)})),this.chosenFormat&&-1===this.matchingFormats.indexOf(this.chosenFormat)&&this.resetFormat()}},{key:"formatSuits",value:function(e,t,i){return!(i&&!e.usesNationalPrefix()&&!e.nationalPrefixIsOptionalWhenFormattingInNationalFormat())&&!(!t&&!i&&e.nationalPrefixIsMandatoryWhenFormattingInNationalFormat())}},{key:"formatMatches",value:function(e,t,i){var n=e.leadingDigitsPatterns().length;if(0===n)return!0;i=Math.min(i,n-1);var o=e.leadingDigitsPatterns()[i];if(t.length<3)try{return void 0!==new gy(o).match(t,{allowOverflow:!0})}catch(e){return console.error(e),!0}return new RegExp("^(".concat(o,")")).test(t)}},{key:"getFormatFormat",value:function(e,t){return t?e.internationalFormat():e.format()}},{key:"chooseFormat",value:function(e){for(var t,i=this,n=function(){var n=t.value;return i.chosenFormat===n?"break":Cy.test(i.getFormatFormat(n,e.international))?i.createTemplateForFormat(n,e)?(i.chosenFormat=n,"break"):(i.matchingFormats=i.matchingFormats.filter((function(e){return e!==n})),"continue"):"continue"},o=my(this.matchingFormats.slice());!(t=o()).done;){var r=n();if("break"===r)break}return this.chosenFormat||this.resetFormat(),this.chosenFormat}},{key:"createTemplateForFormat",value:function(e,t){if(!(e.pattern().indexOf("|")>=0)){var i=this.getTemplateForFormat(e,t);return i?(this.setNationalNumberTemplate(i,t),!0):void 0}}},{key:"getSeparatorAfterNationalPrefix",value:function(e){return this.isNANP||e&&e.nationalPrefixFormattingRule()&&wy.test(e.nationalPrefixFormattingRule())?" ":""}},{key:"getInternationalPrefixBeforeCountryCallingCode",value:function(e,t){var i=e.IDDPrefix,n=e.missingPlus;return i?t&&!1===t.spacing?i:i+" ":n?"":"+"}},{key:"getTemplate",value:function(e){if(this.template){for(var t=-1,i=0,n=e.international?this.getInternationalPrefixBeforeCountryCallingCode(e,{spacing:!1}):"";i<n.length+e.getDigitsWithoutInternationalPrefix().length;)t=this.template.indexOf(ey,t+1),i++;return ny(this.template,t+1)}}},{key:"setNationalNumberTemplate",value:function(e,t){this.nationalNumberTemplate=e,this.populatedNationalNumberTemplate=e,this.populatedNationalNumberTemplatePosition=-1,t.international?this.template=this.getInternationalPrefixBeforeCountryCallingCode(t).replace(/[\d\+]/g,ey)+iy(ey,t.callingCode.length)+" "+e:this.template=e}},{key:"getTemplateForFormat",value:function(e,t){var i=t.nationalSignificantNumber,n=t.international,o=t.nationalPrefix,r=t.complexPrefixBeforeNationalSignificantNumber,s=e.pattern();s=s.replace(/\[([^\[\]])*\]/g,"\\d").replace(/\d(?=[^,}][^,}])/g,"\\d");var a=$y.match(s)[0];if(!(i.length>a.length)){var d=new RegExp("^"+s+"$"),l=i.replace(/\d/g,"9");d.test(l)&&(a=l);var c,u=this.getFormatFormat(e,n);if(this.shouldTryNationalPrefixFormattingRule(e,{international:n,nationalPrefix:o})){var h=u.replace(zg,e.nationalPrefixFormattingRule());if(jg(e.nationalPrefixFormattingRule())===(o||"")+jg("$1")&&(u=h,c=!0,o))for(var f=o.length;f>0;)u=u.replace(/\d/,ey),f--}var p=a.replace(new RegExp(s),u).replace(new RegExp("9","g"),ey);return c||(r?p=iy(ey,r.length)+" "+p:o&&(p=iy(ey,o.length)+this.getSeparatorAfterNationalPrefix(e)+p)),n&&(p=Hg(p)),p}}},{key:"formatNextNationalNumberDigits",value:function(e){var t=function(e,t,i){for(var n,o=Xm(i.split(""));!(n=o()).done;){var r=n.value;if(e.slice(t+1).search(ty)<0)return;t=e.search(ty),e=e.replace(ty,r)}return[e,t]}(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition,e);if(t)return this.populatedNationalNumberTemplate=t[0],this.populatedNationalNumberTemplatePosition=t[1],ny(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition+1);this.resetFormat()}},{key:"shouldTryNationalPrefixFormattingRule",value:function(e,t){var i=t.international,n=t.nationalPrefix;if(e.nationalPrefixFormattingRule()){var o=e.usesNationalPrefix();if(o&&n||!o&&!i)return!0}}}]),e}();function Sy(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,o,r=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(r.push(n.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Iy(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Iy(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Iy(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Ry(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var xy=new RegExp("^"+("["+eg+Qp+"]+")+"$","i"),Oy="(?:[++]["+eg+Qp+"]*|["+eg+Qp+"]+)",Ey=new RegExp("[^"+eg+Qp+"]+.*$"),Ay=/[^\d\[\]]/,Ny=function(){function e(t){var i=t.defaultCountry,n=t.defaultCallingCode,o=t.metadata,r=t.onNationalSignificantNumberChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.defaultCountry=i,this.defaultCallingCode=n,this.metadata=o,this.onNationalSignificantNumberChange=r}return Ry(e,[{key:"input",value:function(e,t){var i,n=function(e){var t=function(e){var t=function(e){var t,i=e.search(Oy);if(i<0)return;e=e.slice(i),"+"===e[0]&&(t=!0,e=e.slice(1));e=e.replace(Ey,""),t&&(e="+"+e);return e}(e)||"";if("+"===t[0])return[t.slice(1),!0];return[t]}(e),i=Sy(t,2),n=i[0],o=i[1];xy.test(n)||(n="");return[n,o]}(e),o=Sy(n,2),r=o[0],s=o[1],a=jg(r);return s&&(t.digits||(t.startInternationalNumber(),a||(i=!0))),a&&this.inputDigits(a,t),{digits:a,justLeadingPlus:i}}},{key:"inputDigits",value:function(e,t){var i=t.digits,n=i.length<3&&i.length+e.length>=3;if(t.appendDigits(e),n&&this.extractIddPrefix(t),this.isWaitingForCountryCallingCode(t)){if(!this.extractCountryCallingCode(t))return}else t.appendNationalSignificantNumberDigits(e);t.international||this.hasExtractedNationalSignificantNumber||this.extractNationalSignificantNumber(t.getNationalDigits(),(function(e){return t.update(e)}))}},{key:"isWaitingForCountryCallingCode",value:function(e){var t=e.international,i=e.callingCode;return t&&!i}},{key:"extractCountryCallingCode",value:function(e){var t=mv("+"+e.getDigitsWithoutInternationalPrefix(),this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),i=t.countryCallingCode,n=t.number;if(i)return e.setCallingCode(i),e.update({nationalSignificantNumber:n}),!0}},{key:"reset",value:function(e){if(e){this.hasSelectedNumberingPlan=!0;var t=e._nationalPrefixForParsing();this.couldPossiblyExtractAnotherNationalSignificantNumber=t&&Ay.test(t)}else this.hasSelectedNumberingPlan=void 0,this.couldPossiblyExtractAnotherNationalSignificantNumber=void 0}},{key:"extractNationalSignificantNumber",value:function(e,t){if(this.hasSelectedNumberingPlan){var i=pv(e,this.metadata),n=i.nationalPrefix,o=i.nationalNumber,r=i.carrierCode;if(o!==e)return this.onExtractedNationalNumber(n,r,o,e,t),!0}}},{key:"extractAnotherNationalSignificantNumber",value:function(e,t,i){if(!this.hasExtractedNationalSignificantNumber)return this.extractNationalSignificantNumber(e,i);if(this.couldPossiblyExtractAnotherNationalSignificantNumber){var n=pv(e,this.metadata),o=n.nationalPrefix,r=n.nationalNumber,s=n.carrierCode;if(r!==t)return this.onExtractedNationalNumber(o,s,r,e,i),!0}}},{key:"onExtractedNationalNumber",value:function(e,t,i,n,o){var r,s,a=n.lastIndexOf(i);if(a>=0&&a===n.length-i.length){s=!0;var d=n.slice(0,a);d!==e&&(r=d)}o({nationalPrefix:e,carrierCode:t,nationalSignificantNumber:i,nationalSignificantNumberMatchesInput:s,complexPrefixBeforeNationalSignificantNumber:r}),this.hasExtractedNationalSignificantNumber=!0,this.onNationalSignificantNumberChange()}},{key:"reExtractNationalSignificantNumber",value:function(e){return!!this.extractAnotherNationalSignificantNumber(e.getNationalDigits(),e.nationalSignificantNumber,(function(t){return e.update(t)}))||(this.extractIddPrefix(e)||this.fixMissingPlus(e)?(this.extractCallingCodeAndNationalSignificantNumber(e),!0):void 0)}},{key:"extractIddPrefix",value:function(e){var t=e.international,i=e.IDDPrefix,n=e.digits;if(e.nationalSignificantNumber,!t&&!i){var o=fv(n,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata);return void 0!==o&&o!==n?(e.update({IDDPrefix:n.slice(0,n.length-o.length)}),this.startInternationalNumber(e,{country:void 0,callingCode:void 0}),!0):void 0}}},{key:"fixMissingPlus",value:function(e){if(!e.international){var t=vv(e.digits,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),i=t.countryCallingCode;if(t.number,i)return e.update({missingPlus:!0}),this.startInternationalNumber(e,{country:e.country,callingCode:i}),!0}}},{key:"startInternationalNumber",value:function(e,t){var i=t.country,n=t.callingCode;e.startInternationalNumber(i,n),e.nationalSignificantNumber&&(e.resetNationalSignificantNumber(),this.onNationalSignificantNumberChange(),this.hasExtractedNationalSignificantNumber=void 0)}},{key:"extractCallingCodeAndNationalSignificantNumber",value:function(e){this.extractCountryCallingCode(e)&&this.extractNationalSignificantNumber(e.getNationalDigits(),(function(t){return e.update(t)}))}}]),e}();function jy(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,o,r=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(r.push(n.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return My(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return My(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function My(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Py(e,t,i){return t&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var Uy,Ty=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=new cg(i);var n=jy(this.getCountryAndCallingCode(t),2),o=n[0],r=n[1];this.defaultCountry=o,this.defaultCallingCode=r,this.reset()}return Py(e,[{key:"getCountryAndCallingCode",value:function(e){var t,i;return e&&(og(e)?(t=e.defaultCountry,i=e.defaultCallingCode):t=e),t&&!this.metadata.hasCountry(t)&&(t=void 0),[t,i]}},{key:"input",value:function(e){var t=this.parser.input(e,this.state),i=t.digits;if(t.justLeadingPlus)this.formattedOutput="+";else if(i){var n;if(this.determineTheCountryIfNeeded(),this.state.nationalSignificantNumber&&this.formatter.narrowDownMatchingFormats(this.state),this.metadata.hasSelectedNumberingPlan()&&(n=this.formatter.format(i,this.state)),void 0===n&&this.parser.reExtractNationalSignificantNumber(this.state)){this.determineTheCountryIfNeeded();var o=this.state.getNationalDigits();o&&(n=this.formatter.format(o,this.state))}this.formattedOutput=n?this.getFullNumber(n):this.getNonFormattedNumber()}return this.formattedOutput}},{key:"reset",value:function(){var e=this;return this.state=new Ym({onCountryChange:function(t){e.country=t},onCallingCodeChange:function(t,i){e.metadata.selectNumberingPlan(i,t),e.formatter.reset(e.metadata.numberingPlan,e.state),e.parser.reset(e.metadata.numberingPlan)}}),this.formatter=new ky({state:this.state,metadata:this.metadata}),this.parser=new Ny({defaultCountry:this.defaultCountry,defaultCallingCode:this.defaultCallingCode,metadata:this.metadata,state:this.state,onNationalSignificantNumberChange:function(){e.determineTheCountryIfNeeded(),e.formatter.reset(e.metadata.numberingPlan,e.state)}}),this.state.reset({country:this.defaultCountry,callingCode:this.defaultCallingCode}),this.formattedOutput="",this}},{key:"isInternational",value:function(){return this.state.international}},{key:"getCallingCode",value:function(){if(this.isInternational())return this.state.callingCode}},{key:"getCountryCallingCode",value:function(){return this.getCallingCode()}},{key:"getCountry",value:function(){if(this.state.digits)return this._getCountry()}},{key:"_getCountry",value:function(){return this.state.country}},{key:"determineTheCountryIfNeeded",value:function(){this.state.country&&!this.isCountryCallingCodeAmbiguous()||this.determineTheCountry()}},{key:"getFullNumber",value:function(e){var t=this;if(this.isInternational()){var i=function(e){return t.formatter.getInternationalPrefixBeforeCountryCallingCode(t.state,{spacing:!!e})+e},n=this.state.callingCode;return i(n?e?"".concat(n," ").concat(e):n:"".concat(this.state.getDigitsWithoutInternationalPrefix()))}return e}},{key:"getNonFormattedNationalNumberWithPrefix",value:function(){var e=this.state,t=e.nationalSignificantNumber,i=e.complexPrefixBeforeNationalSignificantNumber,n=e.nationalPrefix,o=t,r=i||n;return r&&(o=r+o),o}},{key:"getNonFormattedNumber",value:function(){var e=this.state.nationalSignificantNumberMatchesInput;return this.getFullNumber(e?this.getNonFormattedNationalNumberWithPrefix():this.state.getNationalDigits())}},{key:"getNonFormattedTemplate",value:function(){var e=this.getNonFormattedNumber();if(e)return e.replace(/[\+\d]/g,ey)}},{key:"isCountryCallingCodeAmbiguous",value:function(){var e=this.state.callingCode,t=this.metadata.getCountryCodesForCallingCode(e);return t&&t.length>1}},{key:"determineTheCountry",value:function(){this.state.setCountry(wv(this.isInternational()?this.state.callingCode:this.defaultCallingCode,{nationalNumber:this.state.nationalSignificantNumber,defaultCountry:this.defaultCountry,metadata:this.metadata}))}},{key:"getNumberValue",value:function(){var e=this.state,t=e.digits,i=e.callingCode,n=e.country,o=e.nationalSignificantNumber;if(t)return this.isInternational()?i?"+"+i+o:"+"+t:n||i?"+"+(n?this.metadata.countryCallingCode():i)+o:void 0}},{key:"getNumber",value:function(){var e=this.state,t=e.nationalSignificantNumber,i=e.carrierCode,n=e.callingCode,o=this._getCountry();if(t&&(o||n)){if(o&&o===this.defaultCountry){var r=new cg(this.metadata.metadata);r.selectNumberingPlan(o);var s=r.numberingPlan.callingCode(),a=this.metadata.getCountryCodesForCallingCode(s);if(a.length>1){var d=$v(t,{countries:a,defaultCountry:this.defaultCountry,metadata:this.metadata.metadata});d&&(o=d)}}var l=new cv(o||n,t,this.metadata.metadata);return i&&(l.carrierCode=i),l}}},{key:"isPossible",value:function(){var e=this.getNumber();return!!e&&e.isPossible()}},{key:"isValid",value:function(){var e=this.getNumber();return!!e&&e.isValid()}},{key:"getNationalNumber",value:function(){return this.state.nationalSignificantNumber}},{key:"getChars",value:function(){return(this.state.international?"+":"")+this.state.digits}},{key:"getTemplate",value:function(){return this.formatter.getTemplate(this.state)||this.getNonFormattedTemplate()||""}}]),e}();function Wy(){return function(e,t){var i=Array.prototype.slice.call(t);return i.push(_p),e.apply(this,i)}(Hv,arguments)}function Ly(e,t){return Jm.call(this,e,t,_p)}function Dy(e){return Ty.call(this,e,_p)}function _y(){return cg.call(this,_p)}Ly.prototype=Object.create(Jm.prototype,{}),Ly.prototype.constructor=Ly,Dy.prototype=Object.create(Ty.prototype,{}),Dy.prototype.constructor=Dy,_y.prototype=Object.create(cg.prototype,{}),_y.prototype.constructor=_y,function(e){e[e.text=1]="text",e[e.numeric=2]="numeric",e[e.bool=3]="bool",e[e.singleSelect=4]="singleSelect",e[e.array=5]="array",e[e.date=6]="date"}(Uy||(Uy={}));const Fy=(e,t)=>Object.entries(e).reduce(((e,[i,n])=>{const[o,...r]=i.split(".");return t!==o?Object.assign(e,{[i]:n}):(e[o]||(e[o]={}),e[o][r.join(".")]=n,e)}),{}),qy=(e,t)=>Object.fromEntries(Object.entries(e||{}).map((([e,i])=>[`${t}.${e}`,i]))),By=(e,t)=>e===Uy.date?(e=>new Date(Number(e)).toLocaleDateString("en-US"))(`${t}`):t,Vy=(e={})=>{const t=$n("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,i])=>{t.content.querySelector("descope-wc").setAttribute(kn(e),i)})),t};function Ky(e){return new URLSearchParams(window.location.search).get(e)}const Hy={enabled:"active",disabled:"disabled",invited:"invited"},zy=e=>e.tenantRoles.data,Gy=e=>e.selectedUsersLoginIds,Jy=e=>e.notifications,Zy=e=>e.customAttributes.data,Yy=Sl((e=>e.subTenantRoles.data),(e=>Object.fromEntries(e.map((({tenantId:e,tenantName:t,roleNames:i})=>[e,t?{label:t,options:i}:i]))))),Xy=Sl(Yy,(e=>Object.keys(e).length>0)),Qy=Sl(Zy,(e=>Object.fromEntries(e.map((e=>[e.name,e.type]))))),eb=Sl((e=>e.usersList.data),Qy,((e,t)=>e.map((e=>Object.assign(Object.assign({},e),{customAttributes:Object.fromEntries(Object.entries(e.customAttributes||{}).map((([e,i])=>[e,By(t[e],i)])))}))))),tb=e=>{const t=[e.roleNames||[],...(e.userTenants||[]).map((e=>e.roleNames||[]))].filter((e=>e.length>0));if(0===t.length)return e.roleNames||[];const i=t.map((e=>[...e].sort().join("\0")));return i.every((e=>e===i[0]))?t[0]:"Multiple roles"},ib=Sl(eb,(e=>e.map((e=>{var t;return Object.assign(Object.assign(Object.assign({},e),qy(null==e?void 0:e.customAttributes,"customAttributes")),{createdTimeFormatted:new Date(1e3*((null==e?void 0:e.createdTime)||0)).toLocaleString(),status:Hy[e.status]||e.status,roles:tb(e),tenants:null===(t=e.userTenants)||void 0===t?void 0:t.map((e=>e.tenantName||e.tenantId))})})))),nb=Sl(Gy,ib,((e,t)=>t.filter((t=>e.includes(t.loginIds))))),ob=Sl(nb,(e=>e.map((e=>e.userId)))),rb=Sl(nb,(e=>e.map((({userId:e,loginIds:t})=>({userId:e,loginIds:t}))))),sb=Sl(nb,(e=>e.map((e=>({userId:e.userId,roles:e.roleNames}))))),ab=Sl(nb,(e=>e.map((e=>e.status)))),db=Sl(nb,(e=>e.every((e=>e.editable)))),lb=Sl(Gy,(e=>!!e.length)),cb=Sl(Gy,(e=>1===e.length)),ub=Sl(Gy,(e=>{var t;return null===(t=null==e?void 0:e[0])||void 0===t?void 0:t[0]})),hb=Sl(cb,ab,((e,t)=>e&&t.every((e=>e===Hy.enabled)))),fb=Sl(ab,(e=>e.every((e=>e===Hy.disabled)))),pb=Sl(nb,(e=>{var t;return 1===e.length?e[0].name||e[0].email||(null===(t=e[0].loginIds)||void 0===t?void 0:t[0]):`${e.length} users`})),gb=Sl(cb,fb,db,((e,t,i)=>e&&t&&i)),vb=Sl(cb,hb,db,((e,t,i)=>e&&t&&i)),mb=Sl(cb,db,((e,t)=>e&&t)),yb=Sl(cb,db,((e,t)=>e&&t)),bb=Sl(cb,db,((e,t)=>e&&t)),$b=lb,wb=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},Cb=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),kb=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{t&&e.notifications.push({type:"success",msg:t(i)})},onRejected:(t,i)=>{e&&t.notifications.push({type:"error",msg:e(i)})}}),Sb=nc("users/create",((e,{extra:{api:t}})=>t.user.create(e))),Ib=wb(Sb)({onFulfilled:(e,t)=>{e.usersList.data.unshift(t.payload)}},Cb((e=>e.createUser)),kb({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>`}})),Rb={action:Sb,reducer:Ib},xb=nc("users/delete",((e,{extra:{api:t}})=>t.user.deleteBatch(e))),Ob=wb(xb)({onFulfilled:(e,t)=>{e.usersList.data=e.usersList.data.filter((e=>!t.meta.arg.includes(e.userId))),e.selectedUsersLoginIds=[]}},Cb((e=>e.deleteUser)),kb({getSuccessMsg:e=>Sn(e.meta.arg.length)`${["",e.meta.arg.length]} ${["U","u"]}ser${["","s"]} deleted successfully`,getErrorMsg:e=>Sn(e.meta.arg.length)`Failed to delete user${["","s"]}`})),Eb={action:xb,reducer:Ob},Ab=nc("users/setTempPassword",((e,{extra:{api:t}})=>t.user.setTempPassword(e))),Nb=wb(Ab)(Cb((e=>e.setTempUserPassword)),kb({getSuccessMsg:()=>"Successfully reset user password",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to reset user's password</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),jb={action:Ab,reducer:Nb},Mb=nc("users/getCustomAttributes",((e,{extra:{api:t}})=>t.user.getCustomAttributes())),Pb=wb(Mb)({onFulfilled:(e,t)=>{e.customAttributes.data=t.payload}},Cb((e=>e.customAttributes))),Ub={action:Mb,reducer:Pb},Tb=nc("users/search",((e,{extra:{api:t},getState:i})=>{const n=i().searchParams;return t.user.search(Object.assign(Object.assign({},n),e))})),Wb=wb(Tb)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.usersList.data=t.payload}},Cb((e=>e.usersList))),Lb={action:Tb,reducer:Wb},Db=nc("tenant/getTenantRoles",((e,{extra:{api:t}})=>t.tenant.getTenantRoles())),_b=wb(Db)({onFulfilled:(e,t)=>{e.tenantRoles.data=t.payload.roles}},Cb((e=>e.tenantRoles))),Fb={action:Db,reducer:_b},qb=nc("tenant/getSubTenantRoles",((e,{extra:{api:t}})=>t.tenant.getSubTenantRoles())),Bb=wb(qb)({onFulfilled:(e,t)=>{e.subTenantRoles.data=t.payload.roles},onRejected:e=>{e.subTenantRoles.data=[]}},Cb((e=>e.subTenantRoles))),Vb={action:qb,reducer:Bb},Kb=nc("users/update",((e,{extra:{api:t}})=>t.user.update(e))),Hb=wb(Kb)({onFulfilled:(e,t)=>{const i=e.usersList.data.findIndex((e=>wn(e.loginIds,t.payload.loginIds)));-1!==i&&(e.usersList.data[i]=t.payload)}},Cb((e=>e.updateUser)),kb({getSuccessMsg:()=>"User updated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to update user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),zb={action:Kb,reducer:Hb},Gb=nc("users/enable",((e,{extra:{api:t}})=>t.user.enable(e))),Jb=wb(Gb)({onFulfilled:(e,t)=>{var i;const n=e.usersList.data.findIndex((e=>{var i;return wn(e.loginIds,null===(i=t.payload.user)||void 0===i?void 0:i.loginIds)}));-1!==n&&(e.usersList.data[n].status=null===(i=t.payload.user)||void 0===i?void 0:i.status)}},Cb((e=>e.enableUser)),kb({getSuccessMsg:()=>"User enabled successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to enable user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Zb={action:Gb,reducer:Jb},Yb=nc("users/disable",((e,{extra:{api:t}})=>t.user.disable(e))),Xb=wb(Yb)({onFulfilled:(e,t)=>{var i;const n=e.usersList.data.findIndex((e=>{var i;return wn(e.loginIds,null===(i=t.payload.user)||void 0===i?void 0:i.loginIds)}));-1!==n&&(e.usersList.data[n].status=null===(i=t.payload.user)||void 0===i?void 0:i.status)}},Cb((e=>e.disableUser)),kb({getSuccessMsg:()=>"User disabled successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to disable user</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),Qb={action:Yb,reducer:Xb},e$=nc("users/removePasskey",((e,{extra:{api:t}})=>t.user.removePasskey(e))),t$={action:e$,reducer:wb(e$)(Cb((e=>e.removePasskey)),kb({getSuccessMsg:()=>"Successfully removed user's passkey",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to remove user's passkey</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}}))},i$={usersList:{data:[],loading:!1,error:null},createUser:{loading:!1,error:null},updateUser:{loading:!1,error:null},deleteUser:{loading:!1,error:null},enableUser:{loading:!1,error:null},disableUser:{loading:!1,error:null},removePasskey:{loading:!1,error:null},setTempUserPassword:{loading:!1,error:null},customAttributes:{loading:!1,error:null,data:[]},tenantRoles:{loading:!1,error:null,data:[]},subTenantRoles:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedUsersLoginIds:[],notifications:[]},n$="/v1/mgmt/user/search",o$="/v1/mgmt/user/delete/batch",r$="/v1/mgmt/user/create",s$="/v1/mgmt/user/patch",a$="/v1/mgmt/user/update/status",d$="/v1/mgmt/user/password/set/temporary",l$="/v1/mgmt/user/passkeys/delete",c$="/v1/mgmt/user/customattributes",u$="/v1/mgmt/role/all",h$="/v1/mgmt/role/subtenant/all",f$=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),p$=({httpClient:e,tenant:t,mock:i})=>({search:(...n)=>c(void 0,[...n],void 0,(function*({page:n,limit:o=1e4,customAttributes:r,statuses:s,emails:a,phones:d,text:l,sort:u}={}){if(i)return(e=>c(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((i=>{const n=[],o=(new Date).getTime();for(let e=1;e<10;e+=1)n.push({loginIds:[`user${e}@company.com`],externalIds:[`user${e}@company.com`],userId:`user-${e}`,name:`User ${e}`,email:`user${e}@company.com`,roleNames:[`Role ${e}`],phone:`+1-202-555-010${e}`,verifiedEmail:!0,verifiedPhone:!0,userTenants:[{tenantId:"sub-tenant-1",tenantName:"Hurray",roleNames:["Role 1","Role 2"]}],status:"enabled",editable:!0,createdTime:o,createdTimeFormatted:new Date(1e3*(o||0)).toLocaleString(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:"",password:!0,SAML:e%3==0,OIDC:e%3==1,SCIM:e%3==2,test:!1,TOTP:!1,webauthn:!1});t.forEach((e=>{n.sort(((t,i)=>((e,t,i)=>{if("boolean"==typeof e&&"boolean"==typeof t){const n=e?1:0,o=t?1:0;return i?n-o:o-n}const n=(null==e?void 0:e.toString())||"",o=(null==t?void 0:t.toString())||"";return i?o.localeCompare(n):n.localeCompare(o)})(t[e.field],i[e.field],e.desc)))})),i(n.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.phone.toLowerCase().includes(e.toLowerCase())||t.status.toLowerCase().includes(e.toLowerCase())||"active"===e.toLowerCase()||t.familyName.toLowerCase().includes(e.toLowerCase())||t.givenName.toLowerCase().includes(e.toLowerCase())||t.middleName.toLowerCase().includes(e.toLowerCase())||t.email.toLowerCase().includes(e.toLowerCase()))))}))})))({page:n,limit:o,customAttributes:r,statuses:s,emails:a,phones:d,text:l,sort:u});const h=yield e.post(n$,{limit:o,page:n,withTestUser:!1,customAttributes:r,statuses:s,emails:a,phones:d,text:l,sort:u},{queryParams:{tenant:t}});return yield f$(h),(yield h.json()).users})),deleteBatch:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(o$,{userIds:n},{queryParams:{tenant:t}});return yield f$(o),o.json()})),create:n=>c(void 0,[n],void 0,(function*({loginId:n,email:o,phone:r,displayName:s,roles:a,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,givenName:f,middleName:p,familyName:g,additionalLoginIds:v,sendSMS:m,sendMail:y,inviteUrl:b,invite:$,userTenants:w}){if(i)return(e=>c(void 0,[e],void 0,(function*({loginId:e,email:t,phone:i,displayName:n,roles:o,customAttributes:r,picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,userTenants:h}){return new Promise((f=>{const p=Math.random().toString(10).substring(15);f({loginIds:[e],externalIds:[e],userId:`user-${p}`,email:t,phone:i,name:n,roleNames:o,customAttributes:r,picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,createdTime:(new Date).getTime(),editable:!0,password:!0,SAML:!1,SCIM:!1,OIDC:!1,status:"enabled",test:!1,TOTP:!1,userTenants:h||[],webauthn:!1})}))})))({loginId:n,email:o,phone:r,displayName:s,roles:a,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,givenName:f,middleName:p,familyName:g,additionalLoginIds:v,sendSMS:m,sendMail:y,inviteUrl:b,invite:$,userTenants:w});const C=yield e.post(r$,{loginId:n,email:o,phone:r,displayName:s,givenName:f,middleName:p,familyName:g,roleNames:a,userTenants:w,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,additionalLoginIds:v,sendSMS:m,sendMail:y,inviteUrl:b,invite:$},{queryParams:{tenant:t}});return yield f$(C),(yield C.json()).user})),update:n=>c(void 0,[n],void 0,(function*({loginId:n,email:o,phone:r,displayName:s,roles:a,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,givenName:f,middleName:p,familyName:g,additionalLoginIds:v,userTenants:m}){if(i)return(e=>c(void 0,[e],void 0,(function*({loginId:e,email:t,phone:i,displayName:n,roles:o,customAttributes:r,picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,userTenants:h}){return new Promise((f=>{f({loginIds:[e],externalIds:[e],userId:e,email:t,phone:i,name:n,roleNames:o,customAttributes:r||{},picture:s,verifiedEmail:a,verifiedPhone:d,givenName:l,middleName:c,familyName:u,createdTime:(new Date).getTime(),editable:!0,password:!0,SAML:!1,SCIM:!1,OIDC:!1,status:"enabled",test:!1,TOTP:!1,userTenants:h||[],webauthn:!1})}))})))({loginId:n,email:o,phone:r,displayName:s,roles:a,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,givenName:f,middleName:p,familyName:g,additionalLoginIds:v,userTenants:m});const y=yield e.patch(s$,{loginId:n,email:o,phone:r,displayName:s,givenName:f,middleName:p,familyName:g,roleNames:a,userTenants:m,customAttributes:d,picture:l,verifiedEmail:u,verifiedPhone:h,additionalLoginIds:v},{queryParams:{tenant:t}});return yield f$(y),(yield y.json()).user})),enable:n=>c(void 0,void 0,void 0,(function*(){if(i)return(e=>c(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({user:{loginIds:[e],status:"enabled"}})}))})))(n);const o=yield e.post(a$,{loginId:n,status:"enabled"},{queryParams:{tenant:t}});return yield f$(o),o.json()})),disable:n=>c(void 0,void 0,void 0,(function*(){if(i)return(e=>c(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({user:{loginIds:[e],status:"disabled"}})}))})))(n);const o=yield e.post(a$,{loginId:n,status:"disabled"},{queryParams:{tenant:t}});return yield f$(o),o.json()})),removePasskey:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){}));const o=yield e.post(l$,{loginId:n},{queryParams:{tenant:t}});return yield f$(o),o.json()})),setTempPassword:n=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({cleartext:Math.random().toString(20).substring(2)})}))}));const o=yield e.post(d$,{loginId:n},{queryParams:{tenant:t}});return yield f$(o),o.json()})),getCustomAttributes:()=>c(void 0,void 0,void 0,(function*(){if(i)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e([])}))}));const n=yield e.get(c$,{queryParams:{tenant:t}});return yield f$(n),(yield n.json()).data}))}),g$=({httpClient:e,tenant:t,mock:i})=>({getTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(i)return(e=>new Promise((t=>{const i=[];for(let t=1;t<5;t+=1)i.push({name:`Role ${t}`,description:`Role description ${t}`,createdTime:new Date,permissionNames:[`Permission ${t}`],tenantId:e});t({roles:i})})))(t);const n=yield e.get(u$,{queryParams:{tenant:t}});return yield f$(n),n.json()})),getSubTenantRoles:()=>c(void 0,void 0,void 0,(function*(){if(i)return new Promise((e=>{e({roles:[{tenantId:"sub-tenant-1",tenantName:"Sub Tenant 1",roleNames:["Role 1","Role 2"]},{tenantId:"sub-tenant-2",tenantName:"Sub Tenant 2",roleNames:["Role 1","Role 3"]},{tenantId:"sub-tenant-3",tenantName:"Sub Tenant 3",roleNames:["Role 2"]}]})}));const n=yield e.get(h$,{queryParams:{tenant:t}});return yield f$(n),n.json()}))}),v$=Rn((e=>{var t,i,n,o;const r=bn(Vr,pc,qr,Ur,Kr,vc,Br({tenant:Br.missingAttrValidator}))(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||us}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i,n)=>{const o=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-management-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.13.3"}}));return{user:p$({httpClient:o.httpClient,tenant:t,mock:i}),tenant:g$({httpClient:o.httpClient,tenant:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},o})),m$=Rn((e=>{const t=bn(hc({name:"widget",initialState:i$,reducers:{setSelectedUsersIds:(e,{payload:t})=>{e.selectedUsersLoginIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{Rb.reducer(e),zb.reducer(e),Zb.reducer(e),Qb.reducer(e),Eb.reducer(e),Lb.reducer(e),jb.reducer(e),t$.reducer(e),Ub.reducer(e),Fb.reducer(e),Vb.reducer(e)},asyncActions:{searchUsers:Lb.action,createUser:Rb.action,updateUser:zb.action,enableUser:Zb.action,disableUser:Qb.action,deleteUsers:Eb.action,removePasskey:t$.action,getCustomAttributes:Ub.action,getTenantRoles:Fb.action,getSubTenantRoles:Vb.action,setTempUserPassword:jb.action}}),Fr,Ur,v$)(e);return class extends t{constructor(...e){super(...e),this.state=i$,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),y$=Rn((e=>{const t=bn(Gr,pc)(e);return class extends t{fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),b$=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,y$,m$,gc)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.injectStyle(".hidden { display: none; }");const o=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([u(this,t,"m",i).call(this),this.actions.searchUsers(),this.actions.getTenantRoles(),this.actions.getCustomAttributes(),o]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),$$=Rn((e=>{var t,i,n,o,r,s,a,d,l;return l=class extends(bn(m$,sd,fc,Ur,gc,b$)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),a.set(this,(()=>c(this,void 0,void 0,(function*(){yield u(this,i,"f").setData(zy(this.state).map((({name:e})=>({value:e,label:e}))))})))),d.set(this,(()=>{var e;const t=Xy(this.state);null===(e=u(this,n,"f"))||void 0===e||e.classList.toggle("hidden",!t),t&&u(this,o,"f").setData(Yy(this.state))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",r).call(this)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,a=new WeakMap,d=new WeakMap,t=new WeakSet,r=function(){return c(this,void 0,void 0,(function*(){var e;this.createUserModal=this.createModal(),this.createUserModal.setContent($n(yield this.fetchWidgetPage("create-user-modal.html")));const r=new Da((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}),l=()=>{this.resetFormData(this.createUserModal.ele),u(this,o,"f").value=[]};r.onClick((()=>{this.createUserModal.close(),l()}));const f=new Da((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});f.onClick((()=>c(this,void 0,void 0,(function*(){if(this.validateForm(this.createUserModal.ele)){const e=this.getFormData(this.createUserModal.ele),t=u(this,o,"f").mergedValue;this.actions.createUser(Object.assign(Object.assign({},Fy(e,"customAttributes")),{userTenants:t,invite:!0,verifiedEmail:!0,verifiedPhone:!0})),this.createUserModal.close(),l()}})))),h(this,i,new Ja((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),h(this,n,null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-section"]'),"f"),h(this,o,new Ga((()=>{var e;return null===(e=this.createUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-mappings"]')}),{logger:this.logger}),"f"),u(this,a,"f").call(this),this.createUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([this.actions.getTenantRoles(),e]),yield u(this,a,"f").call(this),u(this,d,"f").call(this),u(this,t,"m",s).call(this)}))}))},s=function(){const e=Zy(this.state);this.getFormFieldNames(this.createUserModal.ele).forEach((t=>{const[i,n]=t.split(".");if("customAttributes"!==i)return;const o=e.find((e=>e.name===n));o?o.editable||this.disableFormField(this.createUserModal.ele,t):this.removeFormField(this.createUserModal.ele,t)}))},l})),w$=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,$$,b$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){var e;this.createButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-user"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createUserModal.open()))},n})),C$=Rn((e=>{var t,i,n;return n=class extends(bn(m$,sd,Ur,b$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){var e;this.deleteUsersModal=this.createModal(),this.deleteUsersModal.setContent($n(yield this.fetchWidgetPage("delete-users-modal.html")));const t=new Da((()=>{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 i=new Da((()=>{var e;return null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=ob(this.state);this.actions.deleteUsers(e),this.deleteUsersModal.close()}));const n=new Qa(null===(e=this.deleteUsersModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteUsersModal.beforeOpen=()=>{const e=pb(this.state);n.text=`Delete ${e}?`}}))},n})),k$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,b$,m$,C$)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),$b)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.deleteButton=new Da(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()}))},o})),S$=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(m$,sd,Ur,fc,b$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,i=function(){new Da((()=>{var e;return null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.disableUserModal.close()))},n=function(){new Da((()=>{var e;return null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=ub(this.state);this.actions.disableUser(e),this.disableUserModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.disableUserModal=this.createModal(),this.disableUserModal.setContent($n(yield this.fetchWidgetPage("disable-user-modal.html"))),u(this,t,"m",i).call(this),u(this,t,"m",n).call(this);const o=new Qa(null===(e=this.disableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.disableUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=pb(this.state);o.text=`Disable ${e}?`}))}))},r})),I$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,b$,m$,S$,fc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.disableButton.enable():this.disableButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),vb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.disableButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="disable-user"]'),{logger:this.logger}),this.disableButton.disable(),this.disableButton.onClick((()=>{this.disableUserModal.open()}))},o})),R$=e=>{if(!e)return e;const t=Wy(e.startsWith("+")?e:`+${e}`);if(!t)return e;const i=new RegExp(`(\\+?${null==t?void 0:t.countryCallingCode})(.*)`);return(null==t?void 0:t.number.replace(i,"$1-$2"))||e},x$=Rn((e=>{var t,i,n,o,r,s,a,d,f,p,g,v,m;return m=class extends(bn(m$,sd,Ur,fc,gc,b$)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),d.set(this,(()=>c(this,void 0,void 0,(function*(){yield u(this,n,"f").setData(zy(this.state).map((({name:e})=>({value:e,label:e}))))})))),f.set(this,(()=>{var e;const t=Xy(this.state);null===(e=u(this,o,"f"))||void 0===e||e.classList.toggle("hidden",!t),t&&u(this,r,"f").setData(Yy(this.state))})),g.set(this,(()=>{var e,t;const i=null===(e=nb(this.state))||void 0===e?void 0:e[0],n=Object.assign({loginId:null===(t=null==i?void 0:i.loginIds)||void 0===t?void 0:t.join(", "),displayName:null==i?void 0:i.name,email:null==i?void 0:i.email,phone:R$(null==i?void 0:i.phone),roles:null==i?void 0:i.roleNames,givenName:null==i?void 0:i.givenName,familyName:null==i?void 0:i.familyName,middleName:null==i?void 0:i.middleName},qy(i.customAttributes,"customAttributes"));this.setFormData(this.editUserModal.ele,n),u(this,r,"f").value=(null==i?void 0:i.userTenants)||[]}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",v).call(this)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,d=new WeakMap,f=new WeakMap,g=new WeakMap,t=new WeakSet,s=function(){new Da((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.editUserModal.close()))},a=function(){new Da((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{if(this.validateForm(this.editUserModal.ele)){const e=this.getFormData(this.editUserModal.ele),{loginId:t}=e,i=l(e,["loginId"]),n=u(this,o,"f")&&!u(this,o,"f").classList.contains("hidden")?u(this,r,"f").mergedValue:void 0;this.actions.updateUser(Object.assign(Object.assign({loginId:t.split(", ")[0]},Fy(i,"customAttributes")),void 0!==n&&{userTenants:n})),this.editUserModal.close(),this.resetFormData(this.editUserModal.ele)}}))},p=function(){const e=Zy(this.state);this.getFormFieldNames(this.editUserModal.ele).forEach((t=>{const[i,n]=t.split(".");if("customAttributes"!==i)return;const o=e.find((e=>e.name===n));o?o.editable||this.disableFormField(this.editUserModal.ele,t):this.removeFormField(this.editUserModal.ele,t)}))},v=function(){return c(this,void 0,void 0,(function*(){var e,l;this.editUserModal=this.createModal(),this.editUserModal.setContent($n(yield this.fetchWidgetPage("edit-user-modal.html"))),u(this,t,"m",s).call(this),u(this,t,"m",a).call(this),h(this,i,new ed(null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[name="loginId"]'),{logger:this.logger}),"f"),h(this,n,new Ja((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="roles-multiselect"]')}),{logger:this.logger}),"f"),h(this,o,null===(l=this.editUserModal.ele)||void 0===l?void 0:l.querySelector('[data-id="sub-tenant-section"]'),"f"),h(this,r,new Ga((()=>{var e;return null===(e=this.editUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="sub-tenant-mappings"]')}),{logger:this.logger}),"f"),this.editUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=this.getWidgetConfig().then((e=>(null==e?void 0:e.allowSubTenants)?this.actions.getSubTenantRoles():void 0));yield Promise.all([this.actions.getTenantRoles(),e]),yield u(this,d,"f").call(this),u(this,i,"f").disable(),u(this,f,"f").call(this),u(this,g,"f").call(this),u(this,t,"m",p).call(this)}))}))},m})),O$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,b$,m$,x$,fc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),mb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.editButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-user"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editUserModal.open()}))},o})),E$=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(m$,sd,Ur,fc,b$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,i=function(){new Da((()=>{var e;return null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.enableUserModal.close()))},n=function(){new Da((()=>{var e;return null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=ub(this.state);this.actions.enableUser(e),this.enableUserModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.enableUserModal=this.createModal(),this.enableUserModal.setContent($n(yield this.fetchWidgetPage("enable-user-modal.html"))),u(this,t,"m",i).call(this),u(this,t,"m",n).call(this);const o=new Qa(null===(e=this.enableUserModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.enableUserModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=pb(this.state);o.text=`Activate ${e}?`}))}))},r})),A$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,b$,m$,E$,fc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.enableButton.enable():this.enableButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),gb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.enableButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="enable-user"]'),{logger:this.logger}),this.enableButton.disable(),this.enableButton.onClick((()=>{this.enableUserModal.open()}))},o})),N$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,b$,m$)(e)){constructor(){super(...arguments),t.add(this),i.set(this,In((()=>{this.actions.searchUsers({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this)}))}},i=new WeakMap,t=new WeakSet,n=function(){var e;this.searchInput=new ed(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(u(this,i,"f"))},o})),j$={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="currentcolor"/>\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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},M$=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,m$,dd,Fr)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Cn((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",n).call(this,e);r.setContent(u(this,t,"m",i).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),Jy)}))}},o=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const i=j$[e],n=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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${n.outerHTML}`},n=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),P$=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(m$,sd,Ur,fc,b$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,i=function(){new Da((()=>{var e;return null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.removePasskeyModal.close()))},n=function(){new Da((()=>{var e;return null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>{const e=ub(this.state);this.actions.removePasskey(e),this.removePasskeyModal.close()}))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.removePasskeyModal=this.createModal(),this.removePasskeyModal.setContent($n(yield this.fetchWidgetPage("remove-passkey-modal.html"))),u(this,t,"m",i).call(this),u(this,t,"m",n).call(this);const o=new Qa(null===(e=this.removePasskeyModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.removePasskeyModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=pb(this.state);o.text=`Remove passkey for ${e}?`}))}))},r})),U$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,b$,m$,P$,fc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.removePasskeyButton.enable():this.removePasskeyButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),yb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.removePasskeyButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="remove-passkey"]'),{logger:this.logger}),this.removePasskeyButton.disable(),this.removePasskeyButton.onClick((()=>{this.removePasskeyModal.open()}))},o})),T$=Rn((e=>{var t,i,n,o,r,s,a,d;return d=class extends(bn(m$,Ur,b$)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Cn((e=>{this.usersTable.data=e}))),r.set(this,In(((e,t)=>{const i=[],{value:n}=t;if(n){const t=e.path;i.push({field:t,desc:"desc"===n})}this.actions.searchUsers({sort:i})}))),s.set(this,Cn((e=>{this.usersTable.filterColumns((t=>{var i;const[n,o]=(null===(i=t.path)||void 0===i?void 0:i.split("."))||[];return"customAttributes"!==n||!!(null==e?void 0:e.find((e=>e.name===o)))}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",n).call(this),u(this,o,"f").call(this,ib(this.state)),u(this,s,"f").call(this,Zy(this.state)),this.subscribe(u(this,s,"f").bind(this),Zy),this.subscribe(u(this,o,"f").bind(this),ib)}))}},o=new WeakMap,r=new WeakMap,s=new WeakMap,t=new WeakSet,i=function(){const e=e=>{var t;return null===(t=this.usersTable.ele)||void 0===t?void 0:t.querySelector(`[path="${e}"]`)},t=e=>{var t;const i=`descope-grid-${e}-column`;return null===(t=this.usersTable.ele)||void 0===t?void 0:t.querySelector(i)},i=this.usersTable.renderColumn;this.usersTable.renderColumn=({path:n,header:o,type:r,attrs:s})=>{const a=e(n)||t(r);if(!a)return i({path:n,header:o,type:r,attrs:s});const d=a.cloneNode(!0),l=Object.assign(Object.assign({},s),{header:o});return Object.entries(l).forEach((([e,t])=>{d.setAttribute(e,t)})),d.outerHTML}},n=function(){var e;this.usersTable=new Va(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)))})),this.usersTable.onColumnsChange(u(this,t,"m",a).bind(this)),u(this,t,"m",i).call(this),u(this,t,"m",a).call(this)},a=function(){this.usersTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{u(this,r,"f").call(this,e.target,e.detail)}))}))},d})),W$=Rn((e=>{var t,i,n;return n=class extends(bn(m$,sd,Ur,fc,b$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),yield u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){this.generatedPasswordModal=this.createModal(),this.generatedPasswordModal.setContent($n(yield this.fetchWidgetPage("generated-password-modal.html"))),new Da((()=>{var e;return null===(e=this.generatedPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-close"]')}),{logger:this.logger}).onClick((()=>{navigator.clipboard.writeText(this.getFormData(this.generatedPasswordModal.ele)["generated-password"]),this.resetFormData(this.generatedPasswordModal.ele),this.generatedPasswordModal.close()}))}))},n})),L$=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(m$,sd,Ur,fc,b$,W$)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield u(this,t,"m",o).call(this)}))}},t=new WeakSet,i=function(){new Da((()=>{var e;return null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger}).onClick((()=>this.resetPasswordModal.close()))},n=function(){new Da((()=>{var e;return null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger}).onClick((()=>c(this,void 0,void 0,(function*(){var e;const t=ub(this.state),i=yield this.actions.setTempUserPassword(t);this.resetPasswordModal.close(),this.setFormData(this.generatedPasswordModal.ele,{"generated-password":null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e.cleartext}),this.generatedPasswordModal.open()}))))},o=function(){return c(this,void 0,void 0,(function*(){var e;this.resetPasswordModal=this.createModal(),this.resetPasswordModal.setContent($n(yield this.fetchWidgetPage("reset-password-modal.html"))),u(this,t,"m",i).call(this),u(this,t,"m",n).call(this);const o=new Qa(null===(e=this.resetPasswordModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.resetPasswordModal.beforeOpen=()=>c(this,void 0,void 0,(function*(){const e=pb(this.state);o.text=`This will generate a new temporary password for ${e}?`}))}))},r})),D$=Rn((e=>{var t,i,n,o;return o=class extends(bn(Ur,b$,m$,L$,fc)(e)){constructor(){super(...arguments),t.add(this),n.set(this,Cn((e=>{e?this.resetPasswordButton.enable():this.resetPasswordButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var o;u(this,t,"m",i).call(this),yield null===(o=e.onWidgetRootReady)||void 0===o?void 0:o.call(this),this.subscribe(u(this,n,"f").bind(this),bb)}))}},n=new WeakMap,t=new WeakSet,i=function(){var e;this.resetPasswordButton=new Da(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="reset-password"]'),{logger:this.logger}),this.resetPasswordButton.disable(),this.resetPasswordButton.onClick((()=>{this.resetPasswordModal.open()}))},o})),_$=Rn((e=>class extends(bn(ms,qr)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),F$=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g,v,m;return m=class extends(bn(_$,m$,sd,Ur,fc,b$)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,[]),r.set(this,null),s.set(this,null),v.set(this,Cn((e=>{u(this,o,"f").forEach((t=>{"onlyOne"===t.enableMode&&1===e.length||"oneOrMore"===t.enableMode&&e.length>0||"always"===t.enableMode?t.enable():t.disable()}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",l).call(this),u(this,t,"m",d).call(this),u(this,v,"f").call(this,Gy(this.state))}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,v=new WeakMap,t=new WeakSet,a=function(e){const i=new Fa(e,{logger:this.logger});i.onClick((()=>{u(this,t,"m",g).call(this,i.flowId)})),this.subscribe(u(this,v,"f").bind(this),Gy),u(this,o,"f").push(i)},d=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(i).forEach((e=>{u(this,t,"m",a).call(this,e)}))},l=function(){h(this,i,this.createModal({"data-id":"generic-flow-modal"}),"f"),u(this,i,"f").afterClose=()=>{var e;u(this,r,"f")&&(null===(e=u(this,s,"f"))||void 0===e||e.call(this),h(this,r,null,"f"))},h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,n,"f"))},f=function(){var e;u(this,i,"f").open(),null===(e=u(this,s,"f"))||void 0===e||e.call(this)},p=function(e,i){i=()=>u(this,t,"m",f).call(this),h(this,s,u(this,n,"f").onPageUpdated(i),"f")},g=function(e){u(this,i,"f").setContent(Vy({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,client:JSON.stringify({userIds:ob(this.state),loginIds:rb(this.state),usersAndRoles:sb(this.state)}),tenant:this.tenantId})),u(this,t,"m",p).call(this,u(this,i,"f"),u(this,r,"f")),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.searchUsers()}))},m})),q$="widget-flow",B$=Rn((e=>{var t,i,n;return n=class extends(bn(Fr,sd,m$,vc,Ur,ms)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const o=Ky(q$);o&&(function(e){if(window.history.replaceState&&Ky(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(q$),u(this,t,"m",i).call(this,o))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(Vy({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),new _a((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close()})),t.afterClose=()=>{t.remove()},t.open()},n})),V$=Rn((e=>class extends(bn(ja,ms,B$,T$,w$,k$,O$,A$,I$,D$,U$,N$,M$,F$)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),K$=bn((e=>class extends(V$(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Na})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-management-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.13.3"}}}))}}))(HTMLElement);customElements.define("descope-user-management-widget",K$);var H$=Object.freeze({__proto__:null,default:K$});const z$=(e={})=>{const t=$n("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,i])=>{t.content.querySelector("descope-wc").setAttribute(kn(e),(e=>"string"==typeof e?e:(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(i))})),t};function G$(e){return new URLSearchParams(window.location.search).get(e)}const J$=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},Z$=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),Y$=nc("users/me",((e,{extra:{api:t}})=>t.user.me())),X$=J$(Y$)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Z$((e=>e.me))),Q$={action:Y$,reducer:X$},ew=nc("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),tw=J$(ew)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},Z$((e=>e.devices))),iw={action:ew,reducer:tw},nw=nc("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),ow=J$(nw)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},Z$((e=>e.passkeys))),rw={action:nw,reducer:ow},sw=nc("users/logout",((e,{extra:{api:t}})=>t.user.logout())),aw={action:sw,reducer:J$(sw)({})},dw=e=>{if(!e)return null;const t=(e=>{try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(t).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""));return JSON.parse(i)}catch(e){return null}})(e);return(null==t?void 0:t.dct)||null},lw=e=>e.me.data,cw=Sl(lw,(e=>e.userId)),uw=Sl(lw,(e=>e.picture)),hw=Sl(lw,(e=>e.email)),fw=Sl(lw,(e=>e.verifiedEmail)),pw=Sl(lw,(e=>e.name)),gw=Sl(lw,(e=>e.phone)),vw=Sl(lw,(e=>e.verifiedPhone)),mw=Sl(hw,fw,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),yw=Sl(gw,vw,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),bw=Sl(lw,(e=>e.webauthn));Sl(lw,(e=>e.password));const $w=Sl(lw,(e=>e.TOTP)),ww=Sl(lw,(e=>e.customAttributes)),Cw=Sl(lw,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),kw=Sl((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:i,lastLoginTime:n,isCurrentDevice:o})=>({id:e,name:t,deviceType:i,lastLoginDate:1e3*parseInt(n,10),isCurrent:o}))))),Sw=Sl((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:i,createdTime:n})=>({id:e,name:t,passkeyType:i,createdAt:1e3*n}))))),Iw=e=>e.notifications,Rw=Sl(lw,(e=>e.userTenants||[])),xw=e=>e.tenant.currentTenantId,Ow=nc("tenant/select",((e,t)=>c(void 0,[e,t],void 0,(function*(e,{extra:{api:t},getState:i}){if(e===xw(i()))return null;const n=yield t.user.setCurrentTenant(e),o=n.sessionJwt||n.sessionToken;try{return{tenantId:dw(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),Ew={action:Ow,reducer:J$(Ow)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var i;e.tenant.currentTenantId=null===(i=t.payload)||void 0===i?void 0:i.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},Z$((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{if(t){const n=t(i);n&&e.notifications.push({type:"success",msg:n})}},onRejected:(t,i)=>{if(e){const n=e(i);n&&t.notifications.push({type:"error",msg:n})}}}))({getErrorMsg:e=>{var t,i;const n=(null===(t=e.error)||void 0===t?void 0:t.message)||"";return"Error"===(null===(i=e.error)||void 0===i?void 0:i.name)?n:`${n||"Error"}`}}))},Aw={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},Nw="/v1/auth/me",jw="/v1/mgmt/user/trusteddevices/list",Mw="/v1/mgmt/user/passkeys/list",Pw="/v1/auth/tenant/select",Uw=e=>c(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),Tw=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],Ww=({httpClient:e,mock:t})=>({me:()=>c(void 0,void 0,void 0,(function*(){if(t)return c(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:Tw,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))}));const i=yield e.get(Nw);return yield Uw(i),i.json()})),setCurrentTenant:t=>c(void 0,void 0,void 0,(function*(){const i=yield e.post(Pw,{tenant:t});return yield Uw(i),i.json()}))}),Lw=({httpClient:e,mock:t})=>({devices:i=>c(void 0,[i],void 0,(function*({userId:i}){if(t)return{devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]};const n=yield e.post(jw,{identifiers:[i]});return yield Uw(n),n.json()}))}),Dw=({httpClient:e,mock:t})=>({listPasskeys:i=>c(void 0,[i],void 0,(function*({userId:i}){if(t)return{passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]};const n=yield e.post(Mw,{loginId:i});return yield Uw(n),n.json()}))}),_w=Rn((e=>{var t,i,n,o;const r=bn(Vr,qr,Ur,Kr,vc)(e);return o=class extends r{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||us}get api(){return u(this,i,"f")||u(this,t,"m",n).call(this),u(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var o;yield null===(o=e.init)||void 0===o?void 0:o.call(this),this.observeAttributes(["project-id","base-url"],(()=>{u(this,i,"f")&&u(this,t,"m",n).call(this)}))}))}},i=new WeakMap,t=new WeakSet,n=function(){this.logger.debug("creating an sdk instance"),h(this,i,((e,t,i)=>{const n=cn(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.11.5"}}));return{user:Object.assign(Object.assign({},Ww({httpClient:n.httpClient,mock:t})),{logout:t?()=>c(void 0,void 0,void 0,(function*(){})):n.logout}),device:Object.assign({},Lw({httpClient:n.httpClient,mock:t})),passkey:Object.assign({},Dw({httpClient:n.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},o})),Fw=Rn((e=>{const t=bn(hc({name:"widget",initialState:Aw,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{Q$.reducer(e),iw.reducer(e),rw.reducer(e),aw.reducer(e),Ew.reducer(e)},asyncActions:{getMe:Q$.action,listDevices:iw.action,listPasskeys:rw.action,logout:aw.action,selectTenant:Ew.action}}),Fr,Ur,_w)(e);return class extends t{constructor(...e){super(...e),this.state=Aw,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),qw="widget-flow",Bw=Rn((e=>{var t,i,n;return n=class extends(bn(Fr,sd,Fw,vc,Ur,ms)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const o=G$(qw);o&&(function(e){if(window.history.replaceState&&G$(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(qw),u(this,t,"m",i).call(this,o))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(z$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),new _a((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},n})),Vw=Rn((e=>{const t=bn(Gr,Br({"widget-id":Br.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return c(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Kw=Rn((e=>{var t,i,n;return n=class extends(bn(Ur,Fr,os,cs,Vw,Fw)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return c(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield this.actions.getMe(),yield u(this,t,"m",i).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,i=function(){return c(this,void 0,void 0,(function*(){const e=$n(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),Hw=Rn((e=>class extends(bn(ms,qr)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),zw=Rn((e=>{var t,i,n,o,r,s,a,d,l;return l=class extends(bn(Hw,ms,Fw,Ur,vc,Kw,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),a.set(this,Cn((e=>{this.avatar.image=e}))),d.set(this,Cn((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",s).call(this),u(this,t,"m",o).call(this),u(this,a,"f").call(this,uw(this.state)),u(this,d,"f").call(this,pw(this.state)),this.subscribe(u(this,a,"f").bind(this),uw),this.subscribe(u(this,d,"f").bind(this),pw)}))}},i=new WeakMap,n=new WeakMap,a=new WeakMap,d=new WeakMap,t=new WeakSet,o=function(){this.avatar.flowId&&(h(this,i,this.createModal({"data-id":"update-pic"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,n,"f")))},r=function(){u(this,i,"f").setContent(z$({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},s=function(){this.avatar=new La((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))},l})),Gw=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g,v;return v=class extends(bn(Hw,Fw,Ur,Kw,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.emailUserAttr.value=e}))),g.set(this,Cn((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,hw(this.state)),u(this,g,"f").call(this,mw(this.state)),this.subscribe(u(this,p,"f").bind(this),hw),this.subscribe(u(this,g,"f").bind(this),mw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,g=new WeakMap,t=new WeakSet,s=function(){this.emailUserAttr.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-email"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(z$({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},d=function(){this.emailUserAttr.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-email"}),"f"),h(this,r,new _a((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(z$({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe()}))},f=function(){this.emailUserAttr=new td((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},v})),Jw=Rn((e=>{var t,i,n;return n=class extends(bn(Fw,Ur,Kw,sd)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),u(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){this.logout=new Da((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>c(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},n})),Zw=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Hw,Fw,Ur,Kw,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,pw(this.state)),this.subscribe(u(this,p,"f").bind(this),pw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.nameUserAttr.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-name"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(z$({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},d=function(){this.nameUserAttr.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-name"}),"f"),h(this,r,new _a((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(z$({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe()}))},f=function(){this.nameUserAttr=new td((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),Yw=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Hw,Fw,Ur,Kw,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,bw(this.state)),this.subscribe(u(this,p,"f").bind(this),bw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.passkeyUserAuthMethod.flowId&&(h(this,i,this.createModal({"data-id":"add-passkey"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(z$({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},d=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(h(this,o,this.createModal({"data-id":"remove-passkey"}),"f"),h(this,r,new _a((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(z$({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe()}))},f=function(){this.passkeyUserAuthMethod=new id((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),Xw=Rn((e=>{var t,i,n,o,r,s;return s=class extends(bn(Hw,Fw,Ur,Kw,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new id((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.initPasswordAuthMethod(),u(this,t,"m",o).call(this)}))}},i=new WeakMap,n=new WeakMap,t=new WeakSet,o=function(){this.passwordUserAuthMethod.flowId&&(h(this,i,this.createModal({"data-id":"password"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",r).bind(this),u(this,t,"m",r).call(this),this.syncFlowTheme(u(this,n,"f")))},r=function(){u(this,i,"f").setContent(z$({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close()}))},s})),Qw=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g,v;return v=class extends(bn(Hw,Fw,Ur,Kw,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.phoneUserAttr.value=e}))),g.set(this,Cn((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,gw(this.state)),u(this,g,"f").call(this,yw(this.state)),this.subscribe(u(this,p,"f").bind(this),gw),this.subscribe(u(this,g,"f").bind(this),yw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,g=new WeakMap,t=new WeakSet,s=function(){this.phoneUserAttr.editFlowId&&(h(this,i,this.createModal({"data-id":"edit-phone"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(z$({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},d=function(){this.phoneUserAttr.deleteFlowId&&(h(this,o,this.createModal({"data-id":"delete-phone"}),"f"),h(this,r,new _a((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(z$({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe()}))},f=function(){this.phoneUserAttr=new td((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},v})),eC=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Hw,Fw,Ur,Kw,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),p.set(this,Cn((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",f).call(this),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),u(this,p,"f").call(this,$w(this.state)),this.subscribe(u(this,p,"f").bind(this),$w)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,p=new WeakMap,t=new WeakSet,s=function(){this.totpUserAuthMethod.flowId&&(h(this,i,this.createModal({"data-id":"totp"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(z$({projectId:this.projectId,flowId:this.totpUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},d=function(){this.totpUserAuthMethod.fulfilledFlowId&&(h(this,o,this.createModal({"data-id":"remove-totp"}),"f"),h(this,r,new _a((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,o,"f").afterClose=u(this,t,"m",l).bind(this),u(this,t,"m",l).call(this),this.syncFlowTheme(u(this,r,"f")))},l=function(){u(this,o,"f").setContent(z$({projectId:this.projectId,flowId:this.totpUserAuthMethod.fulfilledFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe()}))},f=function(){this.totpUserAuthMethod=new id((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=u(this,o,"f"))||void 0===e||e.open()}))},g})),tC=Rn((e=>{var t,i,n,o,r,s,a,d,l,h,f;return f=class extends(bn(Hw,Fw,Ur,Kw,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,{}),n.set(this,{}),o.set(this,{}),r.set(this,{}),d.set(this,Cn((e=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("builtin.",""),o=e[n],r=new td(i,{logger:this.logger});r.value=(o||"").toString(),u(this,t,"m",l).call(this,i,n,r),u(this,t,"m",h).call(this,i,n,r)}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),u(this,d,"f").call(this,Cw(this.state)),this.subscribe(u(this,d,"f").bind(this),Cw)}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,d=new WeakMap,t=new WeakSet,s=function(e){var t,o;null===(t=u(this,i,"f")[e])||void 0===t||t.setContent(z$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(o=u(this,n,"f")[e])||void 0===o||o.onSuccess((()=>{var t;null===(t=u(this,i,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},a=function(e){var t,i;null===(t=u(this,o,"f")[e])||void 0===t||t.setContent(z$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(i=u(this,r,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=u(this,o,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},l=function(e,o,r){const a=e.getAttribute("edit-flow-id");a&&(u(this,i,"f")[a]=this.createModal({"data-id":`edit-${o}`}),u(this,n,"f")[a]=new _a((()=>{var e,t;return null===(t=null===(e=u(this,i,"f")[a])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,i,"f")[a].afterClose=u(this,t,"m",s).bind(this,a),r.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,i,"f"))||void 0===e?void 0:e[a])||void 0===t||t.open()})),u(this,t,"m",s).call(this,a),this.syncFlowTheme(u(this,n,"f")[a]))},h=function(e,i,n){const s=e.getAttribute("delete-flow-id");s&&(u(this,o,"f")[s]=this.createModal({"data-id":`delete-${i}`}),u(this,r,"f")[s]=new _a((()=>{var e,t;return null===(t=null===(e=u(this,o,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,o,"f")[s].afterClose=u(this,t,"m",a).bind(this,s),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,o,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),u(this,t,"m",a).call(this,s),this.syncFlowTheme(u(this,r,"f")[s]))},f}));var iC;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(iC||(iC={}));const nC=Rn((e=>{var t,i,n,o,r,s,a,d,l,h,f;return i=class extends(bn(Hw,Fw,Ur,Kw,vc,sd)(e)){constructor(){super(...arguments),t.add(this),n.set(this,{}),o.set(this,{}),r.set(this,{}),s.set(this,{}),l.set(this,Cn((e=>{var n;const o=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(o).forEach((n=>{const o=n.getAttribute("data-id").replace("customAttributes.",""),r=n.getAttribute("data-type")||iC.TEXT,s=e[o],a=new td(n,{logger:this.logger});a.value=i.getFormattedValue(r,s),u(this,t,"m",h).call(this,n,o,a),u(this,t,"m",f).call(this,n,o,a)}))})))}static getFormattedValue(e,t){return e===iC.DATE&&t?new Date(t).toLocaleString():e===iC.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),u(this,l,"f").call(this,ww(this.state)),this.subscribe(u(this,l,"f").bind(this),ww)}))}},n=new WeakMap,o=new WeakMap,r=new WeakMap,s=new WeakMap,l=new WeakMap,t=new WeakSet,a=function(e){var t,i;null===(t=u(this,n,"f")[e])||void 0===t||t.setContent(z$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(i=u(this,o,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=u(this,n,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},d=function(e){var t,i;null===(t=u(this,r,"f")[e])||void 0===t||t.setContent(z$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),null===(i=u(this,s,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=u(this,r,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e,i,r){const s=e.getAttribute("edit-flow-id");s&&(u(this,n,"f")[s]=this.createModal({"data-id":`edit-${i}`}),u(this,o,"f")[s]=new _a((()=>{var e,t;return null===(t=null===(e=u(this,n,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,n,"f")[s].afterClose=u(this,t,"m",a).bind(this,s),r.onEditClick((()=>{var e,t;null===(t=null===(e=u(this,n,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),u(this,t,"m",a).call(this,s),this.syncFlowTheme(u(this,o,"f")[s]))},f=function(e,i,n){const o=e.getAttribute("delete-flow-id");o&&(u(this,r,"f")[o]=this.createModal({"data-id":`delete-${i}`}),u(this,s,"f")[o]=new _a((()=>{var e,t;return null===(t=null===(e=u(this,r,"f")[o])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),u(this,r,"f")[o].afterClose=u(this,t,"m",d).bind(this,o),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=u(this,r,"f"))||void 0===e?void 0:e[o])||void 0===t||t.open()})),u(this,t,"m",d).call(this,o),this.syncFlowTheme(u(this,s,"f")[o]))},i})),oC=Rn((e=>{var t,i,n,o,r,s,a,d;return d=class extends(bn(Hw,ms,Fw,Ur,vc,Kw,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),this.updateDeviceList=Cn((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.deviceList=new nd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield u(this,t,"m",a).call(this),u(this,t,"m",s).call(this,kw(this.state)),u(this,t,"m",o).call(this),this.subscribe(this.updateDeviceList.bind(this),kw))}))}},i=new WeakMap,n=new WeakMap,t=new WeakSet,o=function(){this.deviceList.flowId&&(h(this,i,this.createModal({"data-id":"untrust-device"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=()=>u(this,t,"m",r).call(this,""),this.syncFlowTheme(u(this,n,"f")))},r=function(e=""){u(this,i,"f").setContent(z$({projectId:this.projectId,flowId:this.deviceList.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{deviceId:e}})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.listDevices({userId:cw(this.state)})}))},s=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var n;u(this,t,"m",r).call(this,e),null===(n=u(this,i,"f"))||void 0===n||n.open()})),this.deviceList.data=e},a=function(){return c(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:cw(this.state)})}))},d})),rC=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p,g;return g=class extends(bn(Hw,Fw,Ur,Kw,vc,sd)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,void 0),r.set(this,void 0),f.set(this,Cn((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=Cn((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.userPasskeys=new rd((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(u(this,t,"m",p).call(this,Sw(this.state)),u(this,t,"m",s).call(this),u(this,t,"m",d).call(this),this.subscribe(u(this,f,"f").bind(this),cw),this.subscribe(this.updatePasskeyList.bind(this),Sw))}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,f=new WeakMap,t=new WeakSet,s=function(){this.userPasskeys.addPasskeyFlowId&&(h(this,i,this.createModal({"data-id":"add-user-passkey"}),"f"),h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),u(this,i,"f").afterClose=u(this,t,"m",a).bind(this),u(this,t,"m",a).call(this),this.syncFlowTheme(u(this,n,"f")))},a=function(){u(this,i,"f").setContent(z$({projectId:this.projectId,flowId:this.userPasskeys.addPasskeyFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId})),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:cw(this.state)})}))},d=function(){this.userPasskeys.removePasskeyFlowId&&(h(this,o,this.createModal({"data-id":"remove-user-passkey"}),"f"),h(this,r,new _a((()=>{var e;return null===(e=u(this,o,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,r,"f")))},l=function({externalId:e,credentialId:t}){u(this,o,"f").setContent(z$({projectId:this.projectId,flowId:this.userPasskeys.removePasskeyFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,form:{externalId:e,credentialId:t}})),u(this,r,"f").onSuccess((()=>{u(this,o,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:cw(this.state)})}))},p=function(e){this.updatePasskeyList(e),this.userPasskeys.onAddPasskeyClick((()=>{var e;null===(e=u(this,i,"f"))||void 0===e||e.open()})),this.userPasskeys.onRemovePasskeyClick((({id:e})=>{var i;const n=cw(this.state);u(this,t,"m",l).call(this,{externalId:n,credentialId:e}),null===(i=u(this,o,"f"))||void 0===i||i.open()}))},g})),sC={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="currentcolor"/>\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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},aC=Rn((e=>{var t,i,n,o,r;return r=class extends(bn(Ur,Fw,dd,Fr)(e)){constructor(){super(...arguments),t.add(this),o.set(this,Cn((e=>{e.length&&(e.forEach((({type:e,msg:o})=>{const r=u(this,t,"m",n).call(this,e);r.setContent(u(this,t,"m",i).call(this,{type:e,msg:o})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(u(this,o,"f").bind(this),Iw)}))}},o=new WeakMap,t=new WeakSet,i=function({type:e,msg:t}){const i=sC[e],n=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="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${n.outerHTML}`},n=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},r})),dC=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p;return p=class extends(bn(Fw,Ur,Kw)(e)){constructor(){super(...arguments),t.add(this),i.set(this,null),o.set(this,(e=>c(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),r.set(this,(e=>{const n=xw(e);this.tenantSelector.value!==n&&u(this,t,"m",l).call(this,n);const{loading:o,error:r}=e.selectTenant,a=null!==e.tenant.previousTenantId,d=n!==u(this,i,"f");!n||o||r||a||!d||(h(this,i,n,"f"),u(this,t,"m",s).call(this))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.actions.setCurrentTenantId((()=>{const e=yi();return dw(e)})()),u(this,t,"m",n).call(this),u(this,t,"m",f).call(this),u(this,t,"m",d).call(this,Rw(this.state)),this.subscribe(u(this,r,"f").bind(this))}))}},i=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,n=function(){this.tenantSelector=new od((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(u(this,o,"f"))},s=function(){const e=xw(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&u(this,t,"m",a).call(this)},a=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},d=function(e){return c(this,void 0,void 0,(function*(){const t=e.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(t)}))},l=function(e){e&&(this.tenantSelector.value=e)},f=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{u(this,t,"m",l).call(this,xw(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},p})),lC=Rn((e=>{var t,i,n,o,r,s,a,d,l,f,p;return p=class extends(bn(Hw,Fw,sd,Ur,Kw)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),n.set(this,void 0),o.set(this,[]),r.set(this,null)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return c(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),u(this,t,"m",d).call(this),u(this,t,"m",a).call(this),u(this,o,"f").forEach((e=>e.enable()))}))}},i=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,t=new WeakSet,s=function(e){const i=new Fa(e,{logger:this.logger});i.onClick((()=>{u(this,t,"m",f).call(this,i.flowId,cw(this.state))})),u(this,o,"f").push(i)},a=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(i).forEach((e=>{u(this,t,"m",s).call(this,e)}))},d=function(){h(this,i,this.createModal({"data-id":"generic-flow-modal"}),"f"),u(this,i,"f").afterClose=()=>{var e;null===(e=u(this,r,"f"))||void 0===e||e.call(this),h(this,r,null,"f")},h(this,n,new _a((()=>{var e;return null===(e=u(this,i,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(u(this,n,"f"))},l=function(){var e;u(this,i,"f").open(),null===(e=u(this,r,"f"))||void 0===e||e.call(this)},f=function(e,o){u(this,i,"f").setContent(z$({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,client:{userId:o}})),h(this,r,u(this,n,"f").onPageUpdated((()=>u(this,t,"m",l).call(this))),"f"),u(this,n,"f").onSuccess((()=>{u(this,i,"f").close(),this.actions.getMe()}))},p})),cC=Rn((e=>class extends(bn(ja,ms,Bw,nC,Gw,zw,Zw,Qw,Yw,Xw,eC,tC,Jw,oC,rC,aC,dC,lC)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),uC=bn((e=>class extends(cC(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return Na})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.11.5"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",uC);var hC=Object.freeze({__proto__:null,default:uC});const fC=(e,t,i,n={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===n.left?e.offsetWidth:null!==(o=n.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===n.right?e.offsetWidth:null!==(r=n.right)&&void 0!==r?r:0)),Math.min(Math.max(i,("all"===n.top?e.offsetHeight:null!==(s=n.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===n.bottom?e.offsetHeight:null!==(a=n.bottom)&&void 0!==a?a:0))]},pC=(e,t,i)=>{let n=0,o=0,r=0,s=0;function a(t){t.preventDefault(),n=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,d]=fC(e,e.offsetLeft-n,e.offsetTop-o,i);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=d,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l};var gC,vC,mC,yC,bC,$C,wC,CC,kC,SC,IC;const RC=document.createElement("template");RC.innerHTML='\n<div 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';const xC=bn(as)(HTMLElement);class OC extends xC{constructor(){super(),gC.add(this),vC.set(this,new fr({messages:[]})),mC.set(this,void 0),yC.set(this,void 0),bC.set(this,void 0),$C.set(this,{resize:u(this,gC,"m",IC).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(RC.content.cloneNode(!0)),h(this,mC,this.shadowRoot.querySelector(".debugger"),"f"),h(this,yC,u(this,mC,"f").querySelector(".content"),"f"),h(this,bC,u(this,mC,"f").querySelector(".header"),"f"),u(this,gC,"m",wC).call(this)}updateData(e){u(this,vC,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return c(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),pC(u(this,mC,"f"),u(this,bC,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",u(this,$C,"f").resize),(e=>{e.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}})(u(this,mC,"f")),u(this,mC,"f").onresize=u(this,gC,"m",SC).bind(this),u(this,vC,"f").subscribe(u(this,gC,"m",CC).bind(this))}))}disconnectedCallback(){u(this,vC,"f").unsubscribeAll(),window.removeEventListener("resize",u(this,$C,"f").resize)}}vC=new WeakMap,mC=new WeakMap,yC=new WeakMap,bC=new WeakMap,$C=new WeakMap,gC=new WeakSet,wC=function(){this.injectStyle('\n .debugger {\n all: initial;\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'),u(this,mC,"f").style.top="32px",u(this,mC,"f").style.left=window.innerWidth-300-32+"px"},CC=function(e){u(this,gC,"m",kC).call(this,e),u(this,gC,"m",SC).call(this)},kC=function(e){u(this,yC,"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("")},SC=function(){u(this,yC,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),i=t.scrollWidth>t.clientWidth,n=t.clientHeight>20;i||n?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},IC=function(){const[e,t]=fC(u(this,mC,"f"),Number.parseInt(u(this,mC,"f").style.left,10),Number.parseInt(u(this,mC,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});u(this,mC,"f").style.top=`${t}px`,u(this,mC,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",OC);var EC=Object.freeze({__proto__:null,default:OC});const AC=(e,t,i,n={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===n.left?e.offsetWidth:null!==(o=n.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===n.right?e.offsetWidth:null!==(r=n.right)&&void 0!==r?r:0)),Math.min(Math.max(i,("all"===n.top?e.offsetHeight:null!==(s=n.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===n.bottom?e.offsetHeight:null!==(a=n.bottom)&&void 0!==a?a:0))]};var NC,jC,MC,PC,UC,TC,WC,LC,DC,_C;const FC=document.createElement("template");FC.innerHTML=`\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`;const qC=bn(as)(HTMLElement);class BC extends qC{constructor(){var e;super(),NC.add(this),jC.set(this,new jn({messages:[]})),MC.set(this,void 0),PC.set(this,void 0),UC.set(this,void 0),TC.set(this,{resize:u(this,NC,"m",_C).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(FC.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\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'),h(this,MC,this.shadowRoot.querySelector(".debugger"),"f"),h(this,PC,u(this,MC,"f").querySelector(".content"),"f"),h(this,UC,u(this,MC,"f").querySelector(".header"),"f")}updateData(e){u(this,jC,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,i)=>{let n=0,o=0,r=0,s=0;function a(t){t.preventDefault(),n=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,d]=AC(e,e.offsetLeft-n,e.offsetTop-o,i);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=d,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(u(this,MC,"f"),u(this,UC,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",u(this,TC,"f").resize),(e=u(this,MC,"f")).onmousemove=t=>{var i;const n=t.target;(n.w&&n.w!==n.offsetWidth||n.h&&n.h!==n.offsetHeight)&&(null===(i=e.onresize)||void 0===i||i.call(e,t)),n.w=n.offsetWidth,n.h=n.offsetHeight},u(this,MC,"f").onresize=u(this,NC,"m",DC).bind(this),u(this,jC,"f").subscribe(u(this,NC,"m",WC).bind(this))}disconnectedCallback(){u(this,jC,"f").unsubscribeAll(),window.removeEventListener("resize",u(this,TC,"f").resize)}}jC=new WeakMap,MC=new WeakMap,PC=new WeakMap,UC=new WeakMap,TC=new WeakMap,NC=new WeakSet,WC=function(e){u(this,NC,"m",LC).call(this,e),u(this,NC,"m",DC).call(this)},LC=function(e){u(this,PC,"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("")},DC=function(){u(this,PC,"f").querySelectorAll(".msg").forEach((e=>{const t=e,i=t.querySelector(".msg_desc"),n=i.scrollWidth>i.clientWidth,o=i.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},_C=function(){const[e,t]=AC(u(this,MC,"f"),Number.parseInt(u(this,MC,"f").style.left,10),Number.parseInt(u(this,MC,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});u(this,MC,"f").style.top=`${t}px`,u(this,MC,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",BC);var VC=Object.freeze({__proto__:null,default:BC});e.AccessKeyManagement=Bn,e.ApplicationsPortal=Kn,e.AuditManagement=zn,e.AuthProvider=({projectId:e,baseUrl:o="",baseStaticUrl:a="",baseCdnUrl:d="",sessionTokenViaCookie:l=!1,refreshTokenViaCookie:c=!1,hooks:u,persistTokens:h=!0,autoRefresh:f=!0,oidcConfig:p,storeLastAuthenticatedUser:g=!0,keepLastAuthenticatedUserAfterLogout:v=!1,refreshCookieName:m="",getExternalToken:y,customStorage:b,children:$})=>{const[w,C]=t.useState(),[k,S]=t.useState(),[I,R]=t.useState(),[x,O]=t.useState(!1),[E,A]=t.useState(!1),[N,j]=t.useState(!1),[M,P]=t.useState(!!p),U=t.useRef(!1),T=(({projectId:e,baseUrl:i,persistTokens:n,autoRefresh:o,sessionTokenViaCookie:r,refreshTokenViaCookie:a,refreshCookieName:d,oidcConfig:l,storeLastAuthenticatedUser:c,keepLastAuthenticatedUserAfterLogout:u,getExternalToken:h,hooks:f,customStorage:p})=>t.useMemo((()=>{if(e)return hn({projectId:e,baseUrl:i,sessionTokenViaCookie:r,refreshTokenViaCookie:a,baseHeaders:s,persistTokens:n,autoRefresh:o,refreshCookieName:d,oidcConfig:l,storeLastAuthenticatedUser:c,keepLastAuthenticatedUserAfterLogout:u,hooks:f,getExternalToken:h,customStorage:p})}),[e,i,JSON.stringify(r),JSON.stringify(a),h,p]))({projectId:e,baseUrl:o,persistTokens:h,autoRefresh:f,sessionTokenViaCookie:l,refreshTokenViaCookie:c,hooks:u,oidcConfig:p,storeLastAuthenticatedUser:g,keepLastAuthenticatedUserAfterLogout:v,refreshCookieName:m,getExternalToken:y,customStorage:b});t.useEffect((()=>{if(T){const e=T.onSessionTokenChange(S),t=T.onUserChange(C),i=T.onIsAuthenticatedChange(O),n=T.onClaimsChange(R);return()=>{e(),t(),i(),n()}}}),[T]);const W=t.useRef(!1),L=t.useRef(!1);t.useEffect((()=>{T&&p&&!U.current&&(U.current=!0,T.oidc.finishLoginIfNeed().finally((()=>{P(!1),W.current=!0})))}),[]);const D=t.useCallback((()=>{r()||W.current||(W.current=!0,j(!0),n(null==T?void 0:T.refresh)(void 0,!0).then((()=>{requestAnimationFrame((()=>{setTimeout((()=>{j(!1)}),0)}))})))}),[T]),_=t.useCallback((()=>{L.current||(L.current=!0,A(!0),n(T.me)().then((()=>{A(!1)})))}),[T]),F=t.useMemo((()=>({fetchUser:_,user:w,isUserLoading:E,isUserFetched:L.current,fetchSession:D,session:k,isAuthenticated:x,isSessionLoading:N,isOidcLoading:M,isSessionFetched:W.current,projectId:e,baseUrl:o,baseStaticUrl:a,baseCdnUrl:d,storeLastAuthenticatedUser:g,keepLastAuthenticatedUserAfterLogout:v,refreshCookieName:m,customStorage:b,setUser:C,setSession:S,setIsAuthenticated:O,claims:I,sdk:T})),[_,w,E,L.current,D,k,x,N,M,W.current,e,o,a,d,v,m,b,C,S,O,I,T]);return t.createElement(i.Provider,{value:F},$)},e.Descope=Ln,e.OutboundApplications=Jn,e.RoleManagement=Yn,e.SignInFlow=e=>t.createElement(Ln,Object.assign({},e,{flowId:"sign-in"})),e.SignUpFlow=e=>t.createElement(Ln,Object.assign({},e,{flowId:"sign-up"})),e.SignUpOrInFlow=e=>t.createElement(Ln,Object.assign({},e,{flowId:"sign-up-or-in"})),e.TenantProfile=Qn,e.UserManagement=to,e.UserProfile=no,e.baseHeaders=s,e.getCurrentTenant=yn,e.getJwtPermissions=vn,e.getJwtRoles=mn,e.getRefreshToken=gn,e.getSessionToken=pn,e.isRefreshTokenExpired=(e=gn())=>null==un?void 0:un.isJwtExpired(e),e.isSessionTokenExpired=(e=pn())=>null==un?void 0:un.isJwtExpired(e),e.refresh=(e=gn())=>null==un?void 0:un.refresh(e),e.useDescope=()=>{const{sdk:e}=Dn();return t.useMemo((()=>e||new Proxy(fn(),Fn)),[e])},e.useSession=()=>{const{session:e,claims:i,isSessionLoading:n,isOidcLoading:o,fetchSession:s,isSessionFetched:a,isAuthenticated:d}=Dn(),l=t.useRef(n||o);t.useMemo((()=>{l.current=n||o}),[n,o]);const c=!d&&!n&&!r();return t.useMemo((()=>{c&&!a&&(l.current=!0)}),[a]),t.useEffect((()=>{c&&s()}),[s]),{isSessionLoading:l.current,sessionToken:e,claims:i,isAuthenticated:d}},e.useUser=()=>{const{user:e,fetchUser:i,isUserLoading:n,isAuthenticated:o,isUserFetched:r}=Dn(),[s,a]=t.useState(!1),d=t.useRef(n),l=t.useMemo((()=>!e&&!n&&o&&!s),[i,o,s]);return t.useMemo((()=>{d.current=n}),[n]),t.useMemo((()=>{l&&!r&&(d.current=!0)}),[l,r]),t.useEffect((()=>{l&&(a(!0),i())}),[l]),{isUserLoading:d.current,user:e}}}));
|
|
3
3
|
//# sourceMappingURL=index.umd.js.map
|