@frontegg/js 7.76.0-alpha.1 → 7.76.0

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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see frontegg.production.min.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Frontegg=e():t.Frontegg=e()}(window,(()=>(()=>{var t={3952:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createConditionEvaluator=void 0;const n=a(2904),s=a(9475);e.createConditionEvaluator=function(t){const e=(0,s.useSanitizer)(t.condition.op);if(!e)return()=>!1;const{isSanitized:a,sanitizedValue:i}=e(t.condition.value);if(!a||void 0===i)return()=>!1;const o=(0,n.useOperation)(t.condition.op,i);return e=>{const a=e[t.condition.attribute];if(void 0===a||!o)return!1;const{isValid:n}=o(a);return t.condition.negate?!n:n}}},9838:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(3952),e),s(a(963),e)},963:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3998:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateFeatureFlag=void 0;const n=a(9243);e.evaluateFeatureFlag=function(t,e){if(!t.on)return{treatment:t.offTreatment};const a=function(t,e){var a;return null===(a=t.rules)||void 0===a?void 0:a.find((t=>(0,n.createRuleEvaluator)({rule:t})(e)===n.RuleEvaluationResultEnum.Treatable))}(t,e);return a?{treatment:a.treatment}:{treatment:t.defaultTreatment}}},2152:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(3998),e)},5875:(t,e,a)=>{"use strict";e.Me=e.a_=void 0;a(2152),a(3856),a(9243),a(2752);var n=a(7254);Object.defineProperty(e,"a_",{enumerable:!0,get:function(){return n.evaluateIsEntitledToFeature}}),Object.defineProperty(e,"Me",{enumerable:!0,get:function(){return n.evaluateIsEntitledToPermissions}})},6849:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.BooleanOperationsMapper=void 0;const i=a(2752),o=a(6715);s(a(6715),e),s(a(4965),e),e.BooleanOperationsMapper={[i.OperationEnum.Is]:t=>(0,o.useIsOperation)(t)}},6715:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useIsOperation=void 0,e.useIsOperation=function(t){return e=>({isValid:e===t.boolean})}},4965:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BooleanSanitizersMapper=e.singleBooleanSanitizer=void 0;const n=a(2752);e.singleBooleanSanitizer=t=>{const e=void 0!==t.boolean&&(t=>"boolean"==typeof t)(t.boolean)?{boolean:t.boolean}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.BooleanSanitizersMapper={[n.OperationEnum.Is]:e.singleBooleanSanitizer}},2904:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useOperation=void 0;const n=a(5018),s=a(3922),i=a(3147),o=a(6849),r={...n.StringOperationsMapper,...s.NumericOperationsMapper,...i.DateOperationsMapper,...o.BooleanOperationsMapper};e.useOperation=function(t,e){const a=r[t];return a?a(e):void 0}},9475:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useSanitizer=void 0;const n=a(6849),s=a(1016),i=a(6891),o=a(3922),r={...s.StringSanitizersMapper,...o.NumericSanitizersMapper,...i.DateSanitizersMapper,...n.BooleanSanitizersMapper};e.useSanitizer=function(t){return r[t]}},3147:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.DateOperationsMapper=void 0;const i=a(2752),o=a(1641);s(a(1641),e),s(a(1626),e),e.DateOperationsMapper={[i.OperationEnum.On]:t=>(0,o.useDateOnOperation)(t),[i.OperationEnum.OnOrAfter]:t=>(0,o.useDateOnOrAfterOperation)(t),[i.OperationEnum.OnOrBefore]:t=>(0,o.useDateOnOrBeforeOperation)(t),[i.OperationEnum.BetweenDate]:t=>(0,o.useDateBetweenOperation)(t)}},1641:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useDateBetweenOperation=e.useDateOnOrBeforeOperation=e.useDateOnOrAfterOperation=e.useDateOnOperation=void 0,e.useDateOnOperation=function(t){return e=>({isValid:e.getTime()===t.date.getTime()})},e.useDateOnOrAfterOperation=function(t){return e=>({isValid:e.getTime()>=t.date.getTime()})},e.useDateOnOrBeforeOperation=function(t){return e=>({isValid:e.getTime()<=t.date.getTime()})},e.useDateBetweenOperation=function(t){return e=>({isValid:e.getTime()>=t.start.getTime()&&e.getTime()<=t.end.getTime()})}},6891:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DateSanitizersMapper=e.sanitizeDateRange=e.sanitizeSingleDate=e.isValidDate=e.sanitizeDateValue=void 0;const n=a(2752);e.sanitizeDateValue=t=>new Date(t),e.isValidDate=t=>t instanceof Date&&!isNaN(t),e.sanitizeSingleDate=t=>{const a=t.date?(0,e.sanitizeDateValue)(t.date):void 0,n=a&&(0,e.isValidDate)(a)?{date:a}:void 0;return{isSanitized:!!n,sanitizedValue:n}},e.sanitizeDateRange=t=>{const a=t.start?(0,e.sanitizeDateValue)(t.start):void 0,n=t.end?(0,e.sanitizeDateValue)(t.end):void 0,s=a&&n&&(0,e.isValidDate)(a)&&(0,e.isValidDate)(n)?{start:a,end:n}:void 0;return{isSanitized:!!s,sanitizedValue:s}},e.DateSanitizersMapper={[n.OperationEnum.On]:e.sanitizeSingleDate,[n.OperationEnum.OnOrAfter]:e.sanitizeSingleDate,[n.OperationEnum.OnOrBefore]:e.sanitizeSingleDate,[n.OperationEnum.BetweenDate]:e.sanitizeDateRange}},1626:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3922:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.NumericOperationsMapper=void 0;const i=a(2752),o=a(9194);e.NumericOperationsMapper={[i.OperationEnum.Equal]:t=>(0,o.useEqualsOperation)(t),[i.OperationEnum.GreaterThan]:t=>(0,o.useGreaterThanOperation)(t),[i.OperationEnum.GreaterThanEqual]:t=>(0,o.useGreaterThanEqualOperation)(t),[i.OperationEnum.LesserThan]:t=>(0,o.useLesserThanOperation)(t),[i.OperationEnum.LesserThanEqual]:t=>(0,o.useLesserThanEqualOperation)(t),[i.OperationEnum.BetweenNumeric]:t=>(0,o.useBetweenNumericOperation)(t)},s(a(9194),e),s(a(5168),e),s(a(7695),e)},9194:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useBetweenNumericOperation=e.useLesserThanEqualOperation=e.useLesserThanOperation=e.useGreaterThanEqualOperation=e.useGreaterThanOperation=e.useEqualsOperation=void 0,e.useEqualsOperation=function(t){return e=>({isValid:e===t.number})},e.useGreaterThanOperation=function(t){return e=>({isValid:e>t.number})},e.useGreaterThanEqualOperation=function(t){return e=>({isValid:e>=t.number})},e.useLesserThanOperation=function(t){return e=>({isValid:e<t.number})},e.useLesserThanEqualOperation=function(t){return e=>({isValid:e<=t.number})},e.useBetweenNumericOperation=function(t){return e=>({isValid:e>=t.start&&e<=t.end})}},5168:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NumericSanitizersMapper=e.sanitizeNumericRange=e.sanitizeSingleNumber=void 0;const n=a(2752),s=t=>"number"==typeof t;e.sanitizeSingleNumber=t=>{const e=void 0!==t.number&&s(t.number)?{number:t.number}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.sanitizeNumericRange=t=>{const e=void 0!==t.start&&void 0!==t.end&&s(t.start)&&s(t.end)?{start:t.start,end:t.end}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.NumericSanitizersMapper={[n.OperationEnum.Equal]:e.sanitizeSingleNumber,[n.OperationEnum.GreaterThan]:e.sanitizeSingleNumber,[n.OperationEnum.GreaterThanEqual]:e.sanitizeSingleNumber,[n.OperationEnum.LesserThan]:e.sanitizeSingleNumber,[n.OperationEnum.LesserThanEqual]:e.sanitizeSingleNumber,[n.OperationEnum.BetweenNumeric]:e.sanitizeNumericRange}},7695:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},5018:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.StringOperationsMapper=void 0;const i=a(2752),o=a(5154);s(a(5154),e),s(a(4503),e),e.StringOperationsMapper={[i.OperationEnum.StartsWith]:t=>(0,o.useStartsWithOperation)(t),[i.OperationEnum.EndsWith]:t=>(0,o.useEndsWithOperation)(t),[i.OperationEnum.Contains]:t=>(0,o.useContainsOperation)(t),[i.OperationEnum.InList]:t=>(0,o.useInListOperation)(t),[i.OperationEnum.Matches]:t=>(0,o.useMatchesOperation)(t)}},5154:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useMatchesOperation=e.useInListOperation=e.useContainsOperation=e.useEndsWithOperation=e.useStartsWithOperation=void 0,e.useStartsWithOperation=function(t){return e=>({isValid:t.list.some((t=>e.startsWith(t)))})},e.useEndsWithOperation=function(t){return e=>({isValid:t.list.some((t=>e.endsWith(t)))})},e.useContainsOperation=function(t){return e=>({isValid:t.list.some((t=>e.includes(t)))})},e.useInListOperation=function(t){return e=>({isValid:t.list.includes(e)})},e.useMatchesOperation=function(t){return e=>{let a;try{a=new RegExp(t.string)}catch(t){return{isValid:!1}}return{isValid:a.test(e)}}}},1016:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StringSanitizersMapper=e.sanitizeListString=e.sanitizeSingleString=void 0;const n=a(2752),s=t=>"string"==typeof t;e.sanitizeSingleString=t=>{const e=void 0!==t.string&&s(t.string)?{string:t.string}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.sanitizeListString=t=>{const e=void 0!==t.list&&t.list.every((t=>s(t)))?{list:t.list}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.StringSanitizersMapper={[n.OperationEnum.Matches]:e.sanitizeSingleString,[n.OperationEnum.Contains]:e.sanitizeListString,[n.OperationEnum.StartsWith]:e.sanitizeListString,[n.OperationEnum.EndsWith]:e.sanitizeListString,[n.OperationEnum.InList]:e.sanitizeListString}},4503:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},2752:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7158),e)},7158:(t,e)=>{"use strict";var a;Object.defineProperty(e,"__esModule",{value:!0}),e.OperationEnum=void 0,(a=e.OperationEnum||(e.OperationEnum={})).InList="in_list",a.StartsWith="starts_with",a.EndsWith="ends_with",a.Contains="contains",a.Matches="matches",a.Equal="equal",a.GreaterThan="greater_than",a.GreaterThanEqual="greater_than_equal",a.LesserThan="lower_than",a.LesserThanEqual="lower_than_equal",a.BetweenNumeric="between_numeric",a.Is="is",a.On="on",a.BetweenDate="between_date",a.OnOrAfter="on_or_after",a.OnOrBefore="on_or_before"},3856:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(6334),e)},6334:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluatePlan=void 0;const n=a(9243);e.evaluatePlan=function(t,e){const a=function(t,e){var a;return null===(a=t.rules)||void 0===a?void 0:a.find((t=>(0,n.createRuleEvaluator)({rule:t})(e)===n.RuleEvaluationResultEnum.Treatable))}(t,e);return a?{treatment:a.treatment}:{treatment:t.defaultTreatment}}},9243:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(5546),e),s(a(4874),e)},4874:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createRuleEvaluator=void 0;const n=a(5546),s=a(9838);e.createRuleEvaluator=function(t){return e=>t.rule.conditions.every((t=>(0,s.createConditionEvaluator)({condition:t})(e)))?n.RuleEvaluationResultEnum.Treatable:n.RuleEvaluationResultEnum.Insufficient}},5546:(t,e)=>{"use strict";var a,n;Object.defineProperty(e,"__esModule",{value:!0}),e.RuleEvaluationResultEnum=e.TreatmentEnum=e.ConditionLogicEnum=void 0,(e.ConditionLogicEnum||(e.ConditionLogicEnum={})).And="and",(n=e.TreatmentEnum||(e.TreatmentEnum={})).True="true",n.False="false",(a=e.RuleEvaluationResultEnum||(e.RuleEvaluationResultEnum={})).Treatable="treatable",a.Insufficient="insufficient"},7254:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7416),e),s(a(3817),e),s(a(395),e),s(a(6816),e)},1711:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.directEntitlementEvalutor=void 0;const n=a(395);e.directEntitlementEvalutor=function(t,e,a={}){const s=e.features[t];let i=!1;return s&&null!==s.expireTime&&(i=s.expireTime!==n.NO_EXPIRATION_TIME&&s.expireTime<Date.now(),!i)?{isEntitled:!0}:{isEntitled:!1,justification:i?n.NotEntitledJustification.BUNDLE_EXPIRED:n.NotEntitledJustification.MISSING_FEATURE}}},1343:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.featureFlagEvaluator=void 0;const n=a(395),s=a(2152),i=a(8552),o=a(9243);e.featureFlagEvaluator=function(t,e,a={}){const r=e.features[t];if(r&&r.featureFlag){const t=(0,i.prepareAttributes)(a),{treatment:e}=(0,s.evaluateFeatureFlag)(r.featureFlag,t);if(e===o.TreatmentEnum.True)return{isEntitled:!0}}return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE}}},2031:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getIsEntitledEvaluators=void 0;const n=a(1711),s=a(1343),i=a(3155);e.getIsEntitledEvaluators=function(){return[n.directEntitlementEvalutor,s.featureFlagEvaluator,i.planTargetingRulesEvalutor]}},3155:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.planTargetingRulesEvalutor=void 0;const n=a(395),s=a(8552),i=a(9243),o=a(3856);e.planTargetingRulesEvalutor=function(t,e,a={}){const r=e.features[t];if(r&&r.planIds&&r.planIds.length>0){const t=(0,s.prepareAttributes)(a),n=e.plans;for(const e of r.planIds){const a=n[e];if(a){const{treatment:e}=(0,o.evaluatePlan)(a,t);if(e===i.TreatmentEnum.True)return{isEntitled:!0}}}}return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE}}},7416:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(9398),e)},9398:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateIsEntitledToFeature=void 0;const n=a(395),s=a(6816),i=a(2031);e.evaluateIsEntitledToFeature=function(t,e,a={}){if(!e)return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE};const o=[];for(const n of(0,i.getIsEntitledEvaluators)())if(o.push(n(t,e,a)),!(0,s.shouldContinue)(o))break;return(0,s.getResult)(o)}},3817:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(1474),e)},1474:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateIsEntitledToPermissions=void 0;const n=a(9398),s=a(395),i=a(6816),o=a(7943);e.evaluateIsEntitledToPermissions=function(t,e,a){if(!e)return{isEntitled:!1,justification:s.NotEntitledJustification.MISSING_PERMISSION};if(!(0,o.checkPermission)(e.permissions,t))return{isEntitled:!1,justification:s.NotEntitledJustification.MISSING_PERMISSION};const r=function(t,e){return Object.keys(e.features).filter((a=>e.features[a].linkedPermissions.includes(t)))}(t,e);if(!r.length)return{isEntitled:!0};const l=[];for(const t of r)if(l.push((0,n.evaluateIsEntitledToFeature)(t,e,a)),!(0,i.shouldContinue)(l))break;return(0,i.getResult)(l)}},395:(t,e)=>{"use strict";var a;Object.defineProperty(e,"__esModule",{value:!0}),e.NO_EXPIRATION_TIME=e.NotEntitledJustification=void 0,(a=e.NotEntitledJustification||(e.NotEntitledJustification={})).MISSING_FEATURE="MISSING_FEATURE",a.MISSING_PERMISSION="MISSING_PERMISSION",a.BUNDLE_EXPIRED="BUNDLE_EXPIRED",e.NO_EXPIRATION_TIME=-1},8552:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.modifyObjectKeysWithPrefix=e.defaultFronteggAttributesMapper=e.prepareAttributes=void 0;const n=a(1857);function s(t){return{email:t.email,emailVerified:t.email_verified,tenantId:t.tenantId,userId:t.id}}function i(t,e){return Object.keys(t).reduce(((a,n)=>(a[`${e}${n}`]=t[n],a)),{})}e.prepareAttributes=function(t={},e){const{custom:a={},jwt:o={}}=t,r=(0,n.flatten)(o);return{...a,...i(e?e(o):s(o),"frontegg."),...i(r,"jwt.")}},e.defaultFronteggAttributesMapper=s,e.modifyObjectKeysWithPrefix=i},8843:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.shouldContinue=e.getResult=void 0;const n=a(395);e.getResult=function(t){let e=!1;for(const a of t){if(a.isEntitled)return a;a.justification===n.NotEntitledJustification.BUNDLE_EXPIRED&&(e=!0)}return{isEntitled:!1,justification:e?n.NotEntitledJustification.BUNDLE_EXPIRED:n.NotEntitledJustification.MISSING_FEATURE}},e.shouldContinue=function(t){return t.every((({isEntitled:t})=>!t))}},1857:(t,e)=>{"use strict";function a(t){return t}Object.defineProperty(e,"__esModule",{value:!0}),e.flatten=void 0,e.flatten=function(t,e){const n=(null==(e=e||{})?void 0:e.delimiter)||".",s=null==e?void 0:e.maxDepth,i=(null==e?void 0:e.transformKey)||a,o={};return function t(a,r,l){l=l||1,Object.keys(a).forEach((function(c){const u=a[c],d=(null==e?void 0:e.safe)&&Array.isArray(u),g=Object.prototype.toString.call(u),p=(h=u)&&h.constructor&&"function"==typeof h.constructor.isBuffer&&h.constructor.isBuffer(h);var h;const y="[object Object]"===g||"[object Array]"===g,v=r?r+n+i(c):i(c);if(!d&&!p&&y&&Object.keys(u).length&&(!(null==e?void 0:e.maxDepth)||s&&l<s))return t(u,v,l+1);o[v]=u}))}(t),o}},6816:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7943),e),s(a(8552),e),s(a(8843),e)},7943:(t,e)=>{"use strict";function a(t){return new RegExp("^"+t.replace(/\./g,"\\.").replace(/\*/g,".*")+"$","gs")}Object.defineProperty(e,"__esModule",{value:!0}),e.createPermissionCheckRegex=e.checkPermission=void 0,e.checkPermission=function(t,e){return Object.keys(t).some((t=>a(t).test(e)))},e.createPermissionCheckRegex=a},2743:t=>{"use strict";var e=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===a}(t)}(t)},a="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(t,e){return!1!==e.clone&&e.isMergeableObject(t)?r((a=t,Array.isArray(a)?[]:{}),t,e):t;var a}function s(t,e,a){return t.concat(e).map((function(t){return n(t,a)}))}function i(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter((function(e){return t.propertyIsEnumerable(e)})):[]}(t))}function o(t,e){try{return e in t}catch(t){return!1}}function r(t,a,l){(l=l||{}).arrayMerge=l.arrayMerge||s,l.isMergeableObject=l.isMergeableObject||e,l.cloneUnlessOtherwiseSpecified=n;var c=Array.isArray(a);return c===Array.isArray(t)?c?l.arrayMerge(t,a,l):function(t,e,a){var s={};return a.isMergeableObject(t)&&i(t).forEach((function(e){s[e]=n(t[e],a)})),i(e).forEach((function(i){(function(t,e){return o(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,i)||(o(t,i)&&a.isMergeableObject(e[i])?s[i]=function(t,e){if(!e.customMerge)return r;var a=e.customMerge(t);return"function"==typeof a?a:r}(i,a)(t[i],e[i],a):s[i]=n(e[i],a))})),s}(t,a,l):n(a,l)}r.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce((function(t,a){return r(t,a,e)}),{})};var l=r;t.exports=l},8792:t=>{"use strict";t.exports=function t(e,a){if(e===a)return!0;if(e&&a&&"object"==typeof e&&"object"==typeof a){if(e.constructor!==a.constructor)return!1;var n,s,i;if(Array.isArray(e)){if((n=e.length)!=a.length)return!1;for(s=n;0!=s--;)if(!t(e[s],a[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===a.source&&e.flags===a.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===a.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===a.toString();if((n=(i=Object.keys(e)).length)!==Object.keys(a).length)return!1;for(s=n;0!=s--;)if(!Object.prototype.hasOwnProperty.call(a,i[s]))return!1;for(s=n;0!=s--;){var o=i[s];if(!t(e[o],a[o]))return!1}return!0}return e!=e&&a!=a}},5302:(t,e,a)=>{const n=a(9537);function s(t,e,a){return"function"==typeof a.join?a.join(t):t[0]+e+t[1]}function i(t,e,a){return"function"!=typeof a.isValid||a.isValid(t,e)}function o(t){return n(t)||Array.isArray(t)||"function"==typeof t}t.exports=function(t,e,a){if(n(a)||(a={default:a}),!o(t))return void 0!==a.default?a.default:t;"number"==typeof e&&(e=String(e));const r=Array.isArray(e),l="string"==typeof e,c=a.separator||".",u=a.joinChar||("string"==typeof c?c:".");if(!l&&!r)return t;if(l&&e in t)return i(e,t,a)?t[e]:a.default;let d=r?e:function(t,e,a){return"function"==typeof a.split?a.split(t):t.split(e)}(e,c,a),g=d.length,p=0;do{let e=d[p];for("number"==typeof e&&(e=String(e));e&&"\\"===e.slice(-1);)e=s([e.slice(0,-1),d[++p]||""],u,a);if(e in t){if(!i(e,t,a))return a.default;t=t[e]}else{let n=!1,o=p+1;for(;o<g;)if(e=s([e,d[o++]],u,a),n=e in t){if(!i(e,t,a))return a.default;t=t[e],p=o-1;break}if(!n)return a.default}}while(++p<g&&o(t));return p===g?t:a.default}},2685:(t,e,a)=>{"use strict";var n=a(9537);function s(t){return!0===n(t)&&"[object Object]"===Object.prototype.toString.call(t)}t.exports=function(t){var e,a;return!1!==s(t)&&"function"==typeof(e=t.constructor)&&!1!==s(a=e.prototype)&&!1!==a.hasOwnProperty("isPrototypeOf")}},5858:t=>{"use strict";t.exports=function(t){return"object"==typeof t?null===t:"function"!=typeof t}},9537:t=>{"use strict";t.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},1098:(t,e,a)=>{"use strict";const{deleteProperty:n}=Reflect,s=a(5858),i=a(2685),o=t=>"object"==typeof t&&null!==t||"function"==typeof t,r=t=>{if(!s(t))throw new TypeError("Object keys must be strings or symbols");if((t=>"__proto__"===t||"constructor"===t||"prototype"===t)(t))throw new Error(`Cannot set unsafe key: "${t}"`)},l=(t,e)=>e&&"function"==typeof e.split?e.split(t):"symbol"==typeof t?[t]:Array.isArray(t)?t:((t,e,a)=>{const n=(t=>Array.isArray(t)?t.flat().map(String).join(","):t)(e?((t,e)=>{if("string"!=typeof t||!e)return t;let a=t+";";return void 0!==e.arrays&&(a+=`arrays=${e.arrays};`),void 0!==e.separator&&(a+=`separator=${e.separator};`),void 0!==e.split&&(a+=`split=${e.split};`),void 0!==e.merge&&(a+=`merge=${e.merge};`),void 0!==e.preservePaths&&(a+=`preservePaths=${e.preservePaths};`),a})(t,e):t);r(n);const s=u.cache.get(n)||a();return u.cache.set(n,s),s})(t,e,(()=>((t,e={})=>{const a=e.separator||".",n="/"!==a&&e.preservePaths;if("string"==typeof t&&!1!==n&&/\//.test(t))return[t];const s=[];let i="";const o=t=>{let e;""!==t.trim()&&Number.isInteger(e=Number(t))?s.push(e):s.push(t)};for(let e=0;e<t.length;e++){const n=t[e];"\\"!==n?n!==a?i+=n:(o(i),i=""):i+=t[++e]}return i&&o(i),s})(t,e))),c=(t,e,a,s)=>{if(r(e),void 0===a)n(t,e);else if(s&&s.merge){const n="function"===s.merge?s.merge:Object.assign;n&&i(t[e])&&i(a)?t[e]=n(t[e],a):t[e]=a}else t[e]=a;return t},u=(t,e,a,n)=>{if(!e||!o(t))return t;const s=l(e,n);let i=t;for(let t=0;t<s.length;t++){const e=s[t],l=s[t+1];if(r(e),void 0===l){c(i,e,a,n);break}"number"!=typeof l||Array.isArray(i[e])?(o(i[e])||(i[e]={}),i=i[e]):i=i[e]=[]}return t};u.split=l,u.cache=new Map,u.clear=()=>{u.cache=new Map},t.exports=u},7048:(t,e,a)=>{var n=a(4319).default;function s(){"use strict";t.exports=s=function(){return e},t.exports.__esModule=!0,t.exports.default=t.exports;var e={},a=Object.prototype,i=a.hasOwnProperty,o=Object.defineProperty||function(t,e,a){t[e]=a.value},r="function"==typeof Symbol?Symbol:{},l=r.iterator||"@@iterator",c=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";function d(t,e,a){return Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},"")}catch(t){d=function(t,e,a){return t[e]=a}}function g(t,e,a,n){var s=e&&e.prototype instanceof y?e:y,i=Object.create(s.prototype),r=new k(n||[]);return o(i,"_invoke",{value:E(t,a,r)}),i}function p(t,e,a){try{return{type:"normal",arg:t.call(e,a)}}catch(t){return{type:"throw",arg:t}}}e.wrap=g;var h={};function y(){}function v(){}function S(){}var f={};d(f,l,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(_([])));b&&b!==a&&i.call(b,l)&&(f=b);var A=S.prototype=y.prototype=Object.create(f);function w(t){["next","throw","return"].forEach((function(e){d(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function a(s,o,r,l){var c=p(t[s],t,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==n(d)&&i.call(d,"__await")?e.resolve(d.__await).then((function(t){a("next",t,r,l)}),(function(t){a("throw",t,r,l)})):e.resolve(d).then((function(t){u.value=t,r(u)}),(function(t){return a("throw",t,r,l)}))}l(c.arg)}var s;o(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,s){a(t,n,e,s)}))}return s=s?s.then(i,i):i()}})}function E(t,e,a){var n="suspendedStart";return function(s,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===s)throw i;return{value:void 0,done:!0}}for(a.method=s,a.arg=i;;){var o=a.delegate;if(o){var r=P(o,a);if(r){if(r===h)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===n)throw n="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);n="executing";var l=p(t,e,a);if("normal"===l.type){if(n=a.done?"completed":"suspendedYield",l.arg===h)continue;return{value:l.arg,done:a.done}}"throw"===l.type&&(n="completed",a.method="throw",a.arg=l.arg)}}}function P(t,e){var a=e.method,n=t.iterator[a];if(void 0===n)return e.delegate=null,"throw"===a&&t.iterator.return&&(e.method="return",e.arg=void 0,P(t,e),"throw"===e.method)||"return"!==a&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+a+"' method")),h;var s=p(n,t.iterator,e.arg);if("throw"===s.type)return e.method="throw",e.arg=s.arg,e.delegate=null,h;var i=s.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function _(t){if(t){var e=t[l];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,n=function e(){for(;++a<t.length;)if(i.call(t,a))return e.value=t[a],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:U}}function U(){return{value:void 0,done:!0}}return v.prototype=S,o(A,"constructor",{value:S,configurable:!0}),o(S,"constructor",{value:v,configurable:!0}),v.displayName=d(S,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,S):(t.__proto__=S,d(t,u,"GeneratorFunction")),t.prototype=Object.create(A),t},e.awrap=function(t){return{__await:t}},w(T.prototype),d(T.prototype,c,(function(){return this})),e.AsyncIterator=T,e.async=function(t,a,n,s,i){void 0===i&&(i=Promise);var o=new T(g(t,a,n,s),i);return e.isGeneratorFunction(a)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},w(A),d(A,u,"Generator"),d(A,l,(function(){return this})),d(A,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),a=[];for(var n in e)a.push(n);return a.reverse(),function t(){for(;a.length;){var n=a.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=_,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function a(a,n){return o.type="throw",o.arg=t,e.next=a,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var r=i.call(s,"catchLoc"),l=i.call(s,"finallyLoc");if(r&&l){if(this.prev<s.catchLoc)return a(s.catchLoc,!0);if(this.prev<s.finallyLoc)return a(s.finallyLoc)}else if(r){if(this.prev<s.catchLoc)return a(s.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return a(s.finallyLoc)}}}},abrupt:function(t,e){for(var a=this.tryEntries.length-1;a>=0;--a){var n=this.tryEntries[a];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var s=n;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=e&&e<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=t,o.arg=e,s?(this.method="next",this.next=s.finallyLoc,h):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var a=this.tryEntries[e];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),I(a),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var a=this.tryEntries[e];if(a.tryLoc===t){var n=a.completion;if("throw"===n.type){var s=n.arg;I(a)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,a){return this.delegate={iterator:_(t),resultName:e,nextLoc:a},"next"===this.method&&(this.arg=void 0),h}},e}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports},4319:t=>{function e(a){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(a)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},5799:(t,e,a)=>{var n=a(7048)();t.exports=n;try{regeneratorRuntime=n}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},e={};function a(n){var s=e[n];if(void 0!==s)return s.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,a),i.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";a.r(n),a.d(n,{AdminPortal:()=>Eg,AdminPortalRenderer:()=>Ig,AppHolder:()=>c,CheckoutDialog:()=>Pg,FronteggApp:()=>wg,HostedLogin:()=>Tg,LoginBoxRenderer:()=>Ug,createElement:()=>yg,defaultTheme:()=>kg,formatName:()=>hg,getOverriddenMetadata:()=>Ag,getThemeAdminByName:()=>Og,getThemeByName:()=>_g,initialize:()=>Mg,mockFlagsList:()=>mg,restoreSearchParams:()=>Sg,waitThemeSetter:()=>vg});var t={};a.r(t),a.d(t,{ApplicationAccessType:()=>an,AuthStrategyEnum:()=>N,ContextHolder:()=>R,DirectoryApi:()=>ga,EIdentifierType:()=>x,FRONTEGG_SEPARATE_TABS_BY_TENANT:()=>ie,FeatureFlags:()=>ae,FeatureFlagsApi:()=>ne,FetchClient:()=>Vt,FronteggApiError:()=>z,FronteggContext:()=>L,FronteggFrameworks:()=>jt,GENERIC_ERROR_CODE:()=>xt,GENERIC_ERROR_MESSAGE:()=>Ft,GetUsersFilterPreset:()=>qa,GroupManagedByEnum:()=>za,GroupRelations:()=>Ha,ISubscriptionCancellationPolicy:()=>B,ISubscriptionStatus:()=>G,InsightCode:()=>Qa,LOAD_AUTHORIZATION_FF:()=>Zt,MFAStrategyEnum:()=>Qt,MachineToMachineAuthStrategy:()=>M,NotEntitledJustification:()=>Ya,PaginationOrderEnum:()=>Bt,PasswordRecoveryStrategyEnum:()=>$,PaymentMethodType:()=>j,PermissionAssignmentTypeEnum:()=>Na,ProviderType:()=>V,RecommendationActionKey:()=>Za,RecommendationCode:()=>Xa,RecommendationSeverity:()=>tn,RequestSource:()=>Gt,RestrictionType:()=>Jt,ScimConnectionSource:()=>Wa,SecondaryAuthStrategy:()=>Yt,SecurityCategory:()=>en,SignUpStrategyEnum:()=>F,SocialLoginProviders:()=>D,SortByEnum:()=>Ka,SubAccountAccessTypeEnum:()=>Ma,TenantSortByEnum:()=>La,TenantType:()=>Da,UserManagedByEnum:()=>Ca,WebAuthnDeviceType:()=>Xt,api:()=>nn,createApiClient:()=>sn,default:()=>on,fetch:()=>Wt,fronteggAuthApiRoutesRegex:()=>Fa,fronteggEntitlementsV2Url:()=>Va,fronteggHeaders:()=>$t,fronteggRefreshTokenUrl:()=>xa,fronteggSilentRefreshTokenUrl:()=>$a,fronteggTenantsUrl:()=>ja,fronteggTenantsV3Url:()=>Ba,fronteggUsersUrl:()=>Ga,getCurrentUserTenantsFunction:()=>ge,getTabTenantFromSessionStorage:()=>de,providersArray:()=>Ja,removeTabTenantFromSessionStorage:()=>ue,setTabTenantInSessionStorage:()=>ce});var e={};a.r(e),a.d(e,{ACR_VALUE:()=>Sn,AMR_ADDITIONAL_VALUE:()=>mn,AMR_MFA_VALUE:()=>fn,AcceptInvitationStep:()=>un,ActivateAccountStep:()=>qn,AdminPortalPages:()=>es,AdminPortalPagesForEvents:()=>ts,AllAccountsStateKeys:()=>zo,ApiStateKeys:()=>Ws,AuthStrategyEnum:()=>N,AuthenticationTypes:()=>Zn,DEFAULT_RETRY_CONFIG:()=>Un,EditEmailView:()=>oc,FRONTEGG_AFTER_AUTH_REDIRECT_URL:()=>kn,ForgotPasswordStep:()=>ti,FronteggNativeModule:()=>v,GTMEventAction:()=>as,GroupRelations:()=>gi,GroupsStateKeys:()=>di,HOSTED_LOGIN_VERIFIER_KEY:()=>_n,ImpersonateStep:()=>fi,LoginActionTypes:()=>Pn,LoginFlow:()=>Tn,LoginStep:()=>wn,MFAStep:()=>ns,MachineToMachineAuthStrategy:()=>M,PasswordRotationStep:()=>ii,PaymentMethodType:()=>fc,PaymentProvider:()=>Ac,QuickLoginStrategy:()=>En,REQUEST_NAME:()=>Xn,ResetPhoneNumberStep:()=>pr,RolesStateKeys:()=>wr,SHOULD_STEP_UP_KEY:()=>bn,SSOStateKeys:()=>po,STEP_UP_MAX_AGE_PARAM_NAME:()=>An,SamlVendors:()=>ho,SecurityCenterStateKeys:()=>$r,SignUpStage:()=>nl,SubscriptionCancellationPolicy:()=>Tc,SubscriptionStatus:()=>wc,TENANT_ID_PARAM_KEY:()=>us,TeamStateKeys:()=>Us,UserVerifiedOriginTypes:()=>Qn,authStrategyLoginStepMap:()=>On,base64ToFormData:()=>Ni,base64urlDecode:()=>Di,base64urlEncode:()=>Li,buildAuditsActions:()=>uu,buildAuthActions:()=>uc,buildConnectivityActions:()=>Sc,buildSubscriptionsActions:()=>Zc,buildVendorActions:()=>au,createAuditsState:()=>cu,createAuthState:()=>cc,createConnectivityState:()=>gc,createFronteggStore:()=>xd,createProxy:()=>cn,createRandomString:()=>no,createStore:()=>$d,createSubscriptionsState:()=>Qc,createVendorState:()=>eu,deepClone:()=>xn,deepResetState:()=>$n,defaultFronteggRoutes:()=>In,delay:()=>Rn,errorHandler:()=>Bn,errorTraceId:()=>Nn,generateCodeChallenge:()=>ao,generateCodeChallengeNative:()=>eo,generateCodeChallengePureJs:()=>to,getBaseNameWithoutSlashSuffix:()=>Ss,getEntitlements:()=>uo,getFeatureEntitlements:()=>co,getMfaStepForEnrolledUsers:()=>gs,getMfaStepForNotEnrolledUsers:()=>ps,getNumberOfMfaDevices:()=>ds,getPathAndSearchParamsFromUrl:()=>ls,getPermissionEntitlements:()=>lo,getRedirectUrl:()=>os,getSearchParam:()=>cs,getSearchParamsFromUrl:()=>rs,getUri:()=>Is,hmac:()=>Zi,isAbsoluteUrl:()=>is,isAuthRoute:()=>_s,isEmailPayload:()=>ys,isEntitlementsDeeplyEqual:()=>go,isError:()=>jn,isFronteggApiError:()=>Gn,isMfaRequired:()=>Es,isOauthCallbackRoute:()=>hs,isProxy:()=>Fn,isResetPasswordRequired:()=>Ps,isSteppedUp:()=>ms,isUsernamePayload:()=>vs,mapMetaDataObjectToActions:()=>Os,omitProps:()=>Mn,prepareIdentifiersForSignup:()=>ks,publicKeyCredentialToJSON:()=>Mi,readFileAsText:()=>Fi,redirectByStepUpUrl:()=>As,reportGTMEvent:()=>ss,retry:()=>Cn,retryIfNeeded:()=>Ln,setAfterAuthRedirectUrlForStepUp:()=>bs,sha256:()=>Qi,shouldShowPasswordRotationPromptFunc:()=>fs,snapshot:()=>k,subscribe:()=>I,withRetryConfig:()=>Dn});var s={};function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function r(t,e){for(var a=0;a<e.length;a++){var n=e[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(s=n.key,i=void 0,i=function(t){if("object"!==o(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var a=e.call(t,"string");if("object"!==o(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(s),"symbol"===o(i)?i:String(i)),n)}var s,i}function l(t,e,a){return e&&r(t.prototype,e),a&&r(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}a.r(s),a.d(s,{AccountDetailsPageTabs:()=>Zd,AccountPageFields:()=>Hd,COUNTRY_FILTER_TYPE:()=>jd,DomainRestrictionsTabFields:()=>Qd,GeneralSettingsTabFields:()=>Yd,InviteUserModalFields:()=>Wd,IpRestrictionsTabFields:()=>Xd,Metadata:()=>pg,PrivacyPageFields:()=>Vd,ProfilePageFields:()=>Bd,SecurityPageTabs:()=>qd,SessionManagementTabFields:()=>Jd,SignupFields:()=>Gd,SubscriptionsPageFields:()=>Kd,UsersTableColumns:()=>zd,alpha:()=>og,fieldAppearance:()=>tg,tabAppearance:()=>eg});var c=function(){function t(){i(this,t)}return l(t,null,[{key:"setInstance",value:function(e,a){t._apps[e]=a}},{key:"getInstance",value:function(e){var a=t._apps[e];if(!a)throw Error("[".concat(e,"] FronteggApp not found"));return a}}]),t}();function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=new Array(e);a<e;a++)n[a]=t[a];return n}function d(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var n,s,i,o,r=[],l=!0,c=!1;try{if(i=(a=a.call(t)).next,0===e){if(Object(a)!==a)return;l=!1}else for(;!(l=(n=i.call(a)).done)&&(r.push(n.value),r.length!==e);l=!0);}catch(t){c=!0,s=t}finally{try{if(!l&&null!=a.return&&(o=a.return(),Object(o)!==o))return}finally{if(c)throw s}}return r}}(t,e)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?u(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t,e,a,n,s,i,o){try{var r=t[i](o),l=r.value}catch(t){return void a(t)}r.done?e(l):Promise.resolve(l).then(n,s)}function p(t){return function(){var e=this,a=arguments;return new Promise((function(n,s){var i=t.apply(e,a);function o(t){g(i,n,s,o,r,"next",t)}function r(t){g(i,n,s,o,r,"throw",t)}o(void 0)}))}}c._apps={};var h=a(5799),y=a.n(h);const v=new class{constructor(){this.loginWithSSO=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSSO",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSSO(t)}},this.loginWithSocialLogin=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSocialLogin",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSocialLogin(t)}},this.loginWithSocialLoginProvider=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSocialLoginProvider",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSocialLoginProvider(t)}},this.loginWithCustomSocialLoginProvider=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithCustomSocialLoginProvider",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithCustomSocialLoginProvider(t)}},this.suggestSavePassword=(t,e)=>{if(this.isIOSNativeBridgeAvailable()){var a,n,s;null==(a=window.webkit)||null==(n=a.messageHandlers)||null==(s=n.FronteggNativeBridge)||s.postMessage(JSON.stringify({action:"suggestSavePassword",payload:JSON.stringify({email:t,password:e})}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var i;null==(i=window.FronteggNativeBridge)||i.suggestSavePassword(t,e)}},this.promptSocialLoginConsent=()=>{var t,e;return null!=(t=null==(e=window.FronteggNativeBridgeFunctions)?void 0:e.shouldPromptSocialLoginConsent)&&t}}isIOSNativeBridgeAvailable(){var t,e;return null!=(null==(t=window.webkit)||null==(e=t.messageHandlers)?void 0:e.FronteggNativeBridge)}isAndroidNativeBridgeAvailable(){return null!=window.FronteggNativeBridge}isSocialLoginAvailable(){return this.isAvailable("loginWithSocialLogin")}isSocialLoginProviderAvailable(){return this.isAvailable("loginWithSocialLoginProvider")}isCustomSocialLoginProviderAvailable(){return this.isAvailable("loginWithCustomSocialLoginProvider")}isLoginWithSSOAvailable(){return this.isAvailable("loginWithSSO")}isSuggestSavePasswordAvailable(){return this.isAvailable("suggestSavePassword")}isAvailable(t){var e,a;return!(!this.isIOSNativeBridgeAvailable()&&!this.isAndroidNativeBridgeAvailable())&&null!=(e=null==(a=window.FronteggNativeBridgeFunctions)?void 0:a[t])&&e}};function S(){return S=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},S.apply(this,arguments)}function f(t,e){if(null==t)return{};var a,n,s={},i=Object.keys(t);for(n=0;n<i.length;n++)a=i[n],e.indexOf(a)>=0||(s[a]=t[a]);return s}Symbol();const m=Symbol(),b=Object.getPrototypeOf,A=new WeakMap,w=(t,e=!0)=>{A.set(t,e)},T=t=>"object"==typeof t&&null!==t,E=new WeakMap,P=new WeakSet;const[O]=function(t=Object.is,e=(t,e)=>new Proxy(t,e),a=t=>T(t)&&!P.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),n=t=>{switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t}},s=new WeakMap,i=(t,e,a=n)=>{const o=s.get(t);if((null==o?void 0:o[0])===e)return o[1];const r=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return w(r,!0),s.set(t,[e,r]),Reflect.ownKeys(t).forEach((e=>{if(Object.getOwnPropertyDescriptor(r,e))return;const n=Reflect.get(t,e),{enumerable:s}=Reflect.getOwnPropertyDescriptor(t,e),o={value:n,enumerable:s,configurable:!0};if(P.has(n))w(n,!1);else if(n instanceof Promise)delete o.value,o.get=()=>a(n);else if(E.has(n)){const[t,e]=E.get(n);o.value=i(t,e(),a)}Object.defineProperty(r,e,o)})),Object.preventExtensions(r)},o=new WeakMap,r=[1,1],l=n=>{if(!T(n))throw new Error("object required");const s=o.get(n);if(s)return s;let c=r[0];const u=new Set,d=(t,e=++r[0])=>{c!==e&&(c=e,u.forEach((a=>a(t,e))))};let g=r[1];const p=t=>(e,a)=>{const n=[...e];n[1]=[t,...n[1]],d(n,a)},h=new Map,y=t=>{const e=h.get(t);var a;e&&(h.delete(t),null==(a=e[1])||a.call(e))},v=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),S=e(v,{deleteProperty(t,e){const a=Reflect.get(t,e);y(e);const n=Reflect.deleteProperty(t,e);return n&&d(["delete",[e],a]),n},set(e,n,s,i){const r=Reflect.has(e,n),c=Reflect.get(e,n,i);if(r&&(t(c,s)||o.has(s)&&t(c,o.get(s))))return!0;var g;y(n),T(s)&&(s=(t=>t&&(A.has(t)?A.get(t):b(t)===Object.prototype||b(t)===Array.prototype))(g=s)&&g[m]||s);let v=s;if(s instanceof Promise)s.then((t=>{s.status="fulfilled",s.value=t,d(["resolve",[n],t])})).catch((t=>{s.status="rejected",s.reason=t,d(["reject",[n],t])}));else{!E.has(s)&&a(s)&&(v=l(s));const t=!P.has(v)&&E.get(v);t&&((t,e)=>{if(u.size){const a=e[3](p(t));h.set(t,[e,a])}else h.set(t,[e])})(n,t)}return Reflect.set(e,n,v,i),d(["set",[n],s,c]),!0}});o.set(n,S);const f=[v,(t=++r[1])=>(g===t||u.size||(g=t,h.forEach((([e])=>{const a=e[1](t);a>c&&(c=a)}))),c),i,t=>(u.add(t),1===u.size&&h.forEach((([t,e],a)=>{const n=t[3](p(a));h.set(a,[t,n])})),()=>{u.delete(t),0===u.size&&h.forEach((([t,e],a)=>{e&&(e(),h.set(a,[t]))}))})];return E.set(S,f),Reflect.ownKeys(n).forEach((t=>{const e=Object.getOwnPropertyDescriptor(n,t);"value"in e&&(S[t]=n[t],delete e.value,delete e.writable),Object.defineProperty(v,t,e)})),S}){return[l,E,P,t,e,a,n,s,i,o,r]}();function I(t,e,a){const n=E.get(t);let s;const i=[],o=n[3];let r=!1;const l=o((t=>{i.push(t),a?e(i.splice(0)):s||(s=Promise.resolve().then((()=>{s=void 0,r&&e(i.splice(0))})))}));return r=!0,()=>{r=!1,l()}}function k(t,e){const a=E.get(t),[n,s,i]=a;return i(n,s(),e)}const _=["enabled","name"],U=Symbol();class R{constructor(){this.context=null,this.accessToken=null,this.user=null,this.requestSource=null,this.onRedirectTo=t=>window.location.href=t,this.logout=()=>window.location.href="/account/logout",this.entitlementsOptions=null,this.appName=null,this.sessionContext=void 0,this.basename=null,this.cdnUrl=null,this.assetsUrl=null,this.setContext=t=>{this.context=t},this.setAccessToken=t=>{this.accessToken=t},this.setUser=t=>{this.user=t},this.setRequestSource=t=>{this.requestSource=t},this.setOnRedirectTo=t=>{this.onRedirectTo=t},this.setLogout=t=>{this.logout=t},this.setEntitlementsOptions=t=>{this.entitlementsOptions=t},this.setSessionContext=t=>{this.sessionContext=t},this.setAppName=t=>{this.appName=t},this.getContext=()=>{var t;return null!=(t=this.context)?t:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}},this.getAccessToken=()=>this.accessToken,this.getRequestSource=()=>this.requestSource,this.getUser=()=>this.user,this.shouldLoadEntitlements=()=>{var t;return(null==(t=this.entitlementsOptions)?void 0:t.enabled)||!1},this.isSessionPerTenantEnabled=()=>{var t;return(null==(t=this.sessionContext)?void 0:t.enableSessionPerTenant)||!1},this.shouldSkipUserLoad=()=>{var t;return(null==(t=this.sessionContext)?void 0:t.skipUserLoading)||!1},this.getAppName=()=>this.appName,this.setCdnUrl=t=>{this.cdnUrl=t},this.getCdnUrl=()=>this.cdnUrl,this.setAssetsUrl=t=>{this.assetsUrl=t},this.getAssetsUrl=()=>this.assetsUrl}static default(){return R.getInstance(C)}static for(t){return R.getInstance(t)}static getInstance(t="default"){return R._apps||(R._apps={}),R._apps[t]||(R._apps[t]=new R),R._apps[t]}static createInstance(t="default"){return R._apps[t]=new R,R._apps[t].appName=t,R._apps[t]}static setContext(t,e="default"){R.for(e).context=t}static setAccessToken(t,e=C){R.for(e).accessToken=t}static setUser(t,e="default"){R.for(e).user=t}static setRequestSource(t,e="default"){R.for(e).requestSource=t}static setOnRedirectTo(t,e="default"){R.for(e).onRedirectTo=t}static setLogout(t,e,a="default"){const n=R.for(a);n.logout=a=>{a?t(a):n.onRedirectTo(e,void 0)}}static setEntitlementsOptions(t,e="default"){R.for(e).entitlementsOptions=t}static setSessionContext(t,e="default"){R.for(e).sessionContext=t}static setAppName(t){R.for(t).appName=t}static getContext(t="default"){var e;return null!=(e=R.for(t).context)?e:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}}static getAccessToken(t="default"){return R.for(t).accessToken}static getRequestSource(t="default"){return R.for(t).requestSource}static getBasename(t="default"){return R.for(t).basename}getBasename(){return this.basename}static setBasename(t,e=C){R.for(e).basename=t}setBasename(t){this.basename=t}static getUser(t="default"){return R.for(t).user}static onRedirectTo(t,e,a="default"){return R.for(a).onRedirectTo(t,e)}static logout(t,e="default"){return R.for(e).logout(t)}static shouldLoadEntitlements(t="default"){var e;return(null==(e=R.for(t).entitlementsOptions)?void 0:e.enabled)||!1}static isSessionPerTenantEnabled(t="default"){var e;return(null==(e=R.for(t).sessionContext)?void 0:e.enableSessionPerTenant)||!1}static getAppName(t="default"){return R.for(t).appName}}R._apps=void 0;const C="default",L={getContext:()=>R.getContext(C),getAccessToken:()=>R.getAccessToken(C),setAccessToken:t=>R.setAccessToken(t,C),getUser:()=>R.getUser(C),setUser:t=>R.setUser(t,C),onRedirectTo:(t,e)=>R.onRedirectTo(t,e,C),setOnRedirectTo:t=>R.setOnRedirectTo(t,C),logout:t=>R.logout(t,C),getRequestSource:()=>R.getRequestSource(C),setRequestSource:t=>R.setRequestSource(t,C),isSessionPerTenantEnabled:()=>R.isSessionPerTenantEnabled(C),shouldLoadEntitlements:()=>R.shouldLoadEntitlements(C),getAppName:()=>R.getAppName(C),setEntitlementsOptions:t=>R.setEntitlementsOptions(t,C),setSessionContext:t=>R.setSessionContext(t,C),getBasename:()=>R.getBasename(C),setBasename:t=>R.setBasename(t,C)};let D,N,M,F,x,$,G,j,B,V,W,H;!function(t){t.Microsoft="microsoft",t.Facebook="facebook",t.Google="google",t.Github="github",t.Slack="slack",t.Apple="apple",t.Linkedin="linkedin"}(D||(D={})),function(t){t.EmailAndPassword="EmailAndPassword",t.MagicLink="MagicLink",t.Code="Code",t.NoLocalAuthentication="NoLocalAuthentication",t.SmsCode="SmsCode",t.WebAuthN="WebAuthN",t.UsernameAndPassword="UsernameAndPassword",t.UsernameAndMagicLink="UsernameAndMagicLink",t.UsernameAndCode="UsernameAndCode",t.UsernameAndSms="UsernameAndSms"}(N||(N={})),function(t){t.ClientCredentials="ClientCredentials",t.AccessToken="AccessToken"}(M||(M={})),function(t){t.Email="email",t.PhoneNumber="phoneNumber"}(F||(F={})),function(t){t.email="email",t.phoneNumber="phoneNumber",t.username="username"}(x||(x={})),function(t){t.Email="email",t.Sms="sms"}($||($={})),function(t){t.ACTIVE="active",t.CANCELED="canceled",t.INCOMPLETE="incomplete",t.EXPIRED="expired",t.TRIALING="trialing",t.TRIAL_ENDED="trialEnded"}(G||(G={})),function(t){t.UNKNWON="unknown",t.CARD="card"}(j||(j={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}(B||(B={})),function(t){t.Stripe="Stripe"}(V||(V={})),function(t){t.CHANGE_TO_DEFAULT="change_to_default",t.RETAIN_TRIAL="retain_trial"}(W||(W={})),function(t){t.CREATE="create_customer"}(H||(H={}));class z extends Error{constructor(t,e,a,n,s){super(t),this._statusCode=void 0,this._traceId=void 0,this._errorCode=void 0,this._errorContext=void 0,this._statusCode=e,this._traceId=a,this._errorCode=n,this._errorContext=s}get statusCode(){return this._statusCode}get traceId(){return this._traceId}get errorCode(){return this._errorCode}get errorContext(){return this._errorContext}}const K={v1:{strategies:"/identity/resources/configurations/v1/sign-up/strategies"}},q={v1:"/identity/resources/users/webauthn/v1/devices"},J={v1:"/identity/resources/auth/v1",v2:"/identity/resources/auth/v2"},Y={v1:"/identity/resources/users/v1",v2:"/identity/resources/users/v2",v3:"/identity/resources/users/v3",roles:{v3:"/identity/resources/users/v3/roles"},groups:{v3:"/identity/resources/users/v3/groups"},tenants:{me:{v1:"/identity/resources/users/v1/me/tenants",v3:"/identity/resources/users/v3/me/tenants"}},apiTokens:{v1:"/identity/resources/users/api-tokens/v1"},accessTokens:{v1:"/identity/resources/users/access-tokens/v1"},sessions:{v1:"/identity/resources/users/sessions/v1",currentUser:{v1:"/identity/resources/users/sessions/v1/me"},configurations:{v1:"/identity/resources/configurations/sessions/v1"}},invitation:{resendAll:{v1:"/identity/resources/users/v1/invitation/reset/all"}},passwords:{resetBreachedPasswords:{v1:"/identity/resources/users/v1/passwords/breached/reset/bulk"}},authorization:{v1:"/identity/resources/users/v1/me/authorization"},temporary:{v1:"/identity/resources/users/temporary/v1",configuration:{v1:"/identity/resources/users/temporary/v1/configuration"}}},X={v1:"/identity/resources/configurations/v1"},Q={emailDomain:{v1:"/identity/resources/configurations/restrictions/v1/email-domain"},ip:{v1:"/identity/resources/configurations/v1/restrictions/ip"}},Z={v1:"/identity/resources/sso/v1",v2:"/identity/resources/sso/v2",custom:{v1:"/identity/resources/sso/custom/v1"}},tt={v1:"/identity/resources/permissions/v1"},et={apiTokens:{v1:"/identity/resources/tenants/api-tokens/v1",v2:"/identity/resources/tenants/api-tokens/v2"},accessTokens:{v1:"/identity/resources/tenants/access-tokens/v1"},invites:{user:{v1:"/identity/resources/tenants/invites/v1/user"},verify:{v1:"/identity/resources/tenants/invites/v1/verify"},configuration:{v1:"/identity/resources/tenants/invites/v1/configuration"}},users:{v1:"/identity/resources/tenants/users/v1"}},at={v1:"/identity/resources/roles/v1",v2:"/identity/resources/roles/v2"},nt={v1:"/identity/resources/sub-tenants/users/v1",v2:"/identity/resources/sub-tenants/users/v2"},st={v1:"/identity/resources/impersonation/v1"},it={v1:"/identity/resources/applications/v1"},ot={v1:"/identity/resources/groups/v1",configurations:{v1:"/identity/resources/groups/v1/config"},getByIds:{v1:"/identity/resources/groups/v1/bulkGet"}},rt={v1:"/identity/resources/users/phone-numbers/v1"},lt={v1:"/identity/resources/usernames/v1"},ct={v1:"/team/resources/sso/v1",v2:"/team/resources/sso/v2"},ut={v1:"/team/resources/members/v1"},dt={v1:"/team/resources/roles/v1"},gt={v1:"/team/resources/stats/v1"},pt={v1:"/team/resources/profile"},ht={v1:"/tenants/resources/account-settings/v1"},yt={v1:"/tenants/resources/hierarchy/v1",tree:{v1:"/tenants/resources/hierarchy/v1/tree"},parents:{v1:"/tenants/resources/hierarchy/v1/parents"},v2:"/tenants/resources/hierarchy/v2",metadata:{v2:"/tenants/resources/hierarchy/v2/metadata"}},vt={v1:"/tenants/resources/sub-tenants/v1"},St={v1:"/integrations/resources/configurations/v1",v2:"/integrations/resources/configurations/v2"},ft={subscriptions:{v1:"/subscriptions/resources/billing/subscriptions/v1"},plans:{v1:"/subscriptions/resources/billing/plans/v1"},invoices:{v1:"/subscriptions/resources/billing/invoices/v1"},paymentMethods:{v1:"/subscriptions/resources/billing/payment-methods/v1"},summaries:{v1:"/subscriptions/resources/billing/summaries/v1"},tenantConfiguration:{v1:"/subscriptions/resources/billing/tenant-configurations/v1"},configurations:{vendorPublicConfigurations:{v1:"/subscriptions/resources/billing/configurations/vendor-public-configurations/v1"}},paymentProviders:{stripe:{customers:{v1:"/subscriptions/resources/billing/payment-providers/stripe/customers/v1"},publicConfigurations:{v1:"/subscriptions/resources/billing/payment-providers/stripe/public-configurations/v1"},subscriptions:{v1:"/subscriptions/resources/billing/payment-providers/stripe/subscriptions/v1"},setupIntents:{v1:"/subscriptions/resources/billing/payment-providers/stripe/setup-intents/v1"}}}},mt={v1:"/subscriptions/resources/payment-providers/v1"},bt={v1:"/subscriptions/resources/subscriptions/v1"},At={v1:"/reports/resources/reports/v1",v2:"/reports/resources/reports/v2"},wt={v1:"/reports/engine/resources/triggers/v1"},Tt="/notification",Et="/audits",Pt={v1:"/event/resources/configurations/v1"},Ot="/webhook",It="/oauth",kt="/flags",_t="/directory/resources/v1/configurations/scim2",Ut="/directory/resources/scim/temp",Rt="/entitlements/api/v2/user-entitlements",Ct={v1:"/security-center/resources/recommendations/v1"},Lt={v1:"/security-center/resources/insights/v1"},Dt="/applications/resources/applications/v1",Nt={v1:"/applications/resources/applications/tenant-assignments/v1"},Mt="http://localhost:3037/resources/velo/v1",Ft="We're facing some difficulties, Please try again",xt="ER-ADMIN-PORTAL-GENERIC-ERROR",$t={frameWork:"x-frontegg-framework",fronteggSdkVersion:"x-frontegg-sdk",contentType:"Content-Type",source:"frontegg-source",scopedTenant:"frontegg-scoped-tenant"};let Gt,jt,Bt;!function(t){t.AdminPortal="admin-portal",t.LoginBox="login-box"}(Gt||(Gt={})),function(t){t.Nextjs="nextjs",t.React="react",t.Angular="angular",t.Vuejs="vuejs",t.Flutter="flutter",t.Ios="ios",t.Android="android",t.Vanillajs="vanillajs"}(jt||(jt={})),function(t){t.ASC="ASC",t.DESC="DESC"}(Bt||(Bt={}));class Vt{constructor(t){this.appName=void 0,this.getFronteggContext=()=>R.for(this.appName),this.prepareUrl=async(t,e)=>{const a=this.getFronteggContext().getContext(),n=this.getContextBaseUrl(t),s=await this.buildQueryParams(a,e);let i=t.startsWith("http")?t:`${n}${t}`;const o=Object.keys(s).length>0;return s&&o&&(i+=`?${new URLSearchParams(s)}`),i},this.buildQueryParams=async(t,e)=>{e||(e={});const a=await this.getAdditionalQueryParams(t);for(const t of a)e[t.key]=t.value;const n=Object.keys(e);for(const t of n){const a=e[t];e[t]="object"==typeof a?JSON.stringify(a):a}return e},this.getAdditionalQueryParams=async t=>{let e=[];return t.additionalQueryParamsResolver&&(e=await t.additionalQueryParamsResolver()),e},this.getAdditionalHeaders=async t=>{let e=[];if(t.additionalHeadersResolver&&(e=await t.additionalHeadersResolver()),t.tenantResolver){const a=await t.tenantResolver();null!=a&&a.tenant&&e.push({key:"frontegg-login-alias",value:a.tenant})}return t.appId&&e.push({key:"frontegg-requested-application-id",value:t.appId}),e},this.buildRequestHeaders=async t=>{var e;const a=this.getFronteggContext(),n=a.getContext(),s=Vt.getMetadataHeaders(n),i=await(null!=(e=null==n?void 0:n.tokenResolver)?e:a.getAccessToken)(),o=a.getRequestSource(),r=Vt.getScopedTenant();t&&(s[$t.contentType]=t),o&&(s[$t.source]=o),i&&(s.Authorization=`Bearer ${i}`),r&&(s[$t.scopedTenant]=r);for(const t of await this.getAdditionalHeaders(n))s[`${t.key}`]=`${t.value}`;return s},this.getResponseTraceId=t=>{var e,a;return null==t||null==(e=t.headers)||null==(a=e.get)?void 0:a.call(e,"frontegg-trace-id")},this.sendRequest=async t=>{var e,a,n;const s=this.getFronteggContext().getContext(),i=await this.buildRequestHeaders(t.contentType),o=await this.prepareUrl(t.url,t.params),r=s.beforeRequestInterceptor,l={body:t.body?"application/json"===t.contentType?JSON.stringify(t.body):t.body:null,method:null!=(e=t.method)?e:"GET",headers:S({},i,t.headers),credentials:null!=(a=null!=(n=t.credentials)?n:s.requestCredentials)?a:"same-origin"},c=r?r(l,o):l,u=await fetch(o,c);if(302===u.status)return window.location.href=await u.text(),new Promise((()=>{}));if(!u.ok){var d,g,p,h,y;if(413===u.status)throw new z("Error request is too large",u.status,this.getResponseTraceId(u),void 0);let t,e,a,n=!0;try{t=await u.text(),t=JSON.parse(t)}catch(t){n=!1}throw null!=(d=t)&&d.errorCode&&(e=t.errorCode),null!=(g=t)&&g.context&&"object"==typeof t.context&&(a=t.context),t.errors?t=t.errors.join(", "):"string"!=typeof t&&(t=`Error ${u.status} - ${u.statusText}`),u.status>=400&&u.status<500&&["warn"].includes(null!=(p=s.logLevel)?p:"")?console.warn(t):500===u.status&&["warn","error"].includes(null!=(h=s.logLevel)?h:"")&&console.error(t),new z(n?t:Ft,u.status,this.getResponseTraceId(u),null!=(y=e)?y:xt,a)}if("stream"===t.responseType)return u.body;if(t.responseType&&"json"!==t.responseType){if("blob"===t.responseType){const{outputFileName:e}=t.params;return await u.blob().then((t=>URL.createObjectURL(t))).then((t=>{const a=document.createElement("a");a.href=t,a.setAttribute("download",e||"output"),a.click()}))}return await u.text()}try{return await u.json()}catch(t){return{}}},this.get=async(t,e,a)=>this.sendRequest(S({url:t,method:"GET",contentType:"application/json",params:e},a)),this.post=async(t,e,a)=>this.sendRequest(S({url:t,method:"POST",contentType:"application/json",body:e},a)),this.patch=async(t,e,a)=>this.sendRequest(S({url:t,method:"PATCH",contentType:"application/json",body:e},a)),this.put=async(t,e,a)=>this.sendRequest(S({url:t,method:"PUT",contentType:"application/json",body:e},a)),this.delete=async(t,e,a)=>this.sendRequest(S({url:t,method:"DELETE",contentType:"application/json",body:e},a)),this.postDownload=async(t,e,a,n)=>this.sendRequest(S({url:t,method:"POST",contentType:"application/json",responseType:"blob",body:e,params:a},n)),this.extractHeadersFromOptions=(t={})=>S({},t.jwt?{Authorization:t.jwt}:{}),this.getBaseUrl=(t,e,a=!0)=>Vt.getBaseUrl(t,e,a),this.getContextBaseUrl=(t,e=!0)=>{const a=this.getFronteggContext().getContext();return this.getBaseUrl(a,t,e)},this.getMetadataHeaders=t=>Vt.getMetadataHeaders(t),this.getContextMetadataHeaders=()=>{const t=this.getFronteggContext().getContext();return Vt.getMetadataHeaders(t)},this.appName=t}}Vt.getBaseUrl=(t,e,a=!0)=>{let n;n="function"==typeof t.baseUrl?t.baseUrl(e):t.baseUrl;const s=t.urlPrefix||"frontegg",i="frontegg"===s&&!a;return n.endsWith("/")||(n+="/"),n.endsWith(s)||i||(n+=s),n},Vt.getMetadataHeaders=t=>{var e,a;const n={};return null!=t&&null!=(e=t.metadataHeaders)&&e.fronteggSdkVersion&&(n[$t.fronteggSdkVersion]=t.metadataHeaders.fronteggSdkVersion),null!=t&&null!=(a=t.metadataHeaders)&&a.framework&&(n[$t.frameWork]=t.metadataHeaders.framework),n},Vt.getScopedTenant=()=>new URLSearchParams(window.location.search).get("tenantId")||null;const Wt=new Vt("default");class Ht extends Error{constructor(t){super(t)}}const zt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){const e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ht("'atob' failed: The string to be decoded is not correctly encoded.");let a="";for(let t,n,s=0,i=0;n=e.charAt(i++);~n&&(t=s%4?64*t+n:n,s++%4)?a+=String.fromCharCode(255&t>>(-2*s&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};class Kt extends Error{constructor(t){super(t)}}const qt=(t,e={})=>{const a=e.header?0:1;try{return JSON.parse((t=>{let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(t){return decodeURIComponent(zt(t).replace(/(.)/g,((t,e)=>{let a=e.charCodeAt(0).toString(16).toUpperCase();return a.length<2&&(a="0"+a),"%"+a})))}(e)}catch(t){return zt(e)}})(t.split(".")[a]))}catch(t){throw new Kt("Invalid token specified: "+t.message)}};let Jt,Yt,Xt,Qt;!function(t){t.ALLOW="ALLOW",t.BLOCK="BLOCK"}(Jt||(Jt={})),function(t){t.WebAuthnPlatform="WebAuthnPlatform",t.WebAuthnCrossPlatform="WebAuthnCrossPlatform",t.SmsCode="SmsCode",t.SmsCodeV2="SmsCodeV2",t.Passkeys="Passkeys",t.UsernameAndPassword="UsernameAndPassword",t.UsernameAndMagicLink="UsernameAndMagicLink",t.UsernameAndCode="UsernameAndCode",t.UsernameAndSms="UsernameAndSms"}(Yt||(Yt={})),function(t){t.Platform="Platform",t.CrossPlatform="CrossPlatform"}(Xt||(Xt={})),function(t){t.AuthenticatorApp="AuthenticatorApp",t.WebAuthnPlatform="WebAuthnPlatform",t.WebAuthnCrossPlatform="WebAuthnCrossPlatform",t.SMS="SMS",t.EmailCode="EmailCode"}(Qt||(Qt={}));const Zt="admin_portal_should_load_authorization";class te{constructor(t){this.appName=void 0,this.fetchClient=void 0,this.get=async(t,e,a)=>this.fetchClient.get(t,e,a),this.post=async(t,e,a)=>this.fetchClient.post(t,e,a),this.patch=async(t,e,a)=>this.fetchClient.patch(t,e,a),this.put=async(t,e,a)=>this.fetchClient.put(t,e,a),this.delete=async(t,e,a)=>this.fetchClient.delete(t,e,a),this.postDownload=async(t,e,a,n)=>this.fetchClient.postDownload(t,e,a,n),this.extractHeadersFromOptions=(t={})=>this.fetchClient.extractHeadersFromOptions(t),this.appName=t,this.fetchClient=new Vt(t)}}const ee={flags:{}};class ae{constructor(){var t;this._flags={},this._flags=null!=(t=ee.flags)?t:{}}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new ae;return a.set(t),ae._instances[e]=a,a}static getFeatureFlags(t,e){const a=this.getInstance(e);return t.map((t=>"on"===(null==a?void 0:a._flags[t])))}get flags(){var t;return null!=(t=this.flags)?t:{}}set(t){var e;this._flags=S({},null!=(e=null==ee?void 0:ee.flags)?e:{},null!=t?t:{})}}ae._instances={};class ne extends te{constructor(t){super(t),this.loadFeatureFlags=async()=>this.get(kt)}}const se=new ne("default"),ie="FRONTEGG_SEPARATE_TABS_BY_TENANT",oe="admin_portal_use_current_user_tenants_v1_endpoint";class re extends te{constructor(t){super(t),this.GetUserJwt=async t=>this.post(`${Y.v3}/me/token`,t),this.getUsersV2=async(t,e)=>this.get(Y.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersV3=async(t,e)=>this.get(Y.v3,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersRoles=async(t,e)=>this.get(Y.roles.v3,S({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getUsersGroups=async(t,e)=>this.get(Y.groups.v3,S({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getCurrentUserTenantsV3=async t=>this.get(Y.tenants.me.v3,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getCurrentUserTenantsV1=async t=>this.get(Y.tenants.me.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.sendResetBreachedPasswordEmails=async()=>this.post(Y.passwords.resetBreachedPasswords.v1),this.updateUserProfileV2=async t=>this.put(`${Y.v2}/me`,t),this.unlockMe=async t=>this.post(`${Y.v3}/me/unlock`,t)}}const le=new re("default");function ce(t){t&&sessionStorage.setItem(ie,t)}function ue(){sessionStorage.removeItem(ie)}function de(t){return R.for(t).isSessionPerTenantEnabled()?sessionStorage.getItem(ie):null}function ge(t){if(R.for(t).shouldSkipUserLoad())return async()=>({tenants:[],activeTenant:{}});const e=new re(t),[a]=ae.getFeatureFlags([oe],t);return R.for(t).isSessionPerTenantEnabled()||a?e.getCurrentUserTenantsV1:e.getCurrentUserTenantsV3}class pe extends te{constructor(t){super(t),this.switchTenant=async t=>(R.for(this.appName).isSessionPerTenantEnabled()&&ce(t.tenantId),this.put(`${Y.v1}/tenant`,t)),this.getTenants=async()=>this.get(`${Y.v2}/me/tenants`),this.getSubTenants=async t=>this.get(yt.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getSubTenantsAsTree=async t=>this.get(yt.tree.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenants=async t=>this.get(yt.parents.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenantsById=async(t,e)=>this.get(`${yt.parents.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getTenantsUsersCount=async(t,e)=>this.post(`${et.users.v1}/count`,t,{headers:this.extractHeadersFromOptions(e)}),this.searchSubTenants=async(t,e)=>this.get(yt.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getHierarchyMetadata=async(t,e)=>this.get(yt.metadata.v2,S({},t,{_tenantIds:t._tenantIds.join(",")}),{headers:this.extractHeadersFromOptions(e)})}}const he=new pe("default");class ye extends te{constructor(t){super(t),this.loadEntitlementsV2=async()=>this.get(Rt)}}const ve=new ye("default");class Se extends te{constructor(t){super(t),this.getGlobalSecurityPolicy=async()=>this.get(X.v1),this.getMfaPolicy=async()=>this.get(`${X.v1}/mfa-policy`),this.getVendorMfaPolicy=async()=>this.get(`${X.v1}/mfa-policy/vendor`),this.saveMfaPolicy=async t=>t.id?this.patch(`${X.v1}/mfa-policy`,t):this.post(`${X.v1}/mfa-policy`,t),this.getLockoutPolicy=async()=>this.get(`${X.v1}/lockout-policy`),this.getVendorLockoutPolicy=async()=>this.get(`${X.v1}/lockout-policy/vendor`),this.saveLockoutPolicy=async t=>t.id?this.patch(`${X.v1}/lockout-policy`,t):this.post(`${X.v1}/lockout-policy`,t),this.getCaptchaPolicy=async()=>{try{return await this.get(`${X.v1}/captcha-policy/public`)}catch{return null}},this.getPasswordHistoryPolicy=async()=>this.get(`${X.v1}/password-history-policy`),this.getVendorPasswordHistoryPolicy=async()=>this.get(`${X.v1}/password-history-policy/vendor`),this.savePasswordHistoryPolicy=async t=>t.id?this.patch(`${X.v1}/password-history-policy`,t):this.post(`${X.v1}/password-history-policy`,t),this.getPasswordRotationPolicy=async()=>{try{return await this.get(`${X.v1}/password-rotation`)}catch(t){return{}}},this.getVendorPasswordRotationPolicy=async()=>{try{return await this.get(`${X.v1}/password-rotation/vendor`)}catch(t){return{}}},this.savePasswordRotationPolicy=async t=>this.post(`${X.v1}/password-rotation`,t),this.getPasswordConfigPolicy=async()=>this.get(`${X.v1}/password`),this.getDomainRestrictions=async()=>this.get(`${Q.emailDomain.v1}`),this.getDomainRestrictionsConfig=async()=>this.get(`${Q.emailDomain.v1}/config`),this.createDomainRestriction=async t=>this.post(`${Q.emailDomain.v1}`,t),this.updateDomainRestrictionConfig=async t=>this.post(`${Q.emailDomain.v1}/config`,t),this.deleteDomainRestriction=async t=>this.delete(`${Q.emailDomain.v1}/${t}`),this.getIPRestrictions=async t=>this.get(`${Q.ip.v1}`,t),this.getIPRestrictionsConfig=async()=>this.get(`${Q.ip.v1}/config`),this.createIPRestriction=async t=>this.post(`${Q.ip.v1}`,t),this.bulkCreateIPRestriction=async t=>this.post(`${Q.ip.v1}/bulk`,t),this.updateIPRestrictionConfig=async t=>this.post(`${Q.ip.v1}/config`,t),this.deleteIPRestriction=async t=>this.delete(`${Q.ip.v1}/${t}`),this.testCurrentIp=async()=>this.post(`${Q.ip.v1}/verify`),this.testCurrentIpInAllowList=async()=>this.post(`${Q.ip.v1}/verify/allow`)}}const fe=new Se("default"),me=["type"],be=["type"],Ae=["type"];class we extends te{constructor(t){super(t),this.tenantsApi=new pe(this.appName),this.entitlementsApi=new ye(this.appName),this.securityPolicy=new Se(this.appName),this.generateLoginResponse=async t=>{if(!t.accessToken)return t;const e=R.for(this.appName);e.setAccessToken(t.accessToken);const a=await this.getMeAndEntitlements(),n=S({},t,t.accessToken?qt(t.accessToken):{},a);return e.setUser(n),n},this.generateLoginResponseV2=async t=>{if(!t.accessToken)return{user:t};const e=R.for(this.appName);e.setAccessToken(t.accessToken);const[a,n]=await Promise.all([this.getMeAndEntitlements(),this.tenantsApi.getTenants()]),s=S({},t,t.accessToken?qt(t.accessToken):{},a);return e.setUser(s),{user:s,tenants:n}},this.generateLoginResponseV3=async t=>{const{accessToken:e}=t;if(!e)return{user:t};const a=R.for(this.appName);a.setAccessToken(e);const[n,s]=await Promise.all([this.getMeAndEntitlements(),ge(this.appName)()]),i=S({},t,e?qt(e):{},n);return a.isSessionPerTenantEnabled()&&ce(i.tenantId),a.setUser(i),{user:i,tenants:s.tenants,activeTenant:s.activeTenant}},this.generateLoginResponseFromOAuthResponse=async t=>{const e=R.for(this.appName);e.setAccessToken(t.id_token);const a=await this.getMeAndEntitlements(),n=t.id_token?qt(t.id_token):{},s=S({mfaRequired:!1,accessToken:t.id_token,refreshToken:t.refresh_token},n,a,{expiresIn:t.expires_in||300});return e.setUser(s),s},this.generateLoginResponseFromOAuthResponseV2=async t=>{const e=R.for(this.appName);e.setAccessToken(t.id_token);const[a,n]=await Promise.all([this.getMeAndEntitlements(),ge(this.appName)()]),s=t.id_token?qt(t.id_token):{},i=S({mfaRequired:!1,accessToken:t.id_token,refreshToken:t.refresh_token},s,a,{expiresIn:t.expires_in||300});return e.isSessionPerTenantEnabled()&&ce(i.tenantId),e.setUser(i),{user:i,tenants:n.tenants,activeTenant:n.activeTenant}},this.preLogin=async t=>{try{const{address:e}=await this.post(`${J.v1}/user/saml/prelogin`,t);return e}catch{return null}},this.preLoginWithIdpType=async t=>this.post(`${J.v1}/user/saml/prelogin`,t),this.postLogin=async t=>{const e=await this.post(`${J.v1}/user/saml/postlogin`,t);return this.generateLoginResponse(e)},this.oidcPostLogin=async t=>{const e=await this.post(`${J.v1}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.login=async t=>{const e=await this.post(`${J.v1}/user`,t);return this.generateLoginResponse(e)},this.loginv2=async t=>{const e=await this.post(`${J.v1}/user`,t);return this.generateLoginResponseV3(e)},this.loginWithMfa=async t=>{const e=await this.post(`${J.v1}/user/mfa/verify`,t);return this.generateLoginResponse(e)},this.loginWithMfaV2=async t=>{const e=await this.post(`${J.v1}/user/mfa/verify`,t);return this.generateLoginResponseV3(e)},this.activateAccount=async t=>this.post(`${Y.v1}/activate`,t),this.activateAccountV2=async t=>{const e=await this.post(`${Y.v1}/activate`,t);return this.generateLoginResponseV3(e)},this.activateAccountWithOTC=async t=>{const e=await this.post(`${Y.v1}/activate/code`,t);return this.generateLoginResponseV3(e)},this.getActivateAccountStrategy=async t=>this.get(`${Y.v1}/activate/strategy`,t),this.resendActivationEmail=async t=>this.post(`${Y.v1}/activate/reset`,t),this.resendInvitationEmail=async t=>this.post(`${Y.v1}/invitation/reset`,t),this.acceptInvitation=async t=>this.post(`${Y.v1}/invitation/accept`,t),this.acceptInvitationWithOTC=async t=>this.post(`${Y.v1}/invitation/accept/code`,t),this.refreshToken=async()=>{const t=de(this.appName),e=await this.post(`${J.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponse(e)},this.refreshTokenV2=async()=>{const t=de(this.appName),e=await this.post(`${J.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV2(e)},this.refreshTokenV3=async()=>{const t=de(this.appName),e=await this.post(`${J.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV3(e)},this.logout=async()=>this.post(`${J.v1}/logout`),this.OAuthLogout=async t=>this.get(`${It}/logout`,t),this.forgotPassword=async t=>this.post(`${Y.v1}/passwords/reset`,t),this.resetPassword=async t=>this.post(`${Y.v1}/passwords/reset/verify`,t),this.getPasswordRecoveryStrategies=async()=>this.get(`${X.v1}/password-recovery/strategies`),this.loadPasswordConfig=async t=>this.get(`${Y.v1}/passwords/config`,t),this.getSignUpStrategies=async()=>this.get(`${K.v1.strategies}`),this.recoverMfaToken=async t=>this.post(`${J.v1}/user/mfa/recover`,t),this.enrollMfa=async()=>this.post(`${Y.v1}/mfa/enroll`),this.preEnrollMFAAuthenticatorApp=async()=>this.post(`${Y.v1}/mfa/authenticator/enroll`),this.enrollMFAAuthenticatorApp=async t=>this.post(`${Y.v1}/mfa/authenticator/enroll/verify`,t),this.preEnrollMFASMS=async t=>this.post(`${Y.v1}/mfa/sms/enroll`,t),this.enrollMFASMS=async t=>this.post(`${Y.v1}/mfa/sms/enroll/verify`,t),this.preEnrollMFAWebAuthn=async()=>this.post(`${Y.v1}/mfa/webauthn/enroll`),this.enrollMFAWebAuthn=async t=>this.post(`${Y.v1}/mfa/webauthn/enroll/verify`,t),this.verifyMfa=async t=>this.post(`${Y.v1}/mfa/enroll/verify`,t),this.disableMfa=async t=>this.post(`${Y.v1}/mfa/disable`,t),this.disableMFAAuthenticatorApp=async(t,e)=>this.post(`${Y.v1}/mfa/authenticator/${t}/disable/verify`,e),this.preDisableMFASMS=async t=>this.post(`${Y.v1}/mfa/sms/${t}/disable`),this.disableMFASMS=async(t,e)=>this.post(`${Y.v1}/mfa/sms/${t}/disable/verify`,e),this.preDisableMFAWebAuthn=async t=>this.post(`${Y.v1}/mfa/webauthn/${t}/disable`),this.disableMFAWebAuthn=async(t,e)=>this.post(`${Y.v1}/mfa/webauthn/${t}/disable/verify`,e),this.getMFADevices=async()=>this.get(`${Y.v1}/mfa/devices`),this.preEnrollMFAAuthenticatorAppForLogin=async t=>this.post(`${J.v1}/user/mfa/authenticator/enroll`,t),this.enrollMFAAuthenticatorAppForLogin=async t=>this.post(`${J.v1}/user/mfa/authenticator/enroll/verify`,t),this.enrollMFAAuthenticatorAppForLoginV2=async t=>{const e=await this.post(`${J.v1}/user/mfa/authenticator/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.verifyMFAAuthenticatorAppForLogin=async(t,e)=>this.post(`${J.v1}/user/mfa/authenticator/${t}/verify`,e),this.preVerifyMFAEmailCode=async t=>this.post(`${J.v1}/user/mfa/emailcode`,t),this.verifyMFAEmailCode=async t=>this.post(`${J.v1}/user/mfa/emailcode/verify`,t),this.verifyMFAEmailCodeV2=async t=>{const e=await this.post(`${J.v1}/user/mfa/emailcode/verify`,t);return this.generateLoginResponseV3(e)},this.preEnrollMFASMSForLogin=async t=>this.post(`${J.v1}/user/mfa/sms/enroll`,t),this.enrollMFASMSForLogin=async t=>this.post(`${J.v1}/user/mfa/sms/enroll/verify`,t),this.enrollMFASMSForLoginV2=async t=>{const e=await this.post(`${J.v1}/user/mfa/sms/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFASMSForLogin=async(t,e)=>this.post(`${J.v1}/user/mfa/sms/${t}`,e),this.verifyMFASMSForLogin=async(t,e)=>this.post(`${J.v1}/user/mfa/sms/${t}/verify`,e),this.verifyMFASMSForLoginV2=async(t,e)=>{const a=await this.post(`${J.v1}/user/mfa/sms/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.preEnrollMFAWebAuthnForLogin=async t=>this.post(`${J.v1}/user/mfa/webauthn/enroll`,t),this.enrollMFAWebAuthnForLogin=async t=>this.post(`${J.v1}/user/mfa/webauthn/enroll/verify`,t),this.enrollMFAWebAuthnForLoginV2=async t=>{const e=await this.post(`${J.v1}/user/mfa/webauthn/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${J.v1}/user/mfa/webauthn/${t}`,e),this.verifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${J.v1}/user/mfa/webauthn/${t}/verify`,e),this.verifyMFAWebAuthnForLoginV2=async(t,e)=>{const a=await this.post(`${J.v1}/user/mfa/webauthn/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.getSamlConfiguration=async()=>this.get(`${ct.v1}/saml/configurations`),this.updateSamlConfiguration=async t=>this.post(`${ct.v1}/saml/configurations`,t),this.getSamlVendorConfiguration=async()=>this.get(`${ct.v1}/saml/configurations/vendor-config`),this.updateSamlVendorMetadata=async t=>this.put(`${ct.v1}/saml/configurations/metadata`,t),this.validateSamlDomain=async()=>this.put(`${ct.v1}/saml/validations/domain`),this.getSamlRoles=async()=>this.get(`${ct.v1}/saml/configurations/roles/default`),this.getSamlRolesGroups=async()=>this.get(`${ct.v2}/saml/configurations/groups`),this.updateSamlRoles=async({roleIds:t})=>this.post(`${ct.v1}/saml/configurations/roles/default`,{roleIds:t}),this.createSamlGroup=async({roleIds:t,group:e})=>this.post(`${ct.v2}/saml/configurations/groups`,{group:e,roleIds:t}),this.updateSamlGroup=async({roleIds:t,group:e,id:a})=>this.patch(`${ct.v2}/saml/configurations/groups/${a}`,{group:e,roleIds:t}),this.deleteSamlGroup=async({id:t})=>this.delete(`${ct.v2}/saml/configurations/groups/${t}`),this.getOidcConfiguration=async()=>this.get(`${ct.v1}/oidc/configurations`),this.getSSOPublicConfiguration=async()=>this.get(`${ct.v2}/configurations/public`),this.getSocialLoginProviders=async()=>this.get(Z.v1),this.getSocialLoginProvidersV2=async()=>this.get(Z.v2),this.getSocialLoginProvidersV2ForAuthenticatedUser=async()=>this.get(`${Z.v2}/authenticated`),this.getCustomSocialLoginProvidersV1=async()=>this.get(Z.custom.v1),this.loginViaSocialLogin=async t=>{const e={};return t.code&&(e.code=t.code),t.idToken&&(e.id_token=t.idToken),t.redirectUri&&(e.redirectUri=t.redirectUri),t.codeVerifier&&(e.code_verifier=t.codeVerifier),t.codeVerifierPkce&&(e.code_verifier_pkce=t.codeVerifierPkce),t.state&&(e.state=t.state),this.post(`${J.v1}/user/sso/${t.provider}/postlogin`,{metadata:t.metadata,invitationToken:t.invitationToken},{params:e})},this.getVendorConfig=async()=>this.get(`${X.v1}/public`),this.signUpUser=async t=>{const{shouldActivate:e,authResponse:a,userId:n,tenantId:s,activationToken:i}=await this.post(`${Y.v1}/signUp`,t),o={shouldActivate:e,userId:n,tenantId:s};if(!e&&a){const{user:t,tenants:e,activeTenant:n}=await this.generateLoginResponseV3(a);return S({},o,{user:t,tenants:e,activeTenant:n})}return S({},o,{activationToken:i})},this.signUpUserWithPhoneNumber=async t=>{const{shouldActivate:e,authResponse:a,userId:n,tenantId:s,activationToken:i}=await this.post(`${Y.v1}/signUp/phoneNumber`,t),o={shouldActivate:e,userId:n,tenantId:s};if(!e&&a){const{user:t,tenants:e,activeTenant:n}=await this.generateLoginResponseV3(a);return S({},o,{user:t,tenants:e,activeTenant:n})}return S({},o,{activationToken:i})},this.getCurrentUserSessions=async()=>this.get(Y.sessions.currentUser.v1),this.getCurrentUserSession=async()=>this.get(`${Y.sessions.currentUser.v1}/current`),this.revokeSessionsForUser=async t=>this.post(`${Y.sessions.v1}/revoke`,{userId:t}),this.getSessionConfigurations=async()=>this.get(Y.sessions.configurations.v1),this.createOrUpdateSessionConfigrations=async t=>{await this.post(Y.sessions.configurations.v1,t)},this.deleteSessionForUser=async t=>{await this.delete(`${Y.sessions.currentUser.v1}/${t}`)},this.deleteAllSessionsForUser=async()=>{await this.delete(`${Y.sessions.currentUser.v1}/all`)},this.getUserAccessTokensData=async()=>this.get(Y.accessTokens.v1),this.getTenantAccessTokensData=async()=>this.get(et.accessTokens.v1),this.deleteTenantAccessToken=async({id:t})=>{await this.delete(`${et.accessTokens.v1}/${t}`)},this.deleteUserAccessToken=async({id:t})=>{await this.delete(`${Y.accessTokens.v1}/${t}`)},this.createUserAccessToken=async t=>this.post(Y.accessTokens.v1,t),this.createTenantAccessToken=async t=>this.post(et.accessTokens.v1,t),this.getUserApiTokensData=async()=>this.get(Y.apiTokens.v1),this.getTenantApiTokensData=async()=>this.get(et.apiTokens.v1),this.updateUserApiTokensData=async t=>this.post(Y.apiTokens.v1,t),this.updateTenantApiTokensData=async t=>this.post(et.apiTokens.v2,t),this.deleteTenantApiToken=async({tokenId:t})=>{await this.delete(`${et.apiTokens.v1}/${t}`)},this.deleteUserApiToken=async({tokenId:t})=>{await this.delete(`${Y.apiTokens.v1}/${t}`)},this.getUserById=async({userId:t})=>this.get(`${Y.v1}/${t}`),this.checkIfAllowToRememberMfaDevice=async t=>this.get(`${X.v1}/mfa-policy/allow-remember-device`,{mfaToken:t}),this.passwordlessPreLogin=async t=>{var e;let{type:a}=t,n=f(t,me);const s=(null==(e={[N.UsernameAndCode]:N.Code,[N.UsernameAndMagicLink]:N.MagicLink,[N.UsernameAndSms]:N.SmsCode,[N.UsernameAndPassword]:N.EmailAndPassword}[a])?void 0:e.toLowerCase())||a.toLowerCase();return this.post(`${J.v1}/passwordless/${s}/prelogin`,n)},this.passwordlessPostLoginV2=async t=>{let{type:e}=t,a=f(t,be);const n=await this.post(`${J.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a);return this.generateLoginResponseV3(n)},this.passwordlessPostLogin=async t=>{let{type:e}=t,a=f(t,Ae);return this.post(`${J.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a)},this.verifyInviteToken=async({token:t})=>this.post(et.invites.verify.v1,{token:t}),this.getSSOConfigurations=async()=>this.get(`${ct.v1}/configurations`),this.createSSOConfiguration=async t=>this.post(`${ct.v1}/configurations`,t),this.updateSSOConfiguration=async(t,e)=>this.patch(`${ct.v1}/configurations/${t}`,e),this.deleteSSOConfiguration=async t=>{await this.delete(`${ct.v1}/configurations/${t}`)},this.createSSOConfigurationByMetadata=async t=>this.post(`${ct.v1}/configurations/metadata`,t),this.updateSSOConfigurationByMetadata=async(t,e)=>this.put(`${ct.v1}/configurations/${t}/metadata`,e),this.createSSOConfigurationByMetadataUrl=async t=>this.post(`${ct.v1}/configurations/metadata-url`,t),this.updateSSOConfigurationByMetadataUrl=async(t,e)=>this.put(`${ct.v1}/configurations/${t}/metadata-url`,e),this.createSSODomain=async(t,e)=>this.post(`${ct.v1}/configurations/${t}/domains`,e),this.deleteSSODomain=async(t,e)=>this.delete(`${ct.v1}/configurations/${t}/domains/${e}`),this.validateSSODomain=async(t,e)=>this.put(`${ct.v1}/configurations/${t}/domains/${e}/validate`),this.validateSSODomainV2=async(t,e)=>this.put(`${ct.v2}/configurations/${t}/domains/${e}/validate`),this.getSSODefaultRoles=async t=>this.get(`${ct.v1}/configurations/${t}/roles`),this.setSSODefaultRoles=async(t,e)=>this.put(`${ct.v1}/configurations/${t}/roles`,e),this.createSSOGroup=async(t,e)=>this.post(`${ct.v1}/configurations/${t}/groups`,e),this.updateSSOGroup=async(t,{roleIds:e,group:a,id:n})=>this.patch(`${ct.v1}/configurations/${t}/groups/${n}`,{group:a,roleIds:e}),this.deleteSSOGroup=async(t,e)=>this.delete(`${ct.v1}/configurations/${t}/groups/${e}`),this.getSSOGroups=async t=>this.get(`${ct.v1}/configurations/${t}/groups`),this.preLoginV2=async t=>this.post(`${J.v2}/user/sso/prelogin`,t),this.oidcPostLoginV2=async t=>{const e=await this.post(`${J.v2}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.exchangeOAuthTokensV2=async t=>{const e=await this.post(`${It}/token`,t);return this.generateLoginResponseFromOAuthResponseV2(e)},this.silentOAuthRefreshTokenV2=async()=>{const t=de(this.appName),e=await this.post(`${It}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponseV2(e)},this.exchangeOAuthTokens=async t=>{const e=await this.post(`${It}/token`,t);return this.generateLoginResponseFromOAuthResponse(e)},this.silentOAuthRefreshToken=async()=>{const t=de(this.appName),e=await this.post(`${It}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponse(e)},this.resetPhoneNumber=async t=>this.post(`${Y.v1}/phone/reset`,t),this.verifyResetPhoneNumber=async t=>this.post(`${Y.v1}/phone/reset/verify`,t),this.changePhoneNumberWithVerification=async t=>this.post(`${Y.v1}/phone`,t),this.verifyChangePhoneNumber=async t=>this.post(`${Y.v1}/phone/verify`,t),this.changePhoneNumber=async t=>this.put(`${Y.v1}/phone/change`,t),this.webAuthnPreLogin=async t=>this.post(`${J.v1}/webauthn/prelogin`,t),this.webAuthnPostLogin=async t=>this.post(`${J.v1}/webauthn/postlogin`,t),this.webAuthnPostLoginV2=async t=>{const e=await this.post(`${J.v1}/webauthn/postlogin`,t);return this.generateLoginResponseV3(e)},this.webAuthnCreateNewDeviceSession=async()=>this.post(q.v1),this.getWebAuthnDevices=async()=>this.get(q.v1),this.deleteWebAuthnDevice=async t=>this.delete(`${q.v1}/${t}`),this.verifyNewDeviceSession=async t=>this.post(`${q.v1}/verify`,t),this.getVendorPublicAuthStrategiesConfig=async()=>this.get(`${X.v1}/auth/strategies/public`),this.getPublicAuthStrategiesConfigForAuthenticatedUser=async()=>this.get(`${X.v1}/auth/strategies`),this.getMFAStrategiesConfig=async()=>this.get(`${X.v1}/mfa/strategies`),this.getUserAuthorization=async()=>this.get(`${Y.authorization.v1}`),this.getMeV2=async()=>this.get(`${Y.v2}/me`),this.noThrowLoadEntitlements=async()=>{try{return await this.entitlementsApi.loadEntitlementsV2()}catch(t){}},this.getMeAndEntitlements=async()=>{if(R.for(this.appName).shouldSkipUserLoad())return{roles:[],permissions:[],groups:[],tenants:[]};const t=[{action:this.getMeV2,shouldLoad:!0},{action:this.noThrowLoadEntitlements,shouldLoad:this.shouldLoadEntitlements()},{action:this.getUserAuthorization,shouldLoad:this.shouldLoadMeAuthorization()}].map((t=>async function({shouldLoad:t,action:e}){if(t)return await e()}(t))),[e,a,n]=await Promise.all(t),s=de(this.appName);return s&&(e.tenantId=s),S({},e,null!=n?n:{},{entitlements:a})},this.generateStepupSession=async t=>{const e=await this.post(`${J.v1}/user/step-up/generate`,t);return e.accessToken?this.generateLoginResponseV3(e):e},this.getGlobalSecurityPolicy=this.securityPolicy.getGlobalSecurityPolicy.bind(this.securityPolicy),this.getMfaPolicy=this.securityPolicy.getMfaPolicy.bind(this.securityPolicy),this.getVendorMfaPolicy=this.securityPolicy.getVendorMfaPolicy.bind(this.securityPolicy),this.saveMfaPolicy=this.securityPolicy.saveMfaPolicy.bind(this.securityPolicy),this.getLockoutPolicy=this.securityPolicy.getLockoutPolicy.bind(this.securityPolicy),this.getVendorLockoutPolicy=this.securityPolicy.getVendorLockoutPolicy.bind(this.securityPolicy),this.saveLockoutPolicy=this.securityPolicy.saveLockoutPolicy.bind(this.securityPolicy),this.getCaptchaPolicy=this.securityPolicy.getCaptchaPolicy.bind(this.securityPolicy),this.getPasswordHistoryPolicy=this.securityPolicy.getPasswordHistoryPolicy.bind(this.securityPolicy),this.getVendorPasswordHistoryPolicy=this.securityPolicy.getVendorPasswordHistoryPolicy.bind(this.securityPolicy),this.savePasswordHistoryPolicy=this.securityPolicy.savePasswordHistoryPolicy.bind(this.securityPolicy),this.getPasswordConfigPolicy=this.securityPolicy.getPasswordConfigPolicy.bind(this.securityPolicy),this.getDomainRestrictions=this.securityPolicy.getDomainRestrictions.bind(this.securityPolicy),this.getDomainRestrictionsConfig=this.securityPolicy.getDomainRestrictionsConfig.bind(this.securityPolicy),this.createDomainRestriction=this.securityPolicy.createDomainRestriction.bind(this.securityPolicy),this.updateDomainRestrictionConfig=this.securityPolicy.updateDomainRestrictionConfig.bind(this.securityPolicy),this.deleteDomainRestriction=this.securityPolicy.deleteDomainRestriction.bind(this.securityPolicy),this.getIPRestrictions=this.securityPolicy.getIPRestrictions.bind(this.securityPolicy),this.getIPRestrictionsConfig=this.securityPolicy.getIPRestrictionsConfig.bind(this.securityPolicy),this.createIPRestriction=this.securityPolicy.createIPRestriction.bind(this.securityPolicy),this.bulkCreateIPRestriction=this.securityPolicy.bulkCreateIPRestriction.bind(this.securityPolicy),this.updateIPRestrictionConfig=this.securityPolicy.updateIPRestrictionConfig.bind(this.securityPolicy),this.deleteIPRestriction=this.securityPolicy.deleteIPRestriction.bind(this.securityPolicy),this.testCurrentIp=this.securityPolicy.testCurrentIp.bind(this.securityPolicy),this.testCurrentIpInAllowList=this.securityPolicy.testCurrentIpInAllowList.bind(this.securityPolicy)}shouldLoadEntitlements(){return R.for(this.appName).shouldLoadEntitlements()}shouldLoadMeAuthorization(){const[t]=ae.getFeatureFlags([Zt],this.appName);return t}}const Te=new we("default");class Ee extends te{constructor(t){super(t),this.getProfile=async t=>this.get(`${Y.v2}/me`,null!=t?t:{addRoles:!0}),this.updateEmail=async t=>this.post(`${Y.v1}/email/me`,{email:t}),this.verifyEmail=async(t,e)=>this.post(`${Y.v1}/email/me/verify`,{email:t,code:e}),this.updateProfile=async t=>this.put(`${Y.v2}/me`,t),this.updateProfileImage=async t=>this.put(`${pt.v1}/me/image/v1`,t,{responseType:"plain",contentType:void 0}),this.changePassword=async t=>this.post(`${Y.v1}/passwords/change`,t),this.loadUsers=async t=>{var e,a,n,s,i,o;const r=(t.filter||[]).reduce(((t,e)=>S({},t,{[e.id]:e.value})),{}),l=null!=(e=t.sort)&&e.length?{sortBy:null!=(a=null==(n=t.sort)||null==(s=n[0])?void 0:s.id)?a:"name",sortDirection:null!=(i=t.sort)&&null!=(o=i[0])&&o.desc?"desc":"asc"}:null;return this.get(ut.v1,S({pageOffset:t.pageOffset,pageSize:t.pageSize},r,l))},this.addUser=async t=>this.post(Y.v2,S({},t,{provider:"local"})),this.deleteUser=async t=>this.delete(`${ut.v1}/${t.userId}`),this.updateUser=async t=>this.put(ut.v1,t),this.updateUserExpirationTime=async t=>{const{userId:e,expirationInSeconds:a}=t;return this.put(`${Y.temporary.v1}/${e}`,{expirationInSeconds:a})},this.setPermanentUser=async t=>this.delete(`${Y.temporary.v1}/${t}`),this.getTemporaryUserConfiguration=async()=>this.get(Y.temporary.configuration.v1),this.createInviteUserLink=async t=>this.post(et.invites.user.v1,S({},t)),this.updateInviteUserLink=async t=>this.patch(et.invites.user.v1,S({},t)),this.deleteInviteUserLink=async()=>this.delete(et.invites.user.v1),this.getInviteUserLink=async()=>this.get(et.invites.user.v1),this.getInviteLinkConfiguration=async()=>this.get(et.invites.configuration.v1),this.loadAvailableRoles=async()=>this.get(dt.v1),this.loadAvailablePermissions=async()=>this.get(tt.v1),this.loadStats=async()=>this.get(`${gt.v1}/members`),this.resendActivationLink=async t=>this.post(`${ut.v1}/${t.userId}/resendActivationEmail`,{}),this.resendInvitationLink=async t=>this.post(Y.v2,S({},t,{provider:"local"})),this.resendInvitationLinkToAllTenants=async t=>this.post(Y.invitation.resendAll.v1,S({},t)),this.disableUser=async t=>this.post(`${et.users.v1}/${t}/disable`),this.enableUser=async t=>this.post(`${et.users.v1}/${t}/enable`)}}const Pe=new Ee("default");class Oe extends te{constructor(t){super(t),this.getMetadata=async t=>{var e,a;const n=await this.get("/metadata",t);if(null!=n&&null!=(e=n.rows)&&e[0])return null==n||null==(a=n.rows)?void 0:a[0];throw new Error(`metadata not found: ${t.entityName}`)},this.getAdminBoxMetadata=async()=>this.get("/metadata/admin-box"),this.updateAdminBoxMetadata=async t=>this.post("/metadata/admin-box",t),this.getIpMetadata=async t=>{const e=await this.get(`/metadata/ip/${t}`);if(e)return e;throw new Error("ip metadata not found")},this.getCurrentUserIpMetadata=async()=>{const t=await this.get("/metadata/ipme");if(t)return t;throw new Error("ip metadata not found")},this.getNotificationsMetadata=async()=>this.getMetadata({entityName:"notifications"}),this.getSamlMetadata=async()=>this.getMetadata({entityName:"saml"}),this.getAuditsMetadata=async()=>this.getMetadata({entityName:"audits"}),this.getIpAdressMetadata=async t=>this.getIpMetadata(t)}}const Ie=new Oe("default"),ke=["dataFilters"],_e=["templateId","dataFilters"],Ue=["dataFilters"];class Re extends te{constructor(t){super(t),this.getReports=async t=>this.get(`${At.v2}/tenant-reports`,t),this.getReport=async t=>this.get(`${At.v2}/${t.id}/tenant-reports`),this.renderReport=async t=>{let{dataFilters:e}=t,a=f(t,ke);return{html:await this.get(`${wt.v1}/preview-report`,S({},a,{dataFilters:btoa(JSON.stringify(e||{})),responseType:"html"}),{responseType:"plain"})}},this.scheduleReport=async t=>{let{templateId:e,dataFilters:a}=t,n=f(t,_e);return this.post(`${At.v2}/${e}/tenant-reports`,S({},n,{dataFilters:btoa(JSON.stringify(a||{}))}))},this.downloadReport=async t=>{let{dataFilters:e}=t,a=f(t,Ue);const n=await this.get(`${wt.v1}/preview-report`,S({},a,{dataFilters:btoa(JSON.stringify(e||{}))}),{responseType:"blob"});let s="text/html",i="html";"pdf"===a.responseType?(s="application/pdf",i="pdf"):"image"===a.responseType&&(s="image/jpeg",i="jpg");const o=new Blob([n],{type:s}),r=URL.createObjectURL(o),l=document.createElement("a");l.href=r,l.setAttribute("download",`report_${a.name||""}.${i}`),l.click(),setTimeout(l.remove.bind(l))},this.sendReport=async t=>this.post(`${wt.v1}/tenant-reports`,t)}}const Ce=new Re("default"),Le=["eventKey"],De=["eventKey"];class Ne extends te{constructor(t){super(t),this.getSlackConfiguration=()=>this.get(`${St.v1}/slack`),this.getSlackScope=()=>this.get(`${St.v1}/slack/applications`),this.getSlackChannels=()=>this.get(`${St.v1}/slack/channels`),this.postSlackConfiguration=t=>t.id?this.patch(`${St.v1}/slack/subscription/${t.id}`,t):this.post(`${St.v1}/slack/subscriptions`,t),this.deleteSlackConfiguration=t=>this.delete(`${St.v1}/slack/subscriptions/${t.id}`),this.postSlackCode=t=>this.post(`${St.v1}/slack/applications/registrations`,{code:t}),this.getEmailConfiguration=()=>this.get(`${St.v1}/emails`),this.postEmailConfiguration=t=>{let{eventKey:e}=t,a=f(t,Le);return this.post(`${St.v1}/emails/${e}`,a)},this.patchEmailConfiguration=({eventKey:t,enabled:e})=>this.patch(`${St.v1}/emails/${t}`,{enabled:e}),this.deleteEmailSubscriptions=(t,e)=>this.delete(`${St.v1}/emails/${t}/subscriptions/${e}`),this.putEmailSubscriptions=(t,e,a)=>this.put(`${St.v1}/emails/${e}/subscriptions/${t}`,a),this.deleteEmailConfiguration=t=>this.delete(`${St.v1}/emails/${t}`),this.getSMSConfiguration=()=>this.get(`${St.v2}/sms`),this.postSMSConfiguration=t=>{let{eventKey:e}=t,a=f(t,De);return this.post(`${St.v2}/sms/${e}`,a)},this.patchSMSConfiguration=({eventKey:t,enabled:e})=>this.patch(`${St.v2}/sms/${t}`,{enabled:e}),this.deleteSMSSubscriptions=(t,e)=>this.delete(`${St.v2}/sms/${t}/subscriptions/${e}`),this.putSMSSubscriptions=(t,e,a)=>this.put(`${St.v2}/sms/${e}/subscriptions/${t}`,a),this.deleteSMSConfiguration=t=>this.delete(`${St.v2}/sms/${t}`),this.getWebhooksConfigurations=()=>this.get(Ot),this.postWebhooksConfiguration=t=>t._id?this.patch(`${Ot}/${t._id}`,t):this.post(`${Ot}/custom`,t),this.deleteWebhooksConfiguration=t=>this.delete(`${Ot}/${t}`),this.getWebhookLog=(t,e=0,a=10)=>{const n=new URLSearchParams({id:t,offset:`${e}`,limit:`${a}`});return this.get(`${Ot}/logs/?${n.toString()}`)},this.postWebhookTest=t=>this.post(`${Ot}/test`,t),this.postWebhookRetry=t=>this.post(`${Ot}/logs/${t}/retries`),this.getCategories=()=>this.get(`${Pt.v1}/categories`),this.getChannelMaps=t=>this.get(Pt.v1,{channels:t})}}const Me=new Ne("default");class Fe extends te{constructor(t){super(t),this.getNotifications=async t=>this.get(Tt,{params:t}),this.updateNotificationStatus=async t=>this.put(`${Tt}/status`,{params:t}),this.updateNotificationIsPinned=async t=>{const{notificationId:e,pinStatus:a}=t;return this.put(`${Tt}/${a}`,{notificationId:e})},this.markAllAsRead=async()=>this.post(`${Tt}/status/mark-all-read`)}}const xe=new Fe("default"),$e=["endpoint","headerProps"];class Ge extends te{constructor(t){super(t),this.getAudits=async t=>this.get(Et,t),this.getAuditsStats=async t=>this.get(`${Et}/stats`,t),this.exportAudits=async t=>{const{endpoint:e,headerProps:a}=t,n=f(t,$e);return this.postDownload(`${Et}/export/${e}`,{properties:a},n)}}}const je=new Ge("default");class Be extends te{constructor(t){super(t),this.updateSettings=async(t,e)=>this.put(ht.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.getSettings=async t=>this.get(ht.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getPublicSettings=async()=>this.get(`${ht.v1}/public`)}}const Ve=new Be("default"),We=["roleId"],He=["roleId"],ze=["permissionId"];class Ke extends te{constructor(t){super(t),this.getRoles=async()=>this.get(at.v1),this.addRole=async t=>this.post(at.v1,t),this.deleteRole=async({roleId:t})=>this.delete(`${at.v1}/${t}`),this.updateRole=async t=>{let{roleId:e}=t,a=f(t,We);return this.patch(`${at.v1}/${e}`,a)},this.attachPermissionsToRole=async t=>{let{roleId:e}=t,a=f(t,He);return this.put(`${at.v1}/${e}/permissions`,a)},this.getPermissions=async()=>this.get(tt.v1),this.attachPermissionToRoles=async t=>{let{permissionId:e}=t,a=f(t,ze);return this.put(`${tt.v1}/${e}/roles`,a)},this.getPermissionCategories=async()=>this.get(`${tt.v1}/categories`),this.addRoleV2=async t=>this.post(at.v2,t)}}const qe=new Ke("default");class Je extends te{constructor(...t){super(...t),this.getSubscriptionInvoices=async()=>this.get(ft.invoices.v1),this.getSubscriptionInvoice=async t=>this.get(`${ft.invoices.v1}/${t}`),this.getSubscriptionInvoicePdf=async(t,e)=>this.get(`${ft.invoices.v1}/${t}/pdf`,{outputFileName:e},{responseType:"blob"})}}class Ye extends te{constructor(...t){super(...t),this.getManagedSubscription=async t=>this.get(`${bt.v1}/${t}`),this.getManagedSubscriptions=async()=>this.get(bt.v1),this.cancelManagedSubscription=async t=>this.put(`${bt.v1}/${t}/cancellations/`,{}),this.renewManagedSubscription=async t=>this.put(`${bt.v1}/${t}/renewals/`,{}),this.updateManagedSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${bt.v1}/${t}`,{paymentMethodId:e,planId:a})}}const Xe=["email"];class Qe extends te{constructor(...t){super(...t),this.getPaymentMethods=async()=>this.get(ft.paymentMethods.v1),this.getPaymentMethod=async t=>this.get(`${ft.paymentMethods.v1}/${t}`),this.updatePaymentMethodBillingDetails=async(t,e)=>{let{email:a}=e,n=f(e,Xe);return this.patch(`${ft.paymentMethods.v1}/${t}/billing-details`,{email:a,address:n})}}}class Ze extends te{constructor(...t){super(...t),this.getPaymentProviders=async()=>this.get(mt.v1)}}class ta extends te{constructor(...t){super(...t),this.getSubscriptionPlans=async()=>this.get(ft.plans.v1),this.getSubscriptionPlan=async t=>this.get(`${ft.plans.v1}/${t}`)}}class ea extends te{constructor(...t){super(...t),this.getSubscriptions=async()=>this.get(ft.subscriptions.v1),this.getSubscription=async t=>this.get(`${ft.subscriptions.v1}/${t}`),this.cancelSubscription=async t=>this.put(`${ft.subscriptions.v1}/${t}/cancellations/`,{}),this.renewSubscription=async t=>this.put(`${ft.subscriptions.v1}/${t}/renewals/`,{}),this.updateSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${ft.subscriptions.v1}/${t}`,{paymentMethodId:e,planId:a})}}class aa extends te{constructor(...t){super(...t),this.getSubscriptionSummaries=async t=>this.get(`${ft.summaries.v1}/${t}`)}}class na extends te{constructor(...t){super(...t),this.getTenantConfiguration=async t=>this.get(`${ft.tenantConfiguration.v1}/${t}`),this.createTenantConfiguration=async t=>this.post(ft.tenantConfiguration.v1,t)}}class sa extends te{constructor(...t){super(...t),this.getVendorPublicConfigurations=async()=>this.get(ft.configurations.vendorPublicConfigurations.v1)}}class ia extends te{constructor(...t){super(...t),this.createSubscription=async t=>this.post(ft.paymentProviders.stripe.subscriptions.v1,t),this.getStripeCustomer=async t=>this.get(`${ft.paymentProviders.stripe.customers.v1}/${t}`),this.createStripeCustomer=async t=>this.post(ft.paymentProviders.stripe.customers.v1,t),this.getStripePaymentProviderConfiguration=async()=>this.get(ft.paymentProviders.stripe.publicConfigurations.v1),this.createStripePaymentMethodSetupIntentSecret=async t=>this.post(ft.paymentProviders.stripe.setupIntents.v1,t)}}class oa extends te{constructor(t){super(t),this.invoicesApi=new Je(this.appName),this.managedSubscriptionApi=new Ye(this.appName),this.paymentMethodsApi=new Qe(this.appName),this.paymentProvidersApi=new Ze(this.appName),this.plansApi=new ta(this.appName),this.subscriptionApi=new ea(this.appName),this.summariesApi=new aa(this.appName),this.subscriptionTenantConfigApi=new na(this.appName),this.vendorPublicConfigApi=new sa(this.appName),this.stripeProviderApi=new ia(this.appName),this.getSubscriptionInvoices=this.invoicesApi.getSubscriptionInvoices.bind(this.invoicesApi),this.getSubscriptionInvoice=this.invoicesApi.getSubscriptionInvoice.bind(this.invoicesApi),this.getSubscriptionInvoicePdf=this.invoicesApi.getSubscriptionInvoicePdf.bind(this.invoicesApi),this.getManagedSubscription=this.managedSubscriptionApi.getManagedSubscription.bind(this.managedSubscriptionApi),this.getManagedSubscriptions=this.managedSubscriptionApi.getManagedSubscriptions.bind(this.managedSubscriptionApi),this.cancelManagedSubscription=this.managedSubscriptionApi.cancelManagedSubscription.bind(this.managedSubscriptionApi),this.renewManagedSubscription=this.managedSubscriptionApi.renewManagedSubscription.bind(this.managedSubscriptionApi),this.updateManagedSubscription=this.managedSubscriptionApi.updateManagedSubscription.bind(this.managedSubscriptionApi),this.getPaymentMethods=this.paymentMethodsApi.getPaymentMethods.bind(this.paymentMethodsApi),this.getPaymentMethod=this.paymentMethodsApi.getPaymentMethod.bind(this.paymentMethodsApi),this.updatePaymentMethodBillingDetails=this.paymentMethodsApi.updatePaymentMethodBillingDetails.bind(this.paymentMethodsApi),this.getPaymentProviders=this.paymentProvidersApi.getPaymentProviders.bind(this.paymentProvidersApi),this.getSubscriptionPlans=this.plansApi.getSubscriptionPlans.bind(this.plansApi),this.getSubscriptionPlan=this.plansApi.getSubscriptionPlan.bind(this.plansApi),this.getSubscriptions=this.subscriptionApi.getSubscriptions.bind(this.subscriptionApi),this.getSubscription=this.subscriptionApi.getSubscription.bind(this.subscriptionApi),this.cancelSubscription=this.subscriptionApi.cancelSubscription.bind(this.subscriptionApi),this.renewSubscription=this.subscriptionApi.renewSubscription.bind(this.subscriptionApi),this.updateSubscription=this.subscriptionApi.updateSubscription.bind(this.subscriptionApi),this.getSubscriptionSummaries=this.summariesApi.getSubscriptionSummaries.bind(this.summariesApi),this.getTenantConfiguration=this.subscriptionTenantConfigApi.getTenantConfiguration.bind(this.subscriptionTenantConfigApi),this.createTenantConfiguration=this.subscriptionTenantConfigApi.createTenantConfiguration.bind(this.subscriptionTenantConfigApi),this.getVendorPublicConfigurations=this.vendorPublicConfigApi.getVendorPublicConfigurations.bind(this.vendorPublicConfigApi),this.createSubscription=this.stripeProviderApi.createSubscription.bind(this.stripeProviderApi),this.getStripeCustomer=this.stripeProviderApi.getStripeCustomer.bind(this.stripeProviderApi),this.createStripeCustomer=this.stripeProviderApi.createStripeCustomer.bind(this.stripeProviderApi),this.getStripePaymentProviderConfiguration=this.stripeProviderApi.getStripePaymentProviderConfiguration.bind(this.stripeProviderApi),this.createStripePaymentMethodSetupIntentSecret=this.stripeProviderApi.createStripePaymentMethodSetupIntentSecret.bind(this.stripeProviderApi)}}const ra=new oa("default");class la extends te{constructor(t){super(t),this.getVendorPublicInfo=async()=>this.get("/vendors/public")}}const ca=new la("default");class ua extends te{constructor(t){super(t),this.loadAllUsers=async t=>this.get(nt.v1,t),this.addUserToTenantAndSubTenants=async t=>this.post(nt.v1,t),this.removeUserFromTenantAndSubTenants=async(t,e)=>this.delete(nt.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.addUserRolesForSubTenants=async(t,e,a)=>this.post(`${nt.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.removeUserRolesFromSubTenants=async(t,e,a)=>this.delete(`${nt.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.setUserRolesForSubTenants=async(t,e,a)=>this.patch(`${nt.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.createSubTenant=async(t,e)=>this.post(vt.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.deleteSubTenant=async(t,e)=>this.delete(`${vt.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.updateSubTenant=async({tenantId:t},e,a)=>this.patch(`${vt.v1}/${t}`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubTenantManagement=async({tenantId:t},e,a)=>this.put(`${vt.v1}/${t}/management`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubAccountAccess=async(t,e,a)=>this.put(`${nt.v1}/${t}/access`,e,{headers:this.extractHeadersFromOptions(a)}),this.addUsersToSubTenant=async(t,e)=>this.post(`${nt.v2}/`,t,{headers:this.extractHeadersFromOptions(e)})}updateSubTenantHierarchySettings({tenantId:t},e,a){return this.put(`${vt.v1}/${t}/hierarchy-settings`,e,{headers:this.extractHeadersFromOptions(a)})}}const da=new ua("default");class ga extends te{constructor(t){super(t),this.getConfigs=async()=>this.get(`${_t}`),this.updateConfiguration=async(t,e)=>this.patch(`${_t}/${t}`,e),this.createConfiguration=async t=>this.post(`${_t}`,t),this.deleteConfiguration=async(t,e)=>this.delete(`${_t}/${t}`,{deleteAll:e}),this.countConfigurationUsers=async t=>this.get(`${Ut}/${t}/Users/count`)}}const pa=new ga("default");class ha extends te{constructor(t){super(t),this.impersonate=async t=>this.post(`${st.v1}`,t)}}const ya=new ha("default"),va=["groupId"];class Sa extends te{constructor(t){super(t),this.getGroupById=async({groupId:t},e)=>this.get(`${ot.v1}/${t}`,S({},e)),this.getGroups=async t=>this.get(`${ot.v1}`,S({},t)),this.getGroupsByIds=async(t,e)=>this.post(`${ot.getByIds.v1}`,t,{params:e}),this.createGroup=async t=>this.post(`${ot.v1}`,t),this.updateGroup=async t=>{let{groupId:e}=t,a=f(t,va);return this.patch(`${ot.v1}/${e}`,a)},this.deleteGroup=async t=>this.delete(`${ot.v1}/${t}`),this.addRolesToGroup=async(t,e)=>this.post(`${ot.v1}/${t}/roles`,e),this.deleteRolesFromGroup=async(t,e)=>this.delete(`${ot.v1}/${t}/roles`,e),this.addUsersToGroup=async(t,e)=>this.post(`${ot.v1}/${t}/users`,e),this.deleteUsersFromGroup=async(t,e)=>this.delete(`${ot.v1}/${t}/users`,e),this.getGroupConfiguration=async()=>this.get(`${ot.configurations.v1}`),this.updateGroupConfiguration=async t=>this.post(`${ot.configurations.v1}`,t)}}const fa=new Sa("default");class ma extends te{constructor(t){super(t),this.getRecommendations=async()=>this.get(Ct.v1),this.getInsights=async()=>this.get(Lt.v1)}}const ba=new ma("default");class Aa extends te{constructor(t){super(t),this.getUserPhoneNumbers=async t=>this.get(`${rt.v1}`,t),this.getUserOwnPhoneNumbers=async()=>this.get(`${rt.v1}/me`),this.createPhoneNumber=async t=>this.post(`${rt.v1}`,t),this.deletePhoneNumber=async t=>this.delete(`${rt.v1}/${t}`),this.preVerifyPhoneNumber=async t=>this.post(`${rt.v1}/preverify`,t),this.verifyPhoneNumber=async t=>this.post(`${rt.v1}/verify`,t),this.verifyDeletePhoneNumber=async(t,e)=>this.post(`${rt.v1}/${t}/delete/verify`,e)}}const wa=new Aa("default");class Ta extends te{constructor(t){super(t),this.getUserApplicationsId=async({userId:t})=>this.get(`${it.v1}/${t}/apps`),this.getUsersApplicationsId=async({userIds:t})=>this.get(`${it.v1}/users-apps`,{userIds:t.join(",")}),this.getTenantsApplications=async()=>this.get(Nt.v1),this.getApplicationsData=async({appIds:t,includeFreeAccess:e=!0})=>this.get(Dt,{ids:t.join(","),_includeFreeAccess:e}),this.assignUserToApplications=async t=>this.post(`${it.v1}/apps-user`,t),this.unassignUserFromApplications=async t=>this.delete(`${it.v1}/user-apps`,t),this.getUsersOfApplications=async({appIds:t})=>this.get(`${it.v1}/apps-users`,{appIds:t.join(",")})}}const Ea=new Ta("default"),Pa={"x-frontegg-api-key":"my-frontegg-api-key","frontegg-vendor-id":"04ae2174-d8d9-4a90-8bab-2548e210a508","frontegg-tenant-id":"02e6ab6f-8b25-48e4-b06d-2c53745ce213","frontegg-user-id":"e5c397a1-7120-4753-9216-e5d7f35d1f2d"};class Oa extends te{constructor(t){super(t),this.getAgentsConfig=async()=>this.get(`${Mt}/config`,void 0,{headers:Pa}),this.getConversations=async()=>this.get(`${Mt}/conversations`,void 0,{headers:Pa}),this.getConversationById=async t=>this.get(`${Mt}/conversation/${t.id}`,void 0,{headers:Pa}),this.createConversation=async t=>this.post(`${Mt}/conversations`,{message:t.message,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:Pa}),this.sendMessage=async t=>this.post(`${Mt}/conversation/${t.conversationId}/messages`,{message:t.message,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:Pa}),this.sendApiResponse=async t=>this.post(`${Mt}/conversation/${t.conversationId}/response/${t.callId}`,{data:t.data,status:t.status,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:Pa}),this.getConversationResource=async t=>this.get(`${Mt}/conversation/${t.conversationId}/resource/${t.resourceId}`,void 0,{headers:Pa})}}const Ia=new Oa("default");class ka extends te{constructor(t){super(t),this.getUserOwnUsername=async()=>this.get(`${lt.v1}/me`),this.createUsername=async t=>this.post(`${lt.v1}`,t),this.deleteUsername=async t=>this.delete(`${lt.v1}/${t}`)}}const _a=new ka("default");class Ua extends te{constructor(t){super(t),this.getUserEmailPolicyConfig=async()=>this.get(`${X.v1}/user-emails-policy`)}}const Ra=new Ua("default");let Ca,La,Da,Na,Ma;!function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}(Ca||(Ca={})),function(t){t.createdAt="createdAt",t.name="name",t.tenantId="tenantId"}(La||(La={})),function(t){t.CUSTOMER="customer",t.SPAM="spam",t.TEST="test",t.RESELLER="reseller",t.HEADQUARTER="headquarter"}(Da||(Da={})),function(t){t.NEVER="NEVER",t.ALWAYS="ALWAYS",t.ASSIGNABLE="ASSIGNABLE"}(Na||(Na={})),function(t){t.DEFAULT_OFF="defaultOff",t.DEFAULT_ON="defaultOn",t.ALWAYS_ON="alwaysOn"}(Ma||(Ma={}));const Fa=[/^(.*)\/logout$/g,"/logout",/^\/identity\/resources\/auth\/v[0-9]*\/user\/[^\/]*\/postlogin$/g,/^\/identity\/resources\/impersonation\/v[0-9]$/g,/^\/identity\/resources\/auth\/v[0-9]*\/passwordless\/[^\/]*\/postlogin$/g,/^\/identity\/resources\/auth\/v[0-9]*\/webauthn\/postlogin$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/token\/refresh$/g,/^\/identity\/resources\/users\/v[0-9]*\/signUp$/g,/^\/identity\/resources\/users\/v[0-9]*\/activate$/g,/^\/identity\/resources\/users\/v[0-9]*\/invitation\/accept$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/verify$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/[^\/]*\/[^\/]*\/verify$/g,/^\/oauth\/token$/g,/^\/oauth\/authorize\/silent$/g],xa=`${J.v1}/user/token/refresh`,$a=`${It}/authorize/silent`,Ga=`${Y.v2}/me`,ja=`${Y.v2}/me/tenants`,Ba=`${Y.v3}/me/tenants`,Va=Rt;let Wa,Ha,za,Ka,qa;!function(t){t.FRONTEGG="frontegg",t.OKTA="okta",t.AZURE_AD="azure-ad",t.OTHER="other"}(Wa||(Wa={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(Ha||(Ha={})),function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}(za||(za={})),function(t){t.createdAt="createdAt",t.name="name",t.email="email",t.id="id",t.verified="verified",t.isLocked="isLocked",t.provider="provider",t.tenantId="tenantId"}(Ka||(Ka={})),function(t){t.MFA_UNENROLLED="mfa-unenrolled",t.BREACHED_PASSWORDS="breached-passwords",t.INACTIVE="inactive"}(qa||(qa={}));const Ja=["local","saml","google","github","facebook","microsoft","scim2","slack"];let Ya,Xa,Qa,Za,tn,en,an;!function(t){t.MISSING_PERMISSION="MISSING_PERMISSION",t.MISSING_FEATURE="MISSING_FEATURE",t.BUNDLE_EXPIRED="BUNDLE_EXPIRED"}(Ya||(Ya={})),function(t){t.FORCE_MFA="FORCE_MFA",t.BREACHED_PASSWORDS_EXIST="BREACHED_PASSWORDS_EXIST",t.ENABLE_USER_LOCKOUT="ENABLE_USER_LOCKOUT",t.STRENGTHEN_USER_LOCKOUT="STRENGTHEN_USER_LOCKOUT",t.ENABLE_PASSWORD_HISTORY="ENABLE_PASSWORD_HISTORY",t.STRENGTHEN_PASSWORD_HISTORY="STRENGTHEN_PASSWORD_HISTORY",t.ENABLE_FORCE_RELOGIN="ENABLE_FORCE_RELOGIN",t.SET_FORCE_RELOGIN="SET_FORCE_RELOGIN",t.ENABLE_SESSION_CONCURRENCY="ENABLE_SESSION_CONCURRENCY",t.SET_SESSION_CONCURRENCY="SET_SESSION_CONCURRENCY",t.ENABLE_IDLE_SESSION="ENABLE_IDLE_SESSION",t.SET_IDLE_SESSION="SET_IDLE_SESSION",t.ENABLE_IP_RESTRICTIONS="ENABLE_IP_RESTRICTIONS",t.CHANGE_IP_TO_ALLOWLIST="CHANGE_IP_TO_ALLOWLIST",t.ENABLE_DOMAIN_RESTRICTIONS="ENABLE_DOMAIN_RESTRICTIONS",t.CHANGE_DOMAIN_TO_ALLOWLIST="CHANGE_DOMAIN_TO_ALLOWLIST",t.CONFIGURE_SSO="CONFIGURE_SSO"}(Xa||(Xa={})),function(t){t.MFA_FORCED="MFA_FORCED",t.PARTIALLY_FORCED_MFA="PARTIALLY_FORCED_MFA",t.PARTIAL_MFA_USAGE="PARTIAL_MFA_USAGE",t.FULL_MFA_USAGE="FULL_MFA_USAGE",t.BREACHED_PASSWORD_USERS_EXIST="BREACHED_PASSWORD_USERS_EXIST",t.IMPROVE_LOCKOUT_POLICY="IMPROVE_LOCKOUT_POLICY",t.IMPROVE_PASSWORD_HISTORY_POLICY="IMPROVE_PASSWORD_HISTORY_POLICY",t.NO_SESSION_SETTINGS="NO_SESSION_SETTINGS",t.PARTIAL_SESSION_SETTINGS="PARTIAL_SESSION_SETTINGS",t.FULL_SESSION_SETTINGS="FULL_SESSION_SETTINGS",t.NO_IP_RESTRICTIONS="NO_IP_RESTRICTIONS",t.IP_ALLOWLIST="IP_ALLOWLIST",t.IP_DENYLIST="IP_DENYLIST",t.NO_DOMAIN_RESTRICTIONS="NO_DOMAIN_RESTRICTIONS",t.DOMAIN_ALLOWLIST="DOMAIN_ALLOWLIST",t.DOMAIN_DENYLIST="DOMAIN_DENYLIST",t.FULL_PASSWORD_SETTINGS="FULL_PASSWORD_SETTINGS"}(Qa||(Qa={})),function(t){t.SEND_RESET_BREACHED_PASSWORD_EMAIL="SEND_RESET_BREACHED_PASSWORD_EMAIL",t.ADJUST_FORCE_RELOGIN="ADJUST_FORCE_RELOGIN",t.ADJUST_MAX_CONCURRENT_SESSIONS="ADJUST_MAX_CONCURRENT_SESSIONS",t.ADJUST_IDLE_TIMEOUT="ADJUST_IDLE_TIMEOUT"}(Za||(Za={})),function(t){t.SEVERE="SEVERE",t.WARNING="WARNING",t.INFO="INFO"}(tn||(tn={})),function(t){t.MFA="MFA",t.SESSIONS="SESSIONS",t.PASSWORD="PASSWORD",t.INACTIVITY="INACTIVITY",t.IP="IP",t.DOMAIN="DOMAIN",t.SSO="SSO"}(en||(en={})),function(t){t.FREE_ACCESS="FREE_ACCESS",t.MANAGED_ACCESS="MANAGED_ACCESS"}(an||(an={}));const nn={auth:Te,securityPolicy:fe,teams:Pe,metadata:Ie,reports:Ce,connectivity:Me,notifications:xe,audits:je,tenants:he,accountSettings:Ve,roles:qe,subscriptions:ra,vendor:ca,subTenants:da,featureFlags:se,directory:pa,impersonate:ya,groups:fa,users:le,entitlements:ve,securityCenter:ba,userPhoneNumbers:wa,applications:Ea,velo:Ia,usernames:_a,userEmailPolicy:Ra},sn=t=>({auth:new we(t),securityPolicy:new Se(t),teams:new Ee(t),metadata:new Oe(t),reports:new Re(t),connectivity:new Ne(t),notifications:new Fe(t),audits:new Ge(t),tenants:new pe(t),accountSettings:new Be(t),roles:new Ke(t),subscriptions:new oa(t),vendor:new la(t),subTenants:new ua(t),featureFlags:new ne(t),directory:new ga(t),impersonate:new ha(t),groups:new Sa(t),users:new re(t),entitlements:new ye(t),securityCenter:new ma(t),userPhoneNumbers:new Aa(t),applications:new Ta(t),velo:new Oa(t),usernames:new ka(t),userEmailPolicy:new Ua(t)}),on={fetch:Wt,FetchClient:Vt,ContextHolder:R,FronteggContext:L,api:nn,createApiClient:sn,FronteggApiError:z,AuthStrategyEnum:N,MachineToMachineAuthStrategy:M,SocialLoginProviders:D,ISubscriptionCancellationPolicy:B,ISubscriptionStatus:G,PaymentMethodType:j,ProviderType:V,EIdentifierType:x};var rn=a(2743),ln=a.n(rn);const cn=(t,e)=>{const a=ln()(t,S({},e));return function(t={}){return O(t)}(S({__isProxy:!0},a))};let un;!function(t){t.validate="validate",t.invalid="invalid",t.pending="pending",t.success="success",t.failed="failed"}(un||(un={}));const dn={step:un.validate},gn=t=>cn(dn,t);var pn=a(5302),hn=a.n(pn),yn=a(1098),vn=a.n(yn);const Sn="http://schemas.openid.net/pape/policies/2007/06/multi-factor",fn="mfa",mn=["otp","sms","hwk"],bn="SHOULD_STEP_UP",An="maxAge";let wn,Tn,En,Pn;!function(t){t.preLogin="preLogin",t.magicLinkPreLoginSuccess="magicLinkPreLoginSuccess",t.loginWithSmsOtc="loginWithSmsOtc",t.loginWithQuickSmsOtc="loginWithQuickSmsOtc",t.loginWithOtc="loginWithOtc",t.loginWithPassword="loginWithPassword",t.loginWithTwoFactor="loginWithTwoFactor",t.redirectToSSO="redirectToSSO",t.loginWithSSOFailed="loginWithSSOFailed",t.success="success",t.forceTwoFactor="forceTwoFactor",t.recoverTwoFactor="recoverTwoFactor",t.promptPasskeys="promptPasskeys",t.breachedPassword="breachedPassword",t.breachedPasswordSuccess="breachedPasswordSuccess",t.passwordRotationExpired="passwordRotationExpired",t.passwordRotationNotification="passwordRotationNotification",t.magicLinkPostLoginSuccess="magicLinkPostLoginSuccess"}(wn||(wn={})),function(t){t.Login="login",t.RegisterQuickLogin="registerQuickLogin"}(Tn||(Tn={})),function(t){t.Internal="internal",t.UsbKey="usb-key",t.Android="android",t.Sms="sms"}(En||(En={})),function(t){t["social-login"]="social-login",t["custom-social-login"]="custom-social-login",t.direct="direct"}(Pn||(Pn={}));const On={[N.Code]:wn.loginWithOtc,[N.EmailAndPassword]:wn.loginWithPassword,[N.MagicLink]:wn.magicLinkPreLoginSuccess,[N.SmsCode]:wn.loginWithSmsOtc,[N.UsernameAndPassword]:wn.loginWithPassword,[N.UsernameAndMagicLink]:wn.magicLinkPreLoginSuccess,[N.UsernameAndCode]:wn.loginWithOtc,[N.UsernameAndSms]:wn.loginWithSmsOtc},In={authenticatedUrl:"/",loginUrl:"/account/login",stepUpUrl:"/account/step-up",logoutUrl:"/account/logout",activateUrl:"/account/activate",impersonationUrl:"/account/impersonate",acceptInvitationUrl:"/account/invitation/accept",forgetPasswordUrl:"/account/forget-password",resetPhoneNumberUrl:"/account/reset-phone-number",resetPasswordUrl:"/account/reset-password",socialLoginCallbackUrl:"/account/social/success",signUpUrl:"/account/sign-up",oidcRedirectUrl:"/account/oidc/callback",samlCallbackUrl:"/account/saml/callback",magicLinkCallbackUrl:"/account/login/magic-link",hostedLoginRedirectUrl:"/oauth/callback",openAppUrl:"/account/redirect",unlockAccountUrl:"/account/unlock",activateWithOTCUrl:"/account/activate/code",acceptInvitationWithOTCUrl:"/account/invitation/code",mfaMobileAuthenticator:"/account/mfa-mobile-authenticator"},kn="FRONTEGG_AFTER_AUTH_REDIRECT_URL",_n="HOSTED_LOGIN_VERIFIER_KEY",Un={retryCount:3},Rn=(t=500)=>new Promise((e=>{setTimeout(e,t)})),Cn=async(t,e,a,n)=>{let s=0;for(;s<e-1;)try{const i=await t();if(!n||null!==i)return i;if(s++,s>=e)return i;await new Promise((t=>setTimeout(t,a)))}catch(t){if(s++,s>=e)throw t;await new Promise((t=>setTimeout(t,a)))}return await t()},Ln=async(t,e)=>e?Cn(t,e.retryCount,e.delay||500,e.shouldRetryWhenNull):t(),Dn=t=>S({},t,{retryConfig:Un}),Nn=t=>(null==t?void 0:t.traceId)||void 0;function Mn(t,e){const a=S({},t);return e.forEach((t=>{delete a[t]})),a}function Fn(t){if(null!=t)return function(t){const e=typeof t;return(null==t?void 0:t.constructor)==={}.constructor||"undefined"===e||null===t||"boolean"===e||"number"===e||"string"===e||t instanceof Date||t instanceof RegExp||t instanceof Blob||t instanceof File||t instanceof FileList||t instanceof ArrayBuffer||t instanceof ImageData||t instanceof ImageBitmap||t instanceof Array||t instanceof Map||t instanceof Set}(t)&&void 0!==t.__isProxy}const xn=t=>JSON.parse(JSON.stringify(t)),$n=(t,e,a)=>{const n=xn(a),s=hn()(t,e);for(const a in s)"__isProxy"!==a&&(a in n?vn()(t,[...e,a],n[a]):vn()(t,[...e,a],void 0))},Gn=t=>Boolean(null==t?void 0:t.statusCode),jn=t=>t instanceof Error||(null==t?void 0:t.message)&&(null==t?void 0:t.stack)&&"Error"===(null==t?void 0:t.name),Bn=(t,e)=>t?Gn(t)?(console.error(t.message),t):(jn(t)?console.error(t.message):"string"==typeof t&&console.error(t),null!=e?e:new z(Ft,500,null,xt)):e,Vn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.acceptInvitationState,e)};return{setAcceptInvitationState:n,resetAcceptInvitationState:()=>{$n(t,["auth","acceptInvitationState"],dn)},acceptInvitation:async t=>{if(t.token&&t.userId)try{n({error:void 0,step:un.pending}),await e.auth.acceptInvitation(t),n({step:un.success})}catch(t){n({step:un.failed,error:Bn(t)})}else n({error:void 0,step:un.invalid})},acceptInvitationWithOTC:async t=>{if(t.token&&t.userId&&t.code)try{n({error:void 0,step:un.pending}),await e.auth.acceptInvitationWithOTC(t),n({step:un.success})}catch(t){n({step:un.validate,error:Bn(t)})}else n({error:void 0,step:un.invalid})}}},Wn={loading:!1},Hn=t=>cn(Wn,t),zn=["activeTenant","tenants"],Kn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.accountSettingsState,e)};return{setAccountSettingsState:n,resetAccountSettingsState:()=>{$n(t,["auth","accountSettingsState"],Wn)},saveAccountSettings:async s=>{try{var i;n({loading:!0});const{address:o,timezone:r,dateFormat:l,timeFormat:c,currency:u,logo:d}=t.auth.accountSettingsState,g=await e.accountSettings.updateSettings(S({address:o,timezone:r,dateFormat:l,timeFormat:c,currency:u,logo:d},s));(({newSettingValues:e})=>{const n=t.auth.tenantsState,{activeTenant:s,tenants:i}=n,o=f(n,zn),r=i.map((t=>t.id!==(null==s?void 0:s.id)?t:S({},t,e))),l=S({},s,e);a.setTenantsState(S({},o,{tenants:r,activeTenant:l}))})({newSettingValues:g}),n(S({},g,{loading:!1})),null==(i=s.callback)||i.call(s,g)}catch(t){var o;n({loading:!1,error:Bn(t)}),null==(o=s.callback)||o.call(s,null,t)}},loadAccountSettings:async t=>{n({loading:!(null!=t&&t.silentLoading),error:null});try{const a=await Ln((()=>e.accountSettings.getSettings()),null==t?void 0:t.retryConfig);n(S({},a,{loading:!1}))}catch(t){n({loading:!1,error:Bn(t)})}}}};let qn;!function(t){t.activating="activating",t.success="success",t.resend="resend",t.activatingForm="activatingForm"}(qn||(qn={}));const Jn={step:qn.activating,loading:!1,submitting:!1,resentEmail:!1,activationStrategy:{loading:!1}},Yn=t=>cn(Jn,t);let Xn,Qn,Zn,ts;!function(t){t.LOAD_FEATURE_FLAGS="LOAD_FEATURE_FLAGS,",t.LOAD_ADMIN_BOX_METADATA="LOAD_ADMIN_BOX_METADATA,",t.LOAD_SSO_PUBLIC_CONFIGURATION="LOAD_SSO_PUBLIC_CONFIGURATION,",t.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY="LOAD_PUBLIC_AUTH_STRATEGIES_POLICY,",t.LOAD_ALLOW_SIGNUPS="LOAD_ALLOW_SIGNUPS,",t.LOAD_CUSTOM_LOGIN_ROUTES="LOAD_CUSTOM_LOGIN_ROUTES",t.LOAD_PASSWORD_CONFIGURATION="LOAD_PASSWORD_CONFIGURATION"}(Xn||(Xn={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORDLESS="PASSWORDLESS",t.ACTIVATION_LINK="ACTIVATION_LINK"}(Qn||(Qn={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORD="PASSWORD",t.PHONE_NUMBER="PHONE_NUMBER"}(Zn||(Zn={})),function(t){t.profile="profile",t.privacy="privacy",t.personalApiTokens="personalApiTokens",t.account="account",t.users="users",t.groups="groups",t.security="security",t.sso="sso",t.audits="audits",t.webhooks="webhooks",t.apiTokens="apiTokens",t.roles="roles",t.subscriptions="subscription",t.allAccounts="allAccounts"}(ts||(ts={}));const es={profile:ts.profile,privacy:ts.privacy,personalApiTokens:ts.personalApiTokens,account:ts.account,users:ts.users,groups:ts.groups,security:ts.security,sso:ts.sso,audits:ts.audits,webhooks:ts.webhooks,apiTokens:ts.apiTokens,roles:ts.roles,subscriptions:ts.subscriptions,allAccounts:ts.allAccounts};let as,ns;function ss(t,e){var a,n;null==(a=(n=window).onFronteggEvent)||a.call(n,t,e)}!function(t){t.SIGNUP_COMPLETED="signup_completed",t.USER_VERIFIED="user_verified"}(as||(as={})),function(t){t.verify="verify",t.recoveryCode="recoveryCode",t.authenticatorApp="authenticatorApp",t.smsSetPhoneNumber="smsSetPhoneNumber",t.smsVerifyCode="smsVerifyCode",t.emailVerifyCode="emailVerifyCode",t.noMFAEnrolledStepUp="noMFAEnrolledStepUp"}(ns||(ns={}));const is=t=>{try{return new URL(t),!0}catch(t){return!1}},os=({authenticatedUrl:t,enforceRedirectToSameSite:e,allowedRedirectOrigins:a,includeQueryParam:n})=>{let s=t;const i=new URL(window.location.href).searchParams.get("redirectUrl");return i?e&&is(i)?((t,e)=>{const a=new URL(window.location.href),n=new URL(t),s=n.origin===a.origin;return e.includes(n.origin)||s})(i,a)?s=i:console.warn("The redirect url param is not valid, the origin is a different site"):s=i:n&&(s+=window.location.search),s},rs=t=>{const{searchParams:e}=new URL(t),a=e.toString();if(a)return`?${a}`},ls=(t,e=!1)=>{const{pathname:a,href:n}=new URL(t);if(e)return n;const s=rs(t);return s?a+s:a},cs=t=>{const e=new URLSearchParams(window.location.search).get(t);return null!=e?e:void 0},us="tenantId",ds=t=>{const e=+Boolean(t.webauthn.length),a=+Boolean(t.phones.length),n=+Boolean(t.authenticators.length),s=+Boolean(t.emails.length);return{numberOfWebAuthnDevices:e,numberOfPhoneDevices:a,numberOfAuthenticators:n,numberOfEmails:s,totalDevices:e+a+n+s}},gs=t=>{const{numberOfPhoneDevices:e,numberOfAuthenticators:a,numberOfEmails:n,totalDevices:s}=ds(t);if(1===s){if(a)return ns.authenticatorApp;if(e)return ns.smsVerifyCode;if(n)return ns.emailVerifyCode}return ns.verify},ps=t=>{if(1===t.length){const[e]=t;if(e===Qt.AuthenticatorApp)return ns.authenticatorApp;if(e===Qt.SMS)return ns.smsSetPhoneNumber;if(e===Qt.EmailCode)return ns.emailVerifyCode}return ns.verify},hs=t=>"/oauth/callback"===t;function ys(t){return"email"in t&&"string"==typeof t.email}function vs(t){return"username"in t&&"string"==typeof t.username}const Ss=t=>{const e=R.for(t.root.appName).getBasename();return null!=e&&e.endsWith("/")?e.slice(0,-1):e},fs=t=>void 0!==t.passwordExpiresIn&&void 0!==t.notificationPeriod&&t.passwordExpiresIn<=t.notificationPeriod,ms=(t,{maxAge:e}={})=>{if(!t)return!1;const{amr:a=[],acr:n="",auth_time:s}=t;if(e&&s&&!(Date.now()/1e3-s<=e))return!1;const i=n===Sn,o=-1!==a.indexOf(fn),r=void 0!==mn.find((t=>a.indexOf(t)));return i&&o&&r};function bs(){const t=window.location.pathname+window.location.search;window.localStorage.setItem(kn,t)}const As=(t,e,a)=>{bs();const n=new URLSearchParams(window.location.search);a&&n.set(An,a.toString()),e(`${t}${n?`?${n}`:""}`,{refresh:!1})},ws=["phoneNumber","email"],Ts=["authenticatedUrl"],Es=(t,e)=>{const a=R.for(e);return t.mfaRequired&&t.mfaToken?(a.setAccessToken(null),a.setUser(null),!0):(a.setAccessToken(t.accessToken),a.setUser(t),!1)},Ps=(t,e)=>{const a=R.for(e);return t.resetPasswordToken?(a.setAccessToken(null),!0):(a.setAccessToken(t.accessToken),a.setUser(t),!1)},Os=(t,e=[])=>Object.entries(t).reduce(((t,[a,n])=>"object"==typeof n?[...t,...Os(n,[...e,a])]:[...t,{type:[...e,a].join("/"),payload:n}]),[]),Is=t=>{var e;if("path"===t)return(null!=(e=window)?e:document).location.pathname;{var a;const t=((null!=(a=window)?a:document).location.hash||"#").substring(1);return-1!==t.indexOf("?")?t.substring(0,t.indexOf("?")):t}},ks=t=>{const{phoneNumber:e,email:a}=t,n=f(t,ws);return null!=a&&a.length&&Object.assign(n,{email:a}),null!=e&&e.length&&Object.assign(n,{phoneNumber:e}),n},_s=(t,e)=>{const a=f(S({},In,e),Ts);return Object.values(a).includes(t)};let Us;!function(t){t.USERS="USERS",t.STATS="STATS",t.UPDATE_USER="UPDATE_USER",t.DELETE_USER="DELETE_USER",t.RESEND_ACTIVATE_LINK="RESEND_ACTIVATE_LINK",t.RESEND_INVITATION_LINK="RESEND_INVITATION_LINK",t.ROLES_AND_PERMISSIONS="ROLES_AND_PERMISSIONS",t.CREATE_TOKEN_LINK="CREATE_TOKEN_LINK",t.GET_TOKEN_LINK="GET_TOKEN_LINK",t.UPDATE_TOKEN_LINK="UPDATE_TOKEN_LINK",t.DELETE_TOKEN_LINK="DELETE_TOKEN_LINK",t.CONFIG_TOKEN_LINK="CONFIG_TOKEN_LINK",t.CONFIG_TEMPORARY_USERS="CONFIG_TEMPORARY_USERS",t.UPDATE_USER_EXPIRATION_TIME="UPDATE_USER_EXPIRATION_TIME"}(Us||(Us={}));const Rs=["user"],Cs=["callback","events"],Ls=["user"],Ds=["callback","events"],Ns=["user"],Ms=["callback"],Fs=["callback"],xs=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.activateAccountState,e)},i=()=>{$n(t,["auth","activateAccountState"],Jn)},o=e=>{Object.assign(t.auth.activateAccountState.activationStrategy,e)},r=async({loginResponse:e,events:a,onRedirectTo:o,routes:r})=>{const{user:l}=e,c=f(e,Rs);if(l.redirectLocation)window.location.href=l.redirectLocation;else if(Es(l,t.root.appName)){s({step:qn.success});const t=await n.getMfaRequiredState(l);n.setAuthState(t),await Rn(1e3),o(r.loginUrl,{preserveQueryParams:!0})}else{var u;s({step:qn.success});const t={email:l.email,origin:Qn.ACTIVATION_LINK,id:l.id,tenantId:l.tenantId,name:l.name,createdAt:new Date};null==a||null==(u=a.userVerified)||u.call(a,t),ss(as.USER_VERIFIED,t),n.afterAuthenticationStateUpdate(S({user:l},c),{isAuthenticated:!0}),await Rn(5e3),await n.afterAuthNavigation(),i()}};return{setActivateState:s,resetActivateState:i,setActivateStrategyState:o,activateAccount:async a=>{const{callback:n,events:i}=a,o=f(a,Cs);s({loading:!0,submitting:!0});try{const a=R.for(t.root.appName).onRedirectTo,l=t.auth.routes,c=await e.auth.activateAccountV2(o),{user:u}=c,d=f(c,Ls);s({submitting:!1}),await r({loginResponse:S({user:u},d),events:i,onRedirectTo:a,routes:l}),null==n||n(!0)}catch(t){s({loading:!1,error:Bn(t)})}},preActivateAccount:async a=>{const{userId:i,token:r}=a;s({loading:!0,step:qn.activating});try{t.auth.isAuthenticated&&await n.silentLogout();const a=await e.auth.getActivateAccountStrategy({userId:i,token:r});o({strategy:a,loading:!1,error:void 0}),a.shouldSetPassword&&s({loading:!1,step:qn.activatingForm})}catch(t){s({loading:!1,error:Bn(t)})}},getActivateAccountStrategy:async t=>{const{callback:a}=t,n=f(t,Ms);o({loading:!0});try{const t=await e.auth.getActivateAccountStrategy(n);o({strategy:t,loading:!1,error:void 0}),null==a||a(t)}catch(t){o({loading:!1,error:Bn(t)})}},resendActivationEmail:async t=>{const{callback:a}=t,i=f(t,Fs);n.setTeamLoader({key:Us.RESEND_ACTIVATE_LINK,value:i.email}),s({loading:!0});try{await e.auth.resendActivationEmail(i),s({loading:!1,error:void 0,resentEmail:!0}),null==a||a(!0)}catch(t){s({loading:!1,error:Bn(t)}),null==a||a(null,t)}finally{n.setTeamLoader({key:Us.RESEND_ACTIVATE_LINK,value:!1})}},activateAccountWithCode:async a=>{const{callback:n,events:i}=a,o=f(a,Ds);s({loading:!0,submitting:!0});try{const a=R.for(t.root.appName).onRedirectTo,l=t.auth.routes,c=await e.auth.activateAccountWithOTC(o),{user:u}=c,d=f(c,Ns);s({submitting:!1}),await r({loginResponse:S({user:u},d),events:i,onRedirectTo:a,routes:l}),null==n||n(!0)}catch(t){s({submitting:!1,loading:!1,error:Bn(t),step:qn.activating})}}}},$s={loading:!1,error:void 0,unlockAccountSuccess:!1},Gs=t=>cn($s,t),js=(t,e,a)=>{const n=e=>{Object.assign(t.auth.unlockAccountState,e)};return{setUnlockAccountState:n,resetUnlockAccountState:()=>{$n(t,["auth","activateAccountState"],$s)},unlockAccount:async a=>{const{token:s}=a,i=R.for(t.root.appName).onRedirectTo,o=t.auth.routes;n({loading:!0});try{await e.users.unlockMe({token:s}),n({loading:!1,error:void 0,unlockAccountSuccess:!0}),await Rn(5e3),i(o.loginUrl)}catch(t){n({loading:!1,error:Bn(t)})}}}},Bs={apiTokenType:null,showAddTokenDialog:!1,createdByUserIdColumn:"show",deleteTokenDialog:{open:!1,clientId:""},successDialog:{open:!1,secret:"",clientId:""},loaders:{},apiTokensDataTenant:[],apiTokensDataUser:[],roles:[],permissions:[],errors:{}},Vs=t=>cn(Bs,t);let Ws;!function(t){t.LOAD_API_TOKENS="LOAD_API_TOKENS",t.ADD_API_TOKEN="ADD_API_TOKEN",t.DELETE_API_TOKEN="DELETE_API_TOKEN"}(Ws||(Ws={}));const Hs=(t,e,a)=>{const n=e=>{Object.assign(t.auth.apiTokensState,{loaders:S({},t.auth.apiTokensState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.apiTokensState,{errors:S({},t.auth.apiTokensState.errors,{[e.key]:e.value}),loaders:S({},t.auth.apiTokensState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.apiTokensState,e)};return{setApiTokensLoader:n,setApiTokensError:s,setApiTokensState:i,resetApiTokensState:()=>{$n(t,["auth","apiTokensState"],Bs)},loadApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Ws.LOAD_API_TOKENS,value:!0});try{var a;const[s=[],o=[]]=await Promise.all([e.auth.getUserApiTokensData(),e.auth.getTenantApiTokensData()]);i({apiTokensDataUser:s,apiTokensDataTenant:o}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var o;s({key:Ws.LOAD_API_TOKENS,value:Bn(e)}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,null,e)}},loadUserApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Ws.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([Ln((()=>e.auth.getUserApiTokensData()),null==t?void 0:t.retryConfig),Ln((()=>e.auth.getUserAccessTokensData()),null==t?void 0:t.retryConfig)]),l=(null!=(a=r.accessTokens)?a:[]).map((t=>S({},t,{type:M.AccessToken}))).concat(s.map((t=>S({},t,{type:M.ClientCredentials})))).sort(((t,e)=>new Date(e.createdAt)-new Date(t.createdAt)));i({apiTokensDataUser:null!=l?l:[]}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Ws.LOAD_API_TOKENS,value:Bn(e)}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==t||null==(r=t.callback)||r.call(t,null,e)}},loadTenantApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Ws.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([Ln((()=>e.auth.getTenantApiTokensData()),null==t?void 0:t.retryConfig),Ln((()=>e.auth.getTenantAccessTokensData()),null==t?void 0:t.retryConfig)]),l=(null!=(a=null==r?void 0:r.accessTokens)?a:[]).map((t=>S({},t,{type:M.AccessToken}))).concat(s.map((t=>S({},t,{type:M.ClientCredentials})))).sort(((t,e)=>new Date(e.createdAt)-new Date(t.createdAt)));i({apiTokensDataTenant:null!=l?l:[]}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Ws.LOAD_API_TOKENS,value:Bn(e)}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==t||null==(r=t.callback)||r.call(t,null,e)}},addTenantApiToken:async a=>{const{description:o,roleIds:r,expires:l,callback:c}=a,u=Ws.ADD_API_TOKEN;n({key:u,value:!0});try{const{policy:a}=t.auth.securityPolicyState.publicPolicy,n=(null==a?void 0:a.machineToMachineAuthStrategy)===M.AccessToken;let s,u=null;l&&(u=1440*l),s=n?await e.auth.createTenantAccessToken({description:o,expiresInMinutes:u,roleIds:r}):await e.auth.updateTenantApiTokensData({description:o,roleIds:r,expiresInMinutes:u}),i({showAddTokenDialog:!1}),await Rn(200);const d=n?M.AccessToken:M.ClientCredentials;t.auth.apiTokensState.apiTokensDataTenant.unshift(S({},s,{type:d})),t.auth.apiTokensState.successDialog={open:!0,secret:s.secret,clientId:n?void 0:s.clientId},null==c||c(null)}catch(t){s({key:u,value:Bn(t)}),null==c||c(null,t)}finally{n({key:u,value:!1})}},addUserApiToken:async a=>{const{description:o,expires:r,callback:l}=a,c=Ws.ADD_API_TOKEN;n({key:c,value:!0});try{const{policy:a}=t.auth.securityPolicyState.publicPolicy,n=(null==a?void 0:a.machineToMachineAuthStrategy)===M.AccessToken;let s,c=null;r&&(c=1440*r),s=n?await e.auth.createUserAccessToken({description:o,expiresInMinutes:c}):await e.auth.updateUserApiTokensData({description:o,expiresInMinutes:c}),i({showAddTokenDialog:!1}),await Rn(200);const u=n?M.AccessToken:M.ClientCredentials;t.auth.apiTokensState.apiTokensDataUser.unshift(S({},s,{type:u})),t.auth.apiTokensState.successDialog={open:!0,secret:s.secret,clientId:n?void 0:s.clientId},null==l||l(null)}catch(t){s({key:c,value:Bn(t)}),null==l||l(null,t)}finally{n({key:c,value:!1})}},deleteUserApiToken:async a=>{const o=Ws.DELETE_API_TOKEN;n({key:o,value:!0});try{const n=t.auth.apiTokensState.apiTokensDataUser;n.some((t=>t.id===a))?(await e.auth.deleteUserAccessToken({id:a}),i({apiTokensDataUser:n.filter((t=>t.id!==a)),deleteTokenDialog:{open:!1,id:a}})):(await e.auth.deleteUserApiToken({tokenId:a}),i({apiTokensDataUser:n.filter((t=>t.clientId!==a)),deleteTokenDialog:{open:!1,clientId:a}}))}catch(t){s({key:o,value:Bn(t)})}finally{n({key:o,value:!1})}},deleteTenantApiToken:async a=>{const o=Ws.DELETE_API_TOKEN;n({key:o,value:!0});try{const n=t.auth.apiTokensState.apiTokensDataTenant;n.some((t=>t.id===a))?(await e.auth.deleteTenantAccessToken({id:a}),i({apiTokensDataTenant:n.filter((t=>t.id!==a)),deleteTokenDialog:{open:!1,id:a}})):(await e.auth.deleteTenantApiToken({tokenId:a}),i({apiTokensDataTenant:n.filter((t=>t.clientId!==a)),deleteTokenDialog:{open:!1,id:a}}))}catch(t){s({key:o,value:Bn(t)})}finally{n({key:o,value:!1})}}}},zs={loading:!0,fetching:!0,error:null,userApplications:[],accountApplications:[]},Ks=t=>cn(zs,t),qs=t=>{var e;return null!=(e=t.map((({appIds:t})=>t)).reduce(((t,e)=>(null==e||e.forEach((e=>{t&&!t.includes(e)&&t.push(e)})),t)),[]))?e:[]},Js=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.applicationsState,e)},i=async({userIds:t,retryConfig:a})=>{try{const n=await Ln((()=>e.applications.getUsersApplicationsId({userIds:t})),a),s=qs(n),i=await Ln((()=>e.applications.getApplicationsData({appIds:s})),a);return t.reduce(((t,e)=>{var a,s,o;const r=null==(a=n.find((t=>t.userId==e)))?void 0:a.appIds;return t[e]=[...i.filter((t=>t.accessType===an.FREE_ACCESS)),...null!=(s=null==r||null==(o=r.map((t=>i.find((e=>t===e.id)))))?void 0:o.filter((t=>!!t)))?s:[]],t}),{})}catch(t){s({error:Bn(t)})}},o="Assignment action failed. Try again or contact support.";return{setApplicationsState:s,resetApplicationsState:()=>{$n(t,["auth","applicationsState"],zs)},loadUserApplications:async a=>{s({loading:!0,fetching:!0});try{var n,i;const o=null!=(n=null==(i=t.auth.user)?void 0:i.id)?n:"",r=null==a?void 0:a.retryConfig,l=await Ln((()=>e.applications.getUserApplicationsId({userId:o})),r),c=await Ln((()=>e.applications.getApplicationsData({appIds:l})),r);s({userApplications:c,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Bn(t)})}},loadAccountApplications:async t=>{const a=null==t?void 0:t.retryConfig;s({loading:!0,fetching:!0});try{const t=await Ln((()=>e.applications.getTenantsApplications()),a),n=qs(t),i=await Ln((()=>e.applications.getApplicationsData({appIds:n})),a),o=await Ln((()=>e.applications.getUsersOfApplications({appIds:n})),a),r=i.map((t=>{var e;return S({},t,{userIds:null==(e=o.find((e=>e.appId===t.id)))?void 0:e.userIds})}));s({accountApplications:r,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Bn(t)})}},loadMultipleUsersApplications:i,assignUserToApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,g,p,h,y,v,f;const n=null!=(c=null==(u=t.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await e.applications.assignUserToApplications({userId:i,appIds:r,tenantId:n});const s=null==(g=t.auth)||null==(p=g.applicationsState)?void 0:p.accountApplications,o=null!=(h=null==(y=t.auth)||null==(v=y.teamState)?void 0:v.users)?h:[],m=null!=(f=null==s?void 0:s.filter((t=>r.includes(t.id))))?f:[];null!=m&&m.length&&a.setTeamState({users:o.map((t=>{var e;return t.id===i?S({},t,{applications:[...null!=(e=t.applications)?e:[],...m]}):t}))}),null==l||l(!0)}catch(t){s({error:Bn(t,o)}),null==l||l(!1)}},unassignUserFromApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,g,p,h,y;const n=null!=(c=null==(u=t.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await e.applications.unassignUserFromApplications({userId:i,appIds:r,tenantId:n});const s=null!=(g=null==(p=t.auth)||null==(h=p.teamState)?void 0:h.users)?g:[],o=null==(y=s.find((t=>t.id===i)))?void 0:y.applications;null!=o&&o.length&&r.length&&a.setTeamState({users:s.map((t=>t.id===i?S({},t,{applications:o.filter((t=>!r.includes(t.id)))}):t))}),null==l||l(!0)}catch(t){s({error:Bn(t,o)}),null==l||l(!1)}},assignNewUserToApps:async({appIds:a,user:s})=>{var i,o,r;const[l]=await n.getFeatureFlags(["multi-apps-admin-portal"]);if(!l)return;const c=null==(i=t.auth)||null==(o=i.applicationsState)?void 0:o.accountApplications,u=null!=(r=null==c?void 0:c.filter((t=>t.accessType===an.FREE_ACCESS)))?r:[];if(null!=a&&a.length){var d,g,p;const n=null!=(d=null==(g=t.auth)||null==(p=g.user)?void 0:p.tenantId)?d:"";return await e.applications.assignUserToApplications({userId:s.id,appIds:a,tenantId:n}),a.map((t=>{var e;return null!=(e=null==c?void 0:c.find((e=>e.id===t)))?e:[]})).concat(u)}return u},mapUsersWithApplicationData:async({shouldLoadApps:t,users:e,retryConfig:n})=>{const[s]=await a.getFeatureFlags(["multi-apps-admin-portal"]);if(!s||!t)return e;const o=e.map((t=>t.id)),r=await i({userIds:o,retryConfig:n});return r?e.map((t=>null!=r&&r[t.id]?S({},t,{applications:r[t.id]}):t)):e}}},Ys={loading:!0,error:null},Xs=t=>cn(Ys,t),Qs=["callback"],Zs=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.customLoginState,e)},i=async()=>{var e,a,n,s,i;return t.auth.isAuthenticated?null!=(s=null==(i=t.auth.tenantsState.activeTenant)?void 0:i.hasCustomLogin)&&s:!!(null==(e=await(null==(a=R.for(t.root.appName).getContext())||null==(n=a.tenantResolver)?void 0:n.call(a)))?void 0:e.tenant)};return{setCustomLoginState:s,resetCustomLoginState:()=>{$n(t,["auth","customLoginState"],Ys)},loadTenantMetadata:async()=>{s({loading:!0});try{const t=await e.metadata.getAdminBoxMetadata();s({tenantMetadata:t,loading:!1})}catch(t){s({loading:!1,error:Bn(t)})}},updateTenantMetadata:async t=>{const{callback:a}=t,n=f(t,Qs);try{s({error:null,saving:!0});const t=Os(n);if(0===t.length)throw new Error("No changes to update");await e.metadata.updateAdminBoxMetadata({actions:t});const i=await e.metadata.getAdminBoxMetadata();s({tenantMetadata:i,saving:!1}),null==a||a(!0)}catch(t){s({error:Bn(t,"No changes to update"),saving:!1}),null==a||a(null,t)}},customLoginEnabled:i,loadCustomLoginRoutes:async a=>{try{var o,r,l;if(!await i())return void(null==a||null==(l=a.callback)||l.call(a,!0));const u=t.auth.isAuthenticated,{getSettings:d,getPublicSettings:g}=e.accountSettings,{applicationUrl:p}=await Ln(u?d:g,null==a?void 0:a.retryConfig);var c;if(!p)return void(null==a||null==(c=a.callback)||c.call(a,!0));const h=t.auth.routes,y=null!=(o=rs(p))?o:"";n.setAuthState({routes:S({},h,{customLoginAuthenticatedUrl:p,customLoginUrl:h.loginUrl+y})}),s({customLoginSearchParams:null!=y?y:void 0}),null==a||null==(r=a.callback)||r.call(a,!0)}catch(t){var u;null==a||null==(u=a.callback)||u.call(a,null,t)}}}};let ti;!function(t){t.forgotPassword="forgotPassword",t.resetPasswordViaSms="resetPasswordViaSms",t.passwordRecoverySelector="passwordRecoverySelector",t.resetPasswordPage="resetPasswordPage",t.success="success"}(ti||(ti={}));const ei={step:ti.forgotPassword,loading:!1,identifier:"",passwordConfig:null},ai=t=>cn(ei,t),ni=["callback"],si=(t,e,a)=>{const n=e=>{Object.assign(t.auth.forgotPasswordState,e)},s=async t=>{n({loading:!0});try{var a;await e.auth.forgotPassword(t),n({loading:!1,error:void 0,step:ti.success}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;n({loading:!1,error:Bn(e,"Unknown error occurred")}),null==(s=t.callback)||s.call(t,!1,e)}};return{setForgotPasswordState:n,resetForgotPasswordState:()=>{$n(t,["auth","forgotPasswordState"],ei)},forgotPassword:s,resetPassword:async t=>{const{callback:a}=t,s=f(t,ni);n({loading:!0});try{await e.auth.resetPassword(s),n({loading:!1,error:void 0,step:ti.success}),null==a||a(!0)}catch(t){n({loading:!1,error:Bn(t)}),null==a||a(!1,t)}},loadPasswordConfig:async t=>{n({loading:!0});try{const a=await e.auth.loadPasswordConfig(t);n({loading:!1,passwordConfig:a})}catch(t){n({loading:!1,error:Bn(t)})}},determinePasswordRecoveryStrategy:async t=>{n({loading:!0,error:void 0,identifier:t.identifier});try{const a=await e.auth.getPasswordRecoveryStrategies(),i=a.some((t=>t.strategy===$.Email&&t.isActive)),o=a.some((t=>t.strategy===$.Sms&&t.isActive));i&&o?n({loading:!1,step:ti.passwordRecoverySelector}):i?await s({email:t.identifier,recaptchaToken:t.recaptchaToken}):n(o?{loading:!1,step:ti.resetPasswordViaSms}:{loading:!1,error:"No active password recovery methods found."})}catch(t){n({loading:!1,error:Bn(t,"An error occurred while determining recovery strategy")})}}}};let ii;!function(t){t.success="success",t.notification="notification"}(ii||(ii={}));const oi={step:ii.notification},ri=t=>cn(oi,t),li=(t,e,a)=>({setStep:e=>{var a;a={step:e},Object.assign(t.auth.passwordRotationState,a)}}),ci={loaders:{},errors:{},groups:[],groupsConfiguration:{}},ui=t=>cn(ci,t);let di,gi;!function(t){t.CREATE_GROUP="CREATE_GROUP",t.GET_GROUP="GET_GROUP",t.GET_GROUPS="GET_GROUPS",t.DELETE_GROUP="DELETE_GROUP",t.UPDATE_GROUP="UPDATE_GROUP",t.ADD_USERS_TO_GROUP="ADD_USERS_TO_GROUP",t.DELETE_USERS_FROM_GROUP="DELETE_USERS_FROM_GROUP",t.ADD_ROLES_TO_GROUP="ADD_ROLES_TO_GROUP",t.DELETE_ROLES_FROM_GROUP="DELETE_ROLES_FROM_GROUP",t.GET_GROUP_CONFIGURATION="GET_GROUP_CONFIGURATION",t.UPDATE_GROUP_CONFIGURATION="UPDATE_GROUP_CONFIGURATION",t.GET_TEAM_USERS="GET_TEAM_USERS"}(di||(di={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(gi||(gi={}));const pi=["roleIds","userIds"],hi=(t,e,a)=>{const n=e=>{Object.assign(t.auth.groupsState,{loaders:S({},t.auth.groupsState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.groupsState,{errors:S({},t.auth.groupsState.errors,{[e.key]:e.value}),loaders:S({},t.auth.groupsState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.groupsState,e)},o=async a=>{const o=di.GET_GROUPS,r=t.auth.groupsState;n({key:o,value:!0});try{const{groups:t}=await Ln((()=>e.groups.getGroups({_groupsRelations:gi.rolesAndUsers})),null==a?void 0:a.retryConfig);i(S({groups:t},r.selectedGroup&&{selectedGroup:t.find((t=>{var e;return t.id===(null==(e=r.selectedGroup)?void 0:e.id)}))}))}catch(t){s({key:o,value:Bn(t)})}finally{n({key:o,value:!1})}},r=async t=>{const a=di.ADD_ROLES_TO_GROUP;n({key:a,value:!0});try{var i;await e.groups.addRolesToGroup(t.groupId,{roleIds:t.roleIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Bn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},l=async t=>{const a=di.ADD_USERS_TO_GROUP;n({key:a,value:!0});try{var i;await e.groups.addUsersToGroup(t.groupId,{userIds:t.userIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;null==t||null==(r=t.callback)||r.call(t,!1),s({key:a,value:Bn(e)})}finally{n({key:a,value:!1})}},c=async t=>{const a=di.GET_GROUP_CONFIGURATION;n({key:a,value:!0});try{const a=await Ln((()=>e.groups.getGroupConfiguration()),null==t?void 0:t.retryConfig);i({groupsConfiguration:a})}catch(t){s({key:a,value:Bn(t)})}finally{n({key:a,value:!1})}};return{setUsersGroupsLoader:n,setUsersGroupsError:s,setGroupsState:i,resetUsersGroupsState:()=>{$n(t,["auth","groupsState"],ci)},loadGroups:o,getGroupById:async t=>{const a=di.GET_GROUP;n({key:a,value:!0});try{const a=await e.groups.getGroupById({groupId:t.groupId},{_groupsRelations:gi.rolesAndUsers});i({selectedGroup:a})}catch(t){s({key:a,value:Bn(t)})}finally{n({key:a,value:!1})}},createGroup:async t=>{const a=di.CREATE_GROUP,{roleIds:i,userIds:c}=t,u=f(t,pi);n({key:a,value:!0});try{var d;const a=await e.groups.createGroup(S({name:u.name},!!u.description&&{description:u.description},{color:u.color}));null!=c&&c.length&&l({groupId:a.id,userIds:c}),null!=i&&i.length&&r({groupId:a.id,roleIds:i}),await o(),null==t||null==(d=t.callback)||d.call(t,!0)}catch(e){var g;s({key:a,value:Bn(e)}),null==t||null==(g=t.callback)||g.call(t,!1)}finally{n({key:a,value:!1})}},updateGroup:async t=>{const a=di.UPDATE_GROUP;n({key:a,value:!0});try{var i;await e.groups.updateGroup(t),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Bn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},deleteGroup:async t=>{const a=di.DELETE_GROUP;n({key:a,value:!0});try{var i;await e.groups.deleteGroup(t.groupId),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Bn(e)}),null==t||null==(r=t.callback)||r.call(t,!1,e)}finally{n({key:a,value:!1})}},addRolesToGroup:r,deleteRolesFromGroup:async t=>{const a=di.DELETE_ROLES_FROM_GROUP;n({key:a,value:!0});try{var i;await e.groups.deleteRolesFromGroup(t.groupId,{roleIds:t.roleIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Bn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},addUsersToGroup:l,deleteUsersFromGroup:async t=>{const a=di.DELETE_USERS_FROM_GROUP;n({key:a,value:!0});try{var i;await e.groups.deleteUsersFromGroup(t.groupId,{userIds:t.userIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Bn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},getGroupConfiguration:c,updateGroupConfiguration:async t=>{const a=di.UPDATE_GROUP_CONFIGURATION;n({key:a,value:!0});try{await e.groups.updateGroupConfiguration(t),await c()}catch(t){s({key:a,value:Bn(t)})}finally{n({key:a,value:!1})}},getTeamUsers:async t=>{const a=di.GET_TEAM_USERS;n({key:a,value:!0});try{const{items:a}=await e.users.getUsersV2({_filter:t.filter,_offset:t.pageOffset,_limit:t.pageSize,_includeSubTenants:!1});i({teamUsers:a})}catch(t){s({key:a,value:Bn(t)})}finally{n({key:a,value:!1})}}}},yi={addGroupDialogState:{loading:!1,open:!1},editGroupDialogState:{loading:!1,open:!1},deleteGroupDialogState:{loading:!1,open:!1},addMembersToGroupDialogState:{loading:!1,open:!1,userIds:[]},deleteMemberFromGroupDialogState:{loading:!1,open:!1}},vi=t=>cn(yi,t),Si=(t,e,a)=>({setGroupsDialogsState:e=>{Object.assign(t.auth.groupsDialogsState,e)},resetGroupsDialogsState:()=>{$n(t,["auth","groupsDialogsState"],yi)},openAddGroupDialog:()=>{t.auth.groupsDialogsState.addGroupDialogState.open=!0},closeAddGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.addGroupDialogState,{open:!1,group:void 0})},openAddMembersToGroupDialog:()=>{t.auth.groupsDialogsState.addMembersToGroupDialogState.open=!0},closeAddMembersToGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.addMembersToGroupDialogState,{open:!1,userIds:[]})},openEditGroupDialog:e=>{Object.assign(t.auth.groupsDialogsState.editGroupDialogState,S({},e,{open:!0}))},closeEditGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.editGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteGroupDialog:e=>{Object.assign(t.auth.groupsDialogsState.deleteGroupDialogState,S({},e,{open:!0}))},closeDeleteGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.deleteGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteMemberFromGroupDialog:e=>{Object.assign(t.auth.groupsDialogsState.deleteMemberFromGroupDialogState,e)},closeDeleteMemberFromGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.deleteMemberFromGroupDialogState,{open:!1,userId:void 0,email:void 0})}});let fi;!function(t){t.impersonating="impersonating",t.success="success"}(fi||(fi={}));const mi={step:fi.impersonating,loading:!1},bi=t=>cn(mi,t),Ai=["callback","events"],wi=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.impersonateState,e)},i=()=>{$n(t,["auth","impersonateState"],mi)};return{setImpersonateState:s,resetImpersonateState:i,impersonate:async t=>{const{callback:a}=t,o=f(t,Ai);s({loading:!0});try{await e.impersonate.impersonate(o),s({step:fi.success}),await Rn(1e3),await n.afterAuthNavigation({preventRedirectUrlOriginCleaning:!0}),i(),null==a||a(!0)}catch(t){s({loading:!1,error:Bn(t)})}}}},Ti={flow:Tn.Login,step:wn.preLogin,loading:!1,email:"",tenants:[]},Ei=t=>cn(Ti,t),Pi=(t,e,a)=>{const n=a;const s=async(e,a={})=>{const{customLoginAuthenticatedUrl:n,forceStepUpUrl:s,shouldStepUpDuringLogin:i,preventRedirectUrlOriginCleaning:o=!1}=a,r=t.auth.onRedirectTo;let l;if(s)l=s;else{var c;if(i){const t=window.localStorage.getItem(kn);t&&!is(t)&&(l=t)}l||(l=await async function({customLoginAuthenticatedUrl:e,preventRedirectUrlOriginCleaning:a}){const{routes:n,includeQueryParam:s=!1,enforceRedirectToSameSite:i=!1,allowedRedirectOrigins:o=[]}=t.auth,r=window.localStorage.getItem(kn);if(e&&!r)return ls(e,a);const{authenticatedUrl:l,loginUrl:c,logoutUrl:u,socialLoginCallbackUrl:d,activateUrl:g,activateWithOTCUrl:p}=n;let h=r;h&&![c,u,d,g,p].includes(h)||(h=l);const y=os({authenticatedUrl:h,includeQueryParam:s,enforceRedirectToSameSite:i,allowedRedirectOrigins:o});return a?y:(v=y).startsWith(null==(S=window)?void 0:S.location.origin)?v.replace(null==(f=window)?void 0:f.location.origin,""):v;var v,S,f}({customLoginAuthenticatedUrl:n,preventRedirectUrlOriginCleaning:o})),null==(c=window)||c.localStorage.removeItem(kn)}await Rn(200),await e(),r(l,{refresh:l.startsWith("http")})};return{afterAuthNavigationUtil:s,afterAuthNavigation:async e=>{var a,i;const{customLoginAuthenticatedUrl:o,stepUpUrl:r}=t.auth.routes,l=null==(a=window)?void 0:a.localStorage.getItem(bn),c=t.auth.user;var u;if(l&&(null==(u=window)||u.localStorage.removeItem(bn)),r&&l&&!ms(c))return s(n.resetLoginState,{forceStepUpUrl:r});let d=o;var g;return o||(await n.loadCustomLoginRoutes(),d=null==(g=t.auth.routes)?void 0:g.customLoginAuthenticatedUrl),s(n.resetLoginState,{customLoginAuthenticatedUrl:d,shouldStepUpDuringLogin:!!l,preventRedirectUrlOriginCleaning:null!=(i=null==e?void 0:e.preventRedirectUrlOriginCleaning)&&i})},afterStepUpAuthNavigation:async()=>s(n.resetStepUpState),afterAuthenticationStateUpdate:function({user:e,tenants:a=[],activeTenant:s},i={}){const o=t.auth.tenantsState;n.setAuthState(S({user:e,tenantsState:S({},o,{tenants:a,activeTenant:s,loading:!1})},i))}}},Oi=["callback"],Ii=["callback"],ki=["callback"],_i=["callback","deviceId"],Ui=["callback","deviceId"],Ri="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Ci=new Uint8Array(256);for(let t=0;t<64;t++)Ci[Ri.charCodeAt(t)]=t;const Li=t=>{const e=new Uint8Array(t),a=e.length;let n,s="";for(n=0;n<a;n+=3)s+=Ri[e[n]>>2],s+=Ri[(3&e[n])<<4|e[n+1]>>4],s+=Ri[(15&e[n+1])<<2|e[n+2]>>6],s+=Ri[63&e[n+2]];return a%3==2?s=s.substring(0,s.length-1):a%3==1&&(s=s.substring(0,s.length-2)),s},Di=t=>{const e=.75*t.length,a=t.length;let n,s,i,o,r,l=0;const c=new Uint8Array(e);for(n=0;n<a;n+=4)s=Ci[t.charCodeAt(n)],i=Ci[t.charCodeAt(n+1)],o=Ci[t.charCodeAt(n+2)],r=Ci[t.charCodeAt(n+3)],c[l++]=s<<2|i>>4,c[l++]=(15&i)<<4|o>>2,c[l++]=(3&o)<<6|63&r;return c.buffer};function Ni(t,e="file"){const a=t.match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/);if(null==a)return null;const n=`image/${a[1]}`,s=((t,e)=>{const a=atob(t),n=[];for(let t=0;t<a.length;t+=512){const e=a.slice(t,t+512),s=new Array(e.length);for(let t=0;t<e.length;t++)s[t]=e.charCodeAt(t);n.push(new Uint8Array(s))}return new Blob(n,{type:e})})(a[2],n),i=new FormData;return i.append(e,new File([s],e,{type:n})),i}const Mi=t=>{if(t instanceof Array){const e=[];for(const a of t)e.push(Mi(a));return e}if(t instanceof ArrayBuffer)return Li(t);if(t instanceof Object){const e={};for(const a in t)e[a]=Mi(t[a]);return e}return t},Fi=t=>new Promise(((e,a)=>{const n=new FileReader;n.readAsText(t),n.onload=()=>e(n.result),n.onerror=a})),xi=["callback","deviceId"],$i=["callback","deviceId"],Gi="input is invalid type",ji="undefined"!=typeof ArrayBuffer,Bi="0123456789abcdef".split(""),Vi=[-2147483648,8388608,32768,128],Wi=[24,16,8,0],Hi=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],zi=["hex","array","digest","arrayBuffer"],Ki=[];Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),ji&&!ArrayBuffer.isView&&(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});const qi=function(t){return function(e){const a=new Yi(!0).update(e);return null==a?void 0:a[t]()}},Ji=function(t){return function(e,a){const n=new Xi(e,!0).update(a);return null==n?void 0:n[t]()}};class Yi{constructor(t=!1){this.blocks=void 0,this.h0=void 0,this.h1=void 0,this.h2=void 0,this.h3=void 0,this.h4=void 0,this.h5=void 0,this.h6=void 0,this.h7=void 0,this.block=void 0,this.start=void 0,this.bytes=void 0,this.hBytes=void 0,this.finalized=void 0,this.hashed=void 0,this.first=void 0,this.lastByteIndex=void 0,this.sharedMemory=!1,this.toString=()=>this.hex(),this.array=()=>Yi.prototype.digest(),t?(Ki[0]=Ki[16]=Ki[1]=Ki[2]=Ki[3]=Ki[4]=Ki[5]=Ki[6]=Ki[7]=Ki[8]=Ki[9]=Ki[10]=Ki[11]=Ki[12]=Ki[13]=Ki[14]=Ki[15]=0,this.blocks=Ki):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.sharedMemory=t}update(t){if(this.finalized)return;let e;const a=typeof t;if("string"!==a){if("object"!==a)throw new Error(Gi);if(null===t)throw new Error(Gi);if(ji&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||ji&&ArrayBuffer.isView(t)))throw new Error(Gi);e=!0}let n,s,i=0;const o=t.length,r=this.blocks;for(;i<o;){if(this.hashed&&(this.hashed=!1,r[0]=this.block,r[16]=r[1]=r[2]=r[3]=r[4]=r[5]=r[6]=r[7]=r[8]=r[9]=r[10]=r[11]=r[12]=r[13]=r[14]=r[15]=0),e)for(s=this.start;i<o&&s<64;++i)r[s>>2]|=t[i]<<Wi[3&s++];else for(s=this.start;i<o&&s<64;++i)n=t.charCodeAt(i),n<128?r[s>>2]|=n<<Wi[3&s++]:n<2048?(r[s>>2]|=(192|n>>6)<<Wi[3&s++],r[s>>2]|=(128|63&n)<<Wi[3&s++]):n<55296||n>=57344?(r[s>>2]|=(224|n>>12)<<Wi[3&s++],r[s>>2]|=(128|n>>6&63)<<Wi[3&s++],r[s>>2]|=(128|63&n)<<Wi[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++i)),r[s>>2]|=(240|n>>18)<<Wi[3&s++],r[s>>2]|=(128|n>>12&63)<<Wi[3&s++],r[s>>2]|=(128|n>>6&63)<<Wi[3&s++],r[s>>2]|=(128|63&n)<<Wi[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=r[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}finalize(){if(this.finalized)return;this.finalized=!0;const t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=Vi[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}hash(){let t,e,a,n,s,i,o,r,l,c,u,d=this.h0,g=this.h1,p=this.h2,h=this.h3,y=this.h4,v=this.h5,S=this.h6,f=this.h7;const m=this.blocks;for(t=16;t<64;++t)s=m[t-15],e=(s>>>7|s<<25)^(s>>>18|s<<14)^s>>>3,s=m[t-2],a=(s>>>17|s<<15)^(s>>>19|s<<13)^s>>>10,m[t]=m[t-16]+e+m[t-7]+a|0;for(u=g&p,t=0;t<64;t+=4)this.first?(r=704751109,s=m[0]-210244248,f=s-1521486534|0,h=s+143694565|0,this.first=!1):(e=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),a=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),r=d&g,n=r^d&p^u,o=y&v^~y&S,s=f+a+o+Hi[t]+m[t],i=e+n,f=h+s|0,h=s+i|0),e=(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),a=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),l=h&d,n=l^h&g^r,o=f&y^~f&v,s=S+a+o+Hi[t+1]+m[t+1],i=e+n,S=p+s|0,p=s+i|0,e=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),a=(S>>>6|S<<26)^(S>>>11|S<<21)^(S>>>25|S<<7),c=p&h,n=c^p&d^l,o=S&f^~S&y,s=v+a+o+Hi[t+2]+m[t+2],i=e+n,v=g+s|0,g=s+i|0,e=(g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10),a=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7),u=g&p,n=u^g&h^c,o=v&S^~v&f,s=y+a+o+Hi[t+3]+m[t+3],i=e+n,y=d+s|0,d=s+i|0;this.h0=this.h0+d|0,this.h1=this.h1+g|0,this.h2=this.h2+p|0,this.h3=this.h3+h|0,this.h4=this.h4+y|0,this.h5=this.h5+v|0,this.h6=this.h6+S|0,this.h7=this.h7+f|0}hex(){this.finalize();const t=this.h0,e=this.h1,a=this.h2,n=this.h3,s=this.h4,i=this.h5,o=this.h6,r=this.h7;let l=Bi[t>>28&15]+Bi[t>>24&15]+Bi[t>>20&15]+Bi[t>>16&15]+Bi[t>>12&15]+Bi[t>>8&15]+Bi[t>>4&15]+Bi[15&t]+Bi[e>>28&15]+Bi[e>>24&15]+Bi[e>>20&15]+Bi[e>>16&15]+Bi[e>>12&15]+Bi[e>>8&15]+Bi[e>>4&15]+Bi[15&e]+Bi[a>>28&15]+Bi[a>>24&15]+Bi[a>>20&15]+Bi[a>>16&15]+Bi[a>>12&15]+Bi[a>>8&15]+Bi[a>>4&15]+Bi[15&a]+Bi[n>>28&15]+Bi[n>>24&15]+Bi[n>>20&15]+Bi[n>>16&15]+Bi[n>>12&15]+Bi[n>>8&15]+Bi[n>>4&15]+Bi[15&n]+Bi[s>>28&15]+Bi[s>>24&15]+Bi[s>>20&15]+Bi[s>>16&15]+Bi[s>>12&15]+Bi[s>>8&15]+Bi[s>>4&15]+Bi[15&s]+Bi[i>>28&15]+Bi[i>>24&15]+Bi[i>>20&15]+Bi[i>>16&15]+Bi[i>>12&15]+Bi[i>>8&15]+Bi[i>>4&15]+Bi[15&i]+Bi[o>>28&15]+Bi[o>>24&15]+Bi[o>>20&15]+Bi[o>>16&15]+Bi[o>>12&15]+Bi[o>>8&15]+Bi[o>>4&15]+Bi[15&o];return l+=Bi[r>>28&15]+Bi[r>>24&15]+Bi[r>>20&15]+Bi[r>>16&15]+Bi[r>>12&15]+Bi[r>>8&15]+Bi[r>>4&15]+Bi[15&r],l}digest(){this.finalize();const t=this.h0,e=this.h1,a=this.h2,n=this.h3,s=this.h4,i=this.h5,o=this.h6,r=this.h7,l=[t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e,a>>24&255,a>>16&255,a>>8&255,255&a,n>>24&255,n>>16&255,n>>8&255,255&n,s>>24&255,s>>16&255,s>>8&255,255&s,i>>24&255,i>>16&255,i>>8&255,255&i,o>>24&255,o>>16&255,o>>8&255,255&o];return l.push(r>>24&255,r>>16&255,r>>8&255,255&r),l}arrayBuffer(){this.finalize();const t=new ArrayBuffer(32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),e.setUint32(28,this.h7),t}}class Xi extends Yi{constructor(t,e=!1){let a;super(e),this.inner=void 0,this.oKeyPad=void 0;const n=typeof t;if("string"===n){const e=[],n=t.length;let s,i=0;for(a=0;a<n;++a)s=t.charCodeAt(a),s<128?e[i++]=s:s<2048?(e[i++]=192|s>>6,e[i++]=128|63&s):s<55296||s>=57344?(e[i++]=224|s>>12,e[i++]=128|s>>6&63,e[i++]=128|63&s):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++a)),e[i++]=240|s>>18,e[i++]=128|s>>12&63,e[i++]=128|s>>6&63,e[i++]=128|63&s);t=e}else{if("object"!==n)throw new Error(Gi);if(null===t)throw new Error(Gi);if(ji&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||ji&&ArrayBuffer.isView(t)))throw new Error(Gi)}var s;t.length>64&&(t=null==(s=new Yi(!0).update(t))?void 0:s.array());const i=[],o=[];for(a=0;a<64;++a){const e=t[a]||0;i[a]=92^e,o[a]=54^e}Yi.call(this,e),this.update(o),this.oKeyPad=i,this.inner=!0,this.sharedMemory=e}finalize(){if(super.finalize(),this.inner){this.inner=!1;const t=this.array();Yi.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),Yi.prototype.finalize.call(this)}}}const Qi=function(){const t=qi("hex");t.create=function(){return new Yi},t.update=function(e){return t.create().update(e)};for(let e=0;e<zi.length;++e){const a=zi[e];t[a]=qi(a)}return t}(),Zi=function(){const t=Ji("hex");t.create=function(t){return new Xi(t)},t.update=function(e,a){return t.create(e).update(a)};for(let e=0;e<zi.length;++e){const a=zi[e];t[a]=Ji(a)}return t}();async function to(t){const e=Qi.digest((new TextEncoder).encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function eo(t){const e=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function ao(t){var e,a;return null!=(e=window.crypto)&&null!=(a=e.subtle)&&a.digest?eo(t):(console.warn("Generating CodeChallenge in non-secure domain:",window.location.origin),to(t))}function no(t=16){let e="";for(let a=0;a<t;a++)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return e}var so=a(8792),io=a.n(so),oo=a(5875);const ro=(t="default")=>{if(!R.for(t).shouldLoadEntitlements())throw new Error("You must first enable entitlements via Frontegg options to use this function")},lo=(t,e,a,n,s="default")=>(ro(s),(0,oo.Me)(e,t,a)),co=(t,e,a,n,s="default")=>(ro(s),(0,oo.a_)(e,t,a)),uo=(t,e,a,n,s="default")=>"permissionKey"in e?lo(t,e.permissionKey,a,n,s):co(t,e.featureKey,a,n,s);function go(t,e){return io()(t,e)}let po,ho;!function(t){t.LOAD_SSO_CONFIGURATIONS="LOAD_SSO_CONFIGURATIONS",t.SAVE_SSO_CONFIGURATION="SAVE_SSO_CONFIGURATION",t.UPDATE_SSO_CONFIGURATION="UPDATE_SSO_CONFIGURATION",t.SAVE_SSO_CONFIGURATION_BY_METADATA="SAVE_SSO_CONFIGURATION_BY_METADATA",t.UPDATE_SSO_CONFIGURATION_BY_METADATA="UPDATE_SSO_CONFIGURATION",t.DELETE_SSO_CONFIGURATION="DELETE_SSO_CONFIGURATION",t.SAVE_SSO_DOMAIN="SAVE_SSO_DOMAIN",t.DELETE_SSO_DOMAIN="DELETE_SSO_DOMAIN",t.VALIDATE_SSO_DOMAIN="VALIDATE_SSO_DOMAIN",t.UPDATE_SSO_DEFAULT_ROLES="UPDATE_SSO_DEFAULT_ROLES",t.DELETE_SSO_GROUPS="DELETE_SSO_GROUPS",t.SAVE_SSO_GROUPS="SAVE_SSO_GROUPS",t.GET_SSO_AUTHORIZATION_ROLES="GET_SSO_AUTHORIZATION_ROLES"}(po||(po={})),function(t){t.Saml="saml",t.Okta="okta",t.Azure="azure",t.Google="google",t.Oidc="oidc"}(ho||(ho={}));const yo=["callback","error"],vo=["callback"],So=["callback"],fo=["callback"],mo=["callback"],bo=["callback","events"],Ao=["callback"],wo=["callback"],To=["user"],Eo=["callback"],Po=["callback"],Oo=["callback"],Io=["callback"],ko=["callback"],_o=["callback"],Uo=(t,e,a)=>{const n=a,s=R.for(t.root.appName),i=e=>{var a;const{routes:n,loginState:s}=t.auth,i=null!=(a=localStorage.getItem("register-quick-login"))?a:s.quickLoginToRegister;return i&&"true"!==localStorage.getItem(`${e.id}-${i}`)&&!window.location.pathname.endsWith(n.logoutUrl)},o=async()=>{t.auth.hostedLoginBox?await(async()=>{const a=t.auth.user;if(null==a||!a.refreshToken)return s.setAccessToken(null),s.setUser(null),void n.setAuthState({user:null,isAuthenticated:!1});try{const t={grant_type:"refresh_token",refresh_token:null==a?void 0:a.refreshToken},s=await e.auth.exchangeOAuthTokensV2(t),i=await r(s.user);n.afterAuthenticationStateUpdate(S({},s,{user:i}),{isAuthenticated:!0})}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:s,loginState:o,onRedirectTo:c}=t.auth,{user:u,tenants:d=[],activeTenant:g}=await e.auth.refreshTokenV3();if(Es(u,t.root.appName)){const t=await n.getMfaRequiredState(u);n.setAuthState(t),c(s.loginUrl,{preserveQueryParams:!0})}else{var a;u.id&&localStorage.setItem("userId",u.id);const t=null!=(a=localStorage.getItem("register-quick-login"))?a:o.quickLoginToRegister,e=i(u),s=await r(u);n.afterAuthenticationStateUpdate({user:s,tenants:d,activeTenant:g},{loginState:S({},o,{quickLoginToRegister:t,flow:e?Tn.RegisterQuickLogin:Tn.Login}),isAuthenticated:!0}),await l(e)}}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:void 0,isAuthenticated:!1})}})()},r=async e=>{var a;const n=null==(a=t.auth.user)?void 0:a.entitlements;return go(n,null==e?void 0:e.entitlements)?S({},e,{entitlements:n}):e},l=async e=>{var a;const s=new URL(null==(a=window)?void 0:a.location.href),{routes:i,loginState:o,onRedirectTo:r}=t.auth,l=s.searchParams.get("invitationToken"),c=[i.socialLoginCallbackUrl,i.oidcRedirectUrl,i.samlCallbackUrl,i.magicLinkCallbackUrl];l||c.push(i.loginUrl,i.signUpUrl),e?r(i.loginUrl):c.some((t=>t&&window.location.pathname.endsWith(t)))&&(o.isNewUser&&i.signUpSuccessUrl&&i.socialLoginCallbackUrl===window.location.pathname?r(i.signUpSuccessUrl,{refresh:i.signUpSuccessUrl.startsWith("http")}):await n.afterAuthNavigation())},c=async t=>{try{var a;const{isActive:s}=await Ln(e.auth.getSSOPublicConfiguration,null==t?void 0:t.retryConfig);n.setAuthState({isSSOAuth:s}),null==t||null==(a=t.callback)||a.call(t,{isSSOAuth:s})}catch(e){var s;n.setAuthState({isSSOAuth:!1}),null==t||null==(s=t.callback)||s.call(t,null,e)}},u=async t=>{let a;try{var s;const n=await Ln(e.metadata.getSamlMetadata,null==t?void 0:t.retryConfig);a=null==n||null==(s=n.configuration)?void 0:s.acsUrl}catch(t){console.error(t)}n.setAuthState({ssoACS:a})},d=e=>{Object.assign(t.auth.loginState,e)},g=t=>Dn({callback:(e,a)=>{!a||a.statusCode<500||n.setErrorByRequestName({requestName:t,traceId:Nn(a)})}}),p=async e=>{let{callback:a,error:s}=e,i=f(e,yo);const o=t.auth.securityPolicyState.publicPolicy.policy;if(null==o||!o.authStrategy)return n.setLoginState({step:wn.loginWithPassword,loading:!1}),void(null==a||a());(null==o?void 0:o.authStrategy)===N.EmailAndPassword?(n.setLoginState({step:wn.loginWithPassword,loading:!1}),null==a||a()):[N.MagicLink,N.Code,N.SmsCode].includes(null==o?void 0:o.authStrategy)?await n.passwordlessPreLogin(S({},i,{type:null==o?void 0:o.authStrategy,callback:a})):(n.setLoginState({step:wn.loginWithPassword,loading:!1,error:Bn(s)}),null==a||a())},h=async t=>{const{user:e,tenants:a=[],activeTenant:s}=t,i={step:ns.recoveryCode,loading:!1,error:void 0,saving:!1};null!=e&&e.recoveryCode&&(i.recoveryCode=e.recoveryCode),n.setMfaState(i),n.setUser(e),n.setTenantsState({tenants:a,activeTenant:s,loading:!1}),e.id&&localStorage.setItem("userId",e.id)};return S({setLoginState:d,resetLoginState:()=>{$n(t,["auth","loginState"],Ti)},requestAuthorize:async t=>{const e=[],a=[];e.push(o()),t&&(n.setAuthState({isLoading:!0}),e.push(n.loadSocialLoginsConfigurationV2(Dn())),e.push(n.loadAllowSignUps(g(Xn.LOAD_ALLOW_SIGNUPS))),e.push(n.loadPublicAuthStrategiesPolicy(g(Xn.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY))),e.push(n.loadSignUpStrategies()),e.push(c(g(Xn.LOAD_SSO_PUBLIC_CONFIGURATION))),e.push(n.loadVendorPublicInfo(Dn())),e.push(u(Dn())),a.push(n.loadCustomLoginRoutes(g(Xn.LOAD_CUSTOM_LOGIN_ROUTES)))),await Promise.all(e),a.length>0&&await Promise.all(a),n.setAuthState({isLoading:!1})},requestAuthorizeSSR:async e=>{const a=[];a.push(n.loadSocialLoginsConfigurationV2(Dn())),a.push(n.loadAllowSignUps(g(Xn.LOAD_ALLOW_SIGNUPS))),a.push(c(g(Xn.LOAD_SSO_PUBLIC_CONFIGURATION))),a.push(n.loadSignUpStrategies()),a.push(n.loadVendorPublicInfo(Dn())),a.push(u()),a.push((async({accessToken:e,user:a})=>{if(!e)return void n.setAuthState({user:void 0,isAuthenticated:!1});const{onRedirectTo:s,routes:i}=t.auth;if(Es(a,t.root.appName)){const t=await n.getMfaRequiredState(a,Un,!0);n.setAuthState(t),s(i.loginUrl,{preserveQueryParams:!0})}})(e)),a.push(n.loadCustomLoginRoutes(g(Xn.LOAD_CUSTOM_LOGIN_ROUTES))),await Promise.all(a)},preLogin:async a=>{const{email:n,username:s,recaptchaToken:i,invitationToken:o,callback:r}=a;d({loading:!0});try{const a=t.auth.onRedirectTo,u=cs(us),g=await e.auth.preLoginV2(S({},n?{email:n}:{},s?{username:s}:{},{tenantId:u})),{address:h,idpType:y}=null!=g?g:{};if(h){let e=h;if(y===ho.Oidc&&!e.includes("redirect_uri")){const{oidcRedirectUrl:a}=t.auth.routes;e+=`&redirect_uri=${window.location.origin}${a}`}var l;v.isLoginWithSSOAvailable()?(v.loginWithSSO(null!=(l=null!=n?n:s)?l:""),d({loading:!1}),null==r||r()):(d({step:wn.redirectToSSO,loading:!1,ssoRedirectUrl:e}),setTimeout((()=>{a(e,{refresh:!0})}),2e3))}else{var c;await p({email:null!=(c=null!=n?n:s)?c:"",recaptchaToken:i,callback:r,invitationToken:o})}}catch(t){var u;await p({email:null!=(u=null!=n?n:s)?u:"",recaptchaToken:i,callback:r,invitationToken:o,error:t})}},postLogin:async a=>{const{onRedirectTo:s,routes:i}=t.auth;d({loading:!0});try{const t=await e.auth.postLogin(a);n.setAuthState({user:t.accessToken?t:void 0,isAuthenticated:!!t.accessToken}),await n.afterAuthNavigation()}catch(t){setTimeout((()=>{s(i.authenticatedUrl)}),1e3),d({step:wn.loginWithSSOFailed,loading:!1})}},login:async a=>{const{email:i,username:o,password:r,recaptchaToken:l,invitationToken:c,callback:u}=a;d({loading:!0});try{const{user:a,tenants:s=[],activeTenant:g}=await e.auth.loginv2(S({},i?{email:i}:{},o?{username:o}:{},{password:r,recaptchaToken:l,invitationToken:c})),{onRedirectTo:p,routes:h}=t.auth;if(Es(a,t.root.appName)){const t=await n.getMfaRequiredState(a,Un,!0,i);n.setAuthState(t),p(h.loginUrl,{preserveQueryParams:!0})}else{const[e]=await n.getFeatureFlags(["security-center-show-login-flows"]);if(Ps(a,t.root.appName))d({step:wn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId});else{const o=t.auth.loginState,r=!!a.accessToken;a.id&&localStorage.setItem("userId",a.id),n.afterAuthenticationStateUpdate({user:a,tenants:s,activeTenant:g},{loginState:{flow:o.flow,quickLoginToRegister:o.quickLoginToRegister,email:i,loading:!1,error:void 0,mfaToken:a.mfaToken,step:o.flow===Tn.Login?wn.success:o.step,tenants:s,tenantsLoading:!0,isBreachedPassword:a.isBreachedPassword},isAuthenticated:r}),o.flow===Tn.Login&&(e&&a.isBreachedPassword&&!r?d({step:wn.breachedPassword,loading:!1}):r&&(fs(a)?d({step:wn.passwordRotationNotification,loading:!1}):await n.__shouldShowPromptPasskeys()?(d({step:wn.promptPasskeys,loading:!1}),p(h.loginUrl,{preserveQueryParams:!0})):await n.afterAuthNavigation()))}}v.isSuggestSavePasswordAvailable()&&v.suggestSavePassword(i,r),localStorage.removeItem("register-quick-login"),null==u||u(!0)}catch(t){s.setAccessToken(null),s.setUser(null),null==u||u(!1,t),d({email:i,error:Bn(t),loading:!1})}},logout:async a=>{const i=t.auth.hostedLoginBox;n.setAuthState({isLoading:!0});try{i?await e.auth.OAuthLogout():await e.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&ue(),n.resetAuthState(),await n.requestAuthorize(!0),null==a||a()},silentLogout:async t=>{var a;try{await e.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&ue(),setTimeout((()=>{var e;return null==t||null==(e=t.callback)?void 0:e.call(t,!0)}),null!=(a=null==t?void 0:t.callbackTimeout)?a:500)},recoverMfa:async t=>{d({loading:!0});try{var a;await e.auth.recoverMfaToken(t),d({loading:!1,error:void 0,step:wn.preLogin}),n.setAuthState({user:void 0,isAuthenticated:!1}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;d({error:Bn(e),loading:!1}),null==(s=t.callback)||s.call(t,!1,e)}},quickSmsPasswordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,vo);try{d({loading:!0});const t=await e.auth.passwordlessPreLogin(S({},n,{type:N.SmsCode}));d({step:wn.loginWithQuickSmsOtc,loading:!1,phoneNumber:null==t?void 0:t.phoneNumber,error:void 0}),null==a||a(!0)}catch(t){d({error:Bn(t),loading:!1}),null==a||a(!1,t)}},changePhoneNumberWithVerification:async t=>{const{callback:a}=t,n=f(t,So);try{d({loading:!0});const t=await e.auth.changePhoneNumberWithVerification(n);d({phoneNumber:n.phoneNumber,loading:!1,changePhoneId:t.changePhoneId,step:wn.loginWithQuickSmsOtc,error:void 0}),null==a||a(!0)}catch(t){d({error:Bn(t),loading:!1})}},verifyChangePhoneNumber:async t=>{const{callback:a}=t,n=f(t,fo);try{d({loading:!0}),await e.auth.verifyChangePhoneNumber(n),d({loading:!1}),null==a||a(!0)}catch(t){d({error:Bn(t),loading:!1})}},passwordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,mo);try{var s;let t,i;d({loading:!0}),ys(n)&&(t=n.email),vs(n)&&(i=n.username);const o=await e.auth.passwordlessPreLogin(S({},n,{email:t,username:null!=(s=i)?s:""})),r=On[n.type];d({step:r,loading:!1,phoneNumber:null==o?void 0:o.phoneNumber,email:t,error:void 0}),null==a||a()}catch(t){d({error:Bn(t),loading:!1}),null==a||a(null,t)}},passwordlessPostLogin:async a=>{const{callback:s,events:i}=a,o=f(a,bo);try{d({loading:!0});const{user:l,tenants:c=[],activeTenant:u}=await e.auth.passwordlessPostLoginV2(o),{routes:g,onRedirectTo:p}=t.auth;if(Es(l,t.root.appName)){const t=await n.getMfaRequiredState(l);n.setAuthState(t),p(g.loginUrl,{preserveQueryParams:!0})}else{const e=t.auth.loginState;if(l.emailVerified){var r;const t={email:l.email,origin:Qn.PASSWORDLESS,id:l.id,tenantId:l.tenantId,createdAt:new Date,name:l.name};null==i||null==(r=i.userVerified)||r.call(i,t),ss(as.USER_VERIFIED,t)}l.id&&localStorage.setItem("userId",l.id),n.afterAuthenticationStateUpdate({user:l,tenants:c,activeTenant:u}),d({error:void 0}),n.setAuthState({isLoading:!1}),e.flow===Tn.Login?await n.__shouldShowPromptPasskeys()?(n.setLoginState({step:wn.promptPasskeys,loading:!1}),p(g.loginUrl,{preserveQueryParams:!0})):(n.setAuthState({isAuthenticated:!0}),a.type===N.MagicLink&&(n.setLoginState({step:wn.magicLinkPostLoginSuccess,loading:!1}),await Rn(5e3)),await n.afterAuthNavigation()):p(g.loginUrl,{preserveQueryParams:!0}),localStorage.removeItem("register-quick-login"),null==s||s(!0)}}catch(t){d({error:Bn(t,"Failed to authenticate")}),null==s||s(null,t)}finally{d({loading:!1})}},verifyInviteToken:async t=>{try{d({loading:!0});const{name:a}=await e.auth.verifyInviteToken(t);d({inviteTokenTenantName:a})}catch(t){d({inviteTokenError:Bn(t,"We couldn't verify your invitation")})}finally{d({loading:!1})}},webAuthnPrelogin:async t=>{const{callback:a}=t,s=f(t,Ao);try{var i;n.setPasskeysState({loading:!0}),d({loading:!0});const{options:t}=await e.auth.webAuthnPreLogin(s);t.challenge=Di(t.challenge),t.allowCredentials=null==(i=t.allowCredentials)?void 0:i.map((t=>S({},t,{id:Di(t.id)}))),d({error:void 0}),null==a||a(t)}catch(t){d({error:Bn(t)}),null==a||a(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnPostLogin:async a=>{const{callback:s}=a,i=f(a,wo);try{var o;n.setPasskeysState({loading:!0}),d({loading:!0});const a=Mi(i.publicKey),r=await e.auth.webAuthnPostLoginV2(S({},a,{response:S({},a.response,{userHandle:null!=(o=a.response.userHandle)?o:void 0}),recaptchaToken:i.recaptchaToken,invitationToken:i.invitationToken})),{user:l}=r,c=f(r,To);if(Es(l,t.root.appName)){const{routes:e,onRedirectTo:a}=t.auth,s=await n.getMfaRequiredState(l);n.setAuthState(s),a(e.loginUrl,{preserveQueryParams:!0})}else l.id&&localStorage.setItem("userId",l.id),n.afterAuthenticationStateUpdate(S({user:l},c),{isAuthenticated:!0}),d({error:void 0}),await n.afterAuthNavigation(),null==s||s(!0)}catch(t){d({error:Bn(t)}),null==s||s(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnCreateNewDeviceSession:async t=>{const{callback:a}=t;try{d({loading:!0});const{options:t}=await e.auth.webAuthnCreateNewDeviceSession();t.user.id=Di(t.user.id),t.challenge=Di(t.challenge),t.excludeCredentials=[],null==a||a(t)}catch(t){d({error:Bn(t)}),null==a||a(null)}finally{d({loading:!1})}},webAuthnVerifyNewDeviceSession:async t=>{const{callback:a}=t,n=f(t,Eo);try{d({loading:!0});const t=Mi(n.publicKey),s="platform"===(null==t?void 0:t.authenticatorAttachment)?Xt.Platform:Xt.CrossPlatform;await e.auth.verifyNewDeviceSession({id:t.id,response:t.response,deviceType:s}),null==a||a(!0)}catch(t){d({error:Bn(t)}),null==a||a(null)}finally{d({loading:!1})}},getUserIP:async t=>{const{callback:a}=t;try{n.setAuthState({userIpData:{loading:!0}});const{ip:t,country_code:s}=await e.metadata.getCurrentUserIpMetadata();n.setAuthState({userIpData:{ip:t,countryCode:s,loading:!1}}),n.setAuthState({userIp:t}),null==a||a({ip:t,countryCode:s})}catch(t){n.setAuthState({userIpData:{loading:!1}}),null==a||a(!1)}},preEnrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,Po);d({loading:!0});try{var s;const t=await e.auth.preEnrollMFAWebAuthnForLogin(n),i=S({},t.options,{challenge:Di(t.options.challenge),user:S({},t.options.user,{id:Di(t.options.user.id)}),excludeCredentials:null==(s=t.options.excludeCredentials)?void 0:s.map((t=>S({},t,{id:Di(t.id)})))});d({loading:!1}),null==a||a({options:i,webauthnToken:t.webauthnToken})}catch(t){d({loading:!1,error:Bn(t)}),null==a||a(null)}},enrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,Oo);d({loading:!0});try{const t=Mi(n.publicKey),s=await e.auth.enrollMFAWebAuthnForLoginV2(S({},n,{options:t}));await h(s),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Bn(t)}),null==a||a(null)}},enrollMFAAuthenticatorAppForLogin:async t=>{const{callback:a}=t,n=f(t,Io);d({loading:!0});try{const t=await e.auth.enrollMFAAuthenticatorAppForLoginV2(n);await h(t),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Bn(t)}),null==a||a(null)}},preEnrollMFASMSForLogin:async t=>{const{callback:a}=t,s=f(t,ko);d({loading:!0});try{const t=await e.auth.preEnrollMFASMSForLogin(s);n.setMfaState({otcToken:t.otcToken,step:ns.smsVerifyCode,phoneNumber:t.phoneNumber}),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Bn(t)}),null==a||a(null)}},enrollMFASMSForLogin:async t=>{const{callback:a}=t,n=f(t,_o);d({loading:!0});try{const t=await e.auth.enrollMFASMSForLoginV2(n);await h(t),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Bn(t)}),null==a||a(null)}},handleEnrollMFAResponse:h,resetBreachedPassword:async t=>{d({loading:!0});try{await e.auth.forgotPassword(t),d({loading:!1,error:void 0,step:wn.breachedPasswordSuccess}),n.setAuthState({isAuthenticated:!1})}catch(t){d({loading:!1,error:Bn(t)})}},refreshTokenForSocialLogins:async()=>{t.auth.hostedLoginBox?await(async()=>{const{user:a}=t.auth;if(null==a||!a.refreshToken)return s.setAccessToken(null),s.setUser(null),void n.setAuthState({user:null,isAuthenticated:!1});try{const t={grant_type:"refresh_token",refresh_token:null==a?void 0:a.refreshToken},s=await e.auth.exchangeOAuthTokensV2(t),i=await r(s.user);n.afterAuthenticationStateUpdate(S({},s,{user:i}),{isAuthenticated:!0})}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:s,loginState:o,onRedirectTo:c}=t.auth,{user:u,tenants:d=[],activeTenant:g}=await e.auth.refreshTokenV3();if(Es(u,t.root.appName)){const t=await n.getMfaRequiredState(u);n.setAuthState(t),c(s.loginUrl,{preserveQueryParams:!0})}else{const t=await r(u);if(await n.__shouldShowPromptPasskeys())n.setLoginState({step:wn.promptPasskeys,loading:!1}),n.afterAuthenticationStateUpdate({user:t,tenants:d,activeTenant:g},{isLoading:!1}),c(s.loginUrl,{preserveQueryParams:!0});else{var a;u.id&&localStorage.setItem("userId",u.id);const e=null!=(a=localStorage.getItem("register-quick-login"))?a:o.quickLoginToRegister,s=i(u);n.afterAuthenticationStateUpdate({user:t,tenants:d,activeTenant:g},{loginState:S({},o,{quickLoginToRegister:e,flow:s?Tn.RegisterQuickLogin:Tn.Login}),isAuthenticated:!0}),await l(s)}}}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:void 0,isAuthenticated:!1})}})()},__refreshToken:o},((t,e,a)=>{const n=a,s=async()=>{const t=await e.auth.silentOAuthRefreshTokenV2();if(null==t||!t.user)throw new Error("couldn't refresh user token with oauth service");await n.afterAuthenticationStateUpdate(t,{isAuthenticated:!0,isLoading:!1})},i=async a=>{var s;const{routes:i,onRedirectTo:o}=t.auth,{context:r,urlStrategy:l}=t.root;if(Is(l)===i.hostedLoginRedirectUrl)return void console.debug("Calling loginWithRedirect while in hostedLoginCallback route");n.setAuthState({isLoading:!0});const c=no(),u=no(),d=await ao(u);localStorage.setItem(_n,u);const g=Ss(t);let p=`${window.location.origin}${"path"===l?"":"#"}${null!=g?g:""}${i.hostedLoginRedirectUrl}`;await n.loadCustomLoginRoutes();const h=null==(s=t.auth.customLoginState)?void 0:s.customLoginSearchParams;h&&(p.endsWith("/")&&(p=p.slice(0,-1)),p+=h);const y=`${e.fetch.getBaseUrl(r,"/oauth/authorize")}/oauth/authorize`,v=S({response_type:"code",client_id:r.appId||r.clientId||"INVALID-CLIENT-ID",scope:"openid email profile",redirect_uri:p,code_challenge:d,code_challenge_method:"S256",nonce:c},a);if(r.tenantResolver){var f;const t=await(null==(f=r.tenantResolver)?void 0:f.call(r));null!=t&&t.tenant&&(v.organization=t.tenant)}const m=cs(us);m&&(v.tenantId=m),o(`${y}?${new URLSearchParams(v).toString()}`,{refresh:!0})};return{requestHostedLoginAuthorize:async e=>{var a;null==(a=localStorage)||a.removeItem(bn);const n=t.auth.disableSilentRefresh;if("login"===(null==e?void 0:e.prompt))return await i(e);try{if(n)throw new Error("silent refresh is disabled");return await s()}catch(t){return await i(e)}},requestHostedLoginAuthorizeV2:async e=>{var a,o;const{shouldRedirectToLogin:r,firstTime:l,loginDirectAction:c}=null!=e?e:{};let{additionalParams:u}=null!=e?e:{};if(null==(a=localStorage)||a.removeItem(bn),l){const e=t.root.urlStrategy,a=Is(e);if(n.setAuthState({isLoading:!0}),hs(a))return}const d=t.auth.disableSilentRefresh;if(c&&(u=u||{},u.login_direct_action=btoa(JSON.stringify(c))),"login"===(null==(o=u)?void 0:o.prompt))return await i(u);try{if(d)throw new Error("silent refresh is disabled");return await s()}catch(t){return r?await i(u):void n.setAuthState({isLoading:!1})}},__requestHostedLoginAuthorize:i,__requestHostedLoginSilentAuthorize:s,handleHostedLoginCallback:async a=>{var s;const i=localStorage.getItem(_n)||"INVALID-CODE-VERIFIER",o=t.auth.routes,r=t.root.urlStrategy,l=Ss(t);let c=`${window.location.origin}${"path"===r?"":"#"}${null!=l?l:""}${o.hostedLoginRedirectUrl}`;await n.loadCustomLoginRoutes();const u=null==(s=t.auth.customLoginState)?void 0:s.customLoginSearchParams;u&&(c.endsWith("/")&&(c=c.slice(0,-1)),c+=u);const d={code:a.code,redirect_uri:c,code_verifier:i,grant_type:"authorization_code"};try{const t=await e.auth.exchangeOAuthTokensV2(d);n.afterAuthenticationStateUpdate(t,{isAuthenticated:!0,isLoading:!1})}catch(t){n.setAuthState({isLoading:!1}),console.error("Failed to exchangeOAuthTokens",t)}finally{const e=t.auth.user,a=window.localStorage.getItem(bn);window.localStorage.removeItem(bn),a&&ms(e)?await n.afterStepUpAuthNavigation():await n.afterAuthNavigation()}}}})(t,e,a),Pi(t,0,a),function(t,e,a){const n=a,s=async()=>await n.afterStepUpAuthNavigation(),i=async(e,a)=>{const s=t.auth.loginState,i=t.auth.mfaState.step,[o]=await n.getFeatureFlags(["security-center-show-login-flows"]);if(s.flow===Tn.Login){if(o&&s.isBreachedPassword&&!e)return void n.setLoginState({step:wn.breachedPassword,loading:!1});if(Ps(a,t.root.appName))return void n.setLoginState({step:wn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId});if(fs(a))return void n.setLoginState({step:wn.passwordRotationNotification,loading:!1});const r=await n.__shouldShowPromptPasskeys();i===ns.smsVerifyCode&&r?n.setLoginState({step:wn.promptPasskeys,loading:!1}):await n.afterAuthNavigation()}};return{postHandleVerifyMFAResponseForStepUp:s,postHandleVerifyMFAResponseForLogin:i,handleVerifyMFAResponse:async(t,e=!1)=>{const{user:a,tenants:o,activeTenant:r}=t;n.setUser(a),n.setTenantsState({tenants:o,activeTenant:r,loading:!1}),a.id&&localStorage.setItem("userId",a.id);const l=!!a.accessToken;return n.setAuthState({isAuthenticated:l}),e?await s():await i(l,a)},getFeatureFlags:async e=>{const a=t.root.appName;return ae.getFeatureFlags(e,a)}}}(t,0,a),((t,e)=>({getMfaRequiredState:async(a,n,s=!1,i)=>{var o,r,l;let c=wn.loginWithTwoFactor;const u={step:ns.verify,loading:!1,saving:!1},d=t.auth.loginState;let g,p;try{const t=await Ln((()=>e.auth.checkIfAllowToRememberMfaDevice(a.mfaToken)),n);g=t.isAllowedToRemember,p=t.mfaDeviceExpiration}catch(t){if(!s)throw t}!("mfaEnrolled"in a)||a.mfaEnrolled||(null==(o=a.mfaDevices)||null==(r=o.emails)?void 0:r.length)?Object.assign(u,{mfaDevices:a.mfaDevices,mfaToken:a.mfaToken,step:gs(a.mfaDevices)}):(Object.assign(u,{step:ps(a.mfaStrategies),qrCode:a.qrCode,recoveryCode:a.recoveryCode,loading:!1,mfaToken:a.mfaToken,mfaStrategies:a.mfaStrategies}),c=wn.forceTwoFactor);let h={};const y=localStorage.getItem("register-quick-login");return y&&(h={quickLoginToRegister:y,flow:Tn.RegisterQuickLogin}),{user:void 0,isAuthenticated:!1,mfaState:u,loginState:S({},d,h,{mfaToken:a.mfaToken,mfaRequired:a.mfaRequired,loading:!1,error:void 0,step:c,tenantsLoading:!0,email:null!=(l=a.userEmail)?l:i,tenants:[],allowRememberMfaDevice:g,mfaDeviceExpiration:p,isBreachedPassword:a.isBreachedPassword})}}}))(t,e),((t,e,a)=>{const n=a,s=async(a,s,i)=>{let{callback:o}=a,r=f(a,Oi);s({loading:!0,error:void 0});try{const{user:a,tenants:l=[],activeTenant:c}=await e.auth.loginWithMfaV2(r),u=!!a.accessToken,d=await async function(e,a,n){const s=t.auth.loginState;let i={};if(!n){const t=s.flow===Tn.Login?wn.success:s.step;i={loginState:{flow:s.flow,quickLoginToRegister:s.quickLoginToRegister,loading:!1,step:t,error:void 0,tenants:e}}}return S({},i,{isAuthenticated:a})}(l,u,i);return await n.afterAuthenticationStateUpdate({user:a,tenants:l,activeTenant:c},d),a.id&&localStorage.setItem("userId",a.id),s({loading:!1,error:void 0}),i?await async function(t){await n.afterStepUpAuthNavigation(),null==t||t(!0)}(o):await async function(e,a,s){const i=t.auth.loginState;if(i.flow!==Tn.Login)return;const[o]=await n.getFeatureFlags(["security-center-show-login-flows"]);return o&&i.isBreachedPassword&&!e?(n.setLoginState({step:wn.breachedPassword,loading:!1}),void(null==s||s(!0))):Ps(a,t.root.appName)?(n.setLoginState({step:wn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId}),void(null==s||s(!0))):fs(a)?(n.setLoginState({step:wn.passwordRotationNotification,loading:!1}),void(null==s||s(!0))):(await n.__shouldShowPromptPasskeys()?n.setLoginState({step:wn.promptPasskeys,loading:!1}):await n.afterAuthNavigation(),void(null==s||s(!0)))}(u,a,o)}catch(t){s({loading:!1,error:Bn(t)}),null==o||o(!1,t)}};return{mfaWithAuthenticator:s,loginWithMfa:async t=>await s(t,n.setLoginState,!1)}})(t,e,a),((t,e,a)=>{const n=a,s=async(t,a)=>{var s;let{callback:i}=t,o=f(t,Ii);(a=null!=(s=a)?s:n.setLoginState)({loading:!0,error:void 0});try{const t=await e.auth.preVerifyMFAEmailCode(o);n.setMfaState({otcToken:t.otcToken,step:ns.emailVerifyCode}),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({error:Bn(t)}),null==i||i(null)}},i=async(t,a)=>{var s;let{callback:i}=t,o=f(t,ki);(a=null!=(s=a)?s:n.setLoginState)({loading:!0});try{const t=await e.auth.verifyMFAEmailCodeV2(o);await n.handleVerifyMFAResponse(t),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Bn(t)}),null==i||i(null)}};return{preVerifyMFAEmailCode:s,verifyMFAEmailCode:i,preVerifyMFAEmailCodeForLogin:async t=>await s(t,n.setLoginState),verifyMFAEmailCodeForLogin:async t=>await i(t,n.setLoginState)}})(0,e,a),((t,e,a)=>{const n=a,s=async(t,a)=>{let{callback:s,deviceId:i}=t,o=f(t,_i);a({loading:!1,error:void 0});try{const t=await e.auth.preVerifyMFASMSForLogin(i,o);n.setMfaState({otcToken:t.otcToken,step:ns.smsVerifyCode,phoneNumber:t.phoneNumber}),a({loading:!1,error:void 0}),null==s||s(!0)}catch(t){a({loading:!1,error:Bn(t)}),null==s||s(null)}},i=async(t,a,s=!1)=>{let{callback:i,deviceId:o}=t,r=f(t,Ui);a({loading:!0});try{const t=await e.auth.verifyMFASMSForLoginV2(o,r);await n.handleVerifyMFAResponse(t,s),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Bn(t)}),null==i||i(null)}};return{preVerifyMFASMS:s,verifyMFASMS:i,preVerifyMFASMSForLogin:async t=>await s(t,n.setLoginState),verifyMFASMSForLogin:async t=>await i(t,n.setLoginState,!1)}})(0,e,a),((t,e,a)=>{const n=a,s=async(t,a)=>{let{callback:n,deviceId:s}=t,i=f(t,xi);a({loading:!0});try{var o;const t=await e.auth.preVerifyMFAWebAuthnForLogin(s,i),r=S({},t.options,{challenge:Di(t.options.challenge),allowCredentials:null==(o=t.options.allowCredentials)?void 0:o.map((t=>S({},t,{id:Di(t.id)})))});a({loading:!1,error:void 0}),null==n||n({options:r,webauthnToken:t.webauthnToken})}catch(t){a({loading:!1,error:Bn(t)}),null==n||n(null)}},i=async(t,a,s)=>{let{callback:i,deviceId:o}=t,r=f(t,$i);a({loading:!0});try{const t=Mi(r.publicKey),l=await e.auth.verifyMFAWebAuthnForLoginV2(o,S({},r,{options:t}));await n.handleVerifyMFAResponse(l,s),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Bn(t)}),null==i||i(null)}};return{preVerifyMFAWebAuthn:s,verifyMFAWebAuthn:i,preVerifyMFAWebAuthnForLogin:async t=>await s(t,n.setLoginState),verifyMFAWebAuthnForLogin:async t=>await i(t,n.setLoginState,!1)}})(0,e,a))},Ro={step:ns.verify,loading:!1,saving:!1},Co=t=>cn(Ro,t),Lo=["callback"],Do=["callback"],No=["user"],Mo=["deviceId"],Fo=["deviceId"],xo=["callback"],$o=["callback"],Go=["deviceId","callback"],jo=(t,e,a)=>{const n=a;async function s(e){const a=t.auth.mfaState.step;return{step:e.recoveryCode?ns.recoveryCode:a,loading:!1,saving:!1,error:void 0,recoveryCode:null==e?void 0:e.recoveryCode}}const i=e=>{Object.assign(t.auth.mfaState,e)};return{setMfaState:i,resetMfaState:()=>{$n(t,["auth","mfaState"],Ro)},getMFADevices:async()=>{i({loading:!0});try{const t=await e.auth.getMFADevices();i({loading:!1,error:void 0,mfaDevices:t})}catch(t){i({loading:!1,error:Bn(t)})}},getMFAStrategies:async t=>{i({loading:!0});try{const a=(await Ln((()=>e.auth.getMFAStrategiesConfig()),null==t?void 0:t.retryConfig)).strategies.filter((({isActive:t})=>t)).map((({strategy:t})=>t));i({loading:!1,error:void 0,mfaStrategies:a})}catch(t){i({loading:!1,error:Bn(t)})}},enrollMfa:async()=>{i({saving:!0});try{const{qrCode:t}=await e.auth.enrollMfa();i({saving:!1,error:void 0,qrCode:t})}catch(t){i({saving:!1,error:Bn(t)})}},verifyMfa:async a=>{const{callback:o}=a,r=f(a,Lo);i({saving:!0});try{const a=t.auth.user,l=await e.auth.verifyMfa(r),c=await e.auth.getMFADevices(),u=await s(l);i(S({},u,{mfaDevices:c})),n.setUser(S({},a,{mfaEnrolled:!0})),null==o||o(u.recoveryCode)}catch(t){i({saving:!1,error:Bn(t)}),null==o||o(null,t)}},verifyMfaAfterForce:async t=>{const{callback:a}=t,s=f(t,Do);i({loading:!0});try{const t=await e.auth.loginWithMfaV2(s),{user:o}=t,r=f(t,No),l={step:ns.recoveryCode,loading:!1,saving:!1,error:void 0};null!=o&&o.recoveryCode&&(l.recoveryCode=o.recoveryCode),i(l),await n.afterAuthenticationStateUpdate(S({user:o},r)),null==a||a(l.recoveryCode)}catch(t){i({loading:!1,error:Bn(t)}),null==a||a(null,t)}},disableMfa:async t=>{i({saving:!0});try{var a;await e.auth.disableMfa(t);const n=await e.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:n}),null==(a=t.callback)||a.call(t,!0)}catch(e){var n;i({saving:!1,error:Bn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},preDisableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,Mo);i({saving:!0});try{var s;const t=await e.auth.preDisableMFASMS(a);i({saving:!1,error:void 0,otcToken:t.otcToken,phoneNumber:t.phoneNumber}),null==(s=n.callback)||s.call(n,!0)}catch(t){var o;i({saving:!1,error:Bn(t)}),null==(o=n.callback)||o.call(n,!1,t)}},disableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,Fo);i({saving:!0});try{var s;await e.auth.disableMFASMS(a,n);const t=await e.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:t}),null==(s=n.callback)||s.call(n,!0)}catch(t){var o;i({saving:!1,error:Bn(t)}),null==(o=n.callback)||o.call(n,!1,t)}},preEnrollMfaSms:async t=>{i({saving:!0});try{var a;const n=await e.auth.preEnrollMFASMS(t);i({saving:!1,error:void 0,otcToken:n.otcToken,phoneNumber:n.phoneNumber}),null==(a=t.callback)||a.call(t,!0)}catch(e){var n;i({saving:!1,error:Bn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},enrollMfaSms:async t=>{const{callback:a}=t,n=f(t,xo);i({saving:!0});try{const t=await e.auth.enrollMFASMS(n),o=await e.auth.getMFADevices(),r=await s(t);i(S({},r,{mfaDevices:o})),null==a||a(r.recoveryCode)}catch(t){i({saving:!1,error:Bn(t)}),null==a||a(null,t)}},preEnrollMfaWebAuthn:async t=>{i({saving:!0});try{var a,n;const s=await e.auth.preEnrollMFAWebAuthn(),o=S({},s.options,{challenge:Di(s.options.challenge),user:S({},s.options.user,{id:Di(s.options.user.id)}),excludeCredentials:null==(a=s.options.excludeCredentials)?void 0:a.map((t=>S({},t,{id:Di(t.id)})))});i({saving:!1}),null==(n=t.callback)||n.call(t,{options:o,webauthnToken:s.webauthnToken})}catch(e){var s;i({saving:!1,error:Bn(e)}),null==(s=t.callback)||s.call(t,null,e)}},enrollMfaWebAuthn:async t=>{const{callback:a}=t,n=f(t,$o);i({saving:!0});try{const t=Mi(n.publicKey),o=await e.auth.enrollMFAWebAuthn(S({},n,{options:t})),r=await e.auth.getMFADevices(),l=await s(o);i(S({},l,{mfaDevices:r})),null==a||a(l.recoveryCode)}catch(t){i({saving:!1,error:Bn(t)}),null==a||a(null,t)}},preDisableMfaWebAuthn:async t=>{const{deviceId:a,callback:n}=t;i({saving:!0});try{var s;const t=await e.auth.preDisableMFAWebAuthn(a),o=S({},t.options,{challenge:Di(t.options.challenge),allowCredentials:null==(s=t.options.allowCredentials)?void 0:s.map((t=>S({},t,{id:Di(t.id)})))});i({saving:!1}),null==n||n({options:o,webauthnToken:t.webauthnToken})}catch(t){i({saving:!1,error:Bn(t)}),null==n||n(null,t)}},disableMfaWebAuthn:async t=>{const{deviceId:a,callback:n}=t,s=f(t,Go);i({saving:!0});try{const t=Mi(s.publicKey);await e.auth.disableMFAWebAuthn(a,S({},s,{options:t}));const o=await e.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:o}),null==n||n(!0)}catch(t){i({saving:!1,error:Bn(t)}),null==n||n(!1,t)}},__getMfaStateAfterEnroll:s}},Bo={loaders:{},errors:{},accounts:{tenantId:"",children:[]},accountsQueryParams:{_limit:50,_offset:0,_filter:"",_subTenantId:""},searchAccountsData:[],rootAccount:{tenantId:""},selectedAccount:{tenantId:"",userJwt:{accessToken:"",expiresIn:0,expires:""},users:[],usersQueryParams:{_offset:0,_limit:10,_order:Bt.DESC,_sortBy:Ka.name},usersPageOffset:0,accountSettings:{}}},Vo=t=>cn(Bo,t),Wo={createSubAccountDialog:{loading:!1,open:!1,error:!1,jwt:"",canSelectParentAccount:!1},updateSubAccountDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1,jwt:""},disableSubAccountManagementDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1},enableSubAccountManagementDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1},updateSubAccountHierarchySettingsDialog:{accountId:"",accountName:"",subAccountAccessType:Ma.DEFAULT_OFF,loading:!1,open:!1,error:!1},deleteSubAccountDialog:{accountId:"",accountName:"",isParentAccount:!1,loading:!1,open:!1,error:!1,jwt:""},addUsersToAccountDialog:{loading:!1,open:!1,accountName:"",accountId:"",permissionToGiveAccessToSubAccounts:!1,jwt:""},deleteUserFromAccountDialog:{userId:"",userName:"",accountId:"",loading:!1,open:!1,jwt:""},editUserRolesDialog:{loading:!1,open:!1,jwt:"",accountId:"",userId:"",userName:"",userRoles:[]}},Ho=t=>cn(Wo,t);let zo;!function(t){t.GET_ACCOUNTS="GET_ACCOUNTS",t.SEARCH_ACCOUNTS="SEARCH_ACCOUNTS",t.SET_ROOT_ACCOUNT_DATA="SET_ROOT_ACCOUNT_DATA",t.SET_SELECTED_SUB_ACCOUNT_DATA="SET_SELECTED_SUB_ACCOUNT_DATA",t.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT="LOAD_NUMBER_OF_USERS_FOR_ACCOUNT",t.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER="UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER",t.CREATE_SUB_ACCOUNT="CREATE_SUB_ACCOUNT",t.UPDATE_SUB_ACCOUNT="UPDATE_SUB_ACCOUNT",t.DELETE_SUB_ACCOUNT="DELETE_SUB_ACCOUNT",t.GET_ACCOUNT_USERS="GET_ACCOUNT_USERS",t.ADD_USERS_TO_ACCOUNT="ADD_USERS_TO_ACCOUNT",t.DELETE_USERS_FROM_ACCOUNT="DELETE_USERS_FROM_ACCOUNT",t.SET_USER_ROLES_FOR_SUB_ACCOUNT="SET_USER_ROLES_FOR_SUB_ACCOUNT",t.UPDATE_SUB_ACCOUNT_SETTINGS="UPDATE_SUB_ACCOUNT_SETTINGS",t.UPDATE_SUB_ACCOUNT_MANAGEMENT="UPDATE_SUB_ACCOUNT_MANAGEMENT",t.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS="UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS",t.GET_USER_JWT="GET_USER_JWT",t.GET_TEAM_USERS="GET_TEAM_USERS"}(zo||(zo={}));const Ko=({items:t},e)=>t.map((t=>{var a,n;return{name:t.name,tenantId:t.tenantId,numberOfUsers:null!=(a=null==(n=e.find((e=>e.tenantId===t.tenantId)))?void 0:n.totalUsers)?a:0,createdAt:t.createdAt,metadata:t.metadata,isReseller:t.isReseller,subAccountAccessType:t.subAccountAccessType}}));function qo(t,e,a){var n,s,i;return t.tenantId===e?S({},t,{children:[...null!=(i=null==t?void 0:t.children)?i:[],...a].filter(((t,e,a)=>e===a.findIndex((e=>e.tenantId===t.tenantId))))}):S({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>qo(t,e,a))))?n:[]})}function Jo(t,e){var a;return S({},t,{children:null!=(a=t.children)&&a.length?t.children.filter((t=>t.tenantId!==e)).map((t=>Jo(t,e))):[]})}const Yo=(t,e,a)=>{var n,s;return t.tenantId===e?S({},t,{subAccountAccessType:a}):S({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Yo(t,e,a))))?n:[]})},Xo=(t,e,a)=>{var n,s;return t.tenantId===e?S({},t,{name:a}):S({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Xo(t,e,a))))?n:[]})},Qo=(t,e,a)=>{var n,s;return t?t.tenantId===e?S({},t,{isReseller:a}):S({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Qo(t,e,a))))?n:[]}):{}},Zo=(t,e,a)=>{const n=e=>{Object.assign(t.auth.allAccountsState,{loaders:S({},t.auth.allAccountsState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.allAccountsState,{errors:S({},t.auth.allAccountsState.errors,{[e.key]:e.value}),loaders:S({},t.auth.allAccountsState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.allAccountsState,e)},o=e=>{Object.assign(t.auth.allAccountsState.selectedAccount,e)},r=()=>t.auth.allAccountsState,l=async t=>{var a,i,l,c,u,d,g,p;const{jwt:h,_tenantId:y,_email:v}=t,f=zo.GET_ACCOUNT_USERS;n({key:f,value:!0});const m=r(),b=null!=(a=null!=(i=null==t?void 0:t._offset)?i:null==m||null==(l=m.selectedAccount)||null==(c=l.usersQueryParams)?void 0:c._offset)?a:0,A=null!=(u=null!=(d=null==t?void 0:t._limit)?d:null==m||null==(g=m.selectedAccount)||null==(p=g.usersQueryParams)?void 0:p._limit)?u:10,w=S({_offset:b,_limit:A,_tenantId:y,_includeSubTenants:!1},!!v&&{_email:v});try{const{items:t,_metadata:{totalItems:a,totalPages:n}}=await e.users.getUsersV3(w,{jwt:h}),s={totalUsersItems:a,totalUsersPages:n,usersQueryParams:S({_offset:null!=b?b:0,_limit:null!=A?A:10},!!v&&{_email:v})};if(t.length){const a=t.map((t=>t.id)),n=await e.roles.getRoles(),i=await e.users.getUsersRoles({ids:a},{jwt:h}),r=t.map((t=>{var e,a;const s=null==i||null==(e=i.find((e=>e.userId===t.id)))?void 0:e.roleIds;return S({},t,{roles:null!=(a=null==s?void 0:s.map((t=>{var e;return null!=(e=null==n?void 0:n.find((e=>e.id===t)))?e:[]})))?a:[]})}));o(S({users:r},s))}else o(S({users:[]},s))}catch(t){s({key:f,value:Bn(t)})}finally{n({key:f,value:!1})}};return{setAllAccountsLoader:n,setAllAccountsError:s,setAllAccountsState:i,setSelectedAccountState:o,resetAllAccountsState:()=>{$n(t,["auth","allAccountsState"],Bo)},clearSelectedAccount:()=>{$n(t,["auth","allAccountsState","selectedAccount"],Bo.selectedAccount)},loadAccounts:async t=>{const a=zo.GET_ACCOUNTS;n({key:a,value:!0});const{accountsQueryParams:l}=r(),{jwt:c,_limit:u,_offset:d}=t,g={_offset:null!=d?d:l._offset,_limit:null!=u?u:l._limit,_subTenantId:null==t?void 0:t._subTenantId};try{if(c){var p;const{selectedAccount:a}=r(),{items:n,_links:s}=await e.tenants.searchSubTenants(g,{jwt:c}),i=await e.tenants.getTenantsUsersCount({tenantIds:n.map((t=>t.tenantId))},{jwt:c}),l=Ko({items:n},i),u=qo(a.accounts?a.accounts:a,null!=(p=null==t?void 0:t._subTenantId)?p:"",l.map((t=>({name:t.name,tenantId:t.tenantId,numberOfUsers:t.numberOfUsers,createdAt:t.createdAt,metadata:t.metadata,children:[],loadMoreLink:null==s?void 0:s.next,isReseller:t.isReseller}))));o({accounts:u})}else{var h;const{accounts:a}=r(),{items:n,_links:s}=await e.tenants.searchSubTenants(g),o=await e.tenants.getTenantsUsersCount({tenantIds:n.map((t=>t.tenantId))}),l=Ko({items:n},o),c=qo(a,null!=(h=null==t?void 0:t._subTenantId)?h:"",l.map((t=>({name:t.name,tenantId:t.tenantId,numberOfUsers:t.numberOfUsers,createdAt:t.createdAt,metadata:t.metadata,children:[],loadMoreLink:null==s?void 0:s.next,isReseller:t.isReseller}))));i({accounts:c})}}catch(t){s({key:a,value:Bn(t)})}finally{n({key:a,value:!1})}},searchAccounts:async t=>{const{jwt:a}=t,o=zo.SEARCH_ACCOUNTS;n({key:o,value:!0});const{rootAccount:l}=r();try{if(null!=t&&t._subTenantId){var c;const{items:n}=await e.tenants.searchSubTenants({_offset:0,_limit:50,_filter:null!=(c=null==t?void 0:t._filter)?c:"",_subTenantId:t._subTenantId},{jwt:a});i({searchAccountsData:[...n,{name:l.name,tenantId:l.tenantId}]})}}catch(t){s({key:o,value:Bn(t)})}finally{n({key:o,value:!1})}},updateSubAccountAccessForUser:async t=>{const a=zo.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER;n({key:a,value:!0});const{selectedAccount:i}=r(),{userId:l,allowAccess:c,jwt:u,callback:d}=t;try{var g;await e.subTenants.updateSubAccountAccess(l,{allowAccess:c},{jwt:u}),o({users:null==i||null==(g=i.users)?void 0:g.map((t=>t.id===l?S({},t,{subAccountAccessAllowed:c}):t))}),null==d||d(!0)}catch(t){s({key:a,value:Bn(t)}),null==d||d(!1)}finally{n({key:a,value:!1})}},createSubAccount:async t=>{const a=zo.CREATE_SUB_ACCOUNT;n({key:a,value:!0});const{name:l,parentTenantId:c,tenantId:u,jwt:d,callback:g}=t;try{if(d){const{accounts:t,selectedAccount:a}=r(),n=await e.subTenants.createSubTenant({name:l,parentTenantId:c,tenantId:u},{jwt:d}),s=qo(t,null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]),g=qo(S({name:"",tenantId:""},null==a?void 0:a.accounts),null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:s}),o({accounts:g})}else{const{accounts:t}=r(),a=await e.subTenants.createSubTenant({name:l,tenantId:u,parentTenantId:c}),n=qo(t,null!=c?c:"",[{name:a.name,tenantId:a.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:n})}null==g||g(!0)}catch(t){s({key:a,value:Bn(t)}),null==g||g(!1)}finally{n({key:a,value:!1})}},updateSubAccount:async t=>{},deleteSubAccount:async t=>{const a=zo.DELETE_SUB_ACCOUNT;n({key:a,value:!0});const{jwt:l,tenantId:c,callback:u}=t;try{if(l){const{selectedAccount:t,accounts:a}=r();await e.subTenants.deleteSubTenant(c,{jwt:l});const n=Jo(a,c),s=Jo(t.accounts,c);i({accounts:n}),o({accounts:s})}else{const{accounts:t}=r();await e.subTenants.deleteSubTenant(c);const a=Jo(t,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Bn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountSettings:async t=>{const a=zo.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS;n({key:a,value:!0});const{jwt:l,name:c,callback:u,tenantId:d}=t;try{if(l){const{selectedAccount:t,accounts:a}=r();await e.subTenants.updateSubTenant({tenantId:d},{name:c},{jwt:l});const n=Xo(t.accounts,d,c);o({name:c,accounts:n});const s=Xo(a,d,c);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenant({tenantId:d},{name:c});const a=Xo(t,d,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Bn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountManagement:async r=>{const l=zo.UPDATE_SUB_ACCOUNT_MANAGEMENT;a.setAllAccountsLoader({key:l,value:!0});const{jwt:c,isReseller:u,callback:d,tenantId:g,shouldUpdateSelectedAccount:p}=r,h=!!c;try{if(p){const{selectedAccount:a,accounts:n}=t.auth.allAccountsState;await e.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const s=Qo(a.accounts,g,null!=u&&u);o({accounts:s}),h||o({isReseller:u});const r=Qo(n,g,null!=u&&u);i({accounts:r})}else{const{accounts:a}=t.auth.allAccountsState;e.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const n=Qo(a,g,null!=u&&u);i({accounts:n})}null==d||d(!0)}catch(t){s({key:l,value:Bn(t)}),null==d||d(!1)}finally{n({key:l,value:!1})}},updateSubAccountHierarchySettings:async t=>{const a=zo.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS;n({key:a,value:!0});const{jwt:l,callback:c,tenantId:u,subAccountAccessType:d}=t;if(d)try{if(l){const{selectedAccount:t,accounts:a}=r();await e.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d},{jwt:l});const n=Yo(t.accounts,u,d);o({subAccountAccessType:d,accounts:n});const s=Yo(a,u,d);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d});const a=Yo(t,u,d);i({accounts:a})}null==c||c(!0)}catch(t){s({key:a,value:Bn(t)}),null==c||c(!1)}finally{n({key:a,value:!1})}},addUsersToAccount:async t=>{const{users:a,tenantId:i,jwt:o,callback:r,allowSubAccountAccess:c=!1,roleIds:u}=t,d=zo.ADD_USERS_TO_ACCOUNT;try{n({key:d,value:!0}),await e.subTenants.addUsersToSubTenant({users:a,tenantId:i,allowSubAccountAccess:c,roleIds:u},{jwt:o}),await l({jwt:o,_tenantId:i}),null==r||r(!0)}catch(t){s({key:d,value:Bn(t)}),null==r||r(!1)}finally{n({key:d,value:!1})}},getAccountUsers:l,deleteUsersFromAccount:async t=>{const a=zo.DELETE_USERS_FROM_ACCOUNT;n({key:a,value:!0});const{userId:i,subTenants:o,jwt:r,callback:c}=t;try{await e.subTenants.removeUserFromTenantAndSubTenants({userId:i,subTenants:o},{jwt:r}),await l({jwt:r,_tenantId:o[0].tenantId}),null==c||c(!0)}catch(t){s({key:a,value:Bn(t)}),null==c||c(!1)}finally{n({key:a,value:!1})}},setUserRolesForSubAccount:async t=>{const{userId:a,subTenantsRoles:i,jwt:o,callback:c}=t,u=zo.SET_USER_ROLES_FOR_SUB_ACCOUNT;try{n({key:u,value:!0});const{selectedAccount:t}=r();await e.subTenants.setUserRolesForSubTenants(a,{subTenantsRoles:i},{jwt:o}),await l({jwt:o,_tenantId:t.tenantId}),null==c||c(!0)}catch(t){s({key:u,value:Bn(t)}),null==c||c(!1)}finally{n({key:u,value:!1})}},getUserJwtForSubAccount:async t=>{const{tenantId:a,callback:i}=t,r=zo.GET_USER_JWT;try{n({key:r,value:!0});const t=await e.users.GetUserJwt({tenantId:a});o({userJwt:t,accessPermission:!0}),null==i||i(!0)}catch(t){s({key:r,value:Bn(t)}),o({accessPermission:!1}),null==i||i(!1)}finally{n({key:r,value:!1})}},setRootAccountData:async()=>{const a=zo.SET_ROOT_ACCOUNT_DATA;n({key:a,value:!0});const{activeTenant:o}=t.auth.tenantsState,{accounts:l}=r();if(o)try{var c;const t=await e.tenants.getTenantsUsersCount({tenantIds:[null==o?void 0:o.tenantId]}),a={name:null==o?void 0:o.name,tenantId:null==o?void 0:o.tenantId,numberOfUsers:null==(c=t[0])?void 0:c.totalUsers,createdAt:null==o?void 0:o.createdAt};i({rootAccount:a,accounts:S({},l,a)})}catch(t){s({key:a,value:Bn(t)})}finally{n({key:a,value:!1})}},setSelectedSubAccountData:async t=>{const{jwt:a}=t,i=zo.SET_SELECTED_SUB_ACCOUNT_DATA;try{var r,c,u,d,g,p,h;n({key:i,value:!0});const t=await e.accountSettings.getSettings({jwt:a}),[s,y,v]=await Promise.all([e.tenants.getTenantsUsersCount({tenantIds:[null!=(r=null==t?void 0:t.tenantId)?r:""]},{jwt:a}),e.tenants.getParentTenants({jwt:a}),e.tenants.getHierarchyMetadata({_tenantIds:[null!=(c=null==t?void 0:t.tenantId)?c:""]},{jwt:a})]);o({tenantId:null!=(u=t.tenantId)?u:"",name:t.name,numberOfUsersObject:s[0],parentsAccounts:y,numberOfSubAccounts:null==(d=v[0])?void 0:d.totalSubTenants,accountSettings:t,accounts:{name:t.name,tenantId:null!=(g=t.tenantId)?g:"",numberOfUsers:null==(p=s[0])?void 0:p.totalUsers,createdAt:void 0,children:[]}}),await l({jwt:a,_tenantId:null!=(h=null==t?void 0:t.tenantId)?h:""})}catch(t){s({key:i,value:Bn(t)})}finally{n({key:i,value:!1})}},loadNumberOfUsersForSelectedSubAccount:async t=>{const{tenantId:a,jwt:i}=t,r=zo.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT;try{n({key:r,value:!0});const t=await e.tenants.getTenantsUsersCount({tenantIds:[a]},{jwt:i});o({numberOfUsersObject:t[0]})}catch(t){s({key:r,value:Bn(t)})}finally{n({key:r,value:!1})}}}},tr=(t,e,a)=>({setAllAccountDialogsState:e=>{Object.assign(t.auth.allAccountsDialogsState,e)},resetAllAccountDialogsState:()=>{$n(t,["auth","allAccountsDialogsState"],Wo)},openCreateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.createSubAccountDialog,S({},e,{open:!0}))},closeCreateSubAccountDialog:()=>{$n(t,["auth","allAccountsDialogsState","createSubAccountDialog"],Wo.createSubAccountDialog)},openUpdateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountDialog,S({},e,{open:!0}))},closeUpdateSubAccountDialog:()=>{$n(t,["auth","allAccountsDialogsState","updateSubAccountDialog"],Wo.updateSubAccountDialog)},openEnableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.enableSubAccountManagementDialog,S({},e,{open:!0}))},closeEnableSubAccountManagementDialog:()=>{$n(t,["auth","allAccountsDialogsState","enableSubAccountManagementDialog"],Wo.enableSubAccountManagementDialog)},openUpdateSubAccountHierarchySettingsDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountHierarchySettingsDialog,S({},e,{open:!0}))},closeUpdateSubAccountHierarchySettingsDialog:()=>{$n(t,["auth","allAccountsDialogsState","updateSubAccountHierarchySettingsDialog"],Wo.updateSubAccountHierarchySettingsDialog)},openDisableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.disableSubAccountManagementDialog,S({},e,{open:!0}))},closeDisableSubAccountManagementDialog:()=>{$n(t,["auth","allAccountsDialogsState","disableSubAccountManagementDialog"],Wo.disableSubAccountManagementDialog)},openDeleteSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteSubAccountDialog,S({},e,{open:!0}))},closeDeleteSubAccountDialog:()=>{$n(t,["auth","allAccountsDialogsState","deleteSubAccountDialog"],Wo.deleteSubAccountDialog)},openAddUsersToAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.addUsersToAccountDialog,S({},e,{open:!0}))},closeAddUsersToAccountDialog:()=>{$n(t,["auth","allAccountsDialogsState","addUsersToAccountDialog"],Wo.addUsersToAccountDialog)},openDeleteUserFromAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteUserFromAccountDialog,S({},e,{open:!0}))},closeDeleteUserFromAccountDialog:()=>{$n(t,["auth","allAccountsDialogsState","deleteUserFromAccountDialog"],Wo.deleteUserFromAccountDialog)},openEditUserRolesDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.editUserRolesDialog,S({},e,{open:!0}))},closeEditUserRolesDialog:()=>{$n(t,["auth","allAccountsDialogsState","editUserRolesDialog"],Wo.editUserRolesDialog)}}),er={devices:[],loading:!1,error:null},ar=t=>cn(er,t),nr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.passkeysState,e)};return{setPasskeysState:s,resetPasskeysState:()=>{$n(t,["auth","passkeysState"],er)},loadWebAuthnDevices:async()=>{s({loading:!0});try{const{devices:t}=await e.auth.getWebAuthnDevices();s({devices:t,loading:!1})}catch(t){s({loading:!1,error:Bn(t,null)})}},deleteWebAuthnDevice:async a=>{const{callback:n,deviceId:i}=a;s({loading:!0});try{await e.auth.deleteWebAuthnDevice(i);const a=t.auth.passkeysState.devices.filter((t=>t.id!==i));s({devices:a,loading:!1}),null==n||n(!0)}catch(t){s({loading:!1,error:Bn(t,null)}),null==n||n(null,t)}},__shouldShowPromptPasskeys:async function(){const{publicAuthStrategyPolicy:a}=t.auth.securityPolicyState,{policy:i}=a,o=await async function(t){var e;return!(null==t||null==(e=t.secondaryAuthStrategies)||!e.some((({isActive:t,strategy:e})=>t&&e===Yt.Passkeys)))}(i),r="Passkeys"===localStorage.getItem("preferred-login-method"),l="true"===localStorage.getItem("dont-show-again-prompt-passkeys"),[c]=await n.getFeatureFlags(["show-passkeys-new"]);if(!c||!o||r||l)return!1;{const{devices:t}=await e.auth.getWebAuthnDevices();return s({devices:null!=t?t:[]}),0===(null!=t&&t.length?t.length:0)}}}},sr={loading:!1,error:null},ir=t=>cn(sr,t),or=["callback","profilePictureUrl"],rr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.profileState,e)};return{setProfileState:s,resetProfileState:()=>{$n(t,["auth","profileState"],sr)},loadProfile:async()=>{s({loading:!0});try{const a=await Cn(e.teams.getProfile,3,2e3),i=t.auth.user;n.setUser(S({},i,a)),s({profile:a,loading:!1})}catch(t){s({loading:!1,error:Bn(t)})}},saveProfile:async a=>{const{callback:i,profilePictureUrl:o}=a,r=f(a,or);s({saving:!0,error:null,loading:!0});try{var l;const a=null!=(l=t.auth.profileState.profile)?l:{};let s=a.profilePictureUrl;if(o!==a.profilePictureUrl&&o&&(o||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)){const t=Ni(o,"image");if(t){s=await e.teams.updateProfileImage(t);const a=Date.now().toString(),n=new URL(s);n.searchParams.set("t",a),s=n.href}}const c=S({},a,r,{profilePictureUrl:s}),u=await e.users.updateUserProfileV2(c),d=t.auth.user;n.setUser(S({},d,u)),n.setProfileState({profile:u,saving:!1,loading:!1}),null==i||i(c)}catch(t){s({saving:!1,error:Bn(t),loading:!1}),null==i||i(null,t)}},changePassword:async t=>{s({loading:!0});try{var a;await e.teams.changePassword(t),s({loading:!1,error:void 0}),null==(a=t.callback)||a.call(t,!0)}catch(e){var n;s({loading:!1,error:Bn(e)}),null==(n=t.callback)||n.call(t,null,e)}},updateEmail:async t=>{const{email:a,callback:n}=t;s({saving:!0,error:null,loading:!0});try{await e.teams.updateEmail(a),s({saving:!1,error:null,loading:!1}),null==n||n(!0)}catch(t){s({saving:!1,error:Bn(t),loading:!1}),null==n||n(null,t)}},verifyEmail:async t=>{const{email:a,code:i,callback:o}=t;s({saving:!0,error:null,loading:!0});try{await e.teams.verifyEmail(a,i),await n.__refreshToken(),s({saving:!1,error:null,loading:!1}),null==o||o(!0)}catch(t){s({saving:!1,error:Bn(t),loading:!1}),null==o||o(null,t)}}}},lr={loading:!1},cr=t=>cn(lr,t),ur=["callback"],dr=["id"],gr=(t,e,a)=>{const n=e=>{Object.assign(t.auth.provisioningState,e)},s=async(t,a)=>{const{count:n}=await Ln((()=>e.directory.countConfigurationUsers(t.id)),a);return S({},t,{count:n})};return{setProvisioningState:n,resetProvisioningState:()=>{$n(t,["auth","provisioningState"],lr)},__loadCountForConnection:s,loadProvisionConnections:async t=>{n({loading:!0,error:null});try{const a=null==t?void 0:t.retryConfig,i=await Ln((()=>e.directory.getConfigs()),a),o=await Promise.all(i.map((t=>s(t,a))));n({connections:o,loading:!1})}catch(t){n({error:Bn(t),loading:!1})}},createProvisionConnection:async t=>{const{callback:a}=t,i=f(t,ur);n({loading:!0,error:null});try{const t=await e.directory.createConfiguration(i),o=await e.directory.getConfigs(),r=await Promise.all(o.map((t=>s(t))));n({connections:r,loading:!1}),null==a||a(t)}catch(t){n({error:Bn(t),loading:!1})}},deleteProvisionConnection:async t=>{const{id:a,callback:i}=t;n({loading:!0,error:null});try{await e.directory.deleteConfiguration(a,t.deleteAll);const o=await e.directory.getConfigs(),r=await Promise.all(o.map((t=>s(t))));n({connections:r,loading:!1}),null==i||i(!0)}catch(t){n({error:Bn(t),loading:!1}),null==i||i(!1,t)}},updateProvisionConnection:async t=>{const{id:a}=t,i=f(t,dr);n({loading:!0,error:null});try{await e.directory.updateConfiguration(a,i);const t=await e.directory.getConfigs(),o=await Promise.all(t.map((t=>s(t))));n({connections:o,loading:!1})}catch(t){n({error:Bn(t),loading:!1})}}}};let pr;!function(t){t.ResetPhoneNumber="ResetPhoneNumber",t.VerifyResetPhoneNumber="VerifyResetPhoneNumber",t.ChangePhoneNumber="ChangePhoneNumber"}(pr||(pr={}));const hr={step:pr.ResetPhoneNumber,loading:!1},yr=t=>cn(hr,t),vr=["callback"],Sr=["callback"],fr=["callback"],mr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.resetPhoneNumberState,e)};return{setResetPhoneNumberState:s,resetResetPhoneNumberState:()=>{$n(t,["auth","resetPhoneNumberState"],hr)},resetPhoneNumber:async t=>{const{callback:a}=t,i=f(t,vr);s({loading:!0});try{const t=await e.auth.resetPhoneNumber(i);s({loading:!1,error:void 0,resetPhoneNumberToken:t.resetPhoneNumberToken,step:pr.VerifyResetPhoneNumber}),n.setLoginState({email:i.email})}catch(t){s({loading:!1,error:Bn(t)}),null==a||a(null,t)}},verifyResetPhoneNumber:async t=>{const{callback:a}=t,n=f(t,Sr);s({loading:!0});try{const t=await e.auth.verifyResetPhoneNumber(n);s({loading:!1,error:void 0,changePhoneNumberToken:t.changePhoneNumberToken,step:pr.ChangePhoneNumber}),null==a||a(!0)}catch(t){s({loading:!1,error:Bn(t)}),null==a||a(null,t)}},changePhoneNumber:async a=>{const{callback:i}=a,o=f(a,fr);s({loading:!0});try{const{onRedirectTo:a,routes:r}=t.auth;await e.auth.changePhoneNumber({phoneNumber:o.phoneNumber,changePhoneNumberToken:o.changePhoneNumberToken}),n.setLoginState({step:wn.loginWithSmsOtc}),await n.passwordlessPreLogin({type:N.SmsCode,email:o.email,recaptchaToken:o.recaptchaToken}),a(r.loginUrl),s({loading:!1}),null==i||i(!0)}catch(t){s({loading:!1,error:Bn(t)}),null==i||i(null,t)}}}},br={loaders:{},errors:{},roles:[],permissions:[],permissionCategories:[]},Ar=t=>cn(br,t);let wr;!function(t){t.EDIT_ROLE_DIALOG="editRoleDialog",t.DELETE_ROLE_DIALOG="deleteRoleDialog",t.LOAD_ROLES="loadRoles",t.ADD_ROLE="addRole",t.MANAGE_PERMISSIONS="managePermissions"}(wr||(wr={}));const Tr=["callback"],Er=["callback"],Pr=["callback"],Or=["callback"],Ir=["callback"],kr=["callback"],_r=(t,e,a)=>{const n=e=>{Object.assign(t.auth.rolesState,e)},s=e=>{Object.assign(t.auth.rolesState,{loaders:S({},t.auth.rolesState.loaders,{[e.key]:e.value})})},i=e=>{Object.assign(t.auth.rolesState,{errors:S({},t.auth.rolesState.errors,{[e.key]:e.value}),loaders:S({},t.auth.rolesState.loaders,{[e.key]:!1})})},o=async a=>{var o;const r=wr.LOAD_ROLES;s({key:r,value:!(null!=(o=null==a?void 0:a.silentLoading)&&o)});try{const s=null==a?void 0:a.retryConfig,[i,o,r]=await Promise.all([Ln((()=>e.roles.getRoles()),s),Ln((()=>e.roles.getPermissions()),s),Ln((()=>e.roles.getPermissionCategories()),s)]),{selectedRole:l}=t.auth.rolesState,c=null==i?void 0:i.find((({id:t})=>(null==l?void 0:l.id)===t));n({roles:i,permissions:o,permissionCategories:r,selectedRole:c})}catch(t){i({key:r,value:Bn(t)})}finally{s({key:r,value:!1})}},r=async t=>{const{callback:a}=t,r=f(t,Ir),l=wr.MANAGE_PERMISSIONS;s({key:l,value:!0});try{const t=await e.roles.attachPermissionsToRole(r);await o({silentLoading:!0}),n({saving:!1}),null==a||a(t)}catch(t){i({key:l,value:Bn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}};return{setRolesState:n,setRolesStateLoader:s,setRolesStateError:i,resetRolesState:()=>{$n(t,["auth","rolesState"],br)},loadRolesAndPermissions:o,addRole:async t=>{const{callback:a}=t,n=f(t,Tr),r=wr.ADD_ROLE;s({key:r,value:!0});try{const t=await e.roles.addRole(n);await o({silentLoading:!0}),null==a||a(t)}catch(t){i({key:r,value:Bn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},addRoleV2:async t=>{const{callback:a}=t,n=f(t,Er),r=wr.ADD_ROLE;s({key:r,value:!0});try{const t=await e.roles.addRoleV2(n);await o({silentLoading:!0}),null==a||a(t)}catch(t){i({key:r,value:Bn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},updateRole:async t=>{const{callback:a}=t,r=f(t,Pr),l=wr.EDIT_ROLE_DIALOG;s({key:l,value:!0});try{const t=await e.roles.updateRole(r);await o({silentLoading:!0}),n({saving:!1}),null==a||a(t)}catch(t){i({key:l,value:Bn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}},deleteRole:async t=>{const{callback:a}=t,r=f(t,Or),l=wr.DELETE_ROLE_DIALOG;s({key:l,value:!0});try{await e.roles.deleteRole(r),await o({silentLoading:!0}),n({saving:!1}),null==a||a(!0)}catch(t){i({key:l,value:Bn(t)}),null==a||a(!1,t)}finally{s({key:l,value:!1})}},attachPermissionsToRole:r,attachPermissionToRoles:async t=>{const{callback:e}=t,a=f(t,kr),n=wr.MANAGE_PERMISSIONS;s({key:n,value:!0});try{await Promise.all(a.roleIds.map((t=>r({roleId:t,permissionIds:[a.permissionId]})))),await o({silentLoading:!0}),null==e||e(!0)}catch(t){i({key:n,value:Bn(t)}),null==e||e(null,t)}finally{s({key:n,value:!1})}}}},Ur={ipRestrictions:{loading:!1,pagination:{_offset:0,_limit:4,_filter:Jt.ALLOW},totalPages:1,userIpValid:!1},emailDomainRestrictions:{loading:!1}},Rr=t=>cn(Ur,t),Cr=["callback"],Lr=["callback"],Dr=["callback"],Nr=["callback"],Mr=(t,e,a)=>{const n=a,s=t=>{var e,a,n;return{_filter:null!=(e=null==t?void 0:t._filter)?e:Jt.ALLOW,_limit:null!=(a=null==t?void 0:t._limit)?a:10,_offset:null!=(n=null==t?void 0:t._offset)?n:0}},i=t=>async(...e)=>{const[a]=await n.getFeatureFlags(["security-center-admin-portal-major-version"]);await t(...e),a&&(await n.loadRecommendations(Dn()),await n.loadInsights(Dn()))},o=e=>{Object.assign(t.auth.restrictionsState.ipRestrictions,e)},r=e=>{Object.assign(t.auth.restrictionsState.emailDomainRestrictions,e)},l=async()=>{try{const{valid:t}=await e.auth.testCurrentIpInAllowList();o({userIpValid:t})}catch(t){o({error:Bn(t)})}},c=i((async()=>{o({loading:!0,error:null});try{const a=t.auth.restrictionsState.ipRestrictions,n=await e.auth.getIPRestrictionsConfig(),i=s({_filter:n.strategy,_limit:a.pagination._limit,_offset:a.pagination._offset}),{items:r,_metadata:{totalPages:l}}=await e.auth.getIPRestrictions(i);o({data:{restrictions:r,config:n},totalPages:l,pagination:i,loading:!1})}catch(t){o({error:Bn(t),loading:!1})}})),u=i((async a=>{const{callback:n}=a,i=f(a,Cr);o({saving:!0,error:null});try{var r,c;await e.auth.createIPRestriction(i);const a=t.auth.restrictionsState.ipRestrictions,u=s(a.pagination),{items:d,_metadata:{totalPages:g}}=await e.auth.getIPRestrictions(u),p=d;await l(),o({data:{config:null!=(r=null==(c=a.data)?void 0:c.config)?r:{isActive:!1,strategy:Jt.ALLOW},restrictions:p},pagination:u,totalPages:g,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Bn(t)}),null==n||n(null,t)}})),d=i((async a=>{const{callback:n}=a,i=f(a,Lr);o({saving:!0,error:null});try{await e.auth.updateIPRestrictionConfig(i);const a=t.auth.restrictionsState.ipRestrictions,r=await e.auth.getIPRestrictionsConfig(),c=s(S({},a.pagination,{_filter:r.strategy})),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),g=u;await l(),o({data:{config:r,restrictions:g},pagination:c,totalPages:d,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Bn(t)}),null==n||n(null,t)}})),g=i((async a=>{const{id:n,callback:i}=a;o({saving:!0,error:null});try{var r;await e.auth.deleteIPRestriction(n);const a=t.auth.restrictionsState.ipRestrictions,c=s(a.pagination),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),g=u;await l(),o({data:{config:(null==(r=a.data)?void 0:r.config)||{isActive:!1,strategy:Jt.ALLOW},restrictions:g},pagination:c,totalPages:d,saving:!1}),null==i||i(!0)}catch(t){o({saving:!1,error:Bn(t)}),null==i||i(null,t)}})),p=i(l),h=i((async a=>{const{callback:n}=a;o({saving:!0,error:null});try{var i,r;const a=null!=(i=(null==(r=t.auth.userIpData)?void 0:r.ip)||t.auth.userIp)?i:"";await Promise.all([e.auth.createIPRestriction({ip:a,isActive:!0,description:"My IP",strategy:Jt.ALLOW}),e.auth.updateIPRestrictionConfig({isActive:!0})]);const l=t.auth.restrictionsState.ipRestrictions,c=s(l.pagination),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),g=u;o({data:{config:{isActive:!0,strategy:Jt.ALLOW},restrictions:g},userIpValid:!0,pagination:c,totalPages:d,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:t}),null==n||n(!1,t)}})),y=i((async()=>{r({loading:!0,error:null});try{const t=await e.auth.getDomainRestrictionsConfig(),a=(await e.auth.getDomainRestrictions()).items.filter((e=>e.type===t.listType));r({data:{restrictions:a,config:t},loading:!1})}catch(t){r({error:Bn(t),loading:!1})}})),v=i((async a=>{const{callback:n}=a,s=f(a,Dr);r({saving:!0,error:null});const i=t.auth.restrictionsState.emailDomainRestrictions;try{var o;await e.auth.createDomainRestriction(s);const t=(await e.auth.getDomainRestrictions()).items.filter((t=>{var e;return t.type===(null==(e=i.data)?void 0:e.config.listType)}));r({data:{config:(null==(o=i.data)?void 0:o.config)||{active:!1,blockPublicDomains:!1,listType:s.type},restrictions:t},saving:!1}),null==n||n(!0)}catch(t){r({saving:!1,error:Bn(t)}),null==n||n(null,t)}})),m=i((async t=>{const{callback:a}=t,n=f(t,Nr);r({saving:!0,error:null});try{const t=await e.auth.updateDomainRestrictionConfig(n),s=(await e.auth.getDomainRestrictions()).items.filter((e=>e.type===t.listType));r({data:{config:t,restrictions:s},saving:!1}),null==a||a(!0)}catch(t){r({saving:!1,error:Bn(t)}),null==a||a(null,t)}})),b=i((async a=>{const{id:n}=a;r({saving:!0,error:null});const s=t.auth.restrictionsState.emailDomainRestrictions;try{var i;await e.auth.deleteDomainRestriction(n);const t=(await e.auth.getDomainRestrictions()).items.filter((t=>{var e;return t.type===(null==(e=s.data)?void 0:e.config.listType)}));r({data:{config:(null==(i=s.data)?void 0:i.config)||{active:!1,blockPublicDomains:!1,listType:Jt.ALLOW},restrictions:t},saving:!1})}catch(t){r({saving:!1,error:Bn(t)})}}));return{setRestrictionsState:e=>{Object.assign(t.auth.restrictionsState,e)},setIpRestrictionsState:o,setEmailDomainRestrictionsState:r,__securityCenterSagaWrapper:i,loadIpRestrictions:c,saveIpRestriction:u,saveIpRestrictionsConfig:d,deleteIpRestriction:g,checkIfUserIpValid:p,addCurrentUserIpAndActivate:h,loadEmailDomainRestrictions:y,saveEmailDomainRestriction:v,saveEmailDomainRestrictionsConfig:m,deleteEmailDomainRestriction:b}},Fr={loaders:{},errors:{},recommendations:void 0,insights:void 0,hasSecurityChanges:!1,score:0,breachedPasswordUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10}},unenrolledMfaUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10}},inactiveUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10,_maxInactiveSeconds:7776e3}}},xr=t=>cn(Fr,t);let $r;!function(t){t.RECOMMENDATIONS="recommendations",t.INSIGHTS="insights",t.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS="sendBulkResetBreachedPasswordEmails",t.SEND_BREACHED_PASSWORD_EMAIL="sendBreachedPasswordEmail",t.BREACHED_PASSWORD_USERS_TABLE="breachedPasswordUsersTable",t.UNENROLLED_MFA_USERS_TABLE="unenrolledMfaUsersTable",t.INACTIVE_USERS_TABLE="inactiveUsersTable"}($r||($r={}));const Gr=["callback"],jr=(t,e,a)=>{const n=a,s=async t=>{var a,s,l,c;const{key:u,tableState:d,updateStateKey:g,_offset:p,_limit:h,_preset:y,_email:v,_maxInactiveSeconds:f}=t;r({key:u,value:!1}),o({key:u,value:!0});const m=null!=(a=null!=p?p:null==d||null==(s=d.queryParams)?void 0:s._offset)?a:0,b=null!=(l=null!=h?h:null==d||null==(c=d.queryParams)?void 0:c._limit)?l:10,A=S({_offset:m,_limit:b,_includeSubTenants:!1,_preset:y,_maxInactiveSeconds:f},!!v&&{_email:v});try{const{items:t,_metadata:{totalItems:a,totalPages:s}}=await e.users.getUsersV3(A),o={totalUsersItems:a,totalUsersPages:s,usersPageOffset:m,queryParams:S({_offset:m,_limit:b,_maxInactiveSeconds:f},!!v&&{_email:v})};if(t.length){const a=await(async t=>{const a=t.map((t=>t.id)),n=await e.roles.getRoles(),s=await e.users.getUsersRoles({ids:a});return t.map((t=>{var e,a;const i=null==s||null==(e=s.find((e=>e.userId===t.id)))?void 0:e.roleIds;return S({},t,{roles:null!=(a=null==i?void 0:i.map((t=>{var e;return null!=(e=null==n?void 0:n.find((e=>e.id===t)))?e:[]})))?a:[]})}))})(t);n.setSecurityCenterState({[g]:S({users:a},o)})}else i({[g]:S({users:[]},o)})}catch(t){r({key:u,value:Bn(t)})}finally{o({key:u,value:!1})}},i=e=>{Object.assign(t.auth.securityCenterState,e)},o=e=>{Object.assign(t.auth.securityCenterState,{loaders:S({},t.auth.securityCenterState.loaders,{[e.key]:e.value})})},r=e=>{Object.assign(t.auth.securityCenterState,{errors:S({},t.auth.securityCenterState.errors,{[e.key]:e.value}),loaders:S({},t.auth.securityCenterState.loaders,{[e.key]:!1})})};return{setSecurityCenterState:i,resetSecurityCenterState:()=>{$n(t,["auth","securityCenterState"],Fr)},setSecurityCenterStateLoader:o,setSecurityCenterStateError:r,loadRecommendations:async t=>{const a=$r.RECOMMENDATIONS;o({key:a,value:!0});try{var n;const{recommendations:a,scoring:s}=await Ln((()=>e.securityCenter.getRecommendations()),null==t?void 0:t.retryConfig);i({recommendations:a.items,score:null!=(n=null==s?void 0:s.score)?n:0})}catch(t){r({key:a,value:Bn(t)})}finally{o({key:a,value:!1})}},loadInsights:async t=>{const a=$r.INSIGHTS;o({key:a,value:!0});try{const{insights:a}=await await Ln((()=>e.securityCenter.getInsights()),null==t?void 0:t.retryConfig);i({insights:a.items})}catch(t){r({key:a,value:Bn(t)})}finally{o({key:a,value:!1})}},sendResetBreachedPasswordEmail:async t=>{const{callback:a}=t,n=f(t,Gr),s=$r.SEND_BREACHED_PASSWORD_EMAIL;r({key:s,value:!1}),o({key:s,value:!0});try{await e.auth.forgotPassword(n),null==a||a(!0)}catch(t){r({key:s,value:Bn(t)}),null==a||a(!1,t)}finally{o({key:s,value:!1})}},sendBulkResetBreachedPasswordEmails:async t=>{const{callback:a}=t,n=$r.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS;r({key:n,value:!1}),o({key:n,value:!0});try{await e.users.sendResetBreachedPasswordEmails(),null==a||a(!0)}catch(t){r({key:n,value:Bn(t)}),null==a||a(!1)}finally{o({key:n,value:!1})}},loadBreachedPasswordUsers:async e=>{var a;const n=$r.BREACHED_PASSWORD_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.breachedPasswordUsersTable;await s(S({key:n,updateStateKey:"breachedPasswordUsersTable",_preset:qa.BREACHED_PASSWORDS,tableState:i},e))},loadUnenrolledMfaUsers:async e=>{var a;const n=$r.UNENROLLED_MFA_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.unenrolledMfaUsersTable;await s(S({key:n,updateStateKey:"unenrolledMfaUsersTable",_preset:qa.MFA_UNENROLLED,tableState:i},e))},loadInactiveUsers:async e=>{var a;const n=$r.INACTIVE_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.inactiveUsersTable;await s(S({key:n,updateStateKey:"inactiveUsersTable",_preset:qa.INACTIVE,tableState:i},e))},markSecurityCenterStateAsChanged:(t=!0)=>{i({hasSecurityChanges:t})}}},Br={globalPolicy:{loading:!0},publicPolicy:{loading:!1},vendorMfaPolicy:{loading:!0},mfaPolicy:{loading:!0},vendorLockoutPolicy:{loading:!0},lockoutPolicy:{loading:!0},captchaPolicy:{loading:!0},passwordHistoryPolicy:{loading:!0},passwordPolicy:{loading:!0},vendorPasswordHistoryPolicy:{loading:!0},publicAuthStrategyPolicy:{loading:!0},passwordRotationPolicy:{loading:!0}},Vr=t=>cn(Br,t);function Wr(t,e){const a=null!=e,n=null!=t;if(a||n)return a?n?Math.min(t,e):e:t}const Hr=["callback"],zr=["callback"],Kr=["callback"],qr=["callback"],Jr=(t,e,a)=>{const n=a,s=async(t,e)=>{var a,s;if(!await n.customLoginEnabled())return t;const o=await i(e);return null!=o&&null!=(a=o.mainAuthStrategies)&&null!=(s=a[0])&&s.strategy?S({},t,{authStrategy:o.mainAuthStrategies[0].strategy}):t},i=async a=>{let n;return n=t.auth.isAuthenticated?await Ln(e.auth.getPublicAuthStrategiesConfigForAuthenticatedUser,a):await Ln(e.auth.getVendorPublicAuthStrategiesConfig,a),n},o=e=>{Object.assign(t.auth.securityPolicyState.globalPolicy,e)},r=e=>{Object.assign(t.auth.securityPolicyState.publicPolicy,e)},l=e=>{Object.assign(t.auth.securityPolicyState.mfaPolicy,e)},c=e=>{Object.assign(t.auth.securityPolicyState.vendorMfaPolicy,e)},u=e=>{Object.assign(t.auth.securityPolicyState.lockoutPolicy,e)},d=e=>{Object.assign(t.auth.securityPolicyState.vendorLockoutPolicy,e)},g=e=>{Object.assign(t.auth.securityPolicyState.captchaPolicy,e)},p=e=>{Object.assign(t.auth.securityPolicyState.passwordHistoryPolicy,e)},h=e=>{Object.assign(t.auth.securityPolicyState.vendorPasswordHistoryPolicy,e)},y=e=>{Object.assign(t.auth.securityPolicyState.passwordRotationPolicy,e)},v=e=>{Object.assign(t.auth.securityPolicyState.passwordPolicy,e)},m=e=>{Object.assign(t.auth.securityPolicyState.publicAuthStrategyPolicy,e)},b=async t=>{o({loading:!0,error:null});try{const a=await Ln((()=>e.auth.getGlobalSecurityPolicy()),null==t?void 0:t.retryConfig);o({policy:a,loading:!1})}catch(t){o({error:Bn(t),loading:!1})}},A=async t=>{l({loading:!0,error:null});try{const a=await Ln((()=>e.auth.getMfaPolicy()),null==t?void 0:t.retryConfig);l({policy:a,loading:!1})}catch(t){l({error:Bn(t),loading:!1})}},w=async t=>{l({loading:!0,error:null});try{const a=await Ln((()=>e.auth.getVendorMfaPolicy()),null==t?void 0:t.retryConfig);c({policy:a,loading:!1})}catch(t){c({error:Bn(t),loading:!1})}},T=async t=>{u({loading:!0,error:null});try{const a=await Ln((()=>e.auth.getLockoutPolicy()),null==t?void 0:t.retryConfig);u({policy:a,loading:!1})}catch(t){u({error:Bn(t),loading:!1})}},E=async t=>{d({loading:!0,error:null});try{const a=await Ln((()=>e.auth.getVendorLockoutPolicy()),null==t?void 0:t.retryConfig);d({policy:a,loading:!1})}catch(t){d({error:Bn(t),loading:!1})}},P=async t=>{u({loading:!0,error:null});try{const a=await Ln((()=>e.auth.getCaptchaPolicy()),null==t?void 0:t.retryConfig);g({policy:a,loading:!1})}catch(t){g({error:Bn(t),loading:!1})}},O=async t=>{h({loading:!0,error:null});try{const a=await Ln((()=>e.auth.getVendorPasswordHistoryPolicy()),null==t?void 0:t.retryConfig);h({policy:a,loading:!1})}catch(t){h({error:Bn(t),loading:!1})}},I=async e=>{m({loading:!0,error:null});try{var a,s,o;const l=await i(null==e?void 0:e.retryConfig);await(async e=>{var a,s;const i=await n.customLoginEnabled();if(!e||!i)return;const{policy:o}=null!=(a=null==(s=t.auth.securityPolicyState)?void 0:s.publicPolicy)?a:{policy:null};r({policy:S({},o,{authStrategy:e}),loading:!1})})(null==l||null==(a=l.mainAuthStrategies)||null==(s=a[0])?void 0:s.strategy),m({policy:l,loading:!1}),null==e||null==(o=e.callback)||o.call(e,l)}catch(t){var l;m({error:Bn(t),loading:!1}),null==e||null==(l=e.callback)||l.call(e,null,t)}};return{setSecurityPolicyState:e=>{Object.assign(t.auth.securityPolicyState,e)},setSecurityPolicyGlobalState:o,setSecurityPolicyPublicState:r,setSecurityPolicyMfaState:l,setSecurityPolicyVendorMfaState:c,setSecurityPolicyLockoutState:u,setSecurityPolicyVendorLockoutState:d,setSecurityPolicyCaptchaState:g,setSecurityPolicyPasswordHistoryState:p,setSecurityPolicyVendorPasswordHistoryState:h,setSecurityPolicyPasswordRotationState:y,resetSecurityPolicyState:()=>{$n(t,["auth","securityPolicyState"],Br)},setSecurityPolicyPasswordState:v,setSecurityPolicyAuthStrategyPublicState:m,loadSecurityPolicy:async t=>{const e={retryConfig:null==t?void 0:t.retryConfig};await Promise.all([b(),A(),w(e),T(e),E(e),O(),P(e),I(e)])},loadGlobalSecurityPolicy:b,loadPublicSecurityPolicy:async t=>{r({loading:!0,error:null});try{const a=await e.auth.getVendorConfig(),n=await s(a,null==t?void 0:t.retryConfig);r({policy:n,loading:!1})}catch(t){r({error:Bn(t),loading:!1})}},loadVendorPasswordConfig:async t=>{v({loading:!0,error:null});try{var a;const n=await Ln((()=>e.auth.getPasswordConfigPolicy()),null==t?void 0:t.retryConfig);v({policy:n,loading:!1}),null==t||null==(a=t.callback)||a.call(t,n)}catch(e){var n;v({error:Bn(e),loading:!1}),null==t||null==(n=t.callback)||n.call(t,null,e)}},loadSecurityPolicyMfa:A,loadSecurityPolicyVendorMfa:w,loadSecurityPolicyLockout:T,loadSecurityPolicyVendorLockout:E,loadSecurityPolicyCaptcha:P,loadSecurityPolicyPasswordHistory:async()=>{p({loading:!0,error:null});try{const t=await e.auth.getPasswordHistoryPolicy();p({policy:t,loading:!1})}catch(t){p({error:Bn(t),loading:!1})}},loadSecurityPolicyVendorPasswordHistory:O,loadSecurityPolicyPasswordRotation:async()=>{y({loading:!0,error:null});try{const t=await e.securityPolicy.getPasswordRotationPolicy(),a=await e.securityPolicy.getVendorPasswordRotationPolicy(),n={passwordRotationVendorConfig:a};t&&(null!=a&&a.isActive?n.passwordRotationTenantConfig=null!=t&&t.isActive?S({},t,{rotationPeriod:Wr(a.rotationPeriod,t.rotationPeriod)}):a:n.passwordRotationTenantConfig=t),y({policy:S({},n),loading:!1})}catch(t){y({error:Bn(t),loading:!1})}},loadPublicAuthStrategiesPolicy:I,saveSecurityPolicyMfa:async t=>{const{callback:a}=t,n=f(t,Hr);l({saving:!0,error:null});try{const t=await e.auth.securityPolicy.saveMfaPolicy(n);l({policy:t,saving:!1}),null==a||a(t)}catch(t){l({saving:!1,error:Bn(t)}),null==a||a(null,t)}},saveSecurityPolicyLockout:async t=>{const{callback:a}=t,n=f(t,zr);u({saving:!0,error:null});try{const t=await e.auth.saveLockoutPolicy(n);u({policy:t,saving:!1}),null==a||a(t)}catch(t){u({saving:!1,error:Bn(t)}),null==a||a(null,t)}},saveSecurityPolicyPasswordHistory:async t=>{const{callback:a}=t,n=f(t,Kr);p({saving:!0,error:null});try{const t=await e.auth.savePasswordHistoryPolicy(n);p({policy:t,saving:!1}),null==a||a(t)}catch(t){p({saving:!1,error:Bn(t)}),null==a||a(null,t)}},saveSecurityPolicyPasswordRotation:async t=>{const{callback:a}=t,n=f(t,qr);y({saving:!0,error:null});try{await e.securityPolicy.savePasswordRotationPolicy(n.passwordRotationTenantConfig||{}),y({policy:n,saving:!1}),null==a||a(n)}catch(t){y({saving:!1,error:Bn(t)}),null==a||a(null,t)}},__getSecurityPolicyPublicStateWithCustomLogin:s}},Yr={loading:!1,configurations:{}},Xr=t=>cn(Yr,t),Qr=["callback"],Zr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.sessionsPolicyState,e)};return{setSessionsPolicyState:s,resetSessionsPolicyState:()=>{$n(t,["auth","sessionsPolicyState"],Yr)},loadSessionsPolicy:async()=>{s({loading:!0,error:null});try{const t=await e.auth.getSessionConfigurations();s({configurations:t,loading:!1})}catch(t){n.setSessionsState({error:t,loading:!1})}},createOrUpdateSessionsPolicy:async t=>{const{callback:a}=t,i=f(t,Qr);try{s({loading:!0,error:null}),await e.auth.createOrUpdateSessionConfigrations(i),await n.loadSessionsPolicy(),null==a||a(!0)}catch(t){s({error:t,loading:!1})}}}},tl={loading:!1,sessions:[]},el=t=>cn(tl,t),al=(t,e,a)=>{const n=e=>{Object.assign(t.auth.sessionsState,e)},s=async t=>{n({loading:!0,error:null});try{const a=await Ln((()=>e.auth.getCurrentUserSessions()),null==t?void 0:t.retryConfig);n({sessions:a,loading:!1})}catch(t){n({error:Bn(t),loading:!1})}};return{setSessionsState:n,resetSessionsState:()=>{$n(t,["auth","sessionsState"],tl)},loadUserSessions:s,loadCurrentUserSession:async()=>{n({loading:!0,error:null});try{const t=await e.auth.getCurrentUserSession();n({currentSession:t,loading:!1})}catch(t){n({error:Bn(t),loading:!1})}},deleteUserSession:async t=>{const{id:a}=t;n({loading:!0,error:null});try{await e.auth.deleteSessionForUser(a),await s()}catch(t){n({error:Bn(t),loading:!1})}},deleteAllUserSessions:async()=>{n({loading:!0,error:null});try{await e.auth.deleteAllSessionsForUser(),await s()}catch(t){n({error:Bn(t),loading:!1})}},revokeUserSessions:async t=>{const{callback:a,userId:s}=t;n({loading:!0,error:null});try{await e.auth.revokeSessionsForUser(s),n({loading:!1}),null==a||a(!0)}catch(t){n({error:Bn(t),loading:!1}),null==a||a(!1)}}}};let nl;!function(t){t.SignUp="SignUp",t.SignUpSuccess="SignUpSuccess",t.VerifyPhone="VerifyPhone"}(nl||(nl={}));const sl={loading:!1,allowSignUps:!1,allowNotVerifiedUsersLogin:!1,firstLoad:!0,stage:nl.SignUp,strategies:{[F.Email]:{enabled:!0,required:!0},[F.PhoneNumber]:{enabled:!1,required:!1}}},il=t=>cn(sl,t),ol=["events","url"],rl=["events","url"],ll=(t,e,a)=>{const n=a,s=R.for(t.root.appName),i=e=>{Object.assign(t.auth.signUpState,e)},o=()=>{$n(t,["auth","signUpState"],sl)},r=(t,e,a,n,s,i=Zn.PASSWORD)=>{var o;const{email:r,name:l,companyName:c,phoneNumber:u,url:d}=t,g={email:r,name:l,companyName:c,url:d,phoneNumber:u||void 0,authenticationType:i,id:e,tenantId:a,createdAt:new Date,activationToken:n};null==s||null==(o=s.signUpComplete)||o.call(s,g),ss(as.SIGNUP_COMPLETED,g)},l=async a=>{const{events:o}=a,l=f(a,ol);if(i({loading:!0}),!l.phoneNumber)throw new Error("Phone number is required for phone number signup");try{var c,u,d;const{routes:a,onRedirectTo:s}=t.auth,{tenantId:i,userId:g,activationToken:p}=await e.auth.signUpUserWithPhoneNumber(ks(l));l.invitationToken||r(l,g,i,p,o,Zn.PHONE_NUMBER);const{enabled:h,siteKey:y}=null!=(c=t.auth.securityPolicyState.captchaPolicy.policy)?c:{},v=h&&y?await(null==(u=window.grecaptcha)||null==(d=u.execute)?void 0:d.call(u,{action:"login"})):"";n.passwordlessPreLogin({recaptchaToken:v,phoneNumber:l.phoneNumber,type:N.SmsCode,callback:(t,e)=>{if(!t&&e)throw e;s(a.loginUrl),n.setLoginState({step:wn.loginWithSmsOtc,phoneNumber:l.phoneNumber})}})}catch(t){s.setAccessToken(null),s.setUser(null),i({error:Bn(t)})}finally{i({loading:!1})}};return{setSignUpState:i,resetSignUpState:o,resetSignUpStateSoft:()=>{const{allowSignUps:e,allowNotVerifiedUsersLogin:a}=t.auth.signUpState;o(),i({allowSignUps:e,allowNotVerifiedUsersLogin:a})},signUpUser:async a=>{const{events:o}=a,c=f(a,rl);i({loading:!0});const u=t.auth.signUpState.strategies.phoneNumber;if(null!=u&&u.required&&null!=u&&u.enabled&&c.phoneNumber)return l(a);try{const{routes:a,onRedirectTo:s}=t.auth,{shouldActivate:l,user:u,tenantId:d,userId:g,tenants:p=[],activeTenant:h,activationToken:y}=await e.auth.signUpUser(ks(c));if(c.invitationToken||r(c,g,d,y,o),!l&&u&&Es(u,t.root.appName)){const t=await n.getMfaRequiredState(u,Un,!0,c.email);n.setAuthState(t),s(a.loginUrl)}else if(l&&y){const t=new URLSearchParams({userId:g||"",token:y||""}),e=`${a.activateWithOTCUrl}?${t.toString()}`;i({loading:!1,shouldActivate:l,stage:nl.SignUpSuccess}),s(e)}else{const e=t.auth.tenantsState;i({loading:!1,shouldActivate:l,stage:nl.SignUpSuccess}),n.setAuthState({user:u,isAuthenticated:!(null==u||!u.accessToken),tenantsState:S({},e,{tenants:p,activeTenant:h})})}}catch(t){s.setAccessToken(null),s.setUser(null),i({error:Bn(t)})}finally{i({loading:!1})}},signUpUserWithPhoneNumber:l,loadAllowSignUps:async t=>{i({loading:!0});try{var a;const s=await Ln(e.auth.getVendorConfig,null==t?void 0:t.retryConfig),o=await n.__getSecurityPolicyPublicStateWithCustomLogin(s,null==t?void 0:t.retryConfig),{allowSignups:r,allowNotVerifiedUsersLogin:l}=s;i({loading:!1,allowSignUps:r,allowNotVerifiedUsersLogin:l,firstLoad:!1}),n.setSecurityPolicyPublicState({policy:o,loading:!1}),null==t||null==(a=t.callback)||a.call(t,o||s)}catch(e){var s;i({loading:!1,error:Bn(e),firstLoad:!1}),null==t||null==(s=t.callback)||s.call(t,null,e)}},loadSignUpStrategies:async()=>{try{const t=await e.auth.getSignUpStrategies();i({strategies:t.reduce(((t,{isActive:e,strategy:a,isRequired:n})=>(t[a]={enabled:e,required:n},t)),{})})}catch(t){}}}},cl={loading:!1,error:null,phoneNumbers:void 0},ul=t=>cn(cl,t),dl=["callback"],gl=["callback"],pl=["callback"],hl=["callback","phoneId"],yl=["callback","phoneId"],vl=["callback"],Sl=(t,e,a)=>{const n=e=>{Object.assign(t.auth.smsState,e)},s=async()=>{n({loading:!0});const t={_limit:10,_offset:0};try{const{items:a}=await e.userPhoneNumbers.getUserPhoneNumbers(t);n({phoneNumbers:a})}catch(t){n({error:Bn(t)})}finally{n({loading:!1})}},i=async()=>{n({loading:!0});try{const t=await e.userPhoneNumbers.getUserOwnPhoneNumbers();n({phoneNumbers:t})}catch(t){n({error:Bn(t)})}finally{n({loading:!1})}};return{setSmsState:n,resetSmsState:()=>{$n(t,["auth","smsState"],cl)},loadPhoneNumbers:s,loadUserOwnPhoneNumbers:i,setUpPhoneNumber:async t=>{const{callback:a}=t,i=f(t,gl);try{const{otcToken:t}=await e.userPhoneNumbers.createPhoneNumber(i);n({otcToken:t}),await s(),null==a||a(!0)}catch(t){n({error:Bn(t)}),null==a||a(!1,t)}},setUpOwnPhoneNumber:async t=>{const{callback:a}=t,s=f(t,dl);try{const{otcToken:t}=await e.userPhoneNumbers.createPhoneNumber(s);n({otcToken:t}),await i(),null==a||a(!0)}catch(t){n({error:Bn(t)}),null==a||a(!1,t)}},verifyPhoneNumber:async t=>{const{callback:a}=t,i=f(t,pl);n({loading:!0});try{await e.userPhoneNumbers.verifyPhoneNumber(i),await s(),null==a||a(!0)}catch(t){n({error:Bn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},deletePhoneNumber:async t=>{const{callback:a,phoneId:s}=t;f(t,hl),n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.deletePhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Bn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},verifyDeletePhoneNumber:async t=>{const{callback:a,phoneId:i}=t,o=f(t,yl);n({loading:!0});try{await e.userPhoneNumbers.verifyDeletePhoneNumber(i,o),await s(),null==a||a(!0)}catch(t){n({error:Bn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},preVerifyPhoneNumber:async t=>{const{callback:a}=t,s=f(t,vl);n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.preVerifyPhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Bn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}}}},fl={firstLoad:!0,loading:!1,error:""},ml=t=>cn(fl,t),bl=["authorizationUrl"],Al=["events","url"],wl=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.socialLoginState,e)};return{setSocialLoginsState:s,resetSocialLoginsState:()=>{$n(t,["auth","socialLoginState"],fl)},setSocialLoginError:t=>{s({error:t.error,loading:!1,firstLoad:!1})},loadSocialLoginsConfiguration:async()=>{try{s({loading:!0});const t=await e.auth.getSocialLoginProviders();s({socialLoginsConfig:t,loading:!1,firstLoad:!1})}catch(t){s({error:Bn(t),loading:!1,firstLoad:!1})}},loadSocialLoginsConfigurationV2:async a=>{try{var n;const i=t.root.context;s({loading:!0});const o=await(async a=>{let n;return n=t.auth.isAuthenticated?await Ln(e.auth.getSocialLoginProvidersV2ForAuthenticatedUser,a):await Ln(e.auth.getSocialLoginProvidersV2,a),n})(null==a?void 0:a.retryConfig),{providers:r}=await Ln(e.auth.getCustomSocialLoginProvidersV1,null==a?void 0:a.retryConfig),l={socialLoginsConfigV2:o.map((t=>{let{authorizationUrl:a}=t,n=f(t,bl);const s=e.fetch.getBaseUrl(i,null!=a?a:"");return S({},n,{authorizationUrl:a?`${s}${a}`:null})})),customSocialLoginsConfig:r,loading:!1,firstLoad:!1};s(l),null==a||null==(n=a.callback)||n.call(a,l)}catch(t){var i;null==a||null==(i=a.callback)||i.call(a,null,t),s({error:Bn(t),loading:!1,firstLoad:!1})}},loginViaSocialLogin:async t=>{const{events:a,url:i}=t,o=f(t,Al);try{s({loading:!0});const{email:t,isNewUser:c,userId:u,tenantId:d,name:g}=await e.auth.loginViaSocialLogin(o);if(c){var r,l;const e={email:t,url:i,createdAt:new Date,id:u,tenantId:d},n=S({},e,{socialProvider:o.provider,authenticationType:Zn.SOCIAL_LOGIN});null==a||null==(r=a.signUpComplete)||r.call(a,n),ss(as.SIGNUP_COMPLETED,n);const s=S({},e,{origin:Qn.SOCIAL_LOGIN,name:g});null==a||null==(l=a.userVerified)||l.call(a,s),ss(as.USER_VERIFIED,s)}u&&localStorage.setItem("userId",u),n.setLoginState({email:t,isNewUser:c}),n.refreshTokenForSocialLogins(),localStorage.removeItem("register-quick-login"),s({loading:!1})}catch(t){s({loading:!1,error:Bn(t,"Failed to authenticate"),firstLoad:!1})}}}},Tl={firstLoad:!0,loading:!0,saving:!1,errors:{},loaders:{},ssoConfigurations:[]},El=t=>cn(Tl,t),Pl=["callback","samlVendor"],Ol=["callback"],Il=["callback","ssoConfigId"],kl=["callback","ssoConfigId"],_l=["callback","ssoConfigId"],Ul=(t,e,a)=>S({},((t,e,a)=>{const n=a,s=async()=>{try{const t=await e.auth.getSamlRoles(),a=await e.auth.getSamlRolesGroups();i({authorizationRoles:t.roleIds,rolesGroups:a,error:void 0})}catch(t){i({error:Bn(t)})}},i=e=>{Object.assign(t.auth.ssoState,e)};return{setSSOState:i,resetSSOState:()=>{$n(t,["auth","ssoState"],Tl)},setSSOLoader:e=>{Object.assign(t.auth.ssoState,{loaders:S({},t.auth.ssoState.loaders,{[e.key]:e.value})})},setSSOError:e=>{Object.assign(t.auth.ssoState,{errors:S({},t.auth.ssoState.errors,{[e.key]:e.value}),loaders:S({},t.auth.ssoState.loaders,{[e.key]:!1})})},loadSSOConfigurations:async()=>{try{var t,a;i({loading:!0});const n=await e.auth.getSamlConfiguration(),s=await e.auth.getOidcConfiguration(),o=await e.metadata.getSamlMetadata();n.acsUrl=null==o||null==(t=o.configuration)?void 0:t.acsUrl,n.spEntityId=null==o||null==(a=o.configuration)?void 0:a.spEntityId,n.isSamlActive=null==o?void 0:o.isActive,i({samlConfiguration:n,oidcConfiguration:s,loading:!1,firstLoad:!1})}catch(t){i({error:Bn(t),loading:!1})}},saveSSOConfigurations:async a=>{const{callback:n,samlVendor:s}=a,o=f(a,Pl),r=t.auth.ssoState.samlConfiguration,l=S({},r,o);let c="saving";(null==l?void 0:l.enabled)!==(null==r?void 0:r.enabled)&&(c="loading");try{if(null==l||!l.domain)return void i({samlConfiguration:S({},r,l)});if(i({error:void 0,[c]:!0}),a.type===ho.Saml){var u,d;const t=await e.metadata.getSamlMetadata();l.acsUrl=null==t||null==(u=t.configuration)?void 0:u.acsUrl,l.spEntityId=null==t||null==(d=t.configuration)?void 0:d.spEntityId}const t=Mn(l,["validated","generatedVerification","createdAt","updatedAt"]);(null==r?void 0:r.domain)!==(null==t?void 0:t.domain)&&(t.ssoEndpoint="",t.publicCertificate="",t.signRequest=!1),t.type=null==s?void 0:s.toLowerCase();const o=await e.auth.updateSamlConfiguration(t);o.isSamlActive=null==r?void 0:r.isSamlActive,i({samlConfiguration:o,error:void 0,[c]:!1}),null==n||n(!0)}catch(t){i({samlConfiguration:r,error:Bn(t),[c]:!1}),null==n||n(null,t)}},saveSSOConfigurationsFile:async a=>{const n=t.auth.ssoState.samlConfiguration,s="saving";i({error:void 0,[s]:!0});try{const t=await Fi(a[0]),o=await e.auth.updateSamlVendorMetadata({metadata:t});o.isSamlActive=null==n?void 0:n.isSamlActive,i({samlConfiguration:o,error:void 0,[s]:!1})}catch(t){i({samlConfiguration:n,error:Bn(t),[s]:!1})}},saveSSOConfigurationsFileWithCallback:async a=>{const{configFile:n,callback:s}=a,o=t.auth.ssoState.samlConfiguration,r="saving";i({error:void 0,[r]:!0});try{const t=await Fi(n),a=await e.auth.updateSamlVendorMetadata({metadata:t});a.isSamlActive=null==o?void 0:o.isSamlActive,i({samlConfiguration:a,error:void 0,[r]:!1}),null==s||s(!0)}catch(t){i({samlConfiguration:o,error:Bn(t),[r]:!1}),null==s||s(null,t)}},validateSSODomain:async a=>{const{callback:n}=null!=a?a:{},s=t.auth.ssoState.samlConfiguration;if(!s){const t=new Error("IllegalState: samlConfiguration is not defined");return console.error(t),void(null==n||n(null,t))}try{i({error:void 0,saving:!0}),await e.auth.validateSamlDomain(),i({samlConfiguration:S({},s,{validated:!0}),error:void 0,saving:!1}),null==n||n(!0)}catch(t){i({samlConfiguration:S({},s,{validated:!1}),error:Bn(t),saving:!1}),null==n||n(null,t)}},loadSSOAuthorizationRoles:async()=>{try{const t=await e.auth.getSamlRoles(),a=await e.auth.getSamlRolesGroups();i({authorizationRoles:t.roleIds,rolesGroups:a,error:void 0})}catch(t){i({error:Bn(t)})}},updateSSOAuthorizationRoles:async t=>{const{callback:a,authorizationRoles:n,groups:o}=t;try{i({error:void 0,saving:!0}),await e.auth.updateSamlRoles({roleIds:n}),o&&await(async t=>{try{await Promise.all(t.map((t=>e.auth.updateSamlGroup({id:t.id,roleIds:t.roleIds,group:t.group}))))}catch(t){i({error:Bn(t)})}})(o),await s(),i({error:void 0,saving:!1}),null==a||a(!0)}catch(t){i({error:Bn(t),saving:!1}),null==a||a(null,t)}},deleteSamlGroup:async t=>{const{id:a,callback:n}=t;try{i({error:void 0,saving:!0}),await e.auth.deleteSamlGroup({id:a}),await s(),i({error:void 0,saving:!1}),null==n||n(!0)}catch(t){i({error:Bn(t),saving:!1}),null==n||n(null,t)}},createSamlGroup:async t=>{const{group:a,roleIds:n,callback:o}=t;try{i({error:void 0,saving:!0}),await e.auth.createSamlGroup({group:a,roleIds:n}),await s(),i({error:void 0,saving:!1}),null==o||o(!0)}catch(t){i({error:Bn(t),saving:!1}),null==o||o(null,t)}},oidcPostlogin:async t=>{const a={code:t.code,redirectUri:t.redirectUri,RelayState:t.state};try{i({loading:!0}),await e.auth.oidcPostLoginV2(a),await n.__refreshToken(),i({loading:!1})}catch(t){i({loading:!1,error:Bn(t,"Failed to authenticate"),firstLoad:!1})}}}})(t,e,a),((t,e,a)=>{const n=a,s=async t=>{try{return await Ln((()=>e.auth.getOidcConfiguration()),t)}catch(t){return null}},i=async t=>{try{return await Ln((()=>e.metadata.getSamlMetadata()),t)}catch(t){return null}},o=async(t,e,a)=>{n.setSSOLoader({key:t,value:!0});try{await a()}catch(a){n.setSSOError({key:t,value:Bn(a)}),null==e||e(null,a)}finally{n.setSSOLoader({key:t,value:!1})}};return{loadSSOConfigurationsV2:async t=>{await o(po.LOAD_SSO_CONFIGURATIONS,void 0,(async()=>{const[a,o]=await Promise.all([s(null==t?void 0:t.retryConfig),i(null==t?void 0:t.retryConfig)]),r=await Ln((()=>e.auth.getSSOConfigurations()),null==t?void 0:t.retryConfig);n.setSSOState({ssoConfigurations:r,oidcConfiguration:a,samlMetadata:o})}))},saveSSOConfigurationV2:async a=>{const{callback:s}=a,i=f(a,Ol),r=t.auth.ssoState.ssoConfigurations;await o(po.SAVE_SSO_CONFIGURATION,s,(async()=>{var t;const a=await e.auth.createSSOConfiguration(S({},i,{enabled:null!=(t=i.enabled)&&t}));n.setSSOState({ssoConfigurations:[...r,a]}),null==s||s(a)}))},updateSSOConfiguration:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,Il),l=t.auth.ssoState.ssoConfigurations;await o(po.UPDATE_SSO_CONFIGURATION,s,(async()=>{const t=await e.auth.updateSSOConfiguration(i,r),a=l.map((e=>e.id===i?t:e));n.setSSOState({ssoConfigurations:a}),null==s||s(t)}))},deleteSSOConfiguration:async a=>{const{ssoConfigId:s,callback:i}=a,r=t.auth.ssoState.ssoConfigurations;await o(po.DELETE_SSO_CONFIGURATION,i,(async()=>{await e.auth.deleteSSOConfiguration(s),n.setSSOState({ssoConfigurations:r.filter((({id:t})=>t!==s))}),null==i||i(!0)}))},saveSSODomain:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,kl),l=t.auth.ssoState.ssoConfigurations;await o(po.SAVE_SSO_DOMAIN,s,(async()=>{const t=await e.auth.createSSODomain(i,r),a=l.map((e=>e.id===i?S({},e,{domains:[...e.domains,t]}):e));n.setSSOState({ssoConfigurations:a}),null==s||s(t)}))},deleteSSODomain:async a=>{const{ssoConfigId:s,domainId:i,callback:r}=a,l=t.auth.ssoState.ssoConfigurations;await o(po.DELETE_SSO_DOMAIN,r,(async()=>{await e.auth.deleteSSODomain(s,i);const t=l.map((t=>t.id===s?S({},t,{domains:t.domains.filter((({id:t})=>t!==i))}):t));n.setSSOState({ssoConfigurations:t}),null==r||r(!0)}))},validateSSODomainV2:async a=>{const{callback:s,domainId:i,ssoConfigId:r}=a;await o(po.VALIDATE_SSO_DOMAIN,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations;await e.auth.validateSSODomainV2(r,i);const o=a.map((t=>t.id===r?S({},t,{domains:t.domains.map((t=>t.id===i?S({},t,{validated:!0}):t))}):t));n.setSSOState({ssoConfigurations:o}),null==s||s(!0)}))},setSSOGroups:async a=>{const{groupsToAdd:s,groupsToDelete:i,ssoConfigId:r,callback:l}=a;await o(po.SAVE_SSO_GROUPS,l,(async()=>{const a=t.auth.ssoState.ssoConfigurations;await Promise.all(i.map((t=>e.auth.deleteSSOGroup(r,t)))),await Promise.all(s.map((t=>e.auth.createSSOGroup(r,t))));const o=await e.auth.getSSOGroups(r),c=a.map((t=>t.id===r?S({},t,{groups:o}):t));n.setSSOState({ssoConfigurations:c}),null==l||l(!0)}))},updateSSOGroups:async t=>{const{ssoConfigId:a,changedGroups:n,callback:s}=t;await o(po.SAVE_SSO_GROUPS,s,(async()=>{await Promise.all(n.map((t=>e.auth.updateSSOGroup(a,t)))),null==s||s(!0)}))},setSSODefaultRoles:async a=>{const{callback:s,ssoConfigId:i,roleIds:r}=a;await o(po.UPDATE_SSO_DEFAULT_ROLES,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations;await e.auth.setSSODefaultRoles(i,{roleIds:r});const o=a.map((t=>t.id===i?S({},t,{roleIds:r}):t));n.setSSOState({ssoConfigurations:o}),null==s||s(!0)}))},saveSSOConfigurationByMetadata:async a=>{const{configFile:s,callback:i}=a;await o(po.SAVE_SSO_CONFIGURATION_BY_METADATA,i,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await Fi(s),r=await e.auth.createSSOConfigurationByMetadata({metadata:o});n.setSSOState({ssoConfigurations:[...a,r]}),null==i||i(r)}))},updateSSOConfigurationByMetadata:async a=>{const{callback:s,ssoConfigId:i,configFile:r}=a;await o(po.UPDATE_SSO_CONFIGURATION_BY_METADATA,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await Fi(r),l=await e.auth.updateSSOConfigurationByMetadata(i,{metadata:o}),c=a.map((t=>t.id===i?l:t));n.setSSOState({ssoConfigurations:c}),null==s||s(l)}))},saveSSOConfigurationByUrl:async a=>{const{metadataUrl:s,configMetadata:i,ssoConfigId:r,callback:l}=a;await o(po.SAVE_SSO_CONFIGURATION_BY_METADATA,l,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o={url:s,configMetadata:i};let c,u;r?(c=await e.auth.updateSSOConfigurationByMetadataUrl(r,o),u=a.map((t=>t.id===r?c:t))):(c=await e.auth.createSSOConfigurationByMetadataUrl(o),u=[c,...a]),n.setSSOState({ssoConfigurations:u}),null==l||l(c)}))},saveSSOConfigurationByData:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,_l),l=t.auth.ssoState.ssoConfigurations;await o(po.SAVE_SSO_CONFIGURATION,s,(async()=>{let t,a;i?(t=await e.auth.updateSSOConfiguration(i,r),a=l.map((e=>e.id===i?t:e))):(t=await e.auth.createSSOConfiguration(r),a=[t,...l]),n.setSSOState({ssoConfigurations:a}),null==s||s(t)}))}}})(t,e,a)),Rl={loading:!1,mfaDevices:void 0,mfaToken:""},Cl=t=>cn(Rl,t),Ll=(t,e,a)=>{const n=a;return S({setStepUpState:e=>{Object.assign(t.auth.stepUpState,e)},resetStepUpState:()=>{$n(t,["auth","stepUpState"],Rl)},stepUpWithAuthenticator:async t=>{await n.mfaWithAuthenticator(t,n.setStepUpState,!0)},preVerifyMFASMSForStepUp:async t=>{await n.preVerifyMFASMS(t,n.setStepUpState)},verifyMFASMSForStepUp:async t=>{await n.verifyMFASMS(t,n.setStepUpState,!0)},preVerifyMFAWebAuthnForStepUp:async t=>{await n.preVerifyMFAWebAuthn(t,n.setStepUpState)},verifyMFAWebAuthnForStepUp:async t=>{await n.verifyMFAWebAuthn(t,n.setStepUpState,!0)},preVerifyMFAEmailCodeForStepUp:async t=>{await n.preVerifyMFAEmailCode(t,n.setStepUpState)},verifyMFAEmailCodeForStepUp:async t=>{await n.verifyMFAEmailCode(t,n.setStepUpState)}},((t,e,a)=>{const n=a;return{generateStepUpSession:async a=>{const{maxAge:s,callback:i}=a;n.setStepUpState({mfaDevices:void 0,mfaToken:""});try{const t=await e.auth.generateStepupSession({maxAge:s});t.hasOwnProperty("user")?await(async t=>{await n.afterAuthenticationStateUpdate(t),await n.afterStepUpAuthNavigation()})(t):await(async({mfaToken:t,mfaDevices:e})=>{n.setStepUpState({mfaDevices:e,mfaToken:t});const a=await gs(e);n.setMfaState({step:a})})(t),null==i||i(!0)}catch(e){null==i||i(!1),await(async e=>{if((t=>"MFA is not enrolled"===(null==t?void 0:t.message))(e))return void n.setMfaState({step:ns.noMFAEnrolledStepUp});window.localStorage.setItem(bn,"true");const a=t.auth.routes;R.for(t.root.appName).onRedirectTo(a.logoutUrl,{preserveQueryParams:!0})})(e)}}}})(t,e,a),((t,e,a)=>{const n=a;return{stepUpHostedLogin:async e=>{var a,s;const i={acr_values:Sn},{maxAge:o}=e||{};void 0!==o&&(i.max_age=o.toString());const r=null==(a=t.auth.tenantsState)||null==(s=a.activeTenant)?void 0:s.alias;r&&(i.organization=r),bs(),window.localStorage.setItem(bn,"true"),await n.__requestHostedLoginAuthorize(i)}}})(t,0,a))},Dl={loaders:{},pageOffset:0,pageSize:20,errors:{},users:[],allUsers:[],roles:[],permissions:[],totalPages:0,shouldShowSubTenantUsersIfReseller:!1,allUsersQueryParams:{_filter:null,_offset:0,_limit:20,_order:"DESC",_sortBy:"name"},addUserDialogState:{loading:!1,open:!1},deleteUserDialogState:{loading:!1,open:!1},lockUserDialogState:{loading:!1,open:!1},enableUserDialogState:{loading:!1,open:!1},disableUserDialogState:{loading:!1,open:!1}},Nl=t=>cn(Dl,t),Ml=["callback","appIds"],Fl=["roles"],xl=["callback","profileImage"],$l=["callback"],Gl=["callback"],jl=["callback"],Bl=["callback","userId"],Vl=["callback"],Wl=["callback"],Hl=["callback"],zl=["callback"],Kl=["callback"],ql=["callback"],Jl=(t,e,a)=>{const n=e=>{Object.assign(t.auth.teamState,e)};return S({setTeamLoader:e=>{Object.assign(t.auth.teamState,{loaders:S({},t.auth.teamState.loaders,{[e.key]:e.value})})},setTeamError:e=>{Object.assign(t.auth.teamState,{errors:S({},t.auth.teamState.errors,{[e.key]:e.value}),loaders:S({},t.auth.teamState.loaders,{[e.key]:!1})})},setTeamState:n,resetTeamState:()=>{$n(t,["auth","teamState"],Dl)},openAddUserDialog:t=>{n({addUserDialogState:S({open:!0,loading:!1,error:!1},t)})},closeAddUserDialog:e=>{var a,s;null==(a=(s=t.auth.teamState.addUserDialogState).onClose)||a.call(s,e),n({addUserDialogState:{loading:!1,error:!1,open:!1}})},openDeleteUserDialog:t=>{n({deleteUserDialogState:S({open:!0,loading:!1,error:!1},t)})},closeDeleteUserDialog:e=>{var a,s;null==(a=(s=t.auth.teamState.deleteUserDialogState).onClose)||a.call(s,e),n({deleteUserDialogState:{loading:!1,error:!1,open:!1}})},lockUser:async t=>{}},((t,e,a)=>{const n=a,s=async t=>{try{const{groups:a}=await Ln((()=>e.groups.getGroups({_groupsRelations:Ha.roles})),t);return a}catch(t){return[]}},i=async t=>{n.setTeamLoader({key:Us.ROLES_AND_PERMISSIONS,value:!0});try{var a;const s=null==t?void 0:t.retryConfig,[{items:i},{items:o}]=await Promise.all([Ln((()=>e.teams.loadAvailableRoles()),s),Ln((()=>e.teams.loadAvailablePermissions()),s)]);n.setTeamState({roles:i,permissions:o}),null==t||null==(a=t.callback)||a.call(t,{roles:i,permissions:o})}catch(e){var s;null==t||null==(s=t.callback)||s.call(t,null,e),n.setTeamError({key:Us.ROLES_AND_PERMISSIONS,value:Bn(e)})}finally{n.setTeamLoader({key:Us.ROLES_AND_PERMISSIONS,value:!1})}};return{loadRoles:i,loadUsers:async a=>{var s,o,r,l;const{silentLoading:c,callback:u}=a,d=t.auth.teamState,g=null!=(s=a.pageSize)?s:d.pageSize,p=null!=(o=a.pageOffset)?o:d.pageOffset,h=null!=(r=a.filter)?r:d.filter,y=null!=(l=a.sort)?l:d.sort;n.setTeamLoader({key:Us.USERS,value:!c}),n.setTeamState({pageSize:g,pageOffset:p,filter:h,sort:y});try{const[{items:t,totalPages:a,totalItems:s}]=await Promise.all([e.teams.loadUsers({pageSize:g,pageOffset:p,filter:h,sort:y}),i()]);n.setTeamState({users:t,totalPages:a,totalItems:s}),null==u||u(t)}catch(t){n.setTeamError({key:Us.USERS,value:Bn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:Us.USERS,value:!1})},loadUsersV2:async o=>{var r,l,c,u,d;const{silentLoading:g,callback:p,shouldLoadRoles:h=!0,shouldLoadApps:y,retryConfig:v}=o,f=t.auth.teamState,m=null!=(r=o.pageSize)?r:f.pageSize,b=null!=(l=o.pageOffset)?l:f.pageOffset,A=null!=(c=o.filter)?c:f.filterV2,w=null!=(u=o.sort)?u:f.sortV2,T=null!=(d=null==o?void 0:o.shouldShowSubTenantUsersIfReseller)?d:null==f?void 0:f.shouldShowSubTenantUsersIfReseller;n.setTeamLoader({key:Us.USERS,value:!g}),n.setTeamState({pageSize:m,pageOffset:b,filterV2:A,sortV2:w});try{const[{items:t,_metadata:{totalPages:n,totalItems:r}},{items:l},{items:c},u]=await Promise.all([Ln((()=>e.users.getUsersV2(S({},(null==A?void 0:A.length)&&{_filter:A},w&&{_sortBy:w},o.order&&{_order:o.order},{_offset:b,_limit:m,_includeSubTenants:T}))),v),Ln((()=>e.teams.loadAvailableRoles()),v),Ln((()=>e.teams.loadAvailablePermissions()),v),s(v),h?i({retryConfig:v}):void 0]),d=t.map((t=>{var e;return S({},t,{groups:null==t||null==(e=t.groups)?void 0:e.map((t=>u.filter((e=>e.id===t.id)))).flat()})})).map((t=>S({},t,{roleIds:t.roles.map((t=>t.id))}))),g=await a.mapUsersWithApplicationData({shouldLoadApps:y,users:d,retryConfig:v});a.setTeamState({users:g,totalPages:n,totalItems:r,roles:l,permissions:c}),null==p||p(t)}catch(t){console.error("Failed to load users",t),n.setTeamError({key:Us.USERS,value:Bn(t)}),n.setTeamState({totalPages:0,users:[]}),null==p||p(null,t)}n.setTeamLoader({key:Us.USERS,value:!1})},addUser:async s=>{const{callback:i,appIds:o}=s,r=f(s,Ml),l=t.auth.teamState;n.setTeamState({addUserDialogState:S({},l.addUserDialogState,{loading:!0})});try{var c;const t=await e.teams.addUser(r),{roles:s}=t,u=S({},f(t,Fl),{roleIds:null!=(c=null==s?void 0:s.map((t=>t.id)))?c:[]}),d=await a.assignNewUserToApps({appIds:o,user:u});d&&(u.applications=d),null==i||i(u),n.setTeamState({users:[u,...l.users],addUserDialogState:{open:!1,loading:!1}})}catch(t){console.error("Failed to add user",t),n.setTeamState({addUserDialogState:S({},l.addUserDialogState,{loading:!1,error:Bn(t)})}),null==i||i(null,t)}},addUsersBulk:async a=>{const{callback:s}=a,i=t.auth.teamState;n.setTeamState({addUserDialogState:S({},i.addUserDialogState,{loading:!0})});const o=[],r=[],l=a.emails.map((t=>S({email:t,roleIds:a.roleIds},a.expirationInSeconds&&{expirationInSeconds:a.expirationInSeconds})));n.setTeamState({addUserDialogState:{open:!0,loading:!0}});for(let t=0;t<l.length;t++){const a=l.at(t);try{await e.teams.addUser(a),o.push(a.email)}catch(t){r.push(a.email)}}const c={pageOffset:0,pageSize:10,filter:"",silentLoading:a.emails.length>0};await n.loadUsersV2(c),n.setTeamState({addUserDialogState:{loading:!1}}),null==s||s({unallowedEmails:r,allowedEmails:o})},updateUser:async a=>{const{callback:s}=a,i=f(a,xl),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));if(void 0!==l){n.setTeamLoader({key:Us.UPDATE_USER,value:o||""}),n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!0})}),n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!0}),users:r.users.map((t=>t.id===i.id?S({},t,i):t))});try{var c;l.roleIds.length>0&&0===(null==(c=i.roleIds)?void 0:c.length)&&(i.roleIds=[""]);const{item:t}=await e.teams.updateUser(i);null==s||s(t),n.setTeamState({users:r.users.map((e=>e.id===t.id?S({},e,t,{groups:e.groups,createdAt:e.createdAt,customData:e.customData,lastLogin:e.lastLogin}):e))}),n.setTeamLoader({key:Us.UPDATE_USER,value:!1})}catch(t){n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!1,error:Bn(t)}),users:r.users.map((t=>t.id===i.id?S({},t,l):t))}),n.setTeamLoader({key:Us.UPDATE_USER,value:!1}),null==s||s(null,t)}}else null==s||s(null,"User not in state")},deleteUser:async a=>{const{callback:s}=a,i=f(a,$l),o=t.auth.teamState;n.setTeamState({deleteUserDialogState:S({},o.deleteUserDialogState,{loading:!0})});try{await e.teams.deleteUser(i),null==s||s(!0),n.setTeamState({users:o.users.filter((t=>t.id!==i.userId)),deleteUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({deleteUserDialogState:S({},o.deleteUserDialogState,{loading:!1,error:Bn(t)})}),null==s||s(null,t)}},enableUser:async a=>{const{callback:s,userId:i}=a,o=t.auth.teamState;n.setTeamState({enableUserDialogState:S({},o.enableUserDialogState,{loading:!0})});try{await e.teams.enableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((t=>t.id===i?S({},t,{isDisabled:!1}):t)),enableUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({enableUserDialogState:S({},o.enableUserDialogState,{loading:!1,error:Bn(t)})}),null==s||s(null,t)}},disableUser:async a=>{const{callback:s,userId:i}=a,o=t.auth.teamState;n.setTeamState({disableUserDialogState:S({},o.disableUserDialogState,{loading:!0})});try{await e.teams.disableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((t=>t.id===i?S({},t,{isDisabled:!0}):t)),disableUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({disableUserDialogState:S({},o.disableUserDialogState,{loading:!1,error:Bn(t)})}),null==s||s(null,t)}},getTemporaryUsersConfig:async t=>{n.setTeamError({key:Us.CONFIG_TEMPORARY_USERS,value:!1});try{const a=await Ln((()=>e.teams.getTemporaryUserConfiguration()),null==t?void 0:t.retryConfig);n.setTeamState({temporaryUsersConfig:a})}catch(t){n.setTeamError({key:Us.CONFIG_TEMPORARY_USERS,value:Bn(t)})}},updateUserExpirationTime:async a=>{const{callback:s}=a,i=f(a,Gl),o=t.auth.teamState;n.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!0});try{const t=await e.teams.updateUserExpirationTime(i);n.setTeamState({users:o.users.map((e=>e.id===i.userId?S({},e,{temporaryExpirationDate:new Date(t.temporaryExpirationDate)}):e))}),null==s||s(!0)}catch(t){n.setTeamError({key:Us.UPDATE_USER_EXPIRATION_TIME,value:Bn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!1})}},setUserAsPermanent:async a=>{const{callback:s}=a,i=f(a,jl),o=t.auth.teamState;n.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!0});try{await e.teams.setPermanentUser(i.userId),n.setTeamState({users:o.users.map((t=>t.id===i.userId?S({},t,{temporaryExpirationDate:void 0}):t))}),null==s||s(!0)}catch(t){n.setTeamError({key:Us.UPDATE_USER_EXPIRATION_TIME,value:Bn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!1})}}}})(t,e,a),((t,e,a)=>{const n=a;return{loadAllSubTenantsUsers:async a=>{var s,i,o,r,l;const{silentLoading:c,callback:u}=a,d=t.auth.teamState.allUsersQueryParams,g={_limit:(null!=(s=a._limit)?s:d._limit)||20,_offset:(null!=(i=a._offset)?i:d._offset)||0,_filter:(null!=(o=a._filter)?o:d._filter)||"",_sortBy:(null!=(r=a._sortBy)?r:d._sortBy)||"name",_order:(null!=(l=a._order)?l:d._order)||"DESC"};n.setTeamLoader({key:Us.USERS,value:!c}),n.setTeamState({allUsersQueryParams:g,pageOffset:g._offset});try{const[{items:t,_metadata:{totalPages:a,totalItems:s}},{items:i},{items:o}]=await Promise.all([e.subTenants.loadAllUsers(S({},g)),e.teams.loadAvailableRoles(),e.teams.loadAvailablePermissions()]);n.setTeamState({allUsers:t,totalPages:a,totalItems:s,roles:i,permissions:o}),null==u||u(t)}catch(t){n.setTeamError({key:Us.USERS,value:Bn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:Us.USERS,value:!1})},setUserRolesForSubTenants:async a=>{const{callback:s,userId:i}=a,o=f(a,Bl),r=t.auth.teamState;n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!0})});try{await e.subTenants.setUserRolesForSubTenants(i,o);const t=r.allUsers.find((t=>t.id===i));let a=[];t&&(a=t.tenants.map((t=>{var e;return S({},t,{roles:(null==(e=o.subTenantsRoles.find((e=>e.tenantId===t.tenantId)))?void 0:e.roleIds.map((t=>r.roles.find((({id:e})=>t===e)))).filter((t=>t)))||t.roles})}))),n.setTeamState({allUsers:[...r.allUsers.filter((t=>t.id!==i)),...t?[S({},t,{tenants:a})]:[]],addUserDialogState:{open:!1,loading:!1}}),null==s||s(!0)}catch(t){n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!1,error:Bn(t)})}),null==s||s(null,t)}},deleteUserFromSubTenants:async a=>{const{callback:s}=a,i=f(a,Vl),o=t.auth.teamState;n.setTeamState({deleteUserDialogState:S({},o.deleteUserDialogState,{loading:!0})});try{await e.subTenants.removeUserFromTenantAndSubTenants(i),null==s||s(!0),n.setTeamState({allUsers:o.allUsers.filter((t=>t.id!==i.userId&&t.tenants.length===i.subTenants.length)),deleteUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({deleteUserDialogState:S({},o.deleteUserDialogState,{loading:!1,error:Bn(t)})}),null==s||s(null,t)}},addUserToSubTenants:async a=>{const{callback:s}=a,i=f(a,Wl),o=t.auth.teamState;n.setTeamState({addUserDialogState:S({},o.addUserDialogState,{loading:!0})});try{await e.subTenants.addUserToTenantAndSubTenants(i);const{items:t,_metadata:{totalPages:a,totalItems:o}}=await e.subTenants.loadAllUsers({_limit:20,_offset:0,_filter:"",_sortBy:"name",_order:"DESC"});n.setTeamState({allUsers:t,totalPages:a,totalItems:o,addUserDialogState:{open:!1,loading:!1}}),null==s||s(null)}catch(t){n.setTeamState({addUserDialogState:S({},o.addUserDialogState,{loading:!1,error:Bn(t)})}),null==s||s(null,t)}}}})(t,e,a),((t,e,a)=>{const n=a,s=async(t,e,a,s)=>{n.setTeamLoader({key:t,value:e});try{await s()}catch(e){n.setTeamError({key:t,value:Bn(e)}),null==a||a(null,e)}finally{n.setTeamLoader({key:t,value:!1})}};return{resendActivationLink:async t=>{const{callback:a}=t,n=f(t,Hl);await s(Us.RESEND_ACTIVATE_LINK,n.userId,a,(async()=>{await e.teams.resendActivationLink(n),null==a||a(!0)}))},resendInvitationLink:async t=>{const{callback:a}=t,n=f(t,zl);await s(Us.RESEND_INVITATION_LINK,n.email,a,(async()=>{await e.teams.resendInvitationLink(n),null==a||a(!0)}))},resendInvitationEmail:async t=>{const{callback:a}=t,n=f(t,Kl);await s(Us.RESEND_INVITATION_LINK,a,n.email,(async()=>{await e.auth.resendInvitationEmail(n),null==a||a(!0)}))},resendInvitationLinkToAllSubTenants:async t=>{const{callback:a}=t,n=f(t,ql);await s(Us.RESEND_INVITATION_LINK,n.email,a,(async()=>{await e.teams.resendInvitationLinkToAllTenants(n),null==a||a(!0)}))}}})(0,e,a),((t,e,a)=>{const n=a;return{getInvitationLink:async a=>{n.setTeamError({key:Us.GET_TOKEN_LINK,value:!1});try{const s=null==a?void 0:a.retryConfig;await(async t=>{n.setTeamError({key:Us.CONFIG_TOKEN_LINK,value:!1});try{const a=await Ln((()=>e.teams.getInviteLinkConfiguration()),t);n.setTeamState({inviteTokenState:S({},a)})}catch(t){n.setTeamError({key:Us.CONFIG_TOKEN_LINK,value:Bn(t)})}})(s);const i=await Ln((()=>e.teams.getInviteUserLink()),s),{inviteTokenState:o}=t.auth.teamState;n.setTeamState({inviteTokenState:S({},o,i)})}catch(t){n.setTeamError({key:Us.GET_TOKEN_LINK,value:Bn(t)})}},createInvitationLink:async a=>{const{callback:s}=a;n.setTeamError({key:Us.CREATE_TOKEN_LINK,value:!1});const{inviteTokenState:i}=t.auth.teamState;try{const t=await e.teams.createInviteUserLink({expiresInMinutes:43200});n.setTeamState({inviteTokenState:S({},i,t)}),null==s||s(t.token)}catch(t){null==s||s(null,t),n.setTeamError({key:Us.CREATE_TOKEN_LINK,value:Bn(t)})}},updateInvitationLink:async a=>{const{callback:s,expiresInMinutes:i,shouldSendEmail:o}=a;n.setTeamError({key:Us.UPDATE_TOKEN_LINK,value:!1});try{const{inviteTokenState:a}=t.auth.teamState,r=await e.teams.updateInviteUserLink({expiresInMinutes:i,shouldSendEmail:o});n.setTeamState({inviteTokenState:S({},a,r)}),null==s||s(!0)}catch(t){null==s||s(null,t),n.setTeamError({key:Us.UPDATE_TOKEN_LINK,value:Bn(t)})}},deleteInvitationLink:async t=>{const{callback:a}=null!=t?t:{};n.setTeamError({key:Us.DELETE_TOKEN_LINK,value:!1});try{await e.teams.deleteInviteUserLink(),n.setTeamState({inviteTokenState:void 0}),null==a||a(!0)}catch(t){n.setTeamError({key:Us.DELETE_TOKEN_LINK,value:Bn(t)}),null==a||a(!1,t)}}}})(t,e,a))},Yl={tenants:[],subTenants:[],switchingTenant:!1,loading:!0,tenantTree:null},Xl=t=>cn(Yl,t),Ql=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.tenantsState,e)};return{setTenantsState:s,resetTenantsState:()=>{$n(t,["auth","tenantsState"],Yl)},switchTenant:async a=>{const{tenantId:s,silentReload:i,callback:o}=a;i?n.setTenantsState({switchingTenant:!0}):n.setAuthState({isLoading:!0});try{await e.tenants.switchTenant({tenantId:s}),i&&n.resetAuthState({isLoading:!1,isAuthenticated:!0,user:t.auth.user}),await n.__refreshToken(),(null==o?void 0:o(!0))||(i?n.setTenantsState({switchingTenant:!1}):n.setAuthState({isLoading:!1}))}catch(t){i?n.setTenantsState({switchingTenant:!1}):n.setAuthState({isLoading:!1}),null==o||o(!1,t)}},loadTenants:async e=>{s({loading:!0});try{var a;const n=ge(t.root.appName),i=await n();s({tenants:i.tenants,activeTenant:i.activeTenant,loading:!1}),null==e||null==(a=e.callback)||a.call(e,[])}catch(t){var n;null==e||null==(n=e.callback)||n.call(e,[],t),s({loading:!1})}},loadSubTenants:async t=>{s({loading:!0});try{var a;const n=await retryIfNeeded((()=>e.tenants.getSubTenants()),null==t?void 0:t.retryConfig);s({subTenants:n,loading:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var n;s({loading:!1}),null==t||null==(n=t.callback)||n.call(t,null,e)}},loadSubTenantsTree:async t=>{s({loading:!0});try{var a;const n=await e.tenants.getSubTenantsAsTree();s({tenantTree:n,loading:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var n;s({loading:!1}),null==t||null==(n=t.callback)||n.call(t,null,e)}}}},Zl={loading:!1,error:null,username:void 0,fetching:!0},tc=t=>cn(Zl,t),ec=(t,e,a)=>{const n=e=>{Object.assign(t.auth.usernamesState,e)},s=async t=>{n({loading:!0});try{await e.usernames.deleteUsername(t),n({username:void 0,loading:!1})}catch(t){n({error:Bn(t)})}finally{n({loading:!1})}};return{resetUsernamesState:()=>{$n(t,["auth","usernamesState"],Zl)},loadUserOwnUsername:async()=>{n({loading:!0});try{const t=await e.usernames.getUserOwnUsername();n({username:null==t?void 0:t.username,loading:!1,fetching:!1})}catch(t){n({error:Bn(t),fetching:!1})}finally{n({loading:!1,fetching:!1})}},saveUserUsername:async a=>{n({loading:!0});try{var i,o,r;if(t.auth.usernamesState.username===a.username)return void(null==(i=a.callback)||i.call(a));if(t.auth.usernamesState.username&&t.auth.usernamesState.username!==a.username&&(await s(t.auth.usernamesState.username),!a.username))return n({username:void 0,loading:!1}),void(null==(o=a.callback)||o.call(a));a.username&&(await e.usernames.createUsername(a),n({username:a.username,loading:!1}),null==(r=a.callback)||r.call(a))}catch(t){n({error:Bn(t)})}finally{n({loading:!1})}},deleteUserUsername:s}},ac={userEmailPolicyConfig:null,loading:!1},nc=t=>cn(ac,t),sc=(t,e,a)=>{const n=e=>{Object.assign(t.auth.userEmailPolicyState,e)};return{loadUserEmailPolicyState:async()=>{n({loading:!0});try{const t=await e.userEmailPolicy.getUserEmailPolicyConfig();n({loading:!1,userEmailPolicyConfig:t})}catch(t){n({loading:!1,error:Bn(t)})}}}},ic=(t,e,a)=>{const n=e=>{t.auth.user&&(t.auth.user.entitlements=e)},s=e=>{var a;go(null==(a=t.auth.user)?void 0:a.entitlements,e)||n(e)};return{setEntitlements:n,handleFetchedEntitlements:s,loadEntitlements:async t=>{const a=null==t?void 0:t.callback;try{const t=await e.entitlements.loadEntitlementsV2();s(t),null==a||a(!0)}catch(t){null==a||a(!1)}}}};let oc;!function(t){t[t.Email=0]="Email",t[t.Otc=1]="Otc",t[t.Success=2]="Success"}(oc||(oc={}));const rc=["routes"],lc=["requestName"],cc=t=>{const e=null!=t?t:{},{routes:a}=e,n=f(e,rc);return cn(S({routes:S({},In,a),onRedirectTo:()=>{},isAuthenticated:!1,isLoading:!0,isSSOAuth:!1,user:null,error:void 0,errorByRequest:{},userIp:void 0,userIpData:{loading:!1}},n,{acceptInvitationState:gn(null==n?void 0:n.acceptInvitationState),accountSettingsState:Hn(null==n?void 0:n.accountSettingsState),activateAccountState:Yn(null==n?void 0:n.activateAccountState),unlockAccountState:Gs(null==n?void 0:n.unlockAccountState),apiTokensState:Vs(null==n?void 0:n.apiTokensState),applicationsState:Ks(null==n?void 0:n.applicationsState),customLoginState:Xs(null==n?void 0:n.customLoginState),forgotPasswordState:ai(null==n?void 0:n.forgotPasswordState),passwordRotationState:ri(null==n?void 0:n.passwordRotationState),groupsState:ui(null==n?void 0:n.groupsState),groupsDialogsState:vi(null==n?void 0:n.groupsDialogsState),impersonateState:bi(null==n?void 0:n.impersonateState),loginState:Ei(null==n?void 0:n.loginState),mfaState:Co(null==n?void 0:n.mfaState),allAccountsState:Vo(null==n?void 0:n.allAccountsState),allAccountsDialogsState:Ho(null==n?void 0:n.allAccountsDialogsState),passkeysState:ar(null==n?void 0:n.passkeysState),profileState:ir(null==n?void 0:n.profileState),provisioningState:cr(null==n?void 0:n.provisioningState),resetPhoneNumberState:yr(null==n?void 0:n.resetPhoneNumberState),rolesState:Ar(null==n?void 0:n.rolesState),restrictionsState:Rr(null==n?void 0:n.restrictionsState),securityCenterState:xr(null==n?void 0:n.securityCenterState),securityPolicyState:Vr(null==n?void 0:n.securityPolicyState),sessionsPolicyState:Xr(null==n?void 0:n.sessionsPolicyState),sessionsState:el(null==n?void 0:n.sessionsState),signUpState:il(null==n?void 0:n.signUpState),smsState:ul(null==n?void 0:n.smsState),socialLoginState:ml(null==n?void 0:n.socialLoginState),ssoState:El(null==n?void 0:n.ssoState),stepUpState:Cl(null==n?void 0:n.stepUpState),teamState:Nl(null==n?void 0:n.teamState),tenantsState:Xl(null==n?void 0:n.tenantsState),usernamesState:tc(null==n?void 0:n.usernamesState),userEmailPolicyState:nc(null==n?void 0:n.userEmailPolicyState)}))},uc=(t,e,a,n)=>{const s=e=>{Object.keys(e).forEach((a=>{const n=a;Fn(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))},i={acceptInvitationActions:Vn(t,e),accountSettingsActions:Kn(t,e,a),activateAccountActions:xs(t,e,a),unlockAccountActions:js(t,e),apiTokensActions:Hs(t,e),applicationsActions:Js(t,e,a),customLoginActions:Zs(t,e,a),entitlementsActions:ic(t,e),forgotPasswordActions:si(t,e),passwordRotationActions:li(t),groupsActions:hi(t,e),groupsDialogsActions:Si(t),impersonateActions:wi(t,e,a),loginActions:Uo(t,e,a),mfaActions:jo(t,e,a),allAccountsActions:Zo(t,e,a),allAccountsDialogActions:tr(t),passkeysActions:nr(t,e,a),profileActions:rr(t,e,a),provisioningActions:gr(t,e),resetPhoneNumberActions:mr(t,e,a),rolesActions:_r(t,e),restrictionsActions:Mr(t,e,a),securityCenterActions:jr(t,e,a),securityPolicyActions:Jr(t,e,a),sessionsPolicyActions:Zr(t,e,a),sessionsActions:al(t,e),signUpActions:ll(t,e,a),smsActions:Sl(t,e),socialLoginActions:wl(t,e,a),ssoActions:Ul(t,e,a),stepUpActions:Ll(t,e,a),teamActions:Jl(t,e,a),tenantsActions:Ql(t,e,a),usernamesActions:ec(t,e),usersEmailsPolicyActions:sc(t,e)};return[S({setAuthState:s,setErrorByRequestName:e=>{let{requestName:a}=e,n=f(e,lc);t.auth.errorByRequest=S({},t.auth.errorByRequest,{[a]:S({},n,{isError:!0})})},setState:s,resetAuthState:(e={})=>{$n(t,["auth"],S({},n,e))},setUser:t=>{s({user:t})}},Object.values(i).reduce(((t,e)=>S({},t,e)),{})),i]},dc={isLoading:!1,isSaving:!1,list:[],processIds:[],slackChannels:{isLoading:!1}},gc=t=>cn(dc,t),pc=["email","slack","sms","webhook"],hc={sms:{title:"connectivity.sms",events:t=>(null==t?void 0:t.length)||0,isActive:t=>{var e;return null!=(e=null==t?void 0:t.some((({enabled:t})=>t)))&&e},image:"sms"},email:{title:"common.email",events:t=>(null==t?void 0:t.length)||0,isActive:t=>{var e;return null!=(e=null==t?void 0:t.some((({enabled:t})=>t)))&&e},image:"email"},slack:{title:"connectivity.slack",events:t=>{var e;return(null==t||null==(e=t.slackSubscriptions)?void 0:e.length)||0},isActive:t=>!(null==t||!t.slackSubscriptions.some((({isActive:t})=>t))),image:"slack"},webhook:{title:"connectivity.webhook",events:t=>(null==t?void 0:t.length)||0,isActive:t=>{var e;return null!=(e=null==t?void 0:t.some((({isActive:t})=>t)))&&e},image:"webhook"}},yc=["id"],vc=["id","enabled"],Sc=(t,e,a)=>{const n={slack:e.connectivity.getSlackConfiguration,email:e.connectivity.getEmailConfiguration,sms:e.connectivity.getSMSConfiguration,webhook:e.connectivity.getWebhooksConfigurations,categories:e.connectivity.getCategories,channelMap:e.connectivity.getChannelMaps},s=["categories","channelMap"],i={slack:e.connectivity.postSlackConfiguration,email:e.connectivity.postEmailConfiguration,sms:e.connectivity.postSMSConfiguration,webhook:e.connectivity.postWebhooksConfiguration},o=e=>{Object.assign(t.connectivity,e)},r=e=>{var a;const n=null!=(a=t.connectivity.retryResult)?a:{};t.connectivity.retryResult=S({},n,e)},l=()=>{$n(t,["connectivity"],dc)},c=async(t,e,a)=>{try{return await Ln((()=>n[t](e)),a)}catch(t){return}},u=async()=>{try{o({slackChannels:{isLoading:!0}});const t=await e.connectivity.getSlackChannels();o({error:void 0,slackChannels:{isLoading:!1,data:t}})}catch(t){o({error:void 0,slackChannels:{isLoading:!1}})}},d=async t=>{const e=null!=t?t:pc;o({isLoading:!0});try{const t=await Promise.all([...e.map((t=>c(t,void 0,Un))),c("categories",void 0,Un),(async()=>(await Promise.all(e.map((t=>c("channelMap",t,Un))))).reduce(((t,a,n)=>S({},t,{[`${e[n]}`]:a})),{}))()]),a=await c("webhook",void 0,Un),n=t.reduce(((a,n,i)=>e[i]?t[t.length-1][e[i]].length?S({},a,{[`${e[i]}`]:n,list:[...a.list,{id:i,key:e[i],events:hc[e[i]].events(n),active:hc[e[i]].isActive(n),platform:hc[e[i]].title,image:hc[e[i]].image}]}):a:S({},a,{[`${s[i-e.length]}`]:n})),{list:[],webhook:a});o(S({},n,{error:void 0,isSaving:!1,isLoading:!1}))}catch(t){o({isLoading:!1,error:Bn(t)})}},g=async(e,a)=>{const{list:n}=t.connectivity,s=n.find((({key:t})=>t===e));if(!s)return;const i=hc[e].isActive(a);i!==s.active&&o({list:n.map((t=>t.key===e?S({},t,{active:i}):t))})},p=async a=>{const{platform:n,data:s,callback:r}=a,l=t.connectivity.processIds;try{if(o({isSaving:!0,processIds:"webhook"===n?[s._id,...l]:l}),"slack"===n?await(async a=>{var n;const s=null==(n=t.connectivity.slack)?void 0:n.slackSubscriptions;if(!s)return;const{slackSubscriptions:o}=a;await Promise.all([...o.reduce(((t,e)=>{var a,n;return!e.id&&e.slackEvents&&null!=(a=e.slackEvents[0].channelIds)&&a.length||(null==s?void 0:s.find((t=>{let{id:a}=t,n=f(t,yc);return a===e.id&&JSON.stringify(S({id:a},n))!==JSON.stringify(e)})))&&e.slackEvents&&null!=(n=e.slackEvents[0].channelIds)&&n.length?[...t,e]:t}),[]).map((t=>i.slack(t))),...o.reduce(((t,e)=>e.id&&!e.slackEvents[0].channelIds.length?[...t,e]:t),[]).map((t=>e.connectivity.deleteSlackConfiguration(t)))])})(s):["sms","email"].includes(n)?await(async(a,n)=>{const s=t.connectivity.processIds,i=t.connectivity[n];if(!i)return;let r=[];try{r=await Promise.all([...a.reduce(((t,e)=>!i.find((({eventKey:t})=>t===e.eventKey))&&e.subscriptions[0].recipients.filter((t=>t)).length?[...t,e]:t),[]).map((t=>"email"===n?e.connectivity.postEmailConfiguration(t):e.connectivity.postSMSConfiguration(t))),...a.reduce(((t,e)=>{const a=i.find((({eventKey:t})=>t===e.eventKey));return a&&JSON.stringify(a)!==JSON.stringify(e)?[...t,e]:t}),[]).map((t=>{const{subscriptions:a,eventKey:s}=t,i=a[0],{id:o="",enabled:r}=i,l=f(i,vc);return Promise.all(["email"===n?e.connectivity.patchEmailConfiguration({eventKey:s,enabled:r}):e.connectivity.patchSMSConfiguration({eventKey:s,enabled:r}),"email"===n?e.connectivity.putEmailSubscriptions(o,s,S({},l,{enabled:r})):e.connectivity.putSMSSubscriptions(o,s,S({},l,{enabled:r}))])})),...a.reduce(((t,e)=>{const a=i.find((({eventKey:t})=>t===e.eventKey));return a&&a.subscriptions[0].recipients.length&&!e.subscriptions[0].recipients.filter((t=>!!t)).length?[...t,e]:t}),[]).map((({eventKey:t,subscriptions:a})=>"email"===n?e.connectivity.deleteEmailSubscriptions(t,a[0].id||""):e.connectivity.deleteSMSSubscriptions(t,a[0].id||"")))])}catch{}if(r.length){const t=await c(n);o({error:void 0,isSaving:!1,[`${n}`]:t,processIds:t.id?s.filter((e=>e!==t.id)):s}),await g(n,t)}else o({error:void 0,isSaving:!1,[`${n}`]:i,processIds:s})})(s,n):await i[n](s),!["sms","email"].includes(n)){const t=await c(n);"webhook"===n&&(t.id=s._id),o({error:void 0,isSaving:!1,[`${n}`]:t,processIds:t.id?l.filter((e=>e!==t.id)):l}),await g(n,t),null==r||r(!0)}}catch(t){o({error:Bn(t),isSaving:!1,isLoading:!1})}},h=async t=>{try{await e.connectivity.postSlackCode(t)}catch{}o({error:void 0,isSaving:!1})},y=async()=>{const a=t.connectivity.slackChannels;try{o({slackChannels:S({},a,{isLoadingScope:!0})});const{clientId:t}=await e.connectivity.getSlackScope();o({slackChannels:{error:void 0,clientId:t,isLoadingScope:!1,isLoading:!1}})}catch{o({slackChannels:{error:void 0,isLoadingScope:!1,isLoading:!1}})}},v=async a=>{const{callback:n,webhookId:s}=a,i=t.connectivity.processIds;try{o({isSaving:!0}),await e.connectivity.deleteWebhooksConfiguration(s)}catch(t){null==n||n(null,Bn(t))}const r=await c("webhook");r&&o({error:void 0,isSaving:!1,webhook:r,processIds:r.id?i.filter((t=>t!==r.id)):i}),null==n||n(!0)},m=async t=>{try{o({isTesting:!0});const{statusCode:a,body:n}=await e.connectivity.postWebhookTest(t);if([201,200].includes(a)){const t=JSON.stringify(n,null,2);o({isTesting:!1,testResult:{status:"success",message:t}})}else o({isTesting:!1,testResult:{status:"failed"}})}catch(t){o({isTesting:!1,testResult:{status:"failed",message:Bn(t)}})}},b=async t=>{try{const{statusCode:a}=await e.connectivity.postWebhookRetry(t);r({[t]:{isProcess:!1,success:202===a}})}catch(e){r({[t]:{isProcess:!1,success:!1}})}},A=async a=>{const{id:n,limit:s,offset:i}=a,r=t.connectivity.webhookLogs;try{o({webhookLogs:S({},r,{isLoading:!0})});const t=await e.connectivity.getWebhookLog(n,i,s);o({error:void 0,webhookLogs:S({isLoading:!1},t)})}catch(t){o({error:void 0,webhookLogs:{isLoading:!1}})}};return{setConnectivityState:o,initData:l,resetConnectivityState:l,loadSlackActions:u,loadSlackChannels:u,loadDataAction:d,loadConnectivityChannels:d,postDataAction:p,postChannelData:p,postCodeAction:h,postSlackCode:h,loadScope:y,loadSlackPermissions:y,deleteWebhookConfigAction:v,deleteWebhookConfig:v,postWebhookTestAction:m,postWebhookTest:m,postWebhookRetryAction:b,postWebhookRetry:b,loadWebhookLogsAction:A,loadWebhookLogs:A,cleanWebhookTestData:()=>{o({testResult:void 0})},cleanWebhookLogsData:async()=>{o({webhookLogs:void 0})},cleanWebhookTestMessage:async t=>{var e;o({testResult:{status:null==(e=t.testResult)?void 0:e.status,message:void 0}})},cleanError:async()=>{o({error:void 0})},cleanSlackData:async()=>{o({slackChannels:{isLoading:!1}})}}};let fc;!function(t){t.UNKNWON="unknown",t.CARD="card"}(fc||(fc={}));const mc={loading:!1,error:null,fetching:!0,config:null},bc=t=>cn(mc,t);let Ac,wc,Tc;!function(t){t.STRIPE="Stripe"}(Ac||(Ac={})),function(t){t.ACTIVE="ACTIVE",t.CANCELED="CANCELED",t.INCOMPLETE="INCOMPLETE",t.EXPIRED="EXPIRED",t.TRIALING="TRIALING"}(wc||(wc={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}(Tc||(Tc={}));const Ec=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.config,e)},s=e=>{Object.assign(t.subscriptions.config,{error:e,loading:!1,fetching:!1})};return{setPaymentConfigState:n,resetPaymentConfigState:()=>{$n(t,["subscriptions","config"],mc)},loadPaymentConfiguration:async()=>{n({loading:!0});try{var t;(null!=(t=await e.subscriptions.getPaymentProviders())?t:[]).find((t=>"1"===t.status&&t.providerType===V.Stripe))?await(async()=>{n({loading:!0});try{const t=await e.subscriptions.getStripePaymentProviderConfiguration(),a={paymentProvider:Ac.STRIPE,apiKey:t.publishableKey};n({config:a}),n({loading:!1,fetching:!1})}catch(t){s(Bn(t))}})():s(Bn("Payment provider not configured"))}catch(t){s(Bn(t))}}}},Pc={loading:!1,error:null,fetching:!0},Oc=t=>cn(Pc,t);function Ic({policy:t}){return{policy:Tc.AT_PERIOD_END}}function kc(t){switch(t){case G.ACTIVE:return wc.ACTIVE;case G.INCOMPLETE:return wc.INCOMPLETE;case G.CANCELED:return wc.CANCELED;case G.EXPIRED:return wc.EXPIRED;case G.TRIALING:return wc.TRIALING;default:return wc.EXPIRED}}const _c=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.billing.information,e)},i=t=>{s({error:t,loading:!1,fetching:!1})},o=async(a,o)=>{s({loading:!0});try{var r,l;const i=await e.subscriptions.getSubscriptionSummaries(a),{currentPlanId:c,externallyManaged:u}=i;let d,g=null;u?d=await e.subscriptions.getSubscriptionPlan(c):([,d]=await Promise.all([n.loadSubscription(),e.subscriptions.getSubscriptionPlan(c)]),g=t.subscriptions.billing.subscription.subscription||null),s(S({loading:!1,fetching:!1,summary:i},g?{subscription:{id:g.id,externalId:g.externalId,startDate:g.startDate,currentPeriodStart:g.currentPeriodStart,currentPeriodEnd:g.currentPeriodEnd,status:o?wc.ACTIVE:kc(g.status),cancellation:g.cancellation&&Ic(g.cancellation),trialEnd:g.trialEnd?g.trialEnd:null}}:{},d?{plan:{id:d.id,name:d.name,description:d.description,price:(null==(r=d.price)?void 0:r.amount)||0,currency:(null==(l=d.price)?void 0:l.currency)||"usd",recurringInterval:"month",slug:d.slug}}:{}))}catch(t){i(Bn(t))}};return{setBillingInformationState:s,resetBillingInformationState:()=>{$n(t,["subscriptions","billing","information"],Pc)},loadSummaries:o,loadBillingInformation:async e=>{var a,n;const s=null==(a=t.subscriptions.config.config)?void 0:a.paymentProvider,r=null==(n=t.auth.user)?void 0:n.tenantId;s&&r?await o(r,e):i(new z(s?"Not authorized":"Internal feature failure",500,null))}}},Uc={loading:!1,error:null,fetching:!0,invoices:[],invoiceDownload:{loading:!1,error:null}},Rc=t=>cn(Uc,t),Cc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.billing.invoices,e)},s=e=>{Object.assign(t.subscriptions.billing.invoices.invoiceDownload,e)},i=async()=>{n({loading:!0});try{const t=(await e.subscriptions.getSubscriptionInvoices()).map((t=>({id:t.id,externalId:t.externalId,subscriptionId:t.subscriptionId,paymentDate:new Date(Date.parse(t.paymentDate)),totalAmount:+((t.totalAmount||0)/100).toFixed(2),currency:t.currency||"usd",paid:t.paid||!1,receiptNumber:t.receiptNumber})));n({loading:!1,fetching:!1,invoices:t})}catch(e){t=Bn(e),n({error:t,loading:!1,fetching:!1})}var t},o=async t=>{s({loading:!0,error:null});try{await e.subscriptions.getSubscriptionInvoicePdf(t.invoiceId,t.filename),s({loading:!1,error:null})}catch(t){s({loading:!1,error:Bn(t,null)})}};return{setBillingInvoiceState:n,resetBillingInvoiceState:()=>{$n(t,["subscriptions","billing","invoices"],Uc)},loadInvoices:i,loadBillingInvoices:i,downloadInvoice:o,downloadBillingInvoice:o}},Lc={loading:!1,error:null,fetching:!0},Dc=t=>cn(Lc,t),Nc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.billing.paymentMethod,e)},s=t=>{n({loading:t})},i=t=>{n({error:t,loading:!1,fetching:!1})},o=async()=>{s(!0);try{const t=(await e.subscriptions.getPaymentMethods())[0];n({paymentMethod:t,loading:!1,fetching:!1})}catch(t){i(Bn(t))}};return{setBillingPaymentMethodState:n,resetBillingPaymentMethodState:()=>{$n(t,["subscriptions","billing","paymentMethod"],Lc)},loadPaymentMethod:o,submitPaymentMethod:async()=>{s(!0)},submitPaymentMethodError:async t=>{i(t)},submitPaymentMethodSuccess:async()=>await o(),updatePaymentMethodBillingDetails:async t=>{s(!0);const{id:a,email:n,address:r,callback:l}=t;try{await e.subscriptions.updatePaymentMethodBillingDetails(a,S({email:n},r)),await o(),null==l||l(!0)}catch(t){i(Bn(t)),null==l||l(!1,t)}finally{s(!1)}}}},Mc={loading:!1,error:null,fetching:!0,cancellation:{loading:!1,error:null},renewal:{loading:!1,error:null}},Fc=t=>cn(Mc,t),xc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.billing.subscription,e)},i=t=>{s({error:t,loading:!1,fetching:!1})},o=e=>{Object.assign(t.subscriptions.billing.subscription.cancellation,{loading:e})},r=e=>{Object.assign(t.subscriptions.billing.subscription.cancellation,{error:e})},l=e=>{Object.assign(t.subscriptions.billing.subscription.renewal,{loading:e})},c=e=>{Object.assign(t.subscriptions.billing.subscription.renewal,{error:e})},u=async()=>{s({loading:!0});try{const[t]=await e.subscriptions.getManagedSubscriptions();s({subscription:t,fetching:!1,loading:!1,error:null})}catch(t){i(Bn(t))}};return{setBillingSubscriptionState:s,resetBillingSubscriptionState:()=>{$n(t,["subscriptions","billing","subscription"],Mc)},setCancellationLoading:o,setCancellationError:r,setRenewalLoading:l,setRenewalError:c,loadSubscription:u,loadSubscriptionTenant:async()=>{var e;const a=null==(e=t.auth.user)?void 0:e.tenantId;a?await n.loadSummaries(a):i(new z("TenantId is not defined",500,null))},cancelSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void r(new z("Subscription not found",500,null));if(null!=a&&a.externallyManaged)return void r(new z("Billing is externally managed",500,null));const{id:n,cancellation:s,status:i}=a||{};if(!s&&i===G.ACTIVE)try{o(!0),await e.subscriptions.cancelManagedSubscription(n),await u(),o(!1)}catch(t){r(Bn(t))}},renewSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void c(new z("Subscription not found",500,null));if(null!=a&&a.externallyManaged)return void c(new z("Billing is externally managed",500,null));const{id:n,cancellation:s}=a||{};if((null==s?void 0:s.policy)===B.AT_PERIOD_END)try{l(!0),await e.subscriptions.renewManagedSubscription(n),await u(),l(!1)}catch(t){c(Bn(t))}}}},$c=t=>cn({information:Oc(null==t?void 0:t.information),invoices:Rc(null==t?void 0:t.invoices),paymentMethod:Dc(null==t?void 0:t.paymentMethod),subscription:Fc(null==t?void 0:t.subscription)}),Gc={loading:!1,error:null,fetching:!0,plans:[]},jc=t=>cn(Gc,t),Bc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.plans,e)};return{setPlansState:n,resetPlansState:()=>{$n(t,["subscriptions","plans"],Gc)},loadPlans:async()=>{n({loading:!0});try{const t=(await e.subscriptions.getSubscriptionPlans()).map((t=>{var e,a;return{id:t.id,name:t.name,description:t.description,price:(null==(e=t.price)?void 0:e.amount)||0,currency:(null==(a=t.price)?void 0:a.currency)||"usd",recurringInterval:"month",slug:t.slug}}));n({fetching:!1,loading:!1,plans:t})}catch(e){t=Bn(e),n({loading:!1,fetching:!1,error:t})}var t}}},Vc={fetching:!0,loading:!1,error:null,confirmed:!1},Wc=t=>cn(Vc,t),Hc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.checkout,e)};return{setCheckoutState:s,resetCheckoutState:()=>{$n(t,["subscriptions","checkout"],Vc)},loadCheckout:()=>{s({fetching:!1,loading:!1,error:null,confirmed:!1})},resetCheckout:()=>{s({loading:!1,error:null,confirmed:!1})},submitCheckout:()=>{s({loading:!0,error:null})},confirmCheckout:async a=>{const{paymentMethodId:i,planId:o}=a,r=t.subscriptions.billing.subscription.subscription,l=t.subscriptions.billing.information.summary,c=(null==r?void 0:r.status)===G.TRIALING,u=!(null==l||!l.paymentMethodId);if(r){if(s({loading:!0,error:null}),c&&u)return s({loading:!1,error:null,confirmed:!0}),void n.setBillingSubscriptionState({subscription:S({},r,{status:G.ACTIVE})});try{await e.subscriptions.updateManagedSubscription(r.id,{paymentMethodId:i,planId:o}),await Promise.all([n.loadBillingInformation(),n.loadPaymentMethod(),n.loadInvoices()]),s({loading:!1,error:null,confirmed:!0})}catch(t){s({loading:!1,error:Bn(t)})}}else s({loading:!1,error:new z("Subscription not found",500,null)})},errorCheckout:t=>{s({loading:!1,error:t})}}},zc={loading:!1,error:null,cardSetupIntentSecret:null},Kc=t=>cn(zc,t),qc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.stripe,e)};return{createCardSetupIntentSecret:async a=>{n({loading:!0,error:null,cardSetupIntentSecret:null});try{const t={};a&&(t.paymentMethodId=a);const{setupIntentSecret:s}=await e.subscriptions.createStripePaymentMethodSetupIntentSecret(t);n({cardSetupIntentSecret:s,loading:!1})}catch(e){s=Bn(e),Object.assign(t.subscriptions.stripe,{error:s,loading:!1,fetching:!1})}var s},setStripeState:n,resetStripeState:()=>{$n(t,["subscriptions","stripe"],zc)}}},Jc={loading:!1,fetching:!0,vendorPublicConfig:null},Yc=t=>cn(Jc,t),Xc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.vendorPublicConfig,e)},s=e=>{Object.assign(t.subscriptions.vendorPublicConfig,{error:e,loading:!1,fetching:!1})},i=e=>{Object.assign(t.subscriptions.vendorPublicConfig,{error:null,loading:e})};return{setVendorPublicConfigState:n,resetVendorPublicConfigState:()=>{$n(t,["subscriptions","vendorPublicConfig"],Jc)},setVendorPublicConfigError:s,setVendorPublicConfigLoading:i,loadVendorPublicConfiguration:async()=>{i(!0);try{const t=await e.subscriptions.getVendorPublicConfigurations();n({fetching:!1,loading:!1,vendorPublicConfig:t})}catch(t){s(Bn(t))}}}},Qc=t=>cn({config:bc(null==t?void 0:t.config),billing:$c(null==t?void 0:t.billing),plans:jc(null==t?void 0:t.plans),checkout:Wc(null==t?void 0:t.checkout),stripe:Kc(null==t?void 0:t.stripe),vendorPublicConfig:Yc(null==t?void 0:t.vendorPublicConfig)}),Zc=(t,e,a)=>{const n=Ec(t,e),[s,i]=((t,e,a)=>{const n=_c(t,e,a),s=Nc(t,e),i=Cc(t,e),o=xc(t,e,a);return[S({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=Bc(t,e),r=Hc(t,e,a),l=qc(t,e),c=Xc(t,e);return[S({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},tu={loading:!1},eu=t=>cn(tu,t),au=(t,e,a)=>{const n=e=>{Object.assign(t.vendor,e)},s=async t=>{n({loading:!0});try{var a;const s=await Ln((()=>e.vendor.getVendorPublicInfo()),null==t?void 0:t.retryConfig);s.whiteLabelMode=null!=(a=s.whiteLabelMode)&&a,n(S({},s,{loading:!1}))}catch(t){n({loading:!1}),console.error("failed to getVendorPublicInfo - ",t)}};return{setVendorState:n,resetVendorState:()=>{$n(t,["vendor"],tu)},loadVendorPublicInfo:s,loadVendorPublicConfiguration:s}},nu={loading:!0,pageOffset:0,pageSize:20,logs:[],sort:[],filter:[],totalPages:0,isDownloadingCsv:!1},su=t=>cn(nu,t),iu=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auditLogs.auditLogsState,e)};return{setAuditLogsState:s,resetAuditLogsState:()=>{$n(t,["auditLogs","auditLogsState"],nu)},exportAuditsCsv:async()=>{const a=t.auditLogs.auditLogsState,{columns:n}=t.auditLogs.auditsMetadataState;try{const t=a.filter,i=a.sort.reduce(((t,e)=>S({},t,{sortBy:e.id,sortDirection:e.desc?"desc":"asc"})),{}),o=t.reduce(((t,e)=>S({},t,{[e.id]:e.value})),{});s({isDownloadingCsv:!0});const r="audits.csv";await e.audits.exportAudits(S({endpoint:"csv/v2",headerProps:n,offset:0,outputFileName:r},i,o))}catch(t){console.error("failed to export audits - ",t)}s({isDownloadingCsv:!1})},loadAuditLogs:async a=>{s({loading:!(null!=a&&a.silentLoading),error:null});const i=t.auditLogs.auditLogsState,o=null==a?void 0:a.retryConfig,{columns:r}=t.auditLogs.auditsMetadataState;try{var l,c,u,d,g;const t=null!=(l=a.pageSize)?l:i.pageSize,p=null!=(c=a.pageOffset)?c:i.pageOffset,h=null!=(u=a.filter)?u:i.filter,y=null!=(d=a.sort)?d:i.sort;s({pageSize:t,pageOffset:p,filter:h,sort:y});const v=y.reduce(((t,e)=>S({},t,{sortBy:e.id,sortDirection:e.desc?"desc":"asc"})),{}),f=h.reduce(((t,e)=>S({},t,{[e.id]:e.value})),{});r||await n.loadAuditsMetadata({retryConfig:o});const{data:m,total:b}=await Ln((()=>e.audits.getAudits(S({offset:p,count:t},v,f))),o);s({loading:!1,logs:null!=m?m:[],totalPages:+Math.ceil(b/t)}),null==a||null==(g=a.callback)||g.call(a,!0)}catch(t){var p;s({loading:!1,error:Bn(t)}),null==a||null==(p=a.callback)||p.call(a,null,t)}}}},ou={loading:!0},ru=t=>cn(ou,t),lu=(t,e,a)=>{const n=e=>{Object.assign(t.auditLogs.auditsMetadataState,e)};return{setAuditsMetadataState:n,resetAuditsMetadataState:()=>{$n(t,["auditLogs","auditsMetadataState"],ou)},loadAuditsMetadata:async t=>{n({loading:!0,error:null});try{const{properties:a}=await Ln((()=>e.metadata.getAuditsMetadata()),null==t?void 0:t.retryConfig);n({columns:a,loading:!1})}catch(t){n({error:t,loading:!1})}}}},cu=t=>({auditLogsState:su(null==t?void 0:t.auditLogsState),auditsMetadataState:ru(null==t?void 0:t.auditsMetadataState)}),uu=(t,e,a)=>S({},iu(t,e,a),lu(t,e)),du={total:0,offset:0,filter:"",sortBy:"createdAt",context:null,filters:[],rowsData:[],lastUpdated:new Date,isLoading:!0,isFetchMore:!1,totalToday:0,currentPage:0,headerProps:[],sortDirection:"desc",severeThisWeek:0,predefinedFilters:[],isDownloadingCsv:!1,virtualScroll:!1},gu=(t,e)=>Object.keys(t).reduce(((a,n)=>{const s=n;return e.includes(n)?S({},a,{[n]:t[s]}):S({},a,{[n]:()=>{console.debug(`Action ${String(n)} was called`)}})}),{}),pu={clientId:"CLIENT_ID_16806d3d-8fc3-4450-be97-abdaf66b723e",secret:"SECRET_16806d3d-8fc3-4450-be97-abdaf66b723e",createdAt:"createdAt",description:"Demo API Token (preview only)"},hu=S({},pu,{roleIds:[],tenantId:"my-tenant-id",createdByUserId:"createdByUserId"}),yu=[{id:"a040dcf6-b907-4e83-9970-6bd23c88fd40",key:"ReadOnly",name:"Read Only",description:null,isDefault:!1,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03"],vendorId:"vendorId"},{id:"b43b2c4b-e056-4eec-8c55-d200a475bbc0",key:"Admin",name:"Admin",description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03","16647407-ed6f-4ca6-83a0-86225d921959","f403c6b9-1abe-4ec7-9971-aa032255fc25","a43e059d-d731-44b1-94bb-fb6b16c62210"],vendorId:"vendorId"},{id:"1234",key:"Support",name:"Support",description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03","f26b00f8-ffe0-4739-b15c-7db15c27ea26","a9c803b0-ebfa-49b9-9607-f0d3a390ee61"],tenantId:"tenantId",vendorId:"vendorId"}],vu={sub:"",tenants:[],id:"testId",name:"Demo User Name",email:"demo-user@frontegg.com",mfaEnrolled:!0,profilePictureUrl:"https://www.gravatar.com/avatar/42b2ad2bad6fc9b9db5086dfcf8072ac?d=https://ui-avatars.com/api/fe/128/random?t=1617261890875?t=1617261917434",roles:[{id:"roleId",key:"admin",isDefault:!1,name:"Admin",description:null,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03"],tenantId:"tenantId",vendorId:"vendorId",createdAt:new Date,updatedAt:new Date}],permissions:[{id:"8d71b676-754c-4600-afe7-ca5add1e6809",key:"fe.*",name:"General Admin",description:"description",categoryId:"category",fePermission:!0,createdAt:new Date,updatedAt:new Date,roleIds:[]}],tenantId:"my-tenant-id",tenantIds:["my-tenant-id"],activatedForTenant:!0,metadata:JSON.stringify({phoneNumber:"+972-54123456",jobTitle:"Developer",address:{city:"Tel Aviv",country:"Israel"}}),verified:!1},Su=S({},vu,{accessToken:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1MTY5YmY0Zi02YmI5LTQ5NGMtOGNkZS05MDc4NDQ0NWY4MDciLCJuYW1lIjoiRHVtbXkgVXNlciIsImVtYWlsIjoiZHVtbXlAZnJvbnRlZ2cuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsIm1ldGFkYXRhIjp7fSwicm9sZXMiOlsiYWRtaW4iXSwicGVybWlzc2lvbnMiOlsiZmUuKiJdLCJ0ZW5hbnRJZCI6Im15LXRlbmFudC1pZCIsInRlbmFudElkcyI6WyJteS10ZW5hbnQtaWQiXSwicHJvZmlsZVBpY3R1cmVVcmwiOiJodHRwczovL3d3dy5ncmF2YXRhci5jb20vYXZhdGFyLzQyYjJhZDJiYWQ2ZmM5YjlkYjUwODZkZmNmODA3MmFjP2Q9aHR0cHM6Ly91aS1hdmF0YXJzLmNvbS9hcGkvZmUvMTI4L3JhbmRvbT90PTE2MTcyNjE4OTA4NzU_dD0xNjE3MjYxOTE3NDM0IiwidHlwZSI6InVzZXJUb2tlbiIsImlhdCI6MTYxNzkwNjMyNCwiZXhwIjoxNjE3OTkyNzI0LCJpc3MiOiJmcm9udGVnZyJ9.paaXLkpWEWbQmUtoK2P8IwXCxK4WJp7XhXonvzF8g1I",expiresIn:86400,mfaRequired:!1,refreshToken:"refresh-token-dummy-de39dc9c-9d22-4852-b7f5-c3c0aa613b58",type:"userToken",iat:1617906324,exp:1617992724,iss:"frontegg",email_verified:!0}),fu={loading:!1,error:void 0,saving:!0,profile:vu},mu={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date,allowOverrideEnforcePasswordHistory:!0,allowOverridePasswordComplexity:!1,allowOverridePasswordExpiration:!1,allowSignups:!0,apiTokensEnabled:!0,cookieSameSite:"cookieSameSite",defaultRefreshTokenExpiration:0,defaultTokenExpiration:1,publicKey:"publicKey"},bu={allowSignups:!0,allowNotVerifiedUsersLogin:!1,apiTokensEnabled:!0,forcePermissions:!1,authStrategy:N.EmailAndPassword,machineToMachineAuthStrategy:M.ClientCredentials},Au={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date},wu={id:"id",enabled:!0,maxAttempts:1,createdAt:new Date,updatedAt:new Date},Tu={id:"id",enabled:!0,historySize:1,createdAt:new Date,updatedAt:new Date},Eu={enabled:!0,domain:"domain",validated:!0,generatedVerification:"generatedVerification",ssoEndpoint:"ssoEndpoint",publicCertificate:"publicCertificate",signRequest:!0,createdAt:new Date,updatedAt:new Date,acsUrl:void 0,spEntityId:void 0,oidcClientId:void 0,oidcSecret:void 0,type:void 0},Pu={id:"id",createdAt:"createdAt",updatedAt:"updatedAt",properties:[],vendorId:"vendorId",entityName:"saml",isActive:!0,configuration:{acsUrl:"acsUrl",spEntityId:"spEntityId"}},Ou=[{id:"id",description:"description",key:"key",name:"name",permissions:[],permissionLevel:1}],Iu={firstLoad:!1,loading:!1,error:void 0,saving:!1,samlConfiguration:Eu,roles:Ou,authorizationRoles:[],errors:{},loaders:{},ssoConfigurations:[]},ku=[{description:"string",fePermission:!0,id:"id",key:"key",name:"name",roleIds:[],createdAt:new Date,updatedAt:new Date,categoryId:"categoryId"}],_u={id:"id2",email:"demo-user2@frontegg.com",name:"Demo User Name2",phone:void 0,profileImage:void 0,profileImageUrl:void 0,tenantId:"tenantId",vendorId:"vendorId",roleIds:[],activatedForTenant:!0,verified:!1,createdAt:(new Date).toISOString(),customData:void 0,lastLogin:void 0,mfaEnabled:void 0,roles:[yu[0]],groups:[{id:"id2",name:"Developers",color:"#03A9F4",roles:[yu[0]],managedBy:za.FRONTEGG}]},Uu={id:_u.id,email:_u.email,name:_u.name,phoneNumber:void 0,profileImage:void 0,tenantId:"tenantId",activatedForTenant:!0,createdAt:new Date(2022,4,1),verified:!0,lastLogin:new Date(2022,5,25),mfaEnrolled:!1,roles:[yu[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},Ru={id:"id",email:"demo-user@frontegg.com",name:"Demo User Name",phone:void 0,profileImage:void 0,profileImageUrl:void 0,tenantId:"tenantId",vendorId:"vendorId",roleIds:[],activatedForTenant:!0,createdAt:new Date(2022,4,1).toISOString(),verified:!0,customData:void 0,lastLogin:new Date(2022,5,25).toISOString(),mfaEnabled:void 0,roles:[yu[1]],groups:[{id:"id1",name:"Designers",color:"#E1F5E2",roles:[yu[0]],managedBy:za.FRONTEGG}]},Cu={id:Ru.id,email:Ru.email,name:Ru.name,phoneNumber:void 0,profileImage:void 0,tenantId:"tenantId",activatedForTenant:!0,createdAt:new Date(2022,4,1),verified:!0,lastLogin:new Date(2022,5,25),mfaEnrolled:!1,roles:[yu[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},Lu={metadata:"",mfaEnrolled:!1,provider:"",sub:"",tenantIds:[],tenants:[],verified:!1,id:"id",email:"email",name:"name",tenantId:"tenantId",createdAt:new Date},Du=[Ru,_u],Nu=[Cu,Uu],Mu=[Lu],Fu=[{id:"my-tenant-id",isReseller:!1,name:"Frontegg demo",deletedAt:null,metadata:void 0,tenantId:"my-tenant-id",vendorId:"vendorId",createdAt:new Date,updatedAt:new Date,address:void 0,timezone:void 0,dateFormat:void 0,timeFormat:void 0,currency:void 0,logo:void 0}],xu=[{id:"laptop",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/605.1.15",createdAt:new Date,ipAddress:"190.194.88.251",current:!0},{id:"iphone",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Mobile/15E148 Safari/604.1",createdAt:new Date(Date.now()-1e4),ipAddress:"191.49.203.21"},{id:"tablet",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; SGP771 Build/32.2.A.0.253; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Safari/537.36",createdAt:new Date(Date.now()-3e4),ipAddress:"130.19.196.136"},{id:"anotherlaptop",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/605.1.15",createdAt:new Date(Date.now()-1002232300),ipAddress:"2.228.163.92"}],$u={isActive:!0,strategy:Jt.ALLOW},Gu=[{updatedAt:new Date,createdAt:new Date,id:"1",ip:"255.255.255.255",isActive:!0,strategy:Jt.ALLOW,description:"My IP"},{updatedAt:new Date,createdAt:new Date,id:"2",ip:"255.255.255.254",isActive:!0,strategy:Jt.ALLOW,description:"IP 2"},{updatedAt:new Date,createdAt:new Date,id:"3",ip:"255.255.255.253",isActive:!0,strategy:Jt.BLOCK,description:"IP 3"},{updatedAt:new Date,createdAt:new Date,id:"4",ip:"255.255.255.253",isActive:!0,strategy:Jt.BLOCK,description:"IP 4"}],ju=t=>{const e=[];return Array.from({length:t}).forEach(((t,a)=>{e.push(S({},Ru,{name:"Demo User",id:`id${a}`,profilePictureUrl:null,createdAt:new Date}))})),e},Bu=t=>({id:"b43b2c4b-e056-4eec-8c55-d200a475bbc0"+t,key:t,name:t,description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:[],tenantId:"tenantId",vendorId:"vendorId"}),Vu=[{id:"id1",name:"Designers",color:"#E1F5E2",description:"The whole design team",users:ju(6),roles:[Bu("Editor")],metadata:'{"lastTermsCheck":"2022-08-16T10:31:11.270Z"}',managedBy:za.FRONTEGG},{id:"id2",name:"Developers",color:"#03A9F4",description:"All frontend and backend developers",users:ju(44),roles:[Bu("Editor")],managedBy:za.FRONTEGG},{id:"id3",name:"Product",color:"#E1583E",description:"PMs and team leads",users:ju(8),roles:[Bu("Viewer")],managedBy:za.FRONTEGG},{id:"id4",name:"Management",color:"#9AE0FF",description:"Executives",users:ju(5),roles:[Bu("Admin")],managedBy:za.FRONTEGG},{id:"id5",name:"Sales",color:"#ED8E7C",users:ju(21),description:"BDR, AE, and inside sales",roles:[Bu("Viewer")],managedBy:za.FRONTEGG},{id:"id6",name:"Support",color:"#A79D7B",users:ju(23),description:"Dev success and customer success",roles:[Bu("Admin")],managedBy:za.FRONTEGG},{id:"id7",name:"Marketing",color:"#2CA744",users:ju(10),description:"The marketing department",roles:[Bu("Viewer")],managedBy:za.FRONTEGG},{id:"id8",name:"HR",color:"#EAE1C2",users:ju(4),description:"Human resources",roles:[Bu("Viewer")],managedBy:za.FRONTEGG},{id:"id9",name:"Finance",color:"#5587C0",users:ju(3),roles:[Bu("Viewer")],managedBy:za.FRONTEGG},{id:"id10",name:"Operations",color:"#B1CAE7",users:ju(8),roles:[Bu("Editor")],managedBy:za.FRONTEGG},{id:"id11",name:"Legal",color:"#2CA744",users:ju(4),roles:[Bu("Viewer")],managedBy:za.FRONTEGG}],Wu={scoring:{score:79},recommendations:{items:[{code:Xa.FORCE_MFA,severity:tn.WARNING,category:en.MFA},{code:Xa.ENABLE_FORCE_RELOGIN,severity:tn.WARNING,category:en.SESSIONS}]}},Hu={insights:{items:[{category:en.MFA,code:Qa.PARTIALLY_FORCED_MFA,metadata:{totalUsers:2,mfa:{enrolledUsersCount:1}}},{category:en.SESSIONS,code:Qa.PARTIAL_SESSION_SETTINGS,metadata:{totalUsers:2,sessions:{idleTimeoutRecommendation:1800}}},{category:en.PASSWORD,code:Qa.IMPROVE_PASSWORD_HISTORY_POLICY,metadata:{password:{userLockoutRecommendation:5,historyRecommendations:5}}},{category:en.DOMAIN,code:Qa.NO_IP_RESTRICTIONS,metadata:{restrictions:{ipsCount:1,domainsCount:1}}}]}},zu={users:Nu,totalUsersItems:2,totalUsersPages:1,usersPageOffset:0},Ku={users:[Nu[0]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0,queryParams:{_maxInactiveSeconds:7776e3}},qu={users:[Nu[1]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0};Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date;var Ju,Yu=new Uint8Array(16);function Xu(){if(!Ju&&!(Ju="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ju(Yu)}const Qu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var Zu=[],td=0;td<256;++td)Zu.push((td+256).toString(16).substr(1));const ed=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(Zu[t[e+0]]+Zu[t[e+1]]+Zu[t[e+2]]+Zu[t[e+3]]+"-"+Zu[t[e+4]]+Zu[t[e+5]]+"-"+Zu[t[e+6]]+Zu[t[e+7]]+"-"+Zu[t[e+8]]+Zu[t[e+9]]+"-"+Zu[t[e+10]]+Zu[t[e+11]]+Zu[t[e+12]]+Zu[t[e+13]]+Zu[t[e+14]]+Zu[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&Qu.test(t)}(a))throw TypeError("Stringified UUID is invalid");return a},ad=function(t,e,a){var n=(t=t||{}).random||(t.rng||Xu)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){a=a||0;for(var s=0;s<16;++s)e[a+s]=n[s];return e}return ed(n)},nd=["callback"],sd=["callback"],id=["callback","profilePictureUrl"],od=["callback"],rd=["callback"],ld=["callback"],cd=["callback"],ud=["callback"],dd=["callback"],gd=["callback"],pd=["callback"],hd=["callback","samlVendor"],yd=["callback"],vd=["callback"],Sd=["callback","profileImage"],fd=["callback"],md=["callback"],bd=["callback"],Ad=["callback"],wd=["callback"],Td=["callback"],Ed=["callback"],Pd=["callback"],Od=["requestName"],Id=t=>"createdAt"!==t.id,kd={total:20,data:Array.from(Array(5).keys()).map((t=>S({ip:"198.143.51.1",user:"Demo User Name",email:"demo-user@frontegg.com"},(()=>{switch(Math.floor(6*Math.random())){case 0:return{action:"Updated profile",description:"User updated profile details",severity:"Info"};case 1:return{action:"User logged in",severity:"Info",description:"User logged in to the product"};case 2:return{action:"User failed to login",severity:"High",description:"User failed to login with password"};case 3:return{action:"Added user",severity:"Info",description:"Added user david+535@frontegg.com to tenant"};case 4:return{action:"Assigned roles",severity:"Info",description:"Assigned 0 roles for user"};case 5:return{action:"Removed user david+108@frontegg.com from account",severity:"Info",description:"Removed access from the account for user david+108@frontegg.com"}}})(),{json:{key1:"value1",key2:"value2",key3:"value3",key4:"value4"},tenantId:"my-tenant-id",vendorId:"my-vendor-id",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",createdAt:`2022-04-07 10:${50-t}:40.201`})))},_d={properties:[{showInTable:!0,name:"createdAt",displayName:"Time",type:"Timestamp",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!1},{showInTable:!0,name:"email",displayName:"User",type:"Email",filterable:!0,sortable:!0,isPredefined:!0,chosen:!1,selected:!1},{showInTable:!0,name:"action",displayName:"Action",type:"AlphaNumeric",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!0,name:"description",type:"AlphaNumeric",sortable:!1,filterable:!1,displayName:"Description",isPredefined:!0,chosen:!1,selected:!1},{showInTable:!0,name:"ip",displayName:"IP Address",type:"IpAddress",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!1,name:"severity",displayName:"Severity",type:"Severity",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!1,name:"userAgent",displayName:"User Agent",type:"AlphaNumeric",filterable:!0,sortable:!0,isPredefined:!0,chosen:!1,selected:!1},{showInTable:!1,name:"json",type:"Json",sortable:!0,filterable:!0,displayName:"Json Data",showInMoreInfo:"Always",isPredefined:!1}]},Ud=(t,e,a)=>{const n=((t,e,a)=>{const n=iu(t,e,a),s=gu(n,["setAuditLogsState","resetAuditLogsState"]);return s.loadAuditLogs=async e=>{s.setAuditLogsState({loading:!e.silentLoading,error:null});const n=t.auditLogs.auditLogsState,{columns:i}=t.auditLogs.auditsMetadataState;try{var o,r,l,c,u;const t=null!=(o=e.pageSize)?o:n.pageSize,d=null!=(r=e.pageOffset)?r:n.pageOffset,g=null!=(l=e.filter)?l:n.filter,p=null!=(c=e.sort)?c:n.sort;s.setAuditLogsState({pageSize:t,pageOffset:d,filter:g,sort:p}),i||await a.loadAuditsMetadata();const{data:h,total:y}=((t,e)=>{const{data:a}=kd;let n=a.filter((t=>e=>t.filter(Id).every((t=>e[t.id].includes(t.value))))(t));if(e.length){const{id:t,desc:a=!1}=e[0];n=n.sort(((t,e)=>(a,n)=>a[t]>n[t]?e?-1:1:n[t]>a[t]?e?1:-1:0)(t,a))}return{data:n,total:n.length}})(g,p);s.setAuditLogsState({loading:!1,logs:null!=h?h:[],totalPages:+Math.ceil(y/t)}),null==e||null==(u=e.callback)||u.call(e,!0)}catch(t){var d;s.setAuditLogsState({loading:!1,error:Bn(t)}),null==e||null==(d=e.callback)||d.call(e,null,t)}},s})(t,e,a),s=((t,e)=>{const a=lu(t,e),n=gu(a,["setAuditsMetadataState","resetAuditsMetadataState"]);return n.loadAuditsMetadata=async()=>{n.setAuditsMetadataState({loading:!0,error:null});try{const{properties:t}=_d;n.setAuditsMetadataState({columns:t,loading:!1})}catch(t){n.setAuditsMetadataState({error:t,loading:!1})}},n})(t,e);return S({},n,s)},Rd={id:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",externalId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",startDate:"2021-09-20T08:08:51.000Z",status:G.ACTIVE,externallyManaged:!1,cancellation:null,currentPeriodStart:"2021-09-20T08:08:51.000Z",currentPeriodEnd:"2021-10-20T08:08:51.000Z",plan:{slug:"test"}},Cd=[{id:"prod_J60fUEvI7qV1eL",externalId:"prod_J60fUEvI7qV1eL",name:"Premium",description:"",price:{id:"price_1IToe8Ewsu4qiqnndAV76J69",externalId:"price_1IToe8Ewsu4qiqnndAV76J69",currency:"usd",amount:1e4},slug:"premium"},{id:"prod_J60duauCpXfcur",externalId:"prod_J60duauCpXfcur",name:"Free",description:"Totally free plan. Nothing to pay.",price:{id:"price_1ITocfEwsu4qiqnnnBHDx9fQ",externalId:"price_1ITocfEwsu4qiqnnnBHDx9fQ",currency:"usd",amount:0},slug:"free"}],Ld=[{id:"in_1JbhYWEwsu4qiqnnrUh6hsHa",externalId:"in_1JbhYWEwsu4qiqnnrUh6hsHa",subscriptionId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",paymentDate:"2021-09-20T08:08:51.000Z",totalAmount:1e4,currency:"usd",paid:!0,receiptNumber:""},{id:"in_1JbhYWEwsu4qiqnnrUh6hsHa",externalId:"in_1JbhYWEwsu4qiqnnrUh6hsHa",subscriptionId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",paymentDate:"2021-08-20T08:08:51.000Z",totalAmount:1e4,currency:"usd",paid:!0,receiptNumber:""}],Dd=[{id:"id",externalId:"externalId",type:j.CARD,isDefault:!0,last4:"4242",expMonth:11,expYear:25,brand:"visa",billingDetails:{name:"Dummy",email:"dummy@email.com"}}],Nd={allowPlanDowngrade:!0,allowPlanCancellation:!0},Md=(t,e,a)=>{const n=((t,e)=>{const a=Ec(t,e),n=gu(a,["setPaymentConfigState","resetPaymentConfigState"]);return n.loadPaymentConfiguration=async()=>{n.setPaymentConfigState({loading:!0}),await Rn(500),n.setPaymentConfigState({loading:!1,fetching:!1,config:{paymentProvider:Ac.STRIPE,apiKey:""}})},n})(t,e),[s,i]=((t,e,a)=>{const n=((t,e,a)=>{const n=_c(t,e,a),s=gu(n,["setBillingInformationState","resetBillingInformationState"]);return s.loadBillingInformation=async()=>{var t,e;s.setBillingInformationState({loading:!0}),await Rn(500),s.setBillingInformationState({loading:!1,fetching:!1,summary:{subscriptionId:Rd.id,paymentMethodId:"mockPaymentMethodId",tenantConfigurationId:"mockTenantConfigurationId",providerType:V.Stripe,externallyManaged:!1,currentPlanId:Cd[0].id,defaultPlanId:Cd[0].id},plan:S({},Cd[0],{price:null==(t=Cd[0].price)?void 0:t.amount,currency:null==(e=Cd[0].price)?void 0:e.currency,recurringInterval:"month"})})},s})(t,e,a),s=((t,e)=>{const a=Nc(t,e),n=gu(a,["setBillingPaymentMethodState","resetBillingPaymentMethodState"]);return n.loadPaymentMethod=async()=>{n.setBillingPaymentMethodState({loading:!0}),await Rn(500),n.setBillingPaymentMethodState({paymentMethod:Dd[0],loading:!1,fetching:!1})},n})(t,e),i=((t,e)=>{const a=Cc(t,e),n=gu(a,["setBillingInvoiceState","resetBillingInvoiceState"]);return n.loadBillingInvoices=async()=>{n.setBillingInvoiceState({loading:!0}),await Rn(500),n.setBillingInvoiceState({loading:!1,fetching:!1,invoices:Ld.map((t=>S({},t,{selectedPlan:"Premium",paymentDate:new Date(Date.parse(t.paymentDate)),totalAmount:+((t.totalAmount||0)/100).toFixed(2)})))})},n.loadInvoices=n.loadBillingInvoices,n})(t,e),o=((t,e,a)=>{const n=xc(t,e,a),s=gu(n,["setBillingSubscriptionState","resetBillingSubscriptionState","setCancellationLoading","setCancellationError","setRenewalLoading","setRenewalError"]);return s.loadSubscription=async()=>{s.setBillingSubscriptionState({loading:!0}),await Rn(500),s.setBillingSubscriptionState({subscription:Rd,fetching:!1,loading:!1,error:null})},s})(t,e,a);return[S({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=((t,e)=>{const a=Bc(t,e),n=gu(a,["setPlansState","resetPlansState"]);return n.loadPlans=async()=>{n.setPlansState({loading:!0}),await Rn(500),n.setPlansState({fetching:!1,loading:!1,plans:Cd.map((t=>{var e,a;return S({},t,{price:(null==(e=t.price)?void 0:e.amount)||0,currency:(null==(a=t.price)?void 0:a.currency)||"usd",recurringInterval:"month"})}))})},n})(t,e),r=((t,e,a)=>{const n=Hc(t,e,a);return gu(n,["setCheckoutState","resetCheckoutState","errorCheckout","resetCheckout"])})(t,e,a),l=((t,e)=>{const a=qc(t,e);return gu(a,[])})(t,e),c=((t,e)=>{const a=Xc(t,e),n=gu(a,["setVendorPublicConfigState","resetVendorPublicConfigState","setVendorPublicConfigError","setVendorPublicConfigLoading"]);return n.loadVendorPublicConfiguration=async()=>{n.setVendorPublicConfigLoading(!0),await Rn(),n.setVendorPublicConfigState({fetching:!1,loading:!1,vendorPublicConfig:Nd})},n})(t,e);return[S({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},Fd=(t,e,a,n)=>{const{authActions:s,authStateActions:i}=((t,e,a,n)=>{const s=((t,e)=>{const a=Vn(t,e);return gu(a,["setAcceptInvitationState","resetAcceptInvitationState"])})(t,e),i=((t,e,a)=>{const n=Kn(t,e,a),s=gu(n,["setAccountSettingsState","resetAccountSettingsState"]);return s.saveAccountSettings=async e=>{var a;s.setAccountSettingsState({loading:!0}),await Rn();const n=t.auth.accountSettingsState,{address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u}=n,d=S({address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u},e);s.setAccountSettingsState(S({},d,{loading:!1})),null==(a=e.callback)||a.call(e,d)},s.loadAccountSettings=async t=>{s.setAccountSettingsState({loading:!(null!=t&&t.silentLoading),error:null}),await Rn(),s.setAccountSettingsState(S({address:"Tel-aviv",timezone:"Asia/Jerusalem",dateFormat:"DD/MM/YYYY",timeFormat:"HH:mm",currency:"USD",loading:!1},t))},s})(t,e,a),o=((t,e)=>{const a=js(t,e);return gu(a,["setUnlockAccountState","resetUnlockAccountState"])})(t,e),r=((t,e,a)=>{const n=xs(t,e,a);return gu(n,["setActivateState","resetActivateState","setActivateStrategyState"])})(t,e,a),l=((t,e,a)=>{const n=Zo(t,e,a);return gu(n,["setAllAccountsLoader","setAllAccountsError","setAllAccountsState","setSelectedAccountState","resetAllAccountsState","clearSelectedAccount"])})(t,e,a),c=tr(t),u=((t,e)=>{const a=Hs(t,e),n=gu(a,["setApiTokensState","resetApiTokensState","setApiTokensLoader","setApiTokensError"]);return n.addTenantApiToken=async e=>{const{description:a,roleIds:s,callback:i}=e;n.setApiTokensLoader({key:Ws.ADD_API_TOKEN,value:!0});const{apiTokensDataTenant:o}=t.auth.apiTokensState,r=S({},hu,{description:a,roleIds:s,clientId:`CLIENT_ID_${ad()}`});n.setApiTokensState({showAddTokenDialog:!1}),await Rn(200),n.setApiTokensState({apiTokensDataTenant:[...o,r],successDialog:{open:!0,secret:r.secret,clientId:r.clientId}}),await Rn(200),n.setApiTokensLoader({key:Ws.ADD_API_TOKEN,value:!1}),null==i||i(null)},n.deleteTenantApiToken=async t=>{n.setApiTokensLoader({key:Ws.DELETE_API_TOKEN,value:!0}),await Rn(200);const e=[hu];n.setApiTokensState({apiTokensDataTenant:e.filter((e=>e.clientId!==t)),deleteTokenDialog:{open:!1,clientId:t}}),n.setApiTokensLoader({key:Ws.DELETE_API_TOKEN,value:!1})},n.loadApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!0});const a=[pu],s=[hu];n.setApiTokensState({apiTokensDataUser:a,apiTokensDataTenant:s}),await Rn(200),n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n.loadUserApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!0});const a=[pu];n.setApiTokensState({apiTokensDataUser:a}),await Rn(200),n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n.loadTenantApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!0});const a=[hu];n.setApiTokensState({apiTokensDataTenant:a}),await Rn(200),n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n})(t,e),d=((t,e,a)=>{const n=Js(t,e,a);return gu(n,["setApplicationsState","resetApplicationsState"])})(t,e,a),g=((t,e,a)=>{const n=Zs(t,e,a),s=gu(n,["setCustomLoginState","resetCustomLoginState"]);return s.loadTenantMetadata=async()=>{s.setCustomLoginState({loading:!0}),await Rn(),s.setCustomLoginState({loading:!1})},s.updateTenantMetadata=async t=>{const{callback:e}=t;s.setCustomLoginState({loading:!0,error:null}),await Rn(),s.setCustomLoginState({loading:!1,error:null}),null==e||e(!0)},s})(t,e,a),p=((t,e)=>{const a=ic(t,e);return gu(a,["setEntitlements","handleFetchedEntitlements"])})(t,e),h=((t,e)=>{const a=si(t,e),n=gu(a,["setForgotPasswordState","resetForgotPasswordState"]);return n.loadPasswordConfig=async t=>{n.setForgotPasswordState({loading:!0});try{n.setForgotPasswordState({loading:!1,passwordConfig:{allowPassphrases:!0,maxLength:128,minLength:6,minPhraseLength:6,minOptionalTestsToPass:1}})}catch(t){n.setForgotPasswordState({loading:!1,error:Bn(t)})}},n})(t,e),y=(t=>{const e=li(t),a=gu(e,["setStep"]);return a.setStep(ii.success),a})(t),v=((t,e)=>{const a=hi(t,e),n=gu(a,["setGroupsState","resetUsersGroupsState","setUsersGroupsLoader","setUsersGroupsError"]);return n.loadGroups=async()=>{const t=di.GET_GROUPS;n.setUsersGroupsLoader({key:t,value:!0});const e=Vu;n.setGroupsState({groups:e}),n.setUsersGroupsLoader({key:t,value:!1})},n.createGroup=async e=>{var a;const s=di.CREATE_GROUP,{groups:i}=t.auth.groupsState;n.setUsersGroupsLoader({key:s,value:!0}),await Rn(500),n.setGroupsState({groups:[S({},e,{id:`${e.name}ID`,managedBy:za.FRONTEGG}),...null!=i?i:[]]}),null==e||null==(a=e.callback)||a.call(e,!0),n.setUsersGroupsLoader({key:s,value:!1})},n.updateGroup=async e=>{var a,s,i,o,r;const l=di.UPDATE_GROUP,c=t.auth.groupsState;n.setUsersGroupsLoader({key:l,value:!0}),await Rn(500),n.setGroupsState({groups:null==c||null==(a=c.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?S({},e,{id:e.groupId,name:null!=(a=null==e?void 0:e.name)?a:"",managedBy:za.FRONTEGG}):t})),selectedGroup:S({},null==c?void 0:c.selectedGroup,{name:null!=(s=null==e?void 0:e.name)?s:"",color:null!=(i=null==e?void 0:e.color)?i:"",description:null!=(o=null==e?void 0:e.description)?o:""})}),null==e||null==(r=e.callback)||r.call(e,!0),n.setUsersGroupsLoader({key:l,value:!1})},n.deleteGroup=async e=>{var a,s;const i=di.DELETE_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Rn(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.filter((t=>t.id!==e.groupId))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.addRolesToGroup=async e=>{var a,s;const i=di.ADD_ROLES_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Rn(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?S({},t,{roles:[...null!=(a=null==t?void 0:t.roles)?a:[],...e.roleIds.map((t=>({id:t,name:t})))]}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.deleteRolesFromGroup=async e=>{var a,s;const i=di.DELETE_ROLES_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Rn(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?S({},t,{roles:null==t||null==(a=t.roles)?void 0:a.filter((t=>!e.roleIds.includes(t.id)))}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.addUsersToGroup=async e=>{var a,s;const i=di.ADD_USERS_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Rn(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?S({},t,{users:[...null!=(a=null==t?void 0:t.users)?a:[],...e.userIds.map((t=>({id:t,name:t})))]}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.deleteUsersFromGroup=async e=>{var a,s;const i=di.DELETE_USERS_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Rn(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?S({},t,{users:null==t||null==(a=t.users)?void 0:a.filter((t=>!e.userIds.includes(t.id)))}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.getGroupConfiguration=async()=>{const e=di.GET_GROUP_CONFIGURATION,{groupsConfiguration:a}=t.auth.groupsState;n.setUsersGroupsLoader({key:e,value:!0}),a&&n.setGroupsState({groupsConfiguration:S({},a)}),n.setUsersGroupsLoader({key:e,value:!1})},n.updateGroupConfiguration=async e=>{const a=di.UPDATE_GROUP_CONFIGURATION,{groupsConfiguration:s}=t.auth.groupsState;n.setUsersGroupsLoader({key:a,value:!0}),s&&n.setGroupsState({groupsConfiguration:S({},s,e)}),n.setUsersGroupsLoader({key:a,value:!1})},n})(t,e),m=Si(t),b=((t,e,a)=>{const n=wi(t,e,a);return gu(n,["setImpersonateState","resetImpersonateState"])})(t,e,a),A=((t,e,a)=>{const n=a,s=Uo(t,e,n),i=gu(s,["setLoginState","resetLoginState","afterAuthNavigation"]);return i.requestAuthorize=async t=>{t&&n.setAuthState({isLoading:!0});const e=Su;await n.loadTenants(),n.setAuthState({user:e,isAuthenticated:!0,isLoading:!1})},i.getUserIP=async t=>{const{callback:e}=t;try{const{ip:t}=Gu[0];await n.setAuthState({userIpData:{ip:t},userIp:t}),null==e||e(!0,t)}catch(t){null==e||e(!1,t)}},i})(t,e,a),w=((t,e,a)=>{const n=a,s=jo(t,e,n),i=gu(s,["setMfaState","resetMfaState"]);return i.enrollMfa=async()=>{i.setMfaState({saving:!0}),i.setMfaState({saving:!1,error:void 0,qrCode:"test"})},i.verifyMfa=async e=>{const{callback:a}=e,{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=(f(e,nd),t.auth.mfaState);i.setMfaState({saving:!0}),await Rn();const o={token:"token",recoveryCode:"recoveryCode"},r={step:ns.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:S({},s,{authenticators:[{id:"authenticator-id"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(S({},Su,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i.disableMfa=async e=>{var a;const{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=t.auth.mfaState;i.setMfaState({saving:!0}),await Rn(),i.setMfaState({saving:!1,error:void 0,mfaDevices:S({},s,{authenticators:[]})}),n.setUser(S({},Su)),null==(a=e.callback)||a.call(e,!0)},i.verifyMfaAfterForce=async t=>{const{callback:e}=t,a=f(t,sd);i.setMfaState({loading:!0}),await Rn();const s=S({},a,{recoveryCode:"recoveryCode"}),o={step:ns.recoveryCode,loading:!1,error:void 0,saving:!1};null!=s&&s.recoveryCode&&(o.recoveryCode=s.recoveryCode),i.setMfaState(o),await Rn(),n.setUser(S({},Su,{mfaEnrolled:!0})),null==e||e(o.recoveryCode)},i.preDisableMfaSms=async t=>{i.setMfaState({saving:!0});try{var e;i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(e=t.callback)||e.call(t,!0)}catch(e){var a;i.setMfaState({saving:!1,error:Bn(e)}),null==(a=t.callback)||a.call(t,!1,e)}},i.disableMfaSms=async e=>{var a;const{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=t.auth.mfaState;i.setMfaState({saving:!0}),await Rn(),i.setMfaState({loading:!1,error:void 0,mfaDevices:S({},s,{phones:[]})}),n.setUser(S({},Su)),null==(a=e.callback)||a.call(e,!0)},i.preEnrollMfaSms=async t=>{var e;i.setMfaState({saving:!0}),await Rn(),i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(e=t.callback)||e.call(t,!0)},i.enrollMfaSms=async e=>{const{callback:a}=e,{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=t.auth.mfaState;i.setMfaState({saving:!0}),await Rn();const o={token:"token",recoveryCode:"recoveryCode"},r={step:ns.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:S({},s,{phones:[{id:"phone-id",phoneNumber:"+972504589346"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(S({},Su,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i})(t,e,a),T=((t,e,a)=>{const n=nr(t,e,a);return gu(n,["setPasskeysState","resetPasskeysState"])})(t,e,a),E=((t,e,a)=>{const n=rr(t,e,a),s=gu(n,["setProfileState","resetProfileState"]);return s.loadProfile=async()=>{s.setProfileState({loading:!0}),await Rn(),a.setUser(S({},Su,vu)),s.setProfileState({loading:!1,profile:vu})},s.saveProfile=async t=>{const{callback:e,profilePictureUrl:n}=t,i=f(t,id);s.setProfileState({saving:!0,error:null});const o=fu;let r=o.profile.profilePictureUrl;n!==o.profile.profilePictureUrl&&n&&(n||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)&&(r=n);const l=S({},o.profile,i,{profilePictureUrl:r}),c=Su;await Rn(),a.setUser(S({},c,l)),s.setProfileState({loading:!1,error:null,saving:!1,profile:l}),null==e||e(l)},s.changePassword=async t=>{var e;s.setProfileState({loading:!0}),await Rn(),s.setProfileState({loading:!1,error:void 0}),null==(e=t.callback)||e.call(t,!0)},s.updateEmail=async t=>{var e;s.setProfileState({saving:!0,error:null,loading:!0}),await Rn(),s.setProfileState({saving:!1,error:null,loading:!1}),null==(e=t.callback)||e.call(t,!0)},s.verifyEmail=async t=>{var e;s.setProfileState({saving:!0,error:null,loading:!0}),await Rn(),s.setProfileState({saving:!1,error:null,loading:!1}),null==(e=t.callback)||e.call(t,!0)},s})(t,e,a),P=((t,e)=>{const a=gr(t,e);return gu(a,["setProvisioningState","resetProvisioningState"])})(t,e),O=((t,e,a)=>{const n=mr(t,e,a);return gu(n,["setResetPhoneNumberState","resetResetPhoneNumberState"])})(t,e,a),I=((t,e,a)=>{const n=Mr(t,e,a),s=gu(n,["setRestrictionsState","setIpRestrictionsState","setEmailDomainRestrictionsState"]);return s.loadIpRestrictions=async()=>{s.setIpRestrictionsState({loading:!0,error:null}),s.setIpRestrictionsState({data:{restrictions:Gu.filter((t=>t.strategy===$u.strategy)),config:$u},totalPages:1,pagination:{_filter:Jt.ALLOW,_limit:50,_offset:0},loading:!1})},s.loadEmailDomainRestrictions=async()=>{s.setEmailDomainRestrictionsState({loading:!0,error:null}),s.setEmailDomainRestrictionsState({loading:!1,data:{restrictions:[{domain:"mock.com",id:"1",type:Jt.ALLOW}],config:{active:!0,listType:Jt.ALLOW,blockPublicDomains:!1}}})},s.saveIpRestriction=async e=>{var a,n,i;const{callback:o}=e,r=f(e,od);s.setIpRestrictionsState({saving:!0,error:null});const l=t.auth.restrictionsState.ipRestrictions,c=l.data.restrictions.filter((t=>t.ip!==r.ip));s.setIpRestrictionsState({data:{config:null!=(a=null==(n=l.data)?void 0:n.config)?a:{isActive:!1,strategy:Jt.ALLOW},restrictions:[...c,S({},r,{createdAt:new Date,updatedAt:new Date,id:ad(),isActive:null==(i=r.isActive)||i,strategy:l.data.config.strategy})]},totalPages:1,pagination:{_filter:Jt.ALLOW,_limit:50,_offset:0},saving:!1}),null==o||o(!0)},s.saveIpRestrictionsConfig=async e=>{var a,n,i;const{callback:o}=e,r=f(e,rd),l=t.auth.restrictionsState.ipRestrictions;s.setIpRestrictionsState({saving:!0,error:null}),s.setIpRestrictionsState({data:{config:S({},null==(a=l.data)?void 0:a.config,r),restrictions:null!=(n=null==(i=l.data)?void 0:i.restrictions)?n:[]},pagination:{_filter:Jt.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1}),s.setIpRestrictionsState({saving:!1,error:null}),null==o||o(!0)},s.deleteIpRestriction=async e=>{var a;const{callback:n,id:i}=e;s.setIpRestrictionsState({saving:!0,error:null});const o=t.auth.restrictionsState.ipRestrictions;s.setIpRestrictionsState({data:{config:(null==(a=o.data)?void 0:a.config)||{isActive:!1,strategy:Jt.ALLOW},restrictions:o.data.restrictions.filter((t=>t.id!==i))},pagination:{_filter:Jt.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1,error:null}),null==n||n(!0)},s.checkIfUserIpValid=async()=>{s.setIpRestrictionsState({loading:!0,error:null});try{const e=t.auth.restrictionsState.ipRestrictions,a=Gu[0].ip,n=!!e.data.restrictions.find((t=>t.isActive&&t.ip===a));s.setIpRestrictionsState({userIpValid:n,loading:!1})}catch(t){s.setIpRestrictionsState({error:Bn(t),loading:!1})}},s.saveEmailDomainRestriction=async e=>{var a,n;const{callback:i}=e,o=f(e,ld),r=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await Rn(),null==i||i(!0),s.setEmailDomainRestrictionsState({data:{config:(null==(a=r.data)?void 0:a.config)||{active:!1,blockPublicDomains:!1,listType:o.type},restrictions:[...(null==(n=r.data)?void 0:n.restrictions)||[],S({},o,{id:Date.now().toString()})]},saving:!1})},s.saveEmailDomainRestrictionsConfig=async e=>{var a;const{callback:n}=e,i=f(e,cd),o=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await Rn(),null==n||n(!0),s.setEmailDomainRestrictionsState({data:{config:{active:i.active,blockPublicDomains:i.blockPublicDomains||!1,listType:i.type||Jt.ALLOW},restrictions:[...(null==(a=o.data)?void 0:a.restrictions)||[]]},saving:!1})},s.deleteEmailDomainRestriction=async e=>{var a,n;const{id:i}=e,o=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await Rn(),s.setEmailDomainRestrictionsState({data:{config:(null==(a=o.data)?void 0:a.config)||{active:!1,blockPublicDomains:!1,listType:Jt.ALLOW},restrictions:((null==(n=o.data)?void 0:n.restrictions)||[]).filter((t=>t.id===i))},saving:!1})},s})(t,e,a),k=((t,e)=>{const a=_r(t,e),n=gu(a,["setRolesState","setRolesStateError","setRolesStateLoader","resetRolesState"]);return n.loadRolesAndPermissions=async t=>{var e;const a=wr.LOAD_ROLES;n.setRolesStateLoader({key:a,value:!(null!=(e=null==t?void 0:t.silentLoading)&&e)});try{n.setRolesState({roles:yu})}catch(t){n.setRolesStateError({key:a,value:Bn(t)})}finally{n.setRolesStateLoader({key:a,value:!1})}},n})(t,e),_=((t,e,a)=>{const n=jr(t,e,a),s=gu(n,["setSecurityCenterState","setSecurityCenterStateError","setSecurityCenterStateLoader","resetSecurityCenterState"]);return s.loadRecommendations=async()=>{const t=$r.RECOMMENDATIONS;s.setSecurityCenterStateLoader({key:t,value:!0}),await Rn(),s.setSecurityCenterState({recommendations:Wu.recommendations.items,score:Wu.scoring.score}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInsights=async()=>{const t=$r.INSIGHTS;s.setSecurityCenterStateLoader({key:t,value:!0}),await Rn(),s.setSecurityCenterState({insights:Hu.insights.items}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadBreachedPasswordUsers=async()=>{const t=$r.BREACHED_PASSWORD_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await Rn(),s.setSecurityCenterState({breachedPasswordUsersTable:zu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadUnenrolledMfaUsers=async()=>{const t=$r.UNENROLLED_MFA_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await Rn(),s.setSecurityCenterState({unenrolledMfaUsersTable:qu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInactiveUsers=async()=>{const t=$r.INACTIVE_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await Rn(),s.setSecurityCenterState({inactiveUsersTable:Ku}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.sendResetBreachedPasswordEmail=async t=>{const{callback:e}=t,a=$r.SEND_BREACHED_PASSWORD_EMAIL;s.setSecurityCenterStateLoader({key:a,value:!0}),await Rn(),null==e||e(!0),s.setSecurityCenterStateLoader({key:a,value:!1})},s})(t,e,a),U=((t,e,a)=>{const n=Jr(t,e,a),s=gu(n,["setSecurityPolicyState","setSecurityPolicyGlobalState","setSecurityPolicyPublicState","setSecurityPolicyMfaState","setSecurityPolicyVendorMfaState","setSecurityPolicyLockoutState","setSecurityPolicyVendorLockoutState","setSecurityPolicyCaptchaState","setSecurityPolicyPasswordHistoryState","setSecurityPolicyVendorPasswordHistoryState","resetSecurityPolicyState","setSecurityPolicyPasswordState","setSecurityPolicyAuthStrategyPublicState"]);return s.loadSecurityPolicy=async()=>{s.setSecurityPolicyGlobalState({loading:!0,error:null}),await Promise.all([s.loadSecurityPolicyMfa(),s.loadSecurityPolicyVendorMfa(),s.loadSecurityPolicyLockout(),s.loadSecurityPolicyVendorLockout(),s.loadSecurityPolicyPasswordHistory(),s.loadSecurityPolicyVendorPasswordHistory(),s.loadSecurityPolicyCaptcha()]),await Rn(),s.setSecurityPolicyGlobalState({policy:mu,loading:!1})},s.loadPublicSecurityPolicy=async()=>{s.setSecurityPolicyPublicState({loading:!0,error:null});try{s.setSecurityPolicyPublicState({policy:bu,loading:!1})}catch(t){s.setSecurityPolicyPublicState({error:Bn(t),loading:!1})}},s.saveSecurityPolicyMfa=async t=>{var e;const{callback:a}=t,n=f(t,ud);s.setSecurityPolicyMfaState({saving:!0,error:null});const i=S({},wu,{id:null!=(e=n.id)?e:wu.id,enforceMFAType:n.enforceMFAType});await Rn(),s.setSecurityPolicyMfaState({policy:i,saving:!1}),null==a||a(i)},s.loadSecurityPolicyMfa=async()=>{s.setSecurityPolicyMfaState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyMfaState({policy:Au,loading:!1})},s.loadSecurityPolicyVendorMfa=async()=>{s.setSecurityPolicyVendorMfaState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyVendorMfaState({policy:Au,loading:!1})},s.saveSecurityPolicyLockout=async t=>{const{callback:e}=t,a=f(t,dd);s.setSecurityPolicyLockoutState({saving:!0,error:null}),await Rn();const n=S({},wu,a,{id:a.id?a.id:wu.id});null==e||e(n),s.setSecurityPolicyLockoutState({policy:n,saving:!1})},s.loadSecurityPolicyLockout=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyLockoutState({policy:wu,loading:!1})},s.loadSecurityPolicyVendorLockout=async()=>{s.setSecurityPolicyVendorLockoutState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyVendorLockoutState({policy:wu,loading:!1})},s.loadSecurityPolicyCaptcha=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyLockoutState({policy:wu,loading:!1})},s.saveSecurityPolicyPasswordHistory=async t=>{const{callback:e}=t,a=f(t,gd);s.setSecurityPolicyPasswordHistoryState({saving:!0,error:null}),await Rn();const n=S({},Tu,a,{id:a.id?a.id:Tu.id});null==e||e(n),s.setSecurityPolicyPasswordHistoryState({policy:n,saving:!1})},s.loadSecurityPolicyPasswordHistory=async()=>{s.setSecurityPolicyPasswordHistoryState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyPasswordHistoryState({policy:Tu,loading:!1})},s.loadSecurityPolicyVendorPasswordHistory=async()=>{s.setSecurityPolicyVendorPasswordHistoryState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyVendorPasswordHistoryState({policy:Tu,loading:!1})},s})(t,e,a),R=((t,e)=>{const a=al(t,e),n=gu(a,["setSessionsState","resetSessionsState"]);return n.loadUserSessions=async()=>{n.setSessionsState({loading:!0,error:null}),n.setSessionsState({sessions:xu,loading:!1})},n.deleteUserSession=async e=>{const{id:a}=e;n.setSessionsState({loading:!0,error:null});const s=t.auth.sessionsState.sessions.filter((t=>t.id!==a));n.setSessionsState({sessions:s,loading:!1})},n.deleteAllUserSessions=async()=>{n.setSessionsState({loading:!0,error:null});const t=xu.filter((t=>t.current));n.setSessionsState({sessions:t,loading:!1})},n})(t,e),C=((t,e,a)=>{const n=Zr(t,e,a),s=gu(n,["setSessionsPolicyState","resetSessionsPolicyState"]);return s.loadSessionsPolicy=async()=>{s.setSessionsPolicyState({loading:!0,error:null});const e=t.auth.sessionsPolicyState;s.setSessionsPolicyState(S({},e,{loading:!1}))},s.createOrUpdateSessionsPolicy=async t=>{const{callback:e}=t,a=f(t,pd);s.setSessionsPolicyState({loading:!0,error:null}),null==e||e(!0),s.setSessionsPolicyState({configurations:a,loading:!1})},s})(t,e,a),L=((t,e,a)=>{const n=ll(t,e,a);return gu(n,["setSignUpState","resetSignUpState","resetSignUpStateSoft"])})(t,e,a),D=((t,e)=>{const a=Sl(t,e);return gu(a,["setSmsState","resetSmsState"])})(t,e),N=((t,e,a)=>{const n=wl(t,e,a);return gu(n,["setSocialLoginsState","resetSocialLoginsState","setSocialLoginError"])})(t,e,a),M=((t,e,a)=>{const n=Ul(t,e,a),s=gu(n,["setSSOState","resetSSOState"]);return s.loadSSOConfigurations=async()=>{s.setSSOState({loading:!0}),await Rn(),s.setSSOState({samlConfiguration:Eu,loading:!1,firstLoad:!1})},s.saveSSOConfigurations=async t=>{var e,a;const{callback:n,samlVendor:i}=t,o=f(t,hd),r=Iu.samlConfiguration,l=S({},r,o);let c="saving";if((null==l?void 0:l.enabled)!==r.enabled&&(c="loading"),null==l||!l.domain)return void s.setSSOState({samlConfiguration:S({},r,l)});s.setSSOState({error:void 0,[c]:!0}),await Rn(),l.acsUrl=null==Pu||null==(e=Pu.configuration)?void 0:e.acsUrl,l.spEntityId=null==Pu||null==(a=Pu.configuration)?void 0:a.spEntityId;const u=Mn(l,["validated","generatedVerification","createdAt","updatedAt"]);(null==r?void 0:r.domain)!==(null==u?void 0:u.domain)&&(u.ssoEndpoint="",u.publicCertificate="",u.signRequest=!1),u.type=null==i?void 0:i.toLowerCase(),await Rn(),s.setSSOState({samlConfiguration:u,error:void 0,[c]:!1}),null==n||n(!0)},s.saveSSOConfigurationsFile=async e=>{const a="saving";s.setSSOState({error:void 0,[a]:!0});const n=S({},t.auth.ssoState.samlConfiguration,{enabled:!0},e[0]);s.setSSOState({samlConfiguration:n,error:void 0,[a]:!1})},s.validateSSODomain=async t=>{const{callback:e}=null!=t?t:{},a=Iu.samlConfiguration;s.setSSOState({error:void 0,saving:!0}),await Rn(),s.setSSOState({samlConfiguration:S({},a,{validated:!0}),error:void 0,saving:!1}),null==e||e(!0)},s.loadSSOAuthorizationRoles=async()=>{await Rn(),s.setSSOState({authorizationRoles:["1","2","3"],error:void 0})},s.updateSSOAuthorizationRoles=async t=>{const{callback:e,authorizationRoles:a}=t;s.setSSOState({error:void 0,saving:!0}),await Rn(),s.setSSOState({authorizationRoles:a,error:void 0,saving:!1}),null==e||e(!0)},s})(t,e,a),F=((t,e,a)=>{const n=Ll(t,e,a);return gu(n,["setStepUpState","resetStepUpState"])})(t,e,a),x=((t,e,a)=>{const n=Jl(t,e,a),s=gu(n,["setTeamState","resetTeamState","setTeamLoader","setTeamError","openAddUserDialog","closeAddUserDialog","openDeleteUserDialog","closeDeleteUserDialog"]);return s.loadUsersV2=async e=>{var a,n,i,o;const{silentLoading:r,callback:l}=e,c=t.auth.teamState,u=null!=(a=e.pageSize)?a:c.pageSize,d=null!=(n=e.pageOffset)?n:c.pageOffset,g=null!=(i=e.filter)?i:c.filterV2,p=null!=(o=e.sort)?o:c.sortV2;s.setTeamLoader({key:Us.USERS,value:!r}),s.setTeamState({pageSize:u,pageOffset:d,filterV2:g,sortV2:p}),await Rn(),s.setTeamState({users:Du,totalPages:2,totalItems:10,roles:Ou,permissions:ku}),s.setTeamLoader({key:Us.USERS,value:!1}),null==l||l(Du)},s.loadAllSubTenantsUsers=async e=>{var a,n,i,o,r;const{silentLoading:l,callback:c}=e,u=t.auth.teamState,d=null!=(a=e._limit)?a:u.allUsersQueryParams._limit,g=null!=(n=e._offset)?n:u.allUsersQueryParams._offset,p=null!=(i=e._filter)?i:u.allUsersQueryParams._filter,h=null!=(o=e._sortBy)?o:u.allUsersQueryParams._sortBy,y=null!=(r=e._order)?r:u.allUsersQueryParams._order;s.setTeamLoader({key:Us.USERS,value:!l}),s.setTeamState({allUsersQueryParams:{_limit:d,_offset:g,_filter:p,_sortBy:h,_order:y}}),await Rn(),s.setTeamState({allUsers:Mu,totalPages:2,totalItems:10,roles:Ou,permissions:ku}),s.setTeamLoader({key:Us.USERS,value:!1}),null==c||c(Mu)},s.loadRoles=async t=>{var e;s.setTeamLoader({key:Us.ROLES_AND_PERMISSIONS,value:!0}),await Rn(),s.setTeamState({roles:Ou,permissions:ku}),s.setTeamLoader({key:Us.ROLES_AND_PERMISSIONS,value:!0}),null==t||null==(e=t.callback)||e.call(t,{roles:Ou,permissions:ku})},s.addUser=async e=>{const{callback:a}=e,n=f(e,yd),i=t.auth.teamState;s.setTeamState({addUserDialogState:S({},i.addUserDialogState,{loading:!0})}),await Rn();const o=new Date,r=S({},Ru,{groups:[]},n,{id:`${ad()}`,temporaryExpirationDate:n.expirationInSeconds?new Date(o.setSeconds(o.getSeconds()+n.expirationInSeconds)):void 0});null==a||a(r),s.setTeamState({users:[r,...i.users],addUserDialogState:{open:!1,loading:!1}})},s.addUserToSubTenants=async e=>{const{callback:a}=e,n=f(e,vd),i=t.auth.teamState;s.setTeamState({addUserDialogState:S({},i.addUserDialogState,{loading:!0})}),await Rn();const o=S({},Ru,n,{id:`${ad()}`});s.setTeamState({users:[o,...i.users],addUserDialogState:{open:!1,loading:!1}}),null==a||a(null)},s.updateUser=async e=>{var a;const{callback:n}=e,i=f(e,Sd),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));s.setTeamLoader({key:Us.UPDATE_USER,value:o||""}),s.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!0})}),s.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!0}),users:r.users.map((t=>t.id===i.id?S({},t,i):t))}),l.roleIds.length>0&&0===(null==(a=i.roleIds)?void 0:a.length)&&(i.roleIds=[""]),await Rn();const c=S({},l,i);null==n||n(c),s.setTeamState({users:r.users.map((t=>t.id===c.id?S({},t,c,{createdAt:t.createdAt,customData:t.customData,lastLogin:t.lastLogin}):t))}),s.setTeamLoader({key:Us.UPDATE_USER,value:!1})},s.deleteUser=async e=>{const{callback:a}=e,n=f(e,fd),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:S({},i.deleteUserDialogState,{loading:!0})}),await Rn(),null==a||a(!0),s.setTeamState({users:i.users.filter((t=>t.id!==n.userId)),deleteUserDialogState:{open:!1,loading:!1}})},s.updateUserExpirationTime=async e=>{const{callback:a}=e,n=f(e,md),i=t.auth.teamState;s.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!0});const o=new Date;s.setTeamState({users:i.users.map((t=>t.id===n.userId?S({},t,{temporaryExpirationDate:n.expirationInSeconds?new Date(o.setSeconds(o.getSeconds()+n.expirationInSeconds)):void 0}):t))}),await Rn(),null==a||a(!0),s.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.setUserAsPermanent=async e=>{const{callback:a}=e,n=f(e,bd),i=t.auth.teamState;s.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!0}),s.setTeamState({users:i.users.map((t=>t.id===n.userId?S({},t,{temporaryExpirationDate:void 0}):t))}),await Rn(),null==a||a(!0),s.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.deleteUserFromSubTenants=async e=>{const{callback:a}=e,n=f(e,Ad),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:S({},i.deleteUserDialogState,{loading:!0})}),await Rn(),null==a||a(!0),s.setTeamState({allUsers:i.allUsers.filter((t=>t.id!==n.userId)),deleteUserDialogState:{open:!1,loading:!1}})},s.resendActivationLink=async t=>{const{callback:e}=t,a=f(t,wd);s.setTeamLoader({key:Us.RESEND_ACTIVATE_LINK,value:a.userId}),await Rn(),null==e||e(!0),s.setTeamLoader({key:Us.RESEND_ACTIVATE_LINK,value:!1})},s.resendInvitationLink=async t=>{const{callback:e}=t,a=f(t,Td);s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:a.email}),await Rn(),null==e||e(!0),s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationEmail=async t=>{const{callback:e}=t,a=f(t,Ed);s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:a.email}),await Rn(),null==e||e(!0),s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationLinkToAllSubTenants=async t=>{const{callback:e}=t,a=f(t,Pd);s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:a.email}),await Rn(),null==e||e(!0),s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:!1})},s})(t,e,a),$=((t,e,a)=>{const n=Ql(t,e,a),s=gu(n,["setTenantsState","resetTenantsState"]);return s.loadTenants=async()=>{s.setTenantsState({loading:!0}),s.setTenantsState({tenants:Fu,activeTenant:Fu[0],loading:!1})},s})(t,e,a),G=ec(t,e),j=((t,e)=>{const a=sc(t,e);return gu(a,["loadUserEmailPolicyState"])})(t,e),B={acceptInvitationActions:s,accountSettingsActions:i,unlockAccountActions:o,activateAccountActions:r,allAccountsActions:l,allAccountsDialogActions:c,apiTokensActions:u,applicationsActions:d,customLoginActions:g,entitlementsActions:p,forgotPasswordActions:h,passwordRotationActions:y,groupsActions:v,groupsDialogsActions:m,impersonateActions:b,loginActions:A,mfaActions:w,passkeysActions:T,profileActions:E,provisioningActions:P,resetPhoneNumberActions:O,restrictionsActions:I,rolesActions:k,securityCenterActions:_,securityPolicyActions:U,sessionsActions:R,sessionsPolicyActions:C,signUpActions:L,smsActions:D,socialLoginActions:N,ssoActions:M,stepUpActions:F,teamActions:x,tenantsActions:$,usernamesActions:G,usersEmailsPolicyActions:j},V=e=>{Object.keys(e).forEach((a=>{const n=a;Fn(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))};return{authActions:S({setState:V,setAuthState:V,setErrorByRequestName:e=>{let{requestName:a}=e,n=f(e,Od);t.auth.errorByRequest=S({},t.auth.errorByRequest,{[a]:S({},n,{isError:!0})})},resetAuthState:()=>{$n(t,["auth"],n)},setUser:t=>{V({user:t})}},s,i,r,o,l,c,u,d,g,p,h,y,v,m,b,A,w,T,E,P,O,I,k,_,U,R,C,L,D,N,M,F,x,$,G,j),authStateActions:B}})(t,e,a,n),o=((t,e,a)=>{const n=Sc(t,e,a);return gu(n,["setConnectivityState","resetConnectivityState","initData","resetConnectivityState","cleanWebhookTestData","cleanWebhookLogsData","cleanWebhookTestMessage","cleanError","cleanSlackData"])})(t,e,a),[r,l]=Md(t,e,a),c=((t,e,a)=>{const n=au(t,e,a),s=gu(n,["setVendorState","resetVendorState"]);return s.loadVendorPublicInfo=async()=>{try{s.setVendorState({whiteLabelMode:!1}),await Rn()}catch(t){console.error("failed to getVendorPublicInfo - ",t)}},s.loadVendorPublicConfiguration=s.loadVendorPublicInfo,s})(t,e,a);return{authActions:s,authStateActions:i,connectivityActions:o,subscriptionsActions:r,subscriptionsStateActions:l,vendorActions:c,auditsActions:Ud(t,e,a)}},xd=(t,e,a=!1,n,s,i=!1,o="path")=>$d({name:t.appName,context:t.context,storeHolder:e,previewMode:a,builderMode:i,urlStrategy:o,initialState:{root:S({},t),auth:S({},null==s?void 0:s.auth,n),connectivity:S({},null==s?void 0:s.connectivity),subscriptions:S({},null==s?void 0:s.subscriptions),vendor:S({},null==s?void 0:s.vendor),auditLogs:S({},null==s?void 0:s.auditLogs),audits:S({},null==s?void 0:s.audits)}}),$d=t=>{var e,a,n,s,i,o,r;const{storeHolder:l}=t;let c=l;if("undefined"==typeof window&&null==l)throw Error("createFronteggStore(initState, storeHolder) failed, storeHolder must not be null in Server-Side rendering");if(c||(c=window),c.store)return c.store;const u=t.name||"default",{context:d,previewMode:g=!1,builderMode:p=!1,urlStrategy:h="path"}=t,y=R.for(u);g||p||y.setContext(d),void 0===d.requestCredentials&&(d.requestCredentials="include");const v=cc(null==(e=t.initialState)?void 0:e.auth),m=gc(null==(a=t.initialState)?void 0:a.connectivity),b=Qc(null==(n=t.initialState)?void 0:n.subscriptions),A=eu(null==(s=t.initialState)?void 0:s.vendor),w=cu(null==(i=t.initialState)?void 0:i.auditLogs),T=(E=null==(o=t.initialState)?void 0:o.audits,cn(du,E));var E;const P=null==(r=t.initialState)?void 0:r.auth;P&&Object.keys(P).forEach((t=>{vn()(v,t,P[t],{merge:!0})}));const O=JSON.parse(JSON.stringify(v)),C=cn({root:{appName:u,context:d,urlStrategy:h,previewMode:g},auth:v,connectivity:m,subscriptions:b,vendor:A,auditLogs:w,audits:T});"undefined"!=typeof window&&window.localStorage&&"true"===window.localStorage.DEBUG_FRONTEGG_STORE&&function(t,e){"string"==typeof e&&(e={name:e});const a=e||{},{enabled:n,name:s=""}=a,i=f(a,_);let o;try{o=n&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!o)return;let r=!1;const l=o.connect(S({name:s},i));I(t,(e=>{const a=e.filter((([t,e])=>e[0]!==U)).map((([t,e])=>`${t}:${e.map(String).join(".")}`)).join(", ");if(a)if(r)r=!1;else{const e=Object.assign({},k(t));delete e[U],l.send({type:a,updatedAt:(new Date).toLocaleString()},e)}})),l.subscribe((e=>{var a,n;if("ACTION"===e.type&&e.payload)try{Object.assign(t,JSON.parse(e.payload))}catch(t){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",t)}if("DISPATCH"===e.type&&e.state){var s,i;if("JUMP_TO_ACTION"===(null==(s=e.payload)?void 0:s.type)||"JUMP_TO_STATE"===(null==(i=e.payload)?void 0:i.type)){r=!0;const a=JSON.parse(e.state);Object.assign(t,a)}t[U]=e}else if("DISPATCH"===e.type&&"COMMIT"===(null==(a=e.payload)?void 0:a.type))l.init(k(t));else if("DISPATCH"===e.type&&"IMPORT_STATE"===(null==(n=e.payload)?void 0:n.type)){var o,c;const a=null==(o=e.payload.nextLiftedState)?void 0:o.actionsById,n=(null==(c=e.payload.nextLiftedState)?void 0:c.computedStates)||[];r=!0,n.forEach((({state:e},n)=>{const s=a[n]||"No action found";Object.assign(t,e),0===n?l.init(k(t)):l.send(s,k(t))}))}}));l.init(k(t))}(C,{name:`${u} Store`,enabled:!0});const L={},D={};y.setContext(t.context),y.setAppName(u);const N=S({},sn(u),{fetch:new Vt(u)});if(t.previewMode||t.builderMode){const{authActions:e,authStateActions:a,connectivityActions:n,subscriptionsActions:s,subscriptionsStateActions:i,vendorActions:o,auditsActions:r}=Fd(C,N,D,O);L.auth=a,L.connectivity=n,L.subscriptions=i,L.vendor=o,L.auditLogs=r,L.audits={},Object.assign(D,S({},e,n,s,o,r));const l={dispatch:t=>{setTimeout((()=>{const[a,...i]=t.type.split("/"),r=i.join("/");"auth"===a&&"function"==typeof e[r]?e[r](t.payload):"connectivity"===a&&"function"==typeof n[r]?n[r](t.payload):"subscriptions"===a&&"function"==typeof s[r]?s[r](t.payload):"vendor"===a&&"function"==typeof o[r]&&o[r](t.payload)}))},getState:()=>C,subscribe:t=>I(C,t),subscribeStateChanged:t=>I(C,(()=>t(C))),store:C,actions:D,stateActions:L};return t.previewMode&&l.dispatch({type:"auth/requestAuthorize",payload:!0}),c&&(c.store=l),l}{const[t,e]=uc(C,N,D,O),a=Sc(C,N,D),[n,s]=Zc(C,N,D),i=au(C,N,D),o=uu(C,N,D),r=((t,e)=>{const a=()=>{t.audits.isLoading=!1},n=e=>{var a;t.audits.error=null!=(a=t.audits.error)?a:{},Object.assign(t.audits.error,{[e.name]:e.error})},s=e=>{t.audits.filters=e,t.audits.currentPage=0,t.audits.offset=0,t.audits.isLoading=!0},i=async()=>{const{sortBy:a,sortDirection:s}=t.audits;try{i=await e.audits.getAuditsStats({sortBy:a,sortDirection:s,count:20}),t.audits.error=void 0,t.audits.totalToday=i.totalToday,t.audits.severeThisWeek=i.severeThisWeek}catch(t){const e={name:"stats",error:t};console.error("failed to load stats - ",t),n(e)}var i},o=async()=>{try{a=await e.metadata.getAuditsMetadata(),t.audits.error={},t.audits.headerProps=a.properties,t.audits.themeAudits=a.theme?a.theme.styles:{}}catch(t){const e={name:"metadata",error:t};console.error("failed to load metadata - ",t),n(e)}var a},r=t=>t.reduce(((t,e)=>(t[e.key]=e.value,t)),{}),l=async s=>{const{filters:i,sortBy:o,sortDirection:l,filter:c,offset:u,virtualScroll:d}=t.audits,{appendMode:g=d,onlyOneLoad:p=!0,offset:h=0}=s||{},{rowsData:y}=g?t.audits:{rowsData:[]};try{const n=r(i),{data:s,total:g}=await e.audits.getAudits(S({},d&&{paginationMode:"virtual"},{sortDirection:l,sortBy:o,filter:c},n,{offset:d?y.length+h||y.length+u:h||u,count:20}));(e=>{t.audits.error={},t.audits.rowsData=e.rowsData,t.audits.lastUpdated=new Date,t.audits.total=e.total})({rowsData:[...y,...s],total:g}),p&&a()}catch(t){const e={name:"audits",error:t};console.error("failed to load audits - ",t),n(e)}};return{initData:async()=>{t.audits.isLoading=!0,await Promise.all([i(),o(),l({onlyOneLoad:!1})]),a()},loadAudits:l,removeFilter:async e=>{const{filters:a}=t.audits,n=a.findIndex((t=>t.key===e.key));if(n<0)return;const i=[...a.slice(0,n),...a.slice(n+1)];s(i)},filterData:async e=>{const{filters:a}=t.audits;let n=a.findIndex((t=>t.key===e.key));n<0&&(n=a.length);const i=[...a.slice(0,n),e,...a.slice(n+1)];s(i)},exportCSV:async()=>{const{filters:a,sortBy:n,sortDirection:s,filter:i,headerProps:o=[]}=t.audits,l=r(a);t.audits.isDownloadingCsv=!0;try{await e.audits.exportAudits(S({endpoint:"csv/v2",headerProps:o,sortDirection:s,sortBy:n,filter:i},l,{offset:0,outputFileName:"audits.csv"}))}catch(t){console.error("failed to export audits - ",t)}finally{t.audits.isDownloadingCsv=!1}}}})(C,N);return L.auth=e,L.connectivity=a,L.subscriptions=s,L.vendor=i,L.auditLogs=o,L.audits=r,Object.assign(D,S({},t,a,n,i,o)),{dispatch:e=>{const[s,...o]=e.type.split("/"),r=o.join("/");"auth"===s&&"function"==typeof t[r]?t[r](e.payload):"connectivity"===s&&"function"==typeof a[r]?a[r](e.payload):"subscriptions"===s&&"function"==typeof n[r]?n[r](e.payload):"vendor"===s&&"function"==typeof i[r]&&i[r](e.payload)},getState:()=>C,subscribe:t=>I(C,t),subscribeStateChanged:t=>I(C,(()=>t(C))),store:C,actions:D,stateActions:L}}};let Gd,jd,Bd,Vd,Wd,Hd,zd,Kd,qd,Jd,Yd,Xd,Qd,Zd;!function(t){t.phoneNumber="phoneNumber"}(Gd||(Gd={})),function(t){t.ALLOWED="allowedCountries",t.BLOCKED="blockedCountries"}(jd||(jd={})),function(t){t.Name="name",t.Username="username",t.PhoneNumber="phoneNumber",t.Address="address",t.JobTitle="jobTitle"}(Bd||(Bd={})),function(t){t.LoginSessions="loginSessions",t.Mfa="mfa"}(Vd||(Vd={})),function(t){t.Name="name",t.PhoneNumber="phoneNumber"}(Wd||(Wd={})),function(t){t.CompanyName="companyName",t.Address="address",t.Website="website",t.Timezone="timezone",t.Currency="currency"}(Hd||(Hd={})),function(t){t.User="user",t.Applications="applications",t.Groups="groups",t.Roles="roles",t.JoinedAt="joinedAt",t.LastSeen="lastSeen",t.ManagedBy="managedBy"}(zd||(zd={})),function(t){t.Invoices="invoices"}(Kd||(Kd={})),function(t){t.SessionManagement="sessionManagement",t.GeneralSettings="generalSettings",t.IpRestrictions="ipRestrictions",t.DomainRestrictions="domainRestrictions"}(qd||(qd={})),function(t){t.IdleSessionTimeout="idleSessionTimeout",t.ForceReLogin="forceReLogin",t.MaximumConcurrentSessions="maximumConcurrentSessions"}(Jd||(Jd={})),function(t){t.Mfa="mfa",t.UserLockout="userLockout",t.PasswordHistory="passwordHistory"}(Yd||(Yd={})),function(t){t.IpAddressRestrictions="ipAddressRestrictions"}(Xd||(Xd={})),function(t){t.RestrictSignupByEmailDomain="restrictSignupByEmailDomain"}(Qd||(Qd={})),function(t){t.Settings="settings",t.CustomLogin="customLogin"}(Zd||(Zd={}));const tg={hidden:"hidden",viewOnly:"viewOnly",edit:"edit"},eg={hidden:"hidden",edit:"edit"};function ag(t,e=0,a=1){return Math.min(Math.max(e,t),a)}function ng(t){if(t.type)return t;if("#"===t.charAt(0))return ng(function(t){t=t.substr(1);const e=new RegExp(`.{1,${t.length>=6?2:1}}`,"g");let a=t.match(e);return a&&1===a[0].length&&(a=a.map((t=>t+t))),a?`rgb${4===a.length?"a":""}(${a.map(((t,e)=>e<3?parseInt(t,16):Math.round(parseInt(t,16)/255*1e3)/1e3)).join(", ")})`:""}(t));const e=t.indexOf("("),a=t.substring(0,e);if(-1===["rgb","rgba","hsl","hsla","color"].indexOf(a))throw new Error("MUI: Unsupported `%s` color.\nThe following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color(). "+t);const n=t.substring(e+1,t.length-1);let s,i;if("color"===a){if(i=n.split(" "),s=i.shift(),4===i.length&&"/"===i[3].charAt(0)&&(i[3]=i[3].substr(1)),-1===["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].indexOf(s))throw new Error("MUI: unsupported `%s` color space.\nThe following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020."+s)}else i=n.split(",");return{type:a,values:i.map((t=>parseFloat(t))),colorSpace:s}}function sg(t){const{type:e,colorSpace:a}=t;let{values:n}=t;return-1!==e.indexOf("rgb")?n=n.map(((t,e)=>e<3?parseInt(t,10):t)):-1!==e.indexOf("hsl")&&(n[1]=`${n[1]}%`,n[2]=`${n[2]}%`),n=-1!==e.indexOf("color")?`${a} ${n.join(" ")}`:`${n.join(", ")}`,`${e}(${n})`}function ig(t){if(0===t.indexOf("#"))return t;const{values:e}=ng(t);return`#${e.map(((t,e)=>function(t){const e=t.toString(16);return 1===e.length?`0${e}`:e}(3===e?Math.round(255*t):t))).join("")}`}function og(t,e){return t=ng(t),e=ag(e),"rgb"!==t.type&&"hsl"!==t.type||(t.type+="a"),"color"===t.type?t.values[3]=`/${e}`:t.values[3]=e,sg(t)}function rg(t,e){if(t=ng(t),e=ag(e),-1!==t.type.indexOf("hsl"))t.values[2]*=1-e;else if(-1!==t.type.indexOf("rgb")||-1!==t.type.indexOf("color"))for(let a=0;a<3;a+=1)t.values[a]*=1-e;return sg(t)}function lg(t,e){if(t=ng(t),e=ag(e),-1!==t.type.indexOf("hsl"))t.values[2]+=(100-t.values[2])*e;else if(-1!==t.type.indexOf("rgb"))for(let a=0;a<3;a+=1)t.values[a]+=(255-t.values[a])*e;else if(-1!==t.type.indexOf("color"))for(let a=0;a<3;a+=1)t.values[a]+=(1-t.values[a])*e;return sg(t)}const cg=t=>{if(t)return{main:t,light:ig(lg(t,.4)),dark:ig(rg(t,.15)),hover:ig(rg(t,.15)),active:ig(rg(t,.2))}},ug=t=>{if(t)return{main:t,light:lg(t,.7),dark:rg(t,.2)}},dg=(t,e)=>{var a,n,s,i,o,r,l,c,u,d,g,p;return null!=t&&t.palette&&"string"==typeof(null==t||null==(a=t.palette)?void 0:a.primary)?S({},e,{palette:{primary:S({},cg(null==t||null==(n=t.palette)?void 0:n.primary),{contrastText:null!=(s=null==t||null==(i=t.palette)?void 0:i.primaryText)?s:"#000000"}),secondary:S({},cg(null==t||null==(o=t.palette)?void 0:o.secondary),{contrastText:null!=(r=null==t||null==(l=t.palette)?void 0:l.secondaryText)?r:"#000000"}),danger:S({},cg(null==t||null==(c=t.palette)?void 0:c.error),{contrastText:"#FFF"}),success:S({},ug(null==t||null==(u=t.palette)?void 0:u.success),{contrastText:"#FFF"}),error:S({},ug(null==t||null==(d=t.palette)?void 0:d.error),{contrastText:"#FFF"}),warning:S({},ug(null==t||null==(g=t.palette)?void 0:g.warning),{contrastText:"#FFF"}),info:S({},ug(null==t||null==(p=t.palette)?void 0:p.info),{contrastText:"#FFF"})}}):{}},gg={theme:{},themeV2:{},localizations:{},navigation:{usage:{visibility:"hidden",permissions:["fe.usage.read"],featureFlag:"fe-usage-page"},webhooks:{visibility:"hidden",permissions:["fe.connectivity.read.webhooks"]},roles:{visibility:"hidden",permissions:["fe.secure.read.roles"]},users:{visibility:"always",permissions:["fe.secure.read.users"],inviteDialog:{phoneNumberField:"optional"}},personalApiTokens:{visibility:"hidden",permissions:["fe.secure.read.userApiTokens"]},apiTokens:{visibility:"hidden",permissions:["fe.secure.read.tenantApiTokens"]},profile:{visibility:"always"},privacy:{visibility:"always"},account:{visibility:"always",permissions:["fe.secure.read.accountSettings"]},security:{visibility:"always",permissions:["fe.secure.read.securityPolicy"]},sso:{visibility:"hidden",permissions:["fe.secure.read.samlConfiguration"]},provisioning:{visibility:"hidden",permissions:["fe.secure.read.provisioningConfiguration"]},audits:{visibility:"always",permissions:["fe.secure.read.audits"]},subscriptions:{visibility:"hidden",permissions:["fe.subscriptions.*"]},allAccounts:{visibility:"byPermissions",permissions:["fe.account-hierarchy.read.subAccount"]},groups:{visibility:"hidden",permissions:["fe.secure.read.groups"]}}};class pg{constructor(){this._theme=gg.theme,this._themeV2=gg.themeV2,this._navigation=gg.navigation,this._localizations=gg.localizations,this._integrations=gg.integrations}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new pg;return a.set(t),pg._instances[e]=a,a}get theme(){var t;return null!=(t=this._theme)?t:{}}get themeV2(){var t;return null!=(t=this._themeV2)?t:{}}get navigation(){var t;return null!=(t=this._navigation)?t:{}}get localizations(){var t;return null!=(t=this._localizations)?t:{}}get integrations(){var t;return null!=(t=this._integrations)?t:{}}set(t){try{var e,a,n,s,i,o,r,l,c;this._navigation=ln().all([null!=(e=gg.navigation)?e:{},null!=(a=null==t?void 0:t.navigation)?a:{}]),this._theme=ln().all([null!=(n=gg.theme)?n:{},dg(null==t?void 0:t.theme,gg.theme)]),this._themeV2=ln().all([null!=(s=gg.themeV2)?s:{},null!=(i=null==t?void 0:t.themeV2)?i:{}]),this._localizations=ln().all([null!=(o=gg.localizations)?o:{},null!=(r=null==t?void 0:t.localizations)?r:{}]),this._integrations=ln().all([null!=(l=gg.integrations)?l:{},null!=(c=null==t?void 0:t.integrations)?c:{}])}catch(t){this._navigation=gg.navigation,this._theme=gg.theme,this._themeV2=gg.themeV2,this._localizations=gg.localizations,this._integrations=gg.integrations}}}pg._instances={};var hg=function(t){return t.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map((function(t){return t.toLowerCase()})).join("")},yg=function(t,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=document.createElement(e);return Object.keys(a).forEach((function(t){return n.setAttribute(t,a[t])})),t.appendChild(n),n},vg=function(t){return new Promise((function(e,a){var n=4e3,s=setInterval((function(){return null!=t.themeSetter?(clearInterval(s),void e(!0)):n<0?(a("Failed to load Renderer with themeSetter"),void clearInterval(s)):void(n-=50)}),50)}))},Sg=function(t){var e=t.toString();if(e){var a=new URL(window.location.href);a.search=e,window.history.pushState(null,"",a.toString())}};const fg="7.76.0-alpha.1";var mg={admin_portal_ip_restrictions:"on",admin_portal_domain_restrictions:"on","new-mfa-pages":"on","show-passkeys-new":"on","groups-admin-box-new":"on","msp-all-accounts-new":"on","temporary-users":"on"},bg=function(t){var e,a=pg.getInstance(t),n=null==a||null==(e=a.integrations)?void 0:e.gtm;null==n||n.filter((function(t){var e=t.id;return t.enabled&&/^GTM-[a-zA-Z0-9]+$/.test(e)})).forEach((function(t){var e=t.id,a=document.createElement("script");a.innerHTML="\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','".concat(e,"');\n "),document.body.appendChild(a)}))},Ag=function(){var t=p(y().mark((function t(e,a,n){var s,i,o,r;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=null==(s=e.metadataOverrides)?void 0:s.url){t.next=3;break}return t.abrupt("return",e);case 3:return t.prev=3,t.next=6,Ln((function(){return a.sendRequest({url:i,method:"GET",credentials:"omit"})}),n);case 6:if(!(o=t.sent)){t.next=10;break}return r=ln()(e,o),t.abrupt("return",r);case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(3),console.error("Failed to get metadata overrides",t.t0);case 15:return t.abrupt("return",e);case 16:case"end":return t.stop()}}),t,null,[[3,12]])})));return function(e,a,n){return t.apply(this,arguments)}}(),wg=function(){function a(t,e){var n,s,o,r=this,l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i(this,a),this.name=void 0,this.iframeRendering=void 0,this.options=void 0,this.loading=!0,this.cdnUrl="https://assets.frontegg.com/admin-box/".concat(fg),this.assetsUrl="https://adminBox.frontegg.com/admin-box/".concat(fg),this.customElementName="",this.adminPortalEl=void 0,this.adminPortalRenderer=void 0,this.loginBoxEl=void 0,this.checkoutDialogEl=void 0,this.checkoutDialogRenderer=void 0,this.adminPortalContainer=void 0,this.loginBoxContainer=void 0,this.checkoutDialogContainer=void 0,this.loginBoxRenderer=void 0,this.store=void 0,this.loadingListeners=[],this.fetchClient=void 0,this.apiClient=void 0,this.updateLocalizations=void 0,this.loadAdminBoxMetadata=p(y().mark((function t(){var e,a,n,s,i;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r.options.metadata){t.next=21;break}return t.prev=1,t.next=4,Ln((function(){return r.fetchClient.get("/metadata",{entityName:"adminBox"})}),Un);case 4:return s=t.sent,i=null!=(e=null==s||null==(a=s.rows)||null==(n=a[0])?void 0:n.configuration)?e:{},t.prev=6,t.next=9,Ag(i,r.fetchClient,Un);case 9:r.options.metadata=t.sent,t.next=15;break;case 12:t.prev=12,t.t0=t.catch(6),console.error("failed to get admin portal overridden metadata",t.t0);case 15:t.next=21;break;case 17:t.prev=17,t.t1=t.catch(1),console.error("failed to get admin portal metadata",t.t1),r.dispatchErrorByRequestName(t.t1,Xn.LOAD_ADMIN_BOX_METADATA);case 21:pg.set(r.options.metadata,r.name);case 22:case"end":return t.stop()}}),t,null,[[1,17],[6,12]])}))),this.requestAuthorize=p(y().mark((function t(){var e,a,n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=null==(e=r.options.authOptions)||null==(a=e.hostedLoginOptions)?void 0:a.loadUserOnFirstLoad,r.options.builderMode||"nextjs"===r.options.framework||(r.options.hostedLoginBox&&!r.options.customLoginBox?n&&r.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:{shouldRedirectToLogin:!1,firstTime:!0}}):r.store.dispatch({type:"auth/requestAuthorize",payload:!0}));case 2:case"end":return t.stop()}}),t)}))),this.loadFeatureFlags=p(y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.options.previewMode&&!r.options.builderMode){t.next=4;break}ae.set(mg,r.name),t.next=16;break;case 4:return t.prev=4,t.next=7,Ln((function(){return r.apiClient.featureFlags.loadFeatureFlags()}),Un);case 7:e=t.sent,r.options.overrideFeatureFlags&&Object.assign(e,r.options.overrideFeatureFlags),ae.set(e,r.name),t.next=16;break;case 12:t.prev=12,t.t0=t.catch(4),console.error("failed to get admin portal feature flags",t.t0),r.dispatchErrorByRequestName(t.t0,Xn.LOAD_FEATURE_FLAGS);case 16:case"end":return t.stop()}}),t,null,[[4,12]])}))),this.setFeatureFlagsForPreview=function(t){ae.set(Object.assign({},mg,t),r.name)},this.queryFeatureFlags=function(t){return ae.getFeatureFlags(t,r.name)},this.updateLocalizationsSetter=function(t){r.updateLocalizations=t},this.getEntitlementsFromStore=function(){var t;return null==(t=r.store.getState().auth.user)?void 0:t.entitlements},this.getUserFromStore=function(){return r.store.getState().auth.user},this.getEntitlementsQueryData=function(t){var e=r.getUserFromStore();return{entitlements:r.getEntitlementsFromStore(),attributes:{custom:t,jwt:e}}},this.renderUsersTable=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderUsersTable(e,{injector:r,options:r.options,container:e,props:a,themeOptions:n.themeOptions}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.renderInviteUserDialog=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderInviteUserDialog(e,{injector:r,options:r.options,container:e,props:a,themeOptions:n.themeOptions}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.renderChangePasswordForm=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderChangePasswordForm(e,{injector:r,options:r.options,props:a,themeOptions:n.themeOptions}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.renderProfilePage=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderProfilePage(e,{injector:r,options:r.options,props:a,themeOptions:n.themeOptions,localizations:n.localizations}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.renderEditEmailForm=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderEditEmailForm(e,{injector:r,options:r.options,props:a,themeOptions:n.themeOptions,localizations:n.localizations}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.getUsersTableStore=function(){var t=p(y().mark((function t(e){var a;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return a=t.sent,t.abrupt("return",a.useUsersTableStore(e));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),this.getInviteUserDialogStore=function(){var t=p(y().mark((function t(e){var a;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return a=t.sent,t.abrupt("return",a.useInviteUserDialogStore(e));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var d=hg(e),g="frontegg-app-".concat(d);this.iframeRendering=l,this.name=d,this.options=Object.assign({},t,{contextOptions:Object.assign({requestCredentials:"include"},t.contextOptions)}),this.fetchClient=new Vt(this.name),this.apiClient=sn(this.name),this.options.cdnUrl&&(this.cdnUrl=this.options.cdnUrl),this.options.assetsUrl&&(this.assetsUrl=this.options.assetsUrl),R.for(this.name).setCdnUrl(this.cdnUrl),R.for(this.name).setAssetsUrl(this.assetsUrl),this.customElementName=g;var h,v,S=this.options.authOptions?Object.assign({},this.options.authOptions,{hostedLoginBox:this.options.hostedLoginBox}):{hostedLoginBox:this.options.hostedLoginBox};if(S.onRedirectTo=t.onRedirectTo,S.disableSilentRefresh=null==(n=this.options.authOptions)?void 0:n.disableSilentRefresh,this.options.store){if(this.store=this.options.store,!u&&this.options.store.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=$d({context:this.options.contextOptions,name:this.name,builderMode:this.options.builderMode,previewMode:this.options.previewMode,storeHolder:this,urlStrategy:this.options.urlStrategy,initialState:{auth:Object.assign({},S,null!=(h=this.options.authOptions)?h:{}),auditLogs:Object.assign({},null!=(v=this.options.auditsOptions)?v:{})}});c.setInstance(d,this);var f=R.for(d);f.setAppName(d),this.setEntitlementsOptions(t.entitlementsOptions),this.setSessionContext({enableSessionPerTenant:null==(s=t.authOptions)?void 0:s.enableSessionPerTenant,skipUserLoading:null==(o=t.authOptions)?void 0:o.skipUserLoading});var m=t.basename;m&&f.setBasename(m)}var n,o,r,u;return l(a,[{key:"setEntitlementsOptions",value:function(t){R.for(this.name).setEntitlementsOptions(Object.assign({},t))}},{key:"setSessionContext",value:function(t){R.for(this.name).setSessionContext(Object.assign({},t))}},{key:"dispatchErrorByRequestName",value:function(t,e){(null==t?void 0:t.statusCode)<500||this.store.dispatch({type:"auth/setErrorByRequestName",payload:{requestName:e,traceId:Nn(t)}})}},{key:"initContainers",value:(u=p(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.adminPortalEl=e.adminPortalEl,this.loginBoxEl=e.loginBoxEl,this.checkoutDialogEl=e.checkoutDialogEl,this.adminPortalContainer=e.adminPortalContainer,this.loginBoxContainer=e.loginBoxContainer,this.checkoutDialogContainer=e.checkoutDialogContainer;try{"nextjs"!==this.options.framework&&document.body.classList.add("frontegg-loading")}catch(t){console.error("Failed to add frontegg-loading to body classList")}return t.next=9,Promise.all([this.loadFeatureFlags(),this.loadAdminBoxMetadata(),this.requestAuthorize()]);case 9:this.options.previewMode||this.options.customLoginBox||(this.loadLoginBox(),bg(this.name)),this.options.lazyLoadAdminPortal||this.loadScript("FronteggAdminPortal");case 11:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"updateMetadata",value:function(t){var e;pg.set(t,this.name),null!=t&&t.localizations&&(null==(e=this.updateLocalizations)||e.call(this,t.localizations))}},{key:"addOnLoadedListener",value:function(t){this.loading?this.loadingListeners.push(t):t()}},{key:"ready",value:function(t){this.loading?t():this.addOnLoadedListener(t)}},{key:"loginWithRedirect",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/requestHostedLoginAuthorize",payload:t})}},{key:"loginWithRedirectV2",value:function(t){this.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:t})}},{key:"logout",value:function(t){this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/logout",payload:t})}},{key:"loadScript",value:function(a){var n=this;return new Promise((function(i,o){var r=window;if(r[a])i(r[a]);else{var l=document.createElement("script");l.src="".concat(n.cdnUrl,"/").concat({FronteggLoginBox:"login-box/index.js",FronteggAdminPortal:"admin-portal/index.js"}[a]),l.setAttribute("id","".concat(a,"Script")),l.setAttribute("cdn-url",n.cdnUrl),l.onload=function(){r["".concat(a,"Init")]?i(r["".concat(a,"Init")]({FronteggRestApi:t,FronteggTypes:s,FronteggReduxStore:e})):i(r[a])},l.onerror=function(t){console.log("Profile page error",t),o(t)},document.body.append(l)}}))}},{key:"loadLoginBox",value:(r=p(y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.loadScript("FronteggLoginBox");case 2:t.sent.render(this.loginBoxEl,{injector:this,options:this.options}),this.loading=!1,this.loadingListeners.forEach((function(t){try{t()}catch(t){console.error("Failed to call loadLoginBoxListener",t)}})),this.loadingListeners=[];case 7:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"showAdminPortal",value:(o=p(y().mark((function t(e){var a,n,s,i,o;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=(null!=e?e:{isMultiApp:!1}).isMultiApp,n=this.queryFeatureFlags(["multi-apps-admin-portal"]),s=d(n,1),i=s[0],R.for(this.name).setRequestSource(Gt.AdminPortal),t.next=5,this.loadScript("FronteggAdminPortal");case 5:o=t.sent,this.adminPortalRenderer=o.render(this.adminPortalEl,{injector:this,options:Object.assign({isMultiApp:i&&a},this.options)});case 7:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"openHostedAdminPortal",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.options.contextOptions.baseUrl,a="".concat(e,"/oauth/portal");t?window.open(a,"_blank"):window.location.href=a}},{key:"hideAdminPortal",value:function(){try{var t,e=new URLSearchParams(window.location.search);null==(t=this.adminPortalRenderer)||t.unmount(),Sg(e),R.for(this.name).setRequestSource(null)}catch(t){console.error("Failed to unmount admin portal",t)}}},{key:"showCheckoutDialog",value:(n=p(y().mark((function t(e){var a;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.loadScript("FronteggAdminPortal");case 2:a=t.sent,this.checkoutDialogRenderer=a.renderCheckoutDialog(this.checkoutDialogEl,Object.assign({injector:this},e,{options:this.options}));case 4:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"hideCheckoutDialog",value:function(){try{var t;null==(t=this.checkoutDialogRenderer)||t.unmount()}catch(t){console.error("Failed to unmount checkout dialog",t)}}},{key:"getFeatureEntitlements",value:function(t,e){var a=this.getEntitlementsQueryData(e),n=a.entitlements,s=a.attributes;return co(n,t,s)}},{key:"getPermissionEntitlements",value:function(t,e){var a=this.getEntitlementsQueryData(e),n=a.entitlements,s=a.attributes;return lo(n,t,s)}},{key:"getEntitlements",value:function(t,e){return"permissionKey"in t?this.getPermissionEntitlements(t.permissionKey,e):this.getFeatureEntitlements(t.featureKey,e)}},{key:"loadEntitlements",value:function(t){this.store.dispatch({type:"auth/loadEntitlements",payload:{callback:t}})}},{key:"stepUp",value:function(t){var e=this.store.getState(),a=(null==e?void 0:e.auth)||{},n=a.hostedLoginBox,s=a.routes.stepUpUrl;n?this.store.dispatch({type:"auth/stepUpHostedLogin",payload:t}):As(s,e.auth.onRedirectTo,null==t?void 0:t.maxAge)}},{key:"isSteppedUp",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=((null==(t=this.store.getState())?void 0:t.auth)||{}).user;return ms(a,e)}},{key:"switchTenant",value:function(t){this.store.dispatch({type:"auth/switchTenant",payload:t})}},{key:"close",value:function(){this.hideAdminPortal(),this.hideCheckoutDialog()}}]),a}(),Tg=function(){function t(){i(this,t)}return l(t,null,[{key:"setAuthentication",value:function(t,e,a){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"default",s=c.getInstance(n),i=R.for(n);t&&e?(i.setAccessToken(e),i.setUser(Object.assign({},a,{accessToken:e})),s.store.actions.setAuthState({isLoading:!1,isAuthenticated:t,user:a}),s.store.actions.loadTenants()):(i.setAccessToken(null),i.setUser(null),s.store.actions.setAuthState({isLoading:!1,isAuthenticated:!1,user:null}))}}]),t}(),Eg=function(){function t(){i(this,t)}return l(t,null,[{key:"show",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).showAdminPortal()}},{key:"showMultiApp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).showAdminPortal({isMultiApp:!0})}},{key:"openHosted",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";c.getInstance(e).openHostedAdminPortal(t)}},{key:"hide",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).hideAdminPortal()}}]),t}(),Pg=function(){function t(){i(this,t)}return l(t,null,[{key:"show",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";c.getInstance(e).showCheckoutDialog(t)}},{key:"hide",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).hideCheckoutDialog()}}]),t}(),Og=function(t){var e;return null!=(e=window.FronteggAdminPortal.adminPortalStaticThemesDefaults[t])?e:void 0},Ig=function(){function t(e,a,n,s){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];i(this,t),this.app=void 0,this.options=void 0,this.store=void 0,this.setRoute=function(){},this.themeSetter=void 0,this.themeOptions={};var r={baseUrl:"preview"};if(n){if(this.store=n,!o&&n.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=xd({context:r,appName:e},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:a,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:r},s),this.app=new wg(this.options,e,!0),pg.set({},e)}var e;return l(t,[{key:"render",value:(e=p(y().mark((function t(e){var a,n,s,i,o=this;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(a=e.querySelector("#root"))||((a=e.ownerDocument.createElement("div")).setAttribute("id","root"),e.appendChild(a)),this.app.adminPortalContainer=e,this.app.adminPortalEl=a,n=function(t){o.themeSetter=t},s=function(t){o.setRoute=t},t.next=8,this.app.loadScript("FronteggAdminPortal");case 8:return i=t.sent,this.app.adminPortalRenderer=i.renderPage(a,{options:this.options,injector:this.app,setThemeSetter:n,setStaticRouteSetter:s}),this.app.loading=!1,t.next=13,vg(this);case 13:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"setStaticRoute",value:function(t){var e;null==(e=this.setRoute)||e.call(this,t)}},{key:"unmount",value:function(){try{var t;null==(t=this.app.adminPortalRenderer)||t.unmount()}catch(t){console.error("Failed to unmount admin Portal renderer",t)}}},{key:"setTheme",value:function(t){var e;this.themeOptions=t,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(e=this.themeSetter)||e.call(this,this.themeOptions)}}]),t}(),kg="modern",_g=function(t){var e,a=window.FronteggAdminPortal.themes;return null!=(e=a[t])?e:a[kg]},Ug=function(){function t(e,a,n,s){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];i(this,t),this.app=void 0,this.options=void 0,this.store=void 0,this.themeSetter=void 0,this.setRoute=function(){},this.themeOptions={};var r={baseUrl:"preview"};if(n){if(this.store=n,!o&&n.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=xd({context:r,appName:e},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:a,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:r,onRedirectTo:function(){console.debug("path")}},s),this.app=new wg(this.options,e,!0,o),pg.set({},e)}var e;return l(t,[{key:"render",value:(e=p(y().mark((function t(e){var a,n,s,i,o=this;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(a=e.querySelector("#root"))||((a=e.ownerDocument.createElement("div")).setAttribute("id","root"),e.appendChild(a)),this.app.loginBoxContainer=e,this.app.loginBoxEl=a,n=function(t){o.themeSetter=t},s=function(t){o.setRoute=t},t.next=8,this.app.loadScript("FronteggLoginBox");case 8:return i=t.sent,this.app.loginBoxRenderer=i.renderPage(a,{options:this.options,injector:this.app,setThemeSetter:n,setStaticRouteSetter:s,staticRoute:"/account/login"}),t.next=12,vg(this);case 12:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"unmount",value:function(){try{var t;null==(t=this.app.loginBoxRenderer)||t.unmount()}catch(t){console.error("Failed to unmount login box renderer",t)}}},{key:"setTheme",value:function(t){var e;this.themeOptions=t,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(e=this.themeSetter)||e.call(this,this.themeOptions)}},{key:"setStaticRoute",value:function(t){var e;this.setRoute||console.warn("this.setRoute is not defined yet"),null==(e=this.setRoute)||e.call(this,t)}},{key:"setStore",value:function(t){this.store.dispatch({type:"auth/setState",payload:t})}}]),t}();function Rg(t,e){return Rg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rg(t,e)}function Cg(t){return Cg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Cg(t)}function Lg(t,e,a){return Lg=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,a){var n=[null];n.push.apply(n,e);var s=new(Function.bind.apply(t,n));return a&&Rg(s,a.prototype),s},Lg.apply(null,arguments)}function Dg(t){var e="function"==typeof Map?new Map:void 0;return Dg=function(t){if(null===t||(a=t,-1===Function.toString.call(a).indexOf("[native code]")))return t;var a;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return Lg(t,arguments,Cg(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Rg(n,t)},Dg(t)}function Ng(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var a,n=Cg(t);if(e){var s=Cg(this).constructor;a=Reflect.construct(n,arguments,s)}else a=n.apply(this,arguments);return function(t,e){if(e&&("object"===o(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,a)}}var Mg=function(t){var e=new wg(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default");if("undefined"!=typeof document){var a;if(!t.contextOptions.baseUrl){var n=new Error('Edit <FronteggProvider/> options { ContextOptions: { baseUrl: "" } } in order to connect your application');throw document.body.innerHTML="",alert(n.message),n}if(!customElements.get("frontegg-app")){var s=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Rg(t,e)}(n,e);var a=Ng(n);function n(){var t;i(this,n);for(var e=arguments.length,s=new Array(e),o=0;o<e;o++)s[o]=arguments[o];return(t=a.call.apply(a,[this].concat(s))).app=null,t}return l(n,[{key:"connectedCallback",value:function(){this.updateContent()}},{key:"attributeChangedCallback",value:function(t,e,a){if("app-name"===t){if(null===e)return;if(e===a)return;this.innerHTML="",null===a?this.remove():this.updateContent()}console.debug("attributeChangedCallback",t,e,a)}},{key:"updateContent",value:function(){var e,a=null!=(e=this.getAttribute("app-name"))?e:"default",n=c.getInstance(a);if(null===n)throw Error("FronteggApp not found for appName: '".concat(a,"'"));this.setAttribute("id","frontegg-app-".concat(n.name));var s=yg(this,"div",{id:"frontegg-admin-portal-container-".concat(n.name)}),i=yg(this,"div",{id:"frontegg-login-box-container-".concat(n.name)}),o=yg(this,"div",{id:"frontegg-checkout-dialog-container-".concat(n.name)}),r=s.attachShadow({mode:"open"}),l=t.iframeRendering?i:i.attachShadow({mode:"open"}),u=o.attachShadow({mode:"open"}),d=yg(r,"div",{id:"frontegg-admin-portal-".concat(n.name),class:"frontegg-root-content"}),g=yg(l,"div",{id:"frontegg-login-box-".concat(n.name),class:"frontegg-root-content"}),p=yg(u,"div",{id:"frontegg-checkout-dialog-".concat(n.name),class:"frontegg-root-content"});n.initContainers({adminPortalEl:d,loginBoxEl:g,adminPortalContainer:s,loginBoxContainer:i,checkoutDialogContainer:o,checkoutDialogEl:p})}}],[{key:"observedAttributes",get:function(){return["app-name"]}}]),n}(Dg(HTMLElement));customElements.define("frontegg-app",s)}null==(a=document.querySelector('frontegg-app[app-name="'.concat(e.name,'"]')))||a.remove();var o=document.createElement("frontegg-app");o.setAttribute("app-name",e.name),document.body.appendChild(o)}return e}})(),n})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Frontegg=t():e.Frontegg=t()}(window,(()=>(()=>{var e={3952:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createConditionEvaluator=void 0;const n=a(2904),s=a(9475);t.createConditionEvaluator=function(e){const t=(0,s.useSanitizer)(e.condition.op);if(!t)return()=>!1;const{isSanitized:a,sanitizedValue:i}=t(e.condition.value);if(!a||void 0===i)return()=>!1;const o=(0,n.useOperation)(e.condition.op,i);return t=>{const a=t[e.condition.attribute];if(void 0===a||!o)return!1;const{isValid:n}=o(a);return e.condition.negate?!n:n}}},9838:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),s(a(3952),t),s(a(963),t)},963:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3998:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateFeatureFlag=void 0;const n=a(9243);t.evaluateFeatureFlag=function(e,t){if(!e.on)return{treatment:e.offTreatment};const a=function(e,t){var a;return null===(a=e.rules)||void 0===a?void 0:a.find((e=>(0,n.createRuleEvaluator)({rule:e})(t)===n.RuleEvaluationResultEnum.Treatable))}(e,t);return a?{treatment:a.treatment}:{treatment:e.defaultTreatment}}},2152:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),s(a(3998),t)},5875:(e,t,a)=>{"use strict";t.Me=t.a_=void 0;a(2152),a(3856),a(9243),a(2752);var n=a(7254);Object.defineProperty(t,"a_",{enumerable:!0,get:function(){return n.evaluateIsEntitledToFeature}}),Object.defineProperty(t,"Me",{enumerable:!0,get:function(){return n.evaluateIsEntitledToPermissions}})},6849:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanOperationsMapper=void 0;const i=a(2752),o=a(6715);s(a(6715),t),s(a(4965),t),t.BooleanOperationsMapper={[i.OperationEnum.Is]:e=>(0,o.useIsOperation)(e)}},6715:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useIsOperation=void 0,t.useIsOperation=function(e){return t=>({isValid:t===e.boolean})}},4965:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSanitizersMapper=t.singleBooleanSanitizer=void 0;const n=a(2752);t.singleBooleanSanitizer=e=>{const t=void 0!==e.boolean&&(e=>"boolean"==typeof e)(e.boolean)?{boolean:e.boolean}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.BooleanSanitizersMapper={[n.OperationEnum.Is]:t.singleBooleanSanitizer}},2904:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useOperation=void 0;const n=a(5018),s=a(3922),i=a(3147),o=a(6849),r={...n.StringOperationsMapper,...s.NumericOperationsMapper,...i.DateOperationsMapper,...o.BooleanOperationsMapper};t.useOperation=function(e,t){const a=r[e];return a?a(t):void 0}},9475:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSanitizer=void 0;const n=a(6849),s=a(1016),i=a(6891),o=a(3922),r={...s.StringSanitizersMapper,...o.NumericSanitizersMapper,...i.DateSanitizersMapper,...n.BooleanSanitizersMapper};t.useSanitizer=function(e){return r[e]}},3147:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.DateOperationsMapper=void 0;const i=a(2752),o=a(1641);s(a(1641),t),s(a(1626),t),t.DateOperationsMapper={[i.OperationEnum.On]:e=>(0,o.useDateOnOperation)(e),[i.OperationEnum.OnOrAfter]:e=>(0,o.useDateOnOrAfterOperation)(e),[i.OperationEnum.OnOrBefore]:e=>(0,o.useDateOnOrBeforeOperation)(e),[i.OperationEnum.BetweenDate]:e=>(0,o.useDateBetweenOperation)(e)}},1641:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useDateBetweenOperation=t.useDateOnOrBeforeOperation=t.useDateOnOrAfterOperation=t.useDateOnOperation=void 0,t.useDateOnOperation=function(e){return t=>({isValid:t.getTime()===e.date.getTime()})},t.useDateOnOrAfterOperation=function(e){return t=>({isValid:t.getTime()>=e.date.getTime()})},t.useDateOnOrBeforeOperation=function(e){return t=>({isValid:t.getTime()<=e.date.getTime()})},t.useDateBetweenOperation=function(e){return t=>({isValid:t.getTime()>=e.start.getTime()&&t.getTime()<=e.end.getTime()})}},6891:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateSanitizersMapper=t.sanitizeDateRange=t.sanitizeSingleDate=t.isValidDate=t.sanitizeDateValue=void 0;const n=a(2752);t.sanitizeDateValue=e=>new Date(e),t.isValidDate=e=>e instanceof Date&&!isNaN(e),t.sanitizeSingleDate=e=>{const a=e.date?(0,t.sanitizeDateValue)(e.date):void 0,n=a&&(0,t.isValidDate)(a)?{date:a}:void 0;return{isSanitized:!!n,sanitizedValue:n}},t.sanitizeDateRange=e=>{const a=e.start?(0,t.sanitizeDateValue)(e.start):void 0,n=e.end?(0,t.sanitizeDateValue)(e.end):void 0,s=a&&n&&(0,t.isValidDate)(a)&&(0,t.isValidDate)(n)?{start:a,end:n}:void 0;return{isSanitized:!!s,sanitizedValue:s}},t.DateSanitizersMapper={[n.OperationEnum.On]:t.sanitizeSingleDate,[n.OperationEnum.OnOrAfter]:t.sanitizeSingleDate,[n.OperationEnum.OnOrBefore]:t.sanitizeSingleDate,[n.OperationEnum.BetweenDate]:t.sanitizeDateRange}},1626:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3922:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.NumericOperationsMapper=void 0;const i=a(2752),o=a(9194);t.NumericOperationsMapper={[i.OperationEnum.Equal]:e=>(0,o.useEqualsOperation)(e),[i.OperationEnum.GreaterThan]:e=>(0,o.useGreaterThanOperation)(e),[i.OperationEnum.GreaterThanEqual]:e=>(0,o.useGreaterThanEqualOperation)(e),[i.OperationEnum.LesserThan]:e=>(0,o.useLesserThanOperation)(e),[i.OperationEnum.LesserThanEqual]:e=>(0,o.useLesserThanEqualOperation)(e),[i.OperationEnum.BetweenNumeric]:e=>(0,o.useBetweenNumericOperation)(e)},s(a(9194),t),s(a(5168),t),s(a(7695),t)},9194:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useBetweenNumericOperation=t.useLesserThanEqualOperation=t.useLesserThanOperation=t.useGreaterThanEqualOperation=t.useGreaterThanOperation=t.useEqualsOperation=void 0,t.useEqualsOperation=function(e){return t=>({isValid:t===e.number})},t.useGreaterThanOperation=function(e){return t=>({isValid:t>e.number})},t.useGreaterThanEqualOperation=function(e){return t=>({isValid:t>=e.number})},t.useLesserThanOperation=function(e){return t=>({isValid:t<e.number})},t.useLesserThanEqualOperation=function(e){return t=>({isValid:t<=e.number})},t.useBetweenNumericOperation=function(e){return t=>({isValid:t>=e.start&&t<=e.end})}},5168:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericSanitizersMapper=t.sanitizeNumericRange=t.sanitizeSingleNumber=void 0;const n=a(2752),s=e=>"number"==typeof e;t.sanitizeSingleNumber=e=>{const t=void 0!==e.number&&s(e.number)?{number:e.number}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.sanitizeNumericRange=e=>{const t=void 0!==e.start&&void 0!==e.end&&s(e.start)&&s(e.end)?{start:e.start,end:e.end}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.NumericSanitizersMapper={[n.OperationEnum.Equal]:t.sanitizeSingleNumber,[n.OperationEnum.GreaterThan]:t.sanitizeSingleNumber,[n.OperationEnum.GreaterThanEqual]:t.sanitizeSingleNumber,[n.OperationEnum.LesserThan]:t.sanitizeSingleNumber,[n.OperationEnum.LesserThanEqual]:t.sanitizeSingleNumber,[n.OperationEnum.BetweenNumeric]:t.sanitizeNumericRange}},7695:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5018:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.StringOperationsMapper=void 0;const i=a(2752),o=a(5154);s(a(5154),t),s(a(4503),t),t.StringOperationsMapper={[i.OperationEnum.StartsWith]:e=>(0,o.useStartsWithOperation)(e),[i.OperationEnum.EndsWith]:e=>(0,o.useEndsWithOperation)(e),[i.OperationEnum.Contains]:e=>(0,o.useContainsOperation)(e),[i.OperationEnum.InList]:e=>(0,o.useInListOperation)(e),[i.OperationEnum.Matches]:e=>(0,o.useMatchesOperation)(e)}},5154:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useMatchesOperation=t.useInListOperation=t.useContainsOperation=t.useEndsWithOperation=t.useStartsWithOperation=void 0,t.useStartsWithOperation=function(e){return t=>({isValid:e.list.some((e=>t.startsWith(e)))})},t.useEndsWithOperation=function(e){return t=>({isValid:e.list.some((e=>t.endsWith(e)))})},t.useContainsOperation=function(e){return t=>({isValid:e.list.some((e=>t.includes(e)))})},t.useInListOperation=function(e){return t=>({isValid:e.list.includes(t)})},t.useMatchesOperation=function(e){return t=>{let a;try{a=new RegExp(e.string)}catch(e){return{isValid:!1}}return{isValid:a.test(t)}}}},1016:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSanitizersMapper=t.sanitizeListString=t.sanitizeSingleString=void 0;const n=a(2752),s=e=>"string"==typeof e;t.sanitizeSingleString=e=>{const t=void 0!==e.string&&s(e.string)?{string:e.string}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.sanitizeListString=e=>{const t=void 0!==e.list&&e.list.every((e=>s(e)))?{list:e.list}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.StringSanitizersMapper={[n.OperationEnum.Matches]:t.sanitizeSingleString,[n.OperationEnum.Contains]:t.sanitizeListString,[n.OperationEnum.StartsWith]:t.sanitizeListString,[n.OperationEnum.EndsWith]:t.sanitizeListString,[n.OperationEnum.InList]:t.sanitizeListString}},4503:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2752:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),s(a(7158),t)},7158:(e,t)=>{"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.OperationEnum=void 0,(a=t.OperationEnum||(t.OperationEnum={})).InList="in_list",a.StartsWith="starts_with",a.EndsWith="ends_with",a.Contains="contains",a.Matches="matches",a.Equal="equal",a.GreaterThan="greater_than",a.GreaterThanEqual="greater_than_equal",a.LesserThan="lower_than",a.LesserThanEqual="lower_than_equal",a.BetweenNumeric="between_numeric",a.Is="is",a.On="on",a.BetweenDate="between_date",a.OnOrAfter="on_or_after",a.OnOrBefore="on_or_before"},3856:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),s(a(6334),t)},6334:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluatePlan=void 0;const n=a(9243);t.evaluatePlan=function(e,t){const a=function(e,t){var a;return null===(a=e.rules)||void 0===a?void 0:a.find((e=>(0,n.createRuleEvaluator)({rule:e})(t)===n.RuleEvaluationResultEnum.Treatable))}(e,t);return a?{treatment:a.treatment}:{treatment:e.defaultTreatment}}},9243:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),s(a(5546),t),s(a(4874),t)},4874:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createRuleEvaluator=void 0;const n=a(5546),s=a(9838);t.createRuleEvaluator=function(e){return t=>e.rule.conditions.every((e=>(0,s.createConditionEvaluator)({condition:e})(t)))?n.RuleEvaluationResultEnum.Treatable:n.RuleEvaluationResultEnum.Insufficient}},5546:(e,t)=>{"use strict";var a,n;Object.defineProperty(t,"__esModule",{value:!0}),t.RuleEvaluationResultEnum=t.TreatmentEnum=t.ConditionLogicEnum=void 0,(t.ConditionLogicEnum||(t.ConditionLogicEnum={})).And="and",(n=t.TreatmentEnum||(t.TreatmentEnum={})).True="true",n.False="false",(a=t.RuleEvaluationResultEnum||(t.RuleEvaluationResultEnum={})).Treatable="treatable",a.Insufficient="insufficient"},7254:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),s(a(7416),t),s(a(3817),t),s(a(395),t),s(a(6816),t)},1711:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.directEntitlementEvalutor=void 0;const n=a(395);t.directEntitlementEvalutor=function(e,t,a={}){const s=t.features[e];let i=!1;return s&&null!==s.expireTime&&(i=s.expireTime!==n.NO_EXPIRATION_TIME&&s.expireTime<Date.now(),!i)?{isEntitled:!0}:{isEntitled:!1,justification:i?n.NotEntitledJustification.BUNDLE_EXPIRED:n.NotEntitledJustification.MISSING_FEATURE}}},1343:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.featureFlagEvaluator=void 0;const n=a(395),s=a(2152),i=a(8552),o=a(9243);t.featureFlagEvaluator=function(e,t,a={}){const r=t.features[e];if(r&&r.featureFlag){const e=(0,i.prepareAttributes)(a),{treatment:t}=(0,s.evaluateFeatureFlag)(r.featureFlag,e);if(t===o.TreatmentEnum.True)return{isEntitled:!0}}return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE}}},2031:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getIsEntitledEvaluators=void 0;const n=a(1711),s=a(1343),i=a(3155);t.getIsEntitledEvaluators=function(){return[n.directEntitlementEvalutor,s.featureFlagEvaluator,i.planTargetingRulesEvalutor]}},3155:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.planTargetingRulesEvalutor=void 0;const n=a(395),s=a(8552),i=a(9243),o=a(3856);t.planTargetingRulesEvalutor=function(e,t,a={}){const r=t.features[e];if(r&&r.planIds&&r.planIds.length>0){const e=(0,s.prepareAttributes)(a),n=t.plans;for(const t of r.planIds){const a=n[t];if(a){const{treatment:t}=(0,o.evaluatePlan)(a,e);if(t===i.TreatmentEnum.True)return{isEntitled:!0}}}}return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE}}},7416:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),s(a(9398),t)},9398:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateIsEntitledToFeature=void 0;const n=a(395),s=a(6816),i=a(2031);t.evaluateIsEntitledToFeature=function(e,t,a={}){if(!t)return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE};const o=[];for(const n of(0,i.getIsEntitledEvaluators)())if(o.push(n(e,t,a)),!(0,s.shouldContinue)(o))break;return(0,s.getResult)(o)}},3817:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),s(a(1474),t)},1474:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateIsEntitledToPermissions=void 0;const n=a(9398),s=a(395),i=a(6816),o=a(7943);t.evaluateIsEntitledToPermissions=function(e,t,a){if(!t)return{isEntitled:!1,justification:s.NotEntitledJustification.MISSING_PERMISSION};if(!(0,o.checkPermission)(t.permissions,e))return{isEntitled:!1,justification:s.NotEntitledJustification.MISSING_PERMISSION};const r=function(e,t){return Object.keys(t.features).filter((a=>t.features[a].linkedPermissions.includes(e)))}(e,t);if(!r.length)return{isEntitled:!0};const l=[];for(const e of r)if(l.push((0,n.evaluateIsEntitledToFeature)(e,t,a)),!(0,i.shouldContinue)(l))break;return(0,i.getResult)(l)}},395:(e,t)=>{"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.NO_EXPIRATION_TIME=t.NotEntitledJustification=void 0,(a=t.NotEntitledJustification||(t.NotEntitledJustification={})).MISSING_FEATURE="MISSING_FEATURE",a.MISSING_PERMISSION="MISSING_PERMISSION",a.BUNDLE_EXPIRED="BUNDLE_EXPIRED",t.NO_EXPIRATION_TIME=-1},8552:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modifyObjectKeysWithPrefix=t.defaultFronteggAttributesMapper=t.prepareAttributes=void 0;const n=a(1857);function s(e){return{email:e.email,emailVerified:e.email_verified,tenantId:e.tenantId,userId:e.id}}function i(e,t){return Object.keys(e).reduce(((a,n)=>(a[`${t}${n}`]=e[n],a)),{})}t.prepareAttributes=function(e={},t){const{custom:a={},jwt:o={}}=e,r=(0,n.flatten)(o);return{...a,...i(t?t(o):s(o),"frontegg."),...i(r,"jwt.")}},t.defaultFronteggAttributesMapper=s,t.modifyObjectKeysWithPrefix=i},8843:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shouldContinue=t.getResult=void 0;const n=a(395);t.getResult=function(e){let t=!1;for(const a of e){if(a.isEntitled)return a;a.justification===n.NotEntitledJustification.BUNDLE_EXPIRED&&(t=!0)}return{isEntitled:!1,justification:t?n.NotEntitledJustification.BUNDLE_EXPIRED:n.NotEntitledJustification.MISSING_FEATURE}},t.shouldContinue=function(e){return e.every((({isEntitled:e})=>!e))}},1857:(e,t)=>{"use strict";function a(e){return e}Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0,t.flatten=function(e,t){const n=(null==(t=t||{})?void 0:t.delimiter)||".",s=null==t?void 0:t.maxDepth,i=(null==t?void 0:t.transformKey)||a,o={};return function e(a,r,l){l=l||1,Object.keys(a).forEach((function(c){const u=a[c],d=(null==t?void 0:t.safe)&&Array.isArray(u),g=Object.prototype.toString.call(u),p=(h=u)&&h.constructor&&"function"==typeof h.constructor.isBuffer&&h.constructor.isBuffer(h);var h;const y="[object Object]"===g||"[object Array]"===g,v=r?r+n+i(c):i(c);if(!d&&!p&&y&&Object.keys(u).length&&(!(null==t?void 0:t.maxDepth)||s&&l<s))return e(u,v,l+1);o[v]=u}))}(e),o}},6816:function(e,t,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,s)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),s=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||n(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),s(a(7943),t),s(a(8552),t),s(a(8843),t)},7943:(e,t)=>{"use strict";function a(e){return new RegExp("^"+e.replace(/\./g,"\\.").replace(/\*/g,".*")+"$","gs")}Object.defineProperty(t,"__esModule",{value:!0}),t.createPermissionCheckRegex=t.checkPermission=void 0,t.checkPermission=function(e,t){return Object.keys(e).some((e=>a(e).test(t)))},t.createPermissionCheckRegex=a},2743:e=>{"use strict";var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===a}(e)}(e)},a="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?r((a=e,Array.isArray(a)?[]:{}),e,t):e;var a}function s(e,t,a){return e.concat(t).map((function(e){return n(e,a)}))}function i(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function r(e,a,l){(l=l||{}).arrayMerge=l.arrayMerge||s,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=n;var c=Array.isArray(a);return c===Array.isArray(e)?c?l.arrayMerge(e,a,l):function(e,t,a){var s={};return a.isMergeableObject(e)&&i(e).forEach((function(t){s[t]=n(e[t],a)})),i(t).forEach((function(i){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(o(e,i)&&a.isMergeableObject(t[i])?s[i]=function(e,t){if(!t.customMerge)return r;var a=t.customMerge(e);return"function"==typeof a?a:r}(i,a)(e[i],t[i],a):s[i]=n(t[i],a))})),s}(e,a,l):n(a,l)}r.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,a){return r(e,a,t)}),{})};var l=r;e.exports=l},8792:e=>{"use strict";e.exports=function e(t,a){if(t===a)return!0;if(t&&a&&"object"==typeof t&&"object"==typeof a){if(t.constructor!==a.constructor)return!1;var n,s,i;if(Array.isArray(t)){if((n=t.length)!=a.length)return!1;for(s=n;0!=s--;)if(!e(t[s],a[s]))return!1;return!0}if(t.constructor===RegExp)return t.source===a.source&&t.flags===a.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===a.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===a.toString();if((n=(i=Object.keys(t)).length)!==Object.keys(a).length)return!1;for(s=n;0!=s--;)if(!Object.prototype.hasOwnProperty.call(a,i[s]))return!1;for(s=n;0!=s--;){var o=i[s];if(!e(t[o],a[o]))return!1}return!0}return t!=t&&a!=a}},5302:(e,t,a)=>{const n=a(9537);function s(e,t,a){return"function"==typeof a.join?a.join(e):e[0]+t+e[1]}function i(e,t,a){return"function"!=typeof a.isValid||a.isValid(e,t)}function o(e){return n(e)||Array.isArray(e)||"function"==typeof e}e.exports=function(e,t,a){if(n(a)||(a={default:a}),!o(e))return void 0!==a.default?a.default:e;"number"==typeof t&&(t=String(t));const r=Array.isArray(t),l="string"==typeof t,c=a.separator||".",u=a.joinChar||("string"==typeof c?c:".");if(!l&&!r)return e;if(l&&t in e)return i(t,e,a)?e[t]:a.default;let d=r?t:function(e,t,a){return"function"==typeof a.split?a.split(e):e.split(t)}(t,c,a),g=d.length,p=0;do{let t=d[p];for("number"==typeof t&&(t=String(t));t&&"\\"===t.slice(-1);)t=s([t.slice(0,-1),d[++p]||""],u,a);if(t in e){if(!i(t,e,a))return a.default;e=e[t]}else{let n=!1,o=p+1;for(;o<g;)if(t=s([t,d[o++]],u,a),n=t in e){if(!i(t,e,a))return a.default;e=e[t],p=o-1;break}if(!n)return a.default}}while(++p<g&&o(e));return p===g?e:a.default}},2685:(e,t,a)=>{"use strict";var n=a(9537);function s(e){return!0===n(e)&&"[object Object]"===Object.prototype.toString.call(e)}e.exports=function(e){var t,a;return!1!==s(e)&&"function"==typeof(t=e.constructor)&&!1!==s(a=t.prototype)&&!1!==a.hasOwnProperty("isPrototypeOf")}},5858:e=>{"use strict";e.exports=function(e){return"object"==typeof e?null===e:"function"!=typeof e}},9537:e=>{"use strict";e.exports=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}},1098:(e,t,a)=>{"use strict";const{deleteProperty:n}=Reflect,s=a(5858),i=a(2685),o=e=>"object"==typeof e&&null!==e||"function"==typeof e,r=e=>{if(!s(e))throw new TypeError("Object keys must be strings or symbols");if((e=>"__proto__"===e||"constructor"===e||"prototype"===e)(e))throw new Error(`Cannot set unsafe key: "${e}"`)},l=(e,t)=>t&&"function"==typeof t.split?t.split(e):"symbol"==typeof e?[e]:Array.isArray(e)?e:((e,t,a)=>{const n=(e=>Array.isArray(e)?e.flat().map(String).join(","):e)(t?((e,t)=>{if("string"!=typeof e||!t)return e;let a=e+";";return void 0!==t.arrays&&(a+=`arrays=${t.arrays};`),void 0!==t.separator&&(a+=`separator=${t.separator};`),void 0!==t.split&&(a+=`split=${t.split};`),void 0!==t.merge&&(a+=`merge=${t.merge};`),void 0!==t.preservePaths&&(a+=`preservePaths=${t.preservePaths};`),a})(e,t):e);r(n);const s=u.cache.get(n)||a();return u.cache.set(n,s),s})(e,t,(()=>((e,t={})=>{const a=t.separator||".",n="/"!==a&&t.preservePaths;if("string"==typeof e&&!1!==n&&/\//.test(e))return[e];const s=[];let i="";const o=e=>{let t;""!==e.trim()&&Number.isInteger(t=Number(e))?s.push(t):s.push(e)};for(let t=0;t<e.length;t++){const n=e[t];"\\"!==n?n!==a?i+=n:(o(i),i=""):i+=e[++t]}return i&&o(i),s})(e,t))),c=(e,t,a,s)=>{if(r(t),void 0===a)n(e,t);else if(s&&s.merge){const n="function"===s.merge?s.merge:Object.assign;n&&i(e[t])&&i(a)?e[t]=n(e[t],a):e[t]=a}else e[t]=a;return e},u=(e,t,a,n)=>{if(!t||!o(e))return e;const s=l(t,n);let i=e;for(let e=0;e<s.length;e++){const t=s[e],l=s[e+1];if(r(t),void 0===l){c(i,t,a,n);break}"number"!=typeof l||Array.isArray(i[t])?(o(i[t])||(i[t]={}),i=i[t]):i=i[t]=[]}return e};u.split=l,u.cache=new Map,u.clear=()=>{u.cache=new Map},e.exports=u},7048:(e,t,a)=>{var n=a(4319).default;function s(){"use strict";e.exports=s=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},a=Object.prototype,i=a.hasOwnProperty,o=Object.defineProperty||function(e,t,a){e[t]=a.value},r="function"==typeof Symbol?Symbol:{},l=r.iterator||"@@iterator",c=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";function d(e,t,a){return Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{d({},"")}catch(e){d=function(e,t,a){return e[t]=a}}function g(e,t,a,n){var s=t&&t.prototype instanceof y?t:y,i=Object.create(s.prototype),r=new k(n||[]);return o(i,"_invoke",{value:E(e,a,r)}),i}function p(e,t,a){try{return{type:"normal",arg:e.call(t,a)}}catch(e){return{type:"throw",arg:e}}}t.wrap=g;var h={};function y(){}function v(){}function S(){}var f={};d(f,l,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(_([])));b&&b!==a&&i.call(b,l)&&(f=b);var A=S.prototype=y.prototype=Object.create(f);function w(e){["next","throw","return"].forEach((function(t){d(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function a(s,o,r,l){var c=p(e[s],e,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==n(d)&&i.call(d,"__await")?t.resolve(d.__await).then((function(e){a("next",e,r,l)}),(function(e){a("throw",e,r,l)})):t.resolve(d).then((function(e){u.value=e,r(u)}),(function(e){return a("throw",e,r,l)}))}l(c.arg)}var s;o(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,s){a(e,n,t,s)}))}return s=s?s.then(i,i):i()}})}function E(e,t,a){var n="suspendedStart";return function(s,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===s)throw i;return{value:void 0,done:!0}}for(a.method=s,a.arg=i;;){var o=a.delegate;if(o){var r=P(o,a);if(r){if(r===h)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===n)throw n="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);n="executing";var l=p(e,t,a);if("normal"===l.type){if(n=a.done?"completed":"suspendedYield",l.arg===h)continue;return{value:l.arg,done:a.done}}"throw"===l.type&&(n="completed",a.method="throw",a.arg=l.arg)}}}function P(e,t){var a=t.method,n=e.iterator[a];if(void 0===n)return t.delegate=null,"throw"===a&&e.iterator.return&&(t.method="return",t.arg=void 0,P(e,t),"throw"===t.method)||"return"!==a&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+a+"' method")),h;var s=p(n,e.iterator,t.arg);if("throw"===s.type)return t.method="throw",t.arg=s.arg,t.delegate=null,h;var i=s.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function _(e){if(e){var t=e[l];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,n=function t(){for(;++a<e.length;)if(i.call(e,a))return t.value=e[a],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:U}}function U(){return{value:void 0,done:!0}}return v.prototype=S,o(A,"constructor",{value:S,configurable:!0}),o(S,"constructor",{value:v,configurable:!0}),v.displayName=d(S,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,d(e,u,"GeneratorFunction")),e.prototype=Object.create(A),e},t.awrap=function(e){return{__await:e}},w(T.prototype),d(T.prototype,c,(function(){return this})),t.AsyncIterator=T,t.async=function(e,a,n,s,i){void 0===i&&(i=Promise);var o=new T(g(e,a,n,s),i);return t.isGeneratorFunction(a)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},w(A),d(A,u,"Generator"),d(A,l,(function(){return this})),d(A,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),a=[];for(var n in t)a.push(n);return a.reverse(),function e(){for(;a.length;){var n=a.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=_,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function a(a,n){return o.type="throw",o.arg=e,t.next=a,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var r=i.call(s,"catchLoc"),l=i.call(s,"finallyLoc");if(r&&l){if(this.prev<s.catchLoc)return a(s.catchLoc,!0);if(this.prev<s.finallyLoc)return a(s.finallyLoc)}else if(r){if(this.prev<s.catchLoc)return a(s.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return a(s.finallyLoc)}}}},abrupt:function(e,t){for(var a=this.tryEntries.length-1;a>=0;--a){var n=this.tryEntries[a];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var s=n;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=e,o.arg=t,s?(this.method="next",this.next=s.finallyLoc,h):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var a=this.tryEntries[t];if(a.finallyLoc===e)return this.complete(a.completion,a.afterLoc),O(a),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var a=this.tryEntries[t];if(a.tryLoc===e){var n=a.completion;if("throw"===n.type){var s=n.arg;O(a)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,a){return this.delegate={iterator:_(e),resultName:t,nextLoc:a},"next"===this.method&&(this.arg=void 0),h}},t}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports},4319:e=>{function t(a){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(a)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},5799:(e,t,a)=>{var n=a(7048)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},t={};function a(n){var s=t[n];if(void 0!==s)return s.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,a),i.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";a.r(n),a.d(n,{AdminPortal:()=>Eg,AdminPortalRenderer:()=>Og,AppHolder:()=>c,CheckoutDialog:()=>Pg,FronteggApp:()=>wg,HostedLogin:()=>Tg,LoginBoxRenderer:()=>Ug,createElement:()=>yg,defaultTheme:()=>kg,formatName:()=>hg,getOverriddenMetadata:()=>Ag,getThemeAdminByName:()=>Ig,getThemeByName:()=>_g,initialize:()=>Mg,mockFlagsList:()=>mg,restoreSearchParams:()=>Sg,waitThemeSetter:()=>vg});var e={};a.r(e),a.d(e,{ApplicationAccessType:()=>an,AuthStrategyEnum:()=>N,ContextHolder:()=>R,DirectoryApi:()=>ga,EIdentifierType:()=>x,FRONTEGG_SEPARATE_TABS_BY_TENANT:()=>it,FeatureFlags:()=>at,FeatureFlagsApi:()=>nt,FetchClient:()=>Ve,FronteggApiError:()=>z,FronteggContext:()=>C,FronteggFrameworks:()=>je,GENERIC_ERROR_CODE:()=>xe,GENERIC_ERROR_MESSAGE:()=>Fe,GetUsersFilterPreset:()=>qa,GroupManagedByEnum:()=>za,GroupRelations:()=>Ha,ISubscriptionCancellationPolicy:()=>B,ISubscriptionStatus:()=>G,InsightCode:()=>Qa,LOAD_AUTHORIZATION_FF:()=>Ze,MFAStrategyEnum:()=>Qe,MachineToMachineAuthStrategy:()=>M,NotEntitledJustification:()=>Ya,PaginationOrderEnum:()=>Be,PasswordRecoveryStrategyEnum:()=>$,PaymentMethodType:()=>j,PermissionAssignmentTypeEnum:()=>Na,ProviderType:()=>V,RecommendationActionKey:()=>Za,RecommendationCode:()=>Xa,RecommendationSeverity:()=>en,RequestSource:()=>Ge,RestrictionType:()=>Je,ScimConnectionSource:()=>Wa,SecondaryAuthStrategy:()=>Ye,SecurityCategory:()=>tn,SignUpStrategyEnum:()=>F,SocialLoginProviders:()=>D,SortByEnum:()=>Ka,SubAccountAccessTypeEnum:()=>Ma,TenantSortByEnum:()=>Ca,TenantType:()=>Da,UserManagedByEnum:()=>La,WebAuthnDeviceType:()=>Xe,api:()=>nn,createApiClient:()=>sn,default:()=>on,fetch:()=>We,fronteggAuthApiRoutesRegex:()=>Fa,fronteggEntitlementsV2Url:()=>Va,fronteggHeaders:()=>$e,fronteggRefreshTokenUrl:()=>xa,fronteggSilentRefreshTokenUrl:()=>$a,fronteggTenantsUrl:()=>ja,fronteggTenantsV3Url:()=>Ba,fronteggUsersUrl:()=>Ga,getCurrentUserTenantsFunction:()=>gt,getTabTenantFromSessionStorage:()=>dt,providersArray:()=>Ja,removeTabTenantFromSessionStorage:()=>ut,setTabTenantInSessionStorage:()=>ct});var t={};a.r(t),a.d(t,{ACR_VALUE:()=>Sn,AMR_ADDITIONAL_VALUE:()=>mn,AMR_MFA_VALUE:()=>fn,AcceptInvitationStep:()=>un,ActivateAccountStep:()=>qn,AdminPortalPages:()=>ts,AdminPortalPagesForEvents:()=>es,AllAccountsStateKeys:()=>zo,ApiStateKeys:()=>Ws,AuthStrategyEnum:()=>N,AuthenticationTypes:()=>Zn,DEFAULT_RETRY_CONFIG:()=>Un,EditEmailView:()=>oc,FRONTEGG_AFTER_AUTH_REDIRECT_URL:()=>kn,ForgotPasswordStep:()=>ei,FronteggNativeModule:()=>v,GTMEventAction:()=>as,GroupRelations:()=>gi,GroupsStateKeys:()=>di,HOSTED_LOGIN_VERIFIER_KEY:()=>_n,ImpersonateStep:()=>fi,LoginActionTypes:()=>Pn,LoginFlow:()=>Tn,LoginStep:()=>wn,MFAStep:()=>ns,MachineToMachineAuthStrategy:()=>M,PasswordRotationStep:()=>ii,PaymentMethodType:()=>fc,PaymentProvider:()=>Ac,QuickLoginStrategy:()=>En,REQUEST_NAME:()=>Xn,ResetPhoneNumberStep:()=>pr,RolesStateKeys:()=>wr,SHOULD_STEP_UP_KEY:()=>bn,SSOStateKeys:()=>po,STEP_UP_MAX_AGE_PARAM_NAME:()=>An,SamlVendors:()=>ho,SecurityCenterStateKeys:()=>$r,SignUpStage:()=>nl,SubscriptionCancellationPolicy:()=>Tc,SubscriptionStatus:()=>wc,TENANT_ID_PARAM_KEY:()=>us,TeamStateKeys:()=>Us,UserVerifiedOriginTypes:()=>Qn,authStrategyLoginStepMap:()=>In,base64ToFormData:()=>Ni,base64urlDecode:()=>Di,base64urlEncode:()=>Ci,buildAuditsActions:()=>uu,buildAuthActions:()=>uc,buildConnectivityActions:()=>Sc,buildSubscriptionsActions:()=>Zc,buildVendorActions:()=>au,createAuditsState:()=>cu,createAuthState:()=>cc,createConnectivityState:()=>gc,createFronteggStore:()=>xd,createProxy:()=>cn,createRandomString:()=>no,createStore:()=>$d,createSubscriptionsState:()=>Qc,createVendorState:()=>tu,deepClone:()=>xn,deepResetState:()=>$n,defaultFronteggRoutes:()=>On,delay:()=>Rn,errorHandler:()=>Bn,errorTraceId:()=>Nn,generateCodeChallenge:()=>ao,generateCodeChallengeNative:()=>to,generateCodeChallengePureJs:()=>eo,getBaseNameWithoutSlashSuffix:()=>Ss,getEntitlements:()=>uo,getFeatureEntitlements:()=>co,getMfaStepForEnrolledUsers:()=>gs,getMfaStepForNotEnrolledUsers:()=>ps,getNumberOfMfaDevices:()=>ds,getPathAndSearchParamsFromUrl:()=>ls,getPermissionEntitlements:()=>lo,getRedirectUrl:()=>os,getSearchParam:()=>cs,getSearchParamsFromUrl:()=>rs,getUri:()=>Os,hmac:()=>Zi,isAbsoluteUrl:()=>is,isAuthRoute:()=>_s,isEmailPayload:()=>ys,isEntitlementsDeeplyEqual:()=>go,isError:()=>jn,isFronteggApiError:()=>Gn,isMfaRequired:()=>Es,isOauthCallbackRoute:()=>hs,isProxy:()=>Fn,isResetPasswordRequired:()=>Ps,isSteppedUp:()=>ms,isUsernamePayload:()=>vs,mapMetaDataObjectToActions:()=>Is,omitProps:()=>Mn,prepareIdentifiersForSignup:()=>ks,publicKeyCredentialToJSON:()=>Mi,readFileAsText:()=>Fi,redirectByStepUpUrl:()=>As,reportGTMEvent:()=>ss,retry:()=>Ln,retryIfNeeded:()=>Cn,setAfterAuthRedirectUrlForStepUp:()=>bs,sha256:()=>Qi,shouldShowPasswordRotationPromptFunc:()=>fs,snapshot:()=>k,subscribe:()=>O,withRetryConfig:()=>Dn});var s={};function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(s=n.key,i=void 0,i=function(e){if("object"!==o(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var a=t.call(e,"string");if("object"!==o(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(s),"symbol"===o(i)?i:String(i)),n)}var s,i}function l(e,t,a){return t&&r(e.prototype,t),a&&r(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e}a.r(s),a.d(s,{AccountDetailsPageTabs:()=>Zd,AccountPageFields:()=>Hd,COUNTRY_FILTER_TYPE:()=>jd,DomainRestrictionsTabFields:()=>Qd,GeneralSettingsTabFields:()=>Yd,InviteUserModalFields:()=>Wd,IpRestrictionsTabFields:()=>Xd,Metadata:()=>pg,PrivacyPageFields:()=>Vd,ProfilePageFields:()=>Bd,SecurityPageTabs:()=>qd,SessionManagementTabFields:()=>Jd,SignupFields:()=>Gd,SubscriptionsPageFields:()=>Kd,UsersTableColumns:()=>zd,alpha:()=>og,fieldAppearance:()=>eg,tabAppearance:()=>tg});var c=function(){function e(){i(this,e)}return l(e,null,[{key:"setInstance",value:function(t,a){e._apps[t]=a}},{key:"getInstance",value:function(t){var a=e._apps[t];if(!a)throw Error("[".concat(t,"] FronteggApp not found"));return a}}]),e}();function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,s,i,o,r=[],l=!0,c=!1;try{if(i=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;l=!1}else for(;!(l=(n=i.call(a)).done)&&(r.push(n.value),r.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=a.return&&(o=a.return(),Object(o)!==o))return}finally{if(c)throw s}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?u(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t,a,n,s,i,o){try{var r=e[i](o),l=r.value}catch(e){return void a(e)}r.done?t(l):Promise.resolve(l).then(n,s)}function p(e){return function(){var t=this,a=arguments;return new Promise((function(n,s){var i=e.apply(t,a);function o(e){g(i,n,s,o,r,"next",e)}function r(e){g(i,n,s,o,r,"throw",e)}o(void 0)}))}}c._apps={};var h=a(5799),y=a.n(h);const v=new class{constructor(){this.backToLoginImpl=void 0,this.loginWithSSO=e=>{if(this.isIOSNativeBridgeAvailable()){var t,a,n;null==(t=window.webkit)||null==(a=t.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSSO",payload:e}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSSO(e)}},this.loginWithSocialLogin=e=>{if(this.isIOSNativeBridgeAvailable()){var t,a,n;null==(t=window.webkit)||null==(a=t.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSocialLogin",payload:e}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSocialLogin(e)}},this.loginWithSocialLoginProvider=e=>{if(this.isIOSNativeBridgeAvailable()){var t,a,n;null==(t=window.webkit)||null==(a=t.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSocialLoginProvider",payload:e}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSocialLoginProvider(e)}},this.loginWithCustomSocialLoginProvider=e=>{if(this.isIOSNativeBridgeAvailable()){var t,a,n;null==(t=window.webkit)||null==(a=t.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithCustomSocialLoginProvider",payload:e}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithCustomSocialLoginProvider(e)}},this.suggestSavePassword=(e,t)=>{if(this.isIOSNativeBridgeAvailable()){var a,n,s;null==(a=window.webkit)||null==(n=a.messageHandlers)||null==(s=n.FronteggNativeBridge)||s.postMessage(JSON.stringify({action:"suggestSavePassword",payload:JSON.stringify({email:e,password:t})}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var i;null==(i=window.FronteggNativeBridge)||i.suggestSavePassword(e,t)}},this.promptSocialLoginConsent=()=>{var e,t;return null!=(e=null==(t=window.FronteggNativeBridgeFunctions)?void 0:t.shouldPromptSocialLoginConsent)&&e}}isIOSNativeBridgeAvailable(){var e,t;return null!=(null==(e=window.webkit)||null==(t=e.messageHandlers)?void 0:t.FronteggNativeBridge)}isAndroidNativeBridgeAvailable(){return null!=window.FronteggNativeBridge}isExternalMobileBrowser(){return null!==sessionStorage.getItem("frontegg_external_mobile_browser")&&null!=this.backToLoginImpl}setBackToLogin(e){this.backToLoginImpl=e}backToLogin(){this.backToLoginImpl&&this.backToLoginImpl()}isSocialLoginAvailable(){return this.isAvailable("loginWithSocialLogin")}isSocialLoginProviderAvailable(){return this.isAvailable("loginWithSocialLoginProvider")}isCustomSocialLoginProviderAvailable(){return this.isAvailable("loginWithCustomSocialLoginProvider")}isLoginWithSSOAvailable(){return this.isAvailable("loginWithSSO")}isSuggestSavePasswordAvailable(){return this.isAvailable("suggestSavePassword")}isAvailable(e){var t,a;return!(!this.isIOSNativeBridgeAvailable()&&!this.isAndroidNativeBridgeAvailable())&&null!=(t=null==(a=window.FronteggNativeBridgeFunctions)?void 0:a[e])&&t}};function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},S.apply(this,arguments)}function f(e,t){if(null==e)return{};var a,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||(s[a]=e[a]);return s}Symbol();const m=Symbol(),b=Object.getPrototypeOf,A=new WeakMap,w=(e,t=!0)=>{A.set(e,t)},T=e=>"object"==typeof e&&null!==e,E=new WeakMap,P=new WeakSet;const[I]=function(e=Object.is,t=(e,t)=>new Proxy(e,t),a=e=>T(e)&&!P.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer),n=e=>{switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e}},s=new WeakMap,i=(e,t,a=n)=>{const o=s.get(e);if((null==o?void 0:o[0])===t)return o[1];const r=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return w(r,!0),s.set(e,[t,r]),Reflect.ownKeys(e).forEach((t=>{if(Object.getOwnPropertyDescriptor(r,t))return;const n=Reflect.get(e,t),{enumerable:s}=Reflect.getOwnPropertyDescriptor(e,t),o={value:n,enumerable:s,configurable:!0};if(P.has(n))w(n,!1);else if(n instanceof Promise)delete o.value,o.get=()=>a(n);else if(E.has(n)){const[e,t]=E.get(n);o.value=i(e,t(),a)}Object.defineProperty(r,t,o)})),Object.preventExtensions(r)},o=new WeakMap,r=[1,1],l=n=>{if(!T(n))throw new Error("object required");const s=o.get(n);if(s)return s;let c=r[0];const u=new Set,d=(e,t=++r[0])=>{c!==t&&(c=t,u.forEach((a=>a(e,t))))};let g=r[1];const p=e=>(t,a)=>{const n=[...t];n[1]=[e,...n[1]],d(n,a)},h=new Map,y=e=>{const t=h.get(e);var a;t&&(h.delete(e),null==(a=t[1])||a.call(t))},v=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),S=t(v,{deleteProperty(e,t){const a=Reflect.get(e,t);y(t);const n=Reflect.deleteProperty(e,t);return n&&d(["delete",[t],a]),n},set(t,n,s,i){const r=Reflect.has(t,n),c=Reflect.get(t,n,i);if(r&&(e(c,s)||o.has(s)&&e(c,o.get(s))))return!0;var g;y(n),T(s)&&(s=(e=>e&&(A.has(e)?A.get(e):b(e)===Object.prototype||b(e)===Array.prototype))(g=s)&&g[m]||s);let v=s;if(s instanceof Promise)s.then((e=>{s.status="fulfilled",s.value=e,d(["resolve",[n],e])})).catch((e=>{s.status="rejected",s.reason=e,d(["reject",[n],e])}));else{!E.has(s)&&a(s)&&(v=l(s));const e=!P.has(v)&&E.get(v);e&&((e,t)=>{if(u.size){const a=t[3](p(e));h.set(e,[t,a])}else h.set(e,[t])})(n,e)}return Reflect.set(t,n,v,i),d(["set",[n],s,c]),!0}});o.set(n,S);const f=[v,(e=++r[1])=>(g===e||u.size||(g=e,h.forEach((([t])=>{const a=t[1](e);a>c&&(c=a)}))),c),i,e=>(u.add(e),1===u.size&&h.forEach((([e,t],a)=>{const n=e[3](p(a));h.set(a,[e,n])})),()=>{u.delete(e),0===u.size&&h.forEach((([e,t],a)=>{t&&(t(),h.set(a,[e]))}))})];return E.set(S,f),Reflect.ownKeys(n).forEach((e=>{const t=Object.getOwnPropertyDescriptor(n,e);"value"in t&&(S[e]=n[e],delete t.value,delete t.writable),Object.defineProperty(v,e,t)})),S}){return[l,E,P,e,t,a,n,s,i,o,r]}();function O(e,t,a){const n=E.get(e);let s;const i=[],o=n[3];let r=!1;const l=o((e=>{i.push(e),a?t(i.splice(0)):s||(s=Promise.resolve().then((()=>{s=void 0,r&&t(i.splice(0))})))}));return r=!0,()=>{r=!1,l()}}function k(e,t){const a=E.get(e),[n,s,i]=a;return i(n,s(),t)}const _=["enabled","name"],U=Symbol();class R{constructor(){this.context=null,this.accessToken=null,this.user=null,this.requestSource=null,this.onRedirectTo=e=>window.location.href=e,this.logout=()=>window.location.href="/account/logout",this.entitlementsOptions=null,this.appName=null,this.sessionContext=void 0,this.basename=null,this.cdnUrl=null,this.assetsUrl=null,this.setContext=e=>{this.context=e},this.setAccessToken=e=>{this.accessToken=e},this.setUser=e=>{this.user=e},this.setRequestSource=e=>{this.requestSource=e},this.setOnRedirectTo=e=>{this.onRedirectTo=e},this.setLogout=e=>{this.logout=e},this.setEntitlementsOptions=e=>{this.entitlementsOptions=e},this.setSessionContext=e=>{this.sessionContext=e},this.setAppName=e=>{this.appName=e},this.getContext=()=>{var e;return null!=(e=this.context)?e:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}},this.getAccessToken=()=>this.accessToken,this.getRequestSource=()=>this.requestSource,this.getUser=()=>this.user,this.shouldLoadEntitlements=()=>{var e;return(null==(e=this.entitlementsOptions)?void 0:e.enabled)||!1},this.isSessionPerTenantEnabled=()=>{var e;return(null==(e=this.sessionContext)?void 0:e.enableSessionPerTenant)||!1},this.shouldSkipUserLoad=()=>{var e;return(null==(e=this.sessionContext)?void 0:e.skipUserLoading)||!1},this.getAppName=()=>this.appName,this.setCdnUrl=e=>{this.cdnUrl=e},this.getCdnUrl=()=>this.cdnUrl,this.setAssetsUrl=e=>{this.assetsUrl=e},this.getAssetsUrl=()=>this.assetsUrl}static default(){return R.getInstance(L)}static for(e){return R.getInstance(e)}static getInstance(e="default"){return R._apps||(R._apps={}),R._apps[e]||(R._apps[e]=new R),R._apps[e]}static createInstance(e="default"){return R._apps[e]=new R,R._apps[e].appName=e,R._apps[e]}static setContext(e,t="default"){R.for(t).context=e}static setAccessToken(e,t=L){R.for(t).accessToken=e}static setUser(e,t="default"){R.for(t).user=e}static setRequestSource(e,t="default"){R.for(t).requestSource=e}static setOnRedirectTo(e,t="default"){R.for(t).onRedirectTo=e}static setLogout(e,t,a="default"){const n=R.for(a);n.logout=a=>{a?e(a):n.onRedirectTo(t,void 0)}}static setEntitlementsOptions(e,t="default"){R.for(t).entitlementsOptions=e}static setSessionContext(e,t="default"){R.for(t).sessionContext=e}static setAppName(e){R.for(e).appName=e}static getContext(e="default"){var t;return null!=(t=R.for(e).context)?t:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}}static getAccessToken(e="default"){return R.for(e).accessToken}static getRequestSource(e="default"){return R.for(e).requestSource}static getBasename(e="default"){return R.for(e).basename}getBasename(){return this.basename}static setBasename(e,t=L){R.for(t).basename=e}setBasename(e){this.basename=e}static getUser(e="default"){return R.for(e).user}static onRedirectTo(e,t,a="default"){return R.for(a).onRedirectTo(e,t)}static logout(e,t="default"){return R.for(t).logout(e)}static shouldLoadEntitlements(e="default"){var t;return(null==(t=R.for(e).entitlementsOptions)?void 0:t.enabled)||!1}static isSessionPerTenantEnabled(e="default"){var t;return(null==(t=R.for(e).sessionContext)?void 0:t.enableSessionPerTenant)||!1}static getAppName(e="default"){return R.for(e).appName}}R._apps=void 0;const L="default",C={getContext:()=>R.getContext(L),getAccessToken:()=>R.getAccessToken(L),setAccessToken:e=>R.setAccessToken(e,L),getUser:()=>R.getUser(L),setUser:e=>R.setUser(e,L),onRedirectTo:(e,t)=>R.onRedirectTo(e,t,L),setOnRedirectTo:e=>R.setOnRedirectTo(e,L),logout:e=>R.logout(e,L),getRequestSource:()=>R.getRequestSource(L),setRequestSource:e=>R.setRequestSource(e,L),isSessionPerTenantEnabled:()=>R.isSessionPerTenantEnabled(L),shouldLoadEntitlements:()=>R.shouldLoadEntitlements(L),getAppName:()=>R.getAppName(L),setEntitlementsOptions:e=>R.setEntitlementsOptions(e,L),setSessionContext:e=>R.setSessionContext(e,L),getBasename:()=>R.getBasename(L),setBasename:e=>R.setBasename(e,L)};let D,N,M,F,x,$,G,j,B,V,W,H;!function(e){e.Microsoft="microsoft",e.Facebook="facebook",e.Google="google",e.Github="github",e.Slack="slack",e.Apple="apple",e.Linkedin="linkedin"}(D||(D={})),function(e){e.EmailAndPassword="EmailAndPassword",e.MagicLink="MagicLink",e.Code="Code",e.NoLocalAuthentication="NoLocalAuthentication",e.SmsCode="SmsCode",e.WebAuthN="WebAuthN",e.UsernameAndPassword="UsernameAndPassword",e.UsernameAndMagicLink="UsernameAndMagicLink",e.UsernameAndCode="UsernameAndCode",e.UsernameAndSms="UsernameAndSms"}(N||(N={})),function(e){e.ClientCredentials="ClientCredentials",e.AccessToken="AccessToken"}(M||(M={})),function(e){e.Email="email",e.PhoneNumber="phoneNumber"}(F||(F={})),function(e){e.email="email",e.phoneNumber="phoneNumber",e.username="username"}(x||(x={})),function(e){e.Email="email",e.Sms="sms"}($||($={})),function(e){e.ACTIVE="active",e.CANCELED="canceled",e.INCOMPLETE="incomplete",e.EXPIRED="expired",e.TRIALING="trialing",e.TRIAL_ENDED="trialEnded"}(G||(G={})),function(e){e.UNKNWON="unknown",e.CARD="card"}(j||(j={})),function(e){e.AT_PERIOD_END="atPeriodEnd"}(B||(B={})),function(e){e.Stripe="Stripe"}(V||(V={})),function(e){e.CHANGE_TO_DEFAULT="change_to_default",e.RETAIN_TRIAL="retain_trial"}(W||(W={})),function(e){e.CREATE="create_customer"}(H||(H={}));class z extends Error{constructor(e,t,a,n,s){super(e),this._statusCode=void 0,this._traceId=void 0,this._errorCode=void 0,this._errorContext=void 0,this._statusCode=t,this._traceId=a,this._errorCode=n,this._errorContext=s}get statusCode(){return this._statusCode}get traceId(){return this._traceId}get errorCode(){return this._errorCode}get errorContext(){return this._errorContext}}const K={v1:{strategies:"/identity/resources/configurations/v1/sign-up/strategies"}},q={v1:"/identity/resources/users/webauthn/v1/devices"},J={v1:"/identity/resources/auth/v1",v2:"/identity/resources/auth/v2"},Y={v1:"/identity/resources/users/v1",v2:"/identity/resources/users/v2",v3:"/identity/resources/users/v3",roles:{v3:"/identity/resources/users/v3/roles"},groups:{v3:"/identity/resources/users/v3/groups"},tenants:{me:{v1:"/identity/resources/users/v1/me/tenants",v3:"/identity/resources/users/v3/me/tenants"}},apiTokens:{v1:"/identity/resources/users/api-tokens/v1"},accessTokens:{v1:"/identity/resources/users/access-tokens/v1"},sessions:{v1:"/identity/resources/users/sessions/v1",currentUser:{v1:"/identity/resources/users/sessions/v1/me"},configurations:{v1:"/identity/resources/configurations/sessions/v1"}},invitation:{resendAll:{v1:"/identity/resources/users/v1/invitation/reset/all"}},passwords:{resetBreachedPasswords:{v1:"/identity/resources/users/v1/passwords/breached/reset/bulk"}},authorization:{v1:"/identity/resources/users/v1/me/authorization"},temporary:{v1:"/identity/resources/users/temporary/v1",configuration:{v1:"/identity/resources/users/temporary/v1/configuration"}}},X={v1:"/identity/resources/configurations/v1"},Q={emailDomain:{v1:"/identity/resources/configurations/restrictions/v1/email-domain"},ip:{v1:"/identity/resources/configurations/v1/restrictions/ip"}},Z={v1:"/identity/resources/sso/v1",v2:"/identity/resources/sso/v2",custom:{v1:"/identity/resources/sso/custom/v1"}},ee={v1:"/identity/resources/permissions/v1"},te={apiTokens:{v1:"/identity/resources/tenants/api-tokens/v1",v2:"/identity/resources/tenants/api-tokens/v2"},accessTokens:{v1:"/identity/resources/tenants/access-tokens/v1"},invites:{user:{v1:"/identity/resources/tenants/invites/v1/user"},verify:{v1:"/identity/resources/tenants/invites/v1/verify"},configuration:{v1:"/identity/resources/tenants/invites/v1/configuration"}},users:{v1:"/identity/resources/tenants/users/v1"}},ae={v1:"/identity/resources/roles/v1",v2:"/identity/resources/roles/v2"},ne={v1:"/identity/resources/sub-tenants/users/v1",v2:"/identity/resources/sub-tenants/users/v2"},se={v1:"/identity/resources/impersonation/v1"},ie={v1:"/identity/resources/applications/v1"},oe={v1:"/identity/resources/groups/v1",configurations:{v1:"/identity/resources/groups/v1/config"},getByIds:{v1:"/identity/resources/groups/v1/bulkGet"}},re={v1:"/identity/resources/users/phone-numbers/v1"},le={v1:"/identity/resources/usernames/v1"},ce={v1:"/team/resources/sso/v1",v2:"/team/resources/sso/v2"},ue={v1:"/team/resources/members/v1"},de={v1:"/team/resources/roles/v1"},ge={v1:"/team/resources/stats/v1"},pe={v1:"/team/resources/profile"},he={v1:"/tenants/resources/account-settings/v1"},ye={v1:"/tenants/resources/hierarchy/v1",tree:{v1:"/tenants/resources/hierarchy/v1/tree"},parents:{v1:"/tenants/resources/hierarchy/v1/parents"},v2:"/tenants/resources/hierarchy/v2",metadata:{v2:"/tenants/resources/hierarchy/v2/metadata"}},ve={v1:"/tenants/resources/sub-tenants/v1"},Se={v1:"/integrations/resources/configurations/v1",v2:"/integrations/resources/configurations/v2"},fe={subscriptions:{v1:"/subscriptions/resources/billing/subscriptions/v1"},plans:{v1:"/subscriptions/resources/billing/plans/v1"},invoices:{v1:"/subscriptions/resources/billing/invoices/v1"},paymentMethods:{v1:"/subscriptions/resources/billing/payment-methods/v1"},summaries:{v1:"/subscriptions/resources/billing/summaries/v1"},tenantConfiguration:{v1:"/subscriptions/resources/billing/tenant-configurations/v1"},configurations:{vendorPublicConfigurations:{v1:"/subscriptions/resources/billing/configurations/vendor-public-configurations/v1"}},paymentProviders:{stripe:{customers:{v1:"/subscriptions/resources/billing/payment-providers/stripe/customers/v1"},publicConfigurations:{v1:"/subscriptions/resources/billing/payment-providers/stripe/public-configurations/v1"},subscriptions:{v1:"/subscriptions/resources/billing/payment-providers/stripe/subscriptions/v1"},setupIntents:{v1:"/subscriptions/resources/billing/payment-providers/stripe/setup-intents/v1"}}}},me={v1:"/subscriptions/resources/payment-providers/v1"},be={v1:"/subscriptions/resources/subscriptions/v1"},Ae={v1:"/reports/resources/reports/v1",v2:"/reports/resources/reports/v2"},we={v1:"/reports/engine/resources/triggers/v1"},Te="/notification",Ee="/audits",Pe={v1:"/event/resources/configurations/v1"},Ie="/webhook",Oe="/oauth",ke="/flags",_e="/directory/resources/v1/configurations/scim2",Ue="/directory/resources/scim/temp",Re="/entitlements/api/v2/user-entitlements",Le={v1:"/security-center/resources/recommendations/v1"},Ce={v1:"/security-center/resources/insights/v1"},De="/applications/resources/applications/v1",Ne={v1:"/applications/resources/applications/tenant-assignments/v1"},Me="http://localhost:3037/resources/velo/v1",Fe="We're facing some difficulties, Please try again",xe="ER-ADMIN-PORTAL-GENERIC-ERROR",$e={frameWork:"x-frontegg-framework",fronteggSdkVersion:"x-frontegg-sdk",contentType:"Content-Type",source:"frontegg-source",scopedTenant:"frontegg-scoped-tenant"};let Ge,je,Be;!function(e){e.AdminPortal="admin-portal",e.LoginBox="login-box"}(Ge||(Ge={})),function(e){e.Nextjs="nextjs",e.React="react",e.Angular="angular",e.Vuejs="vuejs",e.Flutter="flutter",e.Ios="ios",e.Android="android",e.Vanillajs="vanillajs"}(je||(je={})),function(e){e.ASC="ASC",e.DESC="DESC"}(Be||(Be={}));class Ve{constructor(e){this.appName=void 0,this.getFronteggContext=()=>R.for(this.appName),this.prepareUrl=async(e,t)=>{const a=this.getFronteggContext().getContext(),n=this.getContextBaseUrl(e),s=await this.buildQueryParams(a,t);let i=e.startsWith("http")?e:`${n}${e}`;const o=Object.keys(s).length>0;return s&&o&&(i+=`?${new URLSearchParams(s)}`),i},this.buildQueryParams=async(e,t)=>{t||(t={});const a=await this.getAdditionalQueryParams(e);for(const e of a)t[e.key]=e.value;const n=Object.keys(t);for(const e of n){const a=t[e];t[e]="object"==typeof a?JSON.stringify(a):a}return t},this.getAdditionalQueryParams=async e=>{let t=[];return e.additionalQueryParamsResolver&&(t=await e.additionalQueryParamsResolver()),t},this.getAdditionalHeaders=async e=>{let t=[];if(e.additionalHeadersResolver&&(t=await e.additionalHeadersResolver()),e.tenantResolver){const a=await e.tenantResolver();null!=a&&a.tenant&&t.push({key:"frontegg-login-alias",value:a.tenant})}return e.appId&&t.push({key:"frontegg-requested-application-id",value:e.appId}),t},this.buildRequestHeaders=async e=>{var t;const a=this.getFronteggContext(),n=a.getContext(),s=Ve.getMetadataHeaders(n),i=await(null!=(t=null==n?void 0:n.tokenResolver)?t:a.getAccessToken)(),o=a.getRequestSource(),r=Ve.getScopedTenant();e&&(s[$e.contentType]=e),o&&(s[$e.source]=o),i&&(s.Authorization=`Bearer ${i}`),r&&(s[$e.scopedTenant]=r);for(const e of await this.getAdditionalHeaders(n))s[`${e.key}`]=`${e.value}`;return s},this.getResponseTraceId=e=>{var t,a;return null==e||null==(t=e.headers)||null==(a=t.get)?void 0:a.call(t,"frontegg-trace-id")},this.sendRequest=async e=>{var t,a,n;const s=this.getFronteggContext().getContext(),i=await this.buildRequestHeaders(e.contentType),o=await this.prepareUrl(e.url,e.params),r=s.beforeRequestInterceptor,l={body:e.body?"application/json"===e.contentType?JSON.stringify(e.body):e.body:null,method:null!=(t=e.method)?t:"GET",headers:S({},i,e.headers),credentials:null!=(a=null!=(n=e.credentials)?n:s.requestCredentials)?a:"same-origin"},c=r?r(l,o):l,u=await fetch(o,c);if(302===u.status)return window.location.href=await u.text(),new Promise((()=>{}));if(!u.ok){var d,g,p,h,y;if(413===u.status)throw new z("Error request is too large",u.status,this.getResponseTraceId(u),void 0);let e,t,a,n=!0;try{e=await u.text(),e=JSON.parse(e)}catch(e){n=!1}throw null!=(d=e)&&d.errorCode&&(t=e.errorCode),null!=(g=e)&&g.context&&"object"==typeof e.context&&(a=e.context),e.errors?e=e.errors.join(", "):"string"!=typeof e&&(e=`Error ${u.status} - ${u.statusText}`),u.status>=400&&u.status<500&&["warn"].includes(null!=(p=s.logLevel)?p:"")?console.warn(e):500===u.status&&["warn","error"].includes(null!=(h=s.logLevel)?h:"")&&console.error(e),new z(n?e:Fe,u.status,this.getResponseTraceId(u),null!=(y=t)?y:xe,a)}if("stream"===e.responseType)return u.body;if(e.responseType&&"json"!==e.responseType){if("blob"===e.responseType){const{outputFileName:t}=e.params;return await u.blob().then((e=>URL.createObjectURL(e))).then((e=>{const a=document.createElement("a");a.href=e,a.setAttribute("download",t||"output"),a.click()}))}return await u.text()}try{return await u.json()}catch(e){return{}}},this.get=async(e,t,a)=>this.sendRequest(S({url:e,method:"GET",contentType:"application/json",params:t},a)),this.post=async(e,t,a)=>this.sendRequest(S({url:e,method:"POST",contentType:"application/json",body:t},a)),this.patch=async(e,t,a)=>this.sendRequest(S({url:e,method:"PATCH",contentType:"application/json",body:t},a)),this.put=async(e,t,a)=>this.sendRequest(S({url:e,method:"PUT",contentType:"application/json",body:t},a)),this.delete=async(e,t,a)=>this.sendRequest(S({url:e,method:"DELETE",contentType:"application/json",body:t},a)),this.postDownload=async(e,t,a,n)=>this.sendRequest(S({url:e,method:"POST",contentType:"application/json",responseType:"blob",body:t,params:a},n)),this.extractHeadersFromOptions=(e={})=>S({},e.jwt?{Authorization:e.jwt}:{}),this.getBaseUrl=(e,t,a=!0)=>Ve.getBaseUrl(e,t,a),this.getContextBaseUrl=(e,t=!0)=>{const a=this.getFronteggContext().getContext();return this.getBaseUrl(a,e,t)},this.getMetadataHeaders=e=>Ve.getMetadataHeaders(e),this.getContextMetadataHeaders=()=>{const e=this.getFronteggContext().getContext();return Ve.getMetadataHeaders(e)},this.appName=e}}Ve.getBaseUrl=(e,t,a=!0)=>{let n;n="function"==typeof e.baseUrl?e.baseUrl(t):e.baseUrl;const s=e.urlPrefix||"frontegg",i="frontegg"===s&&!a;return n.endsWith("/")||(n+="/"),n.endsWith(s)||i||(n+=s),n},Ve.getMetadataHeaders=e=>{var t,a;const n={};return null!=e&&null!=(t=e.metadataHeaders)&&t.fronteggSdkVersion&&(n[$e.fronteggSdkVersion]=e.metadataHeaders.fronteggSdkVersion),null!=e&&null!=(a=e.metadataHeaders)&&a.framework&&(n[$e.frameWork]=e.metadataHeaders.framework),n},Ve.getScopedTenant=()=>new URLSearchParams(window.location.search).get("tenantId")||null;const We=new Ve("default");class He extends Error{constructor(e){super(e)}}const ze="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){const t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new He("'atob' failed: The string to be decoded is not correctly encoded.");let a="";for(let e,n,s=0,i=0;n=t.charAt(i++);~n&&(e=s%4?64*e+n:n,s++%4)?a+=String.fromCharCode(255&e>>(-2*s&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};class Ke extends Error{constructor(e){super(e)}}const qe=(e,t={})=>{const a=t.header?0:1;try{return JSON.parse((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("Illegal base64url string!")}try{return function(e){return decodeURIComponent(ze(e).replace(/(.)/g,((e,t)=>{let a=t.charCodeAt(0).toString(16).toUpperCase();return a.length<2&&(a="0"+a),"%"+a})))}(t)}catch(e){return ze(t)}})(e.split(".")[a]))}catch(e){throw new Ke("Invalid token specified: "+e.message)}};let Je,Ye,Xe,Qe;!function(e){e.ALLOW="ALLOW",e.BLOCK="BLOCK"}(Je||(Je={})),function(e){e.WebAuthnPlatform="WebAuthnPlatform",e.WebAuthnCrossPlatform="WebAuthnCrossPlatform",e.SmsCode="SmsCode",e.SmsCodeV2="SmsCodeV2",e.Passkeys="Passkeys",e.UsernameAndPassword="UsernameAndPassword",e.UsernameAndMagicLink="UsernameAndMagicLink",e.UsernameAndCode="UsernameAndCode",e.UsernameAndSms="UsernameAndSms"}(Ye||(Ye={})),function(e){e.Platform="Platform",e.CrossPlatform="CrossPlatform"}(Xe||(Xe={})),function(e){e.AuthenticatorApp="AuthenticatorApp",e.WebAuthnPlatform="WebAuthnPlatform",e.WebAuthnCrossPlatform="WebAuthnCrossPlatform",e.SMS="SMS",e.EmailCode="EmailCode"}(Qe||(Qe={}));const Ze="admin_portal_should_load_authorization";class et{constructor(e){this.appName=void 0,this.fetchClient=void 0,this.get=async(e,t,a)=>this.fetchClient.get(e,t,a),this.post=async(e,t,a)=>this.fetchClient.post(e,t,a),this.patch=async(e,t,a)=>this.fetchClient.patch(e,t,a),this.put=async(e,t,a)=>this.fetchClient.put(e,t,a),this.delete=async(e,t,a)=>this.fetchClient.delete(e,t,a),this.postDownload=async(e,t,a,n)=>this.fetchClient.postDownload(e,t,a,n),this.extractHeadersFromOptions=(e={})=>this.fetchClient.extractHeadersFromOptions(e),this.appName=e,this.fetchClient=new Ve(e)}}const tt={flags:{}};class at{constructor(){var e;this._flags={},this._flags=null!=(e=tt.flags)?e:{}}static getInstance(e="default"){return this._instances[e]}static set(e,t="default"){const a=new at;return a.set(e),at._instances[t]=a,a}static getFeatureFlags(e,t){const a=this.getInstance(t);return e.map((e=>"on"===(null==a?void 0:a._flags[e])))}get flags(){var e;return null!=(e=this.flags)?e:{}}set(e){var t;this._flags=S({},null!=(t=null==tt?void 0:tt.flags)?t:{},null!=e?e:{})}}at._instances={};class nt extends et{constructor(e){super(e),this.loadFeatureFlags=async()=>this.get(ke)}}const st=new nt("default"),it="FRONTEGG_SEPARATE_TABS_BY_TENANT",ot="admin_portal_use_current_user_tenants_v1_endpoint";class rt extends et{constructor(e){super(e),this.GetUserJwt=async e=>this.post(`${Y.v3}/me/token`,e),this.getUsersV2=async(e,t)=>this.get(Y.v2,e,{headers:this.extractHeadersFromOptions(t)}),this.getUsersV3=async(e,t)=>this.get(Y.v3,e,{headers:this.extractHeadersFromOptions(t)}),this.getUsersRoles=async(e,t)=>this.get(Y.roles.v3,S({},e,{ids:e.ids.join(",")}),{headers:this.extractHeadersFromOptions(t)}),this.getUsersGroups=async(e,t)=>this.get(Y.groups.v3,S({},e,{ids:e.ids.join(",")}),{headers:this.extractHeadersFromOptions(t)}),this.getCurrentUserTenantsV3=async e=>this.get(Y.tenants.me.v3,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getCurrentUserTenantsV1=async e=>this.get(Y.tenants.me.v1,void 0,{headers:this.extractHeadersFromOptions(e)}),this.sendResetBreachedPasswordEmails=async()=>this.post(Y.passwords.resetBreachedPasswords.v1),this.updateUserProfileV2=async e=>this.put(`${Y.v2}/me`,e),this.unlockMe=async e=>this.post(`${Y.v3}/me/unlock`,e)}}const lt=new rt("default");function ct(e){e&&sessionStorage.setItem(it,e)}function ut(){sessionStorage.removeItem(it)}function dt(e){return R.for(e).isSessionPerTenantEnabled()?sessionStorage.getItem(it):null}function gt(e){if(R.for(e).shouldSkipUserLoad())return async()=>({tenants:[],activeTenant:{}});const t=new rt(e),[a]=at.getFeatureFlags([ot],e);return R.for(e).isSessionPerTenantEnabled()||a?t.getCurrentUserTenantsV1:t.getCurrentUserTenantsV3}class pt extends et{constructor(e){super(e),this.switchTenant=async e=>(R.for(this.appName).isSessionPerTenantEnabled()&&ct(e.tenantId),this.put(`${Y.v1}/tenant`,e)),this.getTenants=async()=>this.get(`${Y.v2}/me/tenants`),this.getSubTenants=async e=>this.get(ye.v1,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getSubTenantsAsTree=async e=>this.get(ye.tree.v1,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getParentTenants=async e=>this.get(ye.parents.v1,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getParentTenantsById=async(e,t)=>this.get(`${ye.parents.v1}/${e}`,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getTenantsUsersCount=async(e,t)=>this.post(`${te.users.v1}/count`,e,{headers:this.extractHeadersFromOptions(t)}),this.searchSubTenants=async(e,t)=>this.get(ye.v2,e,{headers:this.extractHeadersFromOptions(t)}),this.getHierarchyMetadata=async(e,t)=>this.get(ye.metadata.v2,S({},e,{_tenantIds:e._tenantIds.join(",")}),{headers:this.extractHeadersFromOptions(t)})}}const ht=new pt("default");class yt extends et{constructor(e){super(e),this.loadEntitlementsV2=async()=>this.get(Re)}}const vt=new yt("default");class St extends et{constructor(e){super(e),this.getGlobalSecurityPolicy=async()=>this.get(X.v1),this.getMfaPolicy=async()=>this.get(`${X.v1}/mfa-policy`),this.getVendorMfaPolicy=async()=>this.get(`${X.v1}/mfa-policy/vendor`),this.saveMfaPolicy=async e=>e.id?this.patch(`${X.v1}/mfa-policy`,e):this.post(`${X.v1}/mfa-policy`,e),this.getLockoutPolicy=async()=>this.get(`${X.v1}/lockout-policy`),this.getVendorLockoutPolicy=async()=>this.get(`${X.v1}/lockout-policy/vendor`),this.saveLockoutPolicy=async e=>e.id?this.patch(`${X.v1}/lockout-policy`,e):this.post(`${X.v1}/lockout-policy`,e),this.getCaptchaPolicy=async()=>{try{return await this.get(`${X.v1}/captcha-policy/public`)}catch{return null}},this.getPasswordHistoryPolicy=async()=>this.get(`${X.v1}/password-history-policy`),this.getVendorPasswordHistoryPolicy=async()=>this.get(`${X.v1}/password-history-policy/vendor`),this.savePasswordHistoryPolicy=async e=>e.id?this.patch(`${X.v1}/password-history-policy`,e):this.post(`${X.v1}/password-history-policy`,e),this.getPasswordRotationPolicy=async()=>{try{return await this.get(`${X.v1}/password-rotation`)}catch(e){return{}}},this.getVendorPasswordRotationPolicy=async()=>{try{return await this.get(`${X.v1}/password-rotation/vendor`)}catch(e){return{}}},this.savePasswordRotationPolicy=async e=>this.post(`${X.v1}/password-rotation`,e),this.getPasswordConfigPolicy=async()=>this.get(`${X.v1}/password`),this.getDomainRestrictions=async()=>this.get(`${Q.emailDomain.v1}`),this.getDomainRestrictionsConfig=async()=>this.get(`${Q.emailDomain.v1}/config`),this.createDomainRestriction=async e=>this.post(`${Q.emailDomain.v1}`,e),this.updateDomainRestrictionConfig=async e=>this.post(`${Q.emailDomain.v1}/config`,e),this.deleteDomainRestriction=async e=>this.delete(`${Q.emailDomain.v1}/${e}`),this.getIPRestrictions=async e=>this.get(`${Q.ip.v1}`,e),this.getIPRestrictionsConfig=async()=>this.get(`${Q.ip.v1}/config`),this.createIPRestriction=async e=>this.post(`${Q.ip.v1}`,e),this.bulkCreateIPRestriction=async e=>this.post(`${Q.ip.v1}/bulk`,e),this.updateIPRestrictionConfig=async e=>this.post(`${Q.ip.v1}/config`,e),this.deleteIPRestriction=async e=>this.delete(`${Q.ip.v1}/${e}`),this.testCurrentIp=async()=>this.post(`${Q.ip.v1}/verify`),this.testCurrentIpInAllowList=async()=>this.post(`${Q.ip.v1}/verify/allow`)}}const ft=new St("default"),mt=["type"],bt=["type"],At=["type"];class wt extends et{constructor(e){super(e),this.tenantsApi=new pt(this.appName),this.entitlementsApi=new yt(this.appName),this.securityPolicy=new St(this.appName),this.generateLoginResponse=async e=>{if(!e.accessToken)return e;const t=R.for(this.appName);t.setAccessToken(e.accessToken);const a=await this.getMeAndEntitlements(),n=S({},e,e.accessToken?qe(e.accessToken):{},a);return t.setUser(n),n},this.generateLoginResponseV2=async e=>{if(!e.accessToken)return{user:e};const t=R.for(this.appName);t.setAccessToken(e.accessToken);const[a,n]=await Promise.all([this.getMeAndEntitlements(),this.tenantsApi.getTenants()]),s=S({},e,e.accessToken?qe(e.accessToken):{},a);return t.setUser(s),{user:s,tenants:n}},this.generateLoginResponseV3=async e=>{const{accessToken:t}=e;if(!t)return{user:e};const a=R.for(this.appName);a.setAccessToken(t);const[n,s]=await Promise.all([this.getMeAndEntitlements(),gt(this.appName)()]),i=S({},e,t?qe(t):{},n);return a.isSessionPerTenantEnabled()&&ct(i.tenantId),a.setUser(i),{user:i,tenants:s.tenants,activeTenant:s.activeTenant}},this.generateLoginResponseFromOAuthResponse=async e=>{const t=R.for(this.appName);t.setAccessToken(e.id_token);const a=await this.getMeAndEntitlements(),n=e.id_token?qe(e.id_token):{},s=S({mfaRequired:!1,accessToken:e.id_token,refreshToken:e.refresh_token},n,a,{expiresIn:e.expires_in||300});return t.setUser(s),s},this.generateLoginResponseFromOAuthResponseV2=async e=>{const t=R.for(this.appName);t.setAccessToken(e.id_token);const[a,n]=await Promise.all([this.getMeAndEntitlements(),gt(this.appName)()]),s=e.id_token?qe(e.id_token):{},i=S({mfaRequired:!1,accessToken:e.id_token,refreshToken:e.refresh_token},s,a,{expiresIn:e.expires_in||300});return t.isSessionPerTenantEnabled()&&ct(i.tenantId),t.setUser(i),{user:i,tenants:n.tenants,activeTenant:n.activeTenant}},this.preLogin=async e=>{try{const{address:t}=await this.post(`${J.v1}/user/saml/prelogin`,e);return t}catch{return null}},this.preLoginWithIdpType=async e=>this.post(`${J.v1}/user/saml/prelogin`,e),this.postLogin=async e=>{const t=await this.post(`${J.v1}/user/saml/postlogin`,e);return this.generateLoginResponse(t)},this.oidcPostLogin=async e=>{const t=await this.post(`${J.v1}/user/oidc/postlogin`,e);return this.generateLoginResponse(t)},this.login=async e=>{const t=await this.post(`${J.v1}/user`,e);return this.generateLoginResponse(t)},this.loginv2=async e=>{const t=await this.post(`${J.v1}/user`,e);return this.generateLoginResponseV3(t)},this.loginWithMfa=async e=>{const t=await this.post(`${J.v1}/user/mfa/verify`,e);return this.generateLoginResponse(t)},this.loginWithMfaV2=async e=>{const t=await this.post(`${J.v1}/user/mfa/verify`,e);return this.generateLoginResponseV3(t)},this.activateAccount=async e=>this.post(`${Y.v1}/activate`,e),this.activateAccountV2=async e=>{const t=await this.post(`${Y.v1}/activate`,e);return this.generateLoginResponseV3(t)},this.activateAccountWithOTC=async e=>{const t=await this.post(`${Y.v1}/activate/code`,e);return this.generateLoginResponseV3(t)},this.getActivateAccountStrategy=async e=>this.get(`${Y.v1}/activate/strategy`,e),this.resendActivationEmail=async e=>this.post(`${Y.v1}/activate/reset`,e),this.resendInvitationEmail=async e=>this.post(`${Y.v1}/invitation/reset`,e),this.acceptInvitation=async e=>this.post(`${Y.v1}/invitation/accept`,e),this.acceptInvitationWithOTC=async e=>this.post(`${Y.v1}/invitation/accept/code`,e),this.refreshToken=async()=>{const e=dt(this.appName),t=await this.post(`${J.v1}/user/token/refresh`,{tenantId:e});return this.generateLoginResponse(t)},this.refreshTokenV2=async()=>{const e=dt(this.appName),t=await this.post(`${J.v1}/user/token/refresh`,{tenantId:e});return this.generateLoginResponseV2(t)},this.refreshTokenV3=async()=>{const e=dt(this.appName),t=await this.post(`${J.v1}/user/token/refresh`,{tenantId:e});return this.generateLoginResponseV3(t)},this.logout=async()=>this.post(`${J.v1}/logout`),this.OAuthLogout=async e=>this.get(`${Oe}/logout`,e),this.forgotPassword=async e=>this.post(`${Y.v1}/passwords/reset`,e),this.resetPassword=async e=>this.post(`${Y.v1}/passwords/reset/verify`,e),this.resetPasswordViaEmail=async e=>this.post(`${Y.v2}/passwords/reset/email`,e),this.resetPasswordViaSms=async e=>this.post(`${Y.v2}/passwords/reset/sms`,e),this.verifyPasswordViaSms=async e=>this.post(`${Y.v2}/passwords/reset/sms/verify`,e),this.getPasswordRecoveryStrategies=async()=>this.get(`${X.v1}/password-recovery/strategies`),this.loadPasswordConfig=async e=>this.get(`${Y.v1}/passwords/config`,e),this.getSignUpStrategies=async()=>this.get(`${K.v1.strategies}`),this.recoverMfaToken=async e=>this.post(`${J.v1}/user/mfa/recover`,e),this.enrollMfa=async()=>this.post(`${Y.v1}/mfa/enroll`),this.preEnrollMFAAuthenticatorApp=async()=>this.post(`${Y.v1}/mfa/authenticator/enroll`),this.enrollMFAAuthenticatorApp=async e=>this.post(`${Y.v1}/mfa/authenticator/enroll/verify`,e),this.preEnrollMFASMS=async e=>this.post(`${Y.v1}/mfa/sms/enroll`,e),this.enrollMFASMS=async e=>this.post(`${Y.v1}/mfa/sms/enroll/verify`,e),this.preEnrollMFAWebAuthn=async()=>this.post(`${Y.v1}/mfa/webauthn/enroll`),this.enrollMFAWebAuthn=async e=>this.post(`${Y.v1}/mfa/webauthn/enroll/verify`,e),this.verifyMfa=async e=>this.post(`${Y.v1}/mfa/enroll/verify`,e),this.disableMfa=async e=>this.post(`${Y.v1}/mfa/disable`,e),this.disableMFAAuthenticatorApp=async(e,t)=>this.post(`${Y.v1}/mfa/authenticator/${e}/disable/verify`,t),this.preDisableMFASMS=async e=>this.post(`${Y.v1}/mfa/sms/${e}/disable`),this.disableMFASMS=async(e,t)=>this.post(`${Y.v1}/mfa/sms/${e}/disable/verify`,t),this.preDisableMFAWebAuthn=async e=>this.post(`${Y.v1}/mfa/webauthn/${e}/disable`),this.disableMFAWebAuthn=async(e,t)=>this.post(`${Y.v1}/mfa/webauthn/${e}/disable/verify`,t),this.getMFADevices=async()=>this.get(`${Y.v1}/mfa/devices`),this.preEnrollMFAAuthenticatorAppForLogin=async e=>this.post(`${J.v1}/user/mfa/authenticator/enroll`,e),this.enrollMFAAuthenticatorAppForLogin=async e=>this.post(`${J.v1}/user/mfa/authenticator/enroll/verify`,e),this.enrollMFAAuthenticatorAppForLoginV2=async e=>{const t=await this.post(`${J.v1}/user/mfa/authenticator/enroll/verify`,e);return this.generateLoginResponseV3(t)},this.verifyMFAAuthenticatorAppForLogin=async(e,t)=>this.post(`${J.v1}/user/mfa/authenticator/${e}/verify`,t),this.preVerifyMFAEmailCode=async e=>this.post(`${J.v1}/user/mfa/emailcode`,e),this.verifyMFAEmailCode=async e=>this.post(`${J.v1}/user/mfa/emailcode/verify`,e),this.verifyMFAEmailCodeV2=async e=>{const t=await this.post(`${J.v1}/user/mfa/emailcode/verify`,e);return this.generateLoginResponseV3(t)},this.preEnrollMFASMSForLogin=async e=>this.post(`${J.v1}/user/mfa/sms/enroll`,e),this.enrollMFASMSForLogin=async e=>this.post(`${J.v1}/user/mfa/sms/enroll/verify`,e),this.enrollMFASMSForLoginV2=async e=>{const t=await this.post(`${J.v1}/user/mfa/sms/enroll/verify`,e);return this.generateLoginResponseV3(t)},this.preVerifyMFASMSForLogin=async(e,t)=>this.post(`${J.v1}/user/mfa/sms/${e}`,t),this.verifyMFASMSForLogin=async(e,t)=>this.post(`${J.v1}/user/mfa/sms/${e}/verify`,t),this.verifyMFASMSForLoginV2=async(e,t)=>{const a=await this.post(`${J.v1}/user/mfa/sms/${e}/verify`,t);return this.generateLoginResponseV3(a)},this.preEnrollMFAWebAuthnForLogin=async e=>this.post(`${J.v1}/user/mfa/webauthn/enroll`,e),this.enrollMFAWebAuthnForLogin=async e=>this.post(`${J.v1}/user/mfa/webauthn/enroll/verify`,e),this.enrollMFAWebAuthnForLoginV2=async e=>{const t=await this.post(`${J.v1}/user/mfa/webauthn/enroll/verify`,e);return this.generateLoginResponseV3(t)},this.preVerifyMFAWebAuthnForLogin=async(e,t)=>this.post(`${J.v1}/user/mfa/webauthn/${e}`,t),this.verifyMFAWebAuthnForLogin=async(e,t)=>this.post(`${J.v1}/user/mfa/webauthn/${e}/verify`,t),this.verifyMFAWebAuthnForLoginV2=async(e,t)=>{const a=await this.post(`${J.v1}/user/mfa/webauthn/${e}/verify`,t);return this.generateLoginResponseV3(a)},this.getSamlConfiguration=async()=>this.get(`${ce.v1}/saml/configurations`),this.updateSamlConfiguration=async e=>this.post(`${ce.v1}/saml/configurations`,e),this.getSamlVendorConfiguration=async()=>this.get(`${ce.v1}/saml/configurations/vendor-config`),this.updateSamlVendorMetadata=async e=>this.put(`${ce.v1}/saml/configurations/metadata`,e),this.validateSamlDomain=async()=>this.put(`${ce.v1}/saml/validations/domain`),this.getSamlRoles=async()=>this.get(`${ce.v1}/saml/configurations/roles/default`),this.getSamlRolesGroups=async()=>this.get(`${ce.v2}/saml/configurations/groups`),this.updateSamlRoles=async({roleIds:e})=>this.post(`${ce.v1}/saml/configurations/roles/default`,{roleIds:e}),this.createSamlGroup=async({roleIds:e,group:t})=>this.post(`${ce.v2}/saml/configurations/groups`,{group:t,roleIds:e}),this.updateSamlGroup=async({roleIds:e,group:t,id:a})=>this.patch(`${ce.v2}/saml/configurations/groups/${a}`,{group:t,roleIds:e}),this.deleteSamlGroup=async({id:e})=>this.delete(`${ce.v2}/saml/configurations/groups/${e}`),this.getOidcConfiguration=async()=>this.get(`${ce.v1}/oidc/configurations`),this.getSSOPublicConfiguration=async()=>this.get(`${ce.v2}/configurations/public`),this.getSocialLoginProviders=async()=>this.get(Z.v1),this.getSocialLoginProvidersV2=async()=>this.get(Z.v2),this.getSocialLoginProvidersV2ForAuthenticatedUser=async()=>this.get(`${Z.v2}/authenticated`),this.getCustomSocialLoginProvidersV1=async()=>this.get(Z.custom.v1),this.loginViaSocialLogin=async e=>{const t={};return e.code&&(t.code=e.code),e.idToken&&(t.id_token=e.idToken),e.redirectUri&&(t.redirectUri=e.redirectUri),e.codeVerifier&&(t.code_verifier=e.codeVerifier),e.codeVerifierPkce&&(t.code_verifier_pkce=e.codeVerifierPkce),e.state&&(t.state=e.state),this.post(`${J.v1}/user/sso/${e.provider}/postlogin`,{metadata:e.metadata,invitationToken:e.invitationToken},{params:t})},this.getVendorConfig=async()=>this.get(`${X.v1}/public`),this.signUpUser=async e=>{const{shouldActivate:t,authResponse:a,userId:n,tenantId:s,activationToken:i}=await this.post(`${Y.v1}/signUp`,e),o={shouldActivate:t,userId:n,tenantId:s};if(!t&&a){const{user:e,tenants:t,activeTenant:n}=await this.generateLoginResponseV3(a);return S({},o,{user:e,tenants:t,activeTenant:n})}return S({},o,{activationToken:i})},this.signUpUserWithPhoneNumber=async e=>{const{shouldActivate:t,authResponse:a,userId:n,tenantId:s,activationToken:i}=await this.post(`${Y.v1}/signUp/phoneNumber`,e),o={shouldActivate:t,userId:n,tenantId:s};if(!t&&a){const{user:e,tenants:t,activeTenant:n}=await this.generateLoginResponseV3(a);return S({},o,{user:e,tenants:t,activeTenant:n})}return S({},o,{activationToken:i})},this.getCurrentUserSessions=async()=>this.get(Y.sessions.currentUser.v1),this.getCurrentUserSession=async()=>this.get(`${Y.sessions.currentUser.v1}/current`),this.revokeSessionsForUser=async e=>this.post(`${Y.sessions.v1}/revoke`,{userId:e}),this.getSessionConfigurations=async()=>this.get(Y.sessions.configurations.v1),this.createOrUpdateSessionConfigrations=async e=>{await this.post(Y.sessions.configurations.v1,e)},this.deleteSessionForUser=async e=>{await this.delete(`${Y.sessions.currentUser.v1}/${e}`)},this.deleteAllSessionsForUser=async()=>{await this.delete(`${Y.sessions.currentUser.v1}/all`)},this.getUserAccessTokensData=async()=>this.get(Y.accessTokens.v1),this.getTenantAccessTokensData=async()=>this.get(te.accessTokens.v1),this.deleteTenantAccessToken=async({id:e})=>{await this.delete(`${te.accessTokens.v1}/${e}`)},this.deleteUserAccessToken=async({id:e})=>{await this.delete(`${Y.accessTokens.v1}/${e}`)},this.createUserAccessToken=async e=>this.post(Y.accessTokens.v1,e),this.createTenantAccessToken=async e=>this.post(te.accessTokens.v1,e),this.getUserApiTokensData=async()=>this.get(Y.apiTokens.v1),this.getTenantApiTokensData=async()=>this.get(te.apiTokens.v1),this.updateUserApiTokensData=async e=>this.post(Y.apiTokens.v1,e),this.updateTenantApiTokensData=async e=>this.post(te.apiTokens.v2,e),this.deleteTenantApiToken=async({tokenId:e})=>{await this.delete(`${te.apiTokens.v1}/${e}`)},this.deleteUserApiToken=async({tokenId:e})=>{await this.delete(`${Y.apiTokens.v1}/${e}`)},this.getUserById=async({userId:e})=>this.get(`${Y.v1}/${e}`),this.checkIfAllowToRememberMfaDevice=async e=>this.get(`${X.v1}/mfa-policy/allow-remember-device`,{mfaToken:e}),this.passwordlessPreLogin=async e=>{var t;let{type:a}=e,n=f(e,mt);const s=(null==(t={[N.UsernameAndCode]:N.Code,[N.UsernameAndMagicLink]:N.MagicLink,[N.UsernameAndSms]:N.SmsCode,[N.UsernameAndPassword]:N.EmailAndPassword}[a])?void 0:t.toLowerCase())||a.toLowerCase();return this.post(`${J.v1}/passwordless/${s}/prelogin`,n)},this.passwordlessPostLoginV2=async e=>{let{type:t}=e,a=f(e,bt);const n=await this.post(`${J.v1}/passwordless/${t.toLocaleLowerCase()}/postlogin`,a);return this.generateLoginResponseV3(n)},this.passwordlessPostLogin=async e=>{let{type:t}=e,a=f(e,At);return this.post(`${J.v1}/passwordless/${t.toLocaleLowerCase()}/postlogin`,a)},this.verifyInviteToken=async({token:e})=>this.post(te.invites.verify.v1,{token:e}),this.getSSOConfigurations=async()=>this.get(`${ce.v1}/configurations`),this.createSSOConfiguration=async e=>this.post(`${ce.v1}/configurations`,e),this.updateSSOConfiguration=async(e,t)=>this.patch(`${ce.v1}/configurations/${e}`,t),this.deleteSSOConfiguration=async e=>{await this.delete(`${ce.v1}/configurations/${e}`)},this.createSSOConfigurationByMetadata=async e=>this.post(`${ce.v1}/configurations/metadata`,e),this.updateSSOConfigurationByMetadata=async(e,t)=>this.put(`${ce.v1}/configurations/${e}/metadata`,t),this.createSSOConfigurationByMetadataUrl=async e=>this.post(`${ce.v1}/configurations/metadata-url`,e),this.updateSSOConfigurationByMetadataUrl=async(e,t)=>this.put(`${ce.v1}/configurations/${e}/metadata-url`,t),this.createSSODomain=async(e,t)=>this.post(`${ce.v1}/configurations/${e}/domains`,t),this.deleteSSODomain=async(e,t)=>this.delete(`${ce.v1}/configurations/${e}/domains/${t}`),this.validateSSODomain=async(e,t)=>this.put(`${ce.v1}/configurations/${e}/domains/${t}/validate`),this.validateSSODomainV2=async(e,t)=>this.put(`${ce.v2}/configurations/${e}/domains/${t}/validate`),this.getSSODefaultRoles=async e=>this.get(`${ce.v1}/configurations/${e}/roles`),this.setSSODefaultRoles=async(e,t)=>this.put(`${ce.v1}/configurations/${e}/roles`,t),this.createSSOGroup=async(e,t)=>this.post(`${ce.v1}/configurations/${e}/groups`,t),this.updateSSOGroup=async(e,{roleIds:t,group:a,id:n})=>this.patch(`${ce.v1}/configurations/${e}/groups/${n}`,{group:a,roleIds:t}),this.deleteSSOGroup=async(e,t)=>this.delete(`${ce.v1}/configurations/${e}/groups/${t}`),this.getSSOGroups=async e=>this.get(`${ce.v1}/configurations/${e}/groups`),this.preLoginV2=async e=>this.post(`${J.v2}/user/sso/prelogin`,e),this.oidcPostLoginV2=async e=>{const t=await this.post(`${J.v2}/user/oidc/postlogin`,e);return this.generateLoginResponse(t)},this.exchangeOAuthTokensV2=async e=>{const t=await this.post(`${Oe}/token`,e);return this.generateLoginResponseFromOAuthResponseV2(t)},this.silentOAuthRefreshTokenV2=async()=>{const e=dt(this.appName),t=await this.post(`${Oe}/authorize/silent`,{tenantId:e});return this.generateLoginResponseFromOAuthResponseV2(t)},this.exchangeOAuthTokens=async e=>{const t=await this.post(`${Oe}/token`,e);return this.generateLoginResponseFromOAuthResponse(t)},this.silentOAuthRefreshToken=async()=>{const e=dt(this.appName),t=await this.post(`${Oe}/authorize/silent`,{tenantId:e});return this.generateLoginResponseFromOAuthResponse(t)},this.resetPhoneNumber=async e=>this.post(`${Y.v1}/phone/reset`,e),this.verifyResetPhoneNumber=async e=>this.post(`${Y.v1}/phone/reset/verify`,e),this.changePhoneNumberWithVerification=async e=>this.post(`${Y.v1}/phone`,e),this.verifyChangePhoneNumber=async e=>this.post(`${Y.v1}/phone/verify`,e),this.changePhoneNumber=async e=>this.put(`${Y.v1}/phone/change`,e),this.webAuthnPreLogin=async e=>this.post(`${J.v1}/webauthn/prelogin`,e),this.webAuthnPostLogin=async e=>this.post(`${J.v1}/webauthn/postlogin`,e),this.webAuthnPostLoginV2=async e=>{const t=await this.post(`${J.v1}/webauthn/postlogin`,e);return this.generateLoginResponseV3(t)},this.webAuthnCreateNewDeviceSession=async()=>this.post(q.v1),this.getWebAuthnDevices=async()=>this.get(q.v1),this.deleteWebAuthnDevice=async e=>this.delete(`${q.v1}/${e}`),this.verifyNewDeviceSession=async e=>this.post(`${q.v1}/verify`,e),this.getVendorPublicAuthStrategiesConfig=async()=>this.get(`${X.v1}/auth/strategies/public`),this.getPublicAuthStrategiesConfigForAuthenticatedUser=async()=>this.get(`${X.v1}/auth/strategies`),this.getMFAStrategiesConfig=async()=>this.get(`${X.v1}/mfa/strategies`),this.getUserAuthorization=async()=>this.get(`${Y.authorization.v1}`),this.getMeV2=async()=>this.get(`${Y.v2}/me`),this.noThrowLoadEntitlements=async()=>{try{return await this.entitlementsApi.loadEntitlementsV2()}catch(e){}},this.getMeAndEntitlements=async()=>{if(R.for(this.appName).shouldSkipUserLoad())return{roles:[],permissions:[],groups:[],tenants:[]};const e=[{action:this.getMeV2,shouldLoad:!0},{action:this.noThrowLoadEntitlements,shouldLoad:this.shouldLoadEntitlements()},{action:this.getUserAuthorization,shouldLoad:this.shouldLoadMeAuthorization()}].map((e=>async function({shouldLoad:e,action:t}){if(e)return await t()}(e))),[t,a,n]=await Promise.all(e),s=dt(this.appName);return s&&(t.tenantId=s),S({},t,null!=n?n:{},{entitlements:a})},this.generateStepupSession=async e=>{const t=await this.post(`${J.v1}/user/step-up/generate`,e);return t.accessToken?this.generateLoginResponseV3(t):t},this.getGlobalSecurityPolicy=this.securityPolicy.getGlobalSecurityPolicy.bind(this.securityPolicy),this.getMfaPolicy=this.securityPolicy.getMfaPolicy.bind(this.securityPolicy),this.getVendorMfaPolicy=this.securityPolicy.getVendorMfaPolicy.bind(this.securityPolicy),this.saveMfaPolicy=this.securityPolicy.saveMfaPolicy.bind(this.securityPolicy),this.getLockoutPolicy=this.securityPolicy.getLockoutPolicy.bind(this.securityPolicy),this.getVendorLockoutPolicy=this.securityPolicy.getVendorLockoutPolicy.bind(this.securityPolicy),this.saveLockoutPolicy=this.securityPolicy.saveLockoutPolicy.bind(this.securityPolicy),this.getCaptchaPolicy=this.securityPolicy.getCaptchaPolicy.bind(this.securityPolicy),this.getPasswordHistoryPolicy=this.securityPolicy.getPasswordHistoryPolicy.bind(this.securityPolicy),this.getVendorPasswordHistoryPolicy=this.securityPolicy.getVendorPasswordHistoryPolicy.bind(this.securityPolicy),this.savePasswordHistoryPolicy=this.securityPolicy.savePasswordHistoryPolicy.bind(this.securityPolicy),this.getPasswordConfigPolicy=this.securityPolicy.getPasswordConfigPolicy.bind(this.securityPolicy),this.getDomainRestrictions=this.securityPolicy.getDomainRestrictions.bind(this.securityPolicy),this.getDomainRestrictionsConfig=this.securityPolicy.getDomainRestrictionsConfig.bind(this.securityPolicy),this.createDomainRestriction=this.securityPolicy.createDomainRestriction.bind(this.securityPolicy),this.updateDomainRestrictionConfig=this.securityPolicy.updateDomainRestrictionConfig.bind(this.securityPolicy),this.deleteDomainRestriction=this.securityPolicy.deleteDomainRestriction.bind(this.securityPolicy),this.getIPRestrictions=this.securityPolicy.getIPRestrictions.bind(this.securityPolicy),this.getIPRestrictionsConfig=this.securityPolicy.getIPRestrictionsConfig.bind(this.securityPolicy),this.createIPRestriction=this.securityPolicy.createIPRestriction.bind(this.securityPolicy),this.bulkCreateIPRestriction=this.securityPolicy.bulkCreateIPRestriction.bind(this.securityPolicy),this.updateIPRestrictionConfig=this.securityPolicy.updateIPRestrictionConfig.bind(this.securityPolicy),this.deleteIPRestriction=this.securityPolicy.deleteIPRestriction.bind(this.securityPolicy),this.testCurrentIp=this.securityPolicy.testCurrentIp.bind(this.securityPolicy),this.testCurrentIpInAllowList=this.securityPolicy.testCurrentIpInAllowList.bind(this.securityPolicy)}shouldLoadEntitlements(){return R.for(this.appName).shouldLoadEntitlements()}shouldLoadMeAuthorization(){const[e]=at.getFeatureFlags([Ze],this.appName);return e}}const Tt=new wt("default");class Et extends et{constructor(e){super(e),this.getProfile=async e=>this.get(`${Y.v2}/me`,null!=e?e:{addRoles:!0}),this.updateEmail=async e=>this.post(`${Y.v1}/email/me`,{email:e}),this.verifyEmail=async(e,t)=>this.post(`${Y.v1}/email/me/verify`,{email:e,code:t}),this.updateProfile=async e=>this.put(`${Y.v2}/me`,e),this.updateProfileImage=async e=>this.put(`${pe.v1}/me/image/v1`,e,{responseType:"plain",contentType:void 0}),this.changePassword=async e=>this.post(`${Y.v1}/passwords/change`,e),this.loadUsers=async e=>{var t,a,n,s,i,o;const r=(e.filter||[]).reduce(((e,t)=>S({},e,{[t.id]:t.value})),{}),l=null!=(t=e.sort)&&t.length?{sortBy:null!=(a=null==(n=e.sort)||null==(s=n[0])?void 0:s.id)?a:"name",sortDirection:null!=(i=e.sort)&&null!=(o=i[0])&&o.desc?"desc":"asc"}:null;return this.get(ue.v1,S({pageOffset:e.pageOffset,pageSize:e.pageSize},r,l))},this.addUser=async e=>this.post(Y.v2,S({},e,{provider:"local"})),this.deleteUser=async e=>this.delete(`${ue.v1}/${e.userId}`),this.updateUser=async e=>this.put(ue.v1,e),this.updateUserExpirationTime=async e=>{const{userId:t,expirationInSeconds:a}=e;return this.put(`${Y.temporary.v1}/${t}`,{expirationInSeconds:a})},this.setPermanentUser=async e=>this.delete(`${Y.temporary.v1}/${e}`),this.getTemporaryUserConfiguration=async()=>this.get(Y.temporary.configuration.v1),this.createInviteUserLink=async e=>this.post(te.invites.user.v1,S({},e)),this.updateInviteUserLink=async e=>this.patch(te.invites.user.v1,S({},e)),this.deleteInviteUserLink=async()=>this.delete(te.invites.user.v1),this.getInviteUserLink=async()=>this.get(te.invites.user.v1),this.getInviteLinkConfiguration=async()=>this.get(te.invites.configuration.v1),this.loadAvailableRoles=async()=>this.get(de.v1),this.loadAvailablePermissions=async()=>this.get(ee.v1),this.loadStats=async()=>this.get(`${ge.v1}/members`),this.resendActivationLink=async e=>this.post(`${ue.v1}/${e.userId}/resendActivationEmail`,{}),this.resendInvitationLink=async e=>this.post(Y.v2,S({},e,{provider:"local"})),this.resendInvitationLinkToAllTenants=async e=>this.post(Y.invitation.resendAll.v1,S({},e)),this.disableUser=async e=>this.post(`${te.users.v1}/${e}/disable`),this.enableUser=async e=>this.post(`${te.users.v1}/${e}/enable`)}}const Pt=new Et("default");class It extends et{constructor(e){super(e),this.getMetadata=async e=>{var t,a;const n=await this.get("/metadata",e);if(null!=n&&null!=(t=n.rows)&&t[0])return null==n||null==(a=n.rows)?void 0:a[0];throw new Error(`metadata not found: ${e.entityName}`)},this.getAdminBoxMetadata=async()=>this.get("/metadata/admin-box"),this.updateAdminBoxMetadata=async e=>this.post("/metadata/admin-box",e),this.getIpMetadata=async e=>{const t=await this.get(`/metadata/ip/${e}`);if(t)return t;throw new Error("ip metadata not found")},this.getCurrentUserIpMetadata=async()=>{const e=await this.get("/metadata/ipme");if(e)return e;throw new Error("ip metadata not found")},this.getNotificationsMetadata=async()=>this.getMetadata({entityName:"notifications"}),this.getSamlMetadata=async()=>this.getMetadata({entityName:"saml"}),this.getAuditsMetadata=async()=>this.getMetadata({entityName:"audits"}),this.getIpAdressMetadata=async e=>this.getIpMetadata(e)}}const Ot=new It("default"),kt=["dataFilters"],_t=["templateId","dataFilters"],Ut=["dataFilters"];class Rt extends et{constructor(e){super(e),this.getReports=async e=>this.get(`${Ae.v2}/tenant-reports`,e),this.getReport=async e=>this.get(`${Ae.v2}/${e.id}/tenant-reports`),this.renderReport=async e=>{let{dataFilters:t}=e,a=f(e,kt);return{html:await this.get(`${we.v1}/preview-report`,S({},a,{dataFilters:btoa(JSON.stringify(t||{})),responseType:"html"}),{responseType:"plain"})}},this.scheduleReport=async e=>{let{templateId:t,dataFilters:a}=e,n=f(e,_t);return this.post(`${Ae.v2}/${t}/tenant-reports`,S({},n,{dataFilters:btoa(JSON.stringify(a||{}))}))},this.downloadReport=async e=>{let{dataFilters:t}=e,a=f(e,Ut);const n=await this.get(`${we.v1}/preview-report`,S({},a,{dataFilters:btoa(JSON.stringify(t||{}))}),{responseType:"blob"});let s="text/html",i="html";"pdf"===a.responseType?(s="application/pdf",i="pdf"):"image"===a.responseType&&(s="image/jpeg",i="jpg");const o=new Blob([n],{type:s}),r=URL.createObjectURL(o),l=document.createElement("a");l.href=r,l.setAttribute("download",`report_${a.name||""}.${i}`),l.click(),setTimeout(l.remove.bind(l))},this.sendReport=async e=>this.post(`${we.v1}/tenant-reports`,e)}}const Lt=new Rt("default"),Ct=["eventKey"],Dt=["eventKey"];class Nt extends et{constructor(e){super(e),this.getSlackConfiguration=()=>this.get(`${Se.v1}/slack`),this.getSlackScope=()=>this.get(`${Se.v1}/slack/applications`),this.getSlackChannels=()=>this.get(`${Se.v1}/slack/channels`),this.postSlackConfiguration=e=>e.id?this.patch(`${Se.v1}/slack/subscription/${e.id}`,e):this.post(`${Se.v1}/slack/subscriptions`,e),this.deleteSlackConfiguration=e=>this.delete(`${Se.v1}/slack/subscriptions/${e.id}`),this.postSlackCode=e=>this.post(`${Se.v1}/slack/applications/registrations`,{code:e}),this.getEmailConfiguration=()=>this.get(`${Se.v1}/emails`),this.postEmailConfiguration=e=>{let{eventKey:t}=e,a=f(e,Ct);return this.post(`${Se.v1}/emails/${t}`,a)},this.patchEmailConfiguration=({eventKey:e,enabled:t})=>this.patch(`${Se.v1}/emails/${e}`,{enabled:t}),this.deleteEmailSubscriptions=(e,t)=>this.delete(`${Se.v1}/emails/${e}/subscriptions/${t}`),this.putEmailSubscriptions=(e,t,a)=>this.put(`${Se.v1}/emails/${t}/subscriptions/${e}`,a),this.deleteEmailConfiguration=e=>this.delete(`${Se.v1}/emails/${e}`),this.getSMSConfiguration=()=>this.get(`${Se.v2}/sms`),this.postSMSConfiguration=e=>{let{eventKey:t}=e,a=f(e,Dt);return this.post(`${Se.v2}/sms/${t}`,a)},this.patchSMSConfiguration=({eventKey:e,enabled:t})=>this.patch(`${Se.v2}/sms/${e}`,{enabled:t}),this.deleteSMSSubscriptions=(e,t)=>this.delete(`${Se.v2}/sms/${e}/subscriptions/${t}`),this.putSMSSubscriptions=(e,t,a)=>this.put(`${Se.v2}/sms/${t}/subscriptions/${e}`,a),this.deleteSMSConfiguration=e=>this.delete(`${Se.v2}/sms/${e}`),this.getWebhooksConfigurations=()=>this.get(Ie),this.postWebhooksConfiguration=e=>e._id?this.patch(`${Ie}/${e._id}`,e):this.post(`${Ie}/custom`,e),this.deleteWebhooksConfiguration=e=>this.delete(`${Ie}/${e}`),this.getWebhookLog=(e,t=0,a=10)=>{const n=new URLSearchParams({id:e,offset:`${t}`,limit:`${a}`});return this.get(`${Ie}/logs/?${n.toString()}`)},this.postWebhookTest=e=>this.post(`${Ie}/test`,e),this.postWebhookRetry=e=>this.post(`${Ie}/logs/${e}/retries`),this.getCategories=()=>this.get(`${Pe.v1}/categories`),this.getChannelMaps=e=>this.get(Pe.v1,{channels:e})}}const Mt=new Nt("default");class Ft extends et{constructor(e){super(e),this.getNotifications=async e=>this.get(Te,{params:e}),this.updateNotificationStatus=async e=>this.put(`${Te}/status`,{params:e}),this.updateNotificationIsPinned=async e=>{const{notificationId:t,pinStatus:a}=e;return this.put(`${Te}/${a}`,{notificationId:t})},this.markAllAsRead=async()=>this.post(`${Te}/status/mark-all-read`)}}const xt=new Ft("default"),$t=["endpoint","headerProps"];class Gt extends et{constructor(e){super(e),this.getAudits=async e=>this.get(Ee,e),this.getAuditsStats=async e=>this.get(`${Ee}/stats`,e),this.exportAudits=async e=>{const{endpoint:t,headerProps:a}=e,n=f(e,$t);return this.postDownload(`${Ee}/export/${t}`,{properties:a},n)}}}const jt=new Gt("default");class Bt extends et{constructor(e){super(e),this.updateSettings=async(e,t)=>this.put(he.v1,e,{headers:this.extractHeadersFromOptions(t)}),this.getSettings=async e=>this.get(he.v1,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getPublicSettings=async()=>this.get(`${he.v1}/public`)}}const Vt=new Bt("default"),Wt=["roleId"],Ht=["roleId"],zt=["permissionId"];class Kt extends et{constructor(e){super(e),this.getRoles=async()=>this.get(ae.v1),this.addRole=async e=>this.post(ae.v1,e),this.deleteRole=async({roleId:e})=>this.delete(`${ae.v1}/${e}`),this.updateRole=async e=>{let{roleId:t}=e,a=f(e,Wt);return this.patch(`${ae.v1}/${t}`,a)},this.attachPermissionsToRole=async e=>{let{roleId:t}=e,a=f(e,Ht);return this.put(`${ae.v1}/${t}/permissions`,a)},this.getPermissions=async()=>this.get(ee.v1),this.attachPermissionToRoles=async e=>{let{permissionId:t}=e,a=f(e,zt);return this.put(`${ee.v1}/${t}/roles`,a)},this.getPermissionCategories=async()=>this.get(`${ee.v1}/categories`),this.addRoleV2=async e=>this.post(ae.v2,e)}}const qt=new Kt("default");class Jt extends et{constructor(...e){super(...e),this.getSubscriptionInvoices=async()=>this.get(fe.invoices.v1),this.getSubscriptionInvoice=async e=>this.get(`${fe.invoices.v1}/${e}`),this.getSubscriptionInvoicePdf=async(e,t)=>this.get(`${fe.invoices.v1}/${e}/pdf`,{outputFileName:t},{responseType:"blob"})}}class Yt extends et{constructor(...e){super(...e),this.getManagedSubscription=async e=>this.get(`${be.v1}/${e}`),this.getManagedSubscriptions=async()=>this.get(be.v1),this.cancelManagedSubscription=async e=>this.put(`${be.v1}/${e}/cancellations/`,{}),this.renewManagedSubscription=async e=>this.put(`${be.v1}/${e}/renewals/`,{}),this.updateManagedSubscription=async(e,{paymentMethodId:t,planId:a})=>this.put(`${be.v1}/${e}`,{paymentMethodId:t,planId:a})}}const Xt=["email"];class Qt extends et{constructor(...e){super(...e),this.getPaymentMethods=async()=>this.get(fe.paymentMethods.v1),this.getPaymentMethod=async e=>this.get(`${fe.paymentMethods.v1}/${e}`),this.updatePaymentMethodBillingDetails=async(e,t)=>{let{email:a}=t,n=f(t,Xt);return this.patch(`${fe.paymentMethods.v1}/${e}/billing-details`,{email:a,address:n})}}}class Zt extends et{constructor(...e){super(...e),this.getPaymentProviders=async()=>this.get(me.v1)}}class ea extends et{constructor(...e){super(...e),this.getSubscriptionPlans=async()=>this.get(fe.plans.v1),this.getSubscriptionPlan=async e=>this.get(`${fe.plans.v1}/${e}`)}}class ta extends et{constructor(...e){super(...e),this.getSubscriptions=async()=>this.get(fe.subscriptions.v1),this.getSubscription=async e=>this.get(`${fe.subscriptions.v1}/${e}`),this.cancelSubscription=async e=>this.put(`${fe.subscriptions.v1}/${e}/cancellations/`,{}),this.renewSubscription=async e=>this.put(`${fe.subscriptions.v1}/${e}/renewals/`,{}),this.updateSubscription=async(e,{paymentMethodId:t,planId:a})=>this.put(`${fe.subscriptions.v1}/${e}`,{paymentMethodId:t,planId:a})}}class aa extends et{constructor(...e){super(...e),this.getSubscriptionSummaries=async e=>this.get(`${fe.summaries.v1}/${e}`)}}class na extends et{constructor(...e){super(...e),this.getTenantConfiguration=async e=>this.get(`${fe.tenantConfiguration.v1}/${e}`),this.createTenantConfiguration=async e=>this.post(fe.tenantConfiguration.v1,e)}}class sa extends et{constructor(...e){super(...e),this.getVendorPublicConfigurations=async()=>this.get(fe.configurations.vendorPublicConfigurations.v1)}}class ia extends et{constructor(...e){super(...e),this.createSubscription=async e=>this.post(fe.paymentProviders.stripe.subscriptions.v1,e),this.getStripeCustomer=async e=>this.get(`${fe.paymentProviders.stripe.customers.v1}/${e}`),this.createStripeCustomer=async e=>this.post(fe.paymentProviders.stripe.customers.v1,e),this.getStripePaymentProviderConfiguration=async()=>this.get(fe.paymentProviders.stripe.publicConfigurations.v1),this.createStripePaymentMethodSetupIntentSecret=async e=>this.post(fe.paymentProviders.stripe.setupIntents.v1,e)}}class oa extends et{constructor(e){super(e),this.invoicesApi=new Jt(this.appName),this.managedSubscriptionApi=new Yt(this.appName),this.paymentMethodsApi=new Qt(this.appName),this.paymentProvidersApi=new Zt(this.appName),this.plansApi=new ea(this.appName),this.subscriptionApi=new ta(this.appName),this.summariesApi=new aa(this.appName),this.subscriptionTenantConfigApi=new na(this.appName),this.vendorPublicConfigApi=new sa(this.appName),this.stripeProviderApi=new ia(this.appName),this.getSubscriptionInvoices=this.invoicesApi.getSubscriptionInvoices.bind(this.invoicesApi),this.getSubscriptionInvoice=this.invoicesApi.getSubscriptionInvoice.bind(this.invoicesApi),this.getSubscriptionInvoicePdf=this.invoicesApi.getSubscriptionInvoicePdf.bind(this.invoicesApi),this.getManagedSubscription=this.managedSubscriptionApi.getManagedSubscription.bind(this.managedSubscriptionApi),this.getManagedSubscriptions=this.managedSubscriptionApi.getManagedSubscriptions.bind(this.managedSubscriptionApi),this.cancelManagedSubscription=this.managedSubscriptionApi.cancelManagedSubscription.bind(this.managedSubscriptionApi),this.renewManagedSubscription=this.managedSubscriptionApi.renewManagedSubscription.bind(this.managedSubscriptionApi),this.updateManagedSubscription=this.managedSubscriptionApi.updateManagedSubscription.bind(this.managedSubscriptionApi),this.getPaymentMethods=this.paymentMethodsApi.getPaymentMethods.bind(this.paymentMethodsApi),this.getPaymentMethod=this.paymentMethodsApi.getPaymentMethod.bind(this.paymentMethodsApi),this.updatePaymentMethodBillingDetails=this.paymentMethodsApi.updatePaymentMethodBillingDetails.bind(this.paymentMethodsApi),this.getPaymentProviders=this.paymentProvidersApi.getPaymentProviders.bind(this.paymentProvidersApi),this.getSubscriptionPlans=this.plansApi.getSubscriptionPlans.bind(this.plansApi),this.getSubscriptionPlan=this.plansApi.getSubscriptionPlan.bind(this.plansApi),this.getSubscriptions=this.subscriptionApi.getSubscriptions.bind(this.subscriptionApi),this.getSubscription=this.subscriptionApi.getSubscription.bind(this.subscriptionApi),this.cancelSubscription=this.subscriptionApi.cancelSubscription.bind(this.subscriptionApi),this.renewSubscription=this.subscriptionApi.renewSubscription.bind(this.subscriptionApi),this.updateSubscription=this.subscriptionApi.updateSubscription.bind(this.subscriptionApi),this.getSubscriptionSummaries=this.summariesApi.getSubscriptionSummaries.bind(this.summariesApi),this.getTenantConfiguration=this.subscriptionTenantConfigApi.getTenantConfiguration.bind(this.subscriptionTenantConfigApi),this.createTenantConfiguration=this.subscriptionTenantConfigApi.createTenantConfiguration.bind(this.subscriptionTenantConfigApi),this.getVendorPublicConfigurations=this.vendorPublicConfigApi.getVendorPublicConfigurations.bind(this.vendorPublicConfigApi),this.createSubscription=this.stripeProviderApi.createSubscription.bind(this.stripeProviderApi),this.getStripeCustomer=this.stripeProviderApi.getStripeCustomer.bind(this.stripeProviderApi),this.createStripeCustomer=this.stripeProviderApi.createStripeCustomer.bind(this.stripeProviderApi),this.getStripePaymentProviderConfiguration=this.stripeProviderApi.getStripePaymentProviderConfiguration.bind(this.stripeProviderApi),this.createStripePaymentMethodSetupIntentSecret=this.stripeProviderApi.createStripePaymentMethodSetupIntentSecret.bind(this.stripeProviderApi)}}const ra=new oa("default");class la extends et{constructor(e){super(e),this.getVendorPublicInfo=async()=>this.get("/vendors/public")}}const ca=new la("default");class ua extends et{constructor(e){super(e),this.loadAllUsers=async e=>this.get(ne.v1,e),this.addUserToTenantAndSubTenants=async e=>this.post(ne.v1,e),this.removeUserFromTenantAndSubTenants=async(e,t)=>this.delete(ne.v1,e,{headers:this.extractHeadersFromOptions(t)}),this.addUserRolesForSubTenants=async(e,t,a)=>this.post(`${ne.v1}/${e}/roles`,t,{headers:this.extractHeadersFromOptions(a)}),this.removeUserRolesFromSubTenants=async(e,t,a)=>this.delete(`${ne.v1}/${e}/roles`,t,{headers:this.extractHeadersFromOptions(a)}),this.setUserRolesForSubTenants=async(e,t,a)=>this.patch(`${ne.v1}/${e}/roles`,t,{headers:this.extractHeadersFromOptions(a)}),this.createSubTenant=async(e,t)=>this.post(ve.v1,e,{headers:this.extractHeadersFromOptions(t)}),this.deleteSubTenant=async(e,t)=>this.delete(`${ve.v1}/${e}`,void 0,{headers:this.extractHeadersFromOptions(t)}),this.updateSubTenant=async({tenantId:e},t,a)=>this.patch(`${ve.v1}/${e}`,t,{headers:this.extractHeadersFromOptions(a)}),this.updateSubTenantManagement=async({tenantId:e},t,a)=>this.put(`${ve.v1}/${e}/management`,t,{headers:this.extractHeadersFromOptions(a)}),this.updateSubAccountAccess=async(e,t,a)=>this.put(`${ne.v1}/${e}/access`,t,{headers:this.extractHeadersFromOptions(a)}),this.addUsersToSubTenant=async(e,t)=>this.post(`${ne.v2}/`,e,{headers:this.extractHeadersFromOptions(t)})}updateSubTenantHierarchySettings({tenantId:e},t,a){return this.put(`${ve.v1}/${e}/hierarchy-settings`,t,{headers:this.extractHeadersFromOptions(a)})}}const da=new ua("default");class ga extends et{constructor(e){super(e),this.getConfigs=async()=>this.get(`${_e}`),this.updateConfiguration=async(e,t)=>this.patch(`${_e}/${e}`,t),this.createConfiguration=async e=>this.post(`${_e}`,e),this.deleteConfiguration=async(e,t)=>this.delete(`${_e}/${e}`,{deleteAll:t}),this.countConfigurationUsers=async e=>this.get(`${Ue}/${e}/Users/count`)}}const pa=new ga("default");class ha extends et{constructor(e){super(e),this.impersonate=async e=>this.post(`${se.v1}`,e)}}const ya=new ha("default"),va=["groupId"];class Sa extends et{constructor(e){super(e),this.getGroupById=async({groupId:e},t)=>this.get(`${oe.v1}/${e}`,S({},t)),this.getGroups=async e=>this.get(`${oe.v1}`,S({},e)),this.getGroupsByIds=async(e,t)=>this.post(`${oe.getByIds.v1}`,e,{params:t}),this.createGroup=async e=>this.post(`${oe.v1}`,e),this.updateGroup=async e=>{let{groupId:t}=e,a=f(e,va);return this.patch(`${oe.v1}/${t}`,a)},this.deleteGroup=async e=>this.delete(`${oe.v1}/${e}`),this.addRolesToGroup=async(e,t)=>this.post(`${oe.v1}/${e}/roles`,t),this.deleteRolesFromGroup=async(e,t)=>this.delete(`${oe.v1}/${e}/roles`,t),this.addUsersToGroup=async(e,t)=>this.post(`${oe.v1}/${e}/users`,t),this.deleteUsersFromGroup=async(e,t)=>this.delete(`${oe.v1}/${e}/users`,t),this.getGroupConfiguration=async()=>this.get(`${oe.configurations.v1}`),this.updateGroupConfiguration=async e=>this.post(`${oe.configurations.v1}`,e)}}const fa=new Sa("default");class ma extends et{constructor(e){super(e),this.getRecommendations=async()=>this.get(Le.v1),this.getInsights=async()=>this.get(Ce.v1)}}const ba=new ma("default");class Aa extends et{constructor(e){super(e),this.getUserPhoneNumbers=async e=>this.get(`${re.v1}`,e),this.getUserOwnPhoneNumbers=async()=>this.get(`${re.v1}/me`),this.createPhoneNumber=async e=>this.post(`${re.v1}`,e),this.deletePhoneNumber=async e=>this.delete(`${re.v1}/${e}`),this.preVerifyPhoneNumber=async e=>this.post(`${re.v1}/preverify`,e),this.verifyPhoneNumber=async e=>this.post(`${re.v1}/verify`,e),this.verifyDeletePhoneNumber=async(e,t)=>this.post(`${re.v1}/${e}/delete/verify`,t)}}const wa=new Aa("default");class Ta extends et{constructor(e){super(e),this.getUserApplicationsId=async({userId:e})=>this.get(`${ie.v1}/${e}/apps`),this.getUsersApplicationsId=async({userIds:e})=>this.get(`${ie.v1}/users-apps`,{userIds:e.join(",")}),this.getTenantsApplications=async()=>this.get(Ne.v1),this.getApplicationsData=async({appIds:e,includeFreeAccess:t=!0})=>this.get(De,{ids:e.join(","),_includeFreeAccess:t}),this.assignUserToApplications=async e=>this.post(`${ie.v1}/apps-user`,e),this.unassignUserFromApplications=async e=>this.delete(`${ie.v1}/user-apps`,e),this.getUsersOfApplications=async({appIds:e})=>this.get(`${ie.v1}/apps-users`,{appIds:e.join(",")})}}const Ea=new Ta("default"),Pa={"x-frontegg-api-key":"my-frontegg-api-key","frontegg-vendor-id":"04ae2174-d8d9-4a90-8bab-2548e210a508","frontegg-tenant-id":"02e6ab6f-8b25-48e4-b06d-2c53745ce213","frontegg-user-id":"e5c397a1-7120-4753-9216-e5d7f35d1f2d"};class Ia extends et{constructor(e){super(e),this.getAgentsConfig=async()=>this.get(`${Me}/config`,void 0,{headers:Pa}),this.getConversations=async()=>this.get(`${Me}/conversations`,void 0,{headers:Pa}),this.getConversationById=async e=>this.get(`${Me}/conversation/${e.id}`,void 0,{headers:Pa}),this.createConversation=async e=>this.post(`${Me}/conversations`,{message:e.message,stream:e.stream},{responseType:!1===e.stream?"json":"stream",headers:Pa}),this.sendMessage=async e=>this.post(`${Me}/conversation/${e.conversationId}/messages`,{message:e.message,stream:e.stream},{responseType:!1===e.stream?"json":"stream",headers:Pa}),this.sendApiResponse=async e=>this.post(`${Me}/conversation/${e.conversationId}/response/${e.callId}`,{data:e.data,status:e.status,stream:e.stream},{responseType:!1===e.stream?"json":"stream",headers:Pa}),this.getConversationResource=async e=>this.get(`${Me}/conversation/${e.conversationId}/resource/${e.resourceId}`,void 0,{headers:Pa})}}const Oa=new Ia("default");class ka extends et{constructor(e){super(e),this.getUserOwnUsername=async()=>this.get(`${le.v1}/me`),this.createUsername=async e=>this.post(`${le.v1}`,e),this.deleteUsername=async e=>this.delete(`${le.v1}/${e}`)}}const _a=new ka("default");class Ua extends et{constructor(e){super(e),this.getUserEmailPolicyConfig=async()=>this.get(`${X.v1}/user-emails-policy`)}}const Ra=new Ua("default");let La,Ca,Da,Na,Ma;!function(e){e.FRONTEGG="frontegg",e.SCIM2="scim2"}(La||(La={})),function(e){e.createdAt="createdAt",e.name="name",e.tenantId="tenantId"}(Ca||(Ca={})),function(e){e.CUSTOMER="customer",e.SPAM="spam",e.TEST="test",e.RESELLER="reseller",e.HEADQUARTER="headquarter"}(Da||(Da={})),function(e){e.NEVER="NEVER",e.ALWAYS="ALWAYS",e.ASSIGNABLE="ASSIGNABLE"}(Na||(Na={})),function(e){e.DEFAULT_OFF="defaultOff",e.DEFAULT_ON="defaultOn",e.ALWAYS_ON="alwaysOn"}(Ma||(Ma={}));const Fa=[/^(.*)\/logout$/g,"/logout",/^\/identity\/resources\/auth\/v[0-9]*\/user\/[^\/]*\/postlogin$/g,/^\/identity\/resources\/impersonation\/v[0-9]$/g,/^\/identity\/resources\/auth\/v[0-9]*\/passwordless\/[^\/]*\/postlogin$/g,/^\/identity\/resources\/auth\/v[0-9]*\/webauthn\/postlogin$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/token\/refresh$/g,/^\/identity\/resources\/users\/v[0-9]*\/signUp$/g,/^\/identity\/resources\/users\/v[0-9]*\/activate$/g,/^\/identity\/resources\/users\/v[0-9]*\/invitation\/accept$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/verify$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/[^\/]*\/[^\/]*\/verify$/g,/^\/oauth\/token$/g,/^\/oauth\/authorize\/silent$/g],xa=`${J.v1}/user/token/refresh`,$a=`${Oe}/authorize/silent`,Ga=`${Y.v2}/me`,ja=`${Y.v2}/me/tenants`,Ba=`${Y.v3}/me/tenants`,Va=Re;let Wa,Ha,za,Ka,qa;!function(e){e.FRONTEGG="frontegg",e.OKTA="okta",e.AZURE_AD="azure-ad",e.OTHER="other"}(Wa||(Wa={})),function(e){e.roles="roles",e.users="users",e.rolesAndUsers="rolesAndUsers"}(Ha||(Ha={})),function(e){e.FRONTEGG="frontegg",e.SCIM2="scim2"}(za||(za={})),function(e){e.createdAt="createdAt",e.name="name",e.email="email",e.id="id",e.verified="verified",e.isLocked="isLocked",e.provider="provider",e.tenantId="tenantId"}(Ka||(Ka={})),function(e){e.MFA_UNENROLLED="mfa-unenrolled",e.BREACHED_PASSWORDS="breached-passwords",e.INACTIVE="inactive"}(qa||(qa={}));const Ja=["local","saml","google","github","facebook","microsoft","scim2","slack"];let Ya,Xa,Qa,Za,en,tn,an;!function(e){e.MISSING_PERMISSION="MISSING_PERMISSION",e.MISSING_FEATURE="MISSING_FEATURE",e.BUNDLE_EXPIRED="BUNDLE_EXPIRED"}(Ya||(Ya={})),function(e){e.FORCE_MFA="FORCE_MFA",e.BREACHED_PASSWORDS_EXIST="BREACHED_PASSWORDS_EXIST",e.ENABLE_USER_LOCKOUT="ENABLE_USER_LOCKOUT",e.STRENGTHEN_USER_LOCKOUT="STRENGTHEN_USER_LOCKOUT",e.ENABLE_PASSWORD_HISTORY="ENABLE_PASSWORD_HISTORY",e.STRENGTHEN_PASSWORD_HISTORY="STRENGTHEN_PASSWORD_HISTORY",e.ENABLE_FORCE_RELOGIN="ENABLE_FORCE_RELOGIN",e.SET_FORCE_RELOGIN="SET_FORCE_RELOGIN",e.ENABLE_SESSION_CONCURRENCY="ENABLE_SESSION_CONCURRENCY",e.SET_SESSION_CONCURRENCY="SET_SESSION_CONCURRENCY",e.ENABLE_IDLE_SESSION="ENABLE_IDLE_SESSION",e.SET_IDLE_SESSION="SET_IDLE_SESSION",e.ENABLE_IP_RESTRICTIONS="ENABLE_IP_RESTRICTIONS",e.CHANGE_IP_TO_ALLOWLIST="CHANGE_IP_TO_ALLOWLIST",e.ENABLE_DOMAIN_RESTRICTIONS="ENABLE_DOMAIN_RESTRICTIONS",e.CHANGE_DOMAIN_TO_ALLOWLIST="CHANGE_DOMAIN_TO_ALLOWLIST",e.CONFIGURE_SSO="CONFIGURE_SSO"}(Xa||(Xa={})),function(e){e.MFA_FORCED="MFA_FORCED",e.PARTIALLY_FORCED_MFA="PARTIALLY_FORCED_MFA",e.PARTIAL_MFA_USAGE="PARTIAL_MFA_USAGE",e.FULL_MFA_USAGE="FULL_MFA_USAGE",e.BREACHED_PASSWORD_USERS_EXIST="BREACHED_PASSWORD_USERS_EXIST",e.IMPROVE_LOCKOUT_POLICY="IMPROVE_LOCKOUT_POLICY",e.IMPROVE_PASSWORD_HISTORY_POLICY="IMPROVE_PASSWORD_HISTORY_POLICY",e.NO_SESSION_SETTINGS="NO_SESSION_SETTINGS",e.PARTIAL_SESSION_SETTINGS="PARTIAL_SESSION_SETTINGS",e.FULL_SESSION_SETTINGS="FULL_SESSION_SETTINGS",e.NO_IP_RESTRICTIONS="NO_IP_RESTRICTIONS",e.IP_ALLOWLIST="IP_ALLOWLIST",e.IP_DENYLIST="IP_DENYLIST",e.NO_DOMAIN_RESTRICTIONS="NO_DOMAIN_RESTRICTIONS",e.DOMAIN_ALLOWLIST="DOMAIN_ALLOWLIST",e.DOMAIN_DENYLIST="DOMAIN_DENYLIST",e.FULL_PASSWORD_SETTINGS="FULL_PASSWORD_SETTINGS"}(Qa||(Qa={})),function(e){e.SEND_RESET_BREACHED_PASSWORD_EMAIL="SEND_RESET_BREACHED_PASSWORD_EMAIL",e.ADJUST_FORCE_RELOGIN="ADJUST_FORCE_RELOGIN",e.ADJUST_MAX_CONCURRENT_SESSIONS="ADJUST_MAX_CONCURRENT_SESSIONS",e.ADJUST_IDLE_TIMEOUT="ADJUST_IDLE_TIMEOUT"}(Za||(Za={})),function(e){e.SEVERE="SEVERE",e.WARNING="WARNING",e.INFO="INFO"}(en||(en={})),function(e){e.MFA="MFA",e.SESSIONS="SESSIONS",e.PASSWORD="PASSWORD",e.INACTIVITY="INACTIVITY",e.IP="IP",e.DOMAIN="DOMAIN",e.SSO="SSO"}(tn||(tn={})),function(e){e.FREE_ACCESS="FREE_ACCESS",e.MANAGED_ACCESS="MANAGED_ACCESS"}(an||(an={}));const nn={auth:Tt,securityPolicy:ft,teams:Pt,metadata:Ot,reports:Lt,connectivity:Mt,notifications:xt,audits:jt,tenants:ht,accountSettings:Vt,roles:qt,subscriptions:ra,vendor:ca,subTenants:da,featureFlags:st,directory:pa,impersonate:ya,groups:fa,users:lt,entitlements:vt,securityCenter:ba,userPhoneNumbers:wa,applications:Ea,velo:Oa,usernames:_a,userEmailPolicy:Ra},sn=e=>({auth:new wt(e),securityPolicy:new St(e),teams:new Et(e),metadata:new It(e),reports:new Rt(e),connectivity:new Nt(e),notifications:new Ft(e),audits:new Gt(e),tenants:new pt(e),accountSettings:new Bt(e),roles:new Kt(e),subscriptions:new oa(e),vendor:new la(e),subTenants:new ua(e),featureFlags:new nt(e),directory:new ga(e),impersonate:new ha(e),groups:new Sa(e),users:new rt(e),entitlements:new yt(e),securityCenter:new ma(e),userPhoneNumbers:new Aa(e),applications:new Ta(e),velo:new Ia(e),usernames:new ka(e),userEmailPolicy:new Ua(e)}),on={fetch:We,FetchClient:Ve,ContextHolder:R,FronteggContext:C,api:nn,createApiClient:sn,FronteggApiError:z,AuthStrategyEnum:N,MachineToMachineAuthStrategy:M,SocialLoginProviders:D,ISubscriptionCancellationPolicy:B,ISubscriptionStatus:G,PaymentMethodType:j,ProviderType:V,EIdentifierType:x};var rn=a(2743),ln=a.n(rn);const cn=(e,t)=>{const a=ln()(e,S({},t));return function(e={}){return I(e)}(S({__isProxy:!0},a))};let un;!function(e){e.validate="validate",e.invalid="invalid",e.pending="pending",e.success="success",e.failed="failed"}(un||(un={}));const dn={step:un.validate},gn=e=>cn(dn,e);var pn=a(5302),hn=a.n(pn),yn=a(1098),vn=a.n(yn);const Sn="http://schemas.openid.net/pape/policies/2007/06/multi-factor",fn="mfa",mn=["otp","sms","hwk"],bn="SHOULD_STEP_UP",An="maxAge";let wn,Tn,En,Pn;!function(e){e.preLogin="preLogin",e.magicLinkPreLoginSuccess="magicLinkPreLoginSuccess",e.loginWithSmsOtc="loginWithSmsOtc",e.loginWithQuickSmsOtc="loginWithQuickSmsOtc",e.loginWithOtc="loginWithOtc",e.loginWithPassword="loginWithPassword",e.loginWithTwoFactor="loginWithTwoFactor",e.redirectToSSO="redirectToSSO",e.loginWithSSOFailed="loginWithSSOFailed",e.success="success",e.forceTwoFactor="forceTwoFactor",e.recoverTwoFactor="recoverTwoFactor",e.promptPasskeys="promptPasskeys",e.breachedPassword="breachedPassword",e.breachedPasswordSuccess="breachedPasswordSuccess",e.passwordRotationExpired="passwordRotationExpired",e.passwordRotationNotification="passwordRotationNotification",e.magicLinkPostLoginSuccess="magicLinkPostLoginSuccess"}(wn||(wn={})),function(e){e.Login="login",e.RegisterQuickLogin="registerQuickLogin"}(Tn||(Tn={})),function(e){e.Internal="internal",e.UsbKey="usb-key",e.Android="android",e.Sms="sms"}(En||(En={})),function(e){e["social-login"]="social-login",e["custom-social-login"]="custom-social-login",e.direct="direct"}(Pn||(Pn={}));const In={[N.Code]:wn.loginWithOtc,[N.EmailAndPassword]:wn.loginWithPassword,[N.MagicLink]:wn.magicLinkPreLoginSuccess,[N.SmsCode]:wn.loginWithSmsOtc,[N.UsernameAndPassword]:wn.loginWithPassword,[N.UsernameAndMagicLink]:wn.magicLinkPreLoginSuccess,[N.UsernameAndCode]:wn.loginWithOtc,[N.UsernameAndSms]:wn.loginWithSmsOtc},On={authenticatedUrl:"/",loginUrl:"/account/login",stepUpUrl:"/account/step-up",logoutUrl:"/account/logout",activateUrl:"/account/activate",impersonationUrl:"/account/impersonate",acceptInvitationUrl:"/account/invitation/accept",forgetPasswordUrl:"/account/forget-password",resetPhoneNumberUrl:"/account/reset-phone-number",resetPasswordUrl:"/account/reset-password",socialLoginCallbackUrl:"/account/social/success",signUpUrl:"/account/sign-up",oidcRedirectUrl:"/account/oidc/callback",samlCallbackUrl:"/account/saml/callback",magicLinkCallbackUrl:"/account/login/magic-link",hostedLoginRedirectUrl:"/oauth/callback",openAppUrl:"/account/redirect",unlockAccountUrl:"/account/unlock",activateWithOTCUrl:"/account/activate/code",acceptInvitationWithOTCUrl:"/account/invitation/code",mfaMobileAuthenticator:"/account/mfa-mobile-authenticator"},kn="FRONTEGG_AFTER_AUTH_REDIRECT_URL",_n="HOSTED_LOGIN_VERIFIER_KEY",Un={retryCount:3},Rn=(e=500)=>new Promise((t=>{setTimeout(t,e)})),Ln=async(e,t,a,n)=>{let s=0;for(;s<t-1;)try{const i=await e();if(!n||null!==i)return i;if(s++,s>=t)return i;await new Promise((e=>setTimeout(e,a)))}catch(e){if(s++,s>=t)throw e;await new Promise((e=>setTimeout(e,a)))}return await e()},Cn=async(e,t)=>t?Ln(e,t.retryCount,t.delay||500,t.shouldRetryWhenNull):e(),Dn=e=>S({},e,{retryConfig:Un}),Nn=e=>(null==e?void 0:e.traceId)||void 0;function Mn(e,t){const a=S({},e);return t.forEach((e=>{delete a[e]})),a}function Fn(e){if(null!=e)return function(e){const t=typeof e;return(null==e?void 0:e.constructor)==={}.constructor||"undefined"===t||null===e||"boolean"===t||"number"===t||"string"===t||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof File||e instanceof FileList||e instanceof ArrayBuffer||e instanceof ImageData||e instanceof ImageBitmap||e instanceof Array||e instanceof Map||e instanceof Set}(e)&&void 0!==e.__isProxy}const xn=e=>JSON.parse(JSON.stringify(e)),$n=(e,t,a)=>{const n=xn(a),s=hn()(e,t);for(const a in s)"__isProxy"!==a&&(a in n?vn()(e,[...t,a],n[a]):vn()(e,[...t,a],void 0))},Gn=e=>Boolean(null==e?void 0:e.statusCode),jn=e=>e instanceof Error||(null==e?void 0:e.message)&&(null==e?void 0:e.stack)&&"Error"===(null==e?void 0:e.name),Bn=(e,t)=>e?Gn(e)?(console.error(e.message),e):(jn(e)?console.error(e.message):"string"==typeof e&&console.error(e),null!=t?t:new z(Fe,500,null,xe)):t,Vn=(e,t,a)=>{const n=t=>{Object.assign(e.auth.acceptInvitationState,t)};return{setAcceptInvitationState:n,resetAcceptInvitationState:()=>{$n(e,["auth","acceptInvitationState"],dn)},acceptInvitation:async e=>{if(e.token&&e.userId)try{n({error:void 0,step:un.pending}),await t.auth.acceptInvitation(e),n({step:un.success})}catch(e){n({step:un.failed,error:Bn(e)})}else n({error:void 0,step:un.invalid})},acceptInvitationWithOTC:async e=>{if(e.token&&e.userId&&e.code)try{n({error:void 0,step:un.pending}),await t.auth.acceptInvitationWithOTC(e),n({step:un.success})}catch(e){n({step:un.validate,error:Bn(e)})}else n({error:void 0,step:un.invalid})}}},Wn={loading:!1},Hn=e=>cn(Wn,e),zn=["activeTenant","tenants"],Kn=(e,t,a)=>{const n=t=>{Object.assign(e.auth.accountSettingsState,t)};return{setAccountSettingsState:n,resetAccountSettingsState:()=>{$n(e,["auth","accountSettingsState"],Wn)},saveAccountSettings:async s=>{try{var i;n({loading:!0});const{address:o,timezone:r,dateFormat:l,timeFormat:c,currency:u,logo:d}=e.auth.accountSettingsState,g=await t.accountSettings.updateSettings(S({address:o,timezone:r,dateFormat:l,timeFormat:c,currency:u,logo:d},s));(({newSettingValues:t})=>{const n=e.auth.tenantsState,{activeTenant:s,tenants:i}=n,o=f(n,zn),r=i.map((e=>e.id!==(null==s?void 0:s.id)?e:S({},e,t))),l=S({},s,t);a.setTenantsState(S({},o,{tenants:r,activeTenant:l}))})({newSettingValues:g}),n(S({},g,{loading:!1})),null==(i=s.callback)||i.call(s,g)}catch(e){var o;n({loading:!1,error:Bn(e)}),null==(o=s.callback)||o.call(s,null,e)}},loadAccountSettings:async e=>{n({loading:!(null!=e&&e.silentLoading),error:null});try{const a=await Cn((()=>t.accountSettings.getSettings()),null==e?void 0:e.retryConfig);n(S({},a,{loading:!1}))}catch(e){n({loading:!1,error:Bn(e)})}}}};let qn;!function(e){e.activating="activating",e.success="success",e.resend="resend",e.activatingForm="activatingForm"}(qn||(qn={}));const Jn={step:qn.activating,loading:!1,submitting:!1,resentEmail:!1,activationStrategy:{loading:!1}},Yn=e=>cn(Jn,e);let Xn,Qn,Zn,es;!function(e){e.LOAD_FEATURE_FLAGS="LOAD_FEATURE_FLAGS,",e.LOAD_ADMIN_BOX_METADATA="LOAD_ADMIN_BOX_METADATA,",e.LOAD_SSO_PUBLIC_CONFIGURATION="LOAD_SSO_PUBLIC_CONFIGURATION,",e.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY="LOAD_PUBLIC_AUTH_STRATEGIES_POLICY,",e.LOAD_ALLOW_SIGNUPS="LOAD_ALLOW_SIGNUPS,",e.LOAD_CUSTOM_LOGIN_ROUTES="LOAD_CUSTOM_LOGIN_ROUTES",e.LOAD_PASSWORD_CONFIGURATION="LOAD_PASSWORD_CONFIGURATION"}(Xn||(Xn={})),function(e){e.SOCIAL_LOGIN="SOCIAL_LOGIN",e.PASSWORDLESS="PASSWORDLESS",e.ACTIVATION_LINK="ACTIVATION_LINK"}(Qn||(Qn={})),function(e){e.SOCIAL_LOGIN="SOCIAL_LOGIN",e.PASSWORD="PASSWORD",e.PHONE_NUMBER="PHONE_NUMBER"}(Zn||(Zn={})),function(e){e.profile="profile",e.privacy="privacy",e.personalApiTokens="personalApiTokens",e.account="account",e.users="users",e.groups="groups",e.security="security",e.sso="sso",e.audits="audits",e.webhooks="webhooks",e.apiTokens="apiTokens",e.roles="roles",e.subscriptions="subscription",e.allAccounts="allAccounts"}(es||(es={}));const ts={profile:es.profile,privacy:es.privacy,personalApiTokens:es.personalApiTokens,account:es.account,users:es.users,groups:es.groups,security:es.security,sso:es.sso,audits:es.audits,webhooks:es.webhooks,apiTokens:es.apiTokens,roles:es.roles,subscriptions:es.subscriptions,allAccounts:es.allAccounts};let as,ns;function ss(e,t){var a,n;null==(a=(n=window).onFronteggEvent)||a.call(n,e,t)}!function(e){e.SIGNUP_COMPLETED="signup_completed",e.USER_VERIFIED="user_verified"}(as||(as={})),function(e){e.verify="verify",e.recoveryCode="recoveryCode",e.authenticatorApp="authenticatorApp",e.smsSetPhoneNumber="smsSetPhoneNumber",e.smsVerifyCode="smsVerifyCode",e.emailVerifyCode="emailVerifyCode",e.noMFAEnrolledStepUp="noMFAEnrolledStepUp"}(ns||(ns={}));const is=e=>{try{return new URL(e),!0}catch(e){return!1}},os=({authenticatedUrl:e,enforceRedirectToSameSite:t,allowedRedirectOrigins:a,includeQueryParam:n})=>{let s=e;const i=new URL(window.location.href).searchParams.get("redirectUrl");return i?t&&is(i)?((e,t)=>{const a=new URL(window.location.href),n=new URL(e),s=n.origin===a.origin;return t.includes(n.origin)||s})(i,a)?s=i:console.warn("The redirect url param is not valid, the origin is a different site"):s=i:n&&(s+=window.location.search),s},rs=e=>{const{searchParams:t}=new URL(e),a=t.toString();if(a)return`?${a}`},ls=(e,t=!1)=>{const{pathname:a,href:n}=new URL(e);if(t)return n;const s=rs(e);return s?a+s:a},cs=e=>{const t=new URLSearchParams(window.location.search).get(e);return null!=t?t:void 0},us="tenantId",ds=e=>{const t=+Boolean(e.webauthn.length),a=+Boolean(e.phones.length),n=+Boolean(e.authenticators.length),s=+Boolean(e.emails.length);return{numberOfWebAuthnDevices:t,numberOfPhoneDevices:a,numberOfAuthenticators:n,numberOfEmails:s,totalDevices:t+a+n+s}},gs=e=>{const{numberOfPhoneDevices:t,numberOfAuthenticators:a,numberOfEmails:n,totalDevices:s}=ds(e);if(1===s){if(a)return ns.authenticatorApp;if(t)return ns.smsVerifyCode;if(n)return ns.emailVerifyCode}return ns.verify},ps=e=>{if(1===e.length){const[t]=e;if(t===Qe.AuthenticatorApp)return ns.authenticatorApp;if(t===Qe.SMS)return ns.smsSetPhoneNumber;if(t===Qe.EmailCode)return ns.emailVerifyCode}return ns.verify},hs=e=>"/oauth/callback"===e;function ys(e){return"email"in e&&"string"==typeof e.email}function vs(e){return"username"in e&&"string"==typeof e.username}const Ss=e=>{const t=R.for(e.root.appName).getBasename();return null!=t&&t.endsWith("/")?t.slice(0,-1):t},fs=e=>void 0!==e.passwordExpiresIn&&void 0!==e.notificationPeriod&&e.passwordExpiresIn<=e.notificationPeriod,ms=(e,{maxAge:t}={})=>{if(!e)return!1;const{amr:a=[],acr:n="",auth_time:s}=e;if(t&&s&&!(Date.now()/1e3-s<=t))return!1;const i=n===Sn,o=-1!==a.indexOf(fn),r=void 0!==mn.find((e=>a.indexOf(e)));return i&&o&&r};function bs(){const e=window.location.pathname+window.location.search;window.localStorage.setItem(kn,e)}const As=(e,t,a)=>{bs();const n=new URLSearchParams(window.location.search);a&&n.set(An,a.toString()),t(`${e}${n?`?${n}`:""}`,{refresh:!1})},ws=["phoneNumber","email"],Ts=["authenticatedUrl"],Es=(e,t)=>{const a=R.for(t);return e.mfaRequired&&e.mfaToken?(a.setAccessToken(null),a.setUser(null),!0):(a.setAccessToken(e.accessToken),a.setUser(e),!1)},Ps=(e,t)=>{const a=R.for(t);return e.resetPasswordToken?(a.setAccessToken(null),!0):(a.setAccessToken(e.accessToken),a.setUser(e),!1)},Is=(e,t=[])=>Object.entries(e).reduce(((e,[a,n])=>"object"==typeof n?[...e,...Is(n,[...t,a])]:[...e,{type:[...t,a].join("/"),payload:n}]),[]),Os=e=>{var t;if("path"===e)return(null!=(t=window)?t:document).location.pathname;{var a;const e=((null!=(a=window)?a:document).location.hash||"#").substring(1);return-1!==e.indexOf("?")?e.substring(0,e.indexOf("?")):e}},ks=e=>{const{phoneNumber:t,email:a}=e,n=f(e,ws);return null!=a&&a.length&&Object.assign(n,{email:a}),null!=t&&t.length&&Object.assign(n,{phoneNumber:t}),n},_s=(e,t)=>{const a=f(S({},On,t),Ts);return Object.values(a).includes(e)};let Us;!function(e){e.USERS="USERS",e.STATS="STATS",e.UPDATE_USER="UPDATE_USER",e.DELETE_USER="DELETE_USER",e.RESEND_ACTIVATE_LINK="RESEND_ACTIVATE_LINK",e.RESEND_INVITATION_LINK="RESEND_INVITATION_LINK",e.ROLES_AND_PERMISSIONS="ROLES_AND_PERMISSIONS",e.CREATE_TOKEN_LINK="CREATE_TOKEN_LINK",e.GET_TOKEN_LINK="GET_TOKEN_LINK",e.UPDATE_TOKEN_LINK="UPDATE_TOKEN_LINK",e.DELETE_TOKEN_LINK="DELETE_TOKEN_LINK",e.CONFIG_TOKEN_LINK="CONFIG_TOKEN_LINK",e.CONFIG_TEMPORARY_USERS="CONFIG_TEMPORARY_USERS",e.UPDATE_USER_EXPIRATION_TIME="UPDATE_USER_EXPIRATION_TIME"}(Us||(Us={}));const Rs=["user"],Ls=["callback","events"],Cs=["user"],Ds=["callback","events"],Ns=["user"],Ms=["callback"],Fs=["callback"],xs=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auth.activateAccountState,t)},i=()=>{$n(e,["auth","activateAccountState"],Jn)},o=t=>{Object.assign(e.auth.activateAccountState.activationStrategy,t)},r=async({loginResponse:t,events:a,onRedirectTo:o,routes:r})=>{const{user:l}=t,c=f(t,Rs);if(l.redirectLocation)window.location.href=l.redirectLocation;else if(Es(l,e.root.appName)){s({step:qn.success});const e=await n.getMfaRequiredState(l);n.setAuthState(e),await Rn(1e3),o(r.loginUrl,{preserveQueryParams:!0})}else{var u;s({step:qn.success});const e={email:l.email,origin:Qn.ACTIVATION_LINK,id:l.id,tenantId:l.tenantId,name:l.name,createdAt:new Date};null==a||null==(u=a.userVerified)||u.call(a,e),ss(as.USER_VERIFIED,e),n.afterAuthenticationStateUpdate(S({user:l},c),{isAuthenticated:!0}),await Rn(5e3),await n.afterAuthNavigation(),i()}};return{setActivateState:s,resetActivateState:i,setActivateStrategyState:o,activateAccount:async a=>{const{callback:n,events:i}=a,o=f(a,Ls);s({loading:!0,submitting:!0});try{const a=R.for(e.root.appName).onRedirectTo,l=e.auth.routes,c=await t.auth.activateAccountV2(o),{user:u}=c,d=f(c,Cs);s({submitting:!1}),await r({loginResponse:S({user:u},d),events:i,onRedirectTo:a,routes:l}),null==n||n(!0)}catch(e){s({loading:!1,error:Bn(e)})}},preActivateAccount:async a=>{const{userId:i,token:r}=a;s({loading:!0,step:qn.activating});try{e.auth.isAuthenticated&&await n.silentLogout();const a=await t.auth.getActivateAccountStrategy({userId:i,token:r});o({strategy:a,loading:!1,error:void 0}),a.shouldSetPassword&&s({loading:!1,step:qn.activatingForm})}catch(e){s({loading:!1,error:Bn(e)})}},getActivateAccountStrategy:async e=>{const{callback:a}=e,n=f(e,Ms);o({loading:!0});try{const e=await t.auth.getActivateAccountStrategy(n);o({strategy:e,loading:!1,error:void 0}),null==a||a(e)}catch(e){o({loading:!1,error:Bn(e)})}},resendActivationEmail:async e=>{const{callback:a}=e,i=f(e,Fs);n.setTeamLoader({key:Us.RESEND_ACTIVATE_LINK,value:i.email}),s({loading:!0});try{await t.auth.resendActivationEmail(i),s({loading:!1,error:void 0,resentEmail:!0}),null==a||a(!0)}catch(e){s({loading:!1,error:Bn(e)}),null==a||a(null,e)}finally{n.setTeamLoader({key:Us.RESEND_ACTIVATE_LINK,value:!1})}},activateAccountWithCode:async a=>{const{callback:n,events:i}=a,o=f(a,Ds);s({loading:!0,submitting:!0});try{const a=R.for(e.root.appName).onRedirectTo,l=e.auth.routes,c=await t.auth.activateAccountWithOTC(o),{user:u}=c,d=f(c,Ns);s({submitting:!1}),await r({loginResponse:S({user:u},d),events:i,onRedirectTo:a,routes:l}),null==n||n(!0)}catch(e){s({submitting:!1,loading:!1,error:Bn(e),step:qn.activating})}}}},$s={loading:!1,error:void 0,unlockAccountSuccess:!1},Gs=e=>cn($s,e),js=(e,t,a)=>{const n=t=>{Object.assign(e.auth.unlockAccountState,t)};return{setUnlockAccountState:n,resetUnlockAccountState:()=>{$n(e,["auth","activateAccountState"],$s)},unlockAccount:async a=>{const{token:s}=a,i=R.for(e.root.appName).onRedirectTo,o=e.auth.routes;n({loading:!0});try{await t.users.unlockMe({token:s}),n({loading:!1,error:void 0,unlockAccountSuccess:!0}),await Rn(5e3),i(o.loginUrl)}catch(e){n({loading:!1,error:Bn(e)})}}}},Bs={apiTokenType:null,showAddTokenDialog:!1,createdByUserIdColumn:"show",deleteTokenDialog:{open:!1,clientId:""},successDialog:{open:!1,secret:"",clientId:""},loaders:{},apiTokensDataTenant:[],apiTokensDataUser:[],roles:[],permissions:[],errors:{}},Vs=e=>cn(Bs,e);let Ws;!function(e){e.LOAD_API_TOKENS="LOAD_API_TOKENS",e.ADD_API_TOKEN="ADD_API_TOKEN",e.DELETE_API_TOKEN="DELETE_API_TOKEN"}(Ws||(Ws={}));const Hs=(e,t,a)=>{const n=t=>{Object.assign(e.auth.apiTokensState,{loaders:S({},e.auth.apiTokensState.loaders,{[t.key]:t.value})})},s=t=>{Object.assign(e.auth.apiTokensState,{errors:S({},e.auth.apiTokensState.errors,{[t.key]:t.value}),loaders:S({},e.auth.apiTokensState.loaders,{[t.key]:!1})})},i=t=>{Object.assign(e.auth.apiTokensState,t)};return{setApiTokensLoader:n,setApiTokensError:s,setApiTokensState:i,resetApiTokensState:()=>{$n(e,["auth","apiTokensState"],Bs)},loadApiTokens:async e=>{null!=e&&e.silentLoading||n({key:Ws.LOAD_API_TOKENS,value:!0});try{var a;const[s=[],o=[]]=await Promise.all([t.auth.getUserApiTokensData(),t.auth.getTenantApiTokensData()]);i({apiTokensDataUser:s,apiTokensDataTenant:o}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==e||null==(a=e.callback)||a.call(e,!0)}catch(t){var o;s({key:Ws.LOAD_API_TOKENS,value:Bn(t)}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==e||null==(o=e.callback)||o.call(e,null,t)}},loadUserApiTokens:async e=>{null!=e&&e.silentLoading||n({key:Ws.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([Cn((()=>t.auth.getUserApiTokensData()),null==e?void 0:e.retryConfig),Cn((()=>t.auth.getUserAccessTokensData()),null==e?void 0:e.retryConfig)]),l=(null!=(a=r.accessTokens)?a:[]).map((e=>S({},e,{type:M.AccessToken}))).concat(s.map((e=>S({},e,{type:M.ClientCredentials})))).sort(((e,t)=>new Date(t.createdAt)-new Date(e.createdAt)));i({apiTokensDataUser:null!=l?l:[]}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==e||null==(o=e.callback)||o.call(e,!0)}catch(t){var r;s({key:Ws.LOAD_API_TOKENS,value:Bn(t)}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==e||null==(r=e.callback)||r.call(e,null,t)}},loadTenantApiTokens:async e=>{null!=e&&e.silentLoading||n({key:Ws.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([Cn((()=>t.auth.getTenantApiTokensData()),null==e?void 0:e.retryConfig),Cn((()=>t.auth.getTenantAccessTokensData()),null==e?void 0:e.retryConfig)]),l=(null!=(a=null==r?void 0:r.accessTokens)?a:[]).map((e=>S({},e,{type:M.AccessToken}))).concat(s.map((e=>S({},e,{type:M.ClientCredentials})))).sort(((e,t)=>new Date(t.createdAt)-new Date(e.createdAt)));i({apiTokensDataTenant:null!=l?l:[]}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==e||null==(o=e.callback)||o.call(e,!0)}catch(t){var r;s({key:Ws.LOAD_API_TOKENS,value:Bn(t)}),n({key:Ws.LOAD_API_TOKENS,value:!1}),null==e||null==(r=e.callback)||r.call(e,null,t)}},addTenantApiToken:async a=>{const{description:o,roleIds:r,expires:l,callback:c}=a,u=Ws.ADD_API_TOKEN;n({key:u,value:!0});try{const{policy:a}=e.auth.securityPolicyState.publicPolicy,n=(null==a?void 0:a.machineToMachineAuthStrategy)===M.AccessToken;let s,u=null;l&&(u=1440*l),s=n?await t.auth.createTenantAccessToken({description:o,expiresInMinutes:u,roleIds:r}):await t.auth.updateTenantApiTokensData({description:o,roleIds:r,expiresInMinutes:u}),i({showAddTokenDialog:!1}),await Rn(200);const d=n?M.AccessToken:M.ClientCredentials;e.auth.apiTokensState.apiTokensDataTenant.unshift(S({},s,{type:d})),e.auth.apiTokensState.successDialog={open:!0,secret:s.secret,clientId:n?void 0:s.clientId},null==c||c(null)}catch(e){s({key:u,value:Bn(e)}),null==c||c(null,e)}finally{n({key:u,value:!1})}},addUserApiToken:async a=>{const{description:o,expires:r,callback:l}=a,c=Ws.ADD_API_TOKEN;n({key:c,value:!0});try{const{policy:a}=e.auth.securityPolicyState.publicPolicy,n=(null==a?void 0:a.machineToMachineAuthStrategy)===M.AccessToken;let s,c=null;r&&(c=1440*r),s=n?await t.auth.createUserAccessToken({description:o,expiresInMinutes:c}):await t.auth.updateUserApiTokensData({description:o,expiresInMinutes:c}),i({showAddTokenDialog:!1}),await Rn(200);const u=n?M.AccessToken:M.ClientCredentials;e.auth.apiTokensState.apiTokensDataUser.unshift(S({},s,{type:u})),e.auth.apiTokensState.successDialog={open:!0,secret:s.secret,clientId:n?void 0:s.clientId},null==l||l(null)}catch(e){s({key:c,value:Bn(e)}),null==l||l(null,e)}finally{n({key:c,value:!1})}},deleteUserApiToken:async a=>{const o=Ws.DELETE_API_TOKEN;n({key:o,value:!0});try{const n=e.auth.apiTokensState.apiTokensDataUser;n.some((e=>e.id===a))?(await t.auth.deleteUserAccessToken({id:a}),i({apiTokensDataUser:n.filter((e=>e.id!==a)),deleteTokenDialog:{open:!1,id:a}})):(await t.auth.deleteUserApiToken({tokenId:a}),i({apiTokensDataUser:n.filter((e=>e.clientId!==a)),deleteTokenDialog:{open:!1,clientId:a}}))}catch(e){s({key:o,value:Bn(e)})}finally{n({key:o,value:!1})}},deleteTenantApiToken:async a=>{const o=Ws.DELETE_API_TOKEN;n({key:o,value:!0});try{const n=e.auth.apiTokensState.apiTokensDataTenant;n.some((e=>e.id===a))?(await t.auth.deleteTenantAccessToken({id:a}),i({apiTokensDataTenant:n.filter((e=>e.id!==a)),deleteTokenDialog:{open:!1,id:a}})):(await t.auth.deleteTenantApiToken({tokenId:a}),i({apiTokensDataTenant:n.filter((e=>e.clientId!==a)),deleteTokenDialog:{open:!1,id:a}}))}catch(e){s({key:o,value:Bn(e)})}finally{n({key:o,value:!1})}}}},zs={loading:!0,fetching:!0,error:null,userApplications:[],accountApplications:[]},Ks=e=>cn(zs,e),qs=e=>{var t;return null!=(t=e.map((({appIds:e})=>e)).reduce(((e,t)=>(null==t||t.forEach((t=>{e&&!e.includes(t)&&e.push(t)})),e)),[]))?t:[]},Js=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auth.applicationsState,t)},i=async({userIds:e,retryConfig:a})=>{try{const n=await Cn((()=>t.applications.getUsersApplicationsId({userIds:e})),a),s=qs(n),i=await Cn((()=>t.applications.getApplicationsData({appIds:s})),a);return e.reduce(((e,t)=>{var a,s,o;const r=null==(a=n.find((e=>e.userId==t)))?void 0:a.appIds;return e[t]=[...i.filter((e=>e.accessType===an.FREE_ACCESS)),...null!=(s=null==r||null==(o=r.map((e=>i.find((t=>e===t.id)))))?void 0:o.filter((e=>!!e)))?s:[]],e}),{})}catch(e){s({error:Bn(e)})}},o="Assignment action failed. Try again or contact support.";return{setApplicationsState:s,resetApplicationsState:()=>{$n(e,["auth","applicationsState"],zs)},loadUserApplications:async a=>{s({loading:!0,fetching:!0});try{var n,i;const o=null!=(n=null==(i=e.auth.user)?void 0:i.id)?n:"",r=null==a?void 0:a.retryConfig,l=await Cn((()=>t.applications.getUserApplicationsId({userId:o})),r),c=await Cn((()=>t.applications.getApplicationsData({appIds:l})),r);s({userApplications:c,fetching:!1,loading:!1})}catch(e){s({loading:!1,fetching:!1,error:Bn(e)})}},loadAccountApplications:async e=>{const a=null==e?void 0:e.retryConfig;s({loading:!0,fetching:!0});try{const e=await Cn((()=>t.applications.getTenantsApplications()),a),n=qs(e),i=await Cn((()=>t.applications.getApplicationsData({appIds:n})),a),o=await Cn((()=>t.applications.getUsersOfApplications({appIds:n})),a),r=i.map((e=>{var t;return S({},e,{userIds:null==(t=o.find((t=>t.appId===e.id)))?void 0:t.userIds})}));s({accountApplications:r,fetching:!1,loading:!1})}catch(e){s({loading:!1,fetching:!1,error:Bn(e)})}},loadMultipleUsersApplications:i,assignUserToApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,g,p,h,y,v,f;const n=null!=(c=null==(u=e.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await t.applications.assignUserToApplications({userId:i,appIds:r,tenantId:n});const s=null==(g=e.auth)||null==(p=g.applicationsState)?void 0:p.accountApplications,o=null!=(h=null==(y=e.auth)||null==(v=y.teamState)?void 0:v.users)?h:[],m=null!=(f=null==s?void 0:s.filter((e=>r.includes(e.id))))?f:[];null!=m&&m.length&&a.setTeamState({users:o.map((e=>{var t;return e.id===i?S({},e,{applications:[...null!=(t=e.applications)?t:[],...m]}):e}))}),null==l||l(!0)}catch(e){s({error:Bn(e,o)}),null==l||l(!1)}},unassignUserFromApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,g,p,h,y;const n=null!=(c=null==(u=e.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await t.applications.unassignUserFromApplications({userId:i,appIds:r,tenantId:n});const s=null!=(g=null==(p=e.auth)||null==(h=p.teamState)?void 0:h.users)?g:[],o=null==(y=s.find((e=>e.id===i)))?void 0:y.applications;null!=o&&o.length&&r.length&&a.setTeamState({users:s.map((e=>e.id===i?S({},e,{applications:o.filter((e=>!r.includes(e.id)))}):e))}),null==l||l(!0)}catch(e){s({error:Bn(e,o)}),null==l||l(!1)}},assignNewUserToApps:async({appIds:a,user:s})=>{var i,o,r;const[l]=await n.getFeatureFlags(["multi-apps-admin-portal"]);if(!l)return;const c=null==(i=e.auth)||null==(o=i.applicationsState)?void 0:o.accountApplications,u=null!=(r=null==c?void 0:c.filter((e=>e.accessType===an.FREE_ACCESS)))?r:[];if(null!=a&&a.length){var d,g,p;const n=null!=(d=null==(g=e.auth)||null==(p=g.user)?void 0:p.tenantId)?d:"";return await t.applications.assignUserToApplications({userId:s.id,appIds:a,tenantId:n}),a.map((e=>{var t;return null!=(t=null==c?void 0:c.find((t=>t.id===e)))?t:[]})).concat(u)}return u},mapUsersWithApplicationData:async({shouldLoadApps:e,users:t,retryConfig:n})=>{const[s]=await a.getFeatureFlags(["multi-apps-admin-portal"]);if(!s||!e)return t;const o=t.map((e=>e.id)),r=await i({userIds:o,retryConfig:n});return r?t.map((e=>null!=r&&r[e.id]?S({},e,{applications:r[e.id]}):e)):t}}},Ys={loading:!0,error:null},Xs=e=>cn(Ys,e),Qs=["callback"],Zs=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auth.customLoginState,t)},i=async()=>{var t,a,n,s,i;return e.auth.isAuthenticated?null!=(s=null==(i=e.auth.tenantsState.activeTenant)?void 0:i.hasCustomLogin)&&s:!!(null==(t=await(null==(a=R.for(e.root.appName).getContext())||null==(n=a.tenantResolver)?void 0:n.call(a)))?void 0:t.tenant)};return{setCustomLoginState:s,resetCustomLoginState:()=>{$n(e,["auth","customLoginState"],Ys)},loadTenantMetadata:async()=>{s({loading:!0});try{const e=await t.metadata.getAdminBoxMetadata();s({tenantMetadata:e,loading:!1})}catch(e){s({loading:!1,error:Bn(e)})}},updateTenantMetadata:async e=>{const{callback:a}=e,n=f(e,Qs);try{s({error:null,saving:!0});const e=Is(n);if(0===e.length)throw new Error("No changes to update");await t.metadata.updateAdminBoxMetadata({actions:e});const i=await t.metadata.getAdminBoxMetadata();s({tenantMetadata:i,saving:!1}),null==a||a(!0)}catch(e){s({error:Bn(e,"No changes to update"),saving:!1}),null==a||a(null,e)}},customLoginEnabled:i,loadCustomLoginRoutes:async a=>{try{var o,r,l;if(!await i())return void(null==a||null==(l=a.callback)||l.call(a,!0));const u=e.auth.isAuthenticated,{getSettings:d,getPublicSettings:g}=t.accountSettings,{applicationUrl:p}=await Cn(u?d:g,null==a?void 0:a.retryConfig);var c;if(!p)return void(null==a||null==(c=a.callback)||c.call(a,!0));const h=e.auth.routes,y=null!=(o=rs(p))?o:"";n.setAuthState({routes:S({},h,{customLoginAuthenticatedUrl:p,customLoginUrl:h.loginUrl+y})}),s({customLoginSearchParams:null!=y?y:void 0}),null==a||null==(r=a.callback)||r.call(a,!0)}catch(e){var u;null==a||null==(u=a.callback)||u.call(a,null,e)}}}};let ei;!function(e){e.forgotPassword="forgotPassword",e.resetPasswordViaSms="resetPasswordViaSms",e.passwordRecoverySelector="passwordRecoverySelector",e.resetPasswordPage="resetPasswordPage",e.success="success"}(ei||(ei={}));const ti={step:ei.forgotPassword,loading:!1,identifier:"",identifierType:x.email,sessionId:"",userId:"",token:"",passwordConfig:null},ai=e=>cn(ti,e),ni=["callback"],si=(e,t,a)=>{const n=t=>{Object.assign(e.auth.forgotPasswordState,t)},s=async()=>{const{identifier:a,identifierType:s}=e.auth.forgotPasswordState;n({loading:!0});try{await t.auth.resetPasswordViaEmail({identifier:a,identifierType:s}),n({loading:!1,error:void 0,step:ei.success})}catch(e){n({loading:!1,error:Bn(e,"An error occurred while sending recovery email")})}};return{setForgotPasswordState:n,resetForgotPasswordState:()=>{$n(e,["auth","forgotPasswordState"],ti)},forgotPassword:async e=>{n({loading:!0});try{var a;await t.auth.forgotPassword(e),n({loading:!1,error:void 0,step:ei.success}),null==(a=e.callback)||a.call(e,!0)}catch(t){var s;n({loading:!1,error:Bn(t,"Unknown error occurred")}),null==(s=e.callback)||s.call(e,!1,t)}},resetPassword:async e=>{const{callback:a}=e,s=f(e,ni);n({loading:!0});try{await t.auth.resetPassword(s),n({loading:!1,error:void 0,step:ei.success}),null==a||a(!0)}catch(e){n({loading:!1,error:Bn(e)}),null==a||a(!1,e)}},loadPasswordConfig:async e=>{n({loading:!0});try{const a=await t.auth.loadPasswordConfig(e);n({loading:!1,passwordConfig:a})}catch(e){n({loading:!1,error:Bn(e)})}},determinePasswordRecoveryStrategy:async e=>{n({loading:!0,error:void 0,identifier:e.identifier,identifierType:e.identifierType});try{const e=await t.auth.getPasswordRecoveryStrategies(),a=e.some((e=>e.strategy===$.Email&&e.isActive)),i=e.some((e=>e.strategy===$.Sms&&e.isActive));a&&i?n({loading:!1,step:ei.passwordRecoverySelector,activeStrategies:e}):a?await s():n(i?{loading:!1,step:ei.resetPasswordViaSms,activeStrategies:e}:{loading:!1,error:"No active password recovery methods found.",activeStrategies:e})}catch(e){n({loading:!1,error:Bn(e,"An error occurred while determining recovery strategy")})}},sendPasswordRecoveryEmail:s,sendPasswordRecoverySms:async()=>{const{identifier:a,identifierType:s}=e.auth.forgotPasswordState;n({loading:!0});try{const e=await t.auth.resetPasswordViaSms({identifier:a,identifierType:s});n({loading:!1,error:void 0,sessionId:e.sessionId})}catch(e){n({loading:!1,error:Bn(e,"An error occurred while sending recovery sms")})}},verifyPasswordViaSms:async a=>{const{sessionId:s}=e.auth.forgotPasswordState;if(s){n({loading:!0});try{const e=await t.auth.verifyPasswordViaSms({otcToken:a.otcToken,sessionId:s});if(!e.userId||!e.token)throw new Error("Invalid response from server: missing userId or token");n({loading:!1,error:void 0,userId:e.userId,token:e.token,step:ei.resetPasswordPage})}catch(e){n({loading:!1,error:Bn(e,"An error occurred while verifying password via sms")})}}else n({loading:!1,error:"Session ID not found in state for verifying password via sms."})}}};let ii;!function(e){e.success="success",e.notification="notification"}(ii||(ii={}));const oi={step:ii.notification},ri=e=>cn(oi,e),li=(e,t,a)=>({setStep:t=>{var a;a={step:t},Object.assign(e.auth.passwordRotationState,a)}}),ci={loaders:{},errors:{},groups:[],groupsConfiguration:{}},ui=e=>cn(ci,e);let di,gi;!function(e){e.CREATE_GROUP="CREATE_GROUP",e.GET_GROUP="GET_GROUP",e.GET_GROUPS="GET_GROUPS",e.DELETE_GROUP="DELETE_GROUP",e.UPDATE_GROUP="UPDATE_GROUP",e.ADD_USERS_TO_GROUP="ADD_USERS_TO_GROUP",e.DELETE_USERS_FROM_GROUP="DELETE_USERS_FROM_GROUP",e.ADD_ROLES_TO_GROUP="ADD_ROLES_TO_GROUP",e.DELETE_ROLES_FROM_GROUP="DELETE_ROLES_FROM_GROUP",e.GET_GROUP_CONFIGURATION="GET_GROUP_CONFIGURATION",e.UPDATE_GROUP_CONFIGURATION="UPDATE_GROUP_CONFIGURATION",e.GET_TEAM_USERS="GET_TEAM_USERS"}(di||(di={})),function(e){e.roles="roles",e.users="users",e.rolesAndUsers="rolesAndUsers"}(gi||(gi={}));const pi=["roleIds","userIds"],hi=(e,t,a)=>{const n=t=>{Object.assign(e.auth.groupsState,{loaders:S({},e.auth.groupsState.loaders,{[t.key]:t.value})})},s=t=>{Object.assign(e.auth.groupsState,{errors:S({},e.auth.groupsState.errors,{[t.key]:t.value}),loaders:S({},e.auth.groupsState.loaders,{[t.key]:!1})})},i=t=>{Object.assign(e.auth.groupsState,t)},o=async a=>{const o=di.GET_GROUPS,r=e.auth.groupsState;n({key:o,value:!0});try{const{groups:e}=await Cn((()=>t.groups.getGroups({_groupsRelations:gi.rolesAndUsers})),null==a?void 0:a.retryConfig);i(S({groups:e},r.selectedGroup&&{selectedGroup:e.find((e=>{var t;return e.id===(null==(t=r.selectedGroup)?void 0:t.id)}))}))}catch(e){s({key:o,value:Bn(e)})}finally{n({key:o,value:!1})}},r=async e=>{const a=di.ADD_ROLES_TO_GROUP;n({key:a,value:!0});try{var i;await t.groups.addRolesToGroup(e.groupId,{roleIds:e.roleIds}),await o(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;s({key:a,value:Bn(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{n({key:a,value:!1})}},l=async e=>{const a=di.ADD_USERS_TO_GROUP;n({key:a,value:!0});try{var i;await t.groups.addUsersToGroup(e.groupId,{userIds:e.userIds}),await o(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;null==e||null==(r=e.callback)||r.call(e,!1),s({key:a,value:Bn(t)})}finally{n({key:a,value:!1})}},c=async e=>{const a=di.GET_GROUP_CONFIGURATION;n({key:a,value:!0});try{const a=await Cn((()=>t.groups.getGroupConfiguration()),null==e?void 0:e.retryConfig);i({groupsConfiguration:a})}catch(e){s({key:a,value:Bn(e)})}finally{n({key:a,value:!1})}};return{setUsersGroupsLoader:n,setUsersGroupsError:s,setGroupsState:i,resetUsersGroupsState:()=>{$n(e,["auth","groupsState"],ci)},loadGroups:o,getGroupById:async e=>{const a=di.GET_GROUP;n({key:a,value:!0});try{const a=await t.groups.getGroupById({groupId:e.groupId},{_groupsRelations:gi.rolesAndUsers});i({selectedGroup:a})}catch(e){s({key:a,value:Bn(e)})}finally{n({key:a,value:!1})}},createGroup:async e=>{const a=di.CREATE_GROUP,{roleIds:i,userIds:c}=e,u=f(e,pi);n({key:a,value:!0});try{var d;const a=await t.groups.createGroup(S({name:u.name},!!u.description&&{description:u.description},{color:u.color}));null!=c&&c.length&&l({groupId:a.id,userIds:c}),null!=i&&i.length&&r({groupId:a.id,roleIds:i}),await o(),null==e||null==(d=e.callback)||d.call(e,!0)}catch(t){var g;s({key:a,value:Bn(t)}),null==e||null==(g=e.callback)||g.call(e,!1)}finally{n({key:a,value:!1})}},updateGroup:async e=>{const a=di.UPDATE_GROUP;n({key:a,value:!0});try{var i;await t.groups.updateGroup(e),await o(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;s({key:a,value:Bn(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{n({key:a,value:!1})}},deleteGroup:async e=>{const a=di.DELETE_GROUP;n({key:a,value:!0});try{var i;await t.groups.deleteGroup(e.groupId),await o(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;s({key:a,value:Bn(t)}),null==e||null==(r=e.callback)||r.call(e,!1,t)}finally{n({key:a,value:!1})}},addRolesToGroup:r,deleteRolesFromGroup:async e=>{const a=di.DELETE_ROLES_FROM_GROUP;n({key:a,value:!0});try{var i;await t.groups.deleteRolesFromGroup(e.groupId,{roleIds:e.roleIds}),await o(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;s({key:a,value:Bn(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{n({key:a,value:!1})}},addUsersToGroup:l,deleteUsersFromGroup:async e=>{const a=di.DELETE_USERS_FROM_GROUP;n({key:a,value:!0});try{var i;await t.groups.deleteUsersFromGroup(e.groupId,{userIds:e.userIds}),await o(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;s({key:a,value:Bn(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{n({key:a,value:!1})}},getGroupConfiguration:c,updateGroupConfiguration:async e=>{const a=di.UPDATE_GROUP_CONFIGURATION;n({key:a,value:!0});try{await t.groups.updateGroupConfiguration(e),await c()}catch(e){s({key:a,value:Bn(e)})}finally{n({key:a,value:!1})}},getTeamUsers:async e=>{const a=di.GET_TEAM_USERS;n({key:a,value:!0});try{const{items:a}=await t.users.getUsersV2({_filter:e.filter,_offset:e.pageOffset,_limit:e.pageSize,_includeSubTenants:!1});i({teamUsers:a})}catch(e){s({key:a,value:Bn(e)})}finally{n({key:a,value:!1})}}}},yi={addGroupDialogState:{loading:!1,open:!1},editGroupDialogState:{loading:!1,open:!1},deleteGroupDialogState:{loading:!1,open:!1},addMembersToGroupDialogState:{loading:!1,open:!1,userIds:[]},deleteMemberFromGroupDialogState:{loading:!1,open:!1}},vi=e=>cn(yi,e),Si=(e,t,a)=>({setGroupsDialogsState:t=>{Object.assign(e.auth.groupsDialogsState,t)},resetGroupsDialogsState:()=>{$n(e,["auth","groupsDialogsState"],yi)},openAddGroupDialog:()=>{e.auth.groupsDialogsState.addGroupDialogState.open=!0},closeAddGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.addGroupDialogState,{open:!1,group:void 0})},openAddMembersToGroupDialog:()=>{e.auth.groupsDialogsState.addMembersToGroupDialogState.open=!0},closeAddMembersToGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.addMembersToGroupDialogState,{open:!1,userIds:[]})},openEditGroupDialog:t=>{Object.assign(e.auth.groupsDialogsState.editGroupDialogState,S({},t,{open:!0}))},closeEditGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.editGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteGroupDialog:t=>{Object.assign(e.auth.groupsDialogsState.deleteGroupDialogState,S({},t,{open:!0}))},closeDeleteGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.deleteGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteMemberFromGroupDialog:t=>{Object.assign(e.auth.groupsDialogsState.deleteMemberFromGroupDialogState,t)},closeDeleteMemberFromGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.deleteMemberFromGroupDialogState,{open:!1,userId:void 0,email:void 0})}});let fi;!function(e){e.impersonating="impersonating",e.success="success"}(fi||(fi={}));const mi={step:fi.impersonating,loading:!1},bi=e=>cn(mi,e),Ai=["callback","events"],wi=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auth.impersonateState,t)},i=()=>{$n(e,["auth","impersonateState"],mi)};return{setImpersonateState:s,resetImpersonateState:i,impersonate:async e=>{const{callback:a}=e,o=f(e,Ai);s({loading:!0});try{await t.impersonate.impersonate(o),s({step:fi.success}),await Rn(1e3),await n.afterAuthNavigation({preventRedirectUrlOriginCleaning:!0}),i(),null==a||a(!0)}catch(e){s({loading:!1,error:Bn(e)})}}}},Ti={flow:Tn.Login,step:wn.preLogin,loading:!1,email:"",tenants:[]},Ei=e=>cn(Ti,e),Pi=(e,t,a)=>{const n=a;const s=async(t,a={})=>{const{customLoginAuthenticatedUrl:n,forceStepUpUrl:s,shouldStepUpDuringLogin:i,preventRedirectUrlOriginCleaning:o=!1}=a,r=e.auth.onRedirectTo;let l;if(s)l=s;else{var c;if(i){const e=window.localStorage.getItem(kn);e&&!is(e)&&(l=e)}l||(l=await async function({customLoginAuthenticatedUrl:t,preventRedirectUrlOriginCleaning:a}){const{routes:n,includeQueryParam:s=!1,enforceRedirectToSameSite:i=!1,allowedRedirectOrigins:o=[]}=e.auth,r=window.localStorage.getItem(kn);if(t&&!r)return ls(t,a);const{authenticatedUrl:l,loginUrl:c,logoutUrl:u,socialLoginCallbackUrl:d,activateUrl:g,activateWithOTCUrl:p}=n;let h=r;h&&![c,u,d,g,p].includes(h)||(h=l);const y=os({authenticatedUrl:h,includeQueryParam:s,enforceRedirectToSameSite:i,allowedRedirectOrigins:o});return a?y:(v=y).startsWith(null==(S=window)?void 0:S.location.origin)?v.replace(null==(f=window)?void 0:f.location.origin,""):v;var v,S,f}({customLoginAuthenticatedUrl:n,preventRedirectUrlOriginCleaning:o})),null==(c=window)||c.localStorage.removeItem(kn)}await Rn(200),await t(),r(l,{refresh:l.startsWith("http")})};return{afterAuthNavigationUtil:s,afterAuthNavigation:async t=>{var a,i;const{customLoginAuthenticatedUrl:o,stepUpUrl:r}=e.auth.routes,l=null==(a=window)?void 0:a.localStorage.getItem(bn),c=e.auth.user;var u;if(l&&(null==(u=window)||u.localStorage.removeItem(bn)),r&&l&&!ms(c))return s(n.resetLoginState,{forceStepUpUrl:r});let d=o;var g;return o||(await n.loadCustomLoginRoutes(),d=null==(g=e.auth.routes)?void 0:g.customLoginAuthenticatedUrl),s(n.resetLoginState,{customLoginAuthenticatedUrl:d,shouldStepUpDuringLogin:!!l,preventRedirectUrlOriginCleaning:null!=(i=null==t?void 0:t.preventRedirectUrlOriginCleaning)&&i})},afterStepUpAuthNavigation:async()=>s(n.resetStepUpState),afterAuthenticationStateUpdate:function({user:t,tenants:a=[],activeTenant:s},i={}){const o=e.auth.tenantsState;n.setAuthState(S({user:t,tenantsState:S({},o,{tenants:a,activeTenant:s,loading:!1})},i))}}},Ii=["callback"],Oi=["callback"],ki=["callback"],_i=["callback","deviceId"],Ui=["callback","deviceId"],Ri="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Li=new Uint8Array(256);for(let e=0;e<64;e++)Li[Ri.charCodeAt(e)]=e;const Ci=e=>{const t=new Uint8Array(e),a=t.length;let n,s="";for(n=0;n<a;n+=3)s+=Ri[t[n]>>2],s+=Ri[(3&t[n])<<4|t[n+1]>>4],s+=Ri[(15&t[n+1])<<2|t[n+2]>>6],s+=Ri[63&t[n+2]];return a%3==2?s=s.substring(0,s.length-1):a%3==1&&(s=s.substring(0,s.length-2)),s},Di=e=>{const t=.75*e.length,a=e.length;let n,s,i,o,r,l=0;const c=new Uint8Array(t);for(n=0;n<a;n+=4)s=Li[e.charCodeAt(n)],i=Li[e.charCodeAt(n+1)],o=Li[e.charCodeAt(n+2)],r=Li[e.charCodeAt(n+3)],c[l++]=s<<2|i>>4,c[l++]=(15&i)<<4|o>>2,c[l++]=(3&o)<<6|63&r;return c.buffer};function Ni(e,t="file"){const a=e.match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/);if(null==a)return null;const n=`image/${a[1]}`,s=((e,t)=>{const a=atob(e),n=[];for(let e=0;e<a.length;e+=512){const t=a.slice(e,e+512),s=new Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);n.push(new Uint8Array(s))}return new Blob(n,{type:t})})(a[2],n),i=new FormData;return i.append(t,new File([s],t,{type:n})),i}const Mi=e=>{if(e instanceof Array){const t=[];for(const a of e)t.push(Mi(a));return t}if(e instanceof ArrayBuffer)return Ci(e);if(e instanceof Object){const t={};for(const a in e)t[a]=Mi(e[a]);return t}return e},Fi=e=>new Promise(((t,a)=>{const n=new FileReader;n.readAsText(e),n.onload=()=>t(n.result),n.onerror=a})),xi=["callback","deviceId"],$i=["callback","deviceId"],Gi="input is invalid type",ji="undefined"!=typeof ArrayBuffer,Bi="0123456789abcdef".split(""),Vi=[-2147483648,8388608,32768,128],Wi=[24,16,8,0],Hi=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],zi=["hex","array","digest","arrayBuffer"],Ki=[];Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),ji&&!ArrayBuffer.isView&&(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});const qi=function(e){return function(t){const a=new Yi(!0).update(t);return null==a?void 0:a[e]()}},Ji=function(e){return function(t,a){const n=new Xi(t,!0).update(a);return null==n?void 0:n[e]()}};class Yi{constructor(e=!1){this.blocks=void 0,this.h0=void 0,this.h1=void 0,this.h2=void 0,this.h3=void 0,this.h4=void 0,this.h5=void 0,this.h6=void 0,this.h7=void 0,this.block=void 0,this.start=void 0,this.bytes=void 0,this.hBytes=void 0,this.finalized=void 0,this.hashed=void 0,this.first=void 0,this.lastByteIndex=void 0,this.sharedMemory=!1,this.toString=()=>this.hex(),this.array=()=>Yi.prototype.digest(),e?(Ki[0]=Ki[16]=Ki[1]=Ki[2]=Ki[3]=Ki[4]=Ki[5]=Ki[6]=Ki[7]=Ki[8]=Ki[9]=Ki[10]=Ki[11]=Ki[12]=Ki[13]=Ki[14]=Ki[15]=0,this.blocks=Ki):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.sharedMemory=e}update(e){if(this.finalized)return;let t;const a=typeof e;if("string"!==a){if("object"!==a)throw new Error(Gi);if(null===e)throw new Error(Gi);if(ji&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||ji&&ArrayBuffer.isView(e)))throw new Error(Gi);t=!0}let n,s,i=0;const o=e.length,r=this.blocks;for(;i<o;){if(this.hashed&&(this.hashed=!1,r[0]=this.block,r[16]=r[1]=r[2]=r[3]=r[4]=r[5]=r[6]=r[7]=r[8]=r[9]=r[10]=r[11]=r[12]=r[13]=r[14]=r[15]=0),t)for(s=this.start;i<o&&s<64;++i)r[s>>2]|=e[i]<<Wi[3&s++];else for(s=this.start;i<o&&s<64;++i)n=e.charCodeAt(i),n<128?r[s>>2]|=n<<Wi[3&s++]:n<2048?(r[s>>2]|=(192|n>>6)<<Wi[3&s++],r[s>>2]|=(128|63&n)<<Wi[3&s++]):n<55296||n>=57344?(r[s>>2]|=(224|n>>12)<<Wi[3&s++],r[s>>2]|=(128|n>>6&63)<<Wi[3&s++],r[s>>2]|=(128|63&n)<<Wi[3&s++]):(n=65536+((1023&n)<<10|1023&e.charCodeAt(++i)),r[s>>2]|=(240|n>>18)<<Wi[3&s++],r[s>>2]|=(128|n>>12&63)<<Wi[3&s++],r[s>>2]|=(128|n>>6&63)<<Wi[3&s++],r[s>>2]|=(128|63&n)<<Wi[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=r[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}finalize(){if(this.finalized)return;this.finalized=!0;const e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=Vi[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}hash(){let e,t,a,n,s,i,o,r,l,c,u,d=this.h0,g=this.h1,p=this.h2,h=this.h3,y=this.h4,v=this.h5,S=this.h6,f=this.h7;const m=this.blocks;for(e=16;e<64;++e)s=m[e-15],t=(s>>>7|s<<25)^(s>>>18|s<<14)^s>>>3,s=m[e-2],a=(s>>>17|s<<15)^(s>>>19|s<<13)^s>>>10,m[e]=m[e-16]+t+m[e-7]+a|0;for(u=g&p,e=0;e<64;e+=4)this.first?(r=704751109,s=m[0]-210244248,f=s-1521486534|0,h=s+143694565|0,this.first=!1):(t=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),a=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),r=d&g,n=r^d&p^u,o=y&v^~y&S,s=f+a+o+Hi[e]+m[e],i=t+n,f=h+s|0,h=s+i|0),t=(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),a=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),l=h&d,n=l^h&g^r,o=f&y^~f&v,s=S+a+o+Hi[e+1]+m[e+1],i=t+n,S=p+s|0,p=s+i|0,t=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),a=(S>>>6|S<<26)^(S>>>11|S<<21)^(S>>>25|S<<7),c=p&h,n=c^p&d^l,o=S&f^~S&y,s=v+a+o+Hi[e+2]+m[e+2],i=t+n,v=g+s|0,g=s+i|0,t=(g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10),a=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7),u=g&p,n=u^g&h^c,o=v&S^~v&f,s=y+a+o+Hi[e+3]+m[e+3],i=t+n,y=d+s|0,d=s+i|0;this.h0=this.h0+d|0,this.h1=this.h1+g|0,this.h2=this.h2+p|0,this.h3=this.h3+h|0,this.h4=this.h4+y|0,this.h5=this.h5+v|0,this.h6=this.h6+S|0,this.h7=this.h7+f|0}hex(){this.finalize();const e=this.h0,t=this.h1,a=this.h2,n=this.h3,s=this.h4,i=this.h5,o=this.h6,r=this.h7;let l=Bi[e>>28&15]+Bi[e>>24&15]+Bi[e>>20&15]+Bi[e>>16&15]+Bi[e>>12&15]+Bi[e>>8&15]+Bi[e>>4&15]+Bi[15&e]+Bi[t>>28&15]+Bi[t>>24&15]+Bi[t>>20&15]+Bi[t>>16&15]+Bi[t>>12&15]+Bi[t>>8&15]+Bi[t>>4&15]+Bi[15&t]+Bi[a>>28&15]+Bi[a>>24&15]+Bi[a>>20&15]+Bi[a>>16&15]+Bi[a>>12&15]+Bi[a>>8&15]+Bi[a>>4&15]+Bi[15&a]+Bi[n>>28&15]+Bi[n>>24&15]+Bi[n>>20&15]+Bi[n>>16&15]+Bi[n>>12&15]+Bi[n>>8&15]+Bi[n>>4&15]+Bi[15&n]+Bi[s>>28&15]+Bi[s>>24&15]+Bi[s>>20&15]+Bi[s>>16&15]+Bi[s>>12&15]+Bi[s>>8&15]+Bi[s>>4&15]+Bi[15&s]+Bi[i>>28&15]+Bi[i>>24&15]+Bi[i>>20&15]+Bi[i>>16&15]+Bi[i>>12&15]+Bi[i>>8&15]+Bi[i>>4&15]+Bi[15&i]+Bi[o>>28&15]+Bi[o>>24&15]+Bi[o>>20&15]+Bi[o>>16&15]+Bi[o>>12&15]+Bi[o>>8&15]+Bi[o>>4&15]+Bi[15&o];return l+=Bi[r>>28&15]+Bi[r>>24&15]+Bi[r>>20&15]+Bi[r>>16&15]+Bi[r>>12&15]+Bi[r>>8&15]+Bi[r>>4&15]+Bi[15&r],l}digest(){this.finalize();const e=this.h0,t=this.h1,a=this.h2,n=this.h3,s=this.h4,i=this.h5,o=this.h6,r=this.h7,l=[e>>24&255,e>>16&255,e>>8&255,255&e,t>>24&255,t>>16&255,t>>8&255,255&t,a>>24&255,a>>16&255,a>>8&255,255&a,n>>24&255,n>>16&255,n>>8&255,255&n,s>>24&255,s>>16&255,s>>8&255,255&s,i>>24&255,i>>16&255,i>>8&255,255&i,o>>24&255,o>>16&255,o>>8&255,255&o];return l.push(r>>24&255,r>>16&255,r>>8&255,255&r),l}arrayBuffer(){this.finalize();const e=new ArrayBuffer(32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),t.setUint32(28,this.h7),e}}class Xi extends Yi{constructor(e,t=!1){let a;super(t),this.inner=void 0,this.oKeyPad=void 0;const n=typeof e;if("string"===n){const t=[],n=e.length;let s,i=0;for(a=0;a<n;++a)s=e.charCodeAt(a),s<128?t[i++]=s:s<2048?(t[i++]=192|s>>6,t[i++]=128|63&s):s<55296||s>=57344?(t[i++]=224|s>>12,t[i++]=128|s>>6&63,t[i++]=128|63&s):(s=65536+((1023&s)<<10|1023&e.charCodeAt(++a)),t[i++]=240|s>>18,t[i++]=128|s>>12&63,t[i++]=128|s>>6&63,t[i++]=128|63&s);e=t}else{if("object"!==n)throw new Error(Gi);if(null===e)throw new Error(Gi);if(ji&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||ji&&ArrayBuffer.isView(e)))throw new Error(Gi)}var s;e.length>64&&(e=null==(s=new Yi(!0).update(e))?void 0:s.array());const i=[],o=[];for(a=0;a<64;++a){const t=e[a]||0;i[a]=92^t,o[a]=54^t}Yi.call(this,t),this.update(o),this.oKeyPad=i,this.inner=!0,this.sharedMemory=t}finalize(){if(super.finalize(),this.inner){this.inner=!1;const e=this.array();Yi.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(e),Yi.prototype.finalize.call(this)}}}const Qi=function(){const e=qi("hex");e.create=function(){return new Yi},e.update=function(t){return e.create().update(t)};for(let t=0;t<zi.length;++t){const a=zi[t];e[a]=qi(a)}return e}(),Zi=function(){const e=Ji("hex");e.create=function(e){return new Xi(e)},e.update=function(t,a){return e.create(t).update(a)};for(let t=0;t<zi.length;++t){const a=zi[t];e[a]=Ji(a)}return e}();async function eo(e){const t=Qi.digest((new TextEncoder).encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function to(e){const t=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function ao(e){var t,a;return null!=(t=window.crypto)&&null!=(a=t.subtle)&&a.digest?to(e):(console.warn("Generating CodeChallenge in non-secure domain:",window.location.origin),eo(e))}function no(e=16){let t="";for(let a=0;a<e;a++)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return t}var so=a(8792),io=a.n(so),oo=a(5875);const ro=(e="default")=>{if(!R.for(e).shouldLoadEntitlements())throw new Error("You must first enable entitlements via Frontegg options to use this function")},lo=(e,t,a,n,s="default")=>(ro(s),(0,oo.Me)(t,e,a)),co=(e,t,a,n,s="default")=>(ro(s),(0,oo.a_)(t,e,a)),uo=(e,t,a,n,s="default")=>"permissionKey"in t?lo(e,t.permissionKey,a,n,s):co(e,t.featureKey,a,n,s);function go(e,t){return io()(e,t)}let po,ho;!function(e){e.LOAD_SSO_CONFIGURATIONS="LOAD_SSO_CONFIGURATIONS",e.SAVE_SSO_CONFIGURATION="SAVE_SSO_CONFIGURATION",e.UPDATE_SSO_CONFIGURATION="UPDATE_SSO_CONFIGURATION",e.SAVE_SSO_CONFIGURATION_BY_METADATA="SAVE_SSO_CONFIGURATION_BY_METADATA",e.UPDATE_SSO_CONFIGURATION_BY_METADATA="UPDATE_SSO_CONFIGURATION",e.DELETE_SSO_CONFIGURATION="DELETE_SSO_CONFIGURATION",e.SAVE_SSO_DOMAIN="SAVE_SSO_DOMAIN",e.DELETE_SSO_DOMAIN="DELETE_SSO_DOMAIN",e.VALIDATE_SSO_DOMAIN="VALIDATE_SSO_DOMAIN",e.UPDATE_SSO_DEFAULT_ROLES="UPDATE_SSO_DEFAULT_ROLES",e.DELETE_SSO_GROUPS="DELETE_SSO_GROUPS",e.SAVE_SSO_GROUPS="SAVE_SSO_GROUPS",e.GET_SSO_AUTHORIZATION_ROLES="GET_SSO_AUTHORIZATION_ROLES"}(po||(po={})),function(e){e.Saml="saml",e.Okta="okta",e.Azure="azure",e.Google="google",e.Oidc="oidc"}(ho||(ho={}));const yo=["callback","error"],vo=["callback"],So=["callback"],fo=["callback"],mo=["callback"],bo=["callback","events"],Ao=["callback"],wo=["callback"],To=["user"],Eo=["callback"],Po=["callback"],Io=["callback"],Oo=["callback"],ko=["callback"],_o=["callback"],Uo=(e,t,a)=>{const n=a,s=R.for(e.root.appName),i=t=>{var a;const{routes:n,loginState:s}=e.auth,i=null!=(a=localStorage.getItem("register-quick-login"))?a:s.quickLoginToRegister;return i&&"true"!==localStorage.getItem(`${t.id}-${i}`)&&!window.location.pathname.endsWith(n.logoutUrl)},o=async()=>{e.auth.hostedLoginBox?await(async()=>{const a=e.auth.user;if(null==a||!a.refreshToken)return s.setAccessToken(null),s.setUser(null),void n.setAuthState({user:null,isAuthenticated:!1});try{const e={grant_type:"refresh_token",refresh_token:null==a?void 0:a.refreshToken},s=await t.auth.exchangeOAuthTokensV2(e),i=await r(s.user);n.afterAuthenticationStateUpdate(S({},s,{user:i}),{isAuthenticated:!0})}catch(e){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:s,loginState:o,onRedirectTo:c}=e.auth,{user:u,tenants:d=[],activeTenant:g}=await t.auth.refreshTokenV3();if(Es(u,e.root.appName)){const e=await n.getMfaRequiredState(u);n.setAuthState(e),c(s.loginUrl,{preserveQueryParams:!0})}else{var a;u.id&&localStorage.setItem("userId",u.id);const e=null!=(a=localStorage.getItem("register-quick-login"))?a:o.quickLoginToRegister,t=i(u),s=await r(u);n.afterAuthenticationStateUpdate({user:s,tenants:d,activeTenant:g},{loginState:S({},o,{quickLoginToRegister:e,flow:t?Tn.RegisterQuickLogin:Tn.Login}),isAuthenticated:!0}),await l(t)}}catch(e){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:void 0,isAuthenticated:!1})}})()},r=async t=>{var a;const n=null==(a=e.auth.user)?void 0:a.entitlements;return go(n,null==t?void 0:t.entitlements)?S({},t,{entitlements:n}):t},l=async t=>{var a;const s=new URL(null==(a=window)?void 0:a.location.href),{routes:i,loginState:o,onRedirectTo:r}=e.auth,l=s.searchParams.get("invitationToken"),c=[i.socialLoginCallbackUrl,i.oidcRedirectUrl,i.samlCallbackUrl,i.magicLinkCallbackUrl];l||c.push(i.loginUrl,i.signUpUrl),t?r(i.loginUrl):c.some((e=>e&&window.location.pathname.endsWith(e)))&&(o.isNewUser&&i.signUpSuccessUrl&&i.socialLoginCallbackUrl===window.location.pathname?r(i.signUpSuccessUrl,{refresh:i.signUpSuccessUrl.startsWith("http")}):await n.afterAuthNavigation())},c=async e=>{try{var a;const{isActive:s}=await Cn(t.auth.getSSOPublicConfiguration,null==e?void 0:e.retryConfig);n.setAuthState({isSSOAuth:s}),null==e||null==(a=e.callback)||a.call(e,{isSSOAuth:s})}catch(t){var s;n.setAuthState({isSSOAuth:!1}),null==e||null==(s=e.callback)||s.call(e,null,t)}},u=async e=>{let a;try{var s;const n=await Cn(t.metadata.getSamlMetadata,null==e?void 0:e.retryConfig);a=null==n||null==(s=n.configuration)?void 0:s.acsUrl}catch(e){console.error(e)}n.setAuthState({ssoACS:a})},d=t=>{Object.assign(e.auth.loginState,t)},g=e=>Dn({callback:(t,a)=>{!a||a.statusCode<500||n.setErrorByRequestName({requestName:e,traceId:Nn(a)})}}),p=async t=>{let{callback:a,error:s}=t,i=f(t,yo);const o=e.auth.securityPolicyState.publicPolicy.policy;if(null==o||!o.authStrategy)return n.setLoginState({step:wn.loginWithPassword,loading:!1}),void(null==a||a());(null==o?void 0:o.authStrategy)===N.EmailAndPassword?(n.setLoginState({step:wn.loginWithPassword,loading:!1}),null==a||a()):[N.MagicLink,N.Code,N.SmsCode].includes(null==o?void 0:o.authStrategy)?await n.passwordlessPreLogin(S({},i,{type:null==o?void 0:o.authStrategy,callback:a})):(n.setLoginState({step:wn.loginWithPassword,loading:!1,error:Bn(s)}),null==a||a())},h=async e=>{const{user:t,tenants:a=[],activeTenant:s}=e,i={step:ns.recoveryCode,loading:!1,error:void 0,saving:!1};null!=t&&t.recoveryCode&&(i.recoveryCode=t.recoveryCode),n.setMfaState(i),n.setUser(t),n.setTenantsState({tenants:a,activeTenant:s,loading:!1}),t.id&&localStorage.setItem("userId",t.id)};return S({setLoginState:d,resetLoginState:()=>{$n(e,["auth","loginState"],Ti)},requestAuthorize:async e=>{const t=[],a=[];t.push(o()),e&&(n.setAuthState({isLoading:!0}),t.push(n.loadSocialLoginsConfigurationV2(Dn())),t.push(n.loadAllowSignUps(g(Xn.LOAD_ALLOW_SIGNUPS))),t.push(n.loadPublicAuthStrategiesPolicy(g(Xn.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY))),t.push(n.loadSignUpStrategies()),t.push(c(g(Xn.LOAD_SSO_PUBLIC_CONFIGURATION))),t.push(n.loadVendorPublicInfo(Dn())),t.push(u(Dn())),a.push(n.loadCustomLoginRoutes(g(Xn.LOAD_CUSTOM_LOGIN_ROUTES)))),await Promise.all(t),a.length>0&&await Promise.all(a),n.setAuthState({isLoading:!1})},requestAuthorizeSSR:async t=>{const a=[];a.push(n.loadSocialLoginsConfigurationV2(Dn())),a.push(n.loadAllowSignUps(g(Xn.LOAD_ALLOW_SIGNUPS))),a.push(c(g(Xn.LOAD_SSO_PUBLIC_CONFIGURATION))),a.push(n.loadSignUpStrategies()),a.push(n.loadVendorPublicInfo(Dn())),a.push(u()),a.push((async({accessToken:t,user:a})=>{if(!t)return void n.setAuthState({user:void 0,isAuthenticated:!1});const{onRedirectTo:s,routes:i}=e.auth;if(Es(a,e.root.appName)){const e=await n.getMfaRequiredState(a,Un,!0);n.setAuthState(e),s(i.loginUrl,{preserveQueryParams:!0})}})(t)),a.push(n.loadCustomLoginRoutes(g(Xn.LOAD_CUSTOM_LOGIN_ROUTES))),await Promise.all(a)},preLogin:async a=>{const{email:n,username:s,recaptchaToken:i,invitationToken:o,callback:r}=a;d({loading:!0});try{const a=e.auth.onRedirectTo,u=cs(us),g=await t.auth.preLoginV2(S({},n?{email:n}:{},s?{username:s}:{},{tenantId:u})),{address:h,idpType:y}=null!=g?g:{};if(h){let t=h;if(y===ho.Oidc&&!t.includes("redirect_uri")){const{oidcRedirectUrl:a}=e.auth.routes;t+=`&redirect_uri=${window.location.origin}${a}`}var l;v.isLoginWithSSOAvailable()?(v.loginWithSSO(null!=(l=null!=n?n:s)?l:""),d({loading:!1}),null==r||r()):(d({step:wn.redirectToSSO,loading:!1,ssoRedirectUrl:t}),setTimeout((()=>{a(t,{refresh:!0})}),2e3))}else{var c;await p({email:null!=(c=null!=n?n:s)?c:"",recaptchaToken:i,callback:r,invitationToken:o})}}catch(e){var u;await p({email:null!=(u=null!=n?n:s)?u:"",recaptchaToken:i,callback:r,invitationToken:o,error:e})}},postLogin:async a=>{const{onRedirectTo:s,routes:i}=e.auth;d({loading:!0});try{const e=await t.auth.postLogin(a);n.setAuthState({user:e.accessToken?e:void 0,isAuthenticated:!!e.accessToken}),await n.afterAuthNavigation()}catch(e){setTimeout((()=>{s(i.authenticatedUrl)}),1e3),d({step:wn.loginWithSSOFailed,loading:!1})}},login:async a=>{const{email:i,username:o,password:r,recaptchaToken:l,invitationToken:c,callback:u}=a;d({loading:!0});try{const{user:a,tenants:s=[],activeTenant:g}=await t.auth.loginv2(S({},i?{email:i}:{},o?{username:o}:{},{password:r,recaptchaToken:l,invitationToken:c})),{onRedirectTo:p,routes:h}=e.auth;if(Es(a,e.root.appName)){const e=await n.getMfaRequiredState(a,Un,!0,i);n.setAuthState(e),p(h.loginUrl,{preserveQueryParams:!0})}else{const[t]=await n.getFeatureFlags(["security-center-show-login-flows"]);if(Ps(a,e.root.appName))d({step:wn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId});else{const o=e.auth.loginState,r=!!a.accessToken;a.id&&localStorage.setItem("userId",a.id),n.afterAuthenticationStateUpdate({user:a,tenants:s,activeTenant:g},{loginState:{flow:o.flow,quickLoginToRegister:o.quickLoginToRegister,email:i,loading:!1,error:void 0,mfaToken:a.mfaToken,step:o.flow===Tn.Login?wn.success:o.step,tenants:s,tenantsLoading:!0,isBreachedPassword:a.isBreachedPassword},isAuthenticated:r}),o.flow===Tn.Login&&(t&&a.isBreachedPassword&&!r?d({step:wn.breachedPassword,loading:!1}):r&&(fs(a)?d({step:wn.passwordRotationNotification,loading:!1}):await n.__shouldShowPromptPasskeys()?(d({step:wn.promptPasskeys,loading:!1}),p(h.loginUrl,{preserveQueryParams:!0})):await n.afterAuthNavigation()))}}v.isSuggestSavePasswordAvailable()&&v.suggestSavePassword(i,r),localStorage.removeItem("register-quick-login"),null==u||u(!0)}catch(e){s.setAccessToken(null),s.setUser(null),null==u||u(!1,e),d({email:i,error:Bn(e),loading:!1})}},logout:async a=>{const i=e.auth.hostedLoginBox;n.setAuthState({isLoading:!0});try{i?await t.auth.OAuthLogout():await t.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&ut(),n.resetAuthState(),await n.requestAuthorize(!0),null==a||a()},silentLogout:async e=>{var a;try{await t.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&ut(),setTimeout((()=>{var t;return null==e||null==(t=e.callback)?void 0:t.call(e,!0)}),null!=(a=null==e?void 0:e.callbackTimeout)?a:500)},recoverMfa:async e=>{d({loading:!0});try{var a;await t.auth.recoverMfaToken(e),d({loading:!1,error:void 0,step:wn.preLogin}),n.setAuthState({user:void 0,isAuthenticated:!1}),null==(a=e.callback)||a.call(e,!0)}catch(t){var s;d({error:Bn(t),loading:!1}),null==(s=e.callback)||s.call(e,!1,t)}},quickSmsPasswordlessPreLogin:async e=>{const{callback:a}=e,n=f(e,vo);try{d({loading:!0});const e=await t.auth.passwordlessPreLogin(S({},n,{type:N.SmsCode}));d({step:wn.loginWithQuickSmsOtc,loading:!1,phoneNumber:null==e?void 0:e.phoneNumber,error:void 0}),null==a||a(!0)}catch(e){d({error:Bn(e),loading:!1}),null==a||a(!1,e)}},changePhoneNumberWithVerification:async e=>{const{callback:a}=e,n=f(e,So);try{d({loading:!0});const e=await t.auth.changePhoneNumberWithVerification(n);d({phoneNumber:n.phoneNumber,loading:!1,changePhoneId:e.changePhoneId,step:wn.loginWithQuickSmsOtc,error:void 0}),null==a||a(!0)}catch(e){d({error:Bn(e),loading:!1})}},verifyChangePhoneNumber:async e=>{const{callback:a}=e,n=f(e,fo);try{d({loading:!0}),await t.auth.verifyChangePhoneNumber(n),d({loading:!1}),null==a||a(!0)}catch(e){d({error:Bn(e),loading:!1})}},passwordlessPreLogin:async e=>{const{callback:a}=e,n=f(e,mo);try{var s;let e,i;d({loading:!0}),ys(n)&&(e=n.email),vs(n)&&(i=n.username);const o=await t.auth.passwordlessPreLogin(S({},n,{email:e,username:null!=(s=i)?s:""})),r=In[n.type];d({step:r,loading:!1,phoneNumber:null==o?void 0:o.phoneNumber,email:e,error:void 0}),null==a||a()}catch(e){d({error:Bn(e),loading:!1}),null==a||a(null,e)}},passwordlessPostLogin:async a=>{const{callback:s,events:i}=a,o=f(a,bo);try{d({loading:!0});const{user:l,tenants:c=[],activeTenant:u}=await t.auth.passwordlessPostLoginV2(o),{routes:g,onRedirectTo:p}=e.auth;if(Es(l,e.root.appName)){const e=await n.getMfaRequiredState(l);n.setAuthState(e),p(g.loginUrl,{preserveQueryParams:!0})}else{const t=e.auth.loginState;if(l.emailVerified){var r;const e={email:l.email,origin:Qn.PASSWORDLESS,id:l.id,tenantId:l.tenantId,createdAt:new Date,name:l.name};null==i||null==(r=i.userVerified)||r.call(i,e),ss(as.USER_VERIFIED,e)}l.id&&localStorage.setItem("userId",l.id),n.afterAuthenticationStateUpdate({user:l,tenants:c,activeTenant:u}),d({error:void 0}),n.setAuthState({isLoading:!1}),t.flow===Tn.Login?await n.__shouldShowPromptPasskeys()?(n.setLoginState({step:wn.promptPasskeys,loading:!1}),p(g.loginUrl,{preserveQueryParams:!0})):(n.setAuthState({isAuthenticated:!0}),a.type===N.MagicLink&&(n.setLoginState({step:wn.magicLinkPostLoginSuccess,loading:!1}),await Rn(5e3)),await n.afterAuthNavigation()):p(g.loginUrl,{preserveQueryParams:!0}),localStorage.removeItem("register-quick-login"),null==s||s(!0)}}catch(e){d({error:Bn(e,"Failed to authenticate")}),null==s||s(null,e)}finally{d({loading:!1})}},verifyInviteToken:async e=>{try{d({loading:!0});const{name:a}=await t.auth.verifyInviteToken(e);d({inviteTokenTenantName:a})}catch(e){d({inviteTokenError:Bn(e,"We couldn't verify your invitation")})}finally{d({loading:!1})}},webAuthnPrelogin:async e=>{const{callback:a}=e,s=f(e,Ao);try{var i;n.setPasskeysState({loading:!0}),d({loading:!0});const{options:e}=await t.auth.webAuthnPreLogin(s);e.challenge=Di(e.challenge),e.allowCredentials=null==(i=e.allowCredentials)?void 0:i.map((e=>S({},e,{id:Di(e.id)}))),d({error:void 0}),null==a||a(e)}catch(e){d({error:Bn(e)}),null==a||a(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnPostLogin:async a=>{const{callback:s}=a,i=f(a,wo);try{var o;n.setPasskeysState({loading:!0}),d({loading:!0});const a=Mi(i.publicKey),r=await t.auth.webAuthnPostLoginV2(S({},a,{response:S({},a.response,{userHandle:null!=(o=a.response.userHandle)?o:void 0}),recaptchaToken:i.recaptchaToken,invitationToken:i.invitationToken})),{user:l}=r,c=f(r,To);if(Es(l,e.root.appName)){const{routes:t,onRedirectTo:a}=e.auth,s=await n.getMfaRequiredState(l);n.setAuthState(s),a(t.loginUrl,{preserveQueryParams:!0})}else l.id&&localStorage.setItem("userId",l.id),n.afterAuthenticationStateUpdate(S({user:l},c),{isAuthenticated:!0}),d({error:void 0}),await n.afterAuthNavigation(),null==s||s(!0)}catch(e){d({error:Bn(e)}),null==s||s(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnCreateNewDeviceSession:async e=>{const{callback:a}=e;try{d({loading:!0});const{options:e}=await t.auth.webAuthnCreateNewDeviceSession();e.user.id=Di(e.user.id),e.challenge=Di(e.challenge),e.excludeCredentials=[],null==a||a(e)}catch(e){d({error:Bn(e)}),null==a||a(null)}finally{d({loading:!1})}},webAuthnVerifyNewDeviceSession:async e=>{const{callback:a}=e,n=f(e,Eo);try{d({loading:!0});const e=Mi(n.publicKey),s="platform"===(null==e?void 0:e.authenticatorAttachment)?Xe.Platform:Xe.CrossPlatform;await t.auth.verifyNewDeviceSession({id:e.id,response:e.response,deviceType:s}),null==a||a(!0)}catch(e){d({error:Bn(e)}),null==a||a(null)}finally{d({loading:!1})}},getUserIP:async e=>{const{callback:a}=e;try{n.setAuthState({userIpData:{loading:!0}});const{ip:e,country_code:s}=await t.metadata.getCurrentUserIpMetadata();n.setAuthState({userIpData:{ip:e,countryCode:s,loading:!1}}),n.setAuthState({userIp:e}),null==a||a({ip:e,countryCode:s})}catch(e){n.setAuthState({userIpData:{loading:!1}}),null==a||a(!1)}},preEnrollMFAWebAuthnForLogin:async e=>{const{callback:a}=e,n=f(e,Po);d({loading:!0});try{var s;const e=await t.auth.preEnrollMFAWebAuthnForLogin(n),i=S({},e.options,{challenge:Di(e.options.challenge),user:S({},e.options.user,{id:Di(e.options.user.id)}),excludeCredentials:null==(s=e.options.excludeCredentials)?void 0:s.map((e=>S({},e,{id:Di(e.id)})))});d({loading:!1}),null==a||a({options:i,webauthnToken:e.webauthnToken})}catch(e){d({loading:!1,error:Bn(e)}),null==a||a(null)}},enrollMFAWebAuthnForLogin:async e=>{const{callback:a}=e,n=f(e,Io);d({loading:!0});try{const e=Mi(n.publicKey),s=await t.auth.enrollMFAWebAuthnForLoginV2(S({},n,{options:e}));await h(s),d({loading:!1}),null==a||a(!0)}catch(e){d({loading:!1,error:Bn(e)}),null==a||a(null)}},enrollMFAAuthenticatorAppForLogin:async e=>{const{callback:a}=e,n=f(e,Oo);d({loading:!0});try{const e=await t.auth.enrollMFAAuthenticatorAppForLoginV2(n);await h(e),d({loading:!1}),null==a||a(!0)}catch(e){d({loading:!1,error:Bn(e)}),null==a||a(null)}},preEnrollMFASMSForLogin:async e=>{const{callback:a}=e,s=f(e,ko);d({loading:!0});try{const e=await t.auth.preEnrollMFASMSForLogin(s);n.setMfaState({otcToken:e.otcToken,step:ns.smsVerifyCode,phoneNumber:e.phoneNumber}),d({loading:!1}),null==a||a(!0)}catch(e){d({loading:!1,error:Bn(e)}),null==a||a(null)}},enrollMFASMSForLogin:async e=>{const{callback:a}=e,n=f(e,_o);d({loading:!0});try{const e=await t.auth.enrollMFASMSForLoginV2(n);await h(e),d({loading:!1}),null==a||a(!0)}catch(e){d({loading:!1,error:Bn(e)}),null==a||a(null)}},handleEnrollMFAResponse:h,resetBreachedPassword:async e=>{d({loading:!0});try{await t.auth.forgotPassword(e),d({loading:!1,error:void 0,step:wn.breachedPasswordSuccess}),n.setAuthState({isAuthenticated:!1})}catch(e){d({loading:!1,error:Bn(e)})}},refreshTokenForSocialLogins:async()=>{e.auth.hostedLoginBox?await(async()=>{const{user:a}=e.auth;if(null==a||!a.refreshToken)return s.setAccessToken(null),s.setUser(null),void n.setAuthState({user:null,isAuthenticated:!1});try{const e={grant_type:"refresh_token",refresh_token:null==a?void 0:a.refreshToken},s=await t.auth.exchangeOAuthTokensV2(e),i=await r(s.user);n.afterAuthenticationStateUpdate(S({},s,{user:i}),{isAuthenticated:!0})}catch(e){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:s,loginState:o,onRedirectTo:c}=e.auth,{user:u,tenants:d=[],activeTenant:g}=await t.auth.refreshTokenV3();if(Es(u,e.root.appName)){const e=await n.getMfaRequiredState(u);n.setAuthState(e),c(s.loginUrl,{preserveQueryParams:!0})}else{const e=await r(u);if(await n.__shouldShowPromptPasskeys())n.setLoginState({step:wn.promptPasskeys,loading:!1}),n.afterAuthenticationStateUpdate({user:e,tenants:d,activeTenant:g},{isLoading:!1}),c(s.loginUrl,{preserveQueryParams:!0});else{var a;u.id&&localStorage.setItem("userId",u.id);const t=null!=(a=localStorage.getItem("register-quick-login"))?a:o.quickLoginToRegister,s=i(u);n.afterAuthenticationStateUpdate({user:e,tenants:d,activeTenant:g},{loginState:S({},o,{quickLoginToRegister:t,flow:s?Tn.RegisterQuickLogin:Tn.Login}),isAuthenticated:!0}),await l(s)}}}catch(e){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:void 0,isAuthenticated:!1})}})()},__refreshToken:o},((e,t,a)=>{const n=a,s=async()=>{const e=await t.auth.silentOAuthRefreshTokenV2();if(null==e||!e.user)throw new Error("couldn't refresh user token with oauth service");await n.afterAuthenticationStateUpdate(e,{isAuthenticated:!0,isLoading:!1})},i=async a=>{var s;const{routes:i,onRedirectTo:o}=e.auth,{context:r,urlStrategy:l}=e.root;if(Os(l)===i.hostedLoginRedirectUrl)return void console.debug("Calling loginWithRedirect while in hostedLoginCallback route");n.setAuthState({isLoading:!0});const c=no(),u=no(),d=await ao(u);localStorage.setItem(_n,u);const g=Ss(e);let p=`${window.location.origin}${"path"===l?"":"#"}${null!=g?g:""}${i.hostedLoginRedirectUrl}`;await n.loadCustomLoginRoutes();const h=null==(s=e.auth.customLoginState)?void 0:s.customLoginSearchParams;h&&(p.endsWith("/")&&(p=p.slice(0,-1)),p+=h);const y=`${t.fetch.getBaseUrl(r,"/oauth/authorize")}/oauth/authorize`,v=S({response_type:"code",client_id:r.appId||r.clientId||"INVALID-CLIENT-ID",scope:"openid email profile",redirect_uri:p,code_challenge:d,code_challenge_method:"S256",nonce:c},a);if(r.tenantResolver){var f;const e=await(null==(f=r.tenantResolver)?void 0:f.call(r));null!=e&&e.tenant&&(v.organization=e.tenant)}const m=cs(us);m&&(v.tenantId=m),o(`${y}?${new URLSearchParams(v).toString()}`,{refresh:!0})};return{requestHostedLoginAuthorize:async t=>{var a;null==(a=localStorage)||a.removeItem(bn);const n=e.auth.disableSilentRefresh;if("login"===(null==t?void 0:t.prompt))return await i(t);try{if(n)throw new Error("silent refresh is disabled");return await s()}catch(e){return await i(t)}},requestHostedLoginAuthorizeV2:async t=>{var a,o;const{shouldRedirectToLogin:r,firstTime:l,loginDirectAction:c}=null!=t?t:{};let{additionalParams:u}=null!=t?t:{};if(null==(a=localStorage)||a.removeItem(bn),l){const t=e.root.urlStrategy,a=Os(t);if(n.setAuthState({isLoading:!0}),hs(a))return}const d=e.auth.disableSilentRefresh;if(c&&(u=u||{},u.login_direct_action=btoa(JSON.stringify(c))),"login"===(null==(o=u)?void 0:o.prompt))return await i(u);try{if(d)throw new Error("silent refresh is disabled");return await s()}catch(e){return r?await i(u):void n.setAuthState({isLoading:!1})}},__requestHostedLoginAuthorize:i,__requestHostedLoginSilentAuthorize:s,handleHostedLoginCallback:async a=>{var s;const i=localStorage.getItem(_n)||"INVALID-CODE-VERIFIER",o=e.auth.routes,r=e.root.urlStrategy,l=Ss(e);let c=`${window.location.origin}${"path"===r?"":"#"}${null!=l?l:""}${o.hostedLoginRedirectUrl}`;await n.loadCustomLoginRoutes();const u=null==(s=e.auth.customLoginState)?void 0:s.customLoginSearchParams;u&&(c.endsWith("/")&&(c=c.slice(0,-1)),c+=u);const d={code:a.code,redirect_uri:c,code_verifier:i,grant_type:"authorization_code"};try{const e=await t.auth.exchangeOAuthTokensV2(d);n.afterAuthenticationStateUpdate(e,{isAuthenticated:!0,isLoading:!1})}catch(e){n.setAuthState({isLoading:!1}),console.error("Failed to exchangeOAuthTokens",e)}finally{const t=e.auth.user,a=window.localStorage.getItem(bn);window.localStorage.removeItem(bn),a&&ms(t)?await n.afterStepUpAuthNavigation():await n.afterAuthNavigation()}}}})(e,t,a),Pi(e,0,a),function(e,t,a){const n=a,s=async()=>await n.afterStepUpAuthNavigation(),i=async(t,a)=>{const s=e.auth.loginState,i=e.auth.mfaState.step,[o]=await n.getFeatureFlags(["security-center-show-login-flows"]);if(s.flow===Tn.Login){if(o&&s.isBreachedPassword&&!t)return void n.setLoginState({step:wn.breachedPassword,loading:!1});if(Ps(a,e.root.appName))return void n.setLoginState({step:wn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId});if(fs(a))return void n.setLoginState({step:wn.passwordRotationNotification,loading:!1});const r=await n.__shouldShowPromptPasskeys();i===ns.smsVerifyCode&&r?n.setLoginState({step:wn.promptPasskeys,loading:!1}):await n.afterAuthNavigation()}};return{postHandleVerifyMFAResponseForStepUp:s,postHandleVerifyMFAResponseForLogin:i,handleVerifyMFAResponse:async(e,t=!1)=>{const{user:a,tenants:o,activeTenant:r}=e;n.setUser(a),n.setTenantsState({tenants:o,activeTenant:r,loading:!1}),a.id&&localStorage.setItem("userId",a.id);const l=!!a.accessToken;return n.setAuthState({isAuthenticated:l}),t?await s():await i(l,a)},getFeatureFlags:async t=>{const a=e.root.appName;return at.getFeatureFlags(t,a)}}}(e,0,a),((e,t)=>({getMfaRequiredState:async(a,n,s=!1,i)=>{var o,r,l;let c=wn.loginWithTwoFactor;const u={step:ns.verify,loading:!1,saving:!1},d=e.auth.loginState;let g,p;try{const e=await Cn((()=>t.auth.checkIfAllowToRememberMfaDevice(a.mfaToken)),n);g=e.isAllowedToRemember,p=e.mfaDeviceExpiration}catch(e){if(!s)throw e}!("mfaEnrolled"in a)||a.mfaEnrolled||(null==(o=a.mfaDevices)||null==(r=o.emails)?void 0:r.length)?Object.assign(u,{mfaDevices:a.mfaDevices,mfaToken:a.mfaToken,step:gs(a.mfaDevices)}):(Object.assign(u,{step:ps(a.mfaStrategies),qrCode:a.qrCode,recoveryCode:a.recoveryCode,loading:!1,mfaToken:a.mfaToken,mfaStrategies:a.mfaStrategies}),c=wn.forceTwoFactor);let h={};const y=localStorage.getItem("register-quick-login");return y&&(h={quickLoginToRegister:y,flow:Tn.RegisterQuickLogin}),{user:void 0,isAuthenticated:!1,mfaState:u,loginState:S({},d,h,{mfaToken:a.mfaToken,mfaRequired:a.mfaRequired,loading:!1,error:void 0,step:c,tenantsLoading:!0,email:null!=(l=a.userEmail)?l:i,tenants:[],allowRememberMfaDevice:g,mfaDeviceExpiration:p,isBreachedPassword:a.isBreachedPassword})}}}))(e,t),((e,t,a)=>{const n=a,s=async(a,s,i)=>{let{callback:o}=a,r=f(a,Ii);s({loading:!0,error:void 0});try{const{user:a,tenants:l=[],activeTenant:c}=await t.auth.loginWithMfaV2(r),u=!!a.accessToken,d=await async function(t,a,n){const s=e.auth.loginState;let i={};if(!n){const e=s.flow===Tn.Login?wn.success:s.step;i={loginState:{flow:s.flow,quickLoginToRegister:s.quickLoginToRegister,loading:!1,step:e,error:void 0,tenants:t}}}return S({},i,{isAuthenticated:a})}(l,u,i);return await n.afterAuthenticationStateUpdate({user:a,tenants:l,activeTenant:c},d),a.id&&localStorage.setItem("userId",a.id),s({loading:!1,error:void 0}),i?await async function(e){await n.afterStepUpAuthNavigation(),null==e||e(!0)}(o):await async function(t,a,s){const i=e.auth.loginState;if(i.flow!==Tn.Login)return;const[o]=await n.getFeatureFlags(["security-center-show-login-flows"]);return o&&i.isBreachedPassword&&!t?(n.setLoginState({step:wn.breachedPassword,loading:!1}),void(null==s||s(!0))):Ps(a,e.root.appName)?(n.setLoginState({step:wn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId}),void(null==s||s(!0))):fs(a)?(n.setLoginState({step:wn.passwordRotationNotification,loading:!1}),void(null==s||s(!0))):(await n.__shouldShowPromptPasskeys()?n.setLoginState({step:wn.promptPasskeys,loading:!1}):await n.afterAuthNavigation(),void(null==s||s(!0)))}(u,a,o)}catch(e){s({loading:!1,error:Bn(e)}),null==o||o(!1,e)}};return{mfaWithAuthenticator:s,loginWithMfa:async e=>await s(e,n.setLoginState,!1)}})(e,t,a),((e,t,a)=>{const n=a,s=async(e,a)=>{var s;let{callback:i}=e,o=f(e,Oi);(a=null!=(s=a)?s:n.setLoginState)({loading:!0,error:void 0});try{const e=await t.auth.preVerifyMFAEmailCode(o);n.setMfaState({otcToken:e.otcToken,step:ns.emailVerifyCode}),a({loading:!1,error:void 0}),null==i||i(!0)}catch(e){a({error:Bn(e)}),null==i||i(null)}},i=async(e,a)=>{var s;let{callback:i}=e,o=f(e,ki);(a=null!=(s=a)?s:n.setLoginState)({loading:!0});try{const e=await t.auth.verifyMFAEmailCodeV2(o);await n.handleVerifyMFAResponse(e),a({loading:!1,error:void 0}),null==i||i(!0)}catch(e){a({loading:!1,error:Bn(e)}),null==i||i(null)}};return{preVerifyMFAEmailCode:s,verifyMFAEmailCode:i,preVerifyMFAEmailCodeForLogin:async e=>await s(e,n.setLoginState),verifyMFAEmailCodeForLogin:async e=>await i(e,n.setLoginState)}})(0,t,a),((e,t,a)=>{const n=a,s=async(e,a)=>{let{callback:s,deviceId:i}=e,o=f(e,_i);a({loading:!1,error:void 0});try{const e=await t.auth.preVerifyMFASMSForLogin(i,o);n.setMfaState({otcToken:e.otcToken,step:ns.smsVerifyCode,phoneNumber:e.phoneNumber}),a({loading:!1,error:void 0}),null==s||s(!0)}catch(e){a({loading:!1,error:Bn(e)}),null==s||s(null)}},i=async(e,a,s=!1)=>{let{callback:i,deviceId:o}=e,r=f(e,Ui);a({loading:!0});try{const e=await t.auth.verifyMFASMSForLoginV2(o,r);await n.handleVerifyMFAResponse(e,s),a({loading:!1,error:void 0}),null==i||i(!0)}catch(e){a({loading:!1,error:Bn(e)}),null==i||i(null)}};return{preVerifyMFASMS:s,verifyMFASMS:i,preVerifyMFASMSForLogin:async e=>await s(e,n.setLoginState),verifyMFASMSForLogin:async e=>await i(e,n.setLoginState,!1)}})(0,t,a),((e,t,a)=>{const n=a,s=async(e,a)=>{let{callback:n,deviceId:s}=e,i=f(e,xi);a({loading:!0});try{var o;const e=await t.auth.preVerifyMFAWebAuthnForLogin(s,i),r=S({},e.options,{challenge:Di(e.options.challenge),allowCredentials:null==(o=e.options.allowCredentials)?void 0:o.map((e=>S({},e,{id:Di(e.id)})))});a({loading:!1,error:void 0}),null==n||n({options:r,webauthnToken:e.webauthnToken})}catch(e){a({loading:!1,error:Bn(e)}),null==n||n(null)}},i=async(e,a,s)=>{let{callback:i,deviceId:o}=e,r=f(e,$i);a({loading:!0});try{const e=Mi(r.publicKey),l=await t.auth.verifyMFAWebAuthnForLoginV2(o,S({},r,{options:e}));await n.handleVerifyMFAResponse(l,s),a({loading:!1,error:void 0}),null==i||i(!0)}catch(e){a({loading:!1,error:Bn(e)}),null==i||i(null)}};return{preVerifyMFAWebAuthn:s,verifyMFAWebAuthn:i,preVerifyMFAWebAuthnForLogin:async e=>await s(e,n.setLoginState),verifyMFAWebAuthnForLogin:async e=>await i(e,n.setLoginState,!1)}})(0,t,a))},Ro={step:ns.verify,loading:!1,saving:!1},Lo=e=>cn(Ro,e),Co=["callback"],Do=["callback"],No=["user"],Mo=["deviceId"],Fo=["deviceId"],xo=["callback"],$o=["callback"],Go=["deviceId","callback"],jo=(e,t,a)=>{const n=a;async function s(t){const a=e.auth.mfaState.step;return{step:t.recoveryCode?ns.recoveryCode:a,loading:!1,saving:!1,error:void 0,recoveryCode:null==t?void 0:t.recoveryCode}}const i=t=>{Object.assign(e.auth.mfaState,t)};return{setMfaState:i,resetMfaState:()=>{$n(e,["auth","mfaState"],Ro)},getMFADevices:async()=>{i({loading:!0});try{const e=await t.auth.getMFADevices();i({loading:!1,error:void 0,mfaDevices:e})}catch(e){i({loading:!1,error:Bn(e)})}},getMFAStrategies:async e=>{i({loading:!0});try{const a=(await Cn((()=>t.auth.getMFAStrategiesConfig()),null==e?void 0:e.retryConfig)).strategies.filter((({isActive:e})=>e)).map((({strategy:e})=>e));i({loading:!1,error:void 0,mfaStrategies:a})}catch(e){i({loading:!1,error:Bn(e)})}},enrollMfa:async()=>{i({saving:!0});try{const{qrCode:e}=await t.auth.enrollMfa();i({saving:!1,error:void 0,qrCode:e})}catch(e){i({saving:!1,error:Bn(e)})}},verifyMfa:async a=>{const{callback:o}=a,r=f(a,Co);i({saving:!0});try{const a=e.auth.user,l=await t.auth.verifyMfa(r),c=await t.auth.getMFADevices(),u=await s(l);i(S({},u,{mfaDevices:c})),n.setUser(S({},a,{mfaEnrolled:!0})),null==o||o(u.recoveryCode)}catch(e){i({saving:!1,error:Bn(e)}),null==o||o(null,e)}},verifyMfaAfterForce:async e=>{const{callback:a}=e,s=f(e,Do);i({loading:!0});try{const e=await t.auth.loginWithMfaV2(s),{user:o}=e,r=f(e,No),l={step:ns.recoveryCode,loading:!1,saving:!1,error:void 0};null!=o&&o.recoveryCode&&(l.recoveryCode=o.recoveryCode),i(l),await n.afterAuthenticationStateUpdate(S({user:o},r)),null==a||a(l.recoveryCode)}catch(e){i({loading:!1,error:Bn(e)}),null==a||a(null,e)}},disableMfa:async e=>{i({saving:!0});try{var a;await t.auth.disableMfa(e);const n=await t.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:n}),null==(a=e.callback)||a.call(e,!0)}catch(t){var n;i({saving:!1,error:Bn(t)}),null==(n=e.callback)||n.call(e,!1,t)}},preDisableMfaSms:async e=>{const{deviceId:a}=e,n=f(e,Mo);i({saving:!0});try{var s;const e=await t.auth.preDisableMFASMS(a);i({saving:!1,error:void 0,otcToken:e.otcToken,phoneNumber:e.phoneNumber}),null==(s=n.callback)||s.call(n,!0)}catch(e){var o;i({saving:!1,error:Bn(e)}),null==(o=n.callback)||o.call(n,!1,e)}},disableMfaSms:async e=>{const{deviceId:a}=e,n=f(e,Fo);i({saving:!0});try{var s;await t.auth.disableMFASMS(a,n);const e=await t.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:e}),null==(s=n.callback)||s.call(n,!0)}catch(e){var o;i({saving:!1,error:Bn(e)}),null==(o=n.callback)||o.call(n,!1,e)}},preEnrollMfaSms:async e=>{i({saving:!0});try{var a;const n=await t.auth.preEnrollMFASMS(e);i({saving:!1,error:void 0,otcToken:n.otcToken,phoneNumber:n.phoneNumber}),null==(a=e.callback)||a.call(e,!0)}catch(t){var n;i({saving:!1,error:Bn(t)}),null==(n=e.callback)||n.call(e,!1,t)}},enrollMfaSms:async e=>{const{callback:a}=e,n=f(e,xo);i({saving:!0});try{const e=await t.auth.enrollMFASMS(n),o=await t.auth.getMFADevices(),r=await s(e);i(S({},r,{mfaDevices:o})),null==a||a(r.recoveryCode)}catch(e){i({saving:!1,error:Bn(e)}),null==a||a(null,e)}},preEnrollMfaWebAuthn:async e=>{i({saving:!0});try{var a,n;const s=await t.auth.preEnrollMFAWebAuthn(),o=S({},s.options,{challenge:Di(s.options.challenge),user:S({},s.options.user,{id:Di(s.options.user.id)}),excludeCredentials:null==(a=s.options.excludeCredentials)?void 0:a.map((e=>S({},e,{id:Di(e.id)})))});i({saving:!1}),null==(n=e.callback)||n.call(e,{options:o,webauthnToken:s.webauthnToken})}catch(t){var s;i({saving:!1,error:Bn(t)}),null==(s=e.callback)||s.call(e,null,t)}},enrollMfaWebAuthn:async e=>{const{callback:a}=e,n=f(e,$o);i({saving:!0});try{const e=Mi(n.publicKey),o=await t.auth.enrollMFAWebAuthn(S({},n,{options:e})),r=await t.auth.getMFADevices(),l=await s(o);i(S({},l,{mfaDevices:r})),null==a||a(l.recoveryCode)}catch(e){i({saving:!1,error:Bn(e)}),null==a||a(null,e)}},preDisableMfaWebAuthn:async e=>{const{deviceId:a,callback:n}=e;i({saving:!0});try{var s;const e=await t.auth.preDisableMFAWebAuthn(a),o=S({},e.options,{challenge:Di(e.options.challenge),allowCredentials:null==(s=e.options.allowCredentials)?void 0:s.map((e=>S({},e,{id:Di(e.id)})))});i({saving:!1}),null==n||n({options:o,webauthnToken:e.webauthnToken})}catch(e){i({saving:!1,error:Bn(e)}),null==n||n(null,e)}},disableMfaWebAuthn:async e=>{const{deviceId:a,callback:n}=e,s=f(e,Go);i({saving:!0});try{const e=Mi(s.publicKey);await t.auth.disableMFAWebAuthn(a,S({},s,{options:e}));const o=await t.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:o}),null==n||n(!0)}catch(e){i({saving:!1,error:Bn(e)}),null==n||n(!1,e)}},__getMfaStateAfterEnroll:s}},Bo={loaders:{},errors:{},accounts:{tenantId:"",children:[]},accountsQueryParams:{_limit:50,_offset:0,_filter:"",_subTenantId:""},searchAccountsData:[],rootAccount:{tenantId:""},selectedAccount:{tenantId:"",userJwt:{accessToken:"",expiresIn:0,expires:""},users:[],usersQueryParams:{_offset:0,_limit:10,_order:Be.DESC,_sortBy:Ka.name},usersPageOffset:0,accountSettings:{}}},Vo=e=>cn(Bo,e),Wo={createSubAccountDialog:{loading:!1,open:!1,error:!1,jwt:"",canSelectParentAccount:!1},updateSubAccountDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1,jwt:""},disableSubAccountManagementDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1},enableSubAccountManagementDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1},updateSubAccountHierarchySettingsDialog:{accountId:"",accountName:"",subAccountAccessType:Ma.DEFAULT_OFF,loading:!1,open:!1,error:!1},deleteSubAccountDialog:{accountId:"",accountName:"",isParentAccount:!1,loading:!1,open:!1,error:!1,jwt:""},addUsersToAccountDialog:{loading:!1,open:!1,accountName:"",accountId:"",permissionToGiveAccessToSubAccounts:!1,jwt:""},deleteUserFromAccountDialog:{userId:"",userName:"",accountId:"",loading:!1,open:!1,jwt:""},editUserRolesDialog:{loading:!1,open:!1,jwt:"",accountId:"",userId:"",userName:"",userRoles:[]}},Ho=e=>cn(Wo,e);let zo;!function(e){e.GET_ACCOUNTS="GET_ACCOUNTS",e.SEARCH_ACCOUNTS="SEARCH_ACCOUNTS",e.SET_ROOT_ACCOUNT_DATA="SET_ROOT_ACCOUNT_DATA",e.SET_SELECTED_SUB_ACCOUNT_DATA="SET_SELECTED_SUB_ACCOUNT_DATA",e.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT="LOAD_NUMBER_OF_USERS_FOR_ACCOUNT",e.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER="UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER",e.CREATE_SUB_ACCOUNT="CREATE_SUB_ACCOUNT",e.UPDATE_SUB_ACCOUNT="UPDATE_SUB_ACCOUNT",e.DELETE_SUB_ACCOUNT="DELETE_SUB_ACCOUNT",e.GET_ACCOUNT_USERS="GET_ACCOUNT_USERS",e.ADD_USERS_TO_ACCOUNT="ADD_USERS_TO_ACCOUNT",e.DELETE_USERS_FROM_ACCOUNT="DELETE_USERS_FROM_ACCOUNT",e.SET_USER_ROLES_FOR_SUB_ACCOUNT="SET_USER_ROLES_FOR_SUB_ACCOUNT",e.UPDATE_SUB_ACCOUNT_SETTINGS="UPDATE_SUB_ACCOUNT_SETTINGS",e.UPDATE_SUB_ACCOUNT_MANAGEMENT="UPDATE_SUB_ACCOUNT_MANAGEMENT",e.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS="UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS",e.GET_USER_JWT="GET_USER_JWT",e.GET_TEAM_USERS="GET_TEAM_USERS"}(zo||(zo={}));const Ko=({items:e},t)=>e.map((e=>{var a,n;return{name:e.name,tenantId:e.tenantId,numberOfUsers:null!=(a=null==(n=t.find((t=>t.tenantId===e.tenantId)))?void 0:n.totalUsers)?a:0,createdAt:e.createdAt,metadata:e.metadata,isReseller:e.isReseller,subAccountAccessType:e.subAccountAccessType}}));function qo(e,t,a){var n,s,i;return e.tenantId===t?S({},e,{children:[...null!=(i=null==e?void 0:e.children)?i:[],...a].filter(((e,t,a)=>t===a.findIndex((t=>t.tenantId===e.tenantId))))}):S({},e,{children:null!=(n=null==e||null==(s=e.children)?void 0:s.map((e=>qo(e,t,a))))?n:[]})}function Jo(e,t){var a;return S({},e,{children:null!=(a=e.children)&&a.length?e.children.filter((e=>e.tenantId!==t)).map((e=>Jo(e,t))):[]})}const Yo=(e,t,a)=>{var n,s;return e.tenantId===t?S({},e,{subAccountAccessType:a}):S({},e,{children:null!=(n=null==e||null==(s=e.children)?void 0:s.map((e=>Yo(e,t,a))))?n:[]})},Xo=(e,t,a)=>{var n,s;return e.tenantId===t?S({},e,{name:a}):S({},e,{children:null!=(n=null==e||null==(s=e.children)?void 0:s.map((e=>Xo(e,t,a))))?n:[]})},Qo=(e,t,a)=>{var n,s;return e?e.tenantId===t?S({},e,{isReseller:a}):S({},e,{children:null!=(n=null==e||null==(s=e.children)?void 0:s.map((e=>Qo(e,t,a))))?n:[]}):{}},Zo=(e,t,a)=>{const n=t=>{Object.assign(e.auth.allAccountsState,{loaders:S({},e.auth.allAccountsState.loaders,{[t.key]:t.value})})},s=t=>{Object.assign(e.auth.allAccountsState,{errors:S({},e.auth.allAccountsState.errors,{[t.key]:t.value}),loaders:S({},e.auth.allAccountsState.loaders,{[t.key]:!1})})},i=t=>{Object.assign(e.auth.allAccountsState,t)},o=t=>{Object.assign(e.auth.allAccountsState.selectedAccount,t)},r=()=>e.auth.allAccountsState,l=async e=>{var a,i,l,c,u,d,g,p;const{jwt:h,_tenantId:y,_email:v}=e,f=zo.GET_ACCOUNT_USERS;n({key:f,value:!0});const m=r(),b=null!=(a=null!=(i=null==e?void 0:e._offset)?i:null==m||null==(l=m.selectedAccount)||null==(c=l.usersQueryParams)?void 0:c._offset)?a:0,A=null!=(u=null!=(d=null==e?void 0:e._limit)?d:null==m||null==(g=m.selectedAccount)||null==(p=g.usersQueryParams)?void 0:p._limit)?u:10,w=S({_offset:b,_limit:A,_tenantId:y,_includeSubTenants:!1},!!v&&{_email:v});try{const{items:e,_metadata:{totalItems:a,totalPages:n}}=await t.users.getUsersV3(w,{jwt:h}),s={totalUsersItems:a,totalUsersPages:n,usersQueryParams:S({_offset:null!=b?b:0,_limit:null!=A?A:10},!!v&&{_email:v})};if(e.length){const a=e.map((e=>e.id)),n=await t.roles.getRoles(),i=await t.users.getUsersRoles({ids:a},{jwt:h}),r=e.map((e=>{var t,a;const s=null==i||null==(t=i.find((t=>t.userId===e.id)))?void 0:t.roleIds;return S({},e,{roles:null!=(a=null==s?void 0:s.map((e=>{var t;return null!=(t=null==n?void 0:n.find((t=>t.id===e)))?t:[]})))?a:[]})}));o(S({users:r},s))}else o(S({users:[]},s))}catch(e){s({key:f,value:Bn(e)})}finally{n({key:f,value:!1})}};return{setAllAccountsLoader:n,setAllAccountsError:s,setAllAccountsState:i,setSelectedAccountState:o,resetAllAccountsState:()=>{$n(e,["auth","allAccountsState"],Bo)},clearSelectedAccount:()=>{$n(e,["auth","allAccountsState","selectedAccount"],Bo.selectedAccount)},loadAccounts:async e=>{const a=zo.GET_ACCOUNTS;n({key:a,value:!0});const{accountsQueryParams:l}=r(),{jwt:c,_limit:u,_offset:d}=e,g={_offset:null!=d?d:l._offset,_limit:null!=u?u:l._limit,_subTenantId:null==e?void 0:e._subTenantId};try{if(c){var p;const{selectedAccount:a}=r(),{items:n,_links:s}=await t.tenants.searchSubTenants(g,{jwt:c}),i=await t.tenants.getTenantsUsersCount({tenantIds:n.map((e=>e.tenantId))},{jwt:c}),l=Ko({items:n},i),u=qo(a.accounts?a.accounts:a,null!=(p=null==e?void 0:e._subTenantId)?p:"",l.map((e=>({name:e.name,tenantId:e.tenantId,numberOfUsers:e.numberOfUsers,createdAt:e.createdAt,metadata:e.metadata,children:[],loadMoreLink:null==s?void 0:s.next,isReseller:e.isReseller}))));o({accounts:u})}else{var h;const{accounts:a}=r(),{items:n,_links:s}=await t.tenants.searchSubTenants(g),o=await t.tenants.getTenantsUsersCount({tenantIds:n.map((e=>e.tenantId))}),l=Ko({items:n},o),c=qo(a,null!=(h=null==e?void 0:e._subTenantId)?h:"",l.map((e=>({name:e.name,tenantId:e.tenantId,numberOfUsers:e.numberOfUsers,createdAt:e.createdAt,metadata:e.metadata,children:[],loadMoreLink:null==s?void 0:s.next,isReseller:e.isReseller}))));i({accounts:c})}}catch(e){s({key:a,value:Bn(e)})}finally{n({key:a,value:!1})}},searchAccounts:async e=>{const{jwt:a}=e,o=zo.SEARCH_ACCOUNTS;n({key:o,value:!0});const{rootAccount:l}=r();try{if(null!=e&&e._subTenantId){var c;const{items:n}=await t.tenants.searchSubTenants({_offset:0,_limit:50,_filter:null!=(c=null==e?void 0:e._filter)?c:"",_subTenantId:e._subTenantId},{jwt:a});i({searchAccountsData:[...n,{name:l.name,tenantId:l.tenantId}]})}}catch(e){s({key:o,value:Bn(e)})}finally{n({key:o,value:!1})}},updateSubAccountAccessForUser:async e=>{const a=zo.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER;n({key:a,value:!0});const{selectedAccount:i}=r(),{userId:l,allowAccess:c,jwt:u,callback:d}=e;try{var g;await t.subTenants.updateSubAccountAccess(l,{allowAccess:c},{jwt:u}),o({users:null==i||null==(g=i.users)?void 0:g.map((e=>e.id===l?S({},e,{subAccountAccessAllowed:c}):e))}),null==d||d(!0)}catch(e){s({key:a,value:Bn(e)}),null==d||d(!1)}finally{n({key:a,value:!1})}},createSubAccount:async e=>{const a=zo.CREATE_SUB_ACCOUNT;n({key:a,value:!0});const{name:l,parentTenantId:c,tenantId:u,jwt:d,callback:g}=e;try{if(d){const{accounts:e,selectedAccount:a}=r(),n=await t.subTenants.createSubTenant({name:l,parentTenantId:c,tenantId:u},{jwt:d}),s=qo(e,null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]),g=qo(S({name:"",tenantId:""},null==a?void 0:a.accounts),null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:s}),o({accounts:g})}else{const{accounts:e}=r(),a=await t.subTenants.createSubTenant({name:l,tenantId:u,parentTenantId:c}),n=qo(e,null!=c?c:"",[{name:a.name,tenantId:a.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:n})}null==g||g(!0)}catch(e){s({key:a,value:Bn(e)}),null==g||g(!1)}finally{n({key:a,value:!1})}},updateSubAccount:async e=>{},deleteSubAccount:async e=>{const a=zo.DELETE_SUB_ACCOUNT;n({key:a,value:!0});const{jwt:l,tenantId:c,callback:u}=e;try{if(l){const{selectedAccount:e,accounts:a}=r();await t.subTenants.deleteSubTenant(c,{jwt:l});const n=Jo(a,c),s=Jo(e.accounts,c);i({accounts:n}),o({accounts:s})}else{const{accounts:e}=r();await t.subTenants.deleteSubTenant(c);const a=Jo(e,c);i({accounts:a})}null==u||u(!0)}catch(e){s({key:a,value:Bn(e)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountSettings:async e=>{const a=zo.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS;n({key:a,value:!0});const{jwt:l,name:c,callback:u,tenantId:d}=e;try{if(l){const{selectedAccount:e,accounts:a}=r();await t.subTenants.updateSubTenant({tenantId:d},{name:c},{jwt:l});const n=Xo(e.accounts,d,c);o({name:c,accounts:n});const s=Xo(a,d,c);i({accounts:s})}else{const{accounts:e}=r();await t.subTenants.updateSubTenant({tenantId:d},{name:c});const a=Xo(e,d,c);i({accounts:a})}null==u||u(!0)}catch(e){s({key:a,value:Bn(e)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountManagement:async r=>{const l=zo.UPDATE_SUB_ACCOUNT_MANAGEMENT;a.setAllAccountsLoader({key:l,value:!0});const{jwt:c,isReseller:u,callback:d,tenantId:g,shouldUpdateSelectedAccount:p}=r,h=!!c;try{if(p){const{selectedAccount:a,accounts:n}=e.auth.allAccountsState;await t.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const s=Qo(a.accounts,g,null!=u&&u);o({accounts:s}),h||o({isReseller:u});const r=Qo(n,g,null!=u&&u);i({accounts:r})}else{const{accounts:a}=e.auth.allAccountsState;t.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const n=Qo(a,g,null!=u&&u);i({accounts:n})}null==d||d(!0)}catch(e){s({key:l,value:Bn(e)}),null==d||d(!1)}finally{n({key:l,value:!1})}},updateSubAccountHierarchySettings:async e=>{const a=zo.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS;n({key:a,value:!0});const{jwt:l,callback:c,tenantId:u,subAccountAccessType:d}=e;if(d)try{if(l){const{selectedAccount:e,accounts:a}=r();await t.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d},{jwt:l});const n=Yo(e.accounts,u,d);o({subAccountAccessType:d,accounts:n});const s=Yo(a,u,d);i({accounts:s})}else{const{accounts:e}=r();await t.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d});const a=Yo(e,u,d);i({accounts:a})}null==c||c(!0)}catch(e){s({key:a,value:Bn(e)}),null==c||c(!1)}finally{n({key:a,value:!1})}},addUsersToAccount:async e=>{const{users:a,tenantId:i,jwt:o,callback:r,allowSubAccountAccess:c=!1,roleIds:u}=e,d=zo.ADD_USERS_TO_ACCOUNT;try{n({key:d,value:!0}),await t.subTenants.addUsersToSubTenant({users:a,tenantId:i,allowSubAccountAccess:c,roleIds:u},{jwt:o}),await l({jwt:o,_tenantId:i}),null==r||r(!0)}catch(e){s({key:d,value:Bn(e)}),null==r||r(!1)}finally{n({key:d,value:!1})}},getAccountUsers:l,deleteUsersFromAccount:async e=>{const a=zo.DELETE_USERS_FROM_ACCOUNT;n({key:a,value:!0});const{userId:i,subTenants:o,jwt:r,callback:c}=e;try{await t.subTenants.removeUserFromTenantAndSubTenants({userId:i,subTenants:o},{jwt:r}),await l({jwt:r,_tenantId:o[0].tenantId}),null==c||c(!0)}catch(e){s({key:a,value:Bn(e)}),null==c||c(!1)}finally{n({key:a,value:!1})}},setUserRolesForSubAccount:async e=>{const{userId:a,subTenantsRoles:i,jwt:o,callback:c}=e,u=zo.SET_USER_ROLES_FOR_SUB_ACCOUNT;try{n({key:u,value:!0});const{selectedAccount:e}=r();await t.subTenants.setUserRolesForSubTenants(a,{subTenantsRoles:i},{jwt:o}),await l({jwt:o,_tenantId:e.tenantId}),null==c||c(!0)}catch(e){s({key:u,value:Bn(e)}),null==c||c(!1)}finally{n({key:u,value:!1})}},getUserJwtForSubAccount:async e=>{const{tenantId:a,callback:i}=e,r=zo.GET_USER_JWT;try{n({key:r,value:!0});const e=await t.users.GetUserJwt({tenantId:a});o({userJwt:e,accessPermission:!0}),null==i||i(!0)}catch(e){s({key:r,value:Bn(e)}),o({accessPermission:!1}),null==i||i(!1)}finally{n({key:r,value:!1})}},setRootAccountData:async()=>{const a=zo.SET_ROOT_ACCOUNT_DATA;n({key:a,value:!0});const{activeTenant:o}=e.auth.tenantsState,{accounts:l}=r();if(o)try{var c;const e=await t.tenants.getTenantsUsersCount({tenantIds:[null==o?void 0:o.tenantId]}),a={name:null==o?void 0:o.name,tenantId:null==o?void 0:o.tenantId,numberOfUsers:null==(c=e[0])?void 0:c.totalUsers,createdAt:null==o?void 0:o.createdAt};i({rootAccount:a,accounts:S({},l,a)})}catch(e){s({key:a,value:Bn(e)})}finally{n({key:a,value:!1})}},setSelectedSubAccountData:async e=>{const{jwt:a}=e,i=zo.SET_SELECTED_SUB_ACCOUNT_DATA;try{var r,c,u,d,g,p,h;n({key:i,value:!0});const e=await t.accountSettings.getSettings({jwt:a}),[s,y,v]=await Promise.all([t.tenants.getTenantsUsersCount({tenantIds:[null!=(r=null==e?void 0:e.tenantId)?r:""]},{jwt:a}),t.tenants.getParentTenants({jwt:a}),t.tenants.getHierarchyMetadata({_tenantIds:[null!=(c=null==e?void 0:e.tenantId)?c:""]},{jwt:a})]);o({tenantId:null!=(u=e.tenantId)?u:"",name:e.name,numberOfUsersObject:s[0],parentsAccounts:y,numberOfSubAccounts:null==(d=v[0])?void 0:d.totalSubTenants,accountSettings:e,accounts:{name:e.name,tenantId:null!=(g=e.tenantId)?g:"",numberOfUsers:null==(p=s[0])?void 0:p.totalUsers,createdAt:void 0,children:[]}}),await l({jwt:a,_tenantId:null!=(h=null==e?void 0:e.tenantId)?h:""})}catch(e){s({key:i,value:Bn(e)})}finally{n({key:i,value:!1})}},loadNumberOfUsersForSelectedSubAccount:async e=>{const{tenantId:a,jwt:i}=e,r=zo.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT;try{n({key:r,value:!0});const e=await t.tenants.getTenantsUsersCount({tenantIds:[a]},{jwt:i});o({numberOfUsersObject:e[0]})}catch(e){s({key:r,value:Bn(e)})}finally{n({key:r,value:!1})}}}},er=(e,t,a)=>({setAllAccountDialogsState:t=>{Object.assign(e.auth.allAccountsDialogsState,t)},resetAllAccountDialogsState:()=>{$n(e,["auth","allAccountsDialogsState"],Wo)},openCreateSubAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.createSubAccountDialog,S({},t,{open:!0}))},closeCreateSubAccountDialog:()=>{$n(e,["auth","allAccountsDialogsState","createSubAccountDialog"],Wo.createSubAccountDialog)},openUpdateSubAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.updateSubAccountDialog,S({},t,{open:!0}))},closeUpdateSubAccountDialog:()=>{$n(e,["auth","allAccountsDialogsState","updateSubAccountDialog"],Wo.updateSubAccountDialog)},openEnableSubAccountManagementDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.enableSubAccountManagementDialog,S({},t,{open:!0}))},closeEnableSubAccountManagementDialog:()=>{$n(e,["auth","allAccountsDialogsState","enableSubAccountManagementDialog"],Wo.enableSubAccountManagementDialog)},openUpdateSubAccountHierarchySettingsDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.updateSubAccountHierarchySettingsDialog,S({},t,{open:!0}))},closeUpdateSubAccountHierarchySettingsDialog:()=>{$n(e,["auth","allAccountsDialogsState","updateSubAccountHierarchySettingsDialog"],Wo.updateSubAccountHierarchySettingsDialog)},openDisableSubAccountManagementDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.disableSubAccountManagementDialog,S({},t,{open:!0}))},closeDisableSubAccountManagementDialog:()=>{$n(e,["auth","allAccountsDialogsState","disableSubAccountManagementDialog"],Wo.disableSubAccountManagementDialog)},openDeleteSubAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.deleteSubAccountDialog,S({},t,{open:!0}))},closeDeleteSubAccountDialog:()=>{$n(e,["auth","allAccountsDialogsState","deleteSubAccountDialog"],Wo.deleteSubAccountDialog)},openAddUsersToAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.addUsersToAccountDialog,S({},t,{open:!0}))},closeAddUsersToAccountDialog:()=>{$n(e,["auth","allAccountsDialogsState","addUsersToAccountDialog"],Wo.addUsersToAccountDialog)},openDeleteUserFromAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.deleteUserFromAccountDialog,S({},t,{open:!0}))},closeDeleteUserFromAccountDialog:()=>{$n(e,["auth","allAccountsDialogsState","deleteUserFromAccountDialog"],Wo.deleteUserFromAccountDialog)},openEditUserRolesDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.editUserRolesDialog,S({},t,{open:!0}))},closeEditUserRolesDialog:()=>{$n(e,["auth","allAccountsDialogsState","editUserRolesDialog"],Wo.editUserRolesDialog)}}),tr={devices:[],loading:!1,error:null},ar=e=>cn(tr,e),nr=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auth.passkeysState,t)};return{setPasskeysState:s,resetPasskeysState:()=>{$n(e,["auth","passkeysState"],tr)},loadWebAuthnDevices:async()=>{s({loading:!0});try{const{devices:e}=await t.auth.getWebAuthnDevices();s({devices:e,loading:!1})}catch(e){s({loading:!1,error:Bn(e,null)})}},deleteWebAuthnDevice:async a=>{const{callback:n,deviceId:i}=a;s({loading:!0});try{await t.auth.deleteWebAuthnDevice(i);const a=e.auth.passkeysState.devices.filter((e=>e.id!==i));s({devices:a,loading:!1}),null==n||n(!0)}catch(e){s({loading:!1,error:Bn(e,null)}),null==n||n(null,e)}},__shouldShowPromptPasskeys:async function(){const{publicAuthStrategyPolicy:a}=e.auth.securityPolicyState,{policy:i}=a,o=await async function(e){var t;return!(null==e||null==(t=e.secondaryAuthStrategies)||!t.some((({isActive:e,strategy:t})=>e&&t===Ye.Passkeys)))}(i),r="Passkeys"===localStorage.getItem("preferred-login-method"),l="true"===localStorage.getItem("dont-show-again-prompt-passkeys"),[c]=await n.getFeatureFlags(["show-passkeys-new"]);if(!c||!o||r||l)return!1;{const{devices:e}=await t.auth.getWebAuthnDevices();return s({devices:null!=e?e:[]}),0===(null!=e&&e.length?e.length:0)}}}},sr={loading:!1,error:null},ir=e=>cn(sr,e),or=["callback","profilePictureUrl"],rr=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auth.profileState,t)};return{setProfileState:s,resetProfileState:()=>{$n(e,["auth","profileState"],sr)},loadProfile:async()=>{s({loading:!0});try{const a=await Ln(t.teams.getProfile,3,2e3),i=e.auth.user;n.setUser(S({},i,a)),s({profile:a,loading:!1})}catch(e){s({loading:!1,error:Bn(e)})}},saveProfile:async a=>{const{callback:i,profilePictureUrl:o}=a,r=f(a,or);s({saving:!0,error:null,loading:!0});try{var l;const a=null!=(l=e.auth.profileState.profile)?l:{};let s=a.profilePictureUrl;if(o!==a.profilePictureUrl&&o&&(o||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)){const e=Ni(o,"image");if(e){s=await t.teams.updateProfileImage(e);const a=Date.now().toString(),n=new URL(s);n.searchParams.set("t",a),s=n.href}}const c=S({},a,r,{profilePictureUrl:s}),u=await t.users.updateUserProfileV2(c),d=e.auth.user;n.setUser(S({},d,u)),n.setProfileState({profile:u,saving:!1,loading:!1}),null==i||i(c)}catch(e){s({saving:!1,error:Bn(e),loading:!1}),null==i||i(null,e)}},changePassword:async e=>{s({loading:!0});try{var a;await t.teams.changePassword(e),s({loading:!1,error:void 0}),null==(a=e.callback)||a.call(e,!0)}catch(t){var n;s({loading:!1,error:Bn(t)}),null==(n=e.callback)||n.call(e,null,t)}},updateEmail:async e=>{const{email:a,callback:n}=e;s({saving:!0,error:null,loading:!0});try{await t.teams.updateEmail(a),s({saving:!1,error:null,loading:!1}),null==n||n(!0)}catch(e){s({saving:!1,error:Bn(e),loading:!1}),null==n||n(null,e)}},verifyEmail:async e=>{const{email:a,code:i,callback:o}=e;s({saving:!0,error:null,loading:!0});try{await t.teams.verifyEmail(a,i),await n.__refreshToken(),s({saving:!1,error:null,loading:!1}),null==o||o(!0)}catch(e){s({saving:!1,error:Bn(e),loading:!1}),null==o||o(null,e)}}}},lr={loading:!1},cr=e=>cn(lr,e),ur=["callback"],dr=["id"],gr=(e,t,a)=>{const n=t=>{Object.assign(e.auth.provisioningState,t)},s=async(e,a)=>{const{count:n}=await Cn((()=>t.directory.countConfigurationUsers(e.id)),a);return S({},e,{count:n})};return{setProvisioningState:n,resetProvisioningState:()=>{$n(e,["auth","provisioningState"],lr)},__loadCountForConnection:s,loadProvisionConnections:async e=>{n({loading:!0,error:null});try{const a=null==e?void 0:e.retryConfig,i=await Cn((()=>t.directory.getConfigs()),a),o=await Promise.all(i.map((e=>s(e,a))));n({connections:o,loading:!1})}catch(e){n({error:Bn(e),loading:!1})}},createProvisionConnection:async e=>{const{callback:a}=e,i=f(e,ur);n({loading:!0,error:null});try{const e=await t.directory.createConfiguration(i),o=await t.directory.getConfigs(),r=await Promise.all(o.map((e=>s(e))));n({connections:r,loading:!1}),null==a||a(e)}catch(e){n({error:Bn(e),loading:!1})}},deleteProvisionConnection:async e=>{const{id:a,callback:i}=e;n({loading:!0,error:null});try{await t.directory.deleteConfiguration(a,e.deleteAll);const o=await t.directory.getConfigs(),r=await Promise.all(o.map((e=>s(e))));n({connections:r,loading:!1}),null==i||i(!0)}catch(e){n({error:Bn(e),loading:!1}),null==i||i(!1,e)}},updateProvisionConnection:async e=>{const{id:a}=e,i=f(e,dr);n({loading:!0,error:null});try{await t.directory.updateConfiguration(a,i);const e=await t.directory.getConfigs(),o=await Promise.all(e.map((e=>s(e))));n({connections:o,loading:!1})}catch(e){n({error:Bn(e),loading:!1})}}}};let pr;!function(e){e.ResetPhoneNumber="ResetPhoneNumber",e.VerifyResetPhoneNumber="VerifyResetPhoneNumber",e.ChangePhoneNumber="ChangePhoneNumber"}(pr||(pr={}));const hr={step:pr.ResetPhoneNumber,loading:!1},yr=e=>cn(hr,e),vr=["callback"],Sr=["callback"],fr=["callback"],mr=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auth.resetPhoneNumberState,t)};return{setResetPhoneNumberState:s,resetResetPhoneNumberState:()=>{$n(e,["auth","resetPhoneNumberState"],hr)},resetPhoneNumber:async e=>{const{callback:a}=e,i=f(e,vr);s({loading:!0});try{const e=await t.auth.resetPhoneNumber(i);s({loading:!1,error:void 0,resetPhoneNumberToken:e.resetPhoneNumberToken,step:pr.VerifyResetPhoneNumber}),n.setLoginState({email:i.email})}catch(e){s({loading:!1,error:Bn(e)}),null==a||a(null,e)}},verifyResetPhoneNumber:async e=>{const{callback:a}=e,n=f(e,Sr);s({loading:!0});try{const e=await t.auth.verifyResetPhoneNumber(n);s({loading:!1,error:void 0,changePhoneNumberToken:e.changePhoneNumberToken,step:pr.ChangePhoneNumber}),null==a||a(!0)}catch(e){s({loading:!1,error:Bn(e)}),null==a||a(null,e)}},changePhoneNumber:async a=>{const{callback:i}=a,o=f(a,fr);s({loading:!0});try{const{onRedirectTo:a,routes:r}=e.auth;await t.auth.changePhoneNumber({phoneNumber:o.phoneNumber,changePhoneNumberToken:o.changePhoneNumberToken}),n.setLoginState({step:wn.loginWithSmsOtc}),await n.passwordlessPreLogin({type:N.SmsCode,email:o.email,recaptchaToken:o.recaptchaToken}),a(r.loginUrl),s({loading:!1}),null==i||i(!0)}catch(e){s({loading:!1,error:Bn(e)}),null==i||i(null,e)}}}},br={loaders:{},errors:{},roles:[],permissions:[],permissionCategories:[]},Ar=e=>cn(br,e);let wr;!function(e){e.EDIT_ROLE_DIALOG="editRoleDialog",e.DELETE_ROLE_DIALOG="deleteRoleDialog",e.LOAD_ROLES="loadRoles",e.ADD_ROLE="addRole",e.MANAGE_PERMISSIONS="managePermissions"}(wr||(wr={}));const Tr=["callback"],Er=["callback"],Pr=["callback"],Ir=["callback"],Or=["callback"],kr=["callback"],_r=(e,t,a)=>{const n=t=>{Object.assign(e.auth.rolesState,t)},s=t=>{Object.assign(e.auth.rolesState,{loaders:S({},e.auth.rolesState.loaders,{[t.key]:t.value})})},i=t=>{Object.assign(e.auth.rolesState,{errors:S({},e.auth.rolesState.errors,{[t.key]:t.value}),loaders:S({},e.auth.rolesState.loaders,{[t.key]:!1})})},o=async a=>{var o;const r=wr.LOAD_ROLES;s({key:r,value:!(null!=(o=null==a?void 0:a.silentLoading)&&o)});try{const s=null==a?void 0:a.retryConfig,[i,o,r]=await Promise.all([Cn((()=>t.roles.getRoles()),s),Cn((()=>t.roles.getPermissions()),s),Cn((()=>t.roles.getPermissionCategories()),s)]),{selectedRole:l}=e.auth.rolesState,c=null==i?void 0:i.find((({id:e})=>(null==l?void 0:l.id)===e));n({roles:i,permissions:o,permissionCategories:r,selectedRole:c})}catch(e){i({key:r,value:Bn(e)})}finally{s({key:r,value:!1})}},r=async e=>{const{callback:a}=e,r=f(e,Or),l=wr.MANAGE_PERMISSIONS;s({key:l,value:!0});try{const e=await t.roles.attachPermissionsToRole(r);await o({silentLoading:!0}),n({saving:!1}),null==a||a(e)}catch(e){i({key:l,value:Bn(e)}),null==a||a(null,e)}finally{s({key:l,value:!1})}};return{setRolesState:n,setRolesStateLoader:s,setRolesStateError:i,resetRolesState:()=>{$n(e,["auth","rolesState"],br)},loadRolesAndPermissions:o,addRole:async e=>{const{callback:a}=e,n=f(e,Tr),r=wr.ADD_ROLE;s({key:r,value:!0});try{const e=await t.roles.addRole(n);await o({silentLoading:!0}),null==a||a(e)}catch(e){i({key:r,value:Bn(e)}),null==a||a(null,e)}finally{s({key:r,value:!1})}},addRoleV2:async e=>{const{callback:a}=e,n=f(e,Er),r=wr.ADD_ROLE;s({key:r,value:!0});try{const e=await t.roles.addRoleV2(n);await o({silentLoading:!0}),null==a||a(e)}catch(e){i({key:r,value:Bn(e)}),null==a||a(null,e)}finally{s({key:r,value:!1})}},updateRole:async e=>{const{callback:a}=e,r=f(e,Pr),l=wr.EDIT_ROLE_DIALOG;s({key:l,value:!0});try{const e=await t.roles.updateRole(r);await o({silentLoading:!0}),n({saving:!1}),null==a||a(e)}catch(e){i({key:l,value:Bn(e)}),null==a||a(null,e)}finally{s({key:l,value:!1})}},deleteRole:async e=>{const{callback:a}=e,r=f(e,Ir),l=wr.DELETE_ROLE_DIALOG;s({key:l,value:!0});try{await t.roles.deleteRole(r),await o({silentLoading:!0}),n({saving:!1}),null==a||a(!0)}catch(e){i({key:l,value:Bn(e)}),null==a||a(!1,e)}finally{s({key:l,value:!1})}},attachPermissionsToRole:r,attachPermissionToRoles:async e=>{const{callback:t}=e,a=f(e,kr),n=wr.MANAGE_PERMISSIONS;s({key:n,value:!0});try{await Promise.all(a.roleIds.map((e=>r({roleId:e,permissionIds:[a.permissionId]})))),await o({silentLoading:!0}),null==t||t(!0)}catch(e){i({key:n,value:Bn(e)}),null==t||t(null,e)}finally{s({key:n,value:!1})}}}},Ur={ipRestrictions:{loading:!1,pagination:{_offset:0,_limit:4,_filter:Je.ALLOW},totalPages:1,userIpValid:!1},emailDomainRestrictions:{loading:!1}},Rr=e=>cn(Ur,e),Lr=["callback"],Cr=["callback"],Dr=["callback"],Nr=["callback"],Mr=(e,t,a)=>{const n=a,s=e=>{var t,a,n;return{_filter:null!=(t=null==e?void 0:e._filter)?t:Je.ALLOW,_limit:null!=(a=null==e?void 0:e._limit)?a:10,_offset:null!=(n=null==e?void 0:e._offset)?n:0}},i=e=>async(...t)=>{const[a]=await n.getFeatureFlags(["security-center-admin-portal-major-version"]);await e(...t),a&&(await n.loadRecommendations(Dn()),await n.loadInsights(Dn()))},o=t=>{Object.assign(e.auth.restrictionsState.ipRestrictions,t)},r=t=>{Object.assign(e.auth.restrictionsState.emailDomainRestrictions,t)},l=async()=>{try{const{valid:e}=await t.auth.testCurrentIpInAllowList();o({userIpValid:e})}catch(e){o({error:Bn(e)})}},c=i((async()=>{o({loading:!0,error:null});try{const a=e.auth.restrictionsState.ipRestrictions,n=await t.auth.getIPRestrictionsConfig(),i=s({_filter:n.strategy,_limit:a.pagination._limit,_offset:a.pagination._offset}),{items:r,_metadata:{totalPages:l}}=await t.auth.getIPRestrictions(i);o({data:{restrictions:r,config:n},totalPages:l,pagination:i,loading:!1})}catch(e){o({error:Bn(e),loading:!1})}})),u=i((async a=>{const{callback:n}=a,i=f(a,Lr);o({saving:!0,error:null});try{var r,c;await t.auth.createIPRestriction(i);const a=e.auth.restrictionsState.ipRestrictions,u=s(a.pagination),{items:d,_metadata:{totalPages:g}}=await t.auth.getIPRestrictions(u),p=d;await l(),o({data:{config:null!=(r=null==(c=a.data)?void 0:c.config)?r:{isActive:!1,strategy:Je.ALLOW},restrictions:p},pagination:u,totalPages:g,saving:!1}),null==n||n(!0)}catch(e){o({saving:!1,error:Bn(e)}),null==n||n(null,e)}})),d=i((async a=>{const{callback:n}=a,i=f(a,Cr);o({saving:!0,error:null});try{await t.auth.updateIPRestrictionConfig(i);const a=e.auth.restrictionsState.ipRestrictions,r=await t.auth.getIPRestrictionsConfig(),c=s(S({},a.pagination,{_filter:r.strategy})),{items:u,_metadata:{totalPages:d}}=await t.auth.getIPRestrictions(c),g=u;await l(),o({data:{config:r,restrictions:g},pagination:c,totalPages:d,saving:!1}),null==n||n(!0)}catch(e){o({saving:!1,error:Bn(e)}),null==n||n(null,e)}})),g=i((async a=>{const{id:n,callback:i}=a;o({saving:!0,error:null});try{var r;await t.auth.deleteIPRestriction(n);const a=e.auth.restrictionsState.ipRestrictions,c=s(a.pagination),{items:u,_metadata:{totalPages:d}}=await t.auth.getIPRestrictions(c),g=u;await l(),o({data:{config:(null==(r=a.data)?void 0:r.config)||{isActive:!1,strategy:Je.ALLOW},restrictions:g},pagination:c,totalPages:d,saving:!1}),null==i||i(!0)}catch(e){o({saving:!1,error:Bn(e)}),null==i||i(null,e)}})),p=i(l),h=i((async a=>{const{callback:n}=a;o({saving:!0,error:null});try{var i,r;const a=null!=(i=(null==(r=e.auth.userIpData)?void 0:r.ip)||e.auth.userIp)?i:"";await Promise.all([t.auth.createIPRestriction({ip:a,isActive:!0,description:"My IP",strategy:Je.ALLOW}),t.auth.updateIPRestrictionConfig({isActive:!0})]);const l=e.auth.restrictionsState.ipRestrictions,c=s(l.pagination),{items:u,_metadata:{totalPages:d}}=await t.auth.getIPRestrictions(c),g=u;o({data:{config:{isActive:!0,strategy:Je.ALLOW},restrictions:g},userIpValid:!0,pagination:c,totalPages:d,saving:!1}),null==n||n(!0)}catch(e){o({saving:!1,error:e}),null==n||n(!1,e)}})),y=i((async()=>{r({loading:!0,error:null});try{const e=await t.auth.getDomainRestrictionsConfig(),a=(await t.auth.getDomainRestrictions()).items.filter((t=>t.type===e.listType));r({data:{restrictions:a,config:e},loading:!1})}catch(e){r({error:Bn(e),loading:!1})}})),v=i((async a=>{const{callback:n}=a,s=f(a,Dr);r({saving:!0,error:null});const i=e.auth.restrictionsState.emailDomainRestrictions;try{var o;await t.auth.createDomainRestriction(s);const e=(await t.auth.getDomainRestrictions()).items.filter((e=>{var t;return e.type===(null==(t=i.data)?void 0:t.config.listType)}));r({data:{config:(null==(o=i.data)?void 0:o.config)||{active:!1,blockPublicDomains:!1,listType:s.type},restrictions:e},saving:!1}),null==n||n(!0)}catch(e){r({saving:!1,error:Bn(e)}),null==n||n(null,e)}})),m=i((async e=>{const{callback:a}=e,n=f(e,Nr);r({saving:!0,error:null});try{const e=await t.auth.updateDomainRestrictionConfig(n),s=(await t.auth.getDomainRestrictions()).items.filter((t=>t.type===e.listType));r({data:{config:e,restrictions:s},saving:!1}),null==a||a(!0)}catch(e){r({saving:!1,error:Bn(e)}),null==a||a(null,e)}})),b=i((async a=>{const{id:n}=a;r({saving:!0,error:null});const s=e.auth.restrictionsState.emailDomainRestrictions;try{var i;await t.auth.deleteDomainRestriction(n);const e=(await t.auth.getDomainRestrictions()).items.filter((e=>{var t;return e.type===(null==(t=s.data)?void 0:t.config.listType)}));r({data:{config:(null==(i=s.data)?void 0:i.config)||{active:!1,blockPublicDomains:!1,listType:Je.ALLOW},restrictions:e},saving:!1})}catch(e){r({saving:!1,error:Bn(e)})}}));return{setRestrictionsState:t=>{Object.assign(e.auth.restrictionsState,t)},setIpRestrictionsState:o,setEmailDomainRestrictionsState:r,__securityCenterSagaWrapper:i,loadIpRestrictions:c,saveIpRestriction:u,saveIpRestrictionsConfig:d,deleteIpRestriction:g,checkIfUserIpValid:p,addCurrentUserIpAndActivate:h,loadEmailDomainRestrictions:y,saveEmailDomainRestriction:v,saveEmailDomainRestrictionsConfig:m,deleteEmailDomainRestriction:b}},Fr={loaders:{},errors:{},recommendations:void 0,insights:void 0,hasSecurityChanges:!1,score:0,breachedPasswordUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10}},unenrolledMfaUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10}},inactiveUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10,_maxInactiveSeconds:7776e3}}},xr=e=>cn(Fr,e);let $r;!function(e){e.RECOMMENDATIONS="recommendations",e.INSIGHTS="insights",e.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS="sendBulkResetBreachedPasswordEmails",e.SEND_BREACHED_PASSWORD_EMAIL="sendBreachedPasswordEmail",e.BREACHED_PASSWORD_USERS_TABLE="breachedPasswordUsersTable",e.UNENROLLED_MFA_USERS_TABLE="unenrolledMfaUsersTable",e.INACTIVE_USERS_TABLE="inactiveUsersTable"}($r||($r={}));const Gr=["callback"],jr=(e,t,a)=>{const n=a,s=async e=>{var a,s,l,c;const{key:u,tableState:d,updateStateKey:g,_offset:p,_limit:h,_preset:y,_email:v,_maxInactiveSeconds:f}=e;r({key:u,value:!1}),o({key:u,value:!0});const m=null!=(a=null!=p?p:null==d||null==(s=d.queryParams)?void 0:s._offset)?a:0,b=null!=(l=null!=h?h:null==d||null==(c=d.queryParams)?void 0:c._limit)?l:10,A=S({_offset:m,_limit:b,_includeSubTenants:!1,_preset:y,_maxInactiveSeconds:f},!!v&&{_email:v});try{const{items:e,_metadata:{totalItems:a,totalPages:s}}=await t.users.getUsersV3(A),o={totalUsersItems:a,totalUsersPages:s,usersPageOffset:m,queryParams:S({_offset:m,_limit:b,_maxInactiveSeconds:f},!!v&&{_email:v})};if(e.length){const a=await(async e=>{const a=e.map((e=>e.id)),n=await t.roles.getRoles(),s=await t.users.getUsersRoles({ids:a});return e.map((e=>{var t,a;const i=null==s||null==(t=s.find((t=>t.userId===e.id)))?void 0:t.roleIds;return S({},e,{roles:null!=(a=null==i?void 0:i.map((e=>{var t;return null!=(t=null==n?void 0:n.find((t=>t.id===e)))?t:[]})))?a:[]})}))})(e);n.setSecurityCenterState({[g]:S({users:a},o)})}else i({[g]:S({users:[]},o)})}catch(e){r({key:u,value:Bn(e)})}finally{o({key:u,value:!1})}},i=t=>{Object.assign(e.auth.securityCenterState,t)},o=t=>{Object.assign(e.auth.securityCenterState,{loaders:S({},e.auth.securityCenterState.loaders,{[t.key]:t.value})})},r=t=>{Object.assign(e.auth.securityCenterState,{errors:S({},e.auth.securityCenterState.errors,{[t.key]:t.value}),loaders:S({},e.auth.securityCenterState.loaders,{[t.key]:!1})})};return{setSecurityCenterState:i,resetSecurityCenterState:()=>{$n(e,["auth","securityCenterState"],Fr)},setSecurityCenterStateLoader:o,setSecurityCenterStateError:r,loadRecommendations:async e=>{const a=$r.RECOMMENDATIONS;o({key:a,value:!0});try{var n;const{recommendations:a,scoring:s}=await Cn((()=>t.securityCenter.getRecommendations()),null==e?void 0:e.retryConfig);i({recommendations:a.items,score:null!=(n=null==s?void 0:s.score)?n:0})}catch(e){r({key:a,value:Bn(e)})}finally{o({key:a,value:!1})}},loadInsights:async e=>{const a=$r.INSIGHTS;o({key:a,value:!0});try{const{insights:a}=await await Cn((()=>t.securityCenter.getInsights()),null==e?void 0:e.retryConfig);i({insights:a.items})}catch(e){r({key:a,value:Bn(e)})}finally{o({key:a,value:!1})}},sendResetBreachedPasswordEmail:async e=>{const{callback:a}=e,n=f(e,Gr),s=$r.SEND_BREACHED_PASSWORD_EMAIL;r({key:s,value:!1}),o({key:s,value:!0});try{await t.auth.forgotPassword(n),null==a||a(!0)}catch(e){r({key:s,value:Bn(e)}),null==a||a(!1,e)}finally{o({key:s,value:!1})}},sendBulkResetBreachedPasswordEmails:async e=>{const{callback:a}=e,n=$r.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS;r({key:n,value:!1}),o({key:n,value:!0});try{await t.users.sendResetBreachedPasswordEmails(),null==a||a(!0)}catch(e){r({key:n,value:Bn(e)}),null==a||a(!1)}finally{o({key:n,value:!1})}},loadBreachedPasswordUsers:async t=>{var a;const n=$r.BREACHED_PASSWORD_USERS_TABLE,i=null==(a=e.auth.securityCenterState)?void 0:a.breachedPasswordUsersTable;await s(S({key:n,updateStateKey:"breachedPasswordUsersTable",_preset:qa.BREACHED_PASSWORDS,tableState:i},t))},loadUnenrolledMfaUsers:async t=>{var a;const n=$r.UNENROLLED_MFA_USERS_TABLE,i=null==(a=e.auth.securityCenterState)?void 0:a.unenrolledMfaUsersTable;await s(S({key:n,updateStateKey:"unenrolledMfaUsersTable",_preset:qa.MFA_UNENROLLED,tableState:i},t))},loadInactiveUsers:async t=>{var a;const n=$r.INACTIVE_USERS_TABLE,i=null==(a=e.auth.securityCenterState)?void 0:a.inactiveUsersTable;await s(S({key:n,updateStateKey:"inactiveUsersTable",_preset:qa.INACTIVE,tableState:i},t))},markSecurityCenterStateAsChanged:(e=!0)=>{i({hasSecurityChanges:e})}}},Br={globalPolicy:{loading:!0},publicPolicy:{loading:!1},vendorMfaPolicy:{loading:!0},mfaPolicy:{loading:!0},vendorLockoutPolicy:{loading:!0},lockoutPolicy:{loading:!0},captchaPolicy:{loading:!0},passwordHistoryPolicy:{loading:!0},passwordPolicy:{loading:!0},vendorPasswordHistoryPolicy:{loading:!0},publicAuthStrategyPolicy:{loading:!0},passwordRotationPolicy:{loading:!0}},Vr=e=>cn(Br,e);function Wr(e,t){const a=null!=t,n=null!=e;if(a||n)return a?n?Math.min(e,t):t:e}const Hr=["callback"],zr=["callback"],Kr=["callback"],qr=["callback"],Jr=(e,t,a)=>{const n=a,s=async(e,t)=>{var a,s;if(!await n.customLoginEnabled())return e;const o=await i(t);return null!=o&&null!=(a=o.mainAuthStrategies)&&null!=(s=a[0])&&s.strategy?S({},e,{authStrategy:o.mainAuthStrategies[0].strategy}):e},i=async a=>{let n;return n=e.auth.isAuthenticated?await Cn(t.auth.getPublicAuthStrategiesConfigForAuthenticatedUser,a):await Cn(t.auth.getVendorPublicAuthStrategiesConfig,a),n},o=t=>{Object.assign(e.auth.securityPolicyState.globalPolicy,t)},r=t=>{Object.assign(e.auth.securityPolicyState.publicPolicy,t)},l=t=>{Object.assign(e.auth.securityPolicyState.mfaPolicy,t)},c=t=>{Object.assign(e.auth.securityPolicyState.vendorMfaPolicy,t)},u=t=>{Object.assign(e.auth.securityPolicyState.lockoutPolicy,t)},d=t=>{Object.assign(e.auth.securityPolicyState.vendorLockoutPolicy,t)},g=t=>{Object.assign(e.auth.securityPolicyState.captchaPolicy,t)},p=t=>{Object.assign(e.auth.securityPolicyState.passwordHistoryPolicy,t)},h=t=>{Object.assign(e.auth.securityPolicyState.vendorPasswordHistoryPolicy,t)},y=t=>{Object.assign(e.auth.securityPolicyState.passwordRotationPolicy,t)},v=t=>{Object.assign(e.auth.securityPolicyState.passwordPolicy,t)},m=t=>{Object.assign(e.auth.securityPolicyState.publicAuthStrategyPolicy,t)},b=async e=>{o({loading:!0,error:null});try{const a=await Cn((()=>t.auth.getGlobalSecurityPolicy()),null==e?void 0:e.retryConfig);o({policy:a,loading:!1})}catch(e){o({error:Bn(e),loading:!1})}},A=async e=>{l({loading:!0,error:null});try{const a=await Cn((()=>t.auth.getMfaPolicy()),null==e?void 0:e.retryConfig);l({policy:a,loading:!1})}catch(e){l({error:Bn(e),loading:!1})}},w=async e=>{l({loading:!0,error:null});try{const a=await Cn((()=>t.auth.getVendorMfaPolicy()),null==e?void 0:e.retryConfig);c({policy:a,loading:!1})}catch(e){c({error:Bn(e),loading:!1})}},T=async e=>{u({loading:!0,error:null});try{const a=await Cn((()=>t.auth.getLockoutPolicy()),null==e?void 0:e.retryConfig);u({policy:a,loading:!1})}catch(e){u({error:Bn(e),loading:!1})}},E=async e=>{d({loading:!0,error:null});try{const a=await Cn((()=>t.auth.getVendorLockoutPolicy()),null==e?void 0:e.retryConfig);d({policy:a,loading:!1})}catch(e){d({error:Bn(e),loading:!1})}},P=async e=>{u({loading:!0,error:null});try{const a=await Cn((()=>t.auth.getCaptchaPolicy()),null==e?void 0:e.retryConfig);g({policy:a,loading:!1})}catch(e){g({error:Bn(e),loading:!1})}},I=async e=>{h({loading:!0,error:null});try{const a=await Cn((()=>t.auth.getVendorPasswordHistoryPolicy()),null==e?void 0:e.retryConfig);h({policy:a,loading:!1})}catch(e){h({error:Bn(e),loading:!1})}},O=async t=>{m({loading:!0,error:null});try{var a,s,o;const l=await i(null==t?void 0:t.retryConfig);await(async t=>{var a,s;const i=await n.customLoginEnabled();if(!t||!i)return;const{policy:o}=null!=(a=null==(s=e.auth.securityPolicyState)?void 0:s.publicPolicy)?a:{policy:null};r({policy:S({},o,{authStrategy:t}),loading:!1})})(null==l||null==(a=l.mainAuthStrategies)||null==(s=a[0])?void 0:s.strategy),m({policy:l,loading:!1}),null==t||null==(o=t.callback)||o.call(t,l)}catch(e){var l;m({error:Bn(e),loading:!1}),null==t||null==(l=t.callback)||l.call(t,null,e)}};return{setSecurityPolicyState:t=>{Object.assign(e.auth.securityPolicyState,t)},setSecurityPolicyGlobalState:o,setSecurityPolicyPublicState:r,setSecurityPolicyMfaState:l,setSecurityPolicyVendorMfaState:c,setSecurityPolicyLockoutState:u,setSecurityPolicyVendorLockoutState:d,setSecurityPolicyCaptchaState:g,setSecurityPolicyPasswordHistoryState:p,setSecurityPolicyVendorPasswordHistoryState:h,setSecurityPolicyPasswordRotationState:y,resetSecurityPolicyState:()=>{$n(e,["auth","securityPolicyState"],Br)},setSecurityPolicyPasswordState:v,setSecurityPolicyAuthStrategyPublicState:m,loadSecurityPolicy:async e=>{const t={retryConfig:null==e?void 0:e.retryConfig};await Promise.all([b(),A(),w(t),T(t),E(t),I(),P(t),O(t)])},loadGlobalSecurityPolicy:b,loadPublicSecurityPolicy:async e=>{r({loading:!0,error:null});try{const a=await t.auth.getVendorConfig(),n=await s(a,null==e?void 0:e.retryConfig);r({policy:n,loading:!1})}catch(e){r({error:Bn(e),loading:!1})}},loadVendorPasswordConfig:async e=>{v({loading:!0,error:null});try{var a;const n=await Cn((()=>t.auth.getPasswordConfigPolicy()),null==e?void 0:e.retryConfig);v({policy:n,loading:!1}),null==e||null==(a=e.callback)||a.call(e,n)}catch(t){var n;v({error:Bn(t),loading:!1}),null==e||null==(n=e.callback)||n.call(e,null,t)}},loadSecurityPolicyMfa:A,loadSecurityPolicyVendorMfa:w,loadSecurityPolicyLockout:T,loadSecurityPolicyVendorLockout:E,loadSecurityPolicyCaptcha:P,loadSecurityPolicyPasswordHistory:async()=>{p({loading:!0,error:null});try{const e=await t.auth.getPasswordHistoryPolicy();p({policy:e,loading:!1})}catch(e){p({error:Bn(e),loading:!1})}},loadSecurityPolicyVendorPasswordHistory:I,loadSecurityPolicyPasswordRotation:async()=>{y({loading:!0,error:null});try{const e=await t.securityPolicy.getPasswordRotationPolicy(),a=await t.securityPolicy.getVendorPasswordRotationPolicy(),n={passwordRotationVendorConfig:a};e&&(null!=a&&a.isActive?n.passwordRotationTenantConfig=null!=e&&e.isActive?S({},e,{rotationPeriod:Wr(a.rotationPeriod,e.rotationPeriod)}):a:n.passwordRotationTenantConfig=e),y({policy:S({},n),loading:!1})}catch(e){y({error:Bn(e),loading:!1})}},loadPublicAuthStrategiesPolicy:O,saveSecurityPolicyMfa:async e=>{const{callback:a}=e,n=f(e,Hr);l({saving:!0,error:null});try{const e=await t.auth.securityPolicy.saveMfaPolicy(n);l({policy:e,saving:!1}),null==a||a(e)}catch(e){l({saving:!1,error:Bn(e)}),null==a||a(null,e)}},saveSecurityPolicyLockout:async e=>{const{callback:a}=e,n=f(e,zr);u({saving:!0,error:null});try{const e=await t.auth.saveLockoutPolicy(n);u({policy:e,saving:!1}),null==a||a(e)}catch(e){u({saving:!1,error:Bn(e)}),null==a||a(null,e)}},saveSecurityPolicyPasswordHistory:async e=>{const{callback:a}=e,n=f(e,Kr);p({saving:!0,error:null});try{const e=await t.auth.savePasswordHistoryPolicy(n);p({policy:e,saving:!1}),null==a||a(e)}catch(e){p({saving:!1,error:Bn(e)}),null==a||a(null,e)}},saveSecurityPolicyPasswordRotation:async e=>{const{callback:a}=e,n=f(e,qr);y({saving:!0,error:null});try{await t.securityPolicy.savePasswordRotationPolicy(n.passwordRotationTenantConfig||{}),y({policy:n,saving:!1}),null==a||a(n)}catch(e){y({saving:!1,error:Bn(e)}),null==a||a(null,e)}},__getSecurityPolicyPublicStateWithCustomLogin:s}},Yr={loading:!1,configurations:{}},Xr=e=>cn(Yr,e),Qr=["callback"],Zr=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auth.sessionsPolicyState,t)};return{setSessionsPolicyState:s,resetSessionsPolicyState:()=>{$n(e,["auth","sessionsPolicyState"],Yr)},loadSessionsPolicy:async()=>{s({loading:!0,error:null});try{const e=await t.auth.getSessionConfigurations();s({configurations:e,loading:!1})}catch(e){n.setSessionsState({error:e,loading:!1})}},createOrUpdateSessionsPolicy:async e=>{const{callback:a}=e,i=f(e,Qr);try{s({loading:!0,error:null}),await t.auth.createOrUpdateSessionConfigrations(i),await n.loadSessionsPolicy(),null==a||a(!0)}catch(e){s({error:e,loading:!1})}}}},el={loading:!1,sessions:[]},tl=e=>cn(el,e),al=(e,t,a)=>{const n=t=>{Object.assign(e.auth.sessionsState,t)},s=async e=>{n({loading:!0,error:null});try{const a=await Cn((()=>t.auth.getCurrentUserSessions()),null==e?void 0:e.retryConfig);n({sessions:a,loading:!1})}catch(e){n({error:Bn(e),loading:!1})}};return{setSessionsState:n,resetSessionsState:()=>{$n(e,["auth","sessionsState"],el)},loadUserSessions:s,loadCurrentUserSession:async()=>{n({loading:!0,error:null});try{const e=await t.auth.getCurrentUserSession();n({currentSession:e,loading:!1})}catch(e){n({error:Bn(e),loading:!1})}},deleteUserSession:async e=>{const{id:a}=e;n({loading:!0,error:null});try{await t.auth.deleteSessionForUser(a),await s()}catch(e){n({error:Bn(e),loading:!1})}},deleteAllUserSessions:async()=>{n({loading:!0,error:null});try{await t.auth.deleteAllSessionsForUser(),await s()}catch(e){n({error:Bn(e),loading:!1})}},revokeUserSessions:async e=>{const{callback:a,userId:s}=e;n({loading:!0,error:null});try{await t.auth.revokeSessionsForUser(s),n({loading:!1}),null==a||a(!0)}catch(e){n({error:Bn(e),loading:!1}),null==a||a(!1)}}}};let nl;!function(e){e.SignUp="SignUp",e.SignUpSuccess="SignUpSuccess",e.VerifyPhone="VerifyPhone"}(nl||(nl={}));const sl={loading:!1,allowSignUps:!1,allowNotVerifiedUsersLogin:!1,firstLoad:!0,stage:nl.SignUp,strategies:{[F.Email]:{enabled:!0,required:!0},[F.PhoneNumber]:{enabled:!1,required:!1}}},il=e=>cn(sl,e),ol=["events","url"],rl=["events","url"],ll=(e,t,a)=>{const n=a,s=R.for(e.root.appName),i=t=>{Object.assign(e.auth.signUpState,t)},o=()=>{$n(e,["auth","signUpState"],sl)},r=(e,t,a,n,s,i=Zn.PASSWORD)=>{var o;const{email:r,name:l,companyName:c,phoneNumber:u,url:d}=e,g={email:r,name:l,companyName:c,url:d,phoneNumber:u||void 0,authenticationType:i,id:t,tenantId:a,createdAt:new Date,activationToken:n};null==s||null==(o=s.signUpComplete)||o.call(s,g),ss(as.SIGNUP_COMPLETED,g)},l=async a=>{const{events:o}=a,l=f(a,ol);if(i({loading:!0}),!l.phoneNumber)throw new Error("Phone number is required for phone number signup");try{var c,u,d;const{routes:a,onRedirectTo:s}=e.auth,{tenantId:i,userId:g,activationToken:p}=await t.auth.signUpUserWithPhoneNumber(ks(l));l.invitationToken||r(l,g,i,p,o,Zn.PHONE_NUMBER);const{enabled:h,siteKey:y}=null!=(c=e.auth.securityPolicyState.captchaPolicy.policy)?c:{},v=h&&y?await(null==(u=window.grecaptcha)||null==(d=u.execute)?void 0:d.call(u,{action:"login"})):"";n.passwordlessPreLogin({recaptchaToken:v,phoneNumber:l.phoneNumber,type:N.SmsCode,callback:(e,t)=>{if(!e&&t)throw t;s(a.loginUrl),n.setLoginState({step:wn.loginWithSmsOtc,phoneNumber:l.phoneNumber})}})}catch(e){s.setAccessToken(null),s.setUser(null),i({error:Bn(e)})}finally{i({loading:!1})}};return{setSignUpState:i,resetSignUpState:o,resetSignUpStateSoft:()=>{const{allowSignUps:t,allowNotVerifiedUsersLogin:a}=e.auth.signUpState;o(),i({allowSignUps:t,allowNotVerifiedUsersLogin:a})},signUpUser:async a=>{const{events:o}=a,c=f(a,rl);i({loading:!0});const u=e.auth.signUpState.strategies.phoneNumber;if(null!=u&&u.required&&null!=u&&u.enabled&&c.phoneNumber)return l(a);try{const{routes:a,onRedirectTo:s}=e.auth,{shouldActivate:l,user:u,tenantId:d,userId:g,tenants:p=[],activeTenant:h,activationToken:y}=await t.auth.signUpUser(ks(c));if(c.invitationToken||r(c,g,d,y,o),!l&&u&&Es(u,e.root.appName)){const e=await n.getMfaRequiredState(u,Un,!0,c.email);n.setAuthState(e),s(a.loginUrl)}else if(l&&y){const e=new URLSearchParams({userId:g||"",token:y||""}),t=`${a.activateWithOTCUrl}?${e.toString()}`;i({loading:!1,shouldActivate:l,stage:nl.SignUpSuccess}),s(t)}else{const t=e.auth.tenantsState;i({loading:!1,shouldActivate:l,stage:nl.SignUpSuccess}),n.setAuthState({user:u,isAuthenticated:!(null==u||!u.accessToken),tenantsState:S({},t,{tenants:p,activeTenant:h})})}}catch(e){s.setAccessToken(null),s.setUser(null),i({error:Bn(e)})}finally{i({loading:!1})}},signUpUserWithPhoneNumber:l,loadAllowSignUps:async e=>{i({loading:!0});try{var a;const s=await Cn(t.auth.getVendorConfig,null==e?void 0:e.retryConfig),o=await n.__getSecurityPolicyPublicStateWithCustomLogin(s,null==e?void 0:e.retryConfig),{allowSignups:r,allowNotVerifiedUsersLogin:l}=s;i({loading:!1,allowSignUps:r,allowNotVerifiedUsersLogin:l,firstLoad:!1}),n.setSecurityPolicyPublicState({policy:o,loading:!1}),null==e||null==(a=e.callback)||a.call(e,o||s)}catch(t){var s;i({loading:!1,error:Bn(t),firstLoad:!1}),null==e||null==(s=e.callback)||s.call(e,null,t)}},loadSignUpStrategies:async()=>{try{const e=await t.auth.getSignUpStrategies();i({strategies:e.reduce(((e,{isActive:t,strategy:a,isRequired:n})=>(e[a]={enabled:t,required:n},e)),{})})}catch(e){}}}},cl={loading:!1,error:null,phoneNumbers:void 0},ul=e=>cn(cl,e),dl=["callback"],gl=["callback"],pl=["callback"],hl=["callback","phoneId"],yl=["callback","phoneId"],vl=["callback"],Sl=(e,t,a)=>{const n=t=>{Object.assign(e.auth.smsState,t)},s=async()=>{n({loading:!0});const e={_limit:10,_offset:0};try{const{items:a}=await t.userPhoneNumbers.getUserPhoneNumbers(e);n({phoneNumbers:a})}catch(e){n({error:Bn(e)})}finally{n({loading:!1})}},i=async()=>{n({loading:!0});try{const e=await t.userPhoneNumbers.getUserOwnPhoneNumbers();n({phoneNumbers:e})}catch(e){n({error:Bn(e)})}finally{n({loading:!1})}};return{setSmsState:n,resetSmsState:()=>{$n(e,["auth","smsState"],cl)},loadPhoneNumbers:s,loadUserOwnPhoneNumbers:i,setUpPhoneNumber:async e=>{const{callback:a}=e,i=f(e,gl);try{const{otcToken:e}=await t.userPhoneNumbers.createPhoneNumber(i);n({otcToken:e}),await s(),null==a||a(!0)}catch(e){n({error:Bn(e)}),null==a||a(!1,e)}},setUpOwnPhoneNumber:async e=>{const{callback:a}=e,s=f(e,dl);try{const{otcToken:e}=await t.userPhoneNumbers.createPhoneNumber(s);n({otcToken:e}),await i(),null==a||a(!0)}catch(e){n({error:Bn(e)}),null==a||a(!1,e)}},verifyPhoneNumber:async e=>{const{callback:a}=e,i=f(e,pl);n({loading:!0});try{await t.userPhoneNumbers.verifyPhoneNumber(i),await s(),null==a||a(!0)}catch(e){n({error:Bn(e)}),null==a||a(!1,e)}finally{n({loading:!1})}},deletePhoneNumber:async e=>{const{callback:a,phoneId:s}=e;f(e,hl),n({loading:!0});try{const{otcToken:e}=await t.userPhoneNumbers.deletePhoneNumber(s);n({otcToken:e}),null==a||a(!0)}catch(e){n({error:Bn(e)}),null==a||a(!1,e)}finally{n({loading:!1})}},verifyDeletePhoneNumber:async e=>{const{callback:a,phoneId:i}=e,o=f(e,yl);n({loading:!0});try{await t.userPhoneNumbers.verifyDeletePhoneNumber(i,o),await s(),null==a||a(!0)}catch(e){n({error:Bn(e)}),null==a||a(!1,e)}finally{n({loading:!1})}},preVerifyPhoneNumber:async e=>{const{callback:a}=e,s=f(e,vl);n({loading:!0});try{const{otcToken:e}=await t.userPhoneNumbers.preVerifyPhoneNumber(s);n({otcToken:e}),null==a||a(!0)}catch(e){n({error:Bn(e)}),null==a||a(!1,e)}finally{n({loading:!1})}}}},fl={firstLoad:!0,loading:!1,error:""},ml=e=>cn(fl,e),bl=["authorizationUrl"],Al=["events","url"],wl=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auth.socialLoginState,t)};return{setSocialLoginsState:s,resetSocialLoginsState:()=>{$n(e,["auth","socialLoginState"],fl)},setSocialLoginError:e=>{s({error:e.error,loading:!1,firstLoad:!1})},loadSocialLoginsConfiguration:async()=>{try{s({loading:!0});const e=await t.auth.getSocialLoginProviders();s({socialLoginsConfig:e,loading:!1,firstLoad:!1})}catch(e){s({error:Bn(e),loading:!1,firstLoad:!1})}},loadSocialLoginsConfigurationV2:async a=>{try{var n;const i=e.root.context;s({loading:!0});const o=await(async a=>{let n;return n=e.auth.isAuthenticated?await Cn(t.auth.getSocialLoginProvidersV2ForAuthenticatedUser,a):await Cn(t.auth.getSocialLoginProvidersV2,a),n})(null==a?void 0:a.retryConfig),{providers:r}=await Cn(t.auth.getCustomSocialLoginProvidersV1,null==a?void 0:a.retryConfig),l={socialLoginsConfigV2:o.map((e=>{let{authorizationUrl:a}=e,n=f(e,bl);const s=t.fetch.getBaseUrl(i,null!=a?a:"");return S({},n,{authorizationUrl:a?`${s}${a}`:null})})),customSocialLoginsConfig:r,loading:!1,firstLoad:!1};s(l),null==a||null==(n=a.callback)||n.call(a,l)}catch(e){var i;null==a||null==(i=a.callback)||i.call(a,null,e),s({error:Bn(e),loading:!1,firstLoad:!1})}},loginViaSocialLogin:async e=>{const{events:a,url:i}=e,o=f(e,Al);try{s({loading:!0});const{email:e,isNewUser:c,userId:u,tenantId:d,name:g}=await t.auth.loginViaSocialLogin(o);if(c){var r,l;const t={email:e,url:i,createdAt:new Date,id:u,tenantId:d},n=S({},t,{socialProvider:o.provider,authenticationType:Zn.SOCIAL_LOGIN});null==a||null==(r=a.signUpComplete)||r.call(a,n),ss(as.SIGNUP_COMPLETED,n);const s=S({},t,{origin:Qn.SOCIAL_LOGIN,name:g});null==a||null==(l=a.userVerified)||l.call(a,s),ss(as.USER_VERIFIED,s)}u&&localStorage.setItem("userId",u),n.setLoginState({email:e,isNewUser:c}),n.refreshTokenForSocialLogins(),localStorage.removeItem("register-quick-login"),s({loading:!1})}catch(e){s({loading:!1,error:Bn(e,"Failed to authenticate"),firstLoad:!1})}}}},Tl={firstLoad:!0,loading:!0,saving:!1,errors:{},loaders:{},ssoConfigurations:[]},El=e=>cn(Tl,e),Pl=["callback","samlVendor"],Il=["callback"],Ol=["callback","ssoConfigId"],kl=["callback","ssoConfigId"],_l=["callback","ssoConfigId"],Ul=(e,t,a)=>S({},((e,t,a)=>{const n=a,s=async()=>{try{const e=await t.auth.getSamlRoles(),a=await t.auth.getSamlRolesGroups();i({authorizationRoles:e.roleIds,rolesGroups:a,error:void 0})}catch(e){i({error:Bn(e)})}},i=t=>{Object.assign(e.auth.ssoState,t)};return{setSSOState:i,resetSSOState:()=>{$n(e,["auth","ssoState"],Tl)},setSSOLoader:t=>{Object.assign(e.auth.ssoState,{loaders:S({},e.auth.ssoState.loaders,{[t.key]:t.value})})},setSSOError:t=>{Object.assign(e.auth.ssoState,{errors:S({},e.auth.ssoState.errors,{[t.key]:t.value}),loaders:S({},e.auth.ssoState.loaders,{[t.key]:!1})})},loadSSOConfigurations:async()=>{try{var e,a;i({loading:!0});const n=await t.auth.getSamlConfiguration(),s=await t.auth.getOidcConfiguration(),o=await t.metadata.getSamlMetadata();n.acsUrl=null==o||null==(e=o.configuration)?void 0:e.acsUrl,n.spEntityId=null==o||null==(a=o.configuration)?void 0:a.spEntityId,n.isSamlActive=null==o?void 0:o.isActive,i({samlConfiguration:n,oidcConfiguration:s,loading:!1,firstLoad:!1})}catch(e){i({error:Bn(e),loading:!1})}},saveSSOConfigurations:async a=>{const{callback:n,samlVendor:s}=a,o=f(a,Pl),r=e.auth.ssoState.samlConfiguration,l=S({},r,o);let c="saving";(null==l?void 0:l.enabled)!==(null==r?void 0:r.enabled)&&(c="loading");try{if(null==l||!l.domain)return void i({samlConfiguration:S({},r,l)});if(i({error:void 0,[c]:!0}),a.type===ho.Saml){var u,d;const e=await t.metadata.getSamlMetadata();l.acsUrl=null==e||null==(u=e.configuration)?void 0:u.acsUrl,l.spEntityId=null==e||null==(d=e.configuration)?void 0:d.spEntityId}const e=Mn(l,["validated","generatedVerification","createdAt","updatedAt"]);(null==r?void 0:r.domain)!==(null==e?void 0:e.domain)&&(e.ssoEndpoint="",e.publicCertificate="",e.signRequest=!1),e.type=null==s?void 0:s.toLowerCase();const o=await t.auth.updateSamlConfiguration(e);o.isSamlActive=null==r?void 0:r.isSamlActive,i({samlConfiguration:o,error:void 0,[c]:!1}),null==n||n(!0)}catch(e){i({samlConfiguration:r,error:Bn(e),[c]:!1}),null==n||n(null,e)}},saveSSOConfigurationsFile:async a=>{const n=e.auth.ssoState.samlConfiguration,s="saving";i({error:void 0,[s]:!0});try{const e=await Fi(a[0]),o=await t.auth.updateSamlVendorMetadata({metadata:e});o.isSamlActive=null==n?void 0:n.isSamlActive,i({samlConfiguration:o,error:void 0,[s]:!1})}catch(e){i({samlConfiguration:n,error:Bn(e),[s]:!1})}},saveSSOConfigurationsFileWithCallback:async a=>{const{configFile:n,callback:s}=a,o=e.auth.ssoState.samlConfiguration,r="saving";i({error:void 0,[r]:!0});try{const e=await Fi(n),a=await t.auth.updateSamlVendorMetadata({metadata:e});a.isSamlActive=null==o?void 0:o.isSamlActive,i({samlConfiguration:a,error:void 0,[r]:!1}),null==s||s(!0)}catch(e){i({samlConfiguration:o,error:Bn(e),[r]:!1}),null==s||s(null,e)}},validateSSODomain:async a=>{const{callback:n}=null!=a?a:{},s=e.auth.ssoState.samlConfiguration;if(!s){const e=new Error("IllegalState: samlConfiguration is not defined");return console.error(e),void(null==n||n(null,e))}try{i({error:void 0,saving:!0}),await t.auth.validateSamlDomain(),i({samlConfiguration:S({},s,{validated:!0}),error:void 0,saving:!1}),null==n||n(!0)}catch(e){i({samlConfiguration:S({},s,{validated:!1}),error:Bn(e),saving:!1}),null==n||n(null,e)}},loadSSOAuthorizationRoles:async()=>{try{const e=await t.auth.getSamlRoles(),a=await t.auth.getSamlRolesGroups();i({authorizationRoles:e.roleIds,rolesGroups:a,error:void 0})}catch(e){i({error:Bn(e)})}},updateSSOAuthorizationRoles:async e=>{const{callback:a,authorizationRoles:n,groups:o}=e;try{i({error:void 0,saving:!0}),await t.auth.updateSamlRoles({roleIds:n}),o&&await(async e=>{try{await Promise.all(e.map((e=>t.auth.updateSamlGroup({id:e.id,roleIds:e.roleIds,group:e.group}))))}catch(e){i({error:Bn(e)})}})(o),await s(),i({error:void 0,saving:!1}),null==a||a(!0)}catch(e){i({error:Bn(e),saving:!1}),null==a||a(null,e)}},deleteSamlGroup:async e=>{const{id:a,callback:n}=e;try{i({error:void 0,saving:!0}),await t.auth.deleteSamlGroup({id:a}),await s(),i({error:void 0,saving:!1}),null==n||n(!0)}catch(e){i({error:Bn(e),saving:!1}),null==n||n(null,e)}},createSamlGroup:async e=>{const{group:a,roleIds:n,callback:o}=e;try{i({error:void 0,saving:!0}),await t.auth.createSamlGroup({group:a,roleIds:n}),await s(),i({error:void 0,saving:!1}),null==o||o(!0)}catch(e){i({error:Bn(e),saving:!1}),null==o||o(null,e)}},oidcPostlogin:async e=>{const a={code:e.code,redirectUri:e.redirectUri,RelayState:e.state};try{i({loading:!0}),await t.auth.oidcPostLoginV2(a),await n.__refreshToken(),i({loading:!1})}catch(e){i({loading:!1,error:Bn(e,"Failed to authenticate"),firstLoad:!1})}}}})(e,t,a),((e,t,a)=>{const n=a,s=async e=>{try{return await Cn((()=>t.auth.getOidcConfiguration()),e)}catch(e){return null}},i=async e=>{try{return await Cn((()=>t.metadata.getSamlMetadata()),e)}catch(e){return null}},o=async(e,t,a)=>{n.setSSOLoader({key:e,value:!0});try{await a()}catch(a){n.setSSOError({key:e,value:Bn(a)}),null==t||t(null,a)}finally{n.setSSOLoader({key:e,value:!1})}};return{loadSSOConfigurationsV2:async e=>{await o(po.LOAD_SSO_CONFIGURATIONS,void 0,(async()=>{const[a,o]=await Promise.all([s(null==e?void 0:e.retryConfig),i(null==e?void 0:e.retryConfig)]),r=await Cn((()=>t.auth.getSSOConfigurations()),null==e?void 0:e.retryConfig);n.setSSOState({ssoConfigurations:r,oidcConfiguration:a,samlMetadata:o})}))},saveSSOConfigurationV2:async a=>{const{callback:s}=a,i=f(a,Il),r=e.auth.ssoState.ssoConfigurations;await o(po.SAVE_SSO_CONFIGURATION,s,(async()=>{var e;const a=await t.auth.createSSOConfiguration(S({},i,{enabled:null!=(e=i.enabled)&&e}));n.setSSOState({ssoConfigurations:[...r,a]}),null==s||s(a)}))},updateSSOConfiguration:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,Ol),l=e.auth.ssoState.ssoConfigurations;await o(po.UPDATE_SSO_CONFIGURATION,s,(async()=>{const e=await t.auth.updateSSOConfiguration(i,r),a=l.map((t=>t.id===i?e:t));n.setSSOState({ssoConfigurations:a}),null==s||s(e)}))},deleteSSOConfiguration:async a=>{const{ssoConfigId:s,callback:i}=a,r=e.auth.ssoState.ssoConfigurations;await o(po.DELETE_SSO_CONFIGURATION,i,(async()=>{await t.auth.deleteSSOConfiguration(s),n.setSSOState({ssoConfigurations:r.filter((({id:e})=>e!==s))}),null==i||i(!0)}))},saveSSODomain:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,kl),l=e.auth.ssoState.ssoConfigurations;await o(po.SAVE_SSO_DOMAIN,s,(async()=>{const e=await t.auth.createSSODomain(i,r),a=l.map((t=>t.id===i?S({},t,{domains:[...t.domains,e]}):t));n.setSSOState({ssoConfigurations:a}),null==s||s(e)}))},deleteSSODomain:async a=>{const{ssoConfigId:s,domainId:i,callback:r}=a,l=e.auth.ssoState.ssoConfigurations;await o(po.DELETE_SSO_DOMAIN,r,(async()=>{await t.auth.deleteSSODomain(s,i);const e=l.map((e=>e.id===s?S({},e,{domains:e.domains.filter((({id:e})=>e!==i))}):e));n.setSSOState({ssoConfigurations:e}),null==r||r(!0)}))},validateSSODomainV2:async a=>{const{callback:s,domainId:i,ssoConfigId:r}=a;await o(po.VALIDATE_SSO_DOMAIN,s,(async()=>{const a=e.auth.ssoState.ssoConfigurations;await t.auth.validateSSODomainV2(r,i);const o=a.map((e=>e.id===r?S({},e,{domains:e.domains.map((e=>e.id===i?S({},e,{validated:!0}):e))}):e));n.setSSOState({ssoConfigurations:o}),null==s||s(!0)}))},setSSOGroups:async a=>{const{groupsToAdd:s,groupsToDelete:i,ssoConfigId:r,callback:l}=a;await o(po.SAVE_SSO_GROUPS,l,(async()=>{const a=e.auth.ssoState.ssoConfigurations;await Promise.all(i.map((e=>t.auth.deleteSSOGroup(r,e)))),await Promise.all(s.map((e=>t.auth.createSSOGroup(r,e))));const o=await t.auth.getSSOGroups(r),c=a.map((e=>e.id===r?S({},e,{groups:o}):e));n.setSSOState({ssoConfigurations:c}),null==l||l(!0)}))},updateSSOGroups:async e=>{const{ssoConfigId:a,changedGroups:n,callback:s}=e;await o(po.SAVE_SSO_GROUPS,s,(async()=>{await Promise.all(n.map((e=>t.auth.updateSSOGroup(a,e)))),null==s||s(!0)}))},setSSODefaultRoles:async a=>{const{callback:s,ssoConfigId:i,roleIds:r}=a;await o(po.UPDATE_SSO_DEFAULT_ROLES,s,(async()=>{const a=e.auth.ssoState.ssoConfigurations;await t.auth.setSSODefaultRoles(i,{roleIds:r});const o=a.map((e=>e.id===i?S({},e,{roleIds:r}):e));n.setSSOState({ssoConfigurations:o}),null==s||s(!0)}))},saveSSOConfigurationByMetadata:async a=>{const{configFile:s,callback:i}=a;await o(po.SAVE_SSO_CONFIGURATION_BY_METADATA,i,(async()=>{const a=e.auth.ssoState.ssoConfigurations,o=await Fi(s),r=await t.auth.createSSOConfigurationByMetadata({metadata:o});n.setSSOState({ssoConfigurations:[...a,r]}),null==i||i(r)}))},updateSSOConfigurationByMetadata:async a=>{const{callback:s,ssoConfigId:i,configFile:r}=a;await o(po.UPDATE_SSO_CONFIGURATION_BY_METADATA,s,(async()=>{const a=e.auth.ssoState.ssoConfigurations,o=await Fi(r),l=await t.auth.updateSSOConfigurationByMetadata(i,{metadata:o}),c=a.map((e=>e.id===i?l:e));n.setSSOState({ssoConfigurations:c}),null==s||s(l)}))},saveSSOConfigurationByUrl:async a=>{const{metadataUrl:s,configMetadata:i,ssoConfigId:r,callback:l}=a;await o(po.SAVE_SSO_CONFIGURATION_BY_METADATA,l,(async()=>{const a=e.auth.ssoState.ssoConfigurations,o={url:s,configMetadata:i};let c,u;r?(c=await t.auth.updateSSOConfigurationByMetadataUrl(r,o),u=a.map((e=>e.id===r?c:e))):(c=await t.auth.createSSOConfigurationByMetadataUrl(o),u=[c,...a]),n.setSSOState({ssoConfigurations:u}),null==l||l(c)}))},saveSSOConfigurationByData:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,_l),l=e.auth.ssoState.ssoConfigurations;await o(po.SAVE_SSO_CONFIGURATION,s,(async()=>{let e,a;i?(e=await t.auth.updateSSOConfiguration(i,r),a=l.map((t=>t.id===i?e:t))):(e=await t.auth.createSSOConfiguration(r),a=[e,...l]),n.setSSOState({ssoConfigurations:a}),null==s||s(e)}))}}})(e,t,a)),Rl={loading:!1,mfaDevices:void 0,mfaToken:""},Ll=e=>cn(Rl,e),Cl=(e,t,a)=>{const n=a;return S({setStepUpState:t=>{Object.assign(e.auth.stepUpState,t)},resetStepUpState:()=>{$n(e,["auth","stepUpState"],Rl)},stepUpWithAuthenticator:async e=>{await n.mfaWithAuthenticator(e,n.setStepUpState,!0)},preVerifyMFASMSForStepUp:async e=>{await n.preVerifyMFASMS(e,n.setStepUpState)},verifyMFASMSForStepUp:async e=>{await n.verifyMFASMS(e,n.setStepUpState,!0)},preVerifyMFAWebAuthnForStepUp:async e=>{await n.preVerifyMFAWebAuthn(e,n.setStepUpState)},verifyMFAWebAuthnForStepUp:async e=>{await n.verifyMFAWebAuthn(e,n.setStepUpState,!0)},preVerifyMFAEmailCodeForStepUp:async e=>{await n.preVerifyMFAEmailCode(e,n.setStepUpState)},verifyMFAEmailCodeForStepUp:async e=>{await n.verifyMFAEmailCode(e,n.setStepUpState)}},((e,t,a)=>{const n=a;return{generateStepUpSession:async a=>{const{maxAge:s,callback:i}=a;n.setStepUpState({mfaDevices:void 0,mfaToken:""});try{const e=await t.auth.generateStepupSession({maxAge:s});e.hasOwnProperty("user")?await(async e=>{await n.afterAuthenticationStateUpdate(e),await n.afterStepUpAuthNavigation()})(e):await(async({mfaToken:e,mfaDevices:t})=>{n.setStepUpState({mfaDevices:t,mfaToken:e});const a=await gs(t);n.setMfaState({step:a})})(e),null==i||i(!0)}catch(t){null==i||i(!1),await(async t=>{if((e=>"MFA is not enrolled"===(null==e?void 0:e.message))(t))return void n.setMfaState({step:ns.noMFAEnrolledStepUp});window.localStorage.setItem(bn,"true");const a=e.auth.routes;R.for(e.root.appName).onRedirectTo(a.logoutUrl,{preserveQueryParams:!0})})(t)}}}})(e,t,a),((e,t,a)=>{const n=a;return{stepUpHostedLogin:async t=>{var a,s;const i={acr_values:Sn},{maxAge:o}=t||{};void 0!==o&&(i.max_age=o.toString());const r=null==(a=e.auth.tenantsState)||null==(s=a.activeTenant)?void 0:s.alias;r&&(i.organization=r),bs(),window.localStorage.setItem(bn,"true"),await n.__requestHostedLoginAuthorize(i)}}})(e,0,a))},Dl={loaders:{},pageOffset:0,pageSize:20,errors:{},users:[],allUsers:[],roles:[],permissions:[],totalPages:0,shouldShowSubTenantUsersIfReseller:!1,allUsersQueryParams:{_filter:null,_offset:0,_limit:20,_order:"DESC",_sortBy:"name"},addUserDialogState:{loading:!1,open:!1},deleteUserDialogState:{loading:!1,open:!1},lockUserDialogState:{loading:!1,open:!1},enableUserDialogState:{loading:!1,open:!1},disableUserDialogState:{loading:!1,open:!1}},Nl=e=>cn(Dl,e),Ml=["callback","appIds"],Fl=["roles"],xl=["callback","profileImage"],$l=["callback"],Gl=["callback"],jl=["callback"],Bl=["callback","userId"],Vl=["callback"],Wl=["callback"],Hl=["callback"],zl=["callback"],Kl=["callback"],ql=["callback"],Jl=(e,t,a)=>{const n=t=>{Object.assign(e.auth.teamState,t)};return S({setTeamLoader:t=>{Object.assign(e.auth.teamState,{loaders:S({},e.auth.teamState.loaders,{[t.key]:t.value})})},setTeamError:t=>{Object.assign(e.auth.teamState,{errors:S({},e.auth.teamState.errors,{[t.key]:t.value}),loaders:S({},e.auth.teamState.loaders,{[t.key]:!1})})},setTeamState:n,resetTeamState:()=>{$n(e,["auth","teamState"],Dl)},openAddUserDialog:e=>{n({addUserDialogState:S({open:!0,loading:!1,error:!1},e)})},closeAddUserDialog:t=>{var a,s;null==(a=(s=e.auth.teamState.addUserDialogState).onClose)||a.call(s,t),n({addUserDialogState:{loading:!1,error:!1,open:!1}})},openDeleteUserDialog:e=>{n({deleteUserDialogState:S({open:!0,loading:!1,error:!1},e)})},closeDeleteUserDialog:t=>{var a,s;null==(a=(s=e.auth.teamState.deleteUserDialogState).onClose)||a.call(s,t),n({deleteUserDialogState:{loading:!1,error:!1,open:!1}})},lockUser:async e=>{}},((e,t,a)=>{const n=a,s=async e=>{try{const{groups:a}=await Cn((()=>t.groups.getGroups({_groupsRelations:Ha.roles})),e);return a}catch(e){return[]}},i=async e=>{n.setTeamLoader({key:Us.ROLES_AND_PERMISSIONS,value:!0});try{var a;const s=null==e?void 0:e.retryConfig,[{items:i},{items:o}]=await Promise.all([Cn((()=>t.teams.loadAvailableRoles()),s),Cn((()=>t.teams.loadAvailablePermissions()),s)]);n.setTeamState({roles:i,permissions:o}),null==e||null==(a=e.callback)||a.call(e,{roles:i,permissions:o})}catch(t){var s;null==e||null==(s=e.callback)||s.call(e,null,t),n.setTeamError({key:Us.ROLES_AND_PERMISSIONS,value:Bn(t)})}finally{n.setTeamLoader({key:Us.ROLES_AND_PERMISSIONS,value:!1})}};return{loadRoles:i,loadUsers:async a=>{var s,o,r,l;const{silentLoading:c,callback:u}=a,d=e.auth.teamState,g=null!=(s=a.pageSize)?s:d.pageSize,p=null!=(o=a.pageOffset)?o:d.pageOffset,h=null!=(r=a.filter)?r:d.filter,y=null!=(l=a.sort)?l:d.sort;n.setTeamLoader({key:Us.USERS,value:!c}),n.setTeamState({pageSize:g,pageOffset:p,filter:h,sort:y});try{const[{items:e,totalPages:a,totalItems:s}]=await Promise.all([t.teams.loadUsers({pageSize:g,pageOffset:p,filter:h,sort:y}),i()]);n.setTeamState({users:e,totalPages:a,totalItems:s}),null==u||u(e)}catch(e){n.setTeamError({key:Us.USERS,value:Bn(e)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,e)}n.setTeamLoader({key:Us.USERS,value:!1})},loadUsersV2:async o=>{var r,l,c,u,d;const{silentLoading:g,callback:p,shouldLoadRoles:h=!0,shouldLoadApps:y,retryConfig:v}=o,f=e.auth.teamState,m=null!=(r=o.pageSize)?r:f.pageSize,b=null!=(l=o.pageOffset)?l:f.pageOffset,A=null!=(c=o.filter)?c:f.filterV2,w=null!=(u=o.sort)?u:f.sortV2,T=null!=(d=null==o?void 0:o.shouldShowSubTenantUsersIfReseller)?d:null==f?void 0:f.shouldShowSubTenantUsersIfReseller;n.setTeamLoader({key:Us.USERS,value:!g}),n.setTeamState({pageSize:m,pageOffset:b,filterV2:A,sortV2:w});try{const[{items:e,_metadata:{totalPages:n,totalItems:r}},{items:l},{items:c},u]=await Promise.all([Cn((()=>t.users.getUsersV2(S({},(null==A?void 0:A.length)&&{_filter:A},w&&{_sortBy:w},o.order&&{_order:o.order},{_offset:b,_limit:m,_includeSubTenants:T}))),v),Cn((()=>t.teams.loadAvailableRoles()),v),Cn((()=>t.teams.loadAvailablePermissions()),v),s(v),h?i({retryConfig:v}):void 0]),d=e.map((e=>{var t;return S({},e,{groups:null==e||null==(t=e.groups)?void 0:t.map((e=>u.filter((t=>t.id===e.id)))).flat()})})).map((e=>S({},e,{roleIds:e.roles.map((e=>e.id))}))),g=await a.mapUsersWithApplicationData({shouldLoadApps:y,users:d,retryConfig:v});a.setTeamState({users:g,totalPages:n,totalItems:r,roles:l,permissions:c}),null==p||p(e)}catch(e){console.error("Failed to load users",e),n.setTeamError({key:Us.USERS,value:Bn(e)}),n.setTeamState({totalPages:0,users:[]}),null==p||p(null,e)}n.setTeamLoader({key:Us.USERS,value:!1})},addUser:async s=>{const{callback:i,appIds:o}=s,r=f(s,Ml),l=e.auth.teamState;n.setTeamState({addUserDialogState:S({},l.addUserDialogState,{loading:!0})});try{var c;const e=await t.teams.addUser(r),{roles:s}=e,u=S({},f(e,Fl),{roleIds:null!=(c=null==s?void 0:s.map((e=>e.id)))?c:[]}),d=await a.assignNewUserToApps({appIds:o,user:u});d&&(u.applications=d),null==i||i(u),n.setTeamState({users:[u,...l.users],addUserDialogState:{open:!1,loading:!1}})}catch(e){console.error("Failed to add user",e),n.setTeamState({addUserDialogState:S({},l.addUserDialogState,{loading:!1,error:Bn(e)})}),null==i||i(null,e)}},addUsersBulk:async a=>{const{callback:s}=a,i=e.auth.teamState;n.setTeamState({addUserDialogState:S({},i.addUserDialogState,{loading:!0})});const o=[],r=[],l=a.emails.map((e=>S({email:e,roleIds:a.roleIds},a.expirationInSeconds&&{expirationInSeconds:a.expirationInSeconds})));n.setTeamState({addUserDialogState:{open:!0,loading:!0}});for(let e=0;e<l.length;e++){const a=l.at(e);try{await t.teams.addUser(a),o.push(a.email)}catch(e){r.push(a.email)}}const c={pageOffset:0,pageSize:10,filter:"",silentLoading:a.emails.length>0};await n.loadUsersV2(c),n.setTeamState({addUserDialogState:{loading:!1}}),null==s||s({unallowedEmails:r,allowedEmails:o})},updateUser:async a=>{const{callback:s}=a,i=f(a,xl),{id:o}=i,r=e.auth.teamState,l=r.users.find((e=>e.id===i.id));if(void 0!==l){n.setTeamLoader({key:Us.UPDATE_USER,value:o||""}),n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!0})}),n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!0}),users:r.users.map((e=>e.id===i.id?S({},e,i):e))});try{var c;l.roleIds.length>0&&0===(null==(c=i.roleIds)?void 0:c.length)&&(i.roleIds=[""]);const{item:e}=await t.teams.updateUser(i);null==s||s(e),n.setTeamState({users:r.users.map((t=>t.id===e.id?S({},t,e,{groups:t.groups,createdAt:t.createdAt,customData:t.customData,lastLogin:t.lastLogin}):t))}),n.setTeamLoader({key:Us.UPDATE_USER,value:!1})}catch(e){n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!1,error:Bn(e)}),users:r.users.map((e=>e.id===i.id?S({},e,l):e))}),n.setTeamLoader({key:Us.UPDATE_USER,value:!1}),null==s||s(null,e)}}else null==s||s(null,"User not in state")},deleteUser:async a=>{const{callback:s}=a,i=f(a,$l),o=e.auth.teamState;n.setTeamState({deleteUserDialogState:S({},o.deleteUserDialogState,{loading:!0})});try{await t.teams.deleteUser(i),null==s||s(!0),n.setTeamState({users:o.users.filter((e=>e.id!==i.userId)),deleteUserDialogState:{open:!1,loading:!1}})}catch(e){n.setTeamState({deleteUserDialogState:S({},o.deleteUserDialogState,{loading:!1,error:Bn(e)})}),null==s||s(null,e)}},enableUser:async a=>{const{callback:s,userId:i}=a,o=e.auth.teamState;n.setTeamState({enableUserDialogState:S({},o.enableUserDialogState,{loading:!0})});try{await t.teams.enableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((e=>e.id===i?S({},e,{isDisabled:!1}):e)),enableUserDialogState:{open:!1,loading:!1}})}catch(e){n.setTeamState({enableUserDialogState:S({},o.enableUserDialogState,{loading:!1,error:Bn(e)})}),null==s||s(null,e)}},disableUser:async a=>{const{callback:s,userId:i}=a,o=e.auth.teamState;n.setTeamState({disableUserDialogState:S({},o.disableUserDialogState,{loading:!0})});try{await t.teams.disableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((e=>e.id===i?S({},e,{isDisabled:!0}):e)),disableUserDialogState:{open:!1,loading:!1}})}catch(e){n.setTeamState({disableUserDialogState:S({},o.disableUserDialogState,{loading:!1,error:Bn(e)})}),null==s||s(null,e)}},getTemporaryUsersConfig:async e=>{n.setTeamError({key:Us.CONFIG_TEMPORARY_USERS,value:!1});try{const a=await Cn((()=>t.teams.getTemporaryUserConfiguration()),null==e?void 0:e.retryConfig);n.setTeamState({temporaryUsersConfig:a})}catch(e){n.setTeamError({key:Us.CONFIG_TEMPORARY_USERS,value:Bn(e)})}},updateUserExpirationTime:async a=>{const{callback:s}=a,i=f(a,Gl),o=e.auth.teamState;n.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!0});try{const e=await t.teams.updateUserExpirationTime(i);n.setTeamState({users:o.users.map((t=>t.id===i.userId?S({},t,{temporaryExpirationDate:new Date(e.temporaryExpirationDate)}):t))}),null==s||s(!0)}catch(e){n.setTeamError({key:Us.UPDATE_USER_EXPIRATION_TIME,value:Bn(e)}),null==s||s(null,e)}finally{n.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!1})}},setUserAsPermanent:async a=>{const{callback:s}=a,i=f(a,jl),o=e.auth.teamState;n.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!0});try{await t.teams.setPermanentUser(i.userId),n.setTeamState({users:o.users.map((e=>e.id===i.userId?S({},e,{temporaryExpirationDate:void 0}):e))}),null==s||s(!0)}catch(e){n.setTeamError({key:Us.UPDATE_USER_EXPIRATION_TIME,value:Bn(e)}),null==s||s(null,e)}finally{n.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!1})}}}})(e,t,a),((e,t,a)=>{const n=a;return{loadAllSubTenantsUsers:async a=>{var s,i,o,r,l;const{silentLoading:c,callback:u}=a,d=e.auth.teamState.allUsersQueryParams,g={_limit:(null!=(s=a._limit)?s:d._limit)||20,_offset:(null!=(i=a._offset)?i:d._offset)||0,_filter:(null!=(o=a._filter)?o:d._filter)||"",_sortBy:(null!=(r=a._sortBy)?r:d._sortBy)||"name",_order:(null!=(l=a._order)?l:d._order)||"DESC"};n.setTeamLoader({key:Us.USERS,value:!c}),n.setTeamState({allUsersQueryParams:g,pageOffset:g._offset});try{const[{items:e,_metadata:{totalPages:a,totalItems:s}},{items:i},{items:o}]=await Promise.all([t.subTenants.loadAllUsers(S({},g)),t.teams.loadAvailableRoles(),t.teams.loadAvailablePermissions()]);n.setTeamState({allUsers:e,totalPages:a,totalItems:s,roles:i,permissions:o}),null==u||u(e)}catch(e){n.setTeamError({key:Us.USERS,value:Bn(e)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,e)}n.setTeamLoader({key:Us.USERS,value:!1})},setUserRolesForSubTenants:async a=>{const{callback:s,userId:i}=a,o=f(a,Bl),r=e.auth.teamState;n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!0})});try{await t.subTenants.setUserRolesForSubTenants(i,o);const e=r.allUsers.find((e=>e.id===i));let a=[];e&&(a=e.tenants.map((e=>{var t;return S({},e,{roles:(null==(t=o.subTenantsRoles.find((t=>t.tenantId===e.tenantId)))?void 0:t.roleIds.map((e=>r.roles.find((({id:t})=>e===t)))).filter((e=>e)))||e.roles})}))),n.setTeamState({allUsers:[...r.allUsers.filter((e=>e.id!==i)),...e?[S({},e,{tenants:a})]:[]],addUserDialogState:{open:!1,loading:!1}}),null==s||s(!0)}catch(e){n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!1,error:Bn(e)})}),null==s||s(null,e)}},deleteUserFromSubTenants:async a=>{const{callback:s}=a,i=f(a,Vl),o=e.auth.teamState;n.setTeamState({deleteUserDialogState:S({},o.deleteUserDialogState,{loading:!0})});try{await t.subTenants.removeUserFromTenantAndSubTenants(i),null==s||s(!0),n.setTeamState({allUsers:o.allUsers.filter((e=>e.id!==i.userId&&e.tenants.length===i.subTenants.length)),deleteUserDialogState:{open:!1,loading:!1}})}catch(e){n.setTeamState({deleteUserDialogState:S({},o.deleteUserDialogState,{loading:!1,error:Bn(e)})}),null==s||s(null,e)}},addUserToSubTenants:async a=>{const{callback:s}=a,i=f(a,Wl),o=e.auth.teamState;n.setTeamState({addUserDialogState:S({},o.addUserDialogState,{loading:!0})});try{await t.subTenants.addUserToTenantAndSubTenants(i);const{items:e,_metadata:{totalPages:a,totalItems:o}}=await t.subTenants.loadAllUsers({_limit:20,_offset:0,_filter:"",_sortBy:"name",_order:"DESC"});n.setTeamState({allUsers:e,totalPages:a,totalItems:o,addUserDialogState:{open:!1,loading:!1}}),null==s||s(null)}catch(e){n.setTeamState({addUserDialogState:S({},o.addUserDialogState,{loading:!1,error:Bn(e)})}),null==s||s(null,e)}}}})(e,t,a),((e,t,a)=>{const n=a,s=async(e,t,a,s)=>{n.setTeamLoader({key:e,value:t});try{await s()}catch(t){n.setTeamError({key:e,value:Bn(t)}),null==a||a(null,t)}finally{n.setTeamLoader({key:e,value:!1})}};return{resendActivationLink:async e=>{const{callback:a}=e,n=f(e,Hl);await s(Us.RESEND_ACTIVATE_LINK,n.userId,a,(async()=>{await t.teams.resendActivationLink(n),null==a||a(!0)}))},resendInvitationLink:async e=>{const{callback:a}=e,n=f(e,zl);await s(Us.RESEND_INVITATION_LINK,n.email,a,(async()=>{await t.teams.resendInvitationLink(n),null==a||a(!0)}))},resendInvitationEmail:async e=>{const{callback:a}=e,n=f(e,Kl);await s(Us.RESEND_INVITATION_LINK,a,n.email,(async()=>{await t.auth.resendInvitationEmail(n),null==a||a(!0)}))},resendInvitationLinkToAllSubTenants:async e=>{const{callback:a}=e,n=f(e,ql);await s(Us.RESEND_INVITATION_LINK,n.email,a,(async()=>{await t.teams.resendInvitationLinkToAllTenants(n),null==a||a(!0)}))}}})(0,t,a),((e,t,a)=>{const n=a;return{getInvitationLink:async a=>{n.setTeamError({key:Us.GET_TOKEN_LINK,value:!1});try{const s=null==a?void 0:a.retryConfig;await(async e=>{n.setTeamError({key:Us.CONFIG_TOKEN_LINK,value:!1});try{const a=await Cn((()=>t.teams.getInviteLinkConfiguration()),e);n.setTeamState({inviteTokenState:S({},a)})}catch(e){n.setTeamError({key:Us.CONFIG_TOKEN_LINK,value:Bn(e)})}})(s);const i=await Cn((()=>t.teams.getInviteUserLink()),s),{inviteTokenState:o}=e.auth.teamState;n.setTeamState({inviteTokenState:S({},o,i)})}catch(e){n.setTeamError({key:Us.GET_TOKEN_LINK,value:Bn(e)})}},createInvitationLink:async a=>{const{callback:s}=a;n.setTeamError({key:Us.CREATE_TOKEN_LINK,value:!1});const{inviteTokenState:i}=e.auth.teamState;try{const e=await t.teams.createInviteUserLink({expiresInMinutes:43200});n.setTeamState({inviteTokenState:S({},i,e)}),null==s||s(e.token)}catch(e){null==s||s(null,e),n.setTeamError({key:Us.CREATE_TOKEN_LINK,value:Bn(e)})}},updateInvitationLink:async a=>{const{callback:s,expiresInMinutes:i,shouldSendEmail:o}=a;n.setTeamError({key:Us.UPDATE_TOKEN_LINK,value:!1});try{const{inviteTokenState:a}=e.auth.teamState,r=await t.teams.updateInviteUserLink({expiresInMinutes:i,shouldSendEmail:o});n.setTeamState({inviteTokenState:S({},a,r)}),null==s||s(!0)}catch(e){null==s||s(null,e),n.setTeamError({key:Us.UPDATE_TOKEN_LINK,value:Bn(e)})}},deleteInvitationLink:async e=>{const{callback:a}=null!=e?e:{};n.setTeamError({key:Us.DELETE_TOKEN_LINK,value:!1});try{await t.teams.deleteInviteUserLink(),n.setTeamState({inviteTokenState:void 0}),null==a||a(!0)}catch(e){n.setTeamError({key:Us.DELETE_TOKEN_LINK,value:Bn(e)}),null==a||a(!1,e)}}}})(e,t,a))},Yl={tenants:[],subTenants:[],switchingTenant:!1,loading:!0,tenantTree:null},Xl=e=>cn(Yl,e),Ql=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auth.tenantsState,t)};return{setTenantsState:s,resetTenantsState:()=>{$n(e,["auth","tenantsState"],Yl)},switchTenant:async a=>{const{tenantId:s,silentReload:i,callback:o}=a;i?n.setTenantsState({switchingTenant:!0}):n.setAuthState({isLoading:!0});try{await t.tenants.switchTenant({tenantId:s}),i&&n.resetAuthState({isLoading:!1,isAuthenticated:!0,user:e.auth.user}),await n.__refreshToken(),(null==o?void 0:o(!0))||(i?n.setTenantsState({switchingTenant:!1}):n.setAuthState({isLoading:!1}))}catch(e){i?n.setTenantsState({switchingTenant:!1}):n.setAuthState({isLoading:!1}),null==o||o(!1,e)}},loadTenants:async t=>{s({loading:!0});try{var a;const n=gt(e.root.appName),i=await n();s({tenants:i.tenants,activeTenant:i.activeTenant,loading:!1}),null==t||null==(a=t.callback)||a.call(t,[])}catch(e){var n;null==t||null==(n=t.callback)||n.call(t,[],e),s({loading:!1})}},loadSubTenants:async e=>{s({loading:!0});try{var a;const n=await retryIfNeeded((()=>t.tenants.getSubTenants()),null==e?void 0:e.retryConfig);s({subTenants:n,loading:!1}),null==e||null==(a=e.callback)||a.call(e,!0)}catch(t){var n;s({loading:!1}),null==e||null==(n=e.callback)||n.call(e,null,t)}},loadSubTenantsTree:async e=>{s({loading:!0});try{var a;const n=await t.tenants.getSubTenantsAsTree();s({tenantTree:n,loading:!1}),null==e||null==(a=e.callback)||a.call(e,!0)}catch(t){var n;s({loading:!1}),null==e||null==(n=e.callback)||n.call(e,null,t)}}}},Zl={loading:!1,error:null,username:void 0,fetching:!0},ec=e=>cn(Zl,e),tc=(e,t,a)=>{const n=t=>{Object.assign(e.auth.usernamesState,t)},s=async e=>{n({loading:!0});try{await t.usernames.deleteUsername(e),n({username:void 0,loading:!1})}catch(e){n({error:Bn(e)})}finally{n({loading:!1})}};return{resetUsernamesState:()=>{$n(e,["auth","usernamesState"],Zl)},loadUserOwnUsername:async()=>{n({loading:!0});try{const e=await t.usernames.getUserOwnUsername();n({username:null==e?void 0:e.username,loading:!1,fetching:!1})}catch(e){n({error:Bn(e),fetching:!1})}finally{n({loading:!1,fetching:!1})}},saveUserUsername:async a=>{n({loading:!0});try{var i,o,r;if(e.auth.usernamesState.username===a.username)return void(null==(i=a.callback)||i.call(a));if(e.auth.usernamesState.username&&e.auth.usernamesState.username!==a.username&&(await s(e.auth.usernamesState.username),!a.username))return n({username:void 0,loading:!1}),void(null==(o=a.callback)||o.call(a));a.username&&(await t.usernames.createUsername(a),n({username:a.username,loading:!1}),null==(r=a.callback)||r.call(a))}catch(e){n({error:Bn(e)})}finally{n({loading:!1})}},deleteUserUsername:s}},ac={userEmailPolicyConfig:null,loading:!1},nc=e=>cn(ac,e),sc=(e,t,a)=>{const n=t=>{Object.assign(e.auth.userEmailPolicyState,t)};return{loadUserEmailPolicyState:async()=>{n({loading:!0});try{const e=await t.userEmailPolicy.getUserEmailPolicyConfig();n({loading:!1,userEmailPolicyConfig:e})}catch(e){n({loading:!1,error:Bn(e)})}},setUserEmailPolicyState:n}},ic=(e,t,a)=>{const n=t=>{e.auth.user&&(e.auth.user.entitlements=t)},s=t=>{var a;go(null==(a=e.auth.user)?void 0:a.entitlements,t)||n(t)};return{setEntitlements:n,handleFetchedEntitlements:s,loadEntitlements:async e=>{const a=null==e?void 0:e.callback;try{const e=await t.entitlements.loadEntitlementsV2();s(e),null==a||a(!0)}catch(e){null==a||a(!1)}}}};let oc;!function(e){e[e.Email=0]="Email",e[e.Otc=1]="Otc",e[e.Success=2]="Success"}(oc||(oc={}));const rc=["routes"],lc=["requestName"],cc=e=>{const t=null!=e?e:{},{routes:a}=t,n=f(t,rc);return cn(S({routes:S({},On,a),onRedirectTo:()=>{},isAuthenticated:!1,isLoading:!0,isSSOAuth:!1,user:null,error:void 0,errorByRequest:{},userIp:void 0,userIpData:{loading:!1}},n,{acceptInvitationState:gn(null==n?void 0:n.acceptInvitationState),accountSettingsState:Hn(null==n?void 0:n.accountSettingsState),activateAccountState:Yn(null==n?void 0:n.activateAccountState),unlockAccountState:Gs(null==n?void 0:n.unlockAccountState),apiTokensState:Vs(null==n?void 0:n.apiTokensState),applicationsState:Ks(null==n?void 0:n.applicationsState),customLoginState:Xs(null==n?void 0:n.customLoginState),forgotPasswordState:ai(null==n?void 0:n.forgotPasswordState),passwordRotationState:ri(null==n?void 0:n.passwordRotationState),groupsState:ui(null==n?void 0:n.groupsState),groupsDialogsState:vi(null==n?void 0:n.groupsDialogsState),impersonateState:bi(null==n?void 0:n.impersonateState),loginState:Ei(null==n?void 0:n.loginState),mfaState:Lo(null==n?void 0:n.mfaState),allAccountsState:Vo(null==n?void 0:n.allAccountsState),allAccountsDialogsState:Ho(null==n?void 0:n.allAccountsDialogsState),passkeysState:ar(null==n?void 0:n.passkeysState),profileState:ir(null==n?void 0:n.profileState),provisioningState:cr(null==n?void 0:n.provisioningState),resetPhoneNumberState:yr(null==n?void 0:n.resetPhoneNumberState),rolesState:Ar(null==n?void 0:n.rolesState),restrictionsState:Rr(null==n?void 0:n.restrictionsState),securityCenterState:xr(null==n?void 0:n.securityCenterState),securityPolicyState:Vr(null==n?void 0:n.securityPolicyState),sessionsPolicyState:Xr(null==n?void 0:n.sessionsPolicyState),sessionsState:tl(null==n?void 0:n.sessionsState),signUpState:il(null==n?void 0:n.signUpState),smsState:ul(null==n?void 0:n.smsState),socialLoginState:ml(null==n?void 0:n.socialLoginState),ssoState:El(null==n?void 0:n.ssoState),stepUpState:Ll(null==n?void 0:n.stepUpState),teamState:Nl(null==n?void 0:n.teamState),tenantsState:Xl(null==n?void 0:n.tenantsState),usernamesState:ec(null==n?void 0:n.usernamesState),userEmailPolicyState:nc(null==n?void 0:n.userEmailPolicyState)}))},uc=(e,t,a,n)=>{const s=t=>{Object.keys(t).forEach((a=>{const n=a;Fn(e.auth[n])?Object.assign(e.auth[n],t[n]):e.auth[n]=t[n]}))},i={acceptInvitationActions:Vn(e,t),accountSettingsActions:Kn(e,t,a),activateAccountActions:xs(e,t,a),unlockAccountActions:js(e,t),apiTokensActions:Hs(e,t),applicationsActions:Js(e,t,a),customLoginActions:Zs(e,t,a),entitlementsActions:ic(e,t),forgotPasswordActions:si(e,t),passwordRotationActions:li(e),groupsActions:hi(e,t),groupsDialogsActions:Si(e),impersonateActions:wi(e,t,a),loginActions:Uo(e,t,a),mfaActions:jo(e,t,a),allAccountsActions:Zo(e,t,a),allAccountsDialogActions:er(e),passkeysActions:nr(e,t,a),profileActions:rr(e,t,a),provisioningActions:gr(e,t),resetPhoneNumberActions:mr(e,t,a),rolesActions:_r(e,t),restrictionsActions:Mr(e,t,a),securityCenterActions:jr(e,t,a),securityPolicyActions:Jr(e,t,a),sessionsPolicyActions:Zr(e,t,a),sessionsActions:al(e,t),signUpActions:ll(e,t,a),smsActions:Sl(e,t),socialLoginActions:wl(e,t,a),ssoActions:Ul(e,t,a),stepUpActions:Cl(e,t,a),teamActions:Jl(e,t,a),tenantsActions:Ql(e,t,a),usernamesActions:tc(e,t),usersEmailsPolicyActions:sc(e,t)};return[S({setAuthState:s,setErrorByRequestName:t=>{let{requestName:a}=t,n=f(t,lc);e.auth.errorByRequest=S({},e.auth.errorByRequest,{[a]:S({},n,{isError:!0})})},setState:s,resetAuthState:(t={})=>{$n(e,["auth"],S({},n,t))},setUser:e=>{s({user:e})}},Object.values(i).reduce(((e,t)=>S({},e,t)),{})),i]},dc={isLoading:!1,isSaving:!1,list:[],processIds:[],slackChannels:{isLoading:!1}},gc=e=>cn(dc,e),pc=["email","slack","sms","webhook"],hc={sms:{title:"connectivity.sms",events:e=>(null==e?void 0:e.length)||0,isActive:e=>{var t;return null!=(t=null==e?void 0:e.some((({enabled:e})=>e)))&&t},image:"sms"},email:{title:"common.email",events:e=>(null==e?void 0:e.length)||0,isActive:e=>{var t;return null!=(t=null==e?void 0:e.some((({enabled:e})=>e)))&&t},image:"email"},slack:{title:"connectivity.slack",events:e=>{var t;return(null==e||null==(t=e.slackSubscriptions)?void 0:t.length)||0},isActive:e=>!(null==e||!e.slackSubscriptions.some((({isActive:e})=>e))),image:"slack"},webhook:{title:"connectivity.webhook",events:e=>(null==e?void 0:e.length)||0,isActive:e=>{var t;return null!=(t=null==e?void 0:e.some((({isActive:e})=>e)))&&t},image:"webhook"}},yc=["id"],vc=["id","enabled"],Sc=(e,t,a)=>{const n={slack:t.connectivity.getSlackConfiguration,email:t.connectivity.getEmailConfiguration,sms:t.connectivity.getSMSConfiguration,webhook:t.connectivity.getWebhooksConfigurations,categories:t.connectivity.getCategories,channelMap:t.connectivity.getChannelMaps},s=["categories","channelMap"],i={slack:t.connectivity.postSlackConfiguration,email:t.connectivity.postEmailConfiguration,sms:t.connectivity.postSMSConfiguration,webhook:t.connectivity.postWebhooksConfiguration},o=t=>{Object.assign(e.connectivity,t)},r=t=>{var a;const n=null!=(a=e.connectivity.retryResult)?a:{};e.connectivity.retryResult=S({},n,t)},l=()=>{$n(e,["connectivity"],dc)},c=async(e,t,a)=>{try{return await Cn((()=>n[e](t)),a)}catch(e){return}},u=async()=>{try{o({slackChannels:{isLoading:!0}});const e=await t.connectivity.getSlackChannels();o({error:void 0,slackChannels:{isLoading:!1,data:e}})}catch(e){o({error:void 0,slackChannels:{isLoading:!1}})}},d=async e=>{const t=null!=e?e:pc;o({isLoading:!0});try{const e=await Promise.all([...t.map((e=>c(e,void 0,Un))),c("categories",void 0,Un),(async()=>(await Promise.all(t.map((e=>c("channelMap",e,Un))))).reduce(((e,a,n)=>S({},e,{[`${t[n]}`]:a})),{}))()]),a=await c("webhook",void 0,Un),n=e.reduce(((a,n,i)=>t[i]?e[e.length-1][t[i]].length?S({},a,{[`${t[i]}`]:n,list:[...a.list,{id:i,key:t[i],events:hc[t[i]].events(n),active:hc[t[i]].isActive(n),platform:hc[t[i]].title,image:hc[t[i]].image}]}):a:S({},a,{[`${s[i-t.length]}`]:n})),{list:[],webhook:a});o(S({},n,{error:void 0,isSaving:!1,isLoading:!1}))}catch(e){o({isLoading:!1,error:Bn(e)})}},g=async(t,a)=>{const{list:n}=e.connectivity,s=n.find((({key:e})=>e===t));if(!s)return;const i=hc[t].isActive(a);i!==s.active&&o({list:n.map((e=>e.key===t?S({},e,{active:i}):e))})},p=async a=>{const{platform:n,data:s,callback:r}=a,l=e.connectivity.processIds;try{if(o({isSaving:!0,processIds:"webhook"===n?[s._id,...l]:l}),"slack"===n?await(async a=>{var n;const s=null==(n=e.connectivity.slack)?void 0:n.slackSubscriptions;if(!s)return;const{slackSubscriptions:o}=a;await Promise.all([...o.reduce(((e,t)=>{var a,n;return!t.id&&t.slackEvents&&null!=(a=t.slackEvents[0].channelIds)&&a.length||(null==s?void 0:s.find((e=>{let{id:a}=e,n=f(e,yc);return a===t.id&&JSON.stringify(S({id:a},n))!==JSON.stringify(t)})))&&t.slackEvents&&null!=(n=t.slackEvents[0].channelIds)&&n.length?[...e,t]:e}),[]).map((e=>i.slack(e))),...o.reduce(((e,t)=>t.id&&!t.slackEvents[0].channelIds.length?[...e,t]:e),[]).map((e=>t.connectivity.deleteSlackConfiguration(e)))])})(s):["sms","email"].includes(n)?await(async(a,n)=>{const s=e.connectivity.processIds,i=e.connectivity[n];if(!i)return;let r=[];try{r=await Promise.all([...a.reduce(((e,t)=>!i.find((({eventKey:e})=>e===t.eventKey))&&t.subscriptions[0].recipients.filter((e=>e)).length?[...e,t]:e),[]).map((e=>"email"===n?t.connectivity.postEmailConfiguration(e):t.connectivity.postSMSConfiguration(e))),...a.reduce(((e,t)=>{const a=i.find((({eventKey:e})=>e===t.eventKey));return a&&JSON.stringify(a)!==JSON.stringify(t)?[...e,t]:e}),[]).map((e=>{const{subscriptions:a,eventKey:s}=e,i=a[0],{id:o="",enabled:r}=i,l=f(i,vc);return Promise.all(["email"===n?t.connectivity.patchEmailConfiguration({eventKey:s,enabled:r}):t.connectivity.patchSMSConfiguration({eventKey:s,enabled:r}),"email"===n?t.connectivity.putEmailSubscriptions(o,s,S({},l,{enabled:r})):t.connectivity.putSMSSubscriptions(o,s,S({},l,{enabled:r}))])})),...a.reduce(((e,t)=>{const a=i.find((({eventKey:e})=>e===t.eventKey));return a&&a.subscriptions[0].recipients.length&&!t.subscriptions[0].recipients.filter((e=>!!e)).length?[...e,t]:e}),[]).map((({eventKey:e,subscriptions:a})=>"email"===n?t.connectivity.deleteEmailSubscriptions(e,a[0].id||""):t.connectivity.deleteSMSSubscriptions(e,a[0].id||"")))])}catch{}if(r.length){const e=await c(n);o({error:void 0,isSaving:!1,[`${n}`]:e,processIds:e.id?s.filter((t=>t!==e.id)):s}),await g(n,e)}else o({error:void 0,isSaving:!1,[`${n}`]:i,processIds:s})})(s,n):await i[n](s),!["sms","email"].includes(n)){const e=await c(n);"webhook"===n&&(e.id=s._id),o({error:void 0,isSaving:!1,[`${n}`]:e,processIds:e.id?l.filter((t=>t!==e.id)):l}),await g(n,e),null==r||r(!0)}}catch(e){o({error:Bn(e),isSaving:!1,isLoading:!1})}},h=async e=>{try{await t.connectivity.postSlackCode(e)}catch{}o({error:void 0,isSaving:!1})},y=async()=>{const a=e.connectivity.slackChannels;try{o({slackChannels:S({},a,{isLoadingScope:!0})});const{clientId:e}=await t.connectivity.getSlackScope();o({slackChannels:{error:void 0,clientId:e,isLoadingScope:!1,isLoading:!1}})}catch{o({slackChannels:{error:void 0,isLoadingScope:!1,isLoading:!1}})}},v=async a=>{const{callback:n,webhookId:s}=a,i=e.connectivity.processIds;try{o({isSaving:!0}),await t.connectivity.deleteWebhooksConfiguration(s)}catch(e){null==n||n(null,Bn(e))}const r=await c("webhook");r&&o({error:void 0,isSaving:!1,webhook:r,processIds:r.id?i.filter((e=>e!==r.id)):i}),null==n||n(!0)},m=async e=>{try{o({isTesting:!0});const{statusCode:a,body:n}=await t.connectivity.postWebhookTest(e);if([201,200].includes(a)){const e=JSON.stringify(n,null,2);o({isTesting:!1,testResult:{status:"success",message:e}})}else o({isTesting:!1,testResult:{status:"failed"}})}catch(e){o({isTesting:!1,testResult:{status:"failed",message:Bn(e)}})}},b=async e=>{try{const{statusCode:a}=await t.connectivity.postWebhookRetry(e);r({[e]:{isProcess:!1,success:202===a}})}catch(t){r({[e]:{isProcess:!1,success:!1}})}},A=async a=>{const{id:n,limit:s,offset:i}=a,r=e.connectivity.webhookLogs;try{o({webhookLogs:S({},r,{isLoading:!0})});const e=await t.connectivity.getWebhookLog(n,i,s);o({error:void 0,webhookLogs:S({isLoading:!1},e)})}catch(e){o({error:void 0,webhookLogs:{isLoading:!1}})}};return{setConnectivityState:o,initData:l,resetConnectivityState:l,loadSlackActions:u,loadSlackChannels:u,loadDataAction:d,loadConnectivityChannels:d,postDataAction:p,postChannelData:p,postCodeAction:h,postSlackCode:h,loadScope:y,loadSlackPermissions:y,deleteWebhookConfigAction:v,deleteWebhookConfig:v,postWebhookTestAction:m,postWebhookTest:m,postWebhookRetryAction:b,postWebhookRetry:b,loadWebhookLogsAction:A,loadWebhookLogs:A,cleanWebhookTestData:()=>{o({testResult:void 0})},cleanWebhookLogsData:async()=>{o({webhookLogs:void 0})},cleanWebhookTestMessage:async e=>{var t;o({testResult:{status:null==(t=e.testResult)?void 0:t.status,message:void 0}})},cleanError:async()=>{o({error:void 0})},cleanSlackData:async()=>{o({slackChannels:{isLoading:!1}})}}};let fc;!function(e){e.UNKNWON="unknown",e.CARD="card"}(fc||(fc={}));const mc={loading:!1,error:null,fetching:!0,config:null},bc=e=>cn(mc,e);let Ac,wc,Tc;!function(e){e.STRIPE="Stripe"}(Ac||(Ac={})),function(e){e.ACTIVE="ACTIVE",e.CANCELED="CANCELED",e.INCOMPLETE="INCOMPLETE",e.EXPIRED="EXPIRED",e.TRIALING="TRIALING"}(wc||(wc={})),function(e){e.AT_PERIOD_END="atPeriodEnd"}(Tc||(Tc={}));const Ec=(e,t,a)=>{const n=t=>{Object.assign(e.subscriptions.config,t)},s=t=>{Object.assign(e.subscriptions.config,{error:t,loading:!1,fetching:!1})};return{setPaymentConfigState:n,resetPaymentConfigState:()=>{$n(e,["subscriptions","config"],mc)},loadPaymentConfiguration:async()=>{n({loading:!0});try{var e;(null!=(e=await t.subscriptions.getPaymentProviders())?e:[]).find((e=>"1"===e.status&&e.providerType===V.Stripe))?await(async()=>{n({loading:!0});try{const e=await t.subscriptions.getStripePaymentProviderConfiguration(),a={paymentProvider:Ac.STRIPE,apiKey:e.publishableKey};n({config:a}),n({loading:!1,fetching:!1})}catch(e){s(Bn(e))}})():s(Bn("Payment provider not configured"))}catch(e){s(Bn(e))}}}},Pc={loading:!1,error:null,fetching:!0},Ic=e=>cn(Pc,e);function Oc({policy:e}){return{policy:Tc.AT_PERIOD_END}}function kc(e){switch(e){case G.ACTIVE:return wc.ACTIVE;case G.INCOMPLETE:return wc.INCOMPLETE;case G.CANCELED:return wc.CANCELED;case G.EXPIRED:return wc.EXPIRED;case G.TRIALING:return wc.TRIALING;default:return wc.EXPIRED}}const _c=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.subscriptions.billing.information,t)},i=e=>{s({error:e,loading:!1,fetching:!1})},o=async(a,o)=>{s({loading:!0});try{var r,l;const i=await t.subscriptions.getSubscriptionSummaries(a),{currentPlanId:c,externallyManaged:u}=i;let d,g=null;u?d=await t.subscriptions.getSubscriptionPlan(c):([,d]=await Promise.all([n.loadSubscription(),t.subscriptions.getSubscriptionPlan(c)]),g=e.subscriptions.billing.subscription.subscription||null),s(S({loading:!1,fetching:!1,summary:i},g?{subscription:{id:g.id,externalId:g.externalId,startDate:g.startDate,currentPeriodStart:g.currentPeriodStart,currentPeriodEnd:g.currentPeriodEnd,status:o?wc.ACTIVE:kc(g.status),cancellation:g.cancellation&&Oc(g.cancellation),trialEnd:g.trialEnd?g.trialEnd:null}}:{},d?{plan:{id:d.id,name:d.name,description:d.description,price:(null==(r=d.price)?void 0:r.amount)||0,currency:(null==(l=d.price)?void 0:l.currency)||"usd",recurringInterval:"month",slug:d.slug}}:{}))}catch(e){i(Bn(e))}};return{setBillingInformationState:s,resetBillingInformationState:()=>{$n(e,["subscriptions","billing","information"],Pc)},loadSummaries:o,loadBillingInformation:async t=>{var a,n;const s=null==(a=e.subscriptions.config.config)?void 0:a.paymentProvider,r=null==(n=e.auth.user)?void 0:n.tenantId;s&&r?await o(r,t):i(new z(s?"Not authorized":"Internal feature failure",500,null))}}},Uc={loading:!1,error:null,fetching:!0,invoices:[],invoiceDownload:{loading:!1,error:null}},Rc=e=>cn(Uc,e),Lc=(e,t,a)=>{const n=t=>{Object.assign(e.subscriptions.billing.invoices,t)},s=t=>{Object.assign(e.subscriptions.billing.invoices.invoiceDownload,t)},i=async()=>{n({loading:!0});try{const e=(await t.subscriptions.getSubscriptionInvoices()).map((e=>({id:e.id,externalId:e.externalId,subscriptionId:e.subscriptionId,paymentDate:new Date(Date.parse(e.paymentDate)),totalAmount:+((e.totalAmount||0)/100).toFixed(2),currency:e.currency||"usd",paid:e.paid||!1,receiptNumber:e.receiptNumber})));n({loading:!1,fetching:!1,invoices:e})}catch(t){e=Bn(t),n({error:e,loading:!1,fetching:!1})}var e},o=async e=>{s({loading:!0,error:null});try{await t.subscriptions.getSubscriptionInvoicePdf(e.invoiceId,e.filename),s({loading:!1,error:null})}catch(e){s({loading:!1,error:Bn(e,null)})}};return{setBillingInvoiceState:n,resetBillingInvoiceState:()=>{$n(e,["subscriptions","billing","invoices"],Uc)},loadInvoices:i,loadBillingInvoices:i,downloadInvoice:o,downloadBillingInvoice:o}},Cc={loading:!1,error:null,fetching:!0},Dc=e=>cn(Cc,e),Nc=(e,t,a)=>{const n=t=>{Object.assign(e.subscriptions.billing.paymentMethod,t)},s=e=>{n({loading:e})},i=e=>{n({error:e,loading:!1,fetching:!1})},o=async()=>{s(!0);try{const e=(await t.subscriptions.getPaymentMethods())[0];n({paymentMethod:e,loading:!1,fetching:!1})}catch(e){i(Bn(e))}};return{setBillingPaymentMethodState:n,resetBillingPaymentMethodState:()=>{$n(e,["subscriptions","billing","paymentMethod"],Cc)},loadPaymentMethod:o,submitPaymentMethod:async()=>{s(!0)},submitPaymentMethodError:async e=>{i(e)},submitPaymentMethodSuccess:async()=>await o(),updatePaymentMethodBillingDetails:async e=>{s(!0);const{id:a,email:n,address:r,callback:l}=e;try{await t.subscriptions.updatePaymentMethodBillingDetails(a,S({email:n},r)),await o(),null==l||l(!0)}catch(e){i(Bn(e)),null==l||l(!1,e)}finally{s(!1)}}}},Mc={loading:!1,error:null,fetching:!0,cancellation:{loading:!1,error:null},renewal:{loading:!1,error:null}},Fc=e=>cn(Mc,e),xc=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.subscriptions.billing.subscription,t)},i=e=>{s({error:e,loading:!1,fetching:!1})},o=t=>{Object.assign(e.subscriptions.billing.subscription.cancellation,{loading:t})},r=t=>{Object.assign(e.subscriptions.billing.subscription.cancellation,{error:t})},l=t=>{Object.assign(e.subscriptions.billing.subscription.renewal,{loading:t})},c=t=>{Object.assign(e.subscriptions.billing.subscription.renewal,{error:t})},u=async()=>{s({loading:!0});try{const[e]=await t.subscriptions.getManagedSubscriptions();s({subscription:e,fetching:!1,loading:!1,error:null})}catch(e){i(Bn(e))}};return{setBillingSubscriptionState:s,resetBillingSubscriptionState:()=>{$n(e,["subscriptions","billing","subscription"],Mc)},setCancellationLoading:o,setCancellationError:r,setRenewalLoading:l,setRenewalError:c,loadSubscription:u,loadSubscriptionTenant:async()=>{var t;const a=null==(t=e.auth.user)?void 0:t.tenantId;a?await n.loadSummaries(a):i(new z("TenantId is not defined",500,null))},cancelSubscription:async()=>{const{subscription:a}=e.subscriptions.billing.subscription;if(!a)return void r(new z("Subscription not found",500,null));if(null!=a&&a.externallyManaged)return void r(new z("Billing is externally managed",500,null));const{id:n,cancellation:s,status:i}=a||{};if(!s&&i===G.ACTIVE)try{o(!0),await t.subscriptions.cancelManagedSubscription(n),await u(),o(!1)}catch(e){r(Bn(e))}},renewSubscription:async()=>{const{subscription:a}=e.subscriptions.billing.subscription;if(!a)return void c(new z("Subscription not found",500,null));if(null!=a&&a.externallyManaged)return void c(new z("Billing is externally managed",500,null));const{id:n,cancellation:s}=a||{};if((null==s?void 0:s.policy)===B.AT_PERIOD_END)try{l(!0),await t.subscriptions.renewManagedSubscription(n),await u(),l(!1)}catch(e){c(Bn(e))}}}},$c=e=>cn({information:Ic(null==e?void 0:e.information),invoices:Rc(null==e?void 0:e.invoices),paymentMethod:Dc(null==e?void 0:e.paymentMethod),subscription:Fc(null==e?void 0:e.subscription)}),Gc={loading:!1,error:null,fetching:!0,plans:[]},jc=e=>cn(Gc,e),Bc=(e,t,a)=>{const n=t=>{Object.assign(e.subscriptions.plans,t)};return{setPlansState:n,resetPlansState:()=>{$n(e,["subscriptions","plans"],Gc)},loadPlans:async()=>{n({loading:!0});try{const e=(await t.subscriptions.getSubscriptionPlans()).map((e=>{var t,a;return{id:e.id,name:e.name,description:e.description,price:(null==(t=e.price)?void 0:t.amount)||0,currency:(null==(a=e.price)?void 0:a.currency)||"usd",recurringInterval:"month",slug:e.slug}}));n({fetching:!1,loading:!1,plans:e})}catch(t){e=Bn(t),n({loading:!1,fetching:!1,error:e})}var e}}},Vc={fetching:!0,loading:!1,error:null,confirmed:!1},Wc=e=>cn(Vc,e),Hc=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.subscriptions.checkout,t)};return{setCheckoutState:s,resetCheckoutState:()=>{$n(e,["subscriptions","checkout"],Vc)},loadCheckout:()=>{s({fetching:!1,loading:!1,error:null,confirmed:!1})},resetCheckout:()=>{s({loading:!1,error:null,confirmed:!1})},submitCheckout:()=>{s({loading:!0,error:null})},confirmCheckout:async a=>{const{paymentMethodId:i,planId:o}=a,r=e.subscriptions.billing.subscription.subscription,l=e.subscriptions.billing.information.summary,c=(null==r?void 0:r.status)===G.TRIALING,u=!(null==l||!l.paymentMethodId);if(r){if(s({loading:!0,error:null}),c&&u)return s({loading:!1,error:null,confirmed:!0}),void n.setBillingSubscriptionState({subscription:S({},r,{status:G.ACTIVE})});try{await t.subscriptions.updateManagedSubscription(r.id,{paymentMethodId:i,planId:o}),await Promise.all([n.loadBillingInformation(),n.loadPaymentMethod(),n.loadInvoices()]),s({loading:!1,error:null,confirmed:!0})}catch(e){s({loading:!1,error:Bn(e)})}}else s({loading:!1,error:new z("Subscription not found",500,null)})},errorCheckout:e=>{s({loading:!1,error:e})}}},zc={loading:!1,error:null,cardSetupIntentSecret:null},Kc=e=>cn(zc,e),qc=(e,t,a)=>{const n=t=>{Object.assign(e.subscriptions.stripe,t)};return{createCardSetupIntentSecret:async a=>{n({loading:!0,error:null,cardSetupIntentSecret:null});try{const e={};a&&(e.paymentMethodId=a);const{setupIntentSecret:s}=await t.subscriptions.createStripePaymentMethodSetupIntentSecret(e);n({cardSetupIntentSecret:s,loading:!1})}catch(t){s=Bn(t),Object.assign(e.subscriptions.stripe,{error:s,loading:!1,fetching:!1})}var s},setStripeState:n,resetStripeState:()=>{$n(e,["subscriptions","stripe"],zc)}}},Jc={loading:!1,fetching:!0,vendorPublicConfig:null},Yc=e=>cn(Jc,e),Xc=(e,t,a)=>{const n=t=>{Object.assign(e.subscriptions.vendorPublicConfig,t)},s=t=>{Object.assign(e.subscriptions.vendorPublicConfig,{error:t,loading:!1,fetching:!1})},i=t=>{Object.assign(e.subscriptions.vendorPublicConfig,{error:null,loading:t})};return{setVendorPublicConfigState:n,resetVendorPublicConfigState:()=>{$n(e,["subscriptions","vendorPublicConfig"],Jc)},setVendorPublicConfigError:s,setVendorPublicConfigLoading:i,loadVendorPublicConfiguration:async()=>{i(!0);try{const e=await t.subscriptions.getVendorPublicConfigurations();n({fetching:!1,loading:!1,vendorPublicConfig:e})}catch(e){s(Bn(e))}}}},Qc=e=>cn({config:bc(null==e?void 0:e.config),billing:$c(null==e?void 0:e.billing),plans:jc(null==e?void 0:e.plans),checkout:Wc(null==e?void 0:e.checkout),stripe:Kc(null==e?void 0:e.stripe),vendorPublicConfig:Yc(null==e?void 0:e.vendorPublicConfig)}),Zc=(e,t,a)=>{const n=Ec(e,t),[s,i]=((e,t,a)=>{const n=_c(e,t,a),s=Nc(e,t),i=Lc(e,t),o=xc(e,t,a);return[S({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(e,t,a),o=Bc(e,t),r=Hc(e,t,a),l=qc(e,t),c=Xc(e,t);return[S({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},eu={loading:!1},tu=e=>cn(eu,e),au=(e,t,a)=>{const n=t=>{Object.assign(e.vendor,t)},s=async e=>{n({loading:!0});try{var a;const s=await Cn((()=>t.vendor.getVendorPublicInfo()),null==e?void 0:e.retryConfig);s.whiteLabelMode=null!=(a=s.whiteLabelMode)&&a,n(S({},s,{loading:!1}))}catch(e){n({loading:!1}),console.error("failed to getVendorPublicInfo - ",e)}};return{setVendorState:n,resetVendorState:()=>{$n(e,["vendor"],eu)},loadVendorPublicInfo:s,loadVendorPublicConfiguration:s}},nu={loading:!0,pageOffset:0,pageSize:20,logs:[],sort:[],filter:[],totalPages:0,isDownloadingCsv:!1},su=e=>cn(nu,e),iu=(e,t,a)=>{const n=a,s=t=>{Object.assign(e.auditLogs.auditLogsState,t)};return{setAuditLogsState:s,resetAuditLogsState:()=>{$n(e,["auditLogs","auditLogsState"],nu)},exportAuditsCsv:async()=>{const a=e.auditLogs.auditLogsState,{columns:n}=e.auditLogs.auditsMetadataState;try{const e=a.filter,i=a.sort.reduce(((e,t)=>S({},e,{sortBy:t.id,sortDirection:t.desc?"desc":"asc"})),{}),o=e.reduce(((e,t)=>S({},e,{[t.id]:t.value})),{});s({isDownloadingCsv:!0});const r="audits.csv";await t.audits.exportAudits(S({endpoint:"csv/v2",headerProps:n,offset:0,outputFileName:r},i,o))}catch(e){console.error("failed to export audits - ",e)}s({isDownloadingCsv:!1})},loadAuditLogs:async a=>{s({loading:!(null!=a&&a.silentLoading),error:null});const i=e.auditLogs.auditLogsState,o=null==a?void 0:a.retryConfig,{columns:r}=e.auditLogs.auditsMetadataState;try{var l,c,u,d,g;const e=null!=(l=a.pageSize)?l:i.pageSize,p=null!=(c=a.pageOffset)?c:i.pageOffset,h=null!=(u=a.filter)?u:i.filter,y=null!=(d=a.sort)?d:i.sort;s({pageSize:e,pageOffset:p,filter:h,sort:y});const v=y.reduce(((e,t)=>S({},e,{sortBy:t.id,sortDirection:t.desc?"desc":"asc"})),{}),f=h.reduce(((e,t)=>S({},e,{[t.id]:t.value})),{});r||await n.loadAuditsMetadata({retryConfig:o});const{data:m,total:b}=await Cn((()=>t.audits.getAudits(S({offset:p,count:e},v,f))),o);s({loading:!1,logs:null!=m?m:[],totalPages:+Math.ceil(b/e)}),null==a||null==(g=a.callback)||g.call(a,!0)}catch(e){var p;s({loading:!1,error:Bn(e)}),null==a||null==(p=a.callback)||p.call(a,null,e)}}}},ou={loading:!0},ru=e=>cn(ou,e),lu=(e,t,a)=>{const n=t=>{Object.assign(e.auditLogs.auditsMetadataState,t)};return{setAuditsMetadataState:n,resetAuditsMetadataState:()=>{$n(e,["auditLogs","auditsMetadataState"],ou)},loadAuditsMetadata:async e=>{n({loading:!0,error:null});try{const{properties:a}=await Cn((()=>t.metadata.getAuditsMetadata()),null==e?void 0:e.retryConfig);n({columns:a,loading:!1})}catch(e){n({error:e,loading:!1})}}}},cu=e=>({auditLogsState:su(null==e?void 0:e.auditLogsState),auditsMetadataState:ru(null==e?void 0:e.auditsMetadataState)}),uu=(e,t,a)=>S({},iu(e,t,a),lu(e,t)),du={total:0,offset:0,filter:"",sortBy:"createdAt",context:null,filters:[],rowsData:[],lastUpdated:new Date,isLoading:!0,isFetchMore:!1,totalToday:0,currentPage:0,headerProps:[],sortDirection:"desc",severeThisWeek:0,predefinedFilters:[],isDownloadingCsv:!1,virtualScroll:!1},gu=(e,t)=>Object.keys(e).reduce(((a,n)=>{const s=n;return t.includes(n)?S({},a,{[n]:e[s]}):S({},a,{[n]:()=>{console.debug(`Action ${String(n)} was called`)}})}),{}),pu={clientId:"CLIENT_ID_16806d3d-8fc3-4450-be97-abdaf66b723e",secret:"SECRET_16806d3d-8fc3-4450-be97-abdaf66b723e",createdAt:"createdAt",description:"Demo API Token (preview only)"},hu=S({},pu,{roleIds:[],tenantId:"my-tenant-id",createdByUserId:"createdByUserId"}),yu=[{id:"a040dcf6-b907-4e83-9970-6bd23c88fd40",key:"ReadOnly",name:"Read Only",description:null,isDefault:!1,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03"],vendorId:"vendorId"},{id:"b43b2c4b-e056-4eec-8c55-d200a475bbc0",key:"Admin",name:"Admin",description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03","16647407-ed6f-4ca6-83a0-86225d921959","f403c6b9-1abe-4ec7-9971-aa032255fc25","a43e059d-d731-44b1-94bb-fb6b16c62210"],vendorId:"vendorId"},{id:"1234",key:"Support",name:"Support",description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03","f26b00f8-ffe0-4739-b15c-7db15c27ea26","a9c803b0-ebfa-49b9-9607-f0d3a390ee61"],tenantId:"tenantId",vendorId:"vendorId"}],vu={sub:"",tenants:[],id:"testId",name:"Demo User Name",email:"demo-user@frontegg.com",mfaEnrolled:!0,profilePictureUrl:"https://www.gravatar.com/avatar/42b2ad2bad6fc9b9db5086dfcf8072ac?d=https://ui-avatars.com/api/fe/128/random?t=1617261890875?t=1617261917434",roles:[{id:"roleId",key:"admin",isDefault:!1,name:"Admin",description:null,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03"],tenantId:"tenantId",vendorId:"vendorId",createdAt:new Date,updatedAt:new Date}],permissions:[{id:"8d71b676-754c-4600-afe7-ca5add1e6809",key:"fe.*",name:"General Admin",description:"description",categoryId:"category",fePermission:!0,createdAt:new Date,updatedAt:new Date,roleIds:[]}],tenantId:"my-tenant-id",tenantIds:["my-tenant-id"],activatedForTenant:!0,metadata:JSON.stringify({phoneNumber:"+972-54123456",jobTitle:"Developer",address:{city:"Tel Aviv",country:"Israel"}}),verified:!1},Su=S({},vu,{accessToken:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1MTY5YmY0Zi02YmI5LTQ5NGMtOGNkZS05MDc4NDQ0NWY4MDciLCJuYW1lIjoiRHVtbXkgVXNlciIsImVtYWlsIjoiZHVtbXlAZnJvbnRlZ2cuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsIm1ldGFkYXRhIjp7fSwicm9sZXMiOlsiYWRtaW4iXSwicGVybWlzc2lvbnMiOlsiZmUuKiJdLCJ0ZW5hbnRJZCI6Im15LXRlbmFudC1pZCIsInRlbmFudElkcyI6WyJteS10ZW5hbnQtaWQiXSwicHJvZmlsZVBpY3R1cmVVcmwiOiJodHRwczovL3d3dy5ncmF2YXRhci5jb20vYXZhdGFyLzQyYjJhZDJiYWQ2ZmM5YjlkYjUwODZkZmNmODA3MmFjP2Q9aHR0cHM6Ly91aS1hdmF0YXJzLmNvbS9hcGkvZmUvMTI4L3JhbmRvbT90PTE2MTcyNjE4OTA4NzU_dD0xNjE3MjYxOTE3NDM0IiwidHlwZSI6InVzZXJUb2tlbiIsImlhdCI6MTYxNzkwNjMyNCwiZXhwIjoxNjE3OTkyNzI0LCJpc3MiOiJmcm9udGVnZyJ9.paaXLkpWEWbQmUtoK2P8IwXCxK4WJp7XhXonvzF8g1I",expiresIn:86400,mfaRequired:!1,refreshToken:"refresh-token-dummy-de39dc9c-9d22-4852-b7f5-c3c0aa613b58",type:"userToken",iat:1617906324,exp:1617992724,iss:"frontegg",email_verified:!0}),fu={loading:!1,error:void 0,saving:!0,profile:vu},mu={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date,allowOverrideEnforcePasswordHistory:!0,allowOverridePasswordComplexity:!1,allowOverridePasswordExpiration:!1,allowSignups:!0,apiTokensEnabled:!0,cookieSameSite:"cookieSameSite",defaultRefreshTokenExpiration:0,defaultTokenExpiration:1,publicKey:"publicKey"},bu={allowSignups:!0,allowNotVerifiedUsersLogin:!1,apiTokensEnabled:!0,forcePermissions:!1,authStrategy:N.EmailAndPassword,machineToMachineAuthStrategy:M.ClientCredentials},Au={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date},wu={id:"id",enabled:!0,maxAttempts:1,createdAt:new Date,updatedAt:new Date},Tu={id:"id",enabled:!0,historySize:1,createdAt:new Date,updatedAt:new Date},Eu={enabled:!0,domain:"domain",validated:!0,generatedVerification:"generatedVerification",ssoEndpoint:"ssoEndpoint",publicCertificate:"publicCertificate",signRequest:!0,createdAt:new Date,updatedAt:new Date,acsUrl:void 0,spEntityId:void 0,oidcClientId:void 0,oidcSecret:void 0,type:void 0},Pu={id:"id",createdAt:"createdAt",updatedAt:"updatedAt",properties:[],vendorId:"vendorId",entityName:"saml",isActive:!0,configuration:{acsUrl:"acsUrl",spEntityId:"spEntityId"}},Iu=[{id:"id",description:"description",key:"key",name:"name",permissions:[],permissionLevel:1}],Ou={firstLoad:!1,loading:!1,error:void 0,saving:!1,samlConfiguration:Eu,roles:Iu,authorizationRoles:[],errors:{},loaders:{},ssoConfigurations:[]},ku=[{description:"string",fePermission:!0,id:"id",key:"key",name:"name",roleIds:[],createdAt:new Date,updatedAt:new Date,categoryId:"categoryId"}],_u={id:"id2",email:"demo-user2@frontegg.com",name:"Demo User Name2",phone:void 0,profileImage:void 0,profileImageUrl:void 0,tenantId:"tenantId",vendorId:"vendorId",roleIds:[],activatedForTenant:!0,verified:!1,createdAt:(new Date).toISOString(),customData:void 0,lastLogin:void 0,mfaEnabled:void 0,roles:[yu[0]],groups:[{id:"id2",name:"Developers",color:"#03A9F4",roles:[yu[0]],managedBy:za.FRONTEGG}]},Uu={id:_u.id,email:_u.email,name:_u.name,phoneNumber:void 0,profileImage:void 0,tenantId:"tenantId",activatedForTenant:!0,createdAt:new Date(2022,4,1),verified:!0,lastLogin:new Date(2022,5,25),mfaEnrolled:!1,roles:[yu[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},Ru={id:"id",email:"demo-user@frontegg.com",name:"Demo User Name",phone:void 0,profileImage:void 0,profileImageUrl:void 0,tenantId:"tenantId",vendorId:"vendorId",roleIds:[],activatedForTenant:!0,createdAt:new Date(2022,4,1).toISOString(),verified:!0,customData:void 0,lastLogin:new Date(2022,5,25).toISOString(),mfaEnabled:void 0,roles:[yu[1]],groups:[{id:"id1",name:"Designers",color:"#E1F5E2",roles:[yu[0]],managedBy:za.FRONTEGG}]},Lu={id:Ru.id,email:Ru.email,name:Ru.name,phoneNumber:void 0,profileImage:void 0,tenantId:"tenantId",activatedForTenant:!0,createdAt:new Date(2022,4,1),verified:!0,lastLogin:new Date(2022,5,25),mfaEnrolled:!1,roles:[yu[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},Cu={metadata:"",mfaEnrolled:!1,provider:"",sub:"",tenantIds:[],tenants:[],verified:!1,id:"id",email:"email",name:"name",tenantId:"tenantId",createdAt:new Date},Du=[Ru,_u],Nu=[Lu,Uu],Mu=[Cu],Fu=[{id:"my-tenant-id",isReseller:!1,name:"Frontegg demo",deletedAt:null,metadata:void 0,tenantId:"my-tenant-id",vendorId:"vendorId",createdAt:new Date,updatedAt:new Date,address:void 0,timezone:void 0,dateFormat:void 0,timeFormat:void 0,currency:void 0,logo:void 0}],xu=[{id:"laptop",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/605.1.15",createdAt:new Date,ipAddress:"190.194.88.251",current:!0},{id:"iphone",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Mobile/15E148 Safari/604.1",createdAt:new Date(Date.now()-1e4),ipAddress:"191.49.203.21"},{id:"tablet",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; SGP771 Build/32.2.A.0.253; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Safari/537.36",createdAt:new Date(Date.now()-3e4),ipAddress:"130.19.196.136"},{id:"anotherlaptop",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/605.1.15",createdAt:new Date(Date.now()-1002232300),ipAddress:"2.228.163.92"}],$u={isActive:!0,strategy:Je.ALLOW},Gu=[{updatedAt:new Date,createdAt:new Date,id:"1",ip:"255.255.255.255",isActive:!0,strategy:Je.ALLOW,description:"My IP"},{updatedAt:new Date,createdAt:new Date,id:"2",ip:"255.255.255.254",isActive:!0,strategy:Je.ALLOW,description:"IP 2"},{updatedAt:new Date,createdAt:new Date,id:"3",ip:"255.255.255.253",isActive:!0,strategy:Je.BLOCK,description:"IP 3"},{updatedAt:new Date,createdAt:new Date,id:"4",ip:"255.255.255.253",isActive:!0,strategy:Je.BLOCK,description:"IP 4"}],ju=e=>{const t=[];return Array.from({length:e}).forEach(((e,a)=>{t.push(S({},Ru,{name:"Demo User",id:`id${a}`,profilePictureUrl:null,createdAt:new Date}))})),t},Bu=e=>({id:"b43b2c4b-e056-4eec-8c55-d200a475bbc0"+e,key:e,name:e,description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:[],tenantId:"tenantId",vendorId:"vendorId"}),Vu=[{id:"id1",name:"Designers",color:"#E1F5E2",description:"The whole design team",users:ju(6),roles:[Bu("Editor")],metadata:'{"lastTermsCheck":"2022-08-16T10:31:11.270Z"}',managedBy:za.FRONTEGG},{id:"id2",name:"Developers",color:"#03A9F4",description:"All frontend and backend developers",users:ju(44),roles:[Bu("Editor")],managedBy:za.FRONTEGG},{id:"id3",name:"Product",color:"#E1583E",description:"PMs and team leads",users:ju(8),roles:[Bu("Viewer")],managedBy:za.FRONTEGG},{id:"id4",name:"Management",color:"#9AE0FF",description:"Executives",users:ju(5),roles:[Bu("Admin")],managedBy:za.FRONTEGG},{id:"id5",name:"Sales",color:"#ED8E7C",users:ju(21),description:"BDR, AE, and inside sales",roles:[Bu("Viewer")],managedBy:za.FRONTEGG},{id:"id6",name:"Support",color:"#A79D7B",users:ju(23),description:"Dev success and customer success",roles:[Bu("Admin")],managedBy:za.FRONTEGG},{id:"id7",name:"Marketing",color:"#2CA744",users:ju(10),description:"The marketing department",roles:[Bu("Viewer")],managedBy:za.FRONTEGG},{id:"id8",name:"HR",color:"#EAE1C2",users:ju(4),description:"Human resources",roles:[Bu("Viewer")],managedBy:za.FRONTEGG},{id:"id9",name:"Finance",color:"#5587C0",users:ju(3),roles:[Bu("Viewer")],managedBy:za.FRONTEGG},{id:"id10",name:"Operations",color:"#B1CAE7",users:ju(8),roles:[Bu("Editor")],managedBy:za.FRONTEGG},{id:"id11",name:"Legal",color:"#2CA744",users:ju(4),roles:[Bu("Viewer")],managedBy:za.FRONTEGG}],Wu={scoring:{score:79},recommendations:{items:[{code:Xa.FORCE_MFA,severity:en.WARNING,category:tn.MFA},{code:Xa.ENABLE_FORCE_RELOGIN,severity:en.WARNING,category:tn.SESSIONS}]}},Hu={insights:{items:[{category:tn.MFA,code:Qa.PARTIALLY_FORCED_MFA,metadata:{totalUsers:2,mfa:{enrolledUsersCount:1}}},{category:tn.SESSIONS,code:Qa.PARTIAL_SESSION_SETTINGS,metadata:{totalUsers:2,sessions:{idleTimeoutRecommendation:1800}}},{category:tn.PASSWORD,code:Qa.IMPROVE_PASSWORD_HISTORY_POLICY,metadata:{password:{userLockoutRecommendation:5,historyRecommendations:5}}},{category:tn.DOMAIN,code:Qa.NO_IP_RESTRICTIONS,metadata:{restrictions:{ipsCount:1,domainsCount:1}}}]}},zu={users:Nu,totalUsersItems:2,totalUsersPages:1,usersPageOffset:0},Ku={users:[Nu[0]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0,queryParams:{_maxInactiveSeconds:7776e3}},qu={users:[Nu[1]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0};Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,Na.ASSIGNABLE,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date;var Ju,Yu=new Uint8Array(16);function Xu(){if(!Ju&&!(Ju="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ju(Yu)}const Qu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var Zu=[],ed=0;ed<256;++ed)Zu.push((ed+256).toString(16).substr(1));const td=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(Zu[e[t+0]]+Zu[e[t+1]]+Zu[e[t+2]]+Zu[e[t+3]]+"-"+Zu[e[t+4]]+Zu[e[t+5]]+"-"+Zu[e[t+6]]+Zu[e[t+7]]+"-"+Zu[e[t+8]]+Zu[e[t+9]]+"-"+Zu[e[t+10]]+Zu[e[t+11]]+Zu[e[t+12]]+Zu[e[t+13]]+Zu[e[t+14]]+Zu[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&Qu.test(e)}(a))throw TypeError("Stringified UUID is invalid");return a},ad=function(e,t,a){var n=(e=e||{}).random||(e.rng||Xu)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){a=a||0;for(var s=0;s<16;++s)t[a+s]=n[s];return t}return td(n)},nd=["callback"],sd=["callback"],id=["callback","profilePictureUrl"],od=["callback"],rd=["callback"],ld=["callback"],cd=["callback"],ud=["callback"],dd=["callback"],gd=["callback"],pd=["callback"],hd=["callback","samlVendor"],yd=["callback"],vd=["callback"],Sd=["callback","profileImage"],fd=["callback"],md=["callback"],bd=["callback"],Ad=["callback"],wd=["callback"],Td=["callback"],Ed=["callback"],Pd=["callback"],Id=["requestName"],Od=e=>"createdAt"!==e.id,kd={total:20,data:Array.from(Array(5).keys()).map((e=>S({ip:"198.143.51.1",user:"Demo User Name",email:"demo-user@frontegg.com"},(()=>{switch(Math.floor(6*Math.random())){case 0:return{action:"Updated profile",description:"User updated profile details",severity:"Info"};case 1:return{action:"User logged in",severity:"Info",description:"User logged in to the product"};case 2:return{action:"User failed to login",severity:"High",description:"User failed to login with password"};case 3:return{action:"Added user",severity:"Info",description:"Added user david+535@frontegg.com to tenant"};case 4:return{action:"Assigned roles",severity:"Info",description:"Assigned 0 roles for user"};case 5:return{action:"Removed user david+108@frontegg.com from account",severity:"Info",description:"Removed access from the account for user david+108@frontegg.com"}}})(),{json:{key1:"value1",key2:"value2",key3:"value3",key4:"value4"},tenantId:"my-tenant-id",vendorId:"my-vendor-id",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",createdAt:`2022-04-07 10:${50-e}:40.201`})))},_d={properties:[{showInTable:!0,name:"createdAt",displayName:"Time",type:"Timestamp",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!1},{showInTable:!0,name:"email",displayName:"User",type:"Email",filterable:!0,sortable:!0,isPredefined:!0,chosen:!1,selected:!1},{showInTable:!0,name:"action",displayName:"Action",type:"AlphaNumeric",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!0,name:"description",type:"AlphaNumeric",sortable:!1,filterable:!1,displayName:"Description",isPredefined:!0,chosen:!1,selected:!1},{showInTable:!0,name:"ip",displayName:"IP Address",type:"IpAddress",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!1,name:"severity",displayName:"Severity",type:"Severity",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!1,name:"userAgent",displayName:"User Agent",type:"AlphaNumeric",filterable:!0,sortable:!0,isPredefined:!0,chosen:!1,selected:!1},{showInTable:!1,name:"json",type:"Json",sortable:!0,filterable:!0,displayName:"Json Data",showInMoreInfo:"Always",isPredefined:!1}]},Ud=(e,t,a)=>{const n=((e,t,a)=>{const n=iu(e,t,a),s=gu(n,["setAuditLogsState","resetAuditLogsState"]);return s.loadAuditLogs=async t=>{s.setAuditLogsState({loading:!t.silentLoading,error:null});const n=e.auditLogs.auditLogsState,{columns:i}=e.auditLogs.auditsMetadataState;try{var o,r,l,c,u;const e=null!=(o=t.pageSize)?o:n.pageSize,d=null!=(r=t.pageOffset)?r:n.pageOffset,g=null!=(l=t.filter)?l:n.filter,p=null!=(c=t.sort)?c:n.sort;s.setAuditLogsState({pageSize:e,pageOffset:d,filter:g,sort:p}),i||await a.loadAuditsMetadata();const{data:h,total:y}=((e,t)=>{const{data:a}=kd;let n=a.filter((e=>t=>e.filter(Od).every((e=>t[e.id].includes(e.value))))(e));if(t.length){const{id:e,desc:a=!1}=t[0];n=n.sort(((e,t)=>(a,n)=>a[e]>n[e]?t?-1:1:n[e]>a[e]?t?1:-1:0)(e,a))}return{data:n,total:n.length}})(g,p);s.setAuditLogsState({loading:!1,logs:null!=h?h:[],totalPages:+Math.ceil(y/e)}),null==t||null==(u=t.callback)||u.call(t,!0)}catch(e){var d;s.setAuditLogsState({loading:!1,error:Bn(e)}),null==t||null==(d=t.callback)||d.call(t,null,e)}},s})(e,t,a),s=((e,t)=>{const a=lu(e,t),n=gu(a,["setAuditsMetadataState","resetAuditsMetadataState"]);return n.loadAuditsMetadata=async()=>{n.setAuditsMetadataState({loading:!0,error:null});try{const{properties:e}=_d;n.setAuditsMetadataState({columns:e,loading:!1})}catch(e){n.setAuditsMetadataState({error:e,loading:!1})}},n})(e,t);return S({},n,s)},Rd={id:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",externalId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",startDate:"2021-09-20T08:08:51.000Z",status:G.ACTIVE,externallyManaged:!1,cancellation:null,currentPeriodStart:"2021-09-20T08:08:51.000Z",currentPeriodEnd:"2021-10-20T08:08:51.000Z",plan:{slug:"test"}},Ld=[{id:"prod_J60fUEvI7qV1eL",externalId:"prod_J60fUEvI7qV1eL",name:"Premium",description:"",price:{id:"price_1IToe8Ewsu4qiqnndAV76J69",externalId:"price_1IToe8Ewsu4qiqnndAV76J69",currency:"usd",amount:1e4},slug:"premium"},{id:"prod_J60duauCpXfcur",externalId:"prod_J60duauCpXfcur",name:"Free",description:"Totally free plan. Nothing to pay.",price:{id:"price_1ITocfEwsu4qiqnnnBHDx9fQ",externalId:"price_1ITocfEwsu4qiqnnnBHDx9fQ",currency:"usd",amount:0},slug:"free"}],Cd=[{id:"in_1JbhYWEwsu4qiqnnrUh6hsHa",externalId:"in_1JbhYWEwsu4qiqnnrUh6hsHa",subscriptionId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",paymentDate:"2021-09-20T08:08:51.000Z",totalAmount:1e4,currency:"usd",paid:!0,receiptNumber:""},{id:"in_1JbhYWEwsu4qiqnnrUh6hsHa",externalId:"in_1JbhYWEwsu4qiqnnrUh6hsHa",subscriptionId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",paymentDate:"2021-08-20T08:08:51.000Z",totalAmount:1e4,currency:"usd",paid:!0,receiptNumber:""}],Dd=[{id:"id",externalId:"externalId",type:j.CARD,isDefault:!0,last4:"4242",expMonth:11,expYear:25,brand:"visa",billingDetails:{name:"Dummy",email:"dummy@email.com"}}],Nd={allowPlanDowngrade:!0,allowPlanCancellation:!0},Md=(e,t,a)=>{const n=((e,t)=>{const a=Ec(e,t),n=gu(a,["setPaymentConfigState","resetPaymentConfigState"]);return n.loadPaymentConfiguration=async()=>{n.setPaymentConfigState({loading:!0}),await Rn(500),n.setPaymentConfigState({loading:!1,fetching:!1,config:{paymentProvider:Ac.STRIPE,apiKey:""}})},n})(e,t),[s,i]=((e,t,a)=>{const n=((e,t,a)=>{const n=_c(e,t,a),s=gu(n,["setBillingInformationState","resetBillingInformationState"]);return s.loadBillingInformation=async()=>{var e,t;s.setBillingInformationState({loading:!0}),await Rn(500),s.setBillingInformationState({loading:!1,fetching:!1,summary:{subscriptionId:Rd.id,paymentMethodId:"mockPaymentMethodId",tenantConfigurationId:"mockTenantConfigurationId",providerType:V.Stripe,externallyManaged:!1,currentPlanId:Ld[0].id,defaultPlanId:Ld[0].id},plan:S({},Ld[0],{price:null==(e=Ld[0].price)?void 0:e.amount,currency:null==(t=Ld[0].price)?void 0:t.currency,recurringInterval:"month"})})},s})(e,t,a),s=((e,t)=>{const a=Nc(e,t),n=gu(a,["setBillingPaymentMethodState","resetBillingPaymentMethodState"]);return n.loadPaymentMethod=async()=>{n.setBillingPaymentMethodState({loading:!0}),await Rn(500),n.setBillingPaymentMethodState({paymentMethod:Dd[0],loading:!1,fetching:!1})},n})(e,t),i=((e,t)=>{const a=Lc(e,t),n=gu(a,["setBillingInvoiceState","resetBillingInvoiceState"]);return n.loadBillingInvoices=async()=>{n.setBillingInvoiceState({loading:!0}),await Rn(500),n.setBillingInvoiceState({loading:!1,fetching:!1,invoices:Cd.map((e=>S({},e,{selectedPlan:"Premium",paymentDate:new Date(Date.parse(e.paymentDate)),totalAmount:+((e.totalAmount||0)/100).toFixed(2)})))})},n.loadInvoices=n.loadBillingInvoices,n})(e,t),o=((e,t,a)=>{const n=xc(e,t,a),s=gu(n,["setBillingSubscriptionState","resetBillingSubscriptionState","setCancellationLoading","setCancellationError","setRenewalLoading","setRenewalError"]);return s.loadSubscription=async()=>{s.setBillingSubscriptionState({loading:!0}),await Rn(500),s.setBillingSubscriptionState({subscription:Rd,fetching:!1,loading:!1,error:null})},s})(e,t,a);return[S({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(e,t,a),o=((e,t)=>{const a=Bc(e,t),n=gu(a,["setPlansState","resetPlansState"]);return n.loadPlans=async()=>{n.setPlansState({loading:!0}),await Rn(500),n.setPlansState({fetching:!1,loading:!1,plans:Ld.map((e=>{var t,a;return S({},e,{price:(null==(t=e.price)?void 0:t.amount)||0,currency:(null==(a=e.price)?void 0:a.currency)||"usd",recurringInterval:"month"})}))})},n})(e,t),r=((e,t,a)=>{const n=Hc(e,t,a);return gu(n,["setCheckoutState","resetCheckoutState","errorCheckout","resetCheckout"])})(e,t,a),l=((e,t)=>{const a=qc(e,t);return gu(a,[])})(e,t),c=((e,t)=>{const a=Xc(e,t),n=gu(a,["setVendorPublicConfigState","resetVendorPublicConfigState","setVendorPublicConfigError","setVendorPublicConfigLoading"]);return n.loadVendorPublicConfiguration=async()=>{n.setVendorPublicConfigLoading(!0),await Rn(),n.setVendorPublicConfigState({fetching:!1,loading:!1,vendorPublicConfig:Nd})},n})(e,t);return[S({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},Fd=(e,t,a,n)=>{const{authActions:s,authStateActions:i}=((e,t,a,n)=>{const s=((e,t)=>{const a=Vn(e,t);return gu(a,["setAcceptInvitationState","resetAcceptInvitationState"])})(e,t),i=((e,t,a)=>{const n=Kn(e,t,a),s=gu(n,["setAccountSettingsState","resetAccountSettingsState"]);return s.saveAccountSettings=async t=>{var a;s.setAccountSettingsState({loading:!0}),await Rn();const n=e.auth.accountSettingsState,{address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u}=n,d=S({address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u},t);s.setAccountSettingsState(S({},d,{loading:!1})),null==(a=t.callback)||a.call(t,d)},s.loadAccountSettings=async e=>{s.setAccountSettingsState({loading:!(null!=e&&e.silentLoading),error:null}),await Rn(),s.setAccountSettingsState(S({address:"Tel-aviv",timezone:"Asia/Jerusalem",dateFormat:"DD/MM/YYYY",timeFormat:"HH:mm",currency:"USD",loading:!1},e))},s})(e,t,a),o=((e,t)=>{const a=js(e,t);return gu(a,["setUnlockAccountState","resetUnlockAccountState"])})(e,t),r=((e,t,a)=>{const n=xs(e,t,a);return gu(n,["setActivateState","resetActivateState","setActivateStrategyState"])})(e,t,a),l=((e,t,a)=>{const n=Zo(e,t,a);return gu(n,["setAllAccountsLoader","setAllAccountsError","setAllAccountsState","setSelectedAccountState","resetAllAccountsState","clearSelectedAccount"])})(e,t,a),c=er(e),u=((e,t)=>{const a=Hs(e,t),n=gu(a,["setApiTokensState","resetApiTokensState","setApiTokensLoader","setApiTokensError"]);return n.addTenantApiToken=async t=>{const{description:a,roleIds:s,callback:i}=t;n.setApiTokensLoader({key:Ws.ADD_API_TOKEN,value:!0});const{apiTokensDataTenant:o}=e.auth.apiTokensState,r=S({},hu,{description:a,roleIds:s,clientId:`CLIENT_ID_${ad()}`});n.setApiTokensState({showAddTokenDialog:!1}),await Rn(200),n.setApiTokensState({apiTokensDataTenant:[...o,r],successDialog:{open:!0,secret:r.secret,clientId:r.clientId}}),await Rn(200),n.setApiTokensLoader({key:Ws.ADD_API_TOKEN,value:!1}),null==i||i(null)},n.deleteTenantApiToken=async e=>{n.setApiTokensLoader({key:Ws.DELETE_API_TOKEN,value:!0}),await Rn(200);const t=[hu];n.setApiTokensState({apiTokensDataTenant:t.filter((t=>t.clientId!==e)),deleteTokenDialog:{open:!1,clientId:e}}),n.setApiTokensLoader({key:Ws.DELETE_API_TOKEN,value:!1})},n.loadApiTokens=async e=>{var t;null!=e&&e.silentLoading||n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!0});const a=[pu],s=[hu];n.setApiTokensState({apiTokensDataUser:a,apiTokensDataTenant:s}),await Rn(200),n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!1}),null==e||null==(t=e.callback)||t.call(e,!0)},n.loadUserApiTokens=async e=>{var t;null!=e&&e.silentLoading||n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!0});const a=[pu];n.setApiTokensState({apiTokensDataUser:a}),await Rn(200),n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!1}),null==e||null==(t=e.callback)||t.call(e,!0)},n.loadTenantApiTokens=async e=>{var t;null!=e&&e.silentLoading||n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!0});const a=[hu];n.setApiTokensState({apiTokensDataTenant:a}),await Rn(200),n.setApiTokensLoader({key:Ws.LOAD_API_TOKENS,value:!1}),null==e||null==(t=e.callback)||t.call(e,!0)},n})(e,t),d=((e,t,a)=>{const n=Js(e,t,a);return gu(n,["setApplicationsState","resetApplicationsState"])})(e,t,a),g=((e,t,a)=>{const n=Zs(e,t,a),s=gu(n,["setCustomLoginState","resetCustomLoginState"]);return s.loadTenantMetadata=async()=>{s.setCustomLoginState({loading:!0}),await Rn(),s.setCustomLoginState({loading:!1})},s.updateTenantMetadata=async e=>{const{callback:t}=e;s.setCustomLoginState({loading:!0,error:null}),await Rn(),s.setCustomLoginState({loading:!1,error:null}),null==t||t(!0)},s})(e,t,a),p=((e,t)=>{const a=ic(e,t);return gu(a,["setEntitlements","handleFetchedEntitlements"])})(e,t),h=((e,t)=>{const a=si(e,t),n=gu(a,["setForgotPasswordState","resetForgotPasswordState"]);return n.loadPasswordConfig=async e=>{n.setForgotPasswordState({loading:!0});try{n.setForgotPasswordState({loading:!1,passwordConfig:{allowPassphrases:!0,maxLength:128,minLength:6,minPhraseLength:6,minOptionalTestsToPass:1}})}catch(e){n.setForgotPasswordState({loading:!1,error:Bn(e)})}},n})(e,t),y=(e=>{const t=li(e),a=gu(t,["setStep"]);return a.setStep(ii.success),a})(e),v=((e,t)=>{const a=hi(e,t),n=gu(a,["setGroupsState","resetUsersGroupsState","setUsersGroupsLoader","setUsersGroupsError"]);return n.loadGroups=async()=>{const e=di.GET_GROUPS;n.setUsersGroupsLoader({key:e,value:!0});const t=Vu;n.setGroupsState({groups:t}),n.setUsersGroupsLoader({key:e,value:!1})},n.createGroup=async t=>{var a;const s=di.CREATE_GROUP,{groups:i}=e.auth.groupsState;n.setUsersGroupsLoader({key:s,value:!0}),await Rn(500),n.setGroupsState({groups:[S({},t,{id:`${t.name}ID`,managedBy:za.FRONTEGG}),...null!=i?i:[]]}),null==t||null==(a=t.callback)||a.call(t,!0),n.setUsersGroupsLoader({key:s,value:!1})},n.updateGroup=async t=>{var a,s,i,o,r;const l=di.UPDATE_GROUP,c=e.auth.groupsState;n.setUsersGroupsLoader({key:l,value:!0}),await Rn(500),n.setGroupsState({groups:null==c||null==(a=c.groups)?void 0:a.map((e=>{var a;return e.id===t.groupId?S({},t,{id:t.groupId,name:null!=(a=null==t?void 0:t.name)?a:"",managedBy:za.FRONTEGG}):e})),selectedGroup:S({},null==c?void 0:c.selectedGroup,{name:null!=(s=null==t?void 0:t.name)?s:"",color:null!=(i=null==t?void 0:t.color)?i:"",description:null!=(o=null==t?void 0:t.description)?o:""})}),null==t||null==(r=t.callback)||r.call(t,!0),n.setUsersGroupsLoader({key:l,value:!1})},n.deleteGroup=async t=>{var a,s;const i=di.DELETE_GROUP,o=e.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Rn(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.filter((e=>e.id!==t.groupId))}),null==t||null==(s=t.callback)||s.call(t,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.addRolesToGroup=async t=>{var a,s;const i=di.ADD_ROLES_TO_GROUP,o=e.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Rn(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((e=>{var a;return e.id===t.groupId?S({},e,{roles:[...null!=(a=null==e?void 0:e.roles)?a:[],...t.roleIds.map((e=>({id:e,name:e})))]}):e}))}),null==t||null==(s=t.callback)||s.call(t,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.deleteRolesFromGroup=async t=>{var a,s;const i=di.DELETE_ROLES_FROM_GROUP,o=e.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Rn(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((e=>{var a;return e.id===t.groupId?S({},e,{roles:null==e||null==(a=e.roles)?void 0:a.filter((e=>!t.roleIds.includes(e.id)))}):e}))}),null==t||null==(s=t.callback)||s.call(t,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.addUsersToGroup=async t=>{var a,s;const i=di.ADD_USERS_TO_GROUP,o=e.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Rn(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((e=>{var a;return e.id===t.groupId?S({},e,{users:[...null!=(a=null==e?void 0:e.users)?a:[],...t.userIds.map((e=>({id:e,name:e})))]}):e}))}),null==t||null==(s=t.callback)||s.call(t,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.deleteUsersFromGroup=async t=>{var a,s;const i=di.DELETE_USERS_FROM_GROUP,o=e.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Rn(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((e=>{var a;return e.id===t.groupId?S({},e,{users:null==e||null==(a=e.users)?void 0:a.filter((e=>!t.userIds.includes(e.id)))}):e}))}),null==t||null==(s=t.callback)||s.call(t,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.getGroupConfiguration=async()=>{const t=di.GET_GROUP_CONFIGURATION,{groupsConfiguration:a}=e.auth.groupsState;n.setUsersGroupsLoader({key:t,value:!0}),a&&n.setGroupsState({groupsConfiguration:S({},a)}),n.setUsersGroupsLoader({key:t,value:!1})},n.updateGroupConfiguration=async t=>{const a=di.UPDATE_GROUP_CONFIGURATION,{groupsConfiguration:s}=e.auth.groupsState;n.setUsersGroupsLoader({key:a,value:!0}),s&&n.setGroupsState({groupsConfiguration:S({},s,t)}),n.setUsersGroupsLoader({key:a,value:!1})},n})(e,t),m=Si(e),b=((e,t,a)=>{const n=wi(e,t,a);return gu(n,["setImpersonateState","resetImpersonateState"])})(e,t,a),A=((e,t,a)=>{const n=a,s=Uo(e,t,n),i=gu(s,["setLoginState","resetLoginState","afterAuthNavigation"]);return i.requestAuthorize=async e=>{e&&n.setAuthState({isLoading:!0});const t=Su;await n.loadTenants(),n.setAuthState({user:t,isAuthenticated:!0,isLoading:!1})},i.getUserIP=async e=>{const{callback:t}=e;try{const{ip:e}=Gu[0];await n.setAuthState({userIpData:{ip:e},userIp:e}),null==t||t(!0,e)}catch(e){null==t||t(!1,e)}},i})(e,t,a),w=((e,t,a)=>{const n=a,s=jo(e,t,n),i=gu(s,["setMfaState","resetMfaState"]);return i.enrollMfa=async()=>{i.setMfaState({saving:!0}),i.setMfaState({saving:!1,error:void 0,qrCode:"test"})},i.verifyMfa=async t=>{const{callback:a}=t,{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=(f(t,nd),e.auth.mfaState);i.setMfaState({saving:!0}),await Rn();const o={token:"token",recoveryCode:"recoveryCode"},r={step:ns.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:S({},s,{authenticators:[{id:"authenticator-id"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(S({},Su,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i.disableMfa=async t=>{var a;const{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=e.auth.mfaState;i.setMfaState({saving:!0}),await Rn(),i.setMfaState({saving:!1,error:void 0,mfaDevices:S({},s,{authenticators:[]})}),n.setUser(S({},Su)),null==(a=t.callback)||a.call(t,!0)},i.verifyMfaAfterForce=async e=>{const{callback:t}=e,a=f(e,sd);i.setMfaState({loading:!0}),await Rn();const s=S({},a,{recoveryCode:"recoveryCode"}),o={step:ns.recoveryCode,loading:!1,error:void 0,saving:!1};null!=s&&s.recoveryCode&&(o.recoveryCode=s.recoveryCode),i.setMfaState(o),await Rn(),n.setUser(S({},Su,{mfaEnrolled:!0})),null==t||t(o.recoveryCode)},i.preDisableMfaSms=async e=>{i.setMfaState({saving:!0});try{var t;i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(t=e.callback)||t.call(e,!0)}catch(t){var a;i.setMfaState({saving:!1,error:Bn(t)}),null==(a=e.callback)||a.call(e,!1,t)}},i.disableMfaSms=async t=>{var a;const{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=e.auth.mfaState;i.setMfaState({saving:!0}),await Rn(),i.setMfaState({loading:!1,error:void 0,mfaDevices:S({},s,{phones:[]})}),n.setUser(S({},Su)),null==(a=t.callback)||a.call(t,!0)},i.preEnrollMfaSms=async e=>{var t;i.setMfaState({saving:!0}),await Rn(),i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(t=e.callback)||t.call(e,!0)},i.enrollMfaSms=async t=>{const{callback:a}=t,{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=e.auth.mfaState;i.setMfaState({saving:!0}),await Rn();const o={token:"token",recoveryCode:"recoveryCode"},r={step:ns.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:S({},s,{phones:[{id:"phone-id",phoneNumber:"+972504589346"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(S({},Su,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i})(e,t,a),T=((e,t,a)=>{const n=nr(e,t,a);return gu(n,["setPasskeysState","resetPasskeysState"])})(e,t,a),E=((e,t,a)=>{const n=rr(e,t,a),s=gu(n,["setProfileState","resetProfileState"]);return s.loadProfile=async()=>{s.setProfileState({loading:!0}),await Rn(),a.setUser(S({},Su,vu)),s.setProfileState({loading:!1,profile:vu})},s.saveProfile=async e=>{const{callback:t,profilePictureUrl:n}=e,i=f(e,id);s.setProfileState({saving:!0,error:null});const o=fu;let r=o.profile.profilePictureUrl;n!==o.profile.profilePictureUrl&&n&&(n||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)&&(r=n);const l=S({},o.profile,i,{profilePictureUrl:r}),c=Su;await Rn(),a.setUser(S({},c,l)),s.setProfileState({loading:!1,error:null,saving:!1,profile:l}),null==t||t(l)},s.changePassword=async e=>{var t;s.setProfileState({loading:!0}),await Rn(),s.setProfileState({loading:!1,error:void 0}),null==(t=e.callback)||t.call(e,!0)},s.updateEmail=async e=>{var t;s.setProfileState({saving:!0,error:null,loading:!0}),await Rn(),s.setProfileState({saving:!1,error:null,loading:!1}),null==(t=e.callback)||t.call(e,!0)},s.verifyEmail=async e=>{var t;s.setProfileState({saving:!0,error:null,loading:!0}),await Rn(),s.setProfileState({saving:!1,error:null,loading:!1}),null==(t=e.callback)||t.call(e,!0)},s})(e,t,a),P=((e,t)=>{const a=gr(e,t);return gu(a,["setProvisioningState","resetProvisioningState"])})(e,t),I=((e,t,a)=>{const n=mr(e,t,a);return gu(n,["setResetPhoneNumberState","resetResetPhoneNumberState"])})(e,t,a),O=((e,t,a)=>{const n=Mr(e,t,a),s=gu(n,["setRestrictionsState","setIpRestrictionsState","setEmailDomainRestrictionsState"]);return s.loadIpRestrictions=async()=>{s.setIpRestrictionsState({loading:!0,error:null}),s.setIpRestrictionsState({data:{restrictions:Gu.filter((e=>e.strategy===$u.strategy)),config:$u},totalPages:1,pagination:{_filter:Je.ALLOW,_limit:50,_offset:0},loading:!1})},s.loadEmailDomainRestrictions=async()=>{s.setEmailDomainRestrictionsState({loading:!0,error:null}),s.setEmailDomainRestrictionsState({loading:!1,data:{restrictions:[{domain:"mock.com",id:"1",type:Je.ALLOW}],config:{active:!0,listType:Je.ALLOW,blockPublicDomains:!1}}})},s.saveIpRestriction=async t=>{var a,n,i;const{callback:o}=t,r=f(t,od);s.setIpRestrictionsState({saving:!0,error:null});const l=e.auth.restrictionsState.ipRestrictions,c=l.data.restrictions.filter((e=>e.ip!==r.ip));s.setIpRestrictionsState({data:{config:null!=(a=null==(n=l.data)?void 0:n.config)?a:{isActive:!1,strategy:Je.ALLOW},restrictions:[...c,S({},r,{createdAt:new Date,updatedAt:new Date,id:ad(),isActive:null==(i=r.isActive)||i,strategy:l.data.config.strategy})]},totalPages:1,pagination:{_filter:Je.ALLOW,_limit:50,_offset:0},saving:!1}),null==o||o(!0)},s.saveIpRestrictionsConfig=async t=>{var a,n,i;const{callback:o}=t,r=f(t,rd),l=e.auth.restrictionsState.ipRestrictions;s.setIpRestrictionsState({saving:!0,error:null}),s.setIpRestrictionsState({data:{config:S({},null==(a=l.data)?void 0:a.config,r),restrictions:null!=(n=null==(i=l.data)?void 0:i.restrictions)?n:[]},pagination:{_filter:Je.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1}),s.setIpRestrictionsState({saving:!1,error:null}),null==o||o(!0)},s.deleteIpRestriction=async t=>{var a;const{callback:n,id:i}=t;s.setIpRestrictionsState({saving:!0,error:null});const o=e.auth.restrictionsState.ipRestrictions;s.setIpRestrictionsState({data:{config:(null==(a=o.data)?void 0:a.config)||{isActive:!1,strategy:Je.ALLOW},restrictions:o.data.restrictions.filter((e=>e.id!==i))},pagination:{_filter:Je.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1,error:null}),null==n||n(!0)},s.checkIfUserIpValid=async()=>{s.setIpRestrictionsState({loading:!0,error:null});try{const t=e.auth.restrictionsState.ipRestrictions,a=Gu[0].ip,n=!!t.data.restrictions.find((e=>e.isActive&&e.ip===a));s.setIpRestrictionsState({userIpValid:n,loading:!1})}catch(e){s.setIpRestrictionsState({error:Bn(e),loading:!1})}},s.saveEmailDomainRestriction=async t=>{var a,n;const{callback:i}=t,o=f(t,ld),r=e.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await Rn(),null==i||i(!0),s.setEmailDomainRestrictionsState({data:{config:(null==(a=r.data)?void 0:a.config)||{active:!1,blockPublicDomains:!1,listType:o.type},restrictions:[...(null==(n=r.data)?void 0:n.restrictions)||[],S({},o,{id:Date.now().toString()})]},saving:!1})},s.saveEmailDomainRestrictionsConfig=async t=>{var a;const{callback:n}=t,i=f(t,cd),o=e.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await Rn(),null==n||n(!0),s.setEmailDomainRestrictionsState({data:{config:{active:i.active,blockPublicDomains:i.blockPublicDomains||!1,listType:i.type||Je.ALLOW},restrictions:[...(null==(a=o.data)?void 0:a.restrictions)||[]]},saving:!1})},s.deleteEmailDomainRestriction=async t=>{var a,n;const{id:i}=t,o=e.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await Rn(),s.setEmailDomainRestrictionsState({data:{config:(null==(a=o.data)?void 0:a.config)||{active:!1,blockPublicDomains:!1,listType:Je.ALLOW},restrictions:((null==(n=o.data)?void 0:n.restrictions)||[]).filter((e=>e.id===i))},saving:!1})},s})(e,t,a),k=((e,t)=>{const a=_r(e,t),n=gu(a,["setRolesState","setRolesStateError","setRolesStateLoader","resetRolesState"]);return n.loadRolesAndPermissions=async e=>{var t;const a=wr.LOAD_ROLES;n.setRolesStateLoader({key:a,value:!(null!=(t=null==e?void 0:e.silentLoading)&&t)});try{n.setRolesState({roles:yu})}catch(e){n.setRolesStateError({key:a,value:Bn(e)})}finally{n.setRolesStateLoader({key:a,value:!1})}},n})(e,t),_=((e,t,a)=>{const n=jr(e,t,a),s=gu(n,["setSecurityCenterState","setSecurityCenterStateError","setSecurityCenterStateLoader","resetSecurityCenterState"]);return s.loadRecommendations=async()=>{const e=$r.RECOMMENDATIONS;s.setSecurityCenterStateLoader({key:e,value:!0}),await Rn(),s.setSecurityCenterState({recommendations:Wu.recommendations.items,score:Wu.scoring.score}),s.setSecurityCenterStateLoader({key:e,value:!1})},s.loadInsights=async()=>{const e=$r.INSIGHTS;s.setSecurityCenterStateLoader({key:e,value:!0}),await Rn(),s.setSecurityCenterState({insights:Hu.insights.items}),s.setSecurityCenterStateLoader({key:e,value:!1})},s.loadBreachedPasswordUsers=async()=>{const e=$r.BREACHED_PASSWORD_USERS_TABLE;s.setSecurityCenterStateLoader({key:e,value:!0}),await Rn(),s.setSecurityCenterState({breachedPasswordUsersTable:zu}),s.setSecurityCenterStateLoader({key:e,value:!1})},s.loadUnenrolledMfaUsers=async()=>{const e=$r.UNENROLLED_MFA_USERS_TABLE;s.setSecurityCenterStateLoader({key:e,value:!0}),await Rn(),s.setSecurityCenterState({unenrolledMfaUsersTable:qu}),s.setSecurityCenterStateLoader({key:e,value:!1})},s.loadInactiveUsers=async()=>{const e=$r.INACTIVE_USERS_TABLE;s.setSecurityCenterStateLoader({key:e,value:!0}),await Rn(),s.setSecurityCenterState({inactiveUsersTable:Ku}),s.setSecurityCenterStateLoader({key:e,value:!1})},s.sendResetBreachedPasswordEmail=async e=>{const{callback:t}=e,a=$r.SEND_BREACHED_PASSWORD_EMAIL;s.setSecurityCenterStateLoader({key:a,value:!0}),await Rn(),null==t||t(!0),s.setSecurityCenterStateLoader({key:a,value:!1})},s})(e,t,a),U=((e,t,a)=>{const n=Jr(e,t,a),s=gu(n,["setSecurityPolicyState","setSecurityPolicyGlobalState","setSecurityPolicyPublicState","setSecurityPolicyMfaState","setSecurityPolicyVendorMfaState","setSecurityPolicyLockoutState","setSecurityPolicyVendorLockoutState","setSecurityPolicyCaptchaState","setSecurityPolicyPasswordHistoryState","setSecurityPolicyVendorPasswordHistoryState","resetSecurityPolicyState","setSecurityPolicyPasswordState","setSecurityPolicyAuthStrategyPublicState"]);return s.loadSecurityPolicy=async()=>{s.setSecurityPolicyGlobalState({loading:!0,error:null}),await Promise.all([s.loadSecurityPolicyMfa(),s.loadSecurityPolicyVendorMfa(),s.loadSecurityPolicyLockout(),s.loadSecurityPolicyVendorLockout(),s.loadSecurityPolicyPasswordHistory(),s.loadSecurityPolicyVendorPasswordHistory(),s.loadSecurityPolicyCaptcha()]),await Rn(),s.setSecurityPolicyGlobalState({policy:mu,loading:!1})},s.loadPublicSecurityPolicy=async()=>{s.setSecurityPolicyPublicState({loading:!0,error:null});try{s.setSecurityPolicyPublicState({policy:bu,loading:!1})}catch(e){s.setSecurityPolicyPublicState({error:Bn(e),loading:!1})}},s.saveSecurityPolicyMfa=async e=>{var t;const{callback:a}=e,n=f(e,ud);s.setSecurityPolicyMfaState({saving:!0,error:null});const i=S({},wu,{id:null!=(t=n.id)?t:wu.id,enforceMFAType:n.enforceMFAType});await Rn(),s.setSecurityPolicyMfaState({policy:i,saving:!1}),null==a||a(i)},s.loadSecurityPolicyMfa=async()=>{s.setSecurityPolicyMfaState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyMfaState({policy:Au,loading:!1})},s.loadSecurityPolicyVendorMfa=async()=>{s.setSecurityPolicyVendorMfaState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyVendorMfaState({policy:Au,loading:!1})},s.saveSecurityPolicyLockout=async e=>{const{callback:t}=e,a=f(e,dd);s.setSecurityPolicyLockoutState({saving:!0,error:null}),await Rn();const n=S({},wu,a,{id:a.id?a.id:wu.id});null==t||t(n),s.setSecurityPolicyLockoutState({policy:n,saving:!1})},s.loadSecurityPolicyLockout=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyLockoutState({policy:wu,loading:!1})},s.loadSecurityPolicyVendorLockout=async()=>{s.setSecurityPolicyVendorLockoutState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyVendorLockoutState({policy:wu,loading:!1})},s.loadSecurityPolicyCaptcha=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyLockoutState({policy:wu,loading:!1})},s.saveSecurityPolicyPasswordHistory=async e=>{const{callback:t}=e,a=f(e,gd);s.setSecurityPolicyPasswordHistoryState({saving:!0,error:null}),await Rn();const n=S({},Tu,a,{id:a.id?a.id:Tu.id});null==t||t(n),s.setSecurityPolicyPasswordHistoryState({policy:n,saving:!1})},s.loadSecurityPolicyPasswordHistory=async()=>{s.setSecurityPolicyPasswordHistoryState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyPasswordHistoryState({policy:Tu,loading:!1})},s.loadSecurityPolicyVendorPasswordHistory=async()=>{s.setSecurityPolicyVendorPasswordHistoryState({loading:!0,error:null}),await Rn(),s.setSecurityPolicyVendorPasswordHistoryState({policy:Tu,loading:!1})},s})(e,t,a),R=((e,t)=>{const a=al(e,t),n=gu(a,["setSessionsState","resetSessionsState"]);return n.loadUserSessions=async()=>{n.setSessionsState({loading:!0,error:null}),n.setSessionsState({sessions:xu,loading:!1})},n.deleteUserSession=async t=>{const{id:a}=t;n.setSessionsState({loading:!0,error:null});const s=e.auth.sessionsState.sessions.filter((e=>e.id!==a));n.setSessionsState({sessions:s,loading:!1})},n.deleteAllUserSessions=async()=>{n.setSessionsState({loading:!0,error:null});const e=xu.filter((e=>e.current));n.setSessionsState({sessions:e,loading:!1})},n})(e,t),L=((e,t,a)=>{const n=Zr(e,t,a),s=gu(n,["setSessionsPolicyState","resetSessionsPolicyState"]);return s.loadSessionsPolicy=async()=>{s.setSessionsPolicyState({loading:!0,error:null});const t=e.auth.sessionsPolicyState;s.setSessionsPolicyState(S({},t,{loading:!1}))},s.createOrUpdateSessionsPolicy=async e=>{const{callback:t}=e,a=f(e,pd);s.setSessionsPolicyState({loading:!0,error:null}),null==t||t(!0),s.setSessionsPolicyState({configurations:a,loading:!1})},s})(e,t,a),C=((e,t,a)=>{const n=ll(e,t,a);return gu(n,["setSignUpState","resetSignUpState","resetSignUpStateSoft"])})(e,t,a),D=((e,t)=>{const a=Sl(e,t);return gu(a,["setSmsState","resetSmsState"])})(e,t),N=((e,t,a)=>{const n=wl(e,t,a);return gu(n,["setSocialLoginsState","resetSocialLoginsState","setSocialLoginError"])})(e,t,a),M=((e,t,a)=>{const n=Ul(e,t,a),s=gu(n,["setSSOState","resetSSOState"]);return s.loadSSOConfigurations=async()=>{s.setSSOState({loading:!0}),await Rn(),s.setSSOState({samlConfiguration:Eu,loading:!1,firstLoad:!1})},s.saveSSOConfigurations=async e=>{var t,a;const{callback:n,samlVendor:i}=e,o=f(e,hd),r=Ou.samlConfiguration,l=S({},r,o);let c="saving";if((null==l?void 0:l.enabled)!==r.enabled&&(c="loading"),null==l||!l.domain)return void s.setSSOState({samlConfiguration:S({},r,l)});s.setSSOState({error:void 0,[c]:!0}),await Rn(),l.acsUrl=null==Pu||null==(t=Pu.configuration)?void 0:t.acsUrl,l.spEntityId=null==Pu||null==(a=Pu.configuration)?void 0:a.spEntityId;const u=Mn(l,["validated","generatedVerification","createdAt","updatedAt"]);(null==r?void 0:r.domain)!==(null==u?void 0:u.domain)&&(u.ssoEndpoint="",u.publicCertificate="",u.signRequest=!1),u.type=null==i?void 0:i.toLowerCase(),await Rn(),s.setSSOState({samlConfiguration:u,error:void 0,[c]:!1}),null==n||n(!0)},s.saveSSOConfigurationsFile=async t=>{const a="saving";s.setSSOState({error:void 0,[a]:!0});const n=S({},e.auth.ssoState.samlConfiguration,{enabled:!0},t[0]);s.setSSOState({samlConfiguration:n,error:void 0,[a]:!1})},s.validateSSODomain=async e=>{const{callback:t}=null!=e?e:{},a=Ou.samlConfiguration;s.setSSOState({error:void 0,saving:!0}),await Rn(),s.setSSOState({samlConfiguration:S({},a,{validated:!0}),error:void 0,saving:!1}),null==t||t(!0)},s.loadSSOAuthorizationRoles=async()=>{await Rn(),s.setSSOState({authorizationRoles:["1","2","3"],error:void 0})},s.updateSSOAuthorizationRoles=async e=>{const{callback:t,authorizationRoles:a}=e;s.setSSOState({error:void 0,saving:!0}),await Rn(),s.setSSOState({authorizationRoles:a,error:void 0,saving:!1}),null==t||t(!0)},s})(e,t,a),F=((e,t,a)=>{const n=Cl(e,t,a);return gu(n,["setStepUpState","resetStepUpState"])})(e,t,a),x=((e,t,a)=>{const n=Jl(e,t,a),s=gu(n,["setTeamState","resetTeamState","setTeamLoader","setTeamError","openAddUserDialog","closeAddUserDialog","openDeleteUserDialog","closeDeleteUserDialog"]);return s.loadUsersV2=async t=>{var a,n,i,o;const{silentLoading:r,callback:l}=t,c=e.auth.teamState,u=null!=(a=t.pageSize)?a:c.pageSize,d=null!=(n=t.pageOffset)?n:c.pageOffset,g=null!=(i=t.filter)?i:c.filterV2,p=null!=(o=t.sort)?o:c.sortV2;s.setTeamLoader({key:Us.USERS,value:!r}),s.setTeamState({pageSize:u,pageOffset:d,filterV2:g,sortV2:p}),await Rn(),s.setTeamState({users:Du,totalPages:2,totalItems:10,roles:Iu,permissions:ku}),s.setTeamLoader({key:Us.USERS,value:!1}),null==l||l(Du)},s.loadAllSubTenantsUsers=async t=>{var a,n,i,o,r;const{silentLoading:l,callback:c}=t,u=e.auth.teamState,d=null!=(a=t._limit)?a:u.allUsersQueryParams._limit,g=null!=(n=t._offset)?n:u.allUsersQueryParams._offset,p=null!=(i=t._filter)?i:u.allUsersQueryParams._filter,h=null!=(o=t._sortBy)?o:u.allUsersQueryParams._sortBy,y=null!=(r=t._order)?r:u.allUsersQueryParams._order;s.setTeamLoader({key:Us.USERS,value:!l}),s.setTeamState({allUsersQueryParams:{_limit:d,_offset:g,_filter:p,_sortBy:h,_order:y}}),await Rn(),s.setTeamState({allUsers:Mu,totalPages:2,totalItems:10,roles:Iu,permissions:ku}),s.setTeamLoader({key:Us.USERS,value:!1}),null==c||c(Mu)},s.loadRoles=async e=>{var t;s.setTeamLoader({key:Us.ROLES_AND_PERMISSIONS,value:!0}),await Rn(),s.setTeamState({roles:Iu,permissions:ku}),s.setTeamLoader({key:Us.ROLES_AND_PERMISSIONS,value:!0}),null==e||null==(t=e.callback)||t.call(e,{roles:Iu,permissions:ku})},s.addUser=async t=>{const{callback:a}=t,n=f(t,yd),i=e.auth.teamState;s.setTeamState({addUserDialogState:S({},i.addUserDialogState,{loading:!0})}),await Rn();const o=new Date,r=S({},Ru,{groups:[]},n,{id:`${ad()}`,temporaryExpirationDate:n.expirationInSeconds?new Date(o.setSeconds(o.getSeconds()+n.expirationInSeconds)):void 0});null==a||a(r),s.setTeamState({users:[r,...i.users],addUserDialogState:{open:!1,loading:!1}})},s.addUserToSubTenants=async t=>{const{callback:a}=t,n=f(t,vd),i=e.auth.teamState;s.setTeamState({addUserDialogState:S({},i.addUserDialogState,{loading:!0})}),await Rn();const o=S({},Ru,n,{id:`${ad()}`});s.setTeamState({users:[o,...i.users],addUserDialogState:{open:!1,loading:!1}}),null==a||a(null)},s.updateUser=async t=>{var a;const{callback:n}=t,i=f(t,Sd),{id:o}=i,r=e.auth.teamState,l=r.users.find((e=>e.id===i.id));s.setTeamLoader({key:Us.UPDATE_USER,value:o||""}),s.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!0})}),s.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!0}),users:r.users.map((e=>e.id===i.id?S({},e,i):e))}),l.roleIds.length>0&&0===(null==(a=i.roleIds)?void 0:a.length)&&(i.roleIds=[""]),await Rn();const c=S({},l,i);null==n||n(c),s.setTeamState({users:r.users.map((e=>e.id===c.id?S({},e,c,{createdAt:e.createdAt,customData:e.customData,lastLogin:e.lastLogin}):e))}),s.setTeamLoader({key:Us.UPDATE_USER,value:!1})},s.deleteUser=async t=>{const{callback:a}=t,n=f(t,fd),i=e.auth.teamState;s.setTeamState({deleteUserDialogState:S({},i.deleteUserDialogState,{loading:!0})}),await Rn(),null==a||a(!0),s.setTeamState({users:i.users.filter((e=>e.id!==n.userId)),deleteUserDialogState:{open:!1,loading:!1}})},s.updateUserExpirationTime=async t=>{const{callback:a}=t,n=f(t,md),i=e.auth.teamState;s.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!0});const o=new Date;s.setTeamState({users:i.users.map((e=>e.id===n.userId?S({},e,{temporaryExpirationDate:n.expirationInSeconds?new Date(o.setSeconds(o.getSeconds()+n.expirationInSeconds)):void 0}):e))}),await Rn(),null==a||a(!0),s.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.setUserAsPermanent=async t=>{const{callback:a}=t,n=f(t,bd),i=e.auth.teamState;s.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!0}),s.setTeamState({users:i.users.map((e=>e.id===n.userId?S({},e,{temporaryExpirationDate:void 0}):e))}),await Rn(),null==a||a(!0),s.setTeamLoader({key:Us.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.deleteUserFromSubTenants=async t=>{const{callback:a}=t,n=f(t,Ad),i=e.auth.teamState;s.setTeamState({deleteUserDialogState:S({},i.deleteUserDialogState,{loading:!0})}),await Rn(),null==a||a(!0),s.setTeamState({allUsers:i.allUsers.filter((e=>e.id!==n.userId)),deleteUserDialogState:{open:!1,loading:!1}})},s.resendActivationLink=async e=>{const{callback:t}=e,a=f(e,wd);s.setTeamLoader({key:Us.RESEND_ACTIVATE_LINK,value:a.userId}),await Rn(),null==t||t(!0),s.setTeamLoader({key:Us.RESEND_ACTIVATE_LINK,value:!1})},s.resendInvitationLink=async e=>{const{callback:t}=e,a=f(e,Td);s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:a.email}),await Rn(),null==t||t(!0),s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationEmail=async e=>{const{callback:t}=e,a=f(e,Ed);s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:a.email}),await Rn(),null==t||t(!0),s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationLinkToAllSubTenants=async e=>{const{callback:t}=e,a=f(e,Pd);s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:a.email}),await Rn(),null==t||t(!0),s.setTeamLoader({key:Us.RESEND_INVITATION_LINK,value:!1})},s})(e,t,a),$=((e,t,a)=>{const n=Ql(e,t,a),s=gu(n,["setTenantsState","resetTenantsState"]);return s.loadTenants=async()=>{s.setTenantsState({loading:!0}),s.setTenantsState({tenants:Fu,activeTenant:Fu[0],loading:!1})},s})(e,t,a),G=tc(e,t),j=((e,t)=>{const a=sc(e,t);return gu(a,["loadUserEmailPolicyState"])})(e,t),B={acceptInvitationActions:s,accountSettingsActions:i,unlockAccountActions:o,activateAccountActions:r,allAccountsActions:l,allAccountsDialogActions:c,apiTokensActions:u,applicationsActions:d,customLoginActions:g,entitlementsActions:p,forgotPasswordActions:h,passwordRotationActions:y,groupsActions:v,groupsDialogsActions:m,impersonateActions:b,loginActions:A,mfaActions:w,passkeysActions:T,profileActions:E,provisioningActions:P,resetPhoneNumberActions:I,restrictionsActions:O,rolesActions:k,securityCenterActions:_,securityPolicyActions:U,sessionsActions:R,sessionsPolicyActions:L,signUpActions:C,smsActions:D,socialLoginActions:N,ssoActions:M,stepUpActions:F,teamActions:x,tenantsActions:$,usernamesActions:G,usersEmailsPolicyActions:j},V=t=>{Object.keys(t).forEach((a=>{const n=a;Fn(e.auth[n])?Object.assign(e.auth[n],t[n]):e.auth[n]=t[n]}))};return{authActions:S({setState:V,setAuthState:V,setErrorByRequestName:t=>{let{requestName:a}=t,n=f(t,Id);e.auth.errorByRequest=S({},e.auth.errorByRequest,{[a]:S({},n,{isError:!0})})},resetAuthState:()=>{$n(e,["auth"],n)},setUser:e=>{V({user:e})}},s,i,r,o,l,c,u,d,g,p,h,y,v,m,b,A,w,T,E,P,I,O,k,_,U,R,L,C,D,N,M,F,x,$,G,j),authStateActions:B}})(e,t,a,n),o=((e,t,a)=>{const n=Sc(e,t,a);return gu(n,["setConnectivityState","resetConnectivityState","initData","resetConnectivityState","cleanWebhookTestData","cleanWebhookLogsData","cleanWebhookTestMessage","cleanError","cleanSlackData"])})(e,t,a),[r,l]=Md(e,t,a),c=((e,t,a)=>{const n=au(e,t,a),s=gu(n,["setVendorState","resetVendorState"]);return s.loadVendorPublicInfo=async()=>{try{s.setVendorState({whiteLabelMode:!1}),await Rn()}catch(e){console.error("failed to getVendorPublicInfo - ",e)}},s.loadVendorPublicConfiguration=s.loadVendorPublicInfo,s})(e,t,a);return{authActions:s,authStateActions:i,connectivityActions:o,subscriptionsActions:r,subscriptionsStateActions:l,vendorActions:c,auditsActions:Ud(e,t,a)}},xd=(e,t,a=!1,n,s,i=!1,o="path")=>$d({name:e.appName,context:e.context,storeHolder:t,previewMode:a,builderMode:i,urlStrategy:o,initialState:{root:S({},e),auth:S({},null==s?void 0:s.auth,n),connectivity:S({},null==s?void 0:s.connectivity),subscriptions:S({},null==s?void 0:s.subscriptions),vendor:S({},null==s?void 0:s.vendor),auditLogs:S({},null==s?void 0:s.auditLogs),audits:S({},null==s?void 0:s.audits)}}),$d=e=>{var t,a,n,s,i,o,r;const{storeHolder:l}=e;let c=l;if("undefined"==typeof window&&null==l)throw Error("createFronteggStore(initState, storeHolder) failed, storeHolder must not be null in Server-Side rendering");if(c||(c=window),c.store)return c.store;const u=e.name||"default",{context:d,previewMode:g=!1,builderMode:p=!1,urlStrategy:h="path"}=e,y=R.for(u);g||p||y.setContext(d),void 0===d.requestCredentials&&(d.requestCredentials="include");const v=cc(null==(t=e.initialState)?void 0:t.auth),m=gc(null==(a=e.initialState)?void 0:a.connectivity),b=Qc(null==(n=e.initialState)?void 0:n.subscriptions),A=tu(null==(s=e.initialState)?void 0:s.vendor),w=cu(null==(i=e.initialState)?void 0:i.auditLogs),T=(E=null==(o=e.initialState)?void 0:o.audits,cn(du,E));var E;const P=null==(r=e.initialState)?void 0:r.auth;P&&Object.keys(P).forEach((e=>{vn()(v,e,P[e],{merge:!0})}));const I=JSON.parse(JSON.stringify(v)),L=cn({root:{appName:u,context:d,urlStrategy:h,previewMode:g},auth:v,connectivity:m,subscriptions:b,vendor:A,auditLogs:w,audits:T});"undefined"!=typeof window&&window.localStorage&&"true"===window.localStorage.DEBUG_FRONTEGG_STORE&&function(e,t){"string"==typeof t&&(t={name:t});const a=t||{},{enabled:n,name:s=""}=a,i=f(a,_);let o;try{o=n&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!o)return;let r=!1;const l=o.connect(S({name:s},i));O(e,(t=>{const a=t.filter((([e,t])=>t[0]!==U)).map((([e,t])=>`${e}:${t.map(String).join(".")}`)).join(", ");if(a)if(r)r=!1;else{const t=Object.assign({},k(e));delete t[U],l.send({type:a,updatedAt:(new Date).toLocaleString()},t)}})),l.subscribe((t=>{var a,n;if("ACTION"===t.type&&t.payload)try{Object.assign(e,JSON.parse(t.payload))}catch(e){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",e)}if("DISPATCH"===t.type&&t.state){var s,i;if("JUMP_TO_ACTION"===(null==(s=t.payload)?void 0:s.type)||"JUMP_TO_STATE"===(null==(i=t.payload)?void 0:i.type)){r=!0;const a=JSON.parse(t.state);Object.assign(e,a)}e[U]=t}else if("DISPATCH"===t.type&&"COMMIT"===(null==(a=t.payload)?void 0:a.type))l.init(k(e));else if("DISPATCH"===t.type&&"IMPORT_STATE"===(null==(n=t.payload)?void 0:n.type)){var o,c;const a=null==(o=t.payload.nextLiftedState)?void 0:o.actionsById,n=(null==(c=t.payload.nextLiftedState)?void 0:c.computedStates)||[];r=!0,n.forEach((({state:t},n)=>{const s=a[n]||"No action found";Object.assign(e,t),0===n?l.init(k(e)):l.send(s,k(e))}))}}));l.init(k(e))}(L,{name:`${u} Store`,enabled:!0});const C={},D={};y.setContext(e.context),y.setAppName(u);const N=S({},sn(u),{fetch:new Ve(u)});if(e.previewMode||e.builderMode){const{authActions:t,authStateActions:a,connectivityActions:n,subscriptionsActions:s,subscriptionsStateActions:i,vendorActions:o,auditsActions:r}=Fd(L,N,D,I);C.auth=a,C.connectivity=n,C.subscriptions=i,C.vendor=o,C.auditLogs=r,C.audits={},Object.assign(D,S({},t,n,s,o,r));const l={dispatch:e=>{setTimeout((()=>{const[a,...i]=e.type.split("/"),r=i.join("/");"auth"===a&&"function"==typeof t[r]?t[r](e.payload):"connectivity"===a&&"function"==typeof n[r]?n[r](e.payload):"subscriptions"===a&&"function"==typeof s[r]?s[r](e.payload):"vendor"===a&&"function"==typeof o[r]&&o[r](e.payload)}))},getState:()=>L,subscribe:e=>O(L,e),subscribeStateChanged:e=>O(L,(()=>e(L))),store:L,actions:D,stateActions:C};return e.previewMode&&l.dispatch({type:"auth/requestAuthorize",payload:!0}),c&&(c.store=l),l}{const[e,t]=uc(L,N,D,I),a=Sc(L,N,D),[n,s]=Zc(L,N,D),i=au(L,N,D),o=uu(L,N,D),r=((e,t)=>{const a=()=>{e.audits.isLoading=!1},n=t=>{var a;e.audits.error=null!=(a=e.audits.error)?a:{},Object.assign(e.audits.error,{[t.name]:t.error})},s=t=>{e.audits.filters=t,e.audits.currentPage=0,e.audits.offset=0,e.audits.isLoading=!0},i=async()=>{const{sortBy:a,sortDirection:s}=e.audits;try{i=await t.audits.getAuditsStats({sortBy:a,sortDirection:s,count:20}),e.audits.error=void 0,e.audits.totalToday=i.totalToday,e.audits.severeThisWeek=i.severeThisWeek}catch(e){const t={name:"stats",error:e};console.error("failed to load stats - ",e),n(t)}var i},o=async()=>{try{a=await t.metadata.getAuditsMetadata(),e.audits.error={},e.audits.headerProps=a.properties,e.audits.themeAudits=a.theme?a.theme.styles:{}}catch(e){const t={name:"metadata",error:e};console.error("failed to load metadata - ",e),n(t)}var a},r=e=>e.reduce(((e,t)=>(e[t.key]=t.value,e)),{}),l=async s=>{const{filters:i,sortBy:o,sortDirection:l,filter:c,offset:u,virtualScroll:d}=e.audits,{appendMode:g=d,onlyOneLoad:p=!0,offset:h=0}=s||{},{rowsData:y}=g?e.audits:{rowsData:[]};try{const n=r(i),{data:s,total:g}=await t.audits.getAudits(S({},d&&{paginationMode:"virtual"},{sortDirection:l,sortBy:o,filter:c},n,{offset:d?y.length+h||y.length+u:h||u,count:20}));(t=>{e.audits.error={},e.audits.rowsData=t.rowsData,e.audits.lastUpdated=new Date,e.audits.total=t.total})({rowsData:[...y,...s],total:g}),p&&a()}catch(e){const t={name:"audits",error:e};console.error("failed to load audits - ",e),n(t)}};return{initData:async()=>{e.audits.isLoading=!0,await Promise.all([i(),o(),l({onlyOneLoad:!1})]),a()},loadAudits:l,removeFilter:async t=>{const{filters:a}=e.audits,n=a.findIndex((e=>e.key===t.key));if(n<0)return;const i=[...a.slice(0,n),...a.slice(n+1)];s(i)},filterData:async t=>{const{filters:a}=e.audits;let n=a.findIndex((e=>e.key===t.key));n<0&&(n=a.length);const i=[...a.slice(0,n),t,...a.slice(n+1)];s(i)},exportCSV:async()=>{const{filters:a,sortBy:n,sortDirection:s,filter:i,headerProps:o=[]}=e.audits,l=r(a);e.audits.isDownloadingCsv=!0;try{await t.audits.exportAudits(S({endpoint:"csv/v2",headerProps:o,sortDirection:s,sortBy:n,filter:i},l,{offset:0,outputFileName:"audits.csv"}))}catch(e){console.error("failed to export audits - ",e)}finally{e.audits.isDownloadingCsv=!1}}}})(L,N);return C.auth=t,C.connectivity=a,C.subscriptions=s,C.vendor=i,C.auditLogs=o,C.audits=r,Object.assign(D,S({},e,a,n,i,o)),{dispatch:t=>{const[s,...o]=t.type.split("/"),r=o.join("/");"auth"===s&&"function"==typeof e[r]?e[r](t.payload):"connectivity"===s&&"function"==typeof a[r]?a[r](t.payload):"subscriptions"===s&&"function"==typeof n[r]?n[r](t.payload):"vendor"===s&&"function"==typeof i[r]&&i[r](t.payload)},getState:()=>L,subscribe:e=>O(L,e),subscribeStateChanged:e=>O(L,(()=>e(L))),store:L,actions:D,stateActions:C}}};let Gd,jd,Bd,Vd,Wd,Hd,zd,Kd,qd,Jd,Yd,Xd,Qd,Zd;!function(e){e.phoneNumber="phoneNumber"}(Gd||(Gd={})),function(e){e.ALLOWED="allowedCountries",e.BLOCKED="blockedCountries"}(jd||(jd={})),function(e){e.Name="name",e.Username="username",e.PhoneNumber="phoneNumber",e.Address="address",e.JobTitle="jobTitle"}(Bd||(Bd={})),function(e){e.LoginSessions="loginSessions",e.Mfa="mfa"}(Vd||(Vd={})),function(e){e.Name="name",e.PhoneNumber="phoneNumber"}(Wd||(Wd={})),function(e){e.CompanyName="companyName",e.Address="address",e.Website="website",e.Timezone="timezone",e.Currency="currency"}(Hd||(Hd={})),function(e){e.User="user",e.Applications="applications",e.Groups="groups",e.Roles="roles",e.JoinedAt="joinedAt",e.LastSeen="lastSeen",e.ManagedBy="managedBy"}(zd||(zd={})),function(e){e.Invoices="invoices"}(Kd||(Kd={})),function(e){e.SessionManagement="sessionManagement",e.GeneralSettings="generalSettings",e.IpRestrictions="ipRestrictions",e.DomainRestrictions="domainRestrictions"}(qd||(qd={})),function(e){e.IdleSessionTimeout="idleSessionTimeout",e.ForceReLogin="forceReLogin",e.MaximumConcurrentSessions="maximumConcurrentSessions"}(Jd||(Jd={})),function(e){e.Mfa="mfa",e.UserLockout="userLockout",e.PasswordHistory="passwordHistory"}(Yd||(Yd={})),function(e){e.IpAddressRestrictions="ipAddressRestrictions"}(Xd||(Xd={})),function(e){e.RestrictSignupByEmailDomain="restrictSignupByEmailDomain"}(Qd||(Qd={})),function(e){e.Settings="settings",e.CustomLogin="customLogin"}(Zd||(Zd={}));const eg={hidden:"hidden",viewOnly:"viewOnly",edit:"edit"},tg={hidden:"hidden",edit:"edit"};function ag(e,t=0,a=1){return Math.min(Math.max(t,e),a)}function ng(e){if(e.type)return e;if("#"===e.charAt(0))return ng(function(e){e=e.substr(1);const t=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let a=e.match(t);return a&&1===a[0].length&&(a=a.map((e=>e+e))),a?`rgb${4===a.length?"a":""}(${a.map(((e,t)=>t<3?parseInt(e,16):Math.round(parseInt(e,16)/255*1e3)/1e3)).join(", ")})`:""}(e));const t=e.indexOf("("),a=e.substring(0,t);if(-1===["rgb","rgba","hsl","hsla","color"].indexOf(a))throw new Error("MUI: Unsupported `%s` color.\nThe following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color(). "+e);const n=e.substring(t+1,e.length-1);let s,i;if("color"===a){if(i=n.split(" "),s=i.shift(),4===i.length&&"/"===i[3].charAt(0)&&(i[3]=i[3].substr(1)),-1===["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].indexOf(s))throw new Error("MUI: unsupported `%s` color space.\nThe following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020."+s)}else i=n.split(",");return{type:a,values:i.map((e=>parseFloat(e))),colorSpace:s}}function sg(e){const{type:t,colorSpace:a}=e;let{values:n}=e;return-1!==t.indexOf("rgb")?n=n.map(((e,t)=>t<3?parseInt(e,10):e)):-1!==t.indexOf("hsl")&&(n[1]=`${n[1]}%`,n[2]=`${n[2]}%`),n=-1!==t.indexOf("color")?`${a} ${n.join(" ")}`:`${n.join(", ")}`,`${t}(${n})`}function ig(e){if(0===e.indexOf("#"))return e;const{values:t}=ng(e);return`#${t.map(((e,t)=>function(e){const t=e.toString(16);return 1===t.length?`0${t}`:t}(3===t?Math.round(255*e):e))).join("")}`}function og(e,t){return e=ng(e),t=ag(t),"rgb"!==e.type&&"hsl"!==e.type||(e.type+="a"),"color"===e.type?e.values[3]=`/${t}`:e.values[3]=t,sg(e)}function rg(e,t){if(e=ng(e),t=ag(t),-1!==e.type.indexOf("hsl"))e.values[2]*=1-t;else if(-1!==e.type.indexOf("rgb")||-1!==e.type.indexOf("color"))for(let a=0;a<3;a+=1)e.values[a]*=1-t;return sg(e)}function lg(e,t){if(e=ng(e),t=ag(t),-1!==e.type.indexOf("hsl"))e.values[2]+=(100-e.values[2])*t;else if(-1!==e.type.indexOf("rgb"))for(let a=0;a<3;a+=1)e.values[a]+=(255-e.values[a])*t;else if(-1!==e.type.indexOf("color"))for(let a=0;a<3;a+=1)e.values[a]+=(1-e.values[a])*t;return sg(e)}const cg=e=>{if(e)return{main:e,light:ig(lg(e,.4)),dark:ig(rg(e,.15)),hover:ig(rg(e,.15)),active:ig(rg(e,.2))}},ug=e=>{if(e)return{main:e,light:lg(e,.7),dark:rg(e,.2)}},dg=(e,t)=>{var a,n,s,i,o,r,l,c,u,d,g,p;return null!=e&&e.palette&&"string"==typeof(null==e||null==(a=e.palette)?void 0:a.primary)?S({},t,{palette:{primary:S({},cg(null==e||null==(n=e.palette)?void 0:n.primary),{contrastText:null!=(s=null==e||null==(i=e.palette)?void 0:i.primaryText)?s:"#000000"}),secondary:S({},cg(null==e||null==(o=e.palette)?void 0:o.secondary),{contrastText:null!=(r=null==e||null==(l=e.palette)?void 0:l.secondaryText)?r:"#000000"}),danger:S({},cg(null==e||null==(c=e.palette)?void 0:c.error),{contrastText:"#FFF"}),success:S({},ug(null==e||null==(u=e.palette)?void 0:u.success),{contrastText:"#FFF"}),error:S({},ug(null==e||null==(d=e.palette)?void 0:d.error),{contrastText:"#FFF"}),warning:S({},ug(null==e||null==(g=e.palette)?void 0:g.warning),{contrastText:"#FFF"}),info:S({},ug(null==e||null==(p=e.palette)?void 0:p.info),{contrastText:"#FFF"})}}):{}},gg={theme:{},themeV2:{},localizations:{},navigation:{usage:{visibility:"hidden",permissions:["fe.usage.read"],featureFlag:"fe-usage-page"},webhooks:{visibility:"hidden",permissions:["fe.connectivity.read.webhooks"]},roles:{visibility:"hidden",permissions:["fe.secure.read.roles"]},users:{visibility:"always",permissions:["fe.secure.read.users"],inviteDialog:{phoneNumberField:"optional"}},personalApiTokens:{visibility:"hidden",permissions:["fe.secure.read.userApiTokens"]},apiTokens:{visibility:"hidden",permissions:["fe.secure.read.tenantApiTokens"]},profile:{visibility:"always"},privacy:{visibility:"always"},account:{visibility:"always",permissions:["fe.secure.read.accountSettings"]},security:{visibility:"always",permissions:["fe.secure.read.securityPolicy"]},sso:{visibility:"hidden",permissions:["fe.secure.read.samlConfiguration"]},provisioning:{visibility:"hidden",permissions:["fe.secure.read.provisioningConfiguration"]},audits:{visibility:"always",permissions:["fe.secure.read.audits"]},subscriptions:{visibility:"hidden",permissions:["fe.subscriptions.*"]},allAccounts:{visibility:"byPermissions",permissions:["fe.account-hierarchy.read.subAccount"]},groups:{visibility:"hidden",permissions:["fe.secure.read.groups"]}}};class pg{constructor(){this._theme=gg.theme,this._themeV2=gg.themeV2,this._navigation=gg.navigation,this._localizations=gg.localizations,this._integrations=gg.integrations}static getInstance(e="default"){return this._instances[e]}static set(e,t="default"){const a=new pg;return a.set(e),pg._instances[t]=a,a}get theme(){var e;return null!=(e=this._theme)?e:{}}get themeV2(){var e;return null!=(e=this._themeV2)?e:{}}get navigation(){var e;return null!=(e=this._navigation)?e:{}}get localizations(){var e;return null!=(e=this._localizations)?e:{}}get integrations(){var e;return null!=(e=this._integrations)?e:{}}set(e){try{var t,a,n,s,i,o,r,l,c;this._navigation=ln().all([null!=(t=gg.navigation)?t:{},null!=(a=null==e?void 0:e.navigation)?a:{}]),this._theme=ln().all([null!=(n=gg.theme)?n:{},dg(null==e?void 0:e.theme,gg.theme)]),this._themeV2=ln().all([null!=(s=gg.themeV2)?s:{},null!=(i=null==e?void 0:e.themeV2)?i:{}]),this._localizations=ln().all([null!=(o=gg.localizations)?o:{},null!=(r=null==e?void 0:e.localizations)?r:{}]),this._integrations=ln().all([null!=(l=gg.integrations)?l:{},null!=(c=null==e?void 0:e.integrations)?c:{}])}catch(e){this._navigation=gg.navigation,this._theme=gg.theme,this._themeV2=gg.themeV2,this._localizations=gg.localizations,this._integrations=gg.integrations}}}pg._instances={};var hg=function(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map((function(e){return e.toLowerCase()})).join("")},yg=function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=document.createElement(t);return Object.keys(a).forEach((function(e){return n.setAttribute(e,a[e])})),e.appendChild(n),n},vg=function(e){return new Promise((function(t,a){var n=4e3,s=setInterval((function(){return null!=e.themeSetter?(clearInterval(s),void t(!0)):n<0?(a("Failed to load Renderer with themeSetter"),void clearInterval(s)):void(n-=50)}),50)}))},Sg=function(e){var t=e.toString();if(t){var a=new URL(window.location.href);a.search=t,window.history.pushState(null,"",a.toString())}};const fg="7.76.0";var mg={admin_portal_ip_restrictions:"on",admin_portal_domain_restrictions:"on","new-mfa-pages":"on","show-passkeys-new":"on","groups-admin-box-new":"on","msp-all-accounts-new":"on","temporary-users":"on"},bg=function(e){var t,a=pg.getInstance(e),n=null==a||null==(t=a.integrations)?void 0:t.gtm;null==n||n.filter((function(e){var t=e.id;return e.enabled&&/^GTM-[a-zA-Z0-9]+$/.test(t)})).forEach((function(e){var t=e.id,a=document.createElement("script");a.innerHTML="\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','".concat(t,"');\n "),document.body.appendChild(a)}))},Ag=function(){var e=p(y().mark((function e(t,a,n){var s,i,o,r;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==(s=t.metadataOverrides)?void 0:s.url){e.next=3;break}return e.abrupt("return",t);case 3:return e.prev=3,e.next=6,Cn((function(){return a.sendRequest({url:i,method:"GET",credentials:"omit"})}),n);case 6:if(!(o=e.sent)){e.next=10;break}return r=ln()(t,o),e.abrupt("return",r);case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(3),console.error("Failed to get metadata overrides",e.t0);case 15:return e.abrupt("return",t);case 16:case"end":return e.stop()}}),e,null,[[3,12]])})));return function(t,a,n){return e.apply(this,arguments)}}(),wg=function(){function a(e,t){var n,s,o,r=this,l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i(this,a),this.name=void 0,this.iframeRendering=void 0,this.options=void 0,this.loading=!0,this.cdnUrl="https://assets.frontegg.com/admin-box/".concat(fg),this.assetsUrl="https://adminBox.frontegg.com/admin-box/".concat(fg),this.customElementName="",this.adminPortalEl=void 0,this.adminPortalRenderer=void 0,this.loginBoxEl=void 0,this.checkoutDialogEl=void 0,this.checkoutDialogRenderer=void 0,this.adminPortalContainer=void 0,this.loginBoxContainer=void 0,this.checkoutDialogContainer=void 0,this.loginBoxRenderer=void 0,this.store=void 0,this.loadingListeners=[],this.fetchClient=void 0,this.apiClient=void 0,this.updateLocalizations=void 0,this.loadAdminBoxMetadata=p(y().mark((function e(){var t,a,n,s,i;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.options.metadata){e.next=21;break}return e.prev=1,e.next=4,Cn((function(){return r.fetchClient.get("/metadata",{entityName:"adminBox"})}),Un);case 4:return s=e.sent,i=null!=(t=null==s||null==(a=s.rows)||null==(n=a[0])?void 0:n.configuration)?t:{},e.prev=6,e.next=9,Ag(i,r.fetchClient,Un);case 9:r.options.metadata=e.sent,e.next=15;break;case 12:e.prev=12,e.t0=e.catch(6),console.error("failed to get admin portal overridden metadata",e.t0);case 15:e.next=21;break;case 17:e.prev=17,e.t1=e.catch(1),console.error("failed to get admin portal metadata",e.t1),r.dispatchErrorByRequestName(e.t1,Xn.LOAD_ADMIN_BOX_METADATA);case 21:pg.set(r.options.metadata,r.name);case 22:case"end":return e.stop()}}),e,null,[[1,17],[6,12]])}))),this.requestAuthorize=p(y().mark((function e(){var t,a,n;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=null==(t=r.options.authOptions)||null==(a=t.hostedLoginOptions)?void 0:a.loadUserOnFirstLoad,r.options.builderMode||"nextjs"===r.options.framework||(r.options.hostedLoginBox&&!r.options.customLoginBox?n&&r.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:{shouldRedirectToLogin:!1,firstTime:!0}}):r.store.dispatch({type:"auth/requestAuthorize",payload:!0}));case 2:case"end":return e.stop()}}),e)}))),this.loadFeatureFlags=p(y().mark((function e(){var t;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r.options.previewMode&&!r.options.builderMode){e.next=4;break}at.set(mg,r.name),e.next=16;break;case 4:return e.prev=4,e.next=7,Cn((function(){return r.apiClient.featureFlags.loadFeatureFlags()}),Un);case 7:t=e.sent,r.options.overrideFeatureFlags&&Object.assign(t,r.options.overrideFeatureFlags),at.set(t,r.name),e.next=16;break;case 12:e.prev=12,e.t0=e.catch(4),console.error("failed to get admin portal feature flags",e.t0),r.dispatchErrorByRequestName(e.t0,Xn.LOAD_FEATURE_FLAGS);case 16:case"end":return e.stop()}}),e,null,[[4,12]])}))),this.setFeatureFlagsForPreview=function(e){at.set(Object.assign({},mg,e),r.name)},this.queryFeatureFlags=function(e){return at.getFeatureFlags(e,r.name)},this.updateLocalizationsSetter=function(e){r.updateLocalizations=e},this.getEntitlementsFromStore=function(){var e;return null==(e=r.store.getState().auth.user)?void 0:e.entitlements},this.getUserFromStore=function(){return r.store.getState().auth.user},this.getEntitlementsQueryData=function(e){var t=r.getUserFromStore();return{entitlements:r.getEntitlementsFromStore(),attributes:{custom:e,jwt:t}}},this.renderUsersTable=function(){var e=p(y().mark((function e(t,a,n){var s;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=e.sent,e.abrupt("return",s.renderUsersTable(t,{injector:r,options:r.options,container:t,props:a,themeOptions:n.themeOptions}));case 4:case"end":return e.stop()}}),e)})));return function(t,a,n){return e.apply(this,arguments)}}(),this.renderInviteUserDialog=function(){var e=p(y().mark((function e(t,a,n){var s;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=e.sent,e.abrupt("return",s.renderInviteUserDialog(t,{injector:r,options:r.options,container:t,props:a,themeOptions:n.themeOptions}));case 4:case"end":return e.stop()}}),e)})));return function(t,a,n){return e.apply(this,arguments)}}(),this.renderChangePasswordForm=function(){var e=p(y().mark((function e(t,a,n){var s;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=e.sent,e.abrupt("return",s.renderChangePasswordForm(t,{injector:r,options:r.options,props:a,themeOptions:n.themeOptions}));case 4:case"end":return e.stop()}}),e)})));return function(t,a,n){return e.apply(this,arguments)}}(),this.renderProfilePage=function(){var e=p(y().mark((function e(t,a,n){var s;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=e.sent,e.abrupt("return",s.renderProfilePage(t,{injector:r,options:r.options,props:a,themeOptions:n.themeOptions,localizations:n.localizations}));case 4:case"end":return e.stop()}}),e)})));return function(t,a,n){return e.apply(this,arguments)}}(),this.renderEditEmailForm=function(){var e=p(y().mark((function e(t,a,n){var s;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=e.sent,e.abrupt("return",s.renderEditEmailForm(t,{injector:r,options:r.options,props:a,themeOptions:n.themeOptions,localizations:n.localizations}));case 4:case"end":return e.stop()}}),e)})));return function(t,a,n){return e.apply(this,arguments)}}(),this.getUsersTableStore=function(){var e=p(y().mark((function e(t){var a;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.loadScript("FronteggAdminPortal");case 2:return a=e.sent,e.abrupt("return",a.useUsersTableStore(t));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),this.getInviteUserDialogStore=function(){var e=p(y().mark((function e(t){var a;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.loadScript("FronteggAdminPortal");case 2:return a=e.sent,e.abrupt("return",a.useInviteUserDialogStore(t));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var d=hg(t),g="frontegg-app-".concat(d);this.iframeRendering=l,this.name=d,this.options=Object.assign({},e,{contextOptions:Object.assign({requestCredentials:"include"},e.contextOptions)}),this.fetchClient=new Ve(this.name),this.apiClient=sn(this.name),this.options.cdnUrl&&(this.cdnUrl=this.options.cdnUrl),this.options.assetsUrl&&(this.assetsUrl=this.options.assetsUrl),R.for(this.name).setCdnUrl(this.cdnUrl),R.for(this.name).setAssetsUrl(this.assetsUrl),this.customElementName=g;var h,v,S=this.options.authOptions?Object.assign({},this.options.authOptions,{hostedLoginBox:this.options.hostedLoginBox}):{hostedLoginBox:this.options.hostedLoginBox};if(S.onRedirectTo=e.onRedirectTo,S.disableSilentRefresh=null==(n=this.options.authOptions)?void 0:n.disableSilentRefresh,this.options.store){if(this.store=this.options.store,!u&&this.options.store.getState().root.appName!==t)throw Error("Mismatch in store names")}else this.store=$d({context:this.options.contextOptions,name:this.name,builderMode:this.options.builderMode,previewMode:this.options.previewMode,storeHolder:this,urlStrategy:this.options.urlStrategy,initialState:{auth:Object.assign({},S,null!=(h=this.options.authOptions)?h:{}),auditLogs:Object.assign({},null!=(v=this.options.auditsOptions)?v:{})}});c.setInstance(d,this);var f=R.for(d);f.setAppName(d),this.setEntitlementsOptions(e.entitlementsOptions),this.setSessionContext({enableSessionPerTenant:null==(s=e.authOptions)?void 0:s.enableSessionPerTenant,skipUserLoading:null==(o=e.authOptions)?void 0:o.skipUserLoading});var m=e.basename;m&&f.setBasename(m)}var n,o,r,u;return l(a,[{key:"setEntitlementsOptions",value:function(e){R.for(this.name).setEntitlementsOptions(Object.assign({},e))}},{key:"setSessionContext",value:function(e){R.for(this.name).setSessionContext(Object.assign({},e))}},{key:"dispatchErrorByRequestName",value:function(e,t){(null==e?void 0:e.statusCode)<500||this.store.dispatch({type:"auth/setErrorByRequestName",payload:{requestName:t,traceId:Nn(e)}})}},{key:"initContainers",value:(u=p(y().mark((function e(t){return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.adminPortalEl=t.adminPortalEl,this.loginBoxEl=t.loginBoxEl,this.checkoutDialogEl=t.checkoutDialogEl,this.adminPortalContainer=t.adminPortalContainer,this.loginBoxContainer=t.loginBoxContainer,this.checkoutDialogContainer=t.checkoutDialogContainer;try{"nextjs"!==this.options.framework&&document.body.classList.add("frontegg-loading")}catch(e){console.error("Failed to add frontegg-loading to body classList")}return e.next=9,Promise.all([this.loadFeatureFlags(),this.loadAdminBoxMetadata(),this.requestAuthorize()]);case 9:this.options.previewMode||this.options.customLoginBox||(this.loadLoginBox(),bg(this.name)),this.options.lazyLoadAdminPortal||this.loadScript("FronteggAdminPortal");case 11:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"updateMetadata",value:function(e){var t;pg.set(e,this.name),null!=e&&e.localizations&&(null==(t=this.updateLocalizations)||t.call(this,e.localizations))}},{key:"addOnLoadedListener",value:function(e){this.loading?this.loadingListeners.push(e):e()}},{key:"ready",value:function(e){this.loading?e():this.addOnLoadedListener(e)}},{key:"loginWithRedirect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/requestHostedLoginAuthorize",payload:e})}},{key:"loginWithRedirectV2",value:function(e){this.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:e})}},{key:"logout",value:function(e){this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/logout",payload:e})}},{key:"loadScript",value:function(a){var n=this;return new Promise((function(i,o){var r=window;if(r[a])i(r[a]);else{var l=document.createElement("script");l.src="".concat(n.cdnUrl,"/").concat({FronteggLoginBox:"login-box/index.js",FronteggAdminPortal:"admin-portal/index.js"}[a]),l.setAttribute("id","".concat(a,"Script")),l.setAttribute("cdn-url",n.cdnUrl),l.onload=function(){r["".concat(a,"Init")]?i(r["".concat(a,"Init")]({FronteggRestApi:e,FronteggTypes:s,FronteggReduxStore:t})):i(r[a])},l.onerror=function(e){console.log("Profile page error",e),o(e)},document.body.append(l)}}))}},{key:"loadLoginBox",value:(r=p(y().mark((function e(){return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.loadScript("FronteggLoginBox");case 2:e.sent.render(this.loginBoxEl,{injector:this,options:this.options}),this.loading=!1,this.loadingListeners.forEach((function(e){try{e()}catch(e){console.error("Failed to call loadLoginBoxListener",e)}})),this.loadingListeners=[];case 7:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"showAdminPortal",value:(o=p(y().mark((function e(t){var a,n,s,i,o;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=(null!=t?t:{isMultiApp:!1}).isMultiApp,n=this.queryFeatureFlags(["multi-apps-admin-portal"]),s=d(n,1),i=s[0],R.for(this.name).setRequestSource(Ge.AdminPortal),e.next=5,this.loadScript("FronteggAdminPortal");case 5:o=e.sent,this.adminPortalRenderer=o.render(this.adminPortalEl,{injector:this,options:Object.assign({isMultiApp:i&&a},this.options)});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"openHostedAdminPortal",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.options.contextOptions.baseUrl,a="".concat(t,"/oauth/portal");e?window.open(a,"_blank"):window.location.href=a}},{key:"hideAdminPortal",value:function(){try{var e,t=new URLSearchParams(window.location.search);null==(e=this.adminPortalRenderer)||e.unmount(),Sg(t),R.for(this.name).setRequestSource(null)}catch(e){console.error("Failed to unmount admin portal",e)}}},{key:"showCheckoutDialog",value:(n=p(y().mark((function e(t){var a;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.loadScript("FronteggAdminPortal");case 2:a=e.sent,this.checkoutDialogRenderer=a.renderCheckoutDialog(this.checkoutDialogEl,Object.assign({injector:this},t,{options:this.options}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"hideCheckoutDialog",value:function(){try{var e;null==(e=this.checkoutDialogRenderer)||e.unmount()}catch(e){console.error("Failed to unmount checkout dialog",e)}}},{key:"getFeatureEntitlements",value:function(e,t){var a=this.getEntitlementsQueryData(t),n=a.entitlements,s=a.attributes;return co(n,e,s)}},{key:"getPermissionEntitlements",value:function(e,t){var a=this.getEntitlementsQueryData(t),n=a.entitlements,s=a.attributes;return lo(n,e,s)}},{key:"getEntitlements",value:function(e,t){return"permissionKey"in e?this.getPermissionEntitlements(e.permissionKey,t):this.getFeatureEntitlements(e.featureKey,t)}},{key:"loadEntitlements",value:function(e){this.store.dispatch({type:"auth/loadEntitlements",payload:{callback:e}})}},{key:"stepUp",value:function(e){var t=this.store.getState(),a=(null==t?void 0:t.auth)||{},n=a.hostedLoginBox,s=a.routes.stepUpUrl;n?this.store.dispatch({type:"auth/stepUpHostedLogin",payload:e}):As(s,t.auth.onRedirectTo,null==e?void 0:e.maxAge)}},{key:"isSteppedUp",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=((null==(e=this.store.getState())?void 0:e.auth)||{}).user;return ms(a,t)}},{key:"switchTenant",value:function(e){this.store.dispatch({type:"auth/switchTenant",payload:e})}},{key:"close",value:function(){this.hideAdminPortal(),this.hideCheckoutDialog()}}]),a}(),Tg=function(){function e(){i(this,e)}return l(e,null,[{key:"setAuthentication",value:function(e,t,a){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"default",s=c.getInstance(n),i=R.for(n);e&&t?(i.setAccessToken(t),i.setUser(Object.assign({},a,{accessToken:t})),s.store.actions.setAuthState({isLoading:!1,isAuthenticated:e,user:a}),s.store.actions.loadTenants()):(i.setAccessToken(null),i.setUser(null),s.store.actions.setAuthState({isLoading:!1,isAuthenticated:!1,user:null}))}}]),e}(),Eg=function(){function e(){i(this,e)}return l(e,null,[{key:"show",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(e).showAdminPortal()}},{key:"showMultiApp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(e).showAdminPortal({isMultiApp:!0})}},{key:"openHosted",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";c.getInstance(t).openHostedAdminPortal(e)}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(e).hideAdminPortal()}}]),e}(),Pg=function(){function e(){i(this,e)}return l(e,null,[{key:"show",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";c.getInstance(t).showCheckoutDialog(e)}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(e).hideCheckoutDialog()}}]),e}(),Ig=function(e){var t;return null!=(t=window.FronteggAdminPortal.adminPortalStaticThemesDefaults[e])?t:void 0},Og=function(){function e(t,a,n,s){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];i(this,e),this.app=void 0,this.options=void 0,this.store=void 0,this.setRoute=function(){},this.themeSetter=void 0,this.themeOptions={};var r={baseUrl:"preview"};if(n){if(this.store=n,!o&&n.getState().root.appName!==t)throw Error("Mismatch in store names")}else this.store=xd({context:r,appName:t},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:a,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:r},s),this.app=new wg(this.options,t,!0),pg.set({},t)}var t;return l(e,[{key:"render",value:(t=p(y().mark((function e(t){var a,n,s,i,o=this;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(a=t.querySelector("#root"))||((a=t.ownerDocument.createElement("div")).setAttribute("id","root"),t.appendChild(a)),this.app.adminPortalContainer=t,this.app.adminPortalEl=a,n=function(e){o.themeSetter=e},s=function(e){o.setRoute=e},e.next=8,this.app.loadScript("FronteggAdminPortal");case 8:return i=e.sent,this.app.adminPortalRenderer=i.renderPage(a,{options:this.options,injector:this.app,setThemeSetter:n,setStaticRouteSetter:s}),this.app.loading=!1,e.next=13,vg(this);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"setStaticRoute",value:function(e){var t;null==(t=this.setRoute)||t.call(this,e)}},{key:"unmount",value:function(){try{var e;null==(e=this.app.adminPortalRenderer)||e.unmount()}catch(e){console.error("Failed to unmount admin Portal renderer",e)}}},{key:"setTheme",value:function(e){var t;this.themeOptions=e,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(t=this.themeSetter)||t.call(this,this.themeOptions)}}]),e}(),kg="modern",_g=function(e){var t,a=window.FronteggAdminPortal.themes;return null!=(t=a[e])?t:a[kg]},Ug=function(){function e(t,a,n,s){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];i(this,e),this.app=void 0,this.options=void 0,this.store=void 0,this.themeSetter=void 0,this.setRoute=function(){},this.themeOptions={};var r={baseUrl:"preview"};if(n){if(this.store=n,!o&&n.getState().root.appName!==t)throw Error("Mismatch in store names")}else this.store=xd({context:r,appName:t},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:a,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:r,onRedirectTo:function(){console.debug("path")}},s),this.app=new wg(this.options,t,!0,o),pg.set({},t)}var t;return l(e,[{key:"render",value:(t=p(y().mark((function e(t){var a,n,s,i,o=this;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(a=t.querySelector("#root"))||((a=t.ownerDocument.createElement("div")).setAttribute("id","root"),t.appendChild(a)),this.app.loginBoxContainer=t,this.app.loginBoxEl=a,n=function(e){o.themeSetter=e},s=function(e){o.setRoute=e},e.next=8,this.app.loadScript("FronteggLoginBox");case 8:return i=e.sent,this.app.loginBoxRenderer=i.renderPage(a,{options:this.options,injector:this.app,setThemeSetter:n,setStaticRouteSetter:s,staticRoute:"/account/login"}),e.next=12,vg(this);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"unmount",value:function(){try{var e;null==(e=this.app.loginBoxRenderer)||e.unmount()}catch(e){console.error("Failed to unmount login box renderer",e)}}},{key:"setTheme",value:function(e){var t;this.themeOptions=e,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(t=this.themeSetter)||t.call(this,this.themeOptions)}},{key:"setStaticRoute",value:function(e){var t;this.setRoute||console.warn("this.setRoute is not defined yet"),null==(t=this.setRoute)||t.call(this,e)}},{key:"setStore",value:function(e){this.store.dispatch({type:"auth/setState",payload:e})}}]),e}();function Rg(e,t){return Rg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Rg(e,t)}function Lg(e){return Lg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Lg(e)}function Cg(e,t,a){return Cg=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,a){var n=[null];n.push.apply(n,t);var s=new(Function.bind.apply(e,n));return a&&Rg(s,a.prototype),s},Cg.apply(null,arguments)}function Dg(e){var t="function"==typeof Map?new Map:void 0;return Dg=function(e){if(null===e||(a=e,-1===Function.toString.call(a).indexOf("[native code]")))return e;var a;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return Cg(e,arguments,Lg(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Rg(n,e)},Dg(e)}function Ng(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var a,n=Lg(e);if(t){var s=Lg(this).constructor;a=Reflect.construct(n,arguments,s)}else a=n.apply(this,arguments);return function(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,a)}}var Mg=function(e){var t=new wg(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default");if("undefined"!=typeof document){var a;if(!e.contextOptions.baseUrl){var n=new Error('Edit <FronteggProvider/> options { ContextOptions: { baseUrl: "" } } in order to connect your application');throw document.body.innerHTML="",alert(n.message),n}if(!customElements.get("frontegg-app")){var s=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Rg(e,t)}(n,t);var a=Ng(n);function n(){var e;i(this,n);for(var t=arguments.length,s=new Array(t),o=0;o<t;o++)s[o]=arguments[o];return(e=a.call.apply(a,[this].concat(s))).app=null,e}return l(n,[{key:"connectedCallback",value:function(){this.updateContent()}},{key:"attributeChangedCallback",value:function(e,t,a){if("app-name"===e){if(null===t)return;if(t===a)return;this.innerHTML="",null===a?this.remove():this.updateContent()}console.debug("attributeChangedCallback",e,t,a)}},{key:"updateContent",value:function(){var t,a=null!=(t=this.getAttribute("app-name"))?t:"default",n=c.getInstance(a);if(null===n)throw Error("FronteggApp not found for appName: '".concat(a,"'"));this.setAttribute("id","frontegg-app-".concat(n.name));var s=yg(this,"div",{id:"frontegg-admin-portal-container-".concat(n.name)}),i=yg(this,"div",{id:"frontegg-login-box-container-".concat(n.name)}),o=yg(this,"div",{id:"frontegg-checkout-dialog-container-".concat(n.name)}),r=s.attachShadow({mode:"open"}),l=e.iframeRendering?i:i.attachShadow({mode:"open"}),u=o.attachShadow({mode:"open"}),d=yg(r,"div",{id:"frontegg-admin-portal-".concat(n.name),class:"frontegg-root-content"}),g=yg(l,"div",{id:"frontegg-login-box-".concat(n.name),class:"frontegg-root-content"}),p=yg(u,"div",{id:"frontegg-checkout-dialog-".concat(n.name),class:"frontegg-root-content"});n.initContainers({adminPortalEl:d,loginBoxEl:g,adminPortalContainer:s,loginBoxContainer:i,checkoutDialogContainer:o,checkoutDialogEl:p})}}],[{key:"observedAttributes",get:function(){return["app-name"]}}]),n}(Dg(HTMLElement));customElements.define("frontegg-app",s)}null==(a=document.querySelector('frontegg-app[app-name="'.concat(t.name,'"]')))||a.remove();var o=document.createElement("frontegg-app");o.setAttribute("app-name",t.name),document.body.appendChild(o)}return t}})(),n})()));