@descope/audit-management-widget 0.9.2 → 0.9.4

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
- * @descope/audit-management-widget v0.9.2
3
+ * @descope/audit-management-widget v0.9.4
4
4
  */
5
- this["descope-audit-management-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function n(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function r(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function o(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!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"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),c=(e,t=500)=>{let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}},l=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),(e=>"string"==typeof e?e:(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},u=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const r=e(n);return r[t]=!0,r}};var d,h,p,f;function g(e,t){const n=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r],i=e[o],s=t[o];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!g(i,s))return!1}else if(i!==s)return!1}return!0}let v=class{constructor(e={},{forceUpdate:t=!1}={}){d.set(this,void 0),h.set(this,{}),p.set(this,0),f.set(this,!0),this.update=e=>{const t="function"==typeof e?e(r(this,d,"f")):e,n=Object.assign(Object.assign({},r(this,d,"f")),t);if(r(this,f,"f")||!g(r(this,d,"f"),n)){const e=r(this,d,"f");o(this,d,n,"f"),Object.freeze(r(this,d,"f")),setTimeout((()=>{Object.values(r(this,h,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,d,e,"f"),o(this,f,t,"f")}get current(){return Object.assign({},r(this,d,"f"))}subscribe(e){return o(this,p,r(this,p,"f")+1,"f"),r(this,h,"f")[r(this,p,"f")]=e,r(this,p,"f").toString()}unsubscribe(e){const t=!!r(this,h,"f")[e];return t&&delete r(this,h,"f")[e],t}unsubscribeAll(){return o(this,h,{},"f"),!0}};d=new WeakMap,h=new WeakMap,p=new WeakMap,f=new WeakMap;const m=["=","+","-","@","\t","\r"],y=e=>{const t=(e=>e.length>0&&m.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};const w=["error","warn","info","debug"],b={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},k=u((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,r(this,t,"m",i).call(this,b))}set logger(e){o(this,n,r(this,t,"m",i).call(this,e||b),"f")}get logger(){return r(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return w.reduce(((t,n)=>(t[n]=(...t)=>{var r;this.onLogEvent(n,t),null===(r=e[n])||void 0===r||r.call(e,...t)},t)),{})},s})),I="undefined"!=typeof localStorage,S="https://static.descope.com/pages",O="https://static2.descope.com/pages",j=I&&localStorage.getItem("base.content.url")||"",x=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,E=u((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&r(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),C=u((e=>{var t,n;const o=i(k,E)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=r(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){r(this,t,"f")[e]||(r(this,t,"f")[e]=[]);const o=r(this,t,"f")[e].push(n);return()=>r(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),_=e=>t=>{var n,o,s;const a=i(k,E,C)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,r(this,n,"m",o).bind(this))}async init(){var e;c.forEach((e=>r(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const r=e[t],o="function"==typeof r?r(t,n):r;o&&this.logger.error(o)},s};_.missingAttrValidator=x;const A=u((e=>{const t=i(_({"project-id":x}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),R=u((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),T="Trying the next fallback URL...",$=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(r){return null==n||n.debug(`Network error fetching URL ${e} [${r.message}], retrying...`),fetch(e,t)}};const P=u((e=>{var t,n,s,a,c,l,u;const d=i(k,A,R)(e);return u=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const i=r(this,t,"m",c).call(this,e),l=Array.isArray(i)?e=>{const{baseUrl:t}=i[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=i[t].baseUrl;r(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:r}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const i=o[e],s=e===o.length-1;try{const o=await $(i.toString(),t,{logger:n});if(o.ok)return null==r||r(e),null==n||n.debug(`Successfully fetched URL ${i}`),o;const a=`Error fetching URL ${i} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${T}`)}catch(e){const t=`Error fetching URL ${i} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${T}`)}}})(i,{cache:"default"},{logger:this.logger,onSuccess:l});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,c=function(e){const i=j||this.baseStaticUrl;if(i)return r(this,t,"m",l).call(this,e,i);r(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),r(this,a,"f").clear());const c=[];if(r(this,s,"f"))c.push(r(this,t,"m",l).call(this,e,r(this,s,"f"))),r(this,s,"f")===S&&c.push(r(this,t,"m",l).call(this,e,O));else{const n=this.baseUrl+"/pages";this.baseUrl&&!r(this,a,"f").has(n)&&c.push(r(this,t,"m",l).call(this,e,n)),r(this,a,"f").has(S)||c.push(r(this,t,"m",l).call(this,e,S)),c.push(r(this,t,"m",l).call(this,e,O))}return 1===c.length?c[0]:c},l=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:r=S}){const o=new URL(r);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=r,o}({projectId:this.projectId,filename:e,baseUrl:t})},u})),U=u((e=>{var t,n;const o=i(_({"project-id":x}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(r(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return r(this,t,"f").set(e,n),()=>{r(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(r(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!r(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=r(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),D=u((e=>{var t,n,s,a,c;const l=i(P,U,E)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.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",r(this,t,"m",n).bind(this))}get config(){return r(this,s,"f")||o(this,s,r(this,a,"f").call(this),"f"),r(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},c})),L=u((e=>{var t,n,s,a,c,l,u;return u=class extends(i(E,k)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,o),"debug"===e&&r(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&r(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),r(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=r(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(r(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return wa})),document.body.appendChild(r(this,n,"f"))},c=function(){this.debug?r(this,t,"m",a).call(this):r(this,t,"m",s).call(this)},l=function(e,t){var o;e&&(null===(o=r(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},u})),M=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],N=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},W=(e,t,n)=>new Promise(((r,o)=>{const i=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);i.onerror=e=>{i.setAttribute("status","error"),o(e)},i.onload=()=>{i.setAttribute("status","loaded"),r(i)},i.src=t.toString(),document.body.appendChild(i)})),q=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},z=u((e=>{const t=i(k)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",r=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const r of e){const{id:e,url:o,integrity:i}=r,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await q(s,i),r}catch(e){t(r,!0)}else try{return await W(e,o,i),r}catch(e){t(r,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,r="",o)=>e.reduce(((e,i)=>{const s=i;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}@${n}/${r}`);const c={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${N(a)}`};return o&&(c.integrity=o),[...e,c]}),[]))([...r,this.baseCdnUrl,...M],e,t,n,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}"`)}))}}})),F="base.ui.components.url",J=I&&localStorage.getItem(F),V=u((e=>{var t,n,s,a,c,l,u;const d=i(k,D,z)(e);return u=class extends d{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return r(this,a,"f")||o(this,a,r(this,t,"m",l).call(this),"f"),r(this,a,"f")}async loadDescopeUiComponents(e){const n=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(n.map((e=>r(this,t,"m",c).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},c=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(", ")}"`)},l=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await r(this,t,"m",n).call(this),o=J?void 0:await r(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[J],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},u})),H=u((e=>{var t,n,o;const s=i(E,C)(e);return o=class extends s{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",r(this,t,"m",n).bind(this)),r(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class K{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?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 B=u((e=>{const t=i(H)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new K(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const r=[...e.adoptedStyleSheets||[]];r[t?"unshift":"push"](n),e.adoptedStyleSheets=r}}return n}}})),Y="content-root",G="root",X=u((e=>{const t=i(B)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${G}">\n <div id="${Y}"></div>\n </div>\n `,this.injectStyle(`\n #${G}, #${Y} {\n height: 100%;\n }\n #${G} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Y),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(G)}}})),Z="descope-modal";var Q,ee;let te=class{constructor(e,t){Q.set(this,void 0),this.nodeName="",o(this,Q,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const r="function"==typeof e?e():e;r&&(clearInterval(n),t(r))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(r(this,Q,"f"))}get ele(){var e,t;const n="function"==typeof r(this,Q,"f")?r(this,Q,"f").call(this):r(this,Q,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};Q=new WeakMap;let ne=class extends te{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};const re=/^descope-grid-([^-]+)-column$/,oe={text:class extends te{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 te{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 ie=class extends te{constructor(){super(...arguments),this.nodeName="descope-grid",ee.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 n;const r=null===(n=re.exec(t.localName))||void 0===n?void 0:n[1],o=oe[r];return o?(e.push(new o(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const o=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);o&&this.ele.columns&&(a(o,this.ele.columns)||(this.ele.columns=o,null===(n=r(this,ee,"f"))||void 0===n||n.call(this,o)))}onColumnsChange(e){o(this,ee,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};var se,ae,ce,le;ee=new WeakMap;let ue=class extends te{constructor(...e){super(...e),se.add(this),ae.set(this,void 0),ce.set(this,void 0),this.nodeName="descope-modal",r(this,se,"m",le).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),r(this,se,"m",le).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),r(this,ae,"f")&&(null===(e=this.ele)||void 0===e||e.append(r(this,ae,"f").content.cloneNode(!0)))}setContent(e){o(this,ae,e,"f"),this.reset()}remove(){var e,t;null===(e=r(this,ce,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};ae=new WeakMap,ce=new WeakMap,se=new WeakSet,le=function(){if(r(this,ce,"f"))return;const e=this.ele;e&&(o(this,ce,new MutationObserver((t=>{t.forEach(((n,r)=>{var o;const i="true"===n.oldValue,s=t[r+1]?t[r+1].oldValue:e.getAttribute("opened");i&&"true"!==s&&(null===(o=this.afterClose)||void 0===o||o.call(this))}))})),"f"),r(this,ce,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};let de=class extends te{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()}},he=class extends te{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)}},pe=class extends te{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")}};u((e=>{var t,n;const o=i(E,X,V)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ue{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(Z);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(r(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Z]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));const fe="descope-notification";u((e=>{var t,n;const o=i(E,X,V)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends de{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(fe);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(r(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([fe])}},t=new WeakMap,n}));const ge=(e,t,n="")=>Object.entries(e).reduce(((e,[r,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(r))return t("Ignoring invalid override-css token path segment"),e;const i=n?`${n}-${r}`:r;if("object"==typeof o&&null!==o)return e+ge(o,t,i);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-${i}:${s};`}),"");function ve(e,t){const n=Object.assign({},e);for(const[e,r]of Object.entries(t||{}))if(null!=r)if("object"==typeof r){if(0===Object.keys(r).length)continue;n[e]=ve(n[e]||{},r)}else n[e]="string"==typeof r?(n[e]||"")+r:r;return n}const me=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",ye=u((e=>{const t=i(_({tenant:me}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),we=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',be=u((e=>{var t,n,s,a,c,l,u,d,h,p,f,g,v,m,y,w,b,k,I,S,O,j;const x=i(_({theme:we}),ye,P,E,V,D,X,C,B)(e);return j=class extends x{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),l.set(this,void 0),u.set(this,void 0),I.set(this,(()=>{r(this,t,"m",S).call(this),r(this,O,"f").call(this,"os"===this.getAttribute("theme"))})),O.set(this,(e=>{var n,o,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===i||i.call(o,"change",(()=>r(this,t,"m",S).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){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 n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}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)),r(this,I,"f").call(this),await Promise.all([r(this,t,"m",p).call(this),r(this,t,"m",v).call(this),r(this,t,"m",y).call(this)]),r(this,t,"m",m).call(this),this.observeAttributes(["theme"],r(this,I,"f")),this.observeAttributes(["theme-override"],(()=>r(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{o(this,u,null,"f"),r(this,t,"m",v).call(this),r(this,t,"m",y).call(this)})),this.observeAttributes(["style-id"],(()=>{o(this,l,null,"f"),r(this,t,"m",b).call(this),r(this,t,"m",p).call(this),r(this,t,"m",y).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,I=new WeakMap,O=new WeakMap,t=new WeakSet,c=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,r,o,i,s,a;const c=null===(o=null===(r=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===r?void 0:r.colors)||void 0===o?void 0:o.primary,l=null===(a=null===(s=null===(i=e[t])||void 0===i?void 0:i.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return c||l?`[data-theme="${t}"]{${ge({colors:{primary:c,secondary:l}},(e=>this.logger.error(e)))}}`:""})).join(""):""},d=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(F))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(F),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();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")}},h=function(){return r(this,l,"f")||(o(this,l,r(this,t,"m",d).call(this),"f"),r(this,l,"f").then((e=>this.logger.debug("Fetched theme",e)))),r(this,l,"f")},p=async function(){var e,i;const s=await r(this,t,"a",h);if(!s)return;const a=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||"");r(this,n,"f")?r(this,n,"f").replaceSync(a):o(this,n,this.injectStyle(a,{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.warn("No tenant style exists, using project default theme.")}},g=function(){return r(this,u,"f")||o(this,u,r(this,t,"m",f).call(this),"f"),r(this,u,"f")},v=async function(){var e,n,i,a;if(!this.tenantId)return void(null===(e=r(this,s,"f"))||void 0===e||e.replaceSync(""));const c=await r(this,t,"a",g);if(!c)return void(null===(n=r(this,s,"f"))||void 0===n||n.replaceSync(""));const l=((null===(i=c.light)||void 0===i?void 0:i.globals)||"")+((null===(a=c.dark)||void 0===a?void 0:a.globals)||"");r(this,s,"f")?r(this,s,"f").replaceSync(l):o(this,s,this.injectStyle(l),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=r(this,a,"f"))||void 0===e||e.replaceSync(""));const n=r(this,t,"m",c).call(this);r(this,a,"f")?r(this,a,"f").replaceSync(n):o(this,a,this.injectStyle(n),"f")},y=async function(){var e,n,o,i;const s=await r(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const c=await r(this,t,"a",g);a.componentsThemeManager.themes={light:ve((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.components)||{},(null===(n=null==c?void 0:c.light)||void 0===n?void 0:n.components)||{}),dark:ve((null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.components)||{},(null===(i=null==c?void 0:c.dark)||void 0===i?void 0:i.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},r=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,i=r||o;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},b=async function(){const e=await r(this,t,"m",w).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")},k=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)},S=function(){r(this,t,"m",b).call(this),r(this,t,"m",k).call(this)},j}));var ke=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),Ie=()=>Math.random().toString(36).substring(7).split("").join("."),Se={INIT:`@@redux/INIT${Ie()}`,REPLACE:`@@redux/REPLACE${Ie()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Ie()}`};function Oe(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 je(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function xe(e){let t=typeof e;return t=je(e),t}function Ee(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${xe(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${xe(n)}'`);return n(Ee)(e,t)}let r=e,o=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function u(){if(c)throw new Error("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 d(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${xe(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),i=null}}}function h(e){if(!Oe(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${xe(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('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(`Action "type" property must be a string. Instead, the actual type was: '${xe(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,o=r(o,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}h({type:Se.INIT});return{dispatch:h,subscribe:d,getState:u,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${xe(e)}`);r=e,h({type:Se.REPLACE})},[ke]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${xe(t)}'`);function n(){const e=t;e.next&&e.next(u())}n();return{unsubscribe:e(n)}},[ke](){return this}}}}}function Ce(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function _e(e){const t=Object.keys(e),n={};for(let r=0;r<t.length;r++){const o=t[r];void 0===e[o]&&Ce(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const r=Object.keys(n);let o,i;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:Se.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:Se.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${Se.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){i=e}return function(e={},t){if(i)throw i;{const r=function(e,t,n,r){const o=Object.keys(t),i=n&&n.type===Se.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(!Oe(e))return`The ${i} has unexpected type of "${xe(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!r[e]));return s.forEach((e=>{r[e]=!0})),n&&n.type===Se.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);r&&Ce(r)}let s=!1;const a={};for(let o=0;o<r.length;o++){const i=r[o],c=n[i],l=e[i],u=c(l,t);if(void 0===u){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=u,s=s||u!==l}return s=s||r.length!==Object.keys(e).length,s?a:e}}function Ae(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Re(e){return Oe(e)&&"type"in e&&"string"==typeof e.type}var Te=Symbol.for("immer-nothing"),$e=Symbol.for("immer-draftable"),Pe=Symbol.for("immer-state"),Ue=[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 De(e,...t){{const n=Ue[e],r="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}}var Le=Object.getPrototypeOf;function Me(e){return!!e&&!!e[Pe]}function Ne(e){return!!e&&(qe(e)||Array.isArray(e)||!!e[$e]||!!e.constructor?.[$e]||He(e)||Ke(e))}var We=Object.prototype.constructor.toString();function qe(e){if(!e||"object"!=typeof e)return!1;const t=Le(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===We}function ze(e,t){0===Fe(e)?Object.entries(e).forEach((([n,r])=>{t(n,r,e)})):e.forEach(((n,r)=>t(r,n,e)))}function Fe(e){const t=e[Pe];return t?t.type_:Array.isArray(e)?1:He(e)?2:Ke(e)?3:0}function Je(e,t){return 2===Fe(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ve(e,t,n){const r=Fe(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function He(e){return e instanceof Map}function Ke(e){return e instanceof Set}function Be(e){return e.copy_||e.base_}function Ye(e,t){if(He(e))return new Map(e);if(Ke(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&qe(e)){if(!Le(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Pe];let r=Reflect.ownKeys(n);for(let t=0;t<r.length;t++){const o=r[t],i=n[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Le(e),n)}function Ge(e,t=!1){return Ze(e)||Me(e)||!Ne(e)||(Fe(e)>1&&(e.set=e.add=e.clear=e.delete=Xe),Object.freeze(e),t&&ze(e,((e,t)=>Ge(t,!0)))),e}function Xe(){De(2)}function Ze(e){return Object.isFrozen(e)}var Qe,et={};function tt(e){const t=et[e];return t||De(0,e),t}function nt(){return Qe}function rt(e,t){t&&(tt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ot(e){it(e),e.drafts_.forEach(at),e.drafts_=null}function it(e){e===Qe&&(Qe=e.parent_)}function st(e){return Qe={drafts_:[],parent_:Qe,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function at(e){const t=e[Pe];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function ct(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Pe].modified_&&(ot(t),De(4)),Ne(e)&&(e=lt(t,e),t.parent_||dt(t,e)),t.patches_&&tt("Patches").generateReplacementPatches_(n[Pe].base_,e,t.patches_,t.inversePatches_)):e=lt(t,n,[]),ot(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Te?e:void 0}function lt(e,t,n){if(Ze(t))return t;const r=t[Pe];if(!r)return ze(t,((o,i)=>ut(e,r,t,o,i,n))),t;if(r.scope_!==e)return t;if(!r.modified_)return dt(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const t=r.copy_;let o=t,i=!1;3===r.type_&&(o=new Set(t),t.clear(),i=!0),ze(o,((o,s)=>ut(e,r,t,o,s,n,i))),dt(e,t,!1),n&&e.patches_&&tt("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function ut(e,t,n,r,o,i,s){if(o===n&&De(5),Me(o)){const s=lt(e,o,i&&t&&3!==t.type_&&!Je(t.assigned_,r)?i.concat(r):void 0);if(Ve(n,r,s),!Me(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(Ne(o)&&!Ze(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;lt(e,o),t&&t.scope_.parent_||dt(e,o)}}function dt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ge(t,n)}var ht={get(e,t){if(t===Pe)return e;const n=Be(e);if(!Je(n,t))return function(e,t,n){const r=gt(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!Ne(r)?r:r===ft(e.base_,t)?(mt(e),e.copy_[t]=yt(r,e)):r},has:(e,t)=>t in Be(e),ownKeys:e=>Reflect.ownKeys(Be(e)),set(e,t,n){const r=gt(Be(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=ft(Be(e),t),o=r?.[Pe];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,r)&&(void 0!==n||Je(e.base_,t)))return!0;mt(e),vt(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==ft(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,mt(e),vt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Be(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty(){De(11)},getPrototypeOf:e=>Le(e.base_),setPrototypeOf(){De(12)}},pt={};function ft(e,t){const n=e[Pe];return(n?Be(n):e)[t]}function gt(e,t){if(!(t in e))return;let n=Le(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Le(n)}}function vt(e){e.modified_||(e.modified_=!0,e.parent_&&vt(e.parent_))}function mt(e){e.copy_||(e.copy_=Ye(e.base_,e.scope_.immer_.useStrictShallowCopy_))}ze(ht,((e,t)=>{pt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),pt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&De(13),pt.set.call(this,e,t,void 0)},pt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&De(14),ht.set.call(this,e[0],t,n,e[0])};function yt(e,t){const n=He(e)?tt("MapSet").proxyMap_(e,t):Ke(e)?tt("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:nt(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=ht;n&&(o=[r],i=pt);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}(e,t);return(t?t.scope_:nt()).drafts_.push(n),n}function wt(e){return Me(e)||De(10,e),bt(e)}function bt(e){if(!Ne(e)||Ze(e))return e;const t=e[Pe];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Ye(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Ye(e,!0);return ze(n,((e,t)=>{Ve(n,e,bt(t))})),t&&(t.finalized_=!1),n}var kt=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const r=this;return function(e=n,...o){return r.produce(e,(e=>t.call(this,e,...o)))}}let r;if("function"!=typeof t&&De(6),void 0!==n&&"function"!=typeof n&&De(7),Ne(e)){const o=st(this),i=yt(e,void 0);let s=!0;try{r=t(i),s=!1}finally{s?ot(o):it(o)}return rt(o,n),ct(r,o)}if(!e||"object"!=typeof e){if(r=t(e),void 0===r&&(r=e),r===Te&&(r=void 0),this.autoFreeze_&&Ge(r,!0),n){const t=[],o=[];tt("Patches").generateReplacementPatches_(e,r,t,o),n(t,o)}return r}De(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,r;const o=this.produce(e,t,((e,t)=>{n=e,r=t}));return[o,n,r]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Ne(e)||De(8),Me(e)&&(e=wt(e));const t=st(this),n=yt(e,void 0);return n[Pe].isManual_=!0,it(t),n}finishDraft(e,t){const n=e&&e[Pe];n&&n.isManual_||De(9);const{scope_:r}=n;return rt(r,t),ct(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=tt("Patches").applyPatches_;return Me(e)?r(e,t):this.produce(e,(e=>r(e,t)))}},It=kt.produce;kt.produceWithPatches.bind(kt),kt.setAutoFreeze.bind(kt),kt.setUseStrictShallowCopy.bind(kt),kt.applyPatches.bind(kt),kt.createDraft.bind(kt),kt.finishDraft.bind(kt);var St=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},Ot=(e,t,n)=>{const{memoize:r,memoizeOptions:o}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=r((()=>({})),...o);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},jt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var xt=e=>Array.isArray(e)?e:[e];function Et(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Ct(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var _t="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},At=0,Rt=1;function Tt(){return{s:At,v:void 0,o:null,p:null}}function $t(e,t={}){let n=Tt();const{resultEqualityCheck:r}=t;let o,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const r=e.get(n);void 0===r?(t=Tt(),e.set(n,t)):t=r}else{let e=t.p;null===e&&(t.p=e=new Map);const r=e.get(n);void 0===r?(t=Tt(),e.set(n,t)):t=r}}const a=t;let c;if(t.s===Rt)c=t.v;else if(c=e.apply(null,arguments),i++,r){const e=o?.deref?.()??o;null!=e&&r(e,c)&&(c=e,0!==i&&i--);o="object"==typeof c&&null!==c||"function"==typeof c?new _t(c):c}return a.s=Rt,a.v=c,c}return s.clearCache=()=>{n=Tt(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function Pt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t,r=0,o=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:u=$t,argsMemoizeOptions:d=[],devModeChecks:h={}}=a,p=xt(l),f=xt(d),g=Et(e),v=c((function(){return r++,s.apply(null,arguments)}),...p);let m=!0;const y=u((function(){o++;const e=Ct(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:r}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...jt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:St},inputStabilityCheck:{shouldRun:"always"===r||"once"===r&&e,run:Ot}}})(m,h);if(n.shouldRun&&n.run(s,e,t),r.shouldRun){const t=Ct(g,arguments);r.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>r,resetRecomputations:()=>{r=0},memoize:c,argsMemoize:u})};return Object.assign(r,{withTypes:()=>r}),r}var Ut=Pt($t),Dt=Object.assign(((e,t=Ut)=>{!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 n=Object.keys(e);return t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,r)=>(e[n[r]]=t,e)),{})))}),{withTypes:()=>Dt});function Lt(e){return({dispatch:t,getState:n})=>r=>o=>"function"==typeof o?o(t,n,e):r(o)}var Mt=Lt(),Nt=Lt;((...e)=>{const t=Pt(...e)})($t);var Wt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Ae:Ae.apply(null,arguments)},qt=e=>e&&"function"==typeof e.match;function zt(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw new Error("prepareAction did not return an object");return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Re(t)&&t.type===e,n}function Ft(e){return"function"==typeof e&&"type"in e&&qt(e)}function Jt(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Vt=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 Ht(e){return Ne(e)?It(e,(()=>{})):e}function Kt(e,t,n){if(e.has(t)){let r=e.get(t);return n.update&&(r=n.update(r,t,e),e.set(t,r)),r}if(!n.insert)throw new Error("No insert provided for key not already in map");const r=n.insert(t,e);return e.set(t,r),r}function Bt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Yt(e,t,n){const r=Gt(e,t,n);return{detectMutations:()=>Xt(e,t,r,n)}}function Gt(e,t=[],n,r="",o=new Set){const i={value:n};if(!e(n)&&!o.has(n)){o.add(n),i.children={};for(const o in n){const s=r?r+"."+o:o;t.length&&-1!==t.indexOf(s)||(i.children[o]=Gt(e,t,n[o],s))}}return i}function Xt(e,t=[],n,r,o=!1,i=""){const s=n?n.value:void 0,a=s===r;if(o&&!a&&!Number.isNaN(r))return{wasMutated:!0,path:i};if(e(s)||e(r))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in r)c[e]=!0;const l=t.length>0;for(let o in c){const s=i?i+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=Xt(e,t,n.children[o],r[o],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function Zt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Oe(e)}function Qt(e,t="",n=Zt,r,o=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=r?r(e):Object.entries(e),c=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Qt(l,a,n,r,o,i),s))return s}return i&&en(e)&&i.add(e),!1}function en(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!en(t))return!1;return!0}function tn(e){return"boolean"==typeof e}var nn=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:o=!0}=e??{};let i=new Vt;if(t&&(tn(t)?i.push(Mt):i.push(Nt(t.extraArgument))),n){let e={};tn(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,r,o){return JSON.stringify(e,n(t,o),r)},n=function(e,t){let n=[],r=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+r.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?r.splice(s,1/0,o):r.push(o),~n.indexOf(i)&&(i=t.call(this,o,i))}else n.push(i);return null==e?i:e.call(this,o,i)}},{isImmutable:r=Bt,ignoredPaths:o,warnAfter:i=32}=e;const s=Yt.bind(null,r,o);return({getState:e})=>{let n,r=e(),o=s(r);return a=>c=>{const l=Jt(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const u=a(c);return l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),u}}}}(e))}if(r){let e={};tn(r)||(e=r),i.push(function(e={}){{const{isSerializable:t=Zt,getEntries:n,ignoredActions:r=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,u=!l&&WeakSet?new WeakSet:void 0;return e=>l=>d=>{if(!Re(d))return l(d);const h=l(d),p=Jt(s,"SerializableStateInvariantMiddleware");return c||r.length&&-1!==r.indexOf(d.type)||p.measureTime((()=>{const e=Qt(d,"",t,n,o,u);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",d,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const r=Qt(e.getState(),"",t,n,i,u);if(r){const{keyPath:e,value:t}=r;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: ${d.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};tn(o)||(e=o),i.unshift(function(e={}){const{isActionCreator:t=Ft}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return i},rn=e=>t=>{setTimeout(t,e)},on="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:rn(10),sn=e=>function(t){const{autoBatch:n=!0}=t??{};let r=new Vt(e);return n&&r.push(((e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let o=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?on:"callback"===e.type?e.queueNotification:rn(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},r,{subscribe(e){const t=r.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,i=!o,i&&(s||(s=!0,c(l))),r.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),r};function an(e){const t=nn(),{reducer:n,middleware:r,devTools:o=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!Oe(n))throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=_e(n)}if(r&&"function"!=typeof r)throw new Error("`middleware` field must be a callback");if("function"==typeof r){if(c=r(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=Ae;o&&(l=Wt({trace:!0,..."object"==typeof o&&o}));const u=function(...e){return t=>(n,r)=>{const o=t(n,r);let i=()=>{throw new Error("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)=>i(e,...t)},a=e.map((e=>e(s)));return i=Ae(...a)(o.dispatch),{...o,dispatch:i}}}(...c),d=sn(u);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(d):d();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");c.length&&!h.includes(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Ee(a,i,l(...h))}function cn(e){const t={},n=[];let r;const o={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(r)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,o},addMatcher(e,t){if(r)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(r)throw new Error("`builder.addDefaultCase` can only be called once");return r=e,o}};return e(o),[t,n,r]}function ln(...e){return t=>e.some((e=>((e,t)=>qt(e)?e.match(t):e(t))(e,t)))}var un=["name","message","stack","code"],dn=class{constructor(e,t){this.payload=e,this.meta=t}_type},hn=class{constructor(e,t){this.payload=e,this.meta=t}_type},pn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of un)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},fn=(()=>{function e(e,t,n){const r=zt(e+"/fulfilled",((e,t,n,r)=>({payload:e,meta:{...r||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=zt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=zt(e+"/rejected",((e,t,r,o,i)=>({payload:o,error:(n&&n.serializeError||pn)(e||"Rejected"),meta:{...i||{},arg:r,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),u=new AbortController;let d;function h(e){d=e,u.abort()}const p=async function(){let p;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||u.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>u.signal.addEventListener("abort",(()=>t({name:"AbortError",message:d||"Aborted"})))));s(o(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:u.signal,abort:h,rejectWithValue:(e,t)=>new dn(e,t),fulfillWithValue:(e,t)=>new hn(e,t)})).then((t=>{if(t instanceof dn)throw t;return t instanceof hn?r(t.payload,l,e,t.meta):r(t,l,e)}))])}catch(t){p=t instanceof dn?i(null,l,e,t.payload,t.meta):i(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&i.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:l,arg:e,unwrap:()=>p.then(gn)})}}),{pending:o,rejected:i,fulfilled:r,settled:ln(i,r),typePrefix:e})}return e.withTypes=()=>e,e})();function gn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var vn=Symbol.for("rtk-slice-createasyncthunk");function mn(e,t){return`${e}/${t}`}function yn(e,t,n,r){function o(o,...i){let s=n.call(e,o);if(void 0===s){if(!r)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return o.unwrapped=t,o}var wn=function({creators:e}={}){const t=e?.asyncThunk?.[vn];return function(e){const{name:n,reducerPath:r=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&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)||{},i=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],r]="function"==typeof e.extraReducers?cn(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[r,o,i]=cn(t);if(function(e){return"function"==typeof e}(e))n=()=>Ht(e());else{const t=Ht(e);n=()=>t}function s(e=n(),t){let s=[r[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(Me(e)){const r=n(e,t);return void 0===r?e:r}if(Ne(e))return It(e,(e=>n(e,t)));{const r=n(e,t);if(void 0===r){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return r}}return e}),e)}return s.getInitialState=n,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 n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)}))}i.forEach((r=>{const i=o[r],s={reducerName:r,type:mn(n,r),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},r,o){let i,s;if("reducer"in r){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(r))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=r.reducer,s=r.prepare}else i=r;o.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?zt(e,s):zt(e))}(s,i,a):function({type:e,reducerName:t},n,r,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:u}=n,d=o(e,i,u);r.exposeAction(t,d),s&&r.addCase(d.fulfilled,s);a&&r.addCase(d.pending,a);c&&r.addCase(d.rejected,c);l&&r.addMatcher(d.settled,l);r.exposeCaseReducer(t,{fulfilled:s||bn,pending:a||bn,rejected:c||bn,settled:l||bn})}(s,i,a,t)}));const l=e=>e,u=new WeakMap;let d;const h={name:n,reducerPath:r,reducer:(e,t)=>(d||(d=c()),d(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(d||(d=c()),d.getInitialState()),getSelectors(t=l){const n=Kt(u,this,{insert:()=>new WeakMap});return Kt(n,t,{insert:()=>{const n={};for(const[r,o]of Object.entries(e.selectors??{}))n[r]=yn(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const r=t??this.reducerPath;return e.inject({reducerPath:r,reducer:this.reducer},n),{...this,reducerPath:r}}};return h}}();function bn(){}var kn="listenerMiddleware";zt(`${kn}/add`),zt(`${kn}/removeAll`),zt(`${kn}/remove`);const In=e=>u((t=>{const n=wn(e),r=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(k)(t)){constructor(...e){super(...e);const t=an({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const r=await t.dispatch(e(...n));try{gn(r)}catch(e){this.logger.error(e.message,r.type,e.stack)}return r},i=Object.keys(r).reduce(((e,t)=>(e[t]=o(r[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));u((e=>class extends(k(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{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 n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const Sn=u((e=>{const t=i(_({"widget-id":x}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),On=u((e=>{const t=i(D,Sn)(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 n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}})),jn=u((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=function(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:""}}(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),xn=e=>u((t=>{var n,o,s;const a=i(P,Sn,On,jn)(t);return s=class extends a{constructor(){super(...arguments),n.add(this)}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async fetchWidgetPage(t){const i=await r(this,n,"m",o).call(this,t);if(void 0!==i)return i;const s=await this.fetchStaticResource(`${e}/${this.widgetId}/${t}`,"text");return null==s?void 0:s.body}},n=new WeakSet,o=async function(t){var n;const r=await this.getWidgetConfig(),o=this.firstAvailableLocale(null!==(n=null==r?void 0:r.targetLocales)&&void 0!==n?n:[]);if(!o)return;const i=".html",s=t.endsWith(i)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${o}${i}`,"text");return null==t?void 0:t.body}catch(e){return}},s})),En=u((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),Cn=I&&localStorage.getItem("base.debug.logs.url"),_n=u((e=>{const t=i(_({"flow-id":x}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function An(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const n=Math.floor(t/60);if(n<60)return`${n} minutes`;const r=Math.floor(n/60);return r<24?`${r} hours`:`${Math.floor(r/24)} days`}u((e=>{var t,n,s,a,c,l,u,d,h,p,f,g;const v=i(z,k,E,D,A,_n)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,null),s.set(this,!1),a.set(this,null),f.set(this,null)}get telemetryManager(){return r(this,n,"f")}updateTelemetryContext(e){if(r(this,n,"f"))try{r(this,n,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const n=this.sdkVersion||"1.0.0";o(this,f,r(this,t,"m",h).call(this).then((e=>r(this,t,"m",c).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:n}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=r(this,f,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),r(this,t,"m",u).call(this)}},n=new WeakMap,s=new WeakMap,a=new WeakMap,f=new WeakMap,t=new WeakSet,c=async function(e,i){if(null==e?void 0:e.enabled)if(r(this,s,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const a=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",a,"dist/index.js",[Cn]);const c=window.DescopeDebugLogs;if(!c)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(o(this,n,new c({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:i.projectId,flowId:i.flowId,version:i.sdkVersion||"1.0.0"},this.logger),"f"),!r(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void o(this,n,null,"f");o(this,s,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&r(this,t,"m",l).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),o(this,s,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},l=function(e){const n=e-Date.now();if(n<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void r(this,t,"m",u).call(this);const i=864e5,s=Math.min(n,i);n>i&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${An(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${An(s)})`),o(this,a,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),r(this,t,"m",u).call(this)}),s),"f")},u=function(){if(r(this,a,"f")&&(clearTimeout(r(this,a,"f")),o(this,a,null,"f")),r(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),r(this,n,"f").shutdown(),o(this,n,null,"f"),o(this,s,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},d=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},h=async function(){var e;const n=await this.config,o=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry;let i;try{const e=Number(process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE);i={enabled:"true"===(process.env.DESCOPE_TELEMETRY_ENABLED||"").toLowerCase(),rumConfig:Object.assign({applicationId:process.env.DESCOPE_TELEMETRY_APPLICATION_ID||"",identityPoolId:process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID||"",region:process.env.DESCOPE_TELEMETRY_REGION||"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN&&{guestRoleArn:process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN})}}catch(e){i={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const s=Object.assign(Object.assign(Object.assign({},i),o),{rumConfig:Object.assign(Object.assign({},i.rumConfig),null==o?void 0:o.rumConfig),capture:r(this,t,"m",p).call(this,null==o?void 0:o.capture)});return s.enabled&&!r(this,t,"m",d).call(this,s.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),s.enabled=!1),o||(s.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),s},p=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},g})),u((e=>{var n,o,i;return i=class extends(be(e)){constructor(){super(...arguments),n.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:i,client:s,form:a}=e,c=t(e,["flowId","client","form"]);return l(Object.assign({projectId:this.getAttribute("project-id"),flowId:i,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:r(this,n,"m",o).call(this,a),client:Object.assign(Object.assign({},this.clientInput),s)},c))}},n=new WeakSet,o=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},i}));const Rn=/(["\\])/g;function Tn(e,t){return Array.from(e.querySelectorAll(`[data-id="${n=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(n):n.replace(Rn,"\\$1")}"]`));var n}function $n(e,t){e&&t&&Object.entries(t).forEach((([t,n])=>{Tn(e,t).forEach((e=>function(e,t){var n;switch(t){case"hide":e.setAttribute("hidden",""),null===(n=e.style)||void 0===n||n.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,n)))}))}const Pn=u((e=>{var t,n,s,a,c,l;const u=i(k,X)(e);return l=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,{})}async init(){var e,i;if("true"===this.getAttribute("mock"))return o(this,n,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const s=r(this,t,"m",a).call(this);o(this,n,r(this,t,"m",c).call(this,s),"f"),await(null===(i=super.init)||void 0===i?void 0:i.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),o(this,s,null!==(t=await r(this,n,"f"))&&void 0!==t?t:{},"f"),$n(this.contentRootElement,r(this,s,"f"))}async reevaluateComponentsState(){const e=r(this,t,"m",a).call(this);var n,i;n=this.contentRootElement,i=r(this,s,"f"),n&&i&&Object.entries(i).forEach((([e,t])=>{Tn(n,e).forEach((e=>function(e,t){var n;switch(t){case"hide":e.removeAttribute("hidden"),null===(n=e.style)||void 0===n||n.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),o(this,s,await r(this,t,"m",c).call(this,e),"f"),$n(this.contentRootElement,r(this,s,"f"))}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},c=async function(e){var t;try{const n=await e.get("/v1/mgmt/widget/components-state");if(!(null==n?void 0:n.ok))return{};const r=await n.json();return null!==(t=null==r?void 0:r.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},l})),Un=(e,t)=>t?{[e]:t}:{},Dn=e=>{if(!e)return;const t=JSON.parse(e);return Array.isArray(t)&&0===t.length?void 0:t},Ln=e=>e.selectedAuditId,Mn=Ut((e=>e.auditList.data),(e=>e.map((e=>{const n=e||{},{occurred:r,ID:o,type:i}=n,s=n.data,a=void 0===s?{saml_request:"",saml_response:"",saml_generated_user:"",saml_generated_roles:"",oidc_response:"",oidc_generated_user:"",scim_request:"",scim_result:"",Change:""}:s,{saml_request:c,saml_response:l,saml_generated_user:u,saml_generated_roles:d,oidc_response:h,oidc_generated_user:p,scim_request:f,scim_result:g,Change:v}=a,m=t(a,["saml_request","saml_response","saml_generated_user","saml_generated_roles","oidc_response","oidc_generated_user","scim_request","scim_result","Change"]),y=t(n,["occurred","ID","type","data"]),w=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}),Un("type",(e=>e&&e[0].toUpperCase()+e.slice(1))(i))),Un("saml_request",c)),Un("saml_response",l)),Un("saml_generated_user",Dn(u))),Un("saml_generated_roles",Dn(d))),Un("oidc_response",Dn(h))),Un("oidc_generated_user",Dn(p))),Un("scim_request",f)),Un("scim_result",g)),Un("Change",v)),{occurredFormatted:r?new Date(Number(r)||0).toLocaleString():"N/A"});return(e=>Object.fromEntries(Object.entries(e).filter((([e,t])=>!!t))))(w)}))));Ut(Ln,Mn,((e,t)=>t.find((t=>e===t.id)))),Ut(Ln,(e=>!!e));const Nn=fn("audit/search",((e,{extra:{api:t},getState:n})=>{const r=n().searchParams;return t.audit.search(Object.assign(Object.assign({},r),e))})),Wn=(e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))})(Nn)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(qn=e=>e.auditList,{onFulfilled:e=>{qn(e).loading=!1},onPending:e=>{qn(e).loading=!0,qn(e).error=null},onRejected:(e,t)=>{qn(e).loading=!1,qn(e).error=t.error}}));var qn;const zn={action:Nn,reducer:Wn},Fn={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""};class Jn extends Error{}function Vn(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 n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function Hn(e,t){if("string"!=typeof e)throw new Jn("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,r=e.split(".")[n];if("string"!=typeof r)throw new Jn(`Invalid token specified: missing part #${n+1}`);let o;try{o=Vn(r)}catch(e){throw new Jn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new Jn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Jn.prototype.name="InvalidTokenError";var Kn={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"},sso:{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 Bn="<region>",Yn=`https://api.${Bn}descope.com`,Gn=6e5,Xn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},Zn=[503,520,521,522,524,530],Qn=[100,5e3,5e3],er=e=>new Promise((t=>setTimeout(t,e))),tr=e=>async function(...t){let n=await e(...t),r=0;for(;Zn.includes(n.status)&&r<Qn.length;)await er(Qn[r]),n=await e(...t),r++;r>0&&(n.retries=r);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n},nr=(e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async function(...t){if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Xn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await tr(n)(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await e.text();return Xn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(r)),r}:tr(n)};let rr;const or=()=>{if(rr)return rr;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()}`,n=Math.floor(1e3+9e3*Math.random());return rr=`${t}-${n}`,rr};var ir,sr;(sr=ir||(ir={})).get="GET",sr.delete="DELETE",sr.post="POST",sr.put="PUT",sr.patch="PATCH";const ar=({path:e,baseUrl:t,queryParams:n,projectId:r})=>{const o=r.slice(1,-27);t=t.replace(Bn,o?o+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,r)=>{i=`${i}${0===r?"?":""}${t}=${encodeURIComponent(n[t])}${r===e.length-1?"":"&"}`}))}return i},cr=(...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,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),lr={"Content-Type":"application/json"},ur=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},dr=(e,t)=>{const n={"x-descope-sdk-session-id":or(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.70.1","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},hr=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var pr=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:r,logger:o,hooks:i,cookiePolicy:s,fetch:a})=>{const c=e||Yn,l=nr(o,a),u=async e=>{var o;const a=(null==i?void 0:i.beforeRequest)?i.beforeRequest(e):e,{path:u,body:d,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(d),m={headers:cr(ur(t,g),dr(t,r),(null==n?void 0:n.baseHeaders)||{},hr(v)?lr:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const y=await l(ar({path:u,baseUrl:c,queryParams:p,projectId:t}),m);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(e,null==y?void 0:y.clone()),null==i?void 0:i.transformResponse){const e=await y.json(),t=(w=(null===(o=y.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function r(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const i=n;let s,a,c=!1;for(;r();)if(","===e.charAt(n)){for(s=n,n+=1,r(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){c=!0,n=a,t.push(e.substring(i,s));break}n=s+1}else n+=1;(!c||n>=e.length)&&t.push(e.substring(i,e.length))}return t}(w).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.create(null),{json:()=>Promise.resolve(e),cookies:t}),r=new Proxy(y,{get:(e,t)=>{if(t in n)return n[t];const r=e[t];return"function"==typeof r?r.bind(e):r},set:(e,t,r)=>(n[t]=r,!0),has:(e,t)=>t in n||t in e});return n.clone=()=>r,i.transformResponse(r)}var w;return y};return{get:(e,{headers:t,queryParams:n,token:r}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:ir.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:o}={})=>u({path:e,headers:n,queryParams:r,body:t,method:ir.post,token:o}),patch:(e,t,{headers:n,queryParams:r,token:o}={})=>u({path:e,headers:n,queryParams:r,body:t,method:ir.patch,token:o}),put:(e,t,{headers:n,queryParams:r,token:o}={})=>u({path:e,headers:n,queryParams:r,body:t,method:ir.put,token:o}),delete:(e,{headers:t,queryParams:n,token:r}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:ir.delete,token:r}),hooks:i,buildUrl:(e,n)=>ar({projectId:t,baseUrl:c,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const r=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==r?void 0:r.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var r;const o=[].concat((null===(r=e.hooks)||void 0===r?void 0:r.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},fr=429;function gr(e,t,n){var r;let o=vr(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o.dct)===t)return(null==o?void 0:o[n])||[];o=null===(r=null==o?void 0:o.tenants)||void 0===r?void 0:r[t]}const i=null==o?void 0:o[n];return Array.isArray(i)?i:[]}function vr(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Hn(e)}function mr(e){const{exp:t}=vr(e);return(new Date).getTime()/1e3>t}function yr(e){let t=vr(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function wr(e,t){return gr(e,t,"permissions")}function br(e,t){return gr(e,t,"roles")}const kr=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Ir(e,t){var n;const r=await e,o={code:r.status,ok:r.ok,response:r},i=await r.clone().json();return r.ok?o.data=i:(o.error=i,r.status===fr&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=r.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function Sr(e){var t;return(null===(t=vr(e))||void 0===t?void 0:t.dct)||""}const Or=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),jr=(e,t)=>(n=t)=>t=>{const r=e.filter((e=>e(t)));return!(r.length<e.length)&&(n?n.replace("{val}",t):r.join(" OR "))},xr=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Er=e=>t=>e.test(t),Cr=Er(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),_r=Er(/^\+[1-9]{1}[0-9]{3,14}$/),Ar=Or(Cr,'"{val}" is not a valid email'),Rr=Or(_r,'"{val}" is not a valid phone number'),Tr=Or((e=>e.length>=1),"Minimum length is 1");const $r=Or((e=>"string"==typeof e),"Input is not a string"),Pr=Or((e=>Array.isArray(e)),"Input is not an array"),Ur=Or((e=>"boolean"==typeof e),"Input is not a boolean"),Dr=Or((e=>void 0===e),"Input is defined"),Lr=jr([$r(),Dr()],"Input is not a string or undefined"),Mr=jr([Pr(),Ur()],"Input is not an array or boolean"),Nr=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>xr(...e).validate(n[t]))),t(...n)),Wr=e=>[$r(`"${e}" must be a string`)],qr=e=>[Lr(`"${e}" must be string or undefined`)],zr=e=>[$r(`"${e}" must be a string`),Tr(`"${e}" must not be empty`)],Fr=e=>[$r(`"${e}" must be a string`),Ar()],Jr=e=>[$r(`"${e}" must be a string`),Rr()],Vr=Nr(zr("accessKey")),Hr=e=>({exchange:Vr(((t,n)=>Ir(e.post(Kn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Kr=(e,t,n)=>(t.forEach((t=>{const r=t.split(".");let o=r.shift(),i=e;for(;r.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=r.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const s=i[o];i[o]=n(s)})),e),Br=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Gn,Gn)});var Yr,Gr;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Yr||(Yr={})),function(e){e.email="email"}(Gr||(Gr={}));const Xr=Object.assign(Object.assign({},Yr),Gr);var Zr;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Zr||(Zr={}));const Qr=zr("loginId"),eo=Nr(zr("token")),to=Nr(Qr),no=Nr(zr("pendingRef")),ro=Nr(Qr,Fr("email")),oo=e=>({verify:eo((t=>Ir(e.post(Kn.enchantedLink.verify,{token:t})))),signIn:to(((n,r,o={},i)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Ir(e.post(kr(Kn.enchantedLink.signIn,Xr.email),{loginId:n,URI:r,loginOptions:a,providerId:s},{token:i}))})),signUpOrIn:to(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Ir(e.post(kr(Kn.enchantedLink.signUpOrIn,Xr.email),{loginId:n,URI:r,loginOptions:s,providerId:i}))})),signUp:to(((n,r,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Ir(e.post(kr(Kn.enchantedLink.signUp,Xr.email),{loginId:n,URI:r,user:o,loginOptions:a,providerId:s}))})),waitForSession:no(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=Br(n);let s;const a=setInterval((async()=>{const n=await e.post(Kn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Ir(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:ro(((t,n,r,o,i)=>Ir(e.post(Kn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o}))))}}),io=Nr(zr("flowId")),so=Nr(zr("executionId"),zr("stepId"),zr("interactionId")),ao=e=>({start:io(((t,n,r,o,i,s,a,c=!1)=>Ir(e.post(Kn.flow.start,{flowId:t,options:n,conditionInteractionId:r,interactionId:o,componentsVersion:i,flowVersions:s,input:a,isCustomScreen:c})))),next:so(((t,n,r,o,i,s,a=!1,c)=>Ir(e.post(Kn.flow.next,{executionId:t,stepId:n,interactionId:r,version:o,componentsVersion:i,input:s,isCustomScreen:a,options:c}))))}),co=zr("loginId"),lo=Nr(zr("token")),uo=Nr(co),ho=Nr(co,Jr("phone")),po=Nr(co,Fr("email")),fo=Object.keys(Xr).filter((e=>e!==Yr.voice&&e!==Yr.im)),go=e=>({verify:lo((t=>Ir(e.post(Kn.magicLink.verify,{token:t})))),signIn:fo.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:uo(((n,o,i={},s)=>{var{providerId:a}=i,c=t(i,["providerId"]);return Ir(e.post(kr(Kn.magicLink.signIn,r),{loginId:n,URI:o,loginOptions:c,providerId:a},{token:s}))}))})),{}),signUp:fo.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:uo(((n,o,i,s={})=>{var{providerId:a}=s,c=t(s,["providerId"]);return Ir(e.post(kr(Kn.magicLink.signUp,r),{loginId:n,URI:o,user:i,loginOptions:c,providerId:a}))}))})),{}),signUpOrIn:fo.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:uo(((n,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Ir(e.post(kr(Kn.magicLink.signUpOrIn,r),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:po(((t,n,r,o,i)=>Ir(e.post(Kn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o})))),phone:Object.keys(Yr).filter((e=>e!==Yr.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ho(((t,r,o,i,s)=>Ir(e.post(kr(Kn.magicLink.update.phone,n),Object.assign({loginId:t,phone:r,URI:o},s),{token:i}))))})),{})}});var vo;!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"}(vo||(vo={}));const mo=Nr(zr("code")),yo=e=>({start:Object.assign(((t,n,r,o,i)=>Ir(e.post(Kn.oauth.start,r||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),i&&{loginHint:i}),token:o}))),Object.keys(vo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,r,o,i)=>Ir(e.post(Kn.oauth.start,r||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),i&&{loginHint:i}),token:o}))})),{})),exchange:mo((t=>Ir(e.post(Kn.oauth.exchange,{code:t})))),startNative:(t,n,r)=>Ir(e.post(Kn.oauth.startNative,{provider:t,loginOptions:n,implicit:r})),finishNative:(t,n,r,o,i)=>Ir(e.post(Kn.oauth.finishNative,{provider:t,stateId:n,user:r,code:o,idToken:i})),getOneTapClientId:t=>Ir(e.get(Kn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,r,o)=>Ir(e.post(Kn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:r,loginOptions:o})),exchangeOneTapIDToken:(t,n,r,o)=>Ir(e.post(Kn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:r,loginOptions:o}))}),wo=zr("appId"),bo=Nr(wo),ko=e=>({connect:bo(((t,n,r)=>{const o=null==n?void 0:n.tenantId,i=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,Ir(e.post(Kn.outbound.connect,{appId:t,tenantId:o,tenantLevel:i,options:n},{token:r}))}))}),Io=zr("loginId"),So=Nr(Io,zr("code")),Oo=Nr(Io),jo=Nr(Io,Jr("phone")),xo=Nr(Io,Fr("email")),Eo=e=>({verify:Object.keys(Xr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:So(((t,r)=>Ir(e.post(kr(Kn.otp.verify,n),{code:r,loginId:t}))))})),{}),signIn:Object.keys(Xr).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Oo(((n,o={},i)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Ir(e.post(kr(Kn.otp.signIn,r),{loginId:n,loginOptions:a,providerId:s},{token:i}))}))})),{}),signUp:Object.keys(Xr).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Oo(((n,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Ir(e.post(kr(Kn.otp.signUp,r),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Xr).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Oo(((n,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Ir(e.post(kr(Kn.otp.signUpOrIn,r),{loginId:n,loginOptions:s,providerId:i}))}))})),{}),update:{email:xo(((t,n,r,o)=>Ir(e.post(Kn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:r})))),phone:Object.keys(Yr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jo(((t,r,o,i)=>Ir(e.post(kr(Kn.otp.update.phone,n),Object.assign({loginId:t,phone:r},i),{token:o}))))})),{})}}),Co=Nr(zr("tenant")),_o=Nr(zr("code")),Ao=e=>({start:Co(((t,n,r,o,i,s,a,c)=>Ir(e.post(Kn.sso.start,r||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),i&&{ssoId:i}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),c&&{initiatedEmail:t})},o&&{token:o}))))),exchange:_o((t=>Ir(e.post(Kn.sso.exchange,{code:t}))))}),Ro=zr("loginId"),To=Nr(Ro,zr("code")),$o=Nr(Ro),Po=Nr(Ro),Uo=e=>({signUp:$o(((t,n)=>Ir(e.post(Kn.totp.signUp,{loginId:t,user:n})))),verify:To(((t,n,r,o)=>Ir(e.post(Kn.totp.verify,{loginId:t,code:n,loginOptions:r},{token:o})))),update:Po(((t,n)=>Ir(e.post(Kn.totp.update,{loginId:t},{token:n}))))}),Do=zr("loginId"),Lo=zr("newPassword"),Mo=Nr(Do,zr("password")),No=Nr(Do),Wo=Nr(Do,Lo),qo=Nr(Do,zr("oldPassword"),Lo),zo=e=>({signUp:Mo(((n,r,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Ir(e.post(Kn.password.signUp,{loginId:n,password:r,user:o,loginOptions:a,providerId:s}))})),signIn:Mo(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Ir(e.post(Kn.password.signIn,{loginId:n,password:r,loginOptions:s,providerId:i}))})),sendReset:No(((t,n,r)=>Ir(e.post(Kn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:r})))),update:Wo(((t,n,r)=>Ir(e.post(Kn.password.update,{loginId:t,newPassword:n},{token:r})))),replace:qo(((t,n,r)=>Ir(e.post(Kn.password.replace,{loginId:t,oldPassword:n,newPassword:r})))),policy:()=>Ir(e.get(Kn.password.policy))}),Fo=Wr("loginId"),Jo=zr("loginId"),Vo=Wr("origin"),Ho=Nr(Jo,Vo,zr("name")),Ko=Nr(Jo,Vo),Bo=Nr(Fo,Vo),Yo=Nr(Jo,Vo,qr("token")),Go=Nr(zr("transactionId"),zr("response")),Xo=e=>({signUp:{start:Ho(((t,n,r,o,i)=>Ir(e.post(Kn.webauthn.signUp.start,{user:{loginId:t,name:r},origin:n,loginOptions:i,passkeyOptions:o})))),finish:Go(((t,n)=>Ir(e.post(Kn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Bo(((t,n,r,o,i)=>Ir(e.post(Kn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:r,passkeyOptions:i},{token:o})))),finish:Go(((t,n)=>Ir(e.post(Kn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ko(((t,n,r,o)=>Ir(e.post(Kn.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r}))))},update:{start:Yo(((t,n,r,o,i)=>Ir(e.post(Kn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:i},{token:r})))),finish:Go(((t,n)=>Ir(e.post(Kn.webauthn.update.finish,{transactionId:t,response:n}))))}}),Zo=Wr("loginId"),Qo=Nr(Zo),ei=Nr(zr("pendingRef")),ti=e=>({signUpOrIn:Qo(((n,r={})=>{var{providerId:o}=r,i=t(r,["providerId"]);return Ir(e.post(Kn.notp.signUpOrIn,{loginId:n,loginOptions:i,providerId:o}))})),signUp:Qo(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Ir(e.post(Kn.notp.signUp,{loginId:n,user:r,providerId:i,loginOptions:s}))})),signIn:Qo(((n,r={},o)=>{var{providerId:i}=r,s=t(r,["providerId"]);return Ir(e.post(Kn.notp.signIn,{loginId:n,loginOptions:s,providerId:i},{token:o}))})),waitForSession:ei(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=Br(n);let s;const a=setInterval((async()=>{const n=await e.post(Kn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Ir(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),ni=Nr(zr("token")),ri=Nr(qr("token"));var oi,ii=Nr([(oi=zr("projectId"),Or(((e,t)=>n=>xr(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),r=n.length;let o=0,i=e===Object(e)?e:void 0;for(;null!=i&&o<r;)i=i[n[o++]];return o&&o===r&&void 0!==i?i:void 0})(n,e)))("projectId",oi))())])((e=>{const{projectId:t,logger:n,baseUrl:r,cookiePolicy:o,baseHeaders:i={},refreshCookieName:s,fetch:a}=e;return c=pr({baseUrl:r,projectId:t,logger:n,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:i},refreshCookieName:s,fetch:a}),{accessKey:Hr(c),otp:Eo(c),magicLink:go(c),enchantedLink:oo(c),oauth:yo(c),outbound:ko(c),sso:Ao(c),saml:Ao(c),totp:Uo(c),notp:ti(c),webauthn:Xo(c),password:zo(c),flow:ao(c),refresh:ri(((e,t,n,r)=>{const o={};n&&(o.externalToken=n);const i=r?Kn.tryRefresh:Kn.refresh;return Ir(c.post(i,o,{token:e,queryParams:t}))})),selectTenant:Nr([$r("tenantId")],[Lr('"token" must be string or undefined')])(((e,t)=>Ir(c.post(Kn.selectTenant,{tenant:e},{token:t})))),logout:ri((e=>Ir(c.post(Kn.logout,{},{token:e})))),logoutAll:ri((e=>Ir(c.post(Kn.logoutAll,{},{token:e})))),me:ri((e=>Ir(c.get(Kn.me,{token:e})))),myTenants:Nr([Mr('"tenants" must a string array or a boolean')],[Lr('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Ir(c.post(Kn.myTenants,n,{token:t}))})),history:ri((e=>Ir(c.get(Kn.history,{token:e})))),isJwtExpired:ni(mr),getTenants:ni(yr),getJwtPermissions:ni(wr),getJwtRoles:ni(br),getCurrentTenant:ni(Sr),httpClient:c};var c})),si=Object.assign(ii,{DeliveryMethods:Xr});
6
- /*! js-cookie v3.0.8 | MIT */function ai(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)"__proto__"!==r&&(e[r]=n[r])}return e}var ci=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=ai({},n,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 i="";for(var s in o)o[s]&&(i+="; "+s,!0!==o[s]&&(i+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+i}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(a in r||(r[a]=t.read(s,a)),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",ai({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,ai({},this.attributes,t))},withConverter:function(t){return e(ai({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},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 li={default:"endpoint"},ui="Blocked by CSP",di="The endpoint parameter is not a valid URL",hi="Failed to load the JS script of the agent",pi="9319";function fi(e,t){var n,r,o,i,s,a=[],c=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||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),i=0,r=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},o=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===ui||s===di)n.exclude(),i=0;else if(s===pi)n.exclude();else if(s===hi){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!o.has(c)&&(o.add(c),i=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=i?i:e.getTime()+r()-Date.now()]}]),l=c[0],u=c[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var d=function(e){var n=new Date,r=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return r()}),r),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=u(n,e);if(!t)throw s;var r,o=t[0],i=t[1];return(r=i,new Promise((function(e){return setTimeout(e,r)}))).then((function(){return d(o)}))}))};return d(l).then((function(e){return[e,a]}))}var gi="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",vi=gi;function mi(n){var r;n.scriptUrlPattern;var o=n.token,i=n.apiKey,s=void 0===i?o:i,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(r=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==r?r:gi,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,r){return e.addEventListener(t,n,r),function(){return e.removeEventListener(t,n,r)}}(document,"visibilitychange",t);return t(),[e,n]}(),u=l[0],d=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(c,s);return fi(e,yi)})).catch((function(e){throw d(),function(e){return e instanceof Error&&e.message===pi?new Error(hi):e}(e)})).then((function(t){var n=t[0],r=t[1];return d(),n.load(e(e({},a),{ldi:{attempts:r,visibilityStates:u}}))}))}function yi(e){return function(e,t,n){var r,o=document,i="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(r=t,a())};o.addEventListener(i,s);var a=function(){return o.removeEventListener(i,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(),r)return n(r);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){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(di);var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(hi))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)}),(function(){throw new Error(ui)})).then(wi)}function wi(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(pi);return n}const bi="3.2.0",ki="undefined"!=typeof window,Ii=Math.pow(2,31)-1,Si=`https://descopecdn.com/npm/oidc-client-ts@${bi}/dist/browser/oidc-client-ts.min.js`,Oi=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${bi}/dist/browser/oidc-client-ts.min.js`,ji=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let xi;const Ei=e=>{try{return Hn(e).exp}catch(e){return null}},Ci=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Ei(n)},_i=e=>{const{expires_in:t,expires_at:n,access_token:r}=e;return n||(t?Math.floor(Date.now()/1e3)+t:r?Ei(r):void 0)},Ai=e=>{const{access_token:n,id_token:r,refresh_token:o,refresh_expire_in:i}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:r,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||_i(e),cookieExpiration:e.cookieExpiration||Ci(e)},s)},Ri=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,r)=>{var o;return n[r]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[r])||[]).concat((null==t?void 0:t[r])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Ti=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return Ai(n)},$i=()=>ki&&!!window.descopeBridge,Pi=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return ji.includes(n)},Ui=void 0!==xi||ki&&void 0!==window.localStorage,Di=(e,t)=>{var n,r;return null===(r=null===(n=xi||ki&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===r?void 0:r.call(n,e,t)},Li=e=>{var t,n;return null===(n=null===(t=xi||ki&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Mi=e=>{var t,n;return null===(n=null===(t=xi||ki&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},Ni=e=>{var t,n,r,o,i;return null!==(i=null!==(n=null===(t=null==xi?void 0:xi.key)||void 0===t?void 0:t.call(xi,e))&&void 0!==n?n:ki&&(null===(o=null===(r=window.localStorage)||void 0===r?void 0:r.key)||void 0===o?void 0:o.call(r,e)))&&void 0!==i?i:null},Wi=e=>{var t,n;return ki&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},qi=e=>{var t,n;try{ki&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},zi=(...e)=>{console.debug(...e)},Fi=(...e)=>{console.warn(...e)},Ji=(e,t)=>{let n;var r;return t>0?(n=1e3*t,zi(`Using provided nextRefreshSeconds: ${t}s`)):n=((r=e)?r.getTime()-(new Date).getTime():0)-2e4,n>Ii&&(zi(`Timeout is too large (${n}ms), setting it to ${Ii}ms`),n=Ii),n},Vi="DS",Hi="DSR",Ki="DSI",Bi="DSRCN";function Yi(e,t,n){if(t){const{cookieDomain:r,cookiePath:o,cookieSameSite:i,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=Gi(r);ci.set(e,t,{path:o,domain:l?r:void 0,expires:c,sameSite:i,secure:a})}}function Gi(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const Xi=e=>(null==e?void 0:e.cookieName)||Vi,Zi=e=>(null==e?void 0:e.cookieName)||Hi;function Qi(e="",t){return ci.get(Zi(t))||Li(`${e}${Hi}`)||""}function es(e="",t){return ci.get(Xi(t))||Li(`${e}${Vi}`)||""}function ts(e=""){return Li(`${e}${Ki}`)||""}function ns(e="",t,n,r){Mi(`${e}${Hi}`),Mi(`${e}${Vi}`),Mi(`${e}${Ki}`),Mi(`${e}${Bi}`);const o=Xi(t);ci.remove(o,null==r?void 0:r.session);const i=Zi(n);ci.remove(i,null==r?void 0:r.refresh)}const rs=(e,t,n)=>r=>{const o=Object.assign(r,{token:r.token||Qi(e,t)});if(!n){const t=function(e=""){return Li(`${e}${Bi}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const i=function(e=""){return Li(`${e}DTD`)||""}(e);return i&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":i})),o},os=ki&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",is="vsid",ss="vrid",as=(e=!1)=>{const t=Li("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},cs=async(e,t=os)=>{try{if(as())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=mi({apiKey:e,endpoint:[r.toString(),li],scriptUrlPattern:[i,vi]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[is]:e,[ss]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Di("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},ls=e=>{const t=as(!0);return t&&e.body&&(e.body.fpData=t),e},us="descopeFlowNonce",ds="X-Descope-Flow-Nonce",hs="/v1/flow/start",ps="/v1/flow/next",fs=(e,t=us)=>`${t}${e}`,gs=(e,t=us)=>{try{const n=fs(e,t),r=Li(n);if(!r)return null;const o=JSON.parse(r);return o.expiry<Date.now()?(vs(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},vs=(e,t=us)=>{try{const n=fs(e,t);Mi(n)}catch(e){console.error("Error removing flow nonce:",e)}},ms=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},ys=e=>{var t;return e.path===ps&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?ms(e.body.executionId):null},ws="dls_last_user_login_id",bs="dls_last_user_display_name",ks=e=>Di(ws,e),Is=()=>Li(ws),Ss=()=>Li(bs),Os=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,r={}]=t,o=Is(),i=Ss();return o&&(null!==(n=r.lastAuth)&&void 0!==n||(r.lastAuth={}),r.lastAuth.loginId=o,r.lastAuth.name=i),await e(...t)},js="DSLI",xs=e=>async(...t)=>{const n=await e(...t);return qi(js),n};function Es(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function Cs(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Us(n.publicKey.challenge),n.publicKey.user.id=Us(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Us(e.id)})),n}(e);try{return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Ds(n.rawId),type:n.type,response:{attestationObject:Ds(n.response.attestationObject),clientDataJSON:Ds(n.response.clientDataJSON)}})}catch(e){throw await Rs(e,t,!0)}var n}async function _s(e){const t=$s(e);try{return Ps(await navigator.credentials.get(t))}catch(e){throw await Rs(e,t,!1)}}async function As(e,t){const n=$s(e);n.signal=t.signal,n.mediation="conditional";try{return Ps(await navigator.credentials.get(n))}catch(e){throw await Rs(e,n,!1)}}async function Rs(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var r,o;const i=null==e?void 0:e.name;if("AbortError"===i&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===i&&n)return"authenticator_already_registered";if("NotSupportedError"===i)return"no_supported_algorithm";if("ConstraintError"===i)return"authenticator_constraints_unsupported";if("SecurityError"===i){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await Ts())return"webauthn_unsupported";const s="platform"===(null===(o=null===(r=null==t?void 0:t.publicKey)||void 0===r?void 0:r.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await Ts(!0)?"platform_authenticator_unsupported":"NotAllowedError"===i?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function Ts(e=!1){var t,n;if(!ki)return Promise.resolve(!1);if($i()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const r=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return r&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():r}function $s(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Us(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Us(e.id)})),n}function Ps(e){return JSON.stringify({id:e.id,rawId:Ds(e.rawId),type:e.type,response:{authenticatorData:Ds(e.response.authenticatorData),clientDataJSON:Ds(e.response.clientDataJSON),signature:Ds(e.response.signature),userHandle:e.response.userHandle?Ds(e.response.userHandle):void 0}})}function Us(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ds(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ls,Ms=(Ls=e=>({async signUp(t,n,r){const o=await e.webauthn.signUp.start(t,window.location.origin,n,r);if(!o.ok)return o;const i=await Cs(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(t,n){const r=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!r.ok)return r;const o=await _s(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,o)},async signUpOrIn(t,n){var r;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(r=o.data)||void 0===r?void 0:r.create){const t=await Cs(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await _s(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,r){const o=await e.webauthn.update.start(t,window.location.origin,n,r);if(!o.ok)return o;const i=await Cs(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Cs,get:_s,isSupported:Ts,conditional:As}}),(...e)=>{const t=Ls(...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 Ns="/fedcm/config";async function Ws(e,t){var n;try{await qs(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function qs(e,t){var n,r;const o=await async function(e,t="google",n,r,o){const i=(()=>{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)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const c=a.data.clientId;return new Promise((e=>{var a,l;const u=n=>{e({provider:t,nonce:i,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,callback:u,nonce:i})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void u()}if(r&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==r||r(t),void u()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const r=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!r.ok||!r.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,r.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(r=null==t?void 0:t.onAuthenticated)||void 0===r||r.call(t,n.data)}}var zs=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Ts(),r=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=r,e.flow.start(...t)}});let Fs;const Js=(e,t)=>new Promise(((n,r)=>{if(!e.length)return r(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const i=e.shift(),s=document.createElement("script");s.src=i,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(i),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Js(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Vs=(e,t,n)=>{const r=async()=>{let r,o;return r&&o||({client:r,stateUserKey:o}=await(async(e,t,n)=>{Fs||(Fs=(async()=>{try{return require("oidc-client-ts")}catch(e){return Js([Si,Oi],(()=>window.oidc))}})());const{OidcClient:r,WebStorageStateStore:o}=await Fs;if(!r)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const i=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,c,l;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,c=`${a}_user`,l="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,c=`${a}_user`,l="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,c=`${a}_user`,l="openid email roles descope.custom_claims offline_access");const u={authority:s,client_id:a,redirect_uri:i,response_type:"code",scope:(null==n?void 0:n.scope)||l,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(u.redirect_uri=n.redirectUri),{client:new r(u),stateUserKey:c}})(e,t,n)),{client:r,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:i}=await r(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),Di(i,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={},n=!1)=>{var o;const{client:i}=await r(),s=await i.createSigninRequest(t),{url:a}=s;return n||(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 n;const{client:o,stateUserKey:i}=await r(),s=(e=>{const t=Li(e);return t?JSON.parse(t):null})(i);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 c=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await r();e||(e={}),e.id_token_hint=e.id_token_hint||ts(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const i=await n.createSignoutRequest(e),{url:s}=i;return Mi(o),t||window.location.replace(s),i}}},Hs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,xi=n,e(t)}),(e=>n=>{var{fpKey:r,fpLoad:o}=n,i=t(n,["fpKey","fpLoad"]);return ki?(r&&o&&cs(r).catch((()=>null)),e(Ri(i,{beforeRequest:ls}))):e(i)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.52.1"},t.baseHeaders)}))),(e=>t=>{const n=Es(),r=Es(),o=Es(),i=Es(),s=e(Ri(t,{afterRequest:async(e,t)=>{if(Pi(e,t))zi("Session invalidated, notifying subscribers with empty values"),r.pub(null),o.pub(null),n.pub(null),i.pub(null);else{const e=await(async e=>{const t=await Ti(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:c}=await Ti(t);s&&r.pub(s),c&&i.pub(c),(a||s)&&n.pub(a||42)}}})),a=Kr(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return r.pub(null),o.pub(null),n.pub(null),i.pub(null),s}));return Object.assign(a,{onSessionTokenChange:r.sub,onUserChange:o.sub,onClaimsChange:i.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var r;const{enableFlowNonce:o=!0,nonceStoragePrefix:i=us}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(s);((e=us)=>{try{if(!Ui)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(r=null!==(t=null==xi?void 0:xi.length)&&void 0!==t?t:ki&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==r?r:0);o++){const t=Ni(o);if(t&&t.startsWith(e)){const n=Li(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Mi(t)}catch(e){Mi(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,r})(i);const a=e(Ri(s,{afterRequest:async(e,t)=>{var n;if(e.path!==hs&&e.path!==ps)return;const{nonce:r,seq:o,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(ds),r=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const r=Number(n);return Number.isSafeInteger(r)?r:void 0})(n);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=ys(e)),{nonce:n,seq:r,executionId:ms(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!r||!s)return;const a=e.path===hs,c=null===(n=gs(s,i))||void 0===n?void 0:n.seq;!a&&void 0!==o&&void 0!==c&&o<=c||((e,t,n,r=us,o)=>{try{const i=fs(e,r),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:o};Di(i,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,r,a,i,null!=o?o:a?void 0:c)},beforeRequest:e=>{if(e.path===ps){const t=ys(e);if(t){const n=((e,t=us)=>{var n,r;return null!==(r=null===(n=gs(e,t))||void 0===n?void 0:n.value)&&void 0!==r?r:null})(t,i);n&&(e.headers=e.headers||{},e.headers[ds]=n)}}return e}}));if(null===(r=a.flow)||void 0===r?void 0:r.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const r=e;let o;e=new Promise((e=>{o=e})),await r;try{return await t(...n)}finally{o()}}}return a}),(e=>t=>{const n=e(Ri(t,{afterRequest:async(e,t)=>{if(Pi(e,t))return void qi(js);const n=await Ti(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,r;try{ki&&(null===(r=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===r||r.call(n,e,t))}catch(e){}})(js,String(n.sessionExpiration))}}));return Kr(n,["logout","logoutAll","oidc.logout"],xs)}),(e=>n=>{var{autoRefresh:r}=n,o=t(n,["autoRefresh"]);const i=!!r,s="object"==typeof r&&(null==r?void 0:r.customActivityTracking);if(!i||$i())return Object.assign(e(o),{markUserActive:()=>{Fi("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:c}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,u,d=null,h=!1,p=!1;s&&(zi("Activity-based refresh enabled"),d=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),ki&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(zi("Expiration time passed, refreshing session"),f.refresh(Qi()||u))}));const f=e(Ri(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:r,sessionExpiration:o,nextRefreshSeconds:i}=await Ti(t);if(Pi(e,t))zi("Session invalidated, canceling all timers"),a();else if(n||o){if(l=((e,t)=>{if(t)return new Date(1e3*t);zi("Could not extract expiration time from session token, trying to decode the token");try{const t=Hn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!l)return void zi("Could not extract expiration time from session token");u=r,h=i>0;const e=Ji(l,i);if(a(),e<=2e4)return void zi("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});zi(`Setting refresh timer for ${t}. (${e}ms)`),d&&(d.reset(),p=!1),c((()=>{if(ki&&"hidden"===document.visibilityState)zi("Skipping refresh due to timer - document is hidden");else{if(d&&h&&!d.hadActivity())return zi("Skipping refresh due to timer - user is idle"),void(p=!0);zi("Refreshing session due to timer"),f.refresh(Qi()||r)}}),e)}}}));return Object.assign(Kr(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return zi("Clearing all timers"),a(),n})),{markUserActive:d?()=>{zi("markUserActive() called"),h||zi("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),d.markActive(),p&&(zi("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Qi()||u))}:()=>{Fi("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:r=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!r)return Object.assign(e(i),{getLastUserLoginId:Is,getLastUserDisplayName:Ss});const s=e(Ri(i,{afterRequest:async(e,t)=>{var n;const{userInfo:r,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()),n=Ai((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),i=null===(n=null==r?void 0:r.loginIds)||void 0===n?void 0:n[0],s=null==r?void 0:r.name;i?(ks(i),(e=>{Di(bs,e)})(s)):(null==o?void 0:o.loginId)&&ks(o.loginId)}}));let a=Kr(s,["flow.start"],Os);return a=Kr(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const r=await t(...n);return e||(Mi(ws),Mi(bs)),r})(o)),Object.assign(a,{getLastUserLoginId:Is,getLastUserDisplayName:Ss})}),(e=>n=>{var{persistTokens:r,sessionTokenViaCookie:o,refreshTokenViaCookie:i,storagePrefix:s,refreshCookieName:a}=n,c=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!r||!ki)return e(Object.assign({refreshCookieName:a},c));let l;const u=e(Ri(Object.assign({refreshCookieName:a},c),{beforeRequest:rs(s,i,a),afterRequest:async(e,t)=>{if(Pi(e,t))zi("Session invalidated, clearing persisted tokens"),ns(s,o,i,l);else{const e=await Ti(t);e.cookieName?Di(`${s||""}${Bi}`,e.cookieName):e.refreshJwt&&Mi(`${s||""}${Bi}`);const n=((e={},t=!1,n="",r=!1)=>{var o,i,s,a;const{sessionJwt:c,refreshJwt:l,trustedDeviceJwt:u}=e;let d;if(l)if(r){Mi(`${n}${Hi}`);const t=r.sameSite||"Strict",s=null===(o=r.secure)||void 0===o||o,a=null!==(i=r.domain)&&void 0!==i?i:e.cookieDomain,c=Zi(r);s&&"https:"!==window.location.protocol&&Fi("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 u=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Yi(c,l,u);const h=Gi(a);d=Object.assign(Object.assign({},d),{refresh:{path:u.cookiePath,domain:h?a:void 0}})}else{const e=Zi(r);ci.remove(e),Di(`${n}${Hi}`,l)}if(c)if(t){const n=t.sameSite||"Strict",r=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,i=Xi(t);r&&"https:"!==window.location.protocol&&Fi("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:n,cookieSecure:r,cookieDomain:o});Yi(i,c,l);const u=Gi(o);d=Object.assign(Object.assign({},d),{session:{path:l.cookiePath,domain:u?o:void 0}})}else Di(`${n}${Vi}`,c);return e.idToken&&Di(`${n}${Ki}`,e.idToken),u&&Di(`${n}DTD`,u),d})(e,o,s,i);n&&(l=n)}}})),d=Kr(u,["logout","logoutAll","oidc.logout"],((e,t,n,r)=>o=>async(...i)=>{const s=await o(...i);return ns(e,t,n,null==r?void 0:r()),s})(s,o,i,(()=>l)));return Object.assign(d,{getRefreshToken:()=>Qi(s,i),getSessionToken:()=>es(s,o),getIdToken:()=>ts(s)})}))((e=>{const t=si(e),n=Vs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(r,o)=>{var i;if($i())return zi(`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 n.refreshToken(r),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&ki&&void 0!==window.localStorage&&!Wi(js)&&!Li(ws)&&!Wi("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=es(),a=Qi();let c="";if(e.getExternalToken)try{c=await(null===(i=e.getExternalToken)||void 0===i?void 0:i.call(e))}catch(e){zi("Error getting external token while refreshing",e)}return t.refresh(r,{dcs:s?"t":"f",dcr:a?"t":"f"},c,o)},logout:async r=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:r}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(r)},flow:zs(t),webauthn:Ms(t),fedcm:(r=t,o=e.projectId,{onetap:{requestExchangeCode(e){Ws(r,e)},requestAuthentication(e){Ws(r,e)}},async oneTap(e,t,n,o,i){await qs(r,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:i})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:r.httpClient.buildUrl(o+Ns),clientId:o}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return r.refresh(i.token)},isSupported:()=>ki&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=r.httpClient.buildUrl(o+Ns);try{const r={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(r));return!!i&&!!i.token}catch(e){return!1}}}),oidc:n});var r,o})),Ks={search:"/v1/mgmt/audit/search"},Bs=e=>n(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((n=>{const r=[],o=(new Date).getTime()/1e3+2592e3,i=new Date(o).toLocaleString();for(let e=1;e<9;e+=1)r.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:i});t.forEach((e=>{r.sort(((t,n)=>{var r,o;return e.desc?null===(o=n[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(r=t[e.field])||void 0===r?void 0:r.localeCompare(n[e.field])}))})),n(r.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()))))}))})),Ys=({httpClient:e,tenant:t,mock:r})=>({search:(...o)=>n(void 0,[...o],void 0,(function*({page:o,limit:i=1e4,text:s,sort:a,from:c}={}){if(r)return Bs({page:o,limit:i,text:s,sort:a},t);const l=yield e.post(Ks.search,{limit:i,page:o,text:s,sort:a,from:c},{queryParams:{tenant:t}});yield(e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(l);return(yield l.json()).audits}))}),Gs=u((e=>{var t,s,a,c;const l=i(A,C,k,R,En,_({tenant:_.missingAttrValidator}))(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.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 r(this,s,"f")||r(this,t,"m",a).call(this),r(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{r(this,s,"f")&&r(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,n,r)=>{const o=Hs(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"audit-management-widget","x-descope-widget-id":r,"x-descope-widget-version":"0.9.2"}}));return{audit:Ys({httpClient:o.httpClient,tenant:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},c})),Xs=u((e=>{const t=i(In({name:"widget",initialState:Fn,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{zn.reducer(e)},asyncActions:{searchAudit:zn.action}}),E,k,Gs)(e);return class extends t{constructor(...e){super(...e),this.state=Fn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Zs=u((e=>{var t,o,a;return a=class extends(i(k,E,V,X,xn("audit-management-widget"),Xs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([r(this,t,"m",o).call(this)]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),Qs=u((e=>{var t,o,s,a,l;return l=class extends(i(k,Zs,Xs)(e)){constructor(){super(...arguments),t.add(this),o.set(this,c((()=>{const e=this.rangeInput.value,t=new Date;let n;switch(e){case"minuets15":n=t.setMinutes(t.getMinutes()-15);break;case"hour":n=t.setHours(t.getHours()-1);break;case"hour6":n=t.setHours(t.getHours()-6);break;case"day":default:n=t.setDate(t.getDate()-1);break;case"day3":n=t.setDate(t.getDate()-3);break;case"week":n=t.setDate(t.getDate()-7);break;case"week2":n=t.setDate(t.getDate()-14);break;case"month":n=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(n).getTime())})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),r(this,t,"m",s).call(this),r(this,t,"m",a).call(this)}))}},o=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new pe(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(r(this,o,"f")),r(this,o,"f").call(this)},a=function(){var e;this.rangeInput=new he(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(r(this,o,"f"))},l})),ea=u((e=>{var t,o,s,c;return c=class extends(i(Xs,k,Zs)(e)){constructor(){super(...arguments),t.add(this),s.set(this,(e=>{let t,n;return(...r)=>(t&&a(t,r)||(t=r,n=e(...r)),n)})((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),r(this,t,"m",o).call(this),r(this,s,"f").call(this,Mn(this.state)),this.subscribe(r(this,s,"f").bind(this),Mn)}))}},s=new WeakMap,t=new WeakSet,o=function(){var e;this.auditTable=new ie(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)))}))},c})),ta=[{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"}],na=u((e=>{var t,o,s;return s=class extends(i(k,Zs,Xs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),r(this,t,"m",o).call(this)}))}},t=new WeakSet,o=function(){var e;this.exportButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="export-button"]'),{logger:this.logger}),this.exportButton.onClick((()=>{const e=Mn(this.state);if(!e.length)return void this.logger.warn("No audit data to export");const t=((e,t)=>[t.map((e=>y(e.header))).join(","),...e.map((e=>t.map((t=>y(e[t.path]))).join(",")))].join("\n"))(e,ta);((e,t)=>{const n=new Blob(["\ufeff"+e],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.setAttribute("download",t),document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)})(t,`audit_logs_${(new Date).toISOString().slice(0,10)}.csv`)}))},s})),ra=u((e=>class extends(i(L,be,ea,Qs,na,Pn)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),oa=i((e=>class extends(ra(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",oa);const ia=(e,t,n,r={})=>{var o,i,s,a;return[Math.min(Math.max(t,("all"===r.left?e.offsetWidth:null!==(o=r.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===r.right?e.offsetWidth:null!==(i=r.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===r.top?e.offsetHeight:null!==(s=r.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===r.bottom?e.offsetHeight:null!==(a=r.bottom)&&void 0!==a?a:0))]};var sa,aa,ca,la,ua,da,ha,pa,fa,ga;const va=document.createElement("template");va.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 ma=i(B)(HTMLElement);class ya extends ma{constructor(){var e;super(),sa.add(this),aa.set(this,new v({messages:[]})),ca.set(this,void 0),la.set(this,void 0),ua.set(this,void 0),da.set(this,{resize:r(this,sa,"m",ga).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(va.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'),o(this,ca,this.shadowRoot.querySelector(".debugger"),"f"),r(this,ca,"f").style.top="32px",r(this,ca,"f").style.left=window.innerWidth-300-32+"px",o(this,la,r(this,ca,"f").querySelector(".content"),"f"),o(this,ua,r(this,ca,"f").querySelector(".header"),"f")}updateData(e){r(this,aa,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let r=0,o=0,i=0,s=0;function a(t){t.preventDefault(),r=i-t.clientX,o=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=ia(e,e.offsetLeft-r,e.offsetTop-o,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(r(this,ca,"f"),r(this,ua,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",r(this,da,"f").resize),(e=r(this,ca,"f")).onmousemove=t=>{var n;const r=t.target;(r.w&&r.w!==r.offsetWidth||r.h&&r.h!==r.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),r.w=r.offsetWidth,r.h=r.offsetHeight},r(this,ca,"f").onresize=r(this,sa,"m",fa).bind(this),r(this,aa,"f").subscribe(r(this,sa,"m",ha).bind(this))}disconnectedCallback(){r(this,aa,"f").unsubscribeAll(),window.removeEventListener("resize",r(this,da,"f").resize)}}aa=new WeakMap,ca=new WeakMap,la=new WeakMap,ua=new WeakMap,da=new WeakMap,sa=new WeakSet,ha=function(e){r(this,sa,"m",pa).call(this,e),r(this,sa,"m",fa).call(this)},pa=function(e){r(this,la,"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("")},fa=function(){r(this,la,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),r=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;r||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)}))},ga=function(){const[e,t]=ia(r(this,ca,"f"),Number.parseInt(r(this,ca,"f").style.left,10),Number.parseInt(r(this,ca,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});r(this,ca,"f").style.top=`${t}px`,r(this,ca,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ya);var wa=Object.freeze({__proto__:null,default:ya});return oa}();
5
+ this["descope-audit-management-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function n(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function r(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function o(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!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"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function i(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),c=(e,t=500)=>{let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}},l=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),(e=>"string"==typeof e?e:"boolean"==typeof e?String(e):(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},u=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const r=e(n);return r[t]=!0,r}};var d,h,p,f;function g(e,t){const n=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r+=1){const o=n[r],i=e[o],s=t[o];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!g(i,s))return!1}else if(i!==s)return!1}return!0}let v=class{constructor(e={},{forceUpdate:t=!1}={}){d.set(this,void 0),h.set(this,{}),p.set(this,0),f.set(this,!0),this.update=e=>{const t="function"==typeof e?e(r(this,d,"f")):e,n=Object.assign(Object.assign({},r(this,d,"f")),t);if(r(this,f,"f")||!g(r(this,d,"f"),n)){const e=r(this,d,"f");o(this,d,n,"f"),Object.freeze(r(this,d,"f")),setTimeout((()=>{Object.values(r(this,h,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,d,e,"f"),o(this,f,t,"f")}get current(){return Object.assign({},r(this,d,"f"))}subscribe(e){return o(this,p,r(this,p,"f")+1,"f"),r(this,h,"f")[r(this,p,"f")]=e,r(this,p,"f").toString()}unsubscribe(e){const t=!!r(this,h,"f")[e];return t&&delete r(this,h,"f")[e],t}unsubscribeAll(){return o(this,h,{},"f"),!0}};d=new WeakMap,h=new WeakMap,p=new WeakMap,f=new WeakMap;const m=["=","+","-","@","\t","\r"],y=e=>{const t=(e=>e.length>0&&m.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};const w=["error","warn","info","debug"],b={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},k=u((e=>{var t,n,i,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,r(this,t,"m",i).call(this,b))}set logger(e){o(this,n,r(this,t,"m",i).call(this,e||b),"f")}get logger(){return r(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,i=function(e){return w.reduce(((t,n)=>(t[n]=(...t)=>{var r;this.onLogEvent(n,t),null===(r=e[n])||void 0===r||r.call(e,...t)},t)),{})},s})),I="undefined"!=typeof localStorage,S="https://static.descope.com/pages",O="https://static2.descope.com/pages",j=I&&localStorage.getItem("base.content.url")||"",x=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,E=u((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&r(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),C=u((e=>{var t,n;const o=i(k,E)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=r(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){r(this,t,"f")[e]||(r(this,t,"f")[e]=[]);const o=r(this,t,"f")[e].push(n);return()=>r(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),_=e=>t=>{var n,o,s;const a=i(k,E,C)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,r(this,n,"m",o).bind(this))}async init(){var e;c.forEach((e=>r(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const r=e[t],o="function"==typeof r?r(t,n):r;o&&this.logger.error(o)},s};_.missingAttrValidator=x;const A=u((e=>{const t=i(_({"project-id":x}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),R=u((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),T="Trying the next fallback URL...",$=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(r){return null==n||n.debug(`Network error fetching URL ${e} [${r.message}], retrying...`),fetch(e,t)}};const P=u((e=>{var t,n,s,a,c,l,u;const d=i(k,A,R)(e);return u=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const i=r(this,t,"m",c).call(this,e),l=Array.isArray(i)?e=>{const{baseUrl:t}=i[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=i[t].baseUrl;r(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:r}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const i=o[e],s=e===o.length-1;try{const o=await $(i.toString(),t,{logger:n});if(o.ok)return null==r||r(e),null==n||n.debug(`Successfully fetched URL ${i}`),o;const a=`Error fetching URL ${i} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${T}`)}catch(e){const t=`Error fetching URL ${i} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${T}`)}}})(i,{cache:"default"},{logger:this.logger,onSuccess:l});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,c=function(e){const i=j||this.baseStaticUrl;if(i)return r(this,t,"m",l).call(this,e,i);r(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),r(this,a,"f").clear());const c=[];if(r(this,s,"f"))c.push(r(this,t,"m",l).call(this,e,r(this,s,"f"))),r(this,s,"f")===S&&c.push(r(this,t,"m",l).call(this,e,O));else{const n=this.baseUrl+"/pages";this.baseUrl&&!r(this,a,"f").has(n)&&c.push(r(this,t,"m",l).call(this,e,n)),r(this,a,"f").has(S)||c.push(r(this,t,"m",l).call(this,e,S)),c.push(r(this,t,"m",l).call(this,e,O))}return 1===c.length?c[0]:c},l=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:r=S}){const o=new URL(r);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=r,o}({projectId:this.projectId,filename:e,baseUrl:t})},u})),U=u((e=>{var t,n;const o=i(_({"project-id":x}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(r(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return r(this,t,"f").set(e,n),()=>{r(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(r(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!r(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=r(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),D=u((e=>{var t,n,s,a,c;const l=i(P,U,E)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.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",r(this,t,"m",n).bind(this))}get config(){return r(this,s,"f")||o(this,s,r(this,a,"f").call(this),"f"),r(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},c})),L=u((e=>{var t,n,s,a,c,l,u;return u=class extends(i(E,k)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var i;null===(i=super.attributeChangedCallback)||void 0===i||i.call(this,e,n,o),"debug"===e&&r(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&r(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),r(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=r(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(r(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return ka})),document.body.appendChild(r(this,n,"f"))},c=function(){this.debug?r(this,t,"m",a).call(this):r(this,t,"m",s).call(this)},l=function(e,t){var o;e&&(null===(o=r(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},u})),M=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],N=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},W=(e,t,n)=>new Promise(((r,o)=>{const i=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);i.onerror=e=>{i.setAttribute("status","error"),o(e)},i.onload=()=>{i.setAttribute("status","loaded"),r(i)},i.src=t.toString(),document.body.appendChild(i)})),q=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},z=u((e=>{const t=i(k)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",r=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const r of e){const{id:e,url:o,integrity:i}=r,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await q(s,i),r}catch(e){t(r,!0)}else try{return await W(e,o,i),r}catch(e){t(r,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,r="",o)=>e.reduce(((e,i)=>{const s=i;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}@${n}/${r}`);const c={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${N(a)}`};return o&&(c.integrity=o),[...e,c]}),[]))([...r,this.baseCdnUrl,...M],e,t,n,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}"`)}))}}})),F="base.ui.components.url",J=I&&localStorage.getItem(F),V=u((e=>{var t,n,s,a,c,l,u;const d=i(k,D,z)(e);return u=class extends d{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return r(this,a,"f")||o(this,a,r(this,t,"m",l).call(this),"f"),r(this,a,"f")}async loadDescopeUiComponents(e){const n=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(n.map((e=>r(this,t,"m",c).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},c=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(", ")}"`)},l=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await r(this,t,"m",n).call(this),o=J?void 0:await r(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[J],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},u})),K=u((e=>{var t,n,o;const s=i(E,C)(e);return o=class extends s{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",r(this,t,"m",n).bind(this)),r(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class H{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?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 B=u((e=>{const t=i(K)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new H(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const r=[...e.adoptedStyleSheets||[]];r[t?"unshift":"push"](n),e.adoptedStyleSheets=r}}return n}}})),Y="content-root",G="root",X=u((e=>{const t=i(B)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${G}">\n <div id="${Y}"></div>\n </div>\n `,this.injectStyle(`\n #${G}, #${Y} {\n height: 100%;\n }\n #${G} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Y),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(G)}}})),Z="descope-modal";var Q,ee;let te=class{constructor(e,t){Q.set(this,void 0),this.nodeName="",o(this,Q,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const r="function"==typeof e?e():e;r&&(clearInterval(n),t(r))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(r(this,Q,"f"))}get ele(){var e,t;const n="function"==typeof r(this,Q,"f")?r(this,Q,"f").call(this):r(this,Q,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};Q=new WeakMap;let ne=class extends te{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};const re=/^descope-grid-([^-]+)-column$/,oe={text:class extends te{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 te{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 ie=class extends te{constructor(){super(...arguments),this.nodeName="descope-grid",ee.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 n;const r=null===(n=re.exec(t.localName))||void 0===n?void 0:n[1],o=oe[r];return o?(e.push(new o(t,{logger:this.logger})),e):e}),[]):[]}filterColumns(e){var t,n;const o=null===(t=this.ele.columns)||void 0===t?void 0:t.filter(e);o&&this.ele.columns&&(a(o,this.ele.columns)||(this.ele.columns=o,null===(n=r(this,ee,"f"))||void 0===n||n.call(this,o)))}onColumnsChange(e){o(this,ee,e,"f")}set renderColumn(e){this.ele.renderColumn=e}};var se,ae,ce,le;ee=new WeakMap;let ue=class extends te{constructor(...e){super(...e),se.add(this),ae.set(this,void 0),ce.set(this,void 0),this.nodeName="descope-modal",r(this,se,"m",le).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),r(this,se,"m",le).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),r(this,ae,"f")&&(null===(e=this.ele)||void 0===e||e.append(r(this,ae,"f").content.cloneNode(!0)))}setContent(e){o(this,ae,e,"f"),this.reset()}remove(){var e,t;null===(e=r(this,ce,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};ae=new WeakMap,ce=new WeakMap,se=new WeakSet,le=function(){if(r(this,ce,"f"))return;const e=this.ele;e&&(o(this,ce,new MutationObserver((t=>{t.forEach(((n,r)=>{var o;const i="true"===n.oldValue,s=t[r+1]?t[r+1].oldValue:e.getAttribute("opened");i&&"true"!==s&&(null===(o=this.afterClose)||void 0===o||o.call(this))}))})),"f"),r(this,ce,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};let de=class extends te{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()}},he=class extends te{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)}},pe=class extends te{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")}};const fe=u((e=>{var t,n;const o=i(E,X,V)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ue{setContent(t){e(t),super.setContent(t)}}})())}get modalDriverClass(){return r(this,t,"f")}createModal(e,n=r(this,t,"f")){const o=((e={})=>{const t=document.createElement(Z);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(o),new n(o,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Z]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));u((e=>class extends(fe(e)){createFlowModal(e){const t=this.modalDriverClass;return this.createModal(e,class extends t{setContent(e){const t=e.content.querySelector("descope-wc");t&&!t.hasAttribute("lazy-start")&&t.setAttribute("lazy-start","true"),super.setContent(e)}async open(){var e,t,n;await super.open(),null===(n=null===(t=null===(e=this.ele)||void 0===e?void 0:e.querySelector("descope-wc"))||void 0===t?void 0:t.start)||void 0===n||n.call(t)}})}}));const ge="descope-notification";u((e=>{var t,n;const o=i(E,X,V)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends de{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ge);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(r(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([ge])}},t=new WeakMap,n}));const ve=(e,t,n="")=>Object.entries(e).reduce(((e,[r,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(r))return t("Ignoring invalid override-css token path segment"),e;const i=n?`${n}-${r}`:r;if("object"==typeof o&&null!==o)return e+ve(o,t,i);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-${i}:${s};`}),"");function me(e,t){const n=Object.assign({},e);for(const[e,r]of Object.entries(t||{}))if(null!=r)if("object"==typeof r){if(0===Object.keys(r).length)continue;n[e]=me(n[e]||{},r)}else n[e]="string"==typeof r?(n[e]||"")+r:r;return n}const ye=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",we=u((e=>{const t=i(_({tenant:ye}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),be=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ke=u((e=>{var t,n,s,a,c,l,u,d,h,p,f,g,v,m,y,w,b,k,I,S,O,j;const x=i(_({theme:be}),we,P,E,V,D,X,C,B)(e);return j=class extends x{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),l.set(this,void 0),u.set(this,void 0),I.set(this,(()=>{r(this,t,"m",S).call(this),r(this,O,"f").call(this,"os"===this.getAttribute("theme"))})),O.set(this,(e=>{var n,o,i;const s=e?"addEventListener":"removeEventListener";null===(i=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===i||i.call(o,"change",(()=>r(this,t,"m",S).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){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 n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}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)),r(this,I,"f").call(this),await Promise.all([r(this,t,"m",p).call(this),r(this,t,"m",v).call(this),r(this,t,"m",y).call(this)]),r(this,t,"m",m).call(this),this.observeAttributes(["theme"],r(this,I,"f")),this.observeAttributes(["theme-override"],(()=>r(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{o(this,u,null,"f"),r(this,t,"m",v).call(this),r(this,t,"m",y).call(this)})),this.observeAttributes(["style-id"],(()=>{o(this,l,null,"f"),r(this,t,"m",b).call(this),r(this,t,"m",p).call(this),r(this,t,"m",y).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,I=new WeakMap,O=new WeakMap,t=new WeakSet,c=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,r,o,i,s,a;const c=null===(o=null===(r=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===r?void 0:r.colors)||void 0===o?void 0:o.primary,l=null===(a=null===(s=null===(i=e[t])||void 0===i?void 0:i.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return c||l?`[data-theme="${t}"]{${ve({colors:{primary:c,secondary:l}},(e=>this.logger.error(e)))}}`:""})).join(""):""},d=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(F))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(F),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();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")}},h=function(){return r(this,l,"f")||(o(this,l,r(this,t,"m",d).call(this),"f"),r(this,l,"f").then((e=>this.logger.debug("Fetched theme",e)))),r(this,l,"f")},p=async function(){var e,i;const s=await r(this,t,"a",h);if(!s)return;const a=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.globals)||"");r(this,n,"f")?r(this,n,"f").replaceSync(a):o(this,n,this.injectStyle(a,{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.warn("No tenant style exists, using project default theme.")}},g=function(){return r(this,u,"f")||o(this,u,r(this,t,"m",f).call(this),"f"),r(this,u,"f")},v=async function(){var e,n,i,a;if(!this.tenantId)return void(null===(e=r(this,s,"f"))||void 0===e||e.replaceSync(""));const c=await r(this,t,"a",g);if(!c)return void(null===(n=r(this,s,"f"))||void 0===n||n.replaceSync(""));const l=((null===(i=c.light)||void 0===i?void 0:i.globals)||"")+((null===(a=c.dark)||void 0===a?void 0:a.globals)||"");r(this,s,"f")?r(this,s,"f").replaceSync(l):o(this,s,this.injectStyle(l),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=r(this,a,"f"))||void 0===e||e.replaceSync(""));const n=r(this,t,"m",c).call(this);r(this,a,"f")?r(this,a,"f").replaceSync(n):o(this,a,this.injectStyle(n),"f")},y=async function(){var e,n,o,i;const s=await r(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const c=await r(this,t,"a",g);a.componentsThemeManager.themes={light:me((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.components)||{},(null===(n=null==c?void 0:c.light)||void 0===n?void 0:n.components)||{}),dark:me((null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.components)||{},(null===(i=null==c?void 0:c.dark)||void 0===i?void 0:i.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},r=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,i=r||o;return null===(t=null==i?void 0:i[this.theme])||void 0===t?void 0:t.fonts},b=async function(){const e=await r(this,t,"m",w).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")},k=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)},S=function(){r(this,t,"m",b).call(this),r(this,t,"m",k).call(this)},j}));var Ie=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),Se=()=>Math.random().toString(36).substring(7).split("").join("."),Oe={INIT:`@@redux/INIT${Se()}`,REPLACE:`@@redux/REPLACE${Se()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Se()}`};function je(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 xe(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function Ee(e){let t=typeof e;return t=xe(e),t}function Ce(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Ee(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${Ee(n)}'`);return n(Ce)(e,t)}let r=e,o=t,i=new Map,s=i,a=0,c=!1;function l(){s===i&&(s=new Map,i.forEach(((e,t)=>{s.set(t,e)})))}function u(){if(c)throw new Error("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 d(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Ee(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),i=null}}}function h(e){if(!je(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Ee(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('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(`Action "type" property must be a string. Instead, the actual type was: '${Ee(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,o=r(o,e)}finally{c=!1}return(i=s).forEach((e=>{e()})),e}h({type:Oe.INIT});return{dispatch:h,subscribe:d,getState:u,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${Ee(e)}`);r=e,h({type:Oe.REPLACE})},[Ie]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${Ee(t)}'`);function n(){const e=t;e.next&&e.next(u())}n();return{unsubscribe:e(n)}},[Ie](){return this}}}}}function _e(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Ae(e){const t=Object.keys(e),n={};for(let r=0;r<t.length;r++){const o=t[r];void 0===e[o]&&_e(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const r=Object.keys(n);let o,i;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:Oe.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:Oe.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${Oe.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){i=e}return function(e={},t){if(i)throw i;{const r=function(e,t,n,r){const o=Object.keys(t),i=n&&n.type===Oe.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(!je(e))return`The ${i} has unexpected type of "${Ee(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!r[e]));return s.forEach((e=>{r[e]=!0})),n&&n.type===Oe.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);r&&_e(r)}let s=!1;const a={};for(let o=0;o<r.length;o++){const i=r[o],c=n[i],l=e[i],u=c(l,t);if(void 0===u){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${i}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[i]=u,s=s||u!==l}return s=s||r.length!==Object.keys(e).length,s?a:e}}function Re(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Te(e){return je(e)&&"type"in e&&"string"==typeof e.type}var $e=Symbol.for("immer-nothing"),Pe=Symbol.for("immer-draftable"),Ue=Symbol.for("immer-state"),De=[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 Le(e,...t){{const n=De[e],r="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}}var Me=Object.getPrototypeOf;function Ne(e){return!!e&&!!e[Ue]}function We(e){return!!e&&(ze(e)||Array.isArray(e)||!!e[Pe]||!!e.constructor?.[Pe]||He(e)||Be(e))}var qe=Object.prototype.constructor.toString();function ze(e){if(!e||"object"!=typeof e)return!1;const t=Me(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===qe}function Fe(e,t){0===Je(e)?Object.entries(e).forEach((([n,r])=>{t(n,r,e)})):e.forEach(((n,r)=>t(r,n,e)))}function Je(e){const t=e[Ue];return t?t.type_:Array.isArray(e)?1:He(e)?2:Be(e)?3:0}function Ve(e,t){return 2===Je(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ke(e,t,n){const r=Je(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function He(e){return e instanceof Map}function Be(e){return e instanceof Set}function Ye(e){return e.copy_||e.base_}function Ge(e,t){if(He(e))return new Map(e);if(Be(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&ze(e)){if(!Me(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Ue];let r=Reflect.ownKeys(n);for(let t=0;t<r.length;t++){const o=r[t],i=n[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Me(e),n)}function Xe(e,t=!1){return Qe(e)||Ne(e)||!We(e)||(Je(e)>1&&(e.set=e.add=e.clear=e.delete=Ze),Object.freeze(e),t&&Fe(e,((e,t)=>Xe(t,!0)))),e}function Ze(){Le(2)}function Qe(e){return Object.isFrozen(e)}var et,tt={};function nt(e){const t=tt[e];return t||Le(0,e),t}function rt(){return et}function ot(e,t){t&&(nt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function it(e){st(e),e.drafts_.forEach(ct),e.drafts_=null}function st(e){e===et&&(et=e.parent_)}function at(e){return et={drafts_:[],parent_:et,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ct(e){const t=e[Ue];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function lt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ue].modified_&&(it(t),Le(4)),We(e)&&(e=ut(t,e),t.parent_||ht(t,e)),t.patches_&&nt("Patches").generateReplacementPatches_(n[Ue].base_,e,t.patches_,t.inversePatches_)):e=ut(t,n,[]),it(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==$e?e:void 0}function ut(e,t,n){if(Qe(t))return t;const r=t[Ue];if(!r)return Fe(t,((o,i)=>dt(e,r,t,o,i,n))),t;if(r.scope_!==e)return t;if(!r.modified_)return ht(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const t=r.copy_;let o=t,i=!1;3===r.type_&&(o=new Set(t),t.clear(),i=!0),Fe(o,((o,s)=>dt(e,r,t,o,s,n,i))),ht(e,t,!1),n&&e.patches_&&nt("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function dt(e,t,n,r,o,i,s){if(o===n&&Le(5),Ne(o)){const s=ut(e,o,i&&t&&3!==t.type_&&!Ve(t.assigned_,r)?i.concat(r):void 0);if(Ke(n,r,s),!Ne(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(We(o)&&!Qe(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ut(e,o),t&&t.scope_.parent_||ht(e,o)}}function ht(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Xe(t,n)}var pt={get(e,t){if(t===Ue)return e;const n=Ye(e);if(!Ve(n,t))return function(e,t,n){const r=vt(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!We(r)?r:r===gt(e.base_,t)?(yt(e),e.copy_[t]=wt(r,e)):r},has:(e,t)=>t in Ye(e),ownKeys:e=>Reflect.ownKeys(Ye(e)),set(e,t,n){const r=vt(Ye(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=gt(Ye(e),t),o=r?.[Ue];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,r)&&(void 0!==n||Ve(e.base_,t)))return!0;yt(e),mt(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==gt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,yt(e),mt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ye(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty(){Le(11)},getPrototypeOf:e=>Me(e.base_),setPrototypeOf(){Le(12)}},ft={};function gt(e,t){const n=e[Ue];return(n?Ye(n):e)[t]}function vt(e,t){if(!(t in e))return;let n=Me(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Me(n)}}function mt(e){e.modified_||(e.modified_=!0,e.parent_&&mt(e.parent_))}function yt(e){e.copy_||(e.copy_=Ge(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Fe(pt,((e,t)=>{ft[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ft.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Le(13),ft.set.call(this,e,t,void 0)},ft.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Le(14),pt.set.call(this,e[0],t,n,e[0])};function wt(e,t){const n=He(e)?nt("MapSet").proxyMap_(e,t):Be(e)?nt("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:rt(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=pt;n&&(o=[r],i=ft);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}(e,t);return(t?t.scope_:rt()).drafts_.push(n),n}function bt(e){return Ne(e)||Le(10,e),kt(e)}function kt(e){if(!We(e)||Qe(e))return e;const t=e[Ue];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Ge(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Ge(e,!0);return Fe(n,((e,t)=>{Ke(n,e,kt(t))})),t&&(t.finalized_=!1),n}var It=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const r=this;return function(e=n,...o){return r.produce(e,(e=>t.call(this,e,...o)))}}let r;if("function"!=typeof t&&Le(6),void 0!==n&&"function"!=typeof n&&Le(7),We(e)){const o=at(this),i=wt(e,void 0);let s=!0;try{r=t(i),s=!1}finally{s?it(o):st(o)}return ot(o,n),lt(r,o)}if(!e||"object"!=typeof e){if(r=t(e),void 0===r&&(r=e),r===$e&&(r=void 0),this.autoFreeze_&&Xe(r,!0),n){const t=[],o=[];nt("Patches").generateReplacementPatches_(e,r,t,o),n(t,o)}return r}Le(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,r;const o=this.produce(e,t,((e,t)=>{n=e,r=t}));return[o,n,r]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){We(e)||Le(8),Ne(e)&&(e=bt(e));const t=at(this),n=wt(e,void 0);return n[Ue].isManual_=!0,st(t),n}finishDraft(e,t){const n=e&&e[Ue];n&&n.isManual_||Le(9);const{scope_:r}=n;return ot(r,t),lt(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=nt("Patches").applyPatches_;return Ne(e)?r(e,t):this.produce(e,(e=>r(e,t)))}},St=It.produce;It.produceWithPatches.bind(It),It.setAutoFreeze.bind(It),It.setUseStrictShallowCopy.bind(It),It.applyPatches.bind(It),It.createDraft.bind(It),It.finishDraft.bind(It);var Ot=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},jt=(e,t,n)=>{const{memoize:r,memoizeOptions:o}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=r((()=>({})),...o);if(!(a.apply(null,i)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},xt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Et=e=>Array.isArray(e)?e:[e];function Ct(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function _t(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var At="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Rt=0,Tt=1;function $t(){return{s:Rt,v:void 0,o:null,p:null}}function Pt(e,t={}){let n=$t();const{resultEqualityCheck:r}=t;let o,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const r=e.get(n);void 0===r?(t=$t(),e.set(n,t)):t=r}else{let e=t.p;null===e&&(t.p=e=new Map);const r=e.get(n);void 0===r?(t=$t(),e.set(n,t)):t=r}}const a=t;let c;if(t.s===Tt)c=t.v;else if(c=e.apply(null,arguments),i++,r){const e=o?.deref?.()??o;null!=e&&r(e,c)&&(c=e,0!==i&&i--);o="object"==typeof c&&null!==c||"function"==typeof c?new At(c):c}return a.s=Tt,a.v=c,c}return s.clearCache=()=>{n=$t(),s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function Ut(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t,r=0,o=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:u=Pt,argsMemoizeOptions:d=[],devModeChecks:h={}}=a,p=Et(l),f=Et(d),g=Ct(e),v=c((function(){return r++,s.apply(null,arguments)}),...p);let m=!0;const y=u((function(){o++;const e=_t(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:r}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...xt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Ot},inputStabilityCheck:{shouldRun:"always"===r||"once"===r&&e,run:jt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),r.shouldRun){const t=_t(g,arguments);r.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(y,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>r,resetRecomputations:()=>{r=0},memoize:c,argsMemoize:u})};return Object.assign(r,{withTypes:()=>r}),r}var Dt=Ut(Pt),Lt=Object.assign(((e,t=Dt)=>{!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 n=Object.keys(e);return t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,r)=>(e[n[r]]=t,e)),{})))}),{withTypes:()=>Lt});function Mt(e){return({dispatch:t,getState:n})=>r=>o=>"function"==typeof o?o(t,n,e):r(o)}var Nt=Mt(),Wt=Mt;((...e)=>{const t=Ut(...e)})(Pt);var qt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Re:Re.apply(null,arguments)},zt=e=>e&&"function"==typeof e.match;function Ft(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw new Error("prepareAction did not return an object");return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Te(t)&&t.type===e,n}function Jt(e){return"function"==typeof e&&"type"in e&&zt(e)}function Vt(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Kt=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 Ht(e){return We(e)?St(e,(()=>{})):e}function Bt(e,t,n){if(e.has(t)){let r=e.get(t);return n.update&&(r=n.update(r,t,e),e.set(t,r)),r}if(!n.insert)throw new Error("No insert provided for key not already in map");const r=n.insert(t,e);return e.set(t,r),r}function Yt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Gt(e,t,n){const r=Xt(e,t,n);return{detectMutations:()=>Zt(e,t,r,n)}}function Xt(e,t=[],n,r="",o=new Set){const i={value:n};if(!e(n)&&!o.has(n)){o.add(n),i.children={};for(const o in n){const s=r?r+"."+o:o;t.length&&-1!==t.indexOf(s)||(i.children[o]=Xt(e,t,n[o],s))}}return i}function Zt(e,t=[],n,r,o=!1,i=""){const s=n?n.value:void 0,a=s===r;if(o&&!a&&!Number.isNaN(r))return{wasMutated:!0,path:i};if(e(s)||e(r))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in r)c[e]=!0;const l=t.length>0;for(let o in c){const s=i?i+"."+o:o;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=Zt(e,t,n.children[o],r[o],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function Qt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||je(e)}function en(e,t="",n=Qt,r,o=[],i){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(i?.has(e))return!1;const a=null!=r?r(e):Object.entries(e),c=o.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=en(l,a,n,r,o,i),s))return s}return i&&tn(e)&&i.add(e),!1}function tn(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!tn(t))return!1;return!0}function nn(e){return"boolean"==typeof e}var rn=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:o=!0}=e??{};let i=new Kt;if(t&&(nn(t)?i.push(Nt):i.push(Wt(t.extraArgument))),n){let e={};nn(n)||(e=n),i.unshift(function(e={}){{let t=function(e,t,r,o){return JSON.stringify(e,n(t,o),r)},n=function(e,t){let n=[],r=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+r.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,i){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?r.splice(s,1/0,o):r.push(o),~n.indexOf(i)&&(i=t.call(this,o,i))}else n.push(i);return null==e?i:e.call(this,o,i)}},{isImmutable:r=Yt,ignoredPaths:o,warnAfter:i=32}=e;const s=Gt.bind(null,r,o);return({getState:e})=>{let n,r=e(),o=s(r);return a=>c=>{const l=Vt(i,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const u=a(c);return l.measureTime((()=>{if(r=e(),n=o.detectMutations(),o=s(r),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),u}}}}(e))}if(r){let e={};nn(r)||(e=r),i.push(function(e={}){{const{isSerializable:t=Qt,getEntries:n,ignoredActions:r=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,u=!l&&WeakSet?new WeakSet:void 0;return e=>l=>d=>{if(!Te(d))return l(d);const h=l(d),p=Vt(s,"SerializableStateInvariantMiddleware");return c||r.length&&-1!==r.indexOf(d.type)||p.measureTime((()=>{const e=en(d,"",t,n,o,u);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",d,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const r=en(e.getState(),"",t,n,i,u);if(r){const{keyPath:e,value:t}=r;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: ${d.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};nn(o)||(e=o),i.unshift(function(e={}){const{isActionCreator:t=Jt}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return i},on=e=>t=>{setTimeout(t,e)},sn="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:on(10),an=e=>function(t){const{autoBatch:n=!0}=t??{};let r=new Kt(e);return n&&r.push(((e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let o=!0,i=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?sn:"callback"===e.type?e.queueNotification:on(e.timeout),l=()=>{s=!1,i&&(i=!1,a.forEach((e=>e())))};return Object.assign({},r,{subscribe(e){const t=r.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,i=!o,i&&(s||(s=!0,c(l))),r.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),r};function cn(e){const t=rn(),{reducer:n,middleware:r,devTools:o=!0,preloadedState:i,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!je(n))throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=Ae(n)}if(r&&"function"!=typeof r)throw new Error("`middleware` field must be a callback");if("function"==typeof r){if(c=r(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=Re;o&&(l=qt({trace:!0,..."object"==typeof o&&o}));const u=function(...e){return t=>(n,r)=>{const o=t(n,r);let i=()=>{throw new Error("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)=>i(e,...t)},a=e.map((e=>e(s)));return i=Re(...a)(o.dispatch),{...o,dispatch:i}}}(...c),d=an(u);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(d):d();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");c.length&&!h.includes(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Ce(a,i,l(...h))}function ln(e){const t={},n=[];let r;const o={addCase(e,i){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(r)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=i,o},addMatcher(e,t){if(r)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(r)throw new Error("`builder.addDefaultCase` can only be called once");return r=e,o}};return e(o),[t,n,r]}function un(...e){return t=>e.some((e=>((e,t)=>zt(e)?e.match(t):e(t))(e,t)))}var dn=["name","message","stack","code"],hn=class{constructor(e,t){this.payload=e,this.meta=t}_type},pn=class{constructor(e,t){this.payload=e,this.meta=t}_type},fn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of dn)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},gn=(()=>{function e(e,t,n){const r=Ft(e+"/fulfilled",((e,t,n,r)=>({payload:e,meta:{...r||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Ft(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),i=Ft(e+"/rejected",((e,t,r,o,i)=>({payload:o,error:(n&&n.serializeError||fn)(e||"Rejected"),meta:{...i||{},arg:r,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),u=new AbortController;let d;function h(e){d=e,u.abort()}const p=async function(){let p;try{let i=n?.condition?.(e,{getState:a,extra:c});if(null!==(f=i)&&"object"==typeof f&&"function"==typeof f.then&&(i=await i),!1===i||u.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>u.signal.addEventListener("abort",(()=>t({name:"AbortError",message:d||"Aborted"})))));s(o(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:u.signal,abort:h,rejectWithValue:(e,t)=>new hn(e,t),fulfillWithValue:(e,t)=>new pn(e,t)})).then((t=>{if(t instanceof hn)throw t;return t instanceof pn?r(t.payload,l,e,t.meta):r(t,l,e)}))])}catch(t){p=t instanceof hn?i(null,l,e,t.payload,t.meta):i(t,l,e)}var f;return n&&!n.dispatchConditionRejection&&i.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:l,arg:e,unwrap:()=>p.then(vn)})}}),{pending:o,rejected:i,fulfilled:r,settled:un(i,r),typePrefix:e})}return e.withTypes=()=>e,e})();function vn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var mn=Symbol.for("rtk-slice-createasyncthunk");function yn(e,t){return`${e}/${t}`}function wn(e,t,n,r){function o(o,...i){let s=n.call(e,o);if(void 0===s){if(!r)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...i)}return o.unwrapped=t,o}var bn=function({creators:e}={}){const t=e?.asyncThunk?.[mn];return function(e){const{name:n,reducerPath:r=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&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)||{},i=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],r]="function"==typeof e.extraReducers?ln(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[r,o,i]=ln(t);if(function(e){return"function"==typeof e}(e))n=()=>Ht(e());else{const t=Ht(e);n=()=>t}function s(e=n(),t){let s=[r[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[i]),s.reduce(((e,n)=>{if(n){if(Ne(e)){const r=n(e,t);return void 0===r?e:r}if(We(e))return St(e,(e=>n(e,t)));{const r=n(e,t);if(void 0===r){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return r}}return e}),e)}return s.getInitialState=n,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 n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)}))}i.forEach((r=>{const i=o[r],s={reducerName:r,type:yn(n,r),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},r,o){let i,s;if("reducer"in r){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(r))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=r.reducer,s=r.prepare}else i=r;o.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,s?Ft(e,s):Ft(e))}(s,i,a):function({type:e,reducerName:t},n,r,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:s,pending:a,rejected:c,settled:l,options:u}=n,d=o(e,i,u);r.exposeAction(t,d),s&&r.addCase(d.fulfilled,s);a&&r.addCase(d.pending,a);c&&r.addCase(d.rejected,c);l&&r.addMatcher(d.settled,l);r.exposeCaseReducer(t,{fulfilled:s||kn,pending:a||kn,rejected:c||kn,settled:l||kn})}(s,i,a,t)}));const l=e=>e,u=new WeakMap;let d;const h={name:n,reducerPath:r,reducer:(e,t)=>(d||(d=c()),d(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(d||(d=c()),d.getInitialState()),getSelectors(t=l){const n=Bt(u,this,{insert:()=>new WeakMap});return Bt(n,t,{insert:()=>{const n={};for(const[r,o]of Object.entries(e.selectors??{}))n[r]=wn(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const r=t??this.reducerPath;return e.inject({reducerPath:r,reducer:this.reducer},n),{...this,reducerPath:r}}};return h}}();function kn(){}var In="listenerMiddleware";Ft(`${In}/add`),Ft(`${In}/removeAll`),Ft(`${In}/remove`);const Sn=e=>u((t=>{const n=bn(e),r=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(i(k)(t)){constructor(...e){super(...e);const t=cn({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const r=await t.dispatch(e(...n));try{vn(r)}catch(e){this.logger.error(e.message,r.type,e.stack)}return r},i=Object.keys(r).reduce(((e,t)=>(e[t]=o(r[t]),e)),{});this.actions=i,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));u((e=>class extends(k(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{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 n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const On=u((e=>{const t=i(_({"widget-id":x}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),jn=u((e=>{const t=i(D,On)(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 n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}})),xn=u((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=function(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:""}}(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),En=e=>u((t=>{var n,o,s;const a=i(P,On,jn,xn)(t);return s=class extends a{constructor(){super(...arguments),n.add(this)}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async fetchWidgetPage(t){const i=await r(this,n,"m",o).call(this,t);if(void 0!==i)return i;const s=await this.fetchStaticResource(`${e}/${this.widgetId}/${t}`,"text");return null==s?void 0:s.body}},n=new WeakSet,o=async function(t){var n;const r=await this.getWidgetConfig(),o=this.firstAvailableLocale(null!==(n=null==r?void 0:r.targetLocales)&&void 0!==n?n:[]);if(!o)return;const i=".html",s=t.endsWith(i)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${o}${i}`,"text");return null==t?void 0:t.body}catch(e){return}},s})),Cn=u((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),_n=I&&localStorage.getItem("base.debug.logs.url"),An=u((e=>{const t=i(_({"flow-id":x}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function Rn(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const n=Math.floor(t/60);if(n<60)return`${n} minutes`;const r=Math.floor(n/60);return r<24?`${r} hours`:`${Math.floor(r/24)} days`}u((e=>{var t,n,s,a,c,l,u,d,h,p,f,g;const v=i(z,k,E,D,A,An)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,null),s.set(this,!1),a.set(this,null),f.set(this,null)}get telemetryManager(){return r(this,n,"f")}updateTelemetryContext(e){if(r(this,n,"f"))try{r(this,n,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const n=this.sdkVersion||"1.0.0";o(this,f,r(this,t,"m",h).call(this).then((e=>r(this,t,"m",c).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:n}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=r(this,f,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),r(this,t,"m",u).call(this)}},n=new WeakMap,s=new WeakMap,a=new WeakMap,f=new WeakMap,t=new WeakSet,c=async function(e,i){if(null==e?void 0:e.enabled)if(r(this,s,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const a=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",a,"dist/index.js",[_n]);const c=window.DescopeDebugLogs;if(!c)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(o(this,n,new c({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:i.projectId,flowId:i.flowId,version:i.sdkVersion||"1.0.0"},this.logger),"f"),!r(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void o(this,n,null,"f");o(this,s,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&r(this,t,"m",l).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),o(this,s,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},l=function(e){const n=e-Date.now();if(n<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void r(this,t,"m",u).call(this);const i=864e5,s=Math.min(n,i);n>i&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${Rn(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${Rn(s)})`),o(this,a,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),r(this,t,"m",u).call(this)}),s),"f")},u=function(){if(r(this,a,"f")&&(clearTimeout(r(this,a,"f")),o(this,a,null,"f")),r(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),r(this,n,"f").shutdown(),o(this,n,null,"f"),o(this,s,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},d=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},h=async function(){var e;const n=await this.config,o=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry;let i;try{const e=Number(process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE);i={enabled:"true"===(process.env.DESCOPE_TELEMETRY_ENABLED||"").toLowerCase(),rumConfig:Object.assign({applicationId:process.env.DESCOPE_TELEMETRY_APPLICATION_ID||"",identityPoolId:process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID||"",region:process.env.DESCOPE_TELEMETRY_REGION||"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN&&{guestRoleArn:process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN})}}catch(e){i={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const s=Object.assign(Object.assign(Object.assign({},i),o),{rumConfig:Object.assign(Object.assign({},i.rumConfig),null==o?void 0:o.rumConfig),capture:r(this,t,"m",p).call(this,null==o?void 0:o.capture)});return s.enabled&&!r(this,t,"m",d).call(this,s.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),s.enabled=!1),o||(s.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),s},p=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},g})),u((e=>{var n,o,i;return i=class extends(ke(e)){constructor(){super(...arguments),n.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:i,client:s,form:a}=e,c=t(e,["flowId","client","form"]);return l(Object.assign({projectId:this.getAttribute("project-id"),flowId:i,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:r(this,n,"m",o).call(this,a),client:Object.assign(Object.assign({},this.clientInput),s)},c))}},n=new WeakSet,o=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},i}));const Tn=/(["\\])/g;function $n(e,t){return Array.from(e.querySelectorAll(`[data-id="${n=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(n):n.replace(Tn,"\\$1")}"]`));var n}function Pn(e,t){e&&t&&Object.entries(t).forEach((([t,n])=>{$n(e,t).forEach((e=>function(e,t){var n;switch(t){case"hide":e.setAttribute("hidden",""),null===(n=e.style)||void 0===n||n.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,n)))}))}const Un=u((e=>{var t,n,s,a,c,l;const u=i(k,X)(e);return l=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,{})}async init(){var e,i;if("true"===this.getAttribute("mock"))return o(this,n,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const s=r(this,t,"m",a).call(this);o(this,n,r(this,t,"m",c).call(this,s),"f"),await(null===(i=super.init)||void 0===i?void 0:i.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),o(this,s,null!==(t=await r(this,n,"f"))&&void 0!==t?t:{},"f"),Pn(this.contentRootElement,r(this,s,"f"))}async reevaluateComponentsState(){const e=r(this,t,"m",a).call(this);var n,i;n=this.contentRootElement,i=r(this,s,"f"),n&&i&&Object.entries(i).forEach((([e,t])=>{$n(n,e).forEach((e=>function(e,t){var n;switch(t){case"hide":e.removeAttribute("hidden"),null===(n=e.style)||void 0===n||n.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),o(this,s,await r(this,t,"m",c).call(this,e),"f"),Pn(this.contentRootElement,r(this,s,"f"))}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},c=async function(e){var t;try{const n=await e.get("/v1/mgmt/widget/components-state");if(!(null==n?void 0:n.ok))return{};const r=await n.json();return null!==(t=null==r?void 0:r.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},l})),Dn=(e,t)=>t?{[e]:t}:{},Ln=e=>{if(!e)return;const t=JSON.parse(e);return Array.isArray(t)&&0===t.length?void 0:t},Mn=e=>e.selectedAuditId,Nn=Dt((e=>e.auditList.data),(e=>e.map((e=>{const n=e||{},{occurred:r,ID:o,type:i}=n,s=n.data,a=void 0===s?{saml_request:"",saml_response:"",saml_generated_user:"",saml_generated_roles:"",oidc_response:"",oidc_generated_user:"",scim_request:"",scim_result:"",Change:""}:s,{saml_request:c,saml_response:l,saml_generated_user:u,saml_generated_roles:d,oidc_response:h,oidc_generated_user:p,scim_request:f,scim_result:g,Change:v}=a,m=t(a,["saml_request","saml_response","saml_generated_user","saml_generated_roles","oidc_response","oidc_generated_user","scim_request","scim_result","Change"]),y=t(n,["occurred","ID","type","data"]),w=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}),Dn("type",(e=>e&&e[0].toUpperCase()+e.slice(1))(i))),Dn("saml_request",c)),Dn("saml_response",l)),Dn("saml_generated_user",Ln(u))),Dn("saml_generated_roles",Ln(d))),Dn("oidc_response",Ln(h))),Dn("oidc_generated_user",Ln(p))),Dn("scim_request",f)),Dn("scim_result",g)),Dn("Change",v)),{occurredFormatted:r?new Date(Number(r)||0).toLocaleString():"N/A"});return(e=>Object.fromEntries(Object.entries(e).filter((([e,t])=>!!t))))(w)}))));Dt(Mn,Nn,((e,t)=>t.find((t=>e===t.id)))),Dt(Mn,(e=>!!e));const Wn=gn("audit/search",((e,{extra:{api:t},getState:n})=>{const r=n().searchParams;return t.audit.search(Object.assign(Object.assign({},r),e))})),qn=(e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))})(Wn)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(zn=e=>e.auditList,{onFulfilled:e=>{zn(e).loading=!1},onPending:e=>{zn(e).loading=!0,zn(e).error=null},onRejected:(e,t)=>{zn(e).loading=!1,zn(e).error=t.error}}));var zn;const Fn={action:Wn,reducer:qn},Jn={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""};class Vn extends Error{}function Kn(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 n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function Hn(e,t){if("string"!=typeof e)throw new Vn("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,r=e.split(".")[n];if("string"!=typeof r)throw new Vn(`Invalid token specified: missing part #${n+1}`);let o;try{o=Kn(r)}catch(e){throw new Vn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new Vn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Vn.prototype.name="InvalidTokenError";var Bn={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"},sso:{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",event:"/v1/flow/event"}};const Yn="<region>",Gn=`https://api.${Yn}descope.com`,Xn=6e5,Zn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},Qn=[503,520,521,522,524,530],er=[100,5e3,5e3],tr=e=>new Promise((t=>setTimeout(t,e))),nr=e=>async function(...t){let n=await e(...t);const r=!!(null==(o=t[1])?void 0:o.disableRetry);var o;let i=0;for(;!r&&Qn.includes(n.status)&&i<er.length;)await tr(er[i]),n=await e(...t),i++;i>0&&(n.retries=i);const s=await n.text();return n.text=()=>Promise.resolve(s),n.json=()=>Promise.resolve(JSON.parse(s)),n.clone=()=>n,n},rr=(e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async function(...t){if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Zn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await nr(n)(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await e.text();return Zn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(r)),r}:nr(n)};let or;const ir=()=>{if(or)return or;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()}`,n=Math.floor(1e3+9e3*Math.random());return or=`${t}-${n}`,or};var sr,ar;(ar=sr||(sr={})).get="GET",ar.delete="DELETE",ar.post="POST",ar.put="PUT",ar.patch="PATCH";const cr=({path:e,baseUrl:t,queryParams:n,projectId:r})=>{const o=r.slice(1,-27);t=t.replace(Yn,o?o+".":"");let i=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,r)=>{i=`${i}${0===r?"?":""}${t}=${encodeURIComponent(n[t])}${r===e.length-1?"":"&"}`}))}return i},lr=(...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,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),ur={"Content-Type":"application/json"},dr=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},hr=(e,t)=>{const n={"x-descope-sdk-session-id":ir(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.72.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},pr=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var fr=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:r,logger:o,hooks:i,cookiePolicy:s,fetch:a})=>{const c=e||Gn,l=rr(o,a),u=async e=>{var o;const a=(null==i?void 0:i.beforeRequest)?i.beforeRequest(e):e,{path:u,body:d,headers:h,queryParams:p,method:f,token:g,keepalive:v,disableRetry:m}=a,y=(e=>void 0===e?void 0:JSON.stringify(e))(d),w=Object.assign(Object.assign({headers:lr(dr(t,g),hr(t,r),(null==n?void 0:n.baseHeaders)||{},pr(y)?ur:{},h),method:f,body:y},v?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==s&&(w.credentials=s||"include");const b=await l(cr({path:u,baseUrl:c,queryParams:p,projectId:t}),w);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(e,null==b?void 0:b.clone()),null==i?void 0:i.transformResponse){const e=await b.json(),t=(k=(null===(o=b.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function r(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const i=n;let s,a,c=!1;for(;r();)if(","===e.charAt(n)){for(s=n,n+=1,r(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){c=!0,n=a,t.push(e.substring(i,s));break}n=s+1}else n+=1;(!c||n>=e.length)&&t.push(e.substring(i,e.length))}return t}(k).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.create(null),{json:()=>Promise.resolve(e),cookies:t}),r=new Proxy(b,{get:(e,t)=>{if(t in n)return n[t];const r=e[t];return"function"==typeof r?r.bind(e):r},set:(e,t,r)=>(n[t]=r,!0),has:(e,t)=>t in n||t in e});return n.clone=()=>r,i.transformResponse(r)}var k;return b};return{get:(e,{headers:t,queryParams:n,token:r,keepalive:o,disableRetry:i}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:sr.get,token:r,keepalive:o,disableRetry:i}),post:(e,t,{headers:n,queryParams:r,token:o,keepalive:i,disableRetry:s}={})=>u({path:e,headers:n,queryParams:r,body:t,method:sr.post,token:o,keepalive:i,disableRetry:s}),patch:(e,t,{headers:n,queryParams:r,token:o,keepalive:i,disableRetry:s}={})=>u({path:e,headers:n,queryParams:r,body:t,method:sr.patch,token:o,keepalive:i,disableRetry:s}),put:(e,t,{headers:n,queryParams:r,token:o,keepalive:i,disableRetry:s}={})=>u({path:e,headers:n,queryParams:r,body:t,method:sr.put,token:o,keepalive:i,disableRetry:s}),delete:(e,{headers:t,queryParams:n,token:r,keepalive:o,disableRetry:i}={})=>u({path:e,headers:t,queryParams:n,body:void 0,method:sr.delete,token:r,keepalive:o,disableRetry:i}),hooks:i,buildUrl:(e,n)=>cr({projectId:t,baseUrl:c,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const r=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==r?void 0:r.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var r;const o=[].concat((null===(r=e.hooks)||void 0===r?void 0:r.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},gr=429;function vr(e,t,n){var r;let o=mr(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o.dct)===t)return(null==o?void 0:o[n])||[];o=null===(r=null==o?void 0:o.tenants)||void 0===r?void 0:r[t]}const i=null==o?void 0:o[n];return Array.isArray(i)?i:[]}function mr(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Hn(e)}function yr(e){const{exp:t}=mr(e);return(new Date).getTime()/1e3>t}function wr(e){let t=mr(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function br(e,t){return vr(e,t,"permissions")}function kr(e,t){return vr(e,t,"roles")}const Ir=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Sr(e,t){var n;const r=await e,o={code:r.status,ok:r.ok,response:r},i=await r.clone().json();return r.ok?o.data=i:(o.error=i,r.status===gr&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=r.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function Or(e){var t;return(null===(t=mr(e))||void 0===t?void 0:t.dct)||""}const jr=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),xr=(e,t)=>(n=t)=>t=>{const r=e.filter((e=>e(t)));return!(r.length<e.length)&&(n?n.replace("{val}",t):r.join(" OR "))},Er=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Cr=e=>t=>e.test(t),_r=Cr(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ar=Cr(/^\+[1-9]{1}[0-9]{3,14}$/),Rr=jr(_r,'"{val}" is not a valid email'),Tr=jr(Ar,'"{val}" is not a valid phone number'),$r=jr((e=>e.length>=1),"Minimum length is 1");const Pr=jr((e=>"string"==typeof e),"Input is not a string"),Ur=jr((e=>Array.isArray(e)),"Input is not an array"),Dr=jr((e=>"boolean"==typeof e),"Input is not a boolean"),Lr=jr((e=>void 0===e),"Input is defined"),Mr=xr([Pr(),Lr()],"Input is not a string or undefined"),Nr=xr([Ur(),Dr()],"Input is not an array or boolean"),Wr=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Er(...e).validate(n[t]))),t(...n)),qr=e=>[Pr(`"${e}" must be a string`)],zr=e=>[Mr(`"${e}" must be string or undefined`)],Fr=e=>[Pr(`"${e}" must be a string`),$r(`"${e}" must not be empty`)],Jr=e=>[Pr(`"${e}" must be a string`),Rr()],Vr=e=>[Pr(`"${e}" must be a string`),Tr()],Kr=Wr(Fr("accessKey")),Hr=e=>({exchange:Kr(((t,n)=>Sr(e.post(Bn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Br=(e,t,n)=>(t.forEach((t=>{const r=t.split(".");let o=r.shift(),i=e;for(;r.length>0;){if(i=i[o],!o||!i)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=r.shift()}if("function"!=typeof i[o])throw Error(`"${t}" is not a function`);const s=i[o];i[o]=n(s)})),e),Yr=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Xn,Xn)});var Gr,Xr;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Gr||(Gr={})),function(e){e.email="email"}(Xr||(Xr={}));const Zr=Object.assign(Object.assign({},Gr),Xr);var Qr;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Qr||(Qr={}));const eo=Fr("loginId"),to=Wr(Fr("token")),no=Wr(eo),ro=Wr(Fr("pendingRef")),oo=Wr(eo,Jr("email")),io=e=>({verify:to((t=>Sr(e.post(Bn.enchantedLink.verify,{token:t})))),signIn:no(((n,r,o={},i)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Sr(e.post(Ir(Bn.enchantedLink.signIn,Zr.email),{loginId:n,URI:r,loginOptions:a,providerId:s},{token:i}))})),signUpOrIn:no(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Sr(e.post(Ir(Bn.enchantedLink.signUpOrIn,Zr.email),{loginId:n,URI:r,loginOptions:s,providerId:i}))})),signUp:no(((n,r,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Sr(e.post(Ir(Bn.enchantedLink.signUp,Zr.email),{loginId:n,URI:r,user:o,loginOptions:a,providerId:s}))})),waitForSession:ro(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=Yr(n);let s;const a=setInterval((async()=>{const n=await e.post(Bn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Sr(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:oo(((t,n,r,o,i)=>Sr(e.post(Bn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o}))))}}),so=Wr(Fr("flowId")),ao=Wr(Fr("executionId"),Fr("stepId"),Fr("interactionId")),co=Wr(Fr("executionId")),lo=e=>({start:so(((t,n,r,o,i,s,a,c=!1)=>Sr(e.post(Bn.flow.start,{flowId:t,options:n,conditionInteractionId:r,interactionId:o,componentsVersion:i,flowVersions:s,input:a,isCustomScreen:c})))),next:ao(((t,n,r,o,i,s,a=!1,c)=>Sr(e.post(Bn.flow.next,{executionId:t,stepId:n,interactionId:r,version:o,componentsVersion:i,input:s,isCustomScreen:a,options:c})))),event:co(((t,n,r)=>Sr(e.post(Bn.flow.event,{executionId:t,events:n},{keepalive:r,disableRetry:!0}))))}),uo=Fr("loginId"),ho=Wr(Fr("token")),po=Wr(uo),fo=Wr(uo,Vr("phone")),go=Wr(uo,Jr("email")),vo=Object.keys(Zr).filter((e=>e!==Gr.voice&&e!==Gr.im)),mo=e=>({verify:ho((t=>Sr(e.post(Bn.magicLink.verify,{token:t})))),signIn:vo.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:po(((n,o,i={},s)=>{var{providerId:a}=i,c=t(i,["providerId"]);return Sr(e.post(Ir(Bn.magicLink.signIn,r),{loginId:n,URI:o,loginOptions:c,providerId:a},{token:s}))}))})),{}),signUp:vo.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:po(((n,o,i,s={})=>{var{providerId:a}=s,c=t(s,["providerId"]);return Sr(e.post(Ir(Bn.magicLink.signUp,r),{loginId:n,URI:o,user:i,loginOptions:c,providerId:a}))}))})),{}),signUpOrIn:vo.reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:po(((n,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Sr(e.post(Ir(Bn.magicLink.signUpOrIn,r),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:go(((t,n,r,o,i)=>Sr(e.post(Bn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:r},i),{token:o})))),phone:Object.keys(Gr).filter((e=>e!==Gr.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:fo(((t,r,o,i,s)=>Sr(e.post(Ir(Bn.magicLink.update.phone,n),Object.assign({loginId:t,phone:r,URI:o},s),{token:i}))))})),{})}});var yo;!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"}(yo||(yo={}));const wo=Wr(Fr("code")),bo=e=>({start:Object.assign(((t,n,r,o,i)=>Sr(e.post(Bn.oauth.start,r||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),i&&{loginHint:i}),token:o}))),Object.keys(yo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,r,o,i)=>Sr(e.post(Bn.oauth.start,r||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),i&&{loginHint:i}),token:o}))})),{})),exchange:wo((t=>Sr(e.post(Bn.oauth.exchange,{code:t})))),startNative:(t,n,r)=>Sr(e.post(Bn.oauth.startNative,{provider:t,loginOptions:n,implicit:r})),finishNative:(t,n,r,o,i)=>Sr(e.post(Bn.oauth.finishNative,{provider:t,stateId:n,user:r,code:o,idToken:i})),getOneTapClientId:t=>Sr(e.get(Bn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,r,o)=>Sr(e.post(Bn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:r,loginOptions:o})),exchangeOneTapIDToken:(t,n,r,o)=>Sr(e.post(Bn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:r,loginOptions:o}))}),ko=Fr("appId"),Io=Wr(ko),So=e=>({connect:Io(((t,n,r)=>{const o=null==n?void 0:n.tenantId,i=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,Sr(e.post(Bn.outbound.connect,{appId:t,tenantId:o,tenantLevel:i,options:n},{token:r}))}))}),Oo=Fr("loginId"),jo=Wr(Oo,Fr("code")),xo=Wr(Oo),Eo=Wr(Oo,Vr("phone")),Co=Wr(Oo,Jr("email")),_o=e=>({verify:Object.keys(Zr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:jo(((t,r)=>Sr(e.post(Ir(Bn.otp.verify,n),{code:r,loginId:t}))))})),{}),signIn:Object.keys(Zr).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:xo(((n,o={},i)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Sr(e.post(Ir(Bn.otp.signIn,r),{loginId:n,loginOptions:a,providerId:s},{token:i}))}))})),{}),signUp:Object.keys(Zr).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:xo(((n,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Sr(e.post(Ir(Bn.otp.signUp,r),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Zr).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:xo(((n,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Sr(e.post(Ir(Bn.otp.signUpOrIn,r),{loginId:n,loginOptions:s,providerId:i}))}))})),{}),update:{email:Co(((t,n,r,o)=>Sr(e.post(Bn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:r})))),phone:Object.keys(Gr).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Eo(((t,r,o,i)=>Sr(e.post(Ir(Bn.otp.update.phone,n),Object.assign({loginId:t,phone:r},i),{token:o}))))})),{})}}),Ao=Wr(Fr("tenant")),Ro=Wr(Fr("code")),To=e=>({start:Ao(((t,n,r,o,i,s,a,c)=>Sr(e.post(Bn.sso.start,r||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),i&&{ssoId:i}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),c&&{initiatedEmail:t})},o&&{token:o}))))),exchange:Ro((t=>Sr(e.post(Bn.sso.exchange,{code:t}))))}),$o=Fr("loginId"),Po=Wr($o,Fr("code")),Uo=Wr($o),Do=Wr($o),Lo=e=>({signUp:Uo(((t,n)=>Sr(e.post(Bn.totp.signUp,{loginId:t,user:n})))),verify:Po(((t,n,r,o)=>Sr(e.post(Bn.totp.verify,{loginId:t,code:n,loginOptions:r},{token:o})))),update:Do(((t,n)=>Sr(e.post(Bn.totp.update,{loginId:t},{token:n}))))}),Mo=Fr("loginId"),No=Fr("newPassword"),Wo=Wr(Mo,Fr("password")),qo=Wr(Mo),zo=Wr(Mo,No),Fo=Wr(Mo,Fr("oldPassword"),No),Jo=e=>({signUp:Wo(((n,r,o,i={})=>{var{providerId:s}=i,a=t(i,["providerId"]);return Sr(e.post(Bn.password.signUp,{loginId:n,password:r,user:o,loginOptions:a,providerId:s}))})),signIn:Wo(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Sr(e.post(Bn.password.signIn,{loginId:n,password:r,loginOptions:s,providerId:i}))})),sendReset:qo(((t,n,r)=>Sr(e.post(Bn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:r})))),update:zo(((t,n,r)=>Sr(e.post(Bn.password.update,{loginId:t,newPassword:n},{token:r})))),replace:Fo(((t,n,r)=>Sr(e.post(Bn.password.replace,{loginId:t,oldPassword:n,newPassword:r})))),policy:()=>Sr(e.get(Bn.password.policy))}),Vo=qr("loginId"),Ko=Fr("loginId"),Ho=qr("origin"),Bo=Wr(Ko,Ho,Fr("name")),Yo=Wr(Ko,Ho),Go=Wr(Vo,Ho),Xo=Wr(Ko,Ho,zr("token")),Zo=Wr(Fr("transactionId"),Fr("response")),Qo=e=>({signUp:{start:Bo(((t,n,r,o,i)=>Sr(e.post(Bn.webauthn.signUp.start,{user:{loginId:t,name:r},origin:n,loginOptions:i,passkeyOptions:o})))),finish:Zo(((t,n)=>Sr(e.post(Bn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Go(((t,n,r,o,i)=>Sr(e.post(Bn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:r,passkeyOptions:i},{token:o})))),finish:Zo(((t,n)=>Sr(e.post(Bn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Yo(((t,n,r,o)=>Sr(e.post(Bn.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r}))))},update:{start:Xo(((t,n,r,o,i)=>Sr(e.post(Bn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:i},{token:r})))),finish:Zo(((t,n)=>Sr(e.post(Bn.webauthn.update.finish,{transactionId:t,response:n}))))}}),ei=qr("loginId"),ti=Wr(ei),ni=Wr(Fr("pendingRef")),ri=e=>({signUpOrIn:ti(((n,r={})=>{var{providerId:o}=r,i=t(r,["providerId"]);return Sr(e.post(Bn.notp.signUpOrIn,{loginId:n,loginOptions:i,providerId:o}))})),signUp:ti(((n,r,o={})=>{var{providerId:i}=o,s=t(o,["providerId"]);return Sr(e.post(Bn.notp.signUp,{loginId:n,user:r,providerId:i,loginOptions:s}))})),signIn:ti(((n,r={},o)=>{var{providerId:i}=r,s=t(r,["providerId"]);return Sr(e.post(Bn.notp.signIn,{loginId:n,loginOptions:s,providerId:i},{token:o}))})),waitForSession:ni(((t,n)=>new Promise((r=>{const{pollingIntervalMs:o,timeoutMs:i}=Yr(n);let s;const a=setInterval((async()=>{const n=await e.post(Bn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),r(Sr(Promise.resolve(n))))}),o);s=setTimeout((()=>{r({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)}))))}),oi=Wr(Fr("token")),ii=Wr(zr("token"));var si,ai=Wr([(si=Fr("projectId"),jr(((e,t)=>n=>Er(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),r=n.length;let o=0,i=e===Object(e)?e:void 0;for(;null!=i&&o<r;)i=i[n[o++]];return o&&o===r&&void 0!==i?i:void 0})(n,e)))("projectId",si))())])((e=>{const{projectId:t,logger:n,baseUrl:r,cookiePolicy:o,baseHeaders:i={},refreshCookieName:s,fetch:a}=e;return c=fr({baseUrl:r,projectId:t,logger:n,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:i},refreshCookieName:s,fetch:a}),{accessKey:Hr(c),otp:_o(c),magicLink:mo(c),enchantedLink:io(c),oauth:bo(c),outbound:So(c),sso:To(c),saml:To(c),totp:Lo(c),notp:ri(c),webauthn:Qo(c),password:Jo(c),flow:lo(c),refresh:ii(((e,t,n,r)=>{const o={};n&&(o.externalToken=n);const i=r?Bn.tryRefresh:Bn.refresh;return Sr(c.post(i,o,{token:e,queryParams:t}))})),selectTenant:Wr([Pr("tenantId")],[Mr('"token" must be string or undefined')])(((e,t)=>Sr(c.post(Bn.selectTenant,{tenant:e},{token:t})))),logout:ii((e=>Sr(c.post(Bn.logout,{},{token:e})))),logoutAll:ii((e=>Sr(c.post(Bn.logoutAll,{},{token:e})))),me:ii((e=>Sr(c.get(Bn.me,{token:e})))),myTenants:Wr([Nr('"tenants" must a string array or a boolean')],[Mr('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Sr(c.post(Bn.myTenants,n,{token:t}))})),history:ii((e=>Sr(c.get(Bn.history,{token:e})))),isJwtExpired:oi(yr),getTenants:oi(wr),getJwtPermissions:oi(br),getJwtRoles:oi(kr),getCurrentTenant:oi(Or),httpClient:c};var c})),ci=Object.assign(ai,{DeliveryMethods:Zr});
6
+ /*! js-cookie v3.0.8 | MIT */function li(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)"__proto__"!==r&&(e[r]=n[r])}return e}var ui=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=li({},n,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 i="";for(var s in o)o[s]&&(i+="; "+s,!0!==o[s]&&(i+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+i}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(a in r||(r[a]=t.read(s,a)),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",li({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,li({},this.attributes,t))},withConverter:function(t){return e(li({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},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 di={default:"endpoint"},hi="Blocked by CSP",pi="The endpoint parameter is not a valid URL",fi="Failed to load the JS script of the agent",gi="9319";function vi(e,t){var n,r,o,i,s,a=[],c=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||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),i=0,r=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},o=new Set,[n.current(),function(e,t){var i,s=t instanceof Error?t.message:"";if(s===hi||s===pi)n.exclude(),i=0;else if(s===gi)n.exclude();else if(s===fi){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!o.has(c)&&(o.add(c),i=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=i?i:e.getTime()+r()-Date.now()]}]),l=c[0],u=c[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var d=function(e){var n=new Date,r=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return r()}),r),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=u(n,e);if(!t)throw s;var r,o=t[0],i=t[1];return(r=i,new Promise((function(e){return setTimeout(e,r)}))).then((function(){return d(o)}))}))};return d(l).then((function(e){return[e,a]}))}var mi="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",yi=mi;function wi(n){var r;n.scriptUrlPattern;var o=n.token,i=n.apiKey,s=void 0===i?o:i,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(r=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==r?r:mi,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,r){return e.addEventListener(t,n,r),function(){return e.removeEventListener(t,n,r)}}(document,"visibilitychange",t);return t(),[e,n]}(),u=l[0],d=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(c,s);return vi(e,bi)})).catch((function(e){throw d(),function(e){return e instanceof Error&&e.message===gi?new Error(fi):e}(e)})).then((function(t){var n=t[0],r=t[1];return d(),n.load(e(e({},a),{ldi:{attempts:r,visibilityStates:u}}))}))}function bi(e){return function(e,t,n){var r,o=document,i="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(r=t,a())};o.addEventListener(i,s);var a=function(){return o.removeEventListener(i,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(),r)return n(r);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){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(pi);var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(fi))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)}),(function(){throw new Error(hi)})).then(ki)}function ki(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(gi);return n}const Ii="3.2.0",Si="undefined"!=typeof window,Oi=Math.pow(2,31)-1,ji=`https://descopecdn.com/npm/oidc-client-ts@${Ii}/dist/browser/oidc-client-ts.min.js`,xi=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Ii}/dist/browser/oidc-client-ts.min.js`,Ei=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let Ci;const _i=e=>{try{return Hn(e).exp}catch(e){return null}},Ai=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:_i(n)},Ri=e=>{const{expires_in:t,expires_at:n,access_token:r}=e;return n||(t?Math.floor(Date.now()/1e3)+t:r?_i(r):void 0)},Ti=e=>{const{access_token:n,id_token:r,refresh_token:o,refresh_expire_in:i}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:r,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||Ri(e),cookieExpiration:e.cookieExpiration||Ai(e)},s)},$i=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,r)=>{var o;return n[r]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[r])||[]).concat((null==t?void 0:t[r])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Pi=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return Ti(n)},Ui=()=>Si&&!!window.descopeBridge,Di=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return Ei.includes(n)},Li=void 0!==Ci||Si&&void 0!==window.localStorage,Mi=(e,t)=>{var n,r;return null===(r=null===(n=Ci||Si&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===r?void 0:r.call(n,e,t)},Ni=e=>{var t,n;return null===(n=null===(t=Ci||Si&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Wi=e=>{var t,n;return null===(n=null===(t=Ci||Si&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},qi=e=>{var t,n,r,o,i;return null!==(i=null!==(n=null===(t=null==Ci?void 0:Ci.key)||void 0===t?void 0:t.call(Ci,e))&&void 0!==n?n:Si&&(null===(o=null===(r=window.localStorage)||void 0===r?void 0:r.key)||void 0===o?void 0:o.call(r,e)))&&void 0!==i?i:null},zi=e=>{var t,n;return Si&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},Fi=e=>{var t,n;try{Si&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},Ji=(...e)=>{console.debug(...e)},Vi=(...e)=>{console.warn(...e)},Ki=(e,t)=>{let n;var r;return t>0?(n=1e3*t,Ji(`Using provided nextRefreshSeconds: ${t}s`)):n=((r=e)?r.getTime()-(new Date).getTime():0)-2e4,n>Oi&&(Ji(`Timeout is too large (${n}ms), setting it to ${Oi}ms`),n=Oi),n},Hi="DS",Bi="DSR",Yi="DSI",Gi="DSRCN";function Xi(e,t,n){if(t){const{cookieDomain:r,cookiePath:o,cookieSameSite:i,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=Zi(r);ui.set(e,t,{path:o,domain:l?r:void 0,expires:c,sameSite:i,secure:a})}}function Zi(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const Qi=e=>(null==e?void 0:e.cookieName)||Hi,es=e=>(null==e?void 0:e.cookieName)||Bi;function ts(e="",t){return ui.get(es(t))||Ni(`${e}${Bi}`)||""}function ns(e="",t){return ui.get(Qi(t))||Ni(`${e}${Hi}`)||""}function rs(e=""){return Ni(`${e}${Yi}`)||""}function os(e="",t,n,r){Wi(`${e}${Bi}`),Wi(`${e}${Hi}`),Wi(`${e}${Yi}`),Wi(`${e}${Gi}`);const o=Qi(t);ui.remove(o,null==r?void 0:r.session);const i=es(n);ui.remove(i,null==r?void 0:r.refresh)}const is=(e,t,n)=>r=>{const o=Object.assign(r,{token:r.token||ts(e,t)});if(!n){const t=function(e=""){return Ni(`${e}${Gi}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const i=function(e=""){return Ni(`${e}DTD`)||""}(e);i&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":i}));const s=function(e=""){return Ni(`${e}DKD`)||""}(e);return s&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-known-device-token":s})),o},ss=Si&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",as="vsid",cs="vrid",ls=(e=!1)=>{const t=Ni("fp");if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},us=async(e,t=ss)=>{try{if(ls())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),r=new URL(t);r.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const i=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=wi({apiKey:e,endpoint:[r.toString(),di],scriptUrlPattern:[i,yi]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[as]:e,[cs]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Mi("fp",JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},ds=e=>{const t=ls(!0);return t&&e.body&&(e.body.fpData=t),e},hs="descopeFlowNonce",ps="X-Descope-Flow-Nonce",fs="/v1/flow/start",gs="/v1/flow/next",vs=(e,t=hs)=>`${t}${e}`,ms=(e,t=hs)=>{try{const n=vs(e,t),r=Ni(n);if(!r)return null;const o=JSON.parse(r);return o.expiry<Date.now()?(ys(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},ys=(e,t=hs)=>{try{const n=vs(e,t);Wi(n)}catch(e){console.error("Error removing flow nonce:",e)}},ws=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},bs=e=>{var t;return e.path===gs&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?ws(e.body.executionId):null},ks="dls_last_user_login_id",Is="dls_last_user_display_name",Ss=e=>Mi(ks,e),Os=()=>Ni(ks),js=()=>Ni(Is),xs=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,r={}]=t,o=Os(),i=js();return o&&(null!==(n=r.lastAuth)&&void 0!==n||(r.lastAuth={}),r.lastAuth.loginId=o,r.lastAuth.name=i),await e(...t)},Es="DSLI",Cs=e=>async(...t)=>{const n=await e(...t);return Fi(Es),n};function _s(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function As(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Ls(n.publicKey.challenge),n.publicKey.user.id=Ls(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Ls(e.id)})),n}(e);try{return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Ms(n.rawId),type:n.type,response:{attestationObject:Ms(n.response.attestationObject),clientDataJSON:Ms(n.response.clientDataJSON)}})}catch(e){throw await $s(e,t,!0)}var n}async function Rs(e){const t=Us(e);try{return Ds(await navigator.credentials.get(t))}catch(e){throw await $s(e,t,!1)}}async function Ts(e,t){const n=Us(e);n.signal=t.signal,n.mediation="conditional";try{return Ds(await navigator.credentials.get(n))}catch(e){throw await $s(e,n,!1)}}async function $s(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var r,o;const i=null==e?void 0:e.name;if("AbortError"===i&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===i&&n)return"authenticator_already_registered";if("NotSupportedError"===i)return"no_supported_algorithm";if("ConstraintError"===i)return"authenticator_constraints_unsupported";if("SecurityError"===i){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await Ps())return"webauthn_unsupported";const s="platform"===(null===(o=null===(r=null==t?void 0:t.publicKey)||void 0===r?void 0:r.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await Ps(!0)?"platform_authenticator_unsupported":"NotAllowedError"===i?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function Ps(e=!1){var t,n;if(!Si)return Promise.resolve(!1);if(Ui()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const r=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return r&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():r}function Us(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Ls(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Ls(e.id)})),n}function Ds(e){return JSON.stringify({id:e.id,rawId:Ms(e.rawId),type:e.type,response:{authenticatorData:Ms(e.response.authenticatorData),clientDataJSON:Ms(e.response.clientDataJSON),signature:Ms(e.response.signature),userHandle:e.response.userHandle?Ms(e.response.userHandle):void 0}})}function Ls(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ms(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ns,Ws=(Ns=e=>({async signUp(t,n,r){const o=await e.webauthn.signUp.start(t,window.location.origin,n,r);if(!o.ok)return o;const i=await As(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(t,n){const r=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!r.ok)return r;const o=await Rs(r.data.options);return await e.webauthn.signIn.finish(r.data.transactionId,o)},async signUpOrIn(t,n){var r;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(r=o.data)||void 0===r?void 0:r.create){const t=await As(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Rs(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,r){const o=await e.webauthn.update.start(t,window.location.origin,n,r);if(!o.ok)return o;const i=await As(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:As,get:Rs,isSupported:Ps,conditional:Ts}}),(...e)=>{const t=Ns(...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 qs="/fedcm/config";async function zs(e,t){var n;try{await Fs(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Fs(e,t){var n,r;const o=await async function(e,t="google",n,r,o){const i=(()=>{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)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const c=a.data.clientId;return new Promise((e=>{var a,l;const u=n=>{e({provider:t,nonce:i,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,callback:u,nonce:i})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void u()}if(r&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==r||r(t),void u()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const r=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!r.ok||!r.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,r.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(r=null==t?void 0:t.onAuthenticated)||void 0===r||r.call(t,n.data)}}var Js=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Ps(),r=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=r,e.flow.start(...t)}});let Vs;const Ks=(e,t)=>new Promise(((n,r)=>{if(!e.length)return r(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const i=e.shift(),s=document.createElement("script");s.src=i,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(i),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Ks(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Hs=(e,t,n)=>{const r=async()=>{let r,o;return r&&o||({client:r,stateUserKey:o}=await(async(e,t,n)=>{Vs||(Vs=(async()=>{try{return require("oidc-client-ts")}catch(e){return Ks([ji,xi],(()=>window.oidc))}})());const{OidcClient:r,WebStorageStateStore:o}=await Vs;if(!r)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const i=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,c,l;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,c=`${a}_user`,l="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,c=`${a}_user`,l="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,c=`${a}_user`,l="openid email roles descope.custom_claims offline_access");const u={authority:s,client_id:a,redirect_uri:i,response_type:"code",scope:(null==n?void 0:n.scope)||l,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(u.redirect_uri=n.redirectUri),{client:new r(u),stateUserKey:c}})(e,t,n)),{client:r,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:i}=await r(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),Mi(i,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={},n=!1)=>{var o;const{client:i}=await r(),s=await i.createSigninRequest(t),{url:a}=s;return n||(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 n;const{client:o,stateUserKey:i}=await r(),s=(e=>{const t=Ni(e);return t?JSON.parse(t):null})(i);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 c=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await r();e||(e={}),e.id_token_hint=e.id_token_hint||rs(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const i=await n.createSignoutRequest(e),{url:s}=i;return Wi(o),t||window.location.replace(s),i}}},Bs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Ci=n,e(t)}),(e=>n=>{var{fpKey:r,fpLoad:o}=n,i=t(n,["fpKey","fpLoad"]);return Si?(r&&o&&us(r).catch((()=>null)),e($i(i,{beforeRequest:ds}))):e(i)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.53.1"},t.baseHeaders)}))),(e=>t=>{const n=_s(),r=_s(),o=_s(),i=_s(),s=e($i(t,{afterRequest:async(e,t)=>{if(Di(e,t))Ji("Session invalidated, notifying subscribers with empty values"),r.pub(null),o.pub(null),n.pub(null),i.pub(null);else{const e=await(async e=>{const t=await Pi(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:c}=await Pi(t);s&&r.pub(s),c&&i.pub(c),(a||s)&&n.pub(a||42)}}})),a=Br(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return r.pub(null),o.pub(null),n.pub(null),i.pub(null),s}));return Object.assign(a,{onSessionTokenChange:r.sub,onUserChange:o.sub,onClaimsChange:i.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var r;const{enableFlowNonce:o=!0,nonceStoragePrefix:i=hs}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(s);((e=hs)=>{try{if(!Li)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(r=null!==(t=null==Ci?void 0:Ci.length)&&void 0!==t?t:Si&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==r?r:0);o++){const t=qi(o);if(t&&t.startsWith(e)){const n=Ni(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Wi(t)}catch(e){Wi(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,r})(i);const a=e($i(s,{afterRequest:async(e,t)=>{var n;if(e.path!==fs&&e.path!==gs)return;const{nonce:r,seq:o,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(ps),r=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const r=Number(n);return Number.isSafeInteger(r)?r:void 0})(n);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=bs(e)),{nonce:n,seq:r,executionId:ws(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!r||!s)return;const a=e.path===fs,c=null===(n=ms(s,i))||void 0===n?void 0:n.seq;!a&&void 0!==o&&void 0!==c&&o<=c||((e,t,n,r=hs,o)=>{try{const i=vs(e,r),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:o};Mi(i,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,r,a,i,null!=o?o:a?void 0:c)},beforeRequest:e=>{if(e.path===gs){const t=bs(e);if(t){const n=((e,t=hs)=>{var n,r;return null!==(r=null===(n=ms(e,t))||void 0===n?void 0:n.value)&&void 0!==r?r:null})(t,i);n&&(e.headers=e.headers||{},e.headers[ps]=n)}}return e}}));if(null===(r=a.flow)||void 0===r?void 0:r.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const r=e;let o;e=new Promise((e=>{o=e})),await r;try{return await t(...n)}finally{o()}}}return a}),(e=>t=>{const n=e($i(t,{afterRequest:async(e,t)=>{if(Di(e,t))return void Fi(Es);const n=await Pi(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,r;try{Si&&(null===(r=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===r||r.call(n,e,t))}catch(e){}})(Es,String(n.sessionExpiration))}}));return Br(n,["logout","logoutAll","oidc.logout"],Cs)}),(e=>n=>{var{autoRefresh:r}=n,o=t(n,["autoRefresh"]);const i=!!r,s="object"==typeof r&&(null==r?void 0:r.customActivityTracking);if(!i||Ui())return Object.assign(e(o),{markUserActive:()=>{Vi("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:c}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,u,d=null,h=!1,p=!1;s&&(Ji("Activity-based refresh enabled"),d=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Si&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(Ji("Expiration time passed, refreshing session"),f.refresh(ts()||u))}));const f=e($i(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:r,sessionExpiration:o,nextRefreshSeconds:i}=await Pi(t);if(Di(e,t))Ji("Session invalidated, canceling all timers"),a();else if(n||o){if(l=((e,t)=>{if(t)return new Date(1e3*t);Ji("Could not extract expiration time from session token, trying to decode the token");try{const t=Hn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!l)return void Ji("Could not extract expiration time from session token");u=r,h=i>0;const e=Ki(l,i);if(a(),e<=2e4)return void Ji("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Ji(`Setting refresh timer for ${t}. (${e}ms)`),d&&(d.reset(),p=!1),c((()=>{if(Si&&"hidden"===document.visibilityState)Ji("Skipping refresh due to timer - document is hidden");else{if(d&&h&&!d.hadActivity())return Ji("Skipping refresh due to timer - user is idle"),void(p=!0);Ji("Refreshing session due to timer"),f.refresh(ts()||r)}}),e)}}}));return Object.assign(Br(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Ji("Clearing all timers"),a(),n})),{markUserActive:d?()=>{Ji("markUserActive() called"),h||Ji("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),d.markActive(),p&&(Ji("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(ts()||u))}:()=>{Vi("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:r=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,i=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!r)return Object.assign(e(i),{getLastUserLoginId:Os,getLastUserDisplayName:js});const s=e($i(i,{afterRequest:async(e,t)=>{var n;const{userInfo:r,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()),n=Ti((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),i=null===(n=null==r?void 0:r.loginIds)||void 0===n?void 0:n[0],s=null==r?void 0:r.name;i?(Ss(i),(e=>{Mi(Is,e)})(s)):(null==o?void 0:o.loginId)&&Ss(o.loginId)}}));let a=Br(s,["flow.start"],xs);return a=Br(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const r=await t(...n);return e||(Wi(ks),Wi(Is)),r})(o)),Object.assign(a,{getLastUserLoginId:Os,getLastUserDisplayName:js})}),(e=>n=>{var{persistTokens:r,sessionTokenViaCookie:o,refreshTokenViaCookie:i,storagePrefix:s,refreshCookieName:a}=n,c=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!r||!Si)return e(Object.assign({refreshCookieName:a},c));let l;const u=e($i(Object.assign({refreshCookieName:a},c),{beforeRequest:is(s,i,a),afterRequest:async(e,t)=>{if(Di(e,t))Ji("Session invalidated, clearing persisted tokens"),os(s,o,i,l);else{const e=await Pi(t);e.cookieName?Mi(`${s||""}${Gi}`,e.cookieName):e.refreshJwt&&Wi(`${s||""}${Gi}`);const n=((e={},t=!1,n="",r=!1)=>{var o,i,s,a;const{sessionJwt:c,refreshJwt:l,trustedDeviceJwt:u,knownDeviceJwt:d}=e;let h;if(l)if(r){Wi(`${n}${Bi}`);const t=r.sameSite||"Strict",s=null===(o=r.secure)||void 0===o||o,a=null!==(i=r.domain)&&void 0!==i?i:e.cookieDomain,c=es(r);s&&"https:"!==window.location.protocol&&Vi("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 u=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Xi(c,l,u);const d=Zi(a);h=Object.assign(Object.assign({},h),{refresh:{path:u.cookiePath,domain:d?a:void 0}})}else{const e=es(r);ui.remove(e),Mi(`${n}${Bi}`,l)}if(c)if(t){const n=t.sameSite||"Strict",r=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,i=Qi(t);r&&"https:"!==window.location.protocol&&Vi("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:n,cookieSecure:r,cookieDomain:o});Xi(i,c,l);const u=Zi(o);h=Object.assign(Object.assign({},h),{session:{path:l.cookiePath,domain:u?o:void 0}})}else Mi(`${n}${Hi}`,c);return e.idToken&&Mi(`${n}${Yi}`,e.idToken),u&&Mi(`${n}DTD`,u),d&&Mi(`${n}DKD`,d),h})(e,o,s,i);n&&(l=n)}}})),d=Br(u,["logout","logoutAll","oidc.logout"],((e,t,n,r)=>o=>async(...i)=>{const s=await o(...i);return os(e,t,n,null==r?void 0:r()),s})(s,o,i,(()=>l)));return Object.assign(d,{getRefreshToken:()=>ts(s,i),getSessionToken:()=>ns(s,o),getIdToken:()=>rs(s)})}))((e=>{const t=ci(e),n=Hs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(r,o)=>{var i;if(Ui())return Ji(`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 n.refreshToken(r),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&Si&&void 0!==window.localStorage&&!zi(Es)&&!Ni(ks)&&!zi("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=ns(),a=ts();let c="";if(e.getExternalToken)try{c=await(null===(i=e.getExternalToken)||void 0===i?void 0:i.call(e))}catch(e){Ji("Error getting external token while refreshing",e)}return t.refresh(r,{dcs:s?"t":"f",dcr:a?"t":"f"},c,o)},logout:async r=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:r}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(r)},flow:Js(t),webauthn:Ws(t),fedcm:(r=t,o=e.projectId,{onetap:{requestExchangeCode(e){zs(r,e)},requestAuthentication(e){zs(r,e)}},async oneTap(e,t,n,o,i){await Fs(r,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:i})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:r.httpClient.buildUrl(o+qs),clientId:o}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return r.refresh(i.token)},isSupported:()=>Si&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=r.httpClient.buildUrl(o+qs);try{const r={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(r));return!!i&&!!i.token}catch(e){return!1}}}),oidc:n});var r,o})),Ys={search:"/v1/mgmt/audit/search"},Gs=e=>n(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((n=>{const r=[],o=(new Date).getTime()/1e3+2592e3,i=new Date(o).toLocaleString();for(let e=1;e<9;e+=1)r.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:i});t.forEach((e=>{r.sort(((t,n)=>{var r,o;return e.desc?null===(o=n[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(r=t[e.field])||void 0===r?void 0:r.localeCompare(n[e.field])}))})),n(r.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()))))}))})),Xs=({httpClient:e,tenant:t,mock:r})=>({search:(...o)=>n(void 0,[...o],void 0,(function*({page:o,limit:i=1e4,text:s,sort:a,from:c}={}){if(r)return Gs({page:o,limit:i,text:s,sort:a},t);const l=yield e.post(Ys.search,{limit:i,page:o,text:s,sort:a,from:c},{queryParams:{tenant:t}});yield(e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(l);return(yield l.json()).audits}))}),Zs=u((e=>{var t,s,a,c;const l=i(A,C,k,R,Cn,_({tenant:_.missingAttrValidator}))(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.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 r(this,s,"f")||r(this,t,"m",a).call(this),r(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{r(this,s,"f")&&r(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,n,r)=>{const o=Bs(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"audit-management-widget","x-descope-widget-id":r,"x-descope-widget-version":"0.9.4"}}));return{audit:Xs({httpClient:o.httpClient,tenant:t,mock:n}),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},c})),Qs=u((e=>{const t=i(Sn({name:"widget",initialState:Jn,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{Fn.reducer(e)},asyncActions:{searchAudit:Fn.action}}),E,k,Zs)(e);return class extends t{constructor(...e){super(...e),this.state=Jn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),ea=u((e=>{var t,o,a;return a=class extends(i(k,E,V,X,En("audit-management-widget"),Qs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([r(this,t,"m",o).call(this)]),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),ta=u((e=>{var t,o,s,a,l;return l=class extends(i(k,ea,Qs)(e)){constructor(){super(...arguments),t.add(this),o.set(this,c((()=>{const e=this.rangeInput.value,t=new Date;let n;switch(e){case"minuets15":n=t.setMinutes(t.getMinutes()-15);break;case"hour":n=t.setHours(t.getHours()-1);break;case"hour6":n=t.setHours(t.getHours()-6);break;case"day":default:n=t.setDate(t.getDate()-1);break;case"day3":n=t.setDate(t.getDate()-3);break;case"week":n=t.setDate(t.getDate()-7);break;case"week2":n=t.setDate(t.getDate()-14);break;case"month":n=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(n).getTime())})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),r(this,t,"m",s).call(this),r(this,t,"m",a).call(this)}))}},o=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new pe(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(r(this,o,"f")),r(this,o,"f").call(this)},a=function(){var e;this.rangeInput=new he(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(r(this,o,"f"))},l})),na=u((e=>{var t,o,s,c;return c=class extends(i(Qs,k,ea)(e)){constructor(){super(...arguments),t.add(this),s.set(this,(e=>{let t,n;return(...r)=>(t&&a(t,r)||(t=r,n=e(...r)),n)})((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),r(this,t,"m",o).call(this),r(this,s,"f").call(this,Nn(this.state)),this.subscribe(r(this,s,"f").bind(this),Nn)}))}},s=new WeakMap,t=new WeakSet,o=function(){var e;this.auditTable=new ie(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)))}))},c})),ra=[{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"}],oa=u((e=>{var t,o,s;return s=class extends(i(k,ea,Qs)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),r(this,t,"m",o).call(this)}))}},t=new WeakSet,o=function(){var e;this.exportButton=new ne(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="export-button"]'),{logger:this.logger}),this.exportButton.onClick((()=>{const e=Nn(this.state);if(!e.length)return void this.logger.warn("No audit data to export");const t=((e,t)=>[t.map((e=>y(e.header))).join(","),...e.map((e=>t.map((t=>y(e[t.path]))).join(",")))].join("\n"))(e,ra);((e,t)=>{const n=new Blob(["\ufeff"+e],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.setAttribute("download",t),document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)})(t,`audit_logs_${(new Date).toISOString().slice(0,10)}.csv`)}))},s})),ia=u((e=>class extends(i(L,ke,na,ta,oa,Un)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),sa=i((e=>class extends(ia(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",sa);const aa=(e,t,n,r={})=>{var o,i,s,a;return[Math.min(Math.max(t,("all"===r.left?e.offsetWidth:null!==(o=r.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===r.right?e.offsetWidth:null!==(i=r.right)&&void 0!==i?i:0)),Math.min(Math.max(n,("all"===r.top?e.offsetHeight:null!==(s=r.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===r.bottom?e.offsetHeight:null!==(a=r.bottom)&&void 0!==a?a:0))]};var ca,la,ua,da,ha,pa,fa,ga,va,ma;const ya=document.createElement("template");ya.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 wa=i(B)(HTMLElement);class ba extends wa{constructor(){var e;super(),ca.add(this),la.set(this,new v({messages:[]})),ua.set(this,void 0),da.set(this,void 0),ha.set(this,void 0),pa.set(this,{resize:r(this,ca,"m",ma).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(ya.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'),o(this,ua,this.shadowRoot.querySelector(".debugger"),"f"),r(this,ua,"f").style.top="32px",r(this,ua,"f").style.left=window.innerWidth-300-32+"px",o(this,da,r(this,ua,"f").querySelector(".content"),"f"),o(this,ha,r(this,ua,"f").querySelector(".header"),"f")}updateData(e){r(this,la,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let r=0,o=0,i=0,s=0;function a(t){t.preventDefault(),r=i-t.clientX,o=s-t.clientY,i=t.clientX,s=t.clientY;const[a,c]=aa(e,e.offsetLeft-r,e.offsetTop-o,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),i=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(r(this,ua,"f"),r(this,ha,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",r(this,pa,"f").resize),(e=r(this,ua,"f")).onmousemove=t=>{var n;const r=t.target;(r.w&&r.w!==r.offsetWidth||r.h&&r.h!==r.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),r.w=r.offsetWidth,r.h=r.offsetHeight},r(this,ua,"f").onresize=r(this,ca,"m",va).bind(this),r(this,la,"f").subscribe(r(this,ca,"m",fa).bind(this))}disconnectedCallback(){r(this,la,"f").unsubscribeAll(),window.removeEventListener("resize",r(this,pa,"f").resize)}}la=new WeakMap,ua=new WeakMap,da=new WeakMap,ha=new WeakMap,pa=new WeakMap,ca=new WeakSet,fa=function(e){r(this,ca,"m",ga).call(this,e),r(this,ca,"m",va).call(this)},ga=function(e){r(this,da,"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("")},va=function(){r(this,da,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),r=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;r||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)}))},ma=function(){const[e,t]=aa(r(this,ua,"f"),Number.parseInt(r(this,ua,"f").style.left,10),Number.parseInt(r(this,ua,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});r(this,ua,"f").style.top=`${t}px`,r(this,ua,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ba);var ka=Object.freeze({__proto__:null,default:ba});return sa}();
7
7
  //# sourceMappingURL=index.js.map