@frontegg/js 7.76.0-alpha.0 → 7.76.0-alpha.1

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:()=>wg,AdminPortalRenderer:()=>Pg,AppHolder:()=>c,CheckoutDialog:()=>Tg,FronteggApp:()=>bg,HostedLogin:()=>Ag,LoginBoxRenderer:()=>kg,createElement:()=>pg,defaultTheme:()=>Og,formatName:()=>gg,getOverriddenMetadata:()=>mg,getThemeAdminByName:()=>Eg,getThemeByName:()=>Ig,initialize:()=>Dg,mockFlagsList:()=>Sg,restoreSearchParams:()=>yg,waitThemeSetter:()=>hg});var t={};a.r(t),a.d(t,{ApplicationAccessType:()=>tn,AuthStrategyEnum:()=>N,ContextHolder:()=>R,DirectoryApi:()=>ua,FRONTEGG_SEPARATE_TABS_BY_TENANT:()=>ne,FeatureFlags:()=>te,FeatureFlagsApi:()=>ee,FetchClient:()=>jt,FronteggApiError:()=>W,FronteggContext:()=>L,FronteggFrameworks:()=>$t,GENERIC_ERROR_CODE:()=>Mt,GENERIC_ERROR_MESSAGE:()=>Nt,GetUsersFilterPreset:()=>za,GroupManagedByEnum:()=>Wa,GroupRelations:()=>Va,ISubscriptionCancellationPolicy:()=>G,ISubscriptionStatus:()=>x,InsightCode:()=>Ya,LOAD_AUTHORIZATION_FF:()=>Xt,MFAStrategyEnum:()=>Yt,MachineToMachineAuthStrategy:()=>M,NotEntitledJustification:()=>qa,PaginationOrderEnum:()=>Gt,PaymentMethodType:()=>$,PermissionAssignmentTypeEnum:()=>La,ProviderType:()=>j,RecommendationActionKey:()=>Xa,RecommendationCode:()=>Ja,RecommendationSeverity:()=>Qa,RequestSource:()=>xt,RestrictionType:()=>Kt,ScimConnectionSource:()=>Ba,SecondaryAuthStrategy:()=>qt,SecurityCategory:()=>Za,SignUpStrategyEnum:()=>F,SocialLoginProviders:()=>D,SortByEnum:()=>Ha,SubAccountAccessTypeEnum:()=>Da,TenantSortByEnum:()=>Ra,TenantType:()=>Ca,UserManagedByEnum:()=>Ua,WebAuthnDeviceType:()=>Jt,api:()=>en,createApiClient:()=>an,default:()=>nn,fetch:()=>Bt,fronteggAuthApiRoutesRegex:()=>Na,fronteggEntitlementsV2Url:()=>ja,fronteggHeaders:()=>Ft,fronteggRefreshTokenUrl:()=>Ma,fronteggSilentRefreshTokenUrl:()=>Fa,fronteggTenantsUrl:()=>$a,fronteggTenantsV3Url:()=>Ga,fronteggUsersUrl:()=>xa,getCurrentUserTenantsFunction:()=>ue,getTabTenantFromSessionStorage:()=>ce,providersArray:()=>Ka,removeTabTenantFromSessionStorage:()=>le,setTabTenantInSessionStorage:()=>re});var e={};a.r(e),a.d(e,{ACR_VALUE:()=>yn,AMR_ADDITIONAL_VALUE:()=>Sn,AMR_MFA_VALUE:()=>vn,AcceptInvitationStep:()=>ln,ActivateAccountStep:()=>zn,AdminPortalPages:()=>Zn,AdminPortalPagesForEvents:()=>Qn,AllAccountsStateKeys:()=>Wo,ApiStateKeys:()=>Bs,AuthStrategyEnum:()=>N,AuthenticationTypes:()=>Xn,DEFAULT_RETRY_CONFIG:()=>kn,EditEmailView:()=>sc,FRONTEGG_AFTER_AUTH_REDIRECT_URL:()=>On,ForgotPasswordStep:()=>Qs,FronteggNativeModule:()=>v,GTMEventAction:()=>ts,GroupRelations:()=>ui,GroupsStateKeys:()=>ci,HOSTED_LOGIN_VERIFIER_KEY:()=>In,ImpersonateStep:()=>vi,LoginActionTypes:()=>Tn,LoginFlow:()=>An,LoginStep:()=>bn,MFAStep:()=>es,MachineToMachineAuthStrategy:()=>M,PasswordRotationStep:()=>ni,PaymentMethodType:()=>vc,PaymentProvider:()=>mc,QuickLoginStrategy:()=>wn,REQUEST_NAME:()=>Jn,ResetPhoneNumberStep:()=>dr,RolesStateKeys:()=>br,SHOULD_STEP_UP_KEY:()=>fn,SSOStateKeys:()=>uo,STEP_UP_MAX_AGE_PARAM_NAME:()=>mn,SamlVendors:()=>go,SecurityCenterStateKeys:()=>Fr,SignUpStage:()=>el,SubscriptionCancellationPolicy:()=>Ac,SubscriptionStatus:()=>bc,TENANT_ID_PARAM_KEY:()=>ls,TeamStateKeys:()=>ks,UserVerifiedOriginTypes:()=>Yn,authStrategyLoginStepMap:()=>En,base64ToFormData:()=>Li,base64urlDecode:()=>Ci,base64urlEncode:()=>Ri,buildAuditsActions:()=>lu,buildAuthActions:()=>lc,buildConnectivityActions:()=>yc,buildSubscriptionsActions:()=>Xc,buildVendorActions:()=>tu,createAuditsState:()=>ru,createAuthState:()=>rc,createConnectivityState:()=>uc,createFronteggStore:()=>Md,createProxy:()=>rn,createRandomString:()=>eo,createStore:()=>Fd,createSubscriptionsState:()=>Yc,createVendorState:()=>Zc,deepClone:()=>Mn,deepResetState:()=>Fn,defaultFronteggRoutes:()=>Pn,delay:()=>_n,errorHandler:()=>Gn,errorTraceId:()=>Ln,generateCodeChallenge:()=>to,generateCodeChallengeNative:()=>Zi,generateCodeChallengePureJs:()=>Qi,getBaseNameWithoutSlashSuffix:()=>ys,getEntitlements:()=>lo,getFeatureEntitlements:()=>ro,getMfaStepForEnrolledUsers:()=>us,getMfaStepForNotEnrolledUsers:()=>ds,getNumberOfMfaDevices:()=>cs,getPathAndSearchParamsFromUrl:()=>os,getPermissionEntitlements:()=>oo,getRedirectUrl:()=>ss,getSearchParam:()=>rs,getSearchParamsFromUrl:()=>is,getUri:()=>Ps,hmac:()=>Xi,isAbsoluteUrl:()=>ns,isAuthRoute:()=>Is,isEmailPayload:()=>ps,isEntitlementsDeeplyEqual:()=>co,isError:()=>$n,isFronteggApiError:()=>xn,isMfaRequired:()=>ws,isOauthCallbackRoute:()=>gs,isProxy:()=>Nn,isResetPasswordRequired:()=>Ts,isSteppedUp:()=>Ss,isUsernamePayload:()=>hs,mapMetaDataObjectToActions:()=>Es,omitProps:()=>Dn,prepareIdentifiersForSignup:()=>Os,publicKeyCredentialToJSON:()=>Di,readFileAsText:()=>Ni,redirectByStepUpUrl:()=>ms,reportGTMEvent:()=>as,retry:()=>Un,retryIfNeeded:()=>Rn,setAfterAuthRedirectUrlForStepUp:()=>fs,sha256:()=>Yi,shouldShowPasswordRotationPromptFunc:()=>vs,snapshot:()=>k,subscribe:()=>I,withRetryConfig:()=>Cn});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:()=>Xd,AccountPageFields:()=>Vd,COUNTRY_FILTER_TYPE:()=>$d,DomainRestrictionsTabFields:()=>Yd,GeneralSettingsTabFields:()=>qd,InviteUserModalFields:()=>Bd,IpRestrictionsTabFields:()=>Jd,Metadata:()=>dg,PrivacyPageFields:()=>jd,ProfilePageFields:()=>Gd,SecurityPageTabs:()=>zd,SessionManagementTabFields:()=>Kd,SignupFields:()=>xd,SubscriptionsPageFields:()=>Hd,UsersTableColumns:()=>Wd,alpha:()=>sg,fieldAppearance:()=>Qd,tabAppearance:()=>Zd});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;!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.ACTIVE="active",t.CANCELED="canceled",t.INCOMPLETE="incomplete",t.EXPIRED="expired",t.TRIALING="trialing",t.TRIAL_ENDED="trialEnded"}(x||(x={})),function(t){t.UNKNWON="unknown",t.CARD="card"}($||($={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}(G||(G={})),function(t){t.Stripe="Stripe"}(j||(j={})),function(t){t.CHANGE_TO_DEFAULT="change_to_default",t.RETAIN_TRIAL="retain_trial"}(B||(B={})),function(t){t.CREATE="create_customer"}(V||(V={}));class W 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 H={v1:{strategies:"/identity/resources/configurations/v1/sign-up/strategies"}},z={v1:"/identity/resources/users/webauthn/v1/devices"},K={v1:"/identity/resources/auth/v1",v2:"/identity/resources/auth/v2"},q={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"}}},J={v1:"/identity/resources/configurations/v1"},Y={emailDomain:{v1:"/identity/resources/configurations/restrictions/v1/email-domain"},ip:{v1:"/identity/resources/configurations/v1/restrictions/ip"}},X={v1:"/identity/resources/sso/v1",v2:"/identity/resources/sso/v2",custom:{v1:"/identity/resources/sso/custom/v1"}},Q={v1:"/identity/resources/permissions/v1"},Z={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"}},tt={v1:"/identity/resources/roles/v1",v2:"/identity/resources/roles/v2"},et={v1:"/identity/resources/sub-tenants/users/v1",v2:"/identity/resources/sub-tenants/users/v2"},at={v1:"/identity/resources/impersonation/v1"},nt={v1:"/identity/resources/applications/v1"},st={v1:"/identity/resources/groups/v1",configurations:{v1:"/identity/resources/groups/v1/config"},getByIds:{v1:"/identity/resources/groups/v1/bulkGet"}},it={v1:"/identity/resources/users/phone-numbers/v1"},ot={v1:"/identity/resources/usernames/v1"},rt={v1:"/team/resources/sso/v1",v2:"/team/resources/sso/v2"},lt={v1:"/team/resources/members/v1"},ct={v1:"/team/resources/roles/v1"},ut={v1:"/team/resources/stats/v1"},dt={v1:"/team/resources/profile"},gt={v1:"/tenants/resources/account-settings/v1"},pt={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"}},ht={v1:"/tenants/resources/sub-tenants/v1"},yt={v1:"/integrations/resources/configurations/v1",v2:"/integrations/resources/configurations/v2"},vt={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"}}}},St={v1:"/subscriptions/resources/payment-providers/v1"},ft={v1:"/subscriptions/resources/subscriptions/v1"},mt={v1:"/reports/resources/reports/v1",v2:"/reports/resources/reports/v2"},bt={v1:"/reports/engine/resources/triggers/v1"},At="/notification",wt="/audits",Tt={v1:"/event/resources/configurations/v1"},Et="/webhook",Pt="/oauth",Ot="/flags",It="/directory/resources/v1/configurations/scim2",kt="/directory/resources/scim/temp",_t="/entitlements/api/v2/user-entitlements",Ut={v1:"/security-center/resources/recommendations/v1"},Rt={v1:"/security-center/resources/insights/v1"},Ct="/applications/resources/applications/v1",Lt={v1:"/applications/resources/applications/tenant-assignments/v1"},Dt="http://localhost:3037/resources/velo/v1",Nt="We're facing some difficulties, Please try again",Mt="ER-ADMIN-PORTAL-GENERIC-ERROR",Ft={frameWork:"x-frontegg-framework",fronteggSdkVersion:"x-frontegg-sdk",contentType:"Content-Type",source:"frontegg-source",scopedTenant:"frontegg-scoped-tenant"};let xt,$t,Gt;!function(t){t.AdminPortal="admin-portal",t.LoginBox="login-box"}(xt||(xt={})),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"}($t||($t={})),function(t){t.ASC="ASC",t.DESC="DESC"}(Gt||(Gt={}));class jt{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=jt.getMetadataHeaders(n),i=await(null!=(e=null==n?void 0:n.tokenResolver)?e:a.getAccessToken)(),o=a.getRequestSource(),r=jt.getScopedTenant();t&&(s[Ft.contentType]=t),o&&(s[Ft.source]=o),i&&(s.Authorization=`Bearer ${i}`),r&&(s[Ft.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 W("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 W(n?t:Nt,u.status,this.getResponseTraceId(u),null!=(y=e)?y:Mt,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)=>jt.getBaseUrl(t,e,a),this.getContextBaseUrl=(t,e=!0)=>{const a=this.getFronteggContext().getContext();return this.getBaseUrl(a,t,e)},this.getMetadataHeaders=t=>jt.getMetadataHeaders(t),this.getContextMetadataHeaders=()=>{const t=this.getFronteggContext().getContext();return jt.getMetadataHeaders(t)},this.appName=t}}jt.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},jt.getMetadataHeaders=t=>{var e,a;const n={};return null!=t&&null!=(e=t.metadataHeaders)&&e.fronteggSdkVersion&&(n[Ft.fronteggSdkVersion]=t.metadataHeaders.fronteggSdkVersion),null!=t&&null!=(a=t.metadataHeaders)&&a.framework&&(n[Ft.frameWork]=t.metadataHeaders.framework),n},jt.getScopedTenant=()=>new URLSearchParams(window.location.search).get("tenantId")||null;const Bt=new jt("default");class Vt extends Error{constructor(t){super(t)}}const Wt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){const e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Vt("'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 Ht extends Error{constructor(t){super(t)}}const zt=(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(Wt(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 Wt(e)}})(t.split(".")[a]))}catch(t){throw new Ht("Invalid token specified: "+t.message)}};let Kt,qt,Jt,Yt;!function(t){t.ALLOW="ALLOW",t.BLOCK="BLOCK"}(Kt||(Kt={})),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"}(qt||(qt={})),function(t){t.Platform="Platform",t.CrossPlatform="CrossPlatform"}(Jt||(Jt={})),function(t){t.AuthenticatorApp="AuthenticatorApp",t.WebAuthnPlatform="WebAuthnPlatform",t.WebAuthnCrossPlatform="WebAuthnCrossPlatform",t.SMS="SMS",t.EmailCode="EmailCode"}(Yt||(Yt={}));const Xt="admin_portal_should_load_authorization";class Qt{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 jt(t)}}const Zt={flags:{}};class te{constructor(){var t;this._flags={},this._flags=null!=(t=Zt.flags)?t:{}}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new te;return a.set(t),te._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==Zt?void 0:Zt.flags)?e:{},null!=t?t:{})}}te._instances={};class ee extends Qt{constructor(t){super(t),this.loadFeatureFlags=async()=>this.get(Ot)}}const ae=new ee("default"),ne="FRONTEGG_SEPARATE_TABS_BY_TENANT",se="admin_portal_use_current_user_tenants_v1_endpoint";class ie extends Qt{constructor(t){super(t),this.GetUserJwt=async t=>this.post(`${q.v3}/me/token`,t),this.getUsersV2=async(t,e)=>this.get(q.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersV3=async(t,e)=>this.get(q.v3,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersRoles=async(t,e)=>this.get(q.roles.v3,S({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getUsersGroups=async(t,e)=>this.get(q.groups.v3,S({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getCurrentUserTenantsV3=async t=>this.get(q.tenants.me.v3,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getCurrentUserTenantsV1=async t=>this.get(q.tenants.me.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.sendResetBreachedPasswordEmails=async()=>this.post(q.passwords.resetBreachedPasswords.v1),this.updateUserProfileV2=async t=>this.put(`${q.v2}/me`,t),this.unlockMe=async t=>this.post(`${q.v3}/me/unlock`,t)}}const oe=new ie("default");function re(t){t&&sessionStorage.setItem(ne,t)}function le(){sessionStorage.removeItem(ne)}function ce(t){return R.for(t).isSessionPerTenantEnabled()?sessionStorage.getItem(ne):null}function ue(t){if(R.for(t).shouldSkipUserLoad())return async()=>({tenants:[],activeTenant:{}});const e=new ie(t),[a]=te.getFeatureFlags([se],t);return R.for(t).isSessionPerTenantEnabled()||a?e.getCurrentUserTenantsV1:e.getCurrentUserTenantsV3}class de extends Qt{constructor(t){super(t),this.switchTenant=async t=>(R.for(this.appName).isSessionPerTenantEnabled()&&re(t.tenantId),this.put(`${q.v1}/tenant`,t)),this.getTenants=async()=>this.get(`${q.v2}/me/tenants`),this.getSubTenants=async t=>this.get(pt.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getSubTenantsAsTree=async t=>this.get(pt.tree.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenants=async t=>this.get(pt.parents.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenantsById=async(t,e)=>this.get(`${pt.parents.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getTenantsUsersCount=async(t,e)=>this.post(`${Z.users.v1}/count`,t,{headers:this.extractHeadersFromOptions(e)}),this.searchSubTenants=async(t,e)=>this.get(pt.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getHierarchyMetadata=async(t,e)=>this.get(pt.metadata.v2,S({},t,{_tenantIds:t._tenantIds.join(",")}),{headers:this.extractHeadersFromOptions(e)})}}const ge=new de("default");class pe extends Qt{constructor(t){super(t),this.loadEntitlementsV2=async()=>this.get(_t)}}const he=new pe("default");class ye extends Qt{constructor(t){super(t),this.getGlobalSecurityPolicy=async()=>this.get(J.v1),this.getMfaPolicy=async()=>this.get(`${J.v1}/mfa-policy`),this.getVendorMfaPolicy=async()=>this.get(`${J.v1}/mfa-policy/vendor`),this.saveMfaPolicy=async t=>t.id?this.patch(`${J.v1}/mfa-policy`,t):this.post(`${J.v1}/mfa-policy`,t),this.getLockoutPolicy=async()=>this.get(`${J.v1}/lockout-policy`),this.getVendorLockoutPolicy=async()=>this.get(`${J.v1}/lockout-policy/vendor`),this.saveLockoutPolicy=async t=>t.id?this.patch(`${J.v1}/lockout-policy`,t):this.post(`${J.v1}/lockout-policy`,t),this.getCaptchaPolicy=async()=>{try{return await this.get(`${J.v1}/captcha-policy/public`)}catch{return null}},this.getPasswordHistoryPolicy=async()=>this.get(`${J.v1}/password-history-policy`),this.getVendorPasswordHistoryPolicy=async()=>this.get(`${J.v1}/password-history-policy/vendor`),this.savePasswordHistoryPolicy=async t=>t.id?this.patch(`${J.v1}/password-history-policy`,t):this.post(`${J.v1}/password-history-policy`,t),this.getPasswordRotationPolicy=async()=>{try{return await this.get(`${J.v1}/password-rotation`)}catch(t){return{}}},this.getVendorPasswordRotationPolicy=async()=>{try{return await this.get(`${J.v1}/password-rotation/vendor`)}catch(t){return{}}},this.savePasswordRotationPolicy=async t=>this.post(`${J.v1}/password-rotation`,t),this.getPasswordConfigPolicy=async()=>this.get(`${J.v1}/password`),this.getDomainRestrictions=async()=>this.get(`${Y.emailDomain.v1}`),this.getDomainRestrictionsConfig=async()=>this.get(`${Y.emailDomain.v1}/config`),this.createDomainRestriction=async t=>this.post(`${Y.emailDomain.v1}`,t),this.updateDomainRestrictionConfig=async t=>this.post(`${Y.emailDomain.v1}/config`,t),this.deleteDomainRestriction=async t=>this.delete(`${Y.emailDomain.v1}/${t}`),this.getIPRestrictions=async t=>this.get(`${Y.ip.v1}`,t),this.getIPRestrictionsConfig=async()=>this.get(`${Y.ip.v1}/config`),this.createIPRestriction=async t=>this.post(`${Y.ip.v1}`,t),this.bulkCreateIPRestriction=async t=>this.post(`${Y.ip.v1}/bulk`,t),this.updateIPRestrictionConfig=async t=>this.post(`${Y.ip.v1}/config`,t),this.deleteIPRestriction=async t=>this.delete(`${Y.ip.v1}/${t}`),this.testCurrentIp=async()=>this.post(`${Y.ip.v1}/verify`),this.testCurrentIpInAllowList=async()=>this.post(`${Y.ip.v1}/verify/allow`)}}const ve=new ye("default"),Se=["type"],fe=["type"],me=["type"];class be extends Qt{constructor(t){super(t),this.tenantsApi=new de(this.appName),this.entitlementsApi=new pe(this.appName),this.securityPolicy=new ye(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?zt(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?zt(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(),ue(this.appName)()]),i=S({},t,e?zt(e):{},n);return a.isSessionPerTenantEnabled()&&re(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?zt(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(),ue(this.appName)()]),s=t.id_token?zt(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()&&re(i.tenantId),e.setUser(i),{user:i,tenants:n.tenants,activeTenant:n.activeTenant}},this.preLogin=async t=>{try{const{address:e}=await this.post(`${K.v1}/user/saml/prelogin`,t);return e}catch{return null}},this.preLoginWithIdpType=async t=>this.post(`${K.v1}/user/saml/prelogin`,t),this.postLogin=async t=>{const e=await this.post(`${K.v1}/user/saml/postlogin`,t);return this.generateLoginResponse(e)},this.oidcPostLogin=async t=>{const e=await this.post(`${K.v1}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.login=async t=>{const e=await this.post(`${K.v1}/user`,t);return this.generateLoginResponse(e)},this.loginv2=async t=>{const e=await this.post(`${K.v1}/user`,t);return this.generateLoginResponseV3(e)},this.loginWithMfa=async t=>{const e=await this.post(`${K.v1}/user/mfa/verify`,t);return this.generateLoginResponse(e)},this.loginWithMfaV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/verify`,t);return this.generateLoginResponseV3(e)},this.activateAccount=async t=>this.post(`${q.v1}/activate`,t),this.activateAccountV2=async t=>{const e=await this.post(`${q.v1}/activate`,t);return this.generateLoginResponseV3(e)},this.activateAccountWithOTC=async t=>{const e=await this.post(`${q.v1}/activate/code`,t);return this.generateLoginResponseV3(e)},this.getActivateAccountStrategy=async t=>this.get(`${q.v1}/activate/strategy`,t),this.resendActivationEmail=async t=>this.post(`${q.v1}/activate/reset`,t),this.resendInvitationEmail=async t=>this.post(`${q.v1}/invitation/reset`,t),this.acceptInvitation=async t=>this.post(`${q.v1}/invitation/accept`,t),this.acceptInvitationWithOTC=async t=>this.post(`${q.v1}/invitation/accept/code`,t),this.refreshToken=async()=>{const t=ce(this.appName),e=await this.post(`${K.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponse(e)},this.refreshTokenV2=async()=>{const t=ce(this.appName),e=await this.post(`${K.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV2(e)},this.refreshTokenV3=async()=>{const t=ce(this.appName),e=await this.post(`${K.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV3(e)},this.logout=async()=>this.post(`${K.v1}/logout`),this.OAuthLogout=async t=>this.get(`${Pt}/logout`,t),this.forgotPassword=async t=>this.post(`${q.v1}/passwords/reset`,t),this.resetPassword=async t=>this.post(`${q.v1}/passwords/reset/verify`,t),this.loadPasswordConfig=async t=>this.get(`${q.v1}/passwords/config`,t),this.getSignUpStrategies=async()=>this.get(`${H.v1.strategies}`),this.recoverMfaToken=async t=>this.post(`${K.v1}/user/mfa/recover`,t),this.enrollMfa=async()=>this.post(`${q.v1}/mfa/enroll`),this.preEnrollMFAAuthenticatorApp=async()=>this.post(`${q.v1}/mfa/authenticator/enroll`),this.enrollMFAAuthenticatorApp=async t=>this.post(`${q.v1}/mfa/authenticator/enroll/verify`,t),this.preEnrollMFASMS=async t=>this.post(`${q.v1}/mfa/sms/enroll`,t),this.enrollMFASMS=async t=>this.post(`${q.v1}/mfa/sms/enroll/verify`,t),this.preEnrollMFAWebAuthn=async()=>this.post(`${q.v1}/mfa/webauthn/enroll`),this.enrollMFAWebAuthn=async t=>this.post(`${q.v1}/mfa/webauthn/enroll/verify`,t),this.verifyMfa=async t=>this.post(`${q.v1}/mfa/enroll/verify`,t),this.disableMfa=async t=>this.post(`${q.v1}/mfa/disable`,t),this.disableMFAAuthenticatorApp=async(t,e)=>this.post(`${q.v1}/mfa/authenticator/${t}/disable/verify`,e),this.preDisableMFASMS=async t=>this.post(`${q.v1}/mfa/sms/${t}/disable`),this.disableMFASMS=async(t,e)=>this.post(`${q.v1}/mfa/sms/${t}/disable/verify`,e),this.preDisableMFAWebAuthn=async t=>this.post(`${q.v1}/mfa/webauthn/${t}/disable`),this.disableMFAWebAuthn=async(t,e)=>this.post(`${q.v1}/mfa/webauthn/${t}/disable/verify`,e),this.getMFADevices=async()=>this.get(`${q.v1}/mfa/devices`),this.preEnrollMFAAuthenticatorAppForLogin=async t=>this.post(`${K.v1}/user/mfa/authenticator/enroll`,t),this.enrollMFAAuthenticatorAppForLogin=async t=>this.post(`${K.v1}/user/mfa/authenticator/enroll/verify`,t),this.enrollMFAAuthenticatorAppForLoginV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/authenticator/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.verifyMFAAuthenticatorAppForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/authenticator/${t}/verify`,e),this.preVerifyMFAEmailCode=async t=>this.post(`${K.v1}/user/mfa/emailcode`,t),this.verifyMFAEmailCode=async t=>this.post(`${K.v1}/user/mfa/emailcode/verify`,t),this.verifyMFAEmailCodeV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/emailcode/verify`,t);return this.generateLoginResponseV3(e)},this.preEnrollMFASMSForLogin=async t=>this.post(`${K.v1}/user/mfa/sms/enroll`,t),this.enrollMFASMSForLogin=async t=>this.post(`${K.v1}/user/mfa/sms/enroll/verify`,t),this.enrollMFASMSForLoginV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/sms/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFASMSForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/sms/${t}`,e),this.verifyMFASMSForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/sms/${t}/verify`,e),this.verifyMFASMSForLoginV2=async(t,e)=>{const a=await this.post(`${K.v1}/user/mfa/sms/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.preEnrollMFAWebAuthnForLogin=async t=>this.post(`${K.v1}/user/mfa/webauthn/enroll`,t),this.enrollMFAWebAuthnForLogin=async t=>this.post(`${K.v1}/user/mfa/webauthn/enroll/verify`,t),this.enrollMFAWebAuthnForLoginV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/webauthn/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/webauthn/${t}`,e),this.verifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/webauthn/${t}/verify`,e),this.verifyMFAWebAuthnForLoginV2=async(t,e)=>{const a=await this.post(`${K.v1}/user/mfa/webauthn/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.getSamlConfiguration=async()=>this.get(`${rt.v1}/saml/configurations`),this.updateSamlConfiguration=async t=>this.post(`${rt.v1}/saml/configurations`,t),this.getSamlVendorConfiguration=async()=>this.get(`${rt.v1}/saml/configurations/vendor-config`),this.updateSamlVendorMetadata=async t=>this.put(`${rt.v1}/saml/configurations/metadata`,t),this.validateSamlDomain=async()=>this.put(`${rt.v1}/saml/validations/domain`),this.getSamlRoles=async()=>this.get(`${rt.v1}/saml/configurations/roles/default`),this.getSamlRolesGroups=async()=>this.get(`${rt.v2}/saml/configurations/groups`),this.updateSamlRoles=async({roleIds:t})=>this.post(`${rt.v1}/saml/configurations/roles/default`,{roleIds:t}),this.createSamlGroup=async({roleIds:t,group:e})=>this.post(`${rt.v2}/saml/configurations/groups`,{group:e,roleIds:t}),this.updateSamlGroup=async({roleIds:t,group:e,id:a})=>this.patch(`${rt.v2}/saml/configurations/groups/${a}`,{group:e,roleIds:t}),this.deleteSamlGroup=async({id:t})=>this.delete(`${rt.v2}/saml/configurations/groups/${t}`),this.getOidcConfiguration=async()=>this.get(`${rt.v1}/oidc/configurations`),this.getSSOPublicConfiguration=async()=>this.get(`${rt.v2}/configurations/public`),this.getSocialLoginProviders=async()=>this.get(X.v1),this.getSocialLoginProvidersV2=async()=>this.get(X.v2),this.getSocialLoginProvidersV2ForAuthenticatedUser=async()=>this.get(`${X.v2}/authenticated`),this.getCustomSocialLoginProvidersV1=async()=>this.get(X.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(`${K.v1}/user/sso/${t.provider}/postlogin`,{metadata:t.metadata,invitationToken:t.invitationToken},{params:e})},this.getVendorConfig=async()=>this.get(`${J.v1}/public`),this.signUpUser=async t=>{const{shouldActivate:e,authResponse:a,userId:n,tenantId:s,activationToken:i}=await this.post(`${q.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(`${q.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(q.sessions.currentUser.v1),this.getCurrentUserSession=async()=>this.get(`${q.sessions.currentUser.v1}/current`),this.revokeSessionsForUser=async t=>this.post(`${q.sessions.v1}/revoke`,{userId:t}),this.getSessionConfigurations=async()=>this.get(q.sessions.configurations.v1),this.createOrUpdateSessionConfigrations=async t=>{await this.post(q.sessions.configurations.v1,t)},this.deleteSessionForUser=async t=>{await this.delete(`${q.sessions.currentUser.v1}/${t}`)},this.deleteAllSessionsForUser=async()=>{await this.delete(`${q.sessions.currentUser.v1}/all`)},this.getUserAccessTokensData=async()=>this.get(q.accessTokens.v1),this.getTenantAccessTokensData=async()=>this.get(Z.accessTokens.v1),this.deleteTenantAccessToken=async({id:t})=>{await this.delete(`${Z.accessTokens.v1}/${t}`)},this.deleteUserAccessToken=async({id:t})=>{await this.delete(`${q.accessTokens.v1}/${t}`)},this.createUserAccessToken=async t=>this.post(q.accessTokens.v1,t),this.createTenantAccessToken=async t=>this.post(Z.accessTokens.v1,t),this.getUserApiTokensData=async()=>this.get(q.apiTokens.v1),this.getTenantApiTokensData=async()=>this.get(Z.apiTokens.v1),this.updateUserApiTokensData=async t=>this.post(q.apiTokens.v1,t),this.updateTenantApiTokensData=async t=>this.post(Z.apiTokens.v2,t),this.deleteTenantApiToken=async({tokenId:t})=>{await this.delete(`${Z.apiTokens.v1}/${t}`)},this.deleteUserApiToken=async({tokenId:t})=>{await this.delete(`${q.apiTokens.v1}/${t}`)},this.getUserById=async({userId:t})=>this.get(`${q.v1}/${t}`),this.checkIfAllowToRememberMfaDevice=async t=>this.get(`${J.v1}/mfa-policy/allow-remember-device`,{mfaToken:t}),this.passwordlessPreLogin=async t=>{var e;let{type:a}=t,n=f(t,Se);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(`${K.v1}/passwordless/${s}/prelogin`,n)},this.passwordlessPostLoginV2=async t=>{let{type:e}=t,a=f(t,fe);const n=await this.post(`${K.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a);return this.generateLoginResponseV3(n)},this.passwordlessPostLogin=async t=>{let{type:e}=t,a=f(t,me);return this.post(`${K.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a)},this.verifyInviteToken=async({token:t})=>this.post(Z.invites.verify.v1,{token:t}),this.getSSOConfigurations=async()=>this.get(`${rt.v1}/configurations`),this.createSSOConfiguration=async t=>this.post(`${rt.v1}/configurations`,t),this.updateSSOConfiguration=async(t,e)=>this.patch(`${rt.v1}/configurations/${t}`,e),this.deleteSSOConfiguration=async t=>{await this.delete(`${rt.v1}/configurations/${t}`)},this.createSSOConfigurationByMetadata=async t=>this.post(`${rt.v1}/configurations/metadata`,t),this.updateSSOConfigurationByMetadata=async(t,e)=>this.put(`${rt.v1}/configurations/${t}/metadata`,e),this.createSSOConfigurationByMetadataUrl=async t=>this.post(`${rt.v1}/configurations/metadata-url`,t),this.updateSSOConfigurationByMetadataUrl=async(t,e)=>this.put(`${rt.v1}/configurations/${t}/metadata-url`,e),this.createSSODomain=async(t,e)=>this.post(`${rt.v1}/configurations/${t}/domains`,e),this.deleteSSODomain=async(t,e)=>this.delete(`${rt.v1}/configurations/${t}/domains/${e}`),this.validateSSODomain=async(t,e)=>this.put(`${rt.v1}/configurations/${t}/domains/${e}/validate`),this.validateSSODomainV2=async(t,e)=>this.put(`${rt.v2}/configurations/${t}/domains/${e}/validate`),this.getSSODefaultRoles=async t=>this.get(`${rt.v1}/configurations/${t}/roles`),this.setSSODefaultRoles=async(t,e)=>this.put(`${rt.v1}/configurations/${t}/roles`,e),this.createSSOGroup=async(t,e)=>this.post(`${rt.v1}/configurations/${t}/groups`,e),this.updateSSOGroup=async(t,{roleIds:e,group:a,id:n})=>this.patch(`${rt.v1}/configurations/${t}/groups/${n}`,{group:a,roleIds:e}),this.deleteSSOGroup=async(t,e)=>this.delete(`${rt.v1}/configurations/${t}/groups/${e}`),this.getSSOGroups=async t=>this.get(`${rt.v1}/configurations/${t}/groups`),this.preLoginV2=async t=>this.post(`${K.v2}/user/sso/prelogin`,t),this.oidcPostLoginV2=async t=>{const e=await this.post(`${K.v2}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.exchangeOAuthTokensV2=async t=>{const e=await this.post(`${Pt}/token`,t);return this.generateLoginResponseFromOAuthResponseV2(e)},this.silentOAuthRefreshTokenV2=async()=>{const t=ce(this.appName),e=await this.post(`${Pt}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponseV2(e)},this.exchangeOAuthTokens=async t=>{const e=await this.post(`${Pt}/token`,t);return this.generateLoginResponseFromOAuthResponse(e)},this.silentOAuthRefreshToken=async()=>{const t=ce(this.appName),e=await this.post(`${Pt}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponse(e)},this.resetPhoneNumber=async t=>this.post(`${q.v1}/phone/reset`,t),this.verifyResetPhoneNumber=async t=>this.post(`${q.v1}/phone/reset/verify`,t),this.changePhoneNumberWithVerification=async t=>this.post(`${q.v1}/phone`,t),this.verifyChangePhoneNumber=async t=>this.post(`${q.v1}/phone/verify`,t),this.changePhoneNumber=async t=>this.put(`${q.v1}/phone/change`,t),this.webAuthnPreLogin=async t=>this.post(`${K.v1}/webauthn/prelogin`,t),this.webAuthnPostLogin=async t=>this.post(`${K.v1}/webauthn/postlogin`,t),this.webAuthnPostLoginV2=async t=>{const e=await this.post(`${K.v1}/webauthn/postlogin`,t);return this.generateLoginResponseV3(e)},this.webAuthnCreateNewDeviceSession=async()=>this.post(z.v1),this.getWebAuthnDevices=async()=>this.get(z.v1),this.deleteWebAuthnDevice=async t=>this.delete(`${z.v1}/${t}`),this.verifyNewDeviceSession=async t=>this.post(`${z.v1}/verify`,t),this.getVendorPublicAuthStrategiesConfig=async()=>this.get(`${J.v1}/auth/strategies/public`),this.getPublicAuthStrategiesConfigForAuthenticatedUser=async()=>this.get(`${J.v1}/auth/strategies`),this.getMFAStrategiesConfig=async()=>this.get(`${J.v1}/mfa/strategies`),this.getUserAuthorization=async()=>this.get(`${q.authorization.v1}`),this.getMeV2=async()=>this.get(`${q.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=ce(this.appName);return s&&(e.tenantId=s),S({},e,null!=n?n:{},{entitlements:a})},this.generateStepupSession=async t=>{const e=await this.post(`${K.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]=te.getFeatureFlags([Xt],this.appName);return t}}const Ae=new be("default");class we extends Qt{constructor(t){super(t),this.getProfile=async t=>this.get(`${q.v2}/me`,null!=t?t:{addRoles:!0}),this.updateEmail=async t=>this.post(`${q.v1}/email/me`,{email:t}),this.verifyEmail=async(t,e)=>this.post(`${q.v1}/email/me/verify`,{email:t,code:e}),this.updateProfile=async t=>this.put(`${q.v2}/me`,t),this.updateProfileImage=async t=>this.put(`${dt.v1}/me/image/v1`,t,{responseType:"plain",contentType:void 0}),this.changePassword=async t=>this.post(`${q.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(lt.v1,S({pageOffset:t.pageOffset,pageSize:t.pageSize},r,l))},this.addUser=async t=>this.post(q.v2,S({},t,{provider:"local"})),this.deleteUser=async t=>this.delete(`${lt.v1}/${t.userId}`),this.updateUser=async t=>this.put(lt.v1,t),this.updateUserExpirationTime=async t=>{const{userId:e,expirationInSeconds:a}=t;return this.put(`${q.temporary.v1}/${e}`,{expirationInSeconds:a})},this.setPermanentUser=async t=>this.delete(`${q.temporary.v1}/${t}`),this.getTemporaryUserConfiguration=async()=>this.get(q.temporary.configuration.v1),this.createInviteUserLink=async t=>this.post(Z.invites.user.v1,S({},t)),this.updateInviteUserLink=async t=>this.patch(Z.invites.user.v1,S({},t)),this.deleteInviteUserLink=async()=>this.delete(Z.invites.user.v1),this.getInviteUserLink=async()=>this.get(Z.invites.user.v1),this.getInviteLinkConfiguration=async()=>this.get(Z.invites.configuration.v1),this.loadAvailableRoles=async()=>this.get(ct.v1),this.loadAvailablePermissions=async()=>this.get(Q.v1),this.loadStats=async()=>this.get(`${ut.v1}/members`),this.resendActivationLink=async t=>this.post(`${lt.v1}/${t.userId}/resendActivationEmail`,{}),this.resendInvitationLink=async t=>this.post(q.v2,S({},t,{provider:"local"})),this.resendInvitationLinkToAllTenants=async t=>this.post(q.invitation.resendAll.v1,S({},t)),this.disableUser=async t=>this.post(`${Z.users.v1}/${t}/disable`),this.enableUser=async t=>this.post(`${Z.users.v1}/${t}/enable`)}}const Te=new we("default");class Ee extends Qt{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 Pe=new Ee("default"),Oe=["dataFilters"],Ie=["templateId","dataFilters"],ke=["dataFilters"];class _e extends Qt{constructor(t){super(t),this.getReports=async t=>this.get(`${mt.v2}/tenant-reports`,t),this.getReport=async t=>this.get(`${mt.v2}/${t.id}/tenant-reports`),this.renderReport=async t=>{let{dataFilters:e}=t,a=f(t,Oe);return{html:await this.get(`${bt.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,Ie);return this.post(`${mt.v2}/${e}/tenant-reports`,S({},n,{dataFilters:btoa(JSON.stringify(a||{}))}))},this.downloadReport=async t=>{let{dataFilters:e}=t,a=f(t,ke);const n=await this.get(`${bt.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(`${bt.v1}/tenant-reports`,t)}}const Ue=new _e("default"),Re=["eventKey"],Ce=["eventKey"];class Le extends Qt{constructor(t){super(t),this.getSlackConfiguration=()=>this.get(`${yt.v1}/slack`),this.getSlackScope=()=>this.get(`${yt.v1}/slack/applications`),this.getSlackChannels=()=>this.get(`${yt.v1}/slack/channels`),this.postSlackConfiguration=t=>t.id?this.patch(`${yt.v1}/slack/subscription/${t.id}`,t):this.post(`${yt.v1}/slack/subscriptions`,t),this.deleteSlackConfiguration=t=>this.delete(`${yt.v1}/slack/subscriptions/${t.id}`),this.postSlackCode=t=>this.post(`${yt.v1}/slack/applications/registrations`,{code:t}),this.getEmailConfiguration=()=>this.get(`${yt.v1}/emails`),this.postEmailConfiguration=t=>{let{eventKey:e}=t,a=f(t,Re);return this.post(`${yt.v1}/emails/${e}`,a)},this.patchEmailConfiguration=({eventKey:t,enabled:e})=>this.patch(`${yt.v1}/emails/${t}`,{enabled:e}),this.deleteEmailSubscriptions=(t,e)=>this.delete(`${yt.v1}/emails/${t}/subscriptions/${e}`),this.putEmailSubscriptions=(t,e,a)=>this.put(`${yt.v1}/emails/${e}/subscriptions/${t}`,a),this.deleteEmailConfiguration=t=>this.delete(`${yt.v1}/emails/${t}`),this.getSMSConfiguration=()=>this.get(`${yt.v2}/sms`),this.postSMSConfiguration=t=>{let{eventKey:e}=t,a=f(t,Ce);return this.post(`${yt.v2}/sms/${e}`,a)},this.patchSMSConfiguration=({eventKey:t,enabled:e})=>this.patch(`${yt.v2}/sms/${t}`,{enabled:e}),this.deleteSMSSubscriptions=(t,e)=>this.delete(`${yt.v2}/sms/${t}/subscriptions/${e}`),this.putSMSSubscriptions=(t,e,a)=>this.put(`${yt.v2}/sms/${e}/subscriptions/${t}`,a),this.deleteSMSConfiguration=t=>this.delete(`${yt.v2}/sms/${t}`),this.getWebhooksConfigurations=()=>this.get(Et),this.postWebhooksConfiguration=t=>t._id?this.patch(`${Et}/${t._id}`,t):this.post(`${Et}/custom`,t),this.deleteWebhooksConfiguration=t=>this.delete(`${Et}/${t}`),this.getWebhookLog=(t,e=0,a=10)=>{const n=new URLSearchParams({id:t,offset:`${e}`,limit:`${a}`});return this.get(`${Et}/logs/?${n.toString()}`)},this.postWebhookTest=t=>this.post(`${Et}/test`,t),this.postWebhookRetry=t=>this.post(`${Et}/logs/${t}/retries`),this.getCategories=()=>this.get(`${Tt.v1}/categories`),this.getChannelMaps=t=>this.get(Tt.v1,{channels:t})}}const De=new Le("default");class Ne extends Qt{constructor(t){super(t),this.getNotifications=async t=>this.get(At,{params:t}),this.updateNotificationStatus=async t=>this.put(`${At}/status`,{params:t}),this.updateNotificationIsPinned=async t=>{const{notificationId:e,pinStatus:a}=t;return this.put(`${At}/${a}`,{notificationId:e})},this.markAllAsRead=async()=>this.post(`${At}/status/mark-all-read`)}}const Me=new Ne("default"),Fe=["endpoint","headerProps"];class xe extends Qt{constructor(t){super(t),this.getAudits=async t=>this.get(wt,t),this.getAuditsStats=async t=>this.get(`${wt}/stats`,t),this.exportAudits=async t=>{const{endpoint:e,headerProps:a}=t,n=f(t,Fe);return this.postDownload(`${wt}/export/${e}`,{properties:a},n)}}}const $e=new xe("default");class Ge extends Qt{constructor(t){super(t),this.updateSettings=async(t,e)=>this.put(gt.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.getSettings=async t=>this.get(gt.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getPublicSettings=async()=>this.get(`${gt.v1}/public`)}}const je=new Ge("default"),Be=["roleId"],Ve=["roleId"],We=["permissionId"];class He extends Qt{constructor(t){super(t),this.getRoles=async()=>this.get(tt.v1),this.addRole=async t=>this.post(tt.v1,t),this.deleteRole=async({roleId:t})=>this.delete(`${tt.v1}/${t}`),this.updateRole=async t=>{let{roleId:e}=t,a=f(t,Be);return this.patch(`${tt.v1}/${e}`,a)},this.attachPermissionsToRole=async t=>{let{roleId:e}=t,a=f(t,Ve);return this.put(`${tt.v1}/${e}/permissions`,a)},this.getPermissions=async()=>this.get(Q.v1),this.attachPermissionToRoles=async t=>{let{permissionId:e}=t,a=f(t,We);return this.put(`${Q.v1}/${e}/roles`,a)},this.getPermissionCategories=async()=>this.get(`${Q.v1}/categories`),this.addRoleV2=async t=>this.post(tt.v2,t)}}const ze=new He("default");class Ke extends Qt{constructor(...t){super(...t),this.getSubscriptionInvoices=async()=>this.get(vt.invoices.v1),this.getSubscriptionInvoice=async t=>this.get(`${vt.invoices.v1}/${t}`),this.getSubscriptionInvoicePdf=async(t,e)=>this.get(`${vt.invoices.v1}/${t}/pdf`,{outputFileName:e},{responseType:"blob"})}}class qe extends Qt{constructor(...t){super(...t),this.getManagedSubscription=async t=>this.get(`${ft.v1}/${t}`),this.getManagedSubscriptions=async()=>this.get(ft.v1),this.cancelManagedSubscription=async t=>this.put(`${ft.v1}/${t}/cancellations/`,{}),this.renewManagedSubscription=async t=>this.put(`${ft.v1}/${t}/renewals/`,{}),this.updateManagedSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${ft.v1}/${t}`,{paymentMethodId:e,planId:a})}}const Je=["email"];class Ye extends Qt{constructor(...t){super(...t),this.getPaymentMethods=async()=>this.get(vt.paymentMethods.v1),this.getPaymentMethod=async t=>this.get(`${vt.paymentMethods.v1}/${t}`),this.updatePaymentMethodBillingDetails=async(t,e)=>{let{email:a}=e,n=f(e,Je);return this.patch(`${vt.paymentMethods.v1}/${t}/billing-details`,{email:a,address:n})}}}class Xe extends Qt{constructor(...t){super(...t),this.getPaymentProviders=async()=>this.get(St.v1)}}class Qe extends Qt{constructor(...t){super(...t),this.getSubscriptionPlans=async()=>this.get(vt.plans.v1),this.getSubscriptionPlan=async t=>this.get(`${vt.plans.v1}/${t}`)}}class Ze extends Qt{constructor(...t){super(...t),this.getSubscriptions=async()=>this.get(vt.subscriptions.v1),this.getSubscription=async t=>this.get(`${vt.subscriptions.v1}/${t}`),this.cancelSubscription=async t=>this.put(`${vt.subscriptions.v1}/${t}/cancellations/`,{}),this.renewSubscription=async t=>this.put(`${vt.subscriptions.v1}/${t}/renewals/`,{}),this.updateSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${vt.subscriptions.v1}/${t}`,{paymentMethodId:e,planId:a})}}class ta extends Qt{constructor(...t){super(...t),this.getSubscriptionSummaries=async t=>this.get(`${vt.summaries.v1}/${t}`)}}class ea extends Qt{constructor(...t){super(...t),this.getTenantConfiguration=async t=>this.get(`${vt.tenantConfiguration.v1}/${t}`),this.createTenantConfiguration=async t=>this.post(vt.tenantConfiguration.v1,t)}}class aa extends Qt{constructor(...t){super(...t),this.getVendorPublicConfigurations=async()=>this.get(vt.configurations.vendorPublicConfigurations.v1)}}class na extends Qt{constructor(...t){super(...t),this.createSubscription=async t=>this.post(vt.paymentProviders.stripe.subscriptions.v1,t),this.getStripeCustomer=async t=>this.get(`${vt.paymentProviders.stripe.customers.v1}/${t}`),this.createStripeCustomer=async t=>this.post(vt.paymentProviders.stripe.customers.v1,t),this.getStripePaymentProviderConfiguration=async()=>this.get(vt.paymentProviders.stripe.publicConfigurations.v1),this.createStripePaymentMethodSetupIntentSecret=async t=>this.post(vt.paymentProviders.stripe.setupIntents.v1,t)}}class sa extends Qt{constructor(t){super(t),this.invoicesApi=new Ke(this.appName),this.managedSubscriptionApi=new qe(this.appName),this.paymentMethodsApi=new Ye(this.appName),this.paymentProvidersApi=new Xe(this.appName),this.plansApi=new Qe(this.appName),this.subscriptionApi=new Ze(this.appName),this.summariesApi=new ta(this.appName),this.subscriptionTenantConfigApi=new ea(this.appName),this.vendorPublicConfigApi=new aa(this.appName),this.stripeProviderApi=new na(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 ia=new sa("default");class oa extends Qt{constructor(t){super(t),this.getVendorPublicInfo=async()=>this.get("/vendors/public")}}const ra=new oa("default");class la extends Qt{constructor(t){super(t),this.loadAllUsers=async t=>this.get(et.v1,t),this.addUserToTenantAndSubTenants=async t=>this.post(et.v1,t),this.removeUserFromTenantAndSubTenants=async(t,e)=>this.delete(et.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.addUserRolesForSubTenants=async(t,e,a)=>this.post(`${et.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.removeUserRolesFromSubTenants=async(t,e,a)=>this.delete(`${et.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.setUserRolesForSubTenants=async(t,e,a)=>this.patch(`${et.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.createSubTenant=async(t,e)=>this.post(ht.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.deleteSubTenant=async(t,e)=>this.delete(`${ht.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.updateSubTenant=async({tenantId:t},e,a)=>this.patch(`${ht.v1}/${t}`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubTenantManagement=async({tenantId:t},e,a)=>this.put(`${ht.v1}/${t}/management`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubAccountAccess=async(t,e,a)=>this.put(`${et.v1}/${t}/access`,e,{headers:this.extractHeadersFromOptions(a)}),this.addUsersToSubTenant=async(t,e)=>this.post(`${et.v2}/`,t,{headers:this.extractHeadersFromOptions(e)})}updateSubTenantHierarchySettings({tenantId:t},e,a){return this.put(`${ht.v1}/${t}/hierarchy-settings`,e,{headers:this.extractHeadersFromOptions(a)})}}const ca=new la("default");class ua extends Qt{constructor(t){super(t),this.getConfigs=async()=>this.get(`${It}`),this.updateConfiguration=async(t,e)=>this.patch(`${It}/${t}`,e),this.createConfiguration=async t=>this.post(`${It}`,t),this.deleteConfiguration=async(t,e)=>this.delete(`${It}/${t}`,{deleteAll:e}),this.countConfigurationUsers=async t=>this.get(`${kt}/${t}/Users/count`)}}const da=new ua("default");class ga extends Qt{constructor(t){super(t),this.impersonate=async t=>this.post(`${at.v1}`,t)}}const pa=new ga("default"),ha=["groupId"];class ya extends Qt{constructor(t){super(t),this.getGroupById=async({groupId:t},e)=>this.get(`${st.v1}/${t}`,S({},e)),this.getGroups=async t=>this.get(`${st.v1}`,S({},t)),this.getGroupsByIds=async(t,e)=>this.post(`${st.getByIds.v1}`,t,{params:e}),this.createGroup=async t=>this.post(`${st.v1}`,t),this.updateGroup=async t=>{let{groupId:e}=t,a=f(t,ha);return this.patch(`${st.v1}/${e}`,a)},this.deleteGroup=async t=>this.delete(`${st.v1}/${t}`),this.addRolesToGroup=async(t,e)=>this.post(`${st.v1}/${t}/roles`,e),this.deleteRolesFromGroup=async(t,e)=>this.delete(`${st.v1}/${t}/roles`,e),this.addUsersToGroup=async(t,e)=>this.post(`${st.v1}/${t}/users`,e),this.deleteUsersFromGroup=async(t,e)=>this.delete(`${st.v1}/${t}/users`,e),this.getGroupConfiguration=async()=>this.get(`${st.configurations.v1}`),this.updateGroupConfiguration=async t=>this.post(`${st.configurations.v1}`,t)}}const va=new ya("default");class Sa extends Qt{constructor(t){super(t),this.getRecommendations=async()=>this.get(Ut.v1),this.getInsights=async()=>this.get(Rt.v1)}}const fa=new Sa("default");class ma extends Qt{constructor(t){super(t),this.getUserPhoneNumbers=async t=>this.get(`${it.v1}`,t),this.getUserOwnPhoneNumbers=async()=>this.get(`${it.v1}/me`),this.createPhoneNumber=async t=>this.post(`${it.v1}`,t),this.deletePhoneNumber=async t=>this.delete(`${it.v1}/${t}`),this.preVerifyPhoneNumber=async t=>this.post(`${it.v1}/preverify`,t),this.verifyPhoneNumber=async t=>this.post(`${it.v1}/verify`,t),this.verifyDeletePhoneNumber=async(t,e)=>this.post(`${it.v1}/${t}/delete/verify`,e)}}const ba=new ma("default");class Aa extends Qt{constructor(t){super(t),this.getUserApplicationsId=async({userId:t})=>this.get(`${nt.v1}/${t}/apps`),this.getUsersApplicationsId=async({userIds:t})=>this.get(`${nt.v1}/users-apps`,{userIds:t.join(",")}),this.getTenantsApplications=async()=>this.get(Lt.v1),this.getApplicationsData=async({appIds:t,includeFreeAccess:e=!0})=>this.get(Ct,{ids:t.join(","),_includeFreeAccess:e}),this.assignUserToApplications=async t=>this.post(`${nt.v1}/apps-user`,t),this.unassignUserFromApplications=async t=>this.delete(`${nt.v1}/user-apps`,t),this.getUsersOfApplications=async({appIds:t})=>this.get(`${nt.v1}/apps-users`,{appIds:t.join(",")})}}const wa=new Aa("default"),Ta={"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 Ea extends Qt{constructor(t){super(t),this.getAgentsConfig=async()=>this.get(`${Dt}/config`,void 0,{headers:Ta}),this.getConversations=async()=>this.get(`${Dt}/conversations`,void 0,{headers:Ta}),this.getConversationById=async t=>this.get(`${Dt}/conversation/${t.id}`,void 0,{headers:Ta}),this.createConversation=async t=>this.post(`${Dt}/conversations`,{message:t.message,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:Ta}),this.sendMessage=async t=>this.post(`${Dt}/conversation/${t.conversationId}/messages`,{message:t.message,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:Ta}),this.sendApiResponse=async t=>this.post(`${Dt}/conversation/${t.conversationId}/response/${t.callId}`,{data:t.data,status:t.status,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:Ta}),this.getConversationResource=async t=>this.get(`${Dt}/conversation/${t.conversationId}/resource/${t.resourceId}`,void 0,{headers:Ta})}}const Pa=new Ea("default");class Oa extends Qt{constructor(t){super(t),this.getUserOwnUsername=async()=>this.get(`${ot.v1}/me`),this.createUsername=async t=>this.post(`${ot.v1}`,t),this.deleteUsername=async t=>this.delete(`${ot.v1}/${t}`)}}const Ia=new Oa("default");class ka extends Qt{constructor(t){super(t),this.getUserEmailPolicyConfig=async()=>this.get(`${J.v1}/user-emails-policy`)}}const _a=new ka("default");let Ua,Ra,Ca,La,Da;!function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}(Ua||(Ua={})),function(t){t.createdAt="createdAt",t.name="name",t.tenantId="tenantId"}(Ra||(Ra={})),function(t){t.CUSTOMER="customer",t.SPAM="spam",t.TEST="test",t.RESELLER="reseller",t.HEADQUARTER="headquarter"}(Ca||(Ca={})),function(t){t.NEVER="NEVER",t.ALWAYS="ALWAYS",t.ASSIGNABLE="ASSIGNABLE"}(La||(La={})),function(t){t.DEFAULT_OFF="defaultOff",t.DEFAULT_ON="defaultOn",t.ALWAYS_ON="alwaysOn"}(Da||(Da={}));const Na=[/^(.*)\/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],Ma=`${K.v1}/user/token/refresh`,Fa=`${Pt}/authorize/silent`,xa=`${q.v2}/me`,$a=`${q.v2}/me/tenants`,Ga=`${q.v3}/me/tenants`,ja=_t;let Ba,Va,Wa,Ha,za;!function(t){t.FRONTEGG="frontegg",t.OKTA="okta",t.AZURE_AD="azure-ad",t.OTHER="other"}(Ba||(Ba={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(Va||(Va={})),function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}(Wa||(Wa={})),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"}(Ha||(Ha={})),function(t){t.MFA_UNENROLLED="mfa-unenrolled",t.BREACHED_PASSWORDS="breached-passwords",t.INACTIVE="inactive"}(za||(za={}));const Ka=["local","saml","google","github","facebook","microsoft","scim2","slack"];let qa,Ja,Ya,Xa,Qa,Za,tn;!function(t){t.MISSING_PERMISSION="MISSING_PERMISSION",t.MISSING_FEATURE="MISSING_FEATURE",t.BUNDLE_EXPIRED="BUNDLE_EXPIRED"}(qa||(qa={})),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"}(Ja||(Ja={})),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"}(Ya||(Ya={})),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"}(Xa||(Xa={})),function(t){t.SEVERE="SEVERE",t.WARNING="WARNING",t.INFO="INFO"}(Qa||(Qa={})),function(t){t.MFA="MFA",t.SESSIONS="SESSIONS",t.PASSWORD="PASSWORD",t.INACTIVITY="INACTIVITY",t.IP="IP",t.DOMAIN="DOMAIN",t.SSO="SSO"}(Za||(Za={})),function(t){t.FREE_ACCESS="FREE_ACCESS",t.MANAGED_ACCESS="MANAGED_ACCESS"}(tn||(tn={}));const en={auth:Ae,securityPolicy:ve,teams:Te,metadata:Pe,reports:Ue,connectivity:De,notifications:Me,audits:$e,tenants:ge,accountSettings:je,roles:ze,subscriptions:ia,vendor:ra,subTenants:ca,featureFlags:ae,directory:da,impersonate:pa,groups:va,users:oe,entitlements:he,securityCenter:fa,userPhoneNumbers:ba,applications:wa,velo:Pa,usernames:Ia,userEmailPolicy:_a},an=t=>({auth:new be(t),securityPolicy:new ye(t),teams:new we(t),metadata:new Ee(t),reports:new _e(t),connectivity:new Le(t),notifications:new Ne(t),audits:new xe(t),tenants:new de(t),accountSettings:new Ge(t),roles:new He(t),subscriptions:new sa(t),vendor:new oa(t),subTenants:new la(t),featureFlags:new ee(t),directory:new ua(t),impersonate:new ga(t),groups:new ya(t),users:new ie(t),entitlements:new pe(t),securityCenter:new Sa(t),userPhoneNumbers:new ma(t),applications:new Aa(t),velo:new Ea(t),usernames:new Oa(t),userEmailPolicy:new ka(t)}),nn={fetch:Bt,FetchClient:jt,ContextHolder:R,FronteggContext:L,api:en,createApiClient:an,FronteggApiError:W,AuthStrategyEnum:N,MachineToMachineAuthStrategy:M,SocialLoginProviders:D,ISubscriptionCancellationPolicy:G,ISubscriptionStatus:x,PaymentMethodType:$,ProviderType:j};var sn=a(2743),on=a.n(sn);const rn=(t,e)=>{const a=on()(t,S({},e));return function(t={}){return O(t)}(S({__isProxy:!0},a))};let ln;!function(t){t.validate="validate",t.invalid="invalid",t.pending="pending",t.success="success",t.failed="failed"}(ln||(ln={}));const cn={step:ln.validate},un=t=>rn(cn,t);var dn=a(5302),gn=a.n(dn),pn=a(1098),hn=a.n(pn);const yn="http://schemas.openid.net/pape/policies/2007/06/multi-factor",vn="mfa",Sn=["otp","sms","hwk"],fn="SHOULD_STEP_UP",mn="maxAge";let bn,An,wn,Tn;!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"}(bn||(bn={})),function(t){t.Login="login",t.RegisterQuickLogin="registerQuickLogin"}(An||(An={})),function(t){t.Internal="internal",t.UsbKey="usb-key",t.Android="android",t.Sms="sms"}(wn||(wn={})),function(t){t["social-login"]="social-login",t["custom-social-login"]="custom-social-login",t.direct="direct"}(Tn||(Tn={}));const En={[N.Code]:bn.loginWithOtc,[N.EmailAndPassword]:bn.loginWithPassword,[N.MagicLink]:bn.magicLinkPreLoginSuccess,[N.SmsCode]:bn.loginWithSmsOtc,[N.UsernameAndPassword]:bn.loginWithPassword,[N.UsernameAndMagicLink]:bn.magicLinkPreLoginSuccess,[N.UsernameAndCode]:bn.loginWithOtc,[N.UsernameAndSms]:bn.loginWithSmsOtc},Pn={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"},On="FRONTEGG_AFTER_AUTH_REDIRECT_URL",In="HOSTED_LOGIN_VERIFIER_KEY",kn={retryCount:3},_n=(t=500)=>new Promise((e=>{setTimeout(e,t)})),Un=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()},Rn=async(t,e)=>e?Un(t,e.retryCount,e.delay||500,e.shouldRetryWhenNull):t(),Cn=t=>S({},t,{retryConfig:kn}),Ln=t=>(null==t?void 0:t.traceId)||void 0;function Dn(t,e){const a=S({},t);return e.forEach((t=>{delete a[t]})),a}function Nn(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 Mn=t=>JSON.parse(JSON.stringify(t)),Fn=(t,e,a)=>{const n=Mn(a),s=gn()(t,e);for(const a in s)"__isProxy"!==a&&(a in n?hn()(t,[...e,a],n[a]):hn()(t,[...e,a],void 0))},xn=t=>Boolean(null==t?void 0:t.statusCode),$n=t=>t instanceof Error||(null==t?void 0:t.message)&&(null==t?void 0:t.stack)&&"Error"===(null==t?void 0:t.name),Gn=(t,e)=>t?xn(t)?(console.error(t.message),t):($n(t)?console.error(t.message):"string"==typeof t&&console.error(t),null!=e?e:new W(Nt,500,null,Mt)):e,jn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.acceptInvitationState,e)};return{setAcceptInvitationState:n,resetAcceptInvitationState:()=>{Fn(t,["auth","acceptInvitationState"],cn)},acceptInvitation:async t=>{if(t.token&&t.userId)try{n({error:void 0,step:ln.pending}),await e.auth.acceptInvitation(t),n({step:ln.success})}catch(t){n({step:ln.failed,error:Gn(t)})}else n({error:void 0,step:ln.invalid})},acceptInvitationWithOTC:async t=>{if(t.token&&t.userId&&t.code)try{n({error:void 0,step:ln.pending}),await e.auth.acceptInvitationWithOTC(t),n({step:ln.success})}catch(t){n({step:ln.validate,error:Gn(t)})}else n({error:void 0,step:ln.invalid})}}},Bn={loading:!1},Vn=t=>rn(Bn,t),Wn=["activeTenant","tenants"],Hn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.accountSettingsState,e)};return{setAccountSettingsState:n,resetAccountSettingsState:()=>{Fn(t,["auth","accountSettingsState"],Bn)},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,Wn),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:Gn(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 Rn((()=>e.accountSettings.getSettings()),null==t?void 0:t.retryConfig);n(S({},a,{loading:!1}))}catch(t){n({loading:!1,error:Gn(t)})}}}};let zn;!function(t){t.activating="activating",t.success="success",t.resend="resend",t.activatingForm="activatingForm"}(zn||(zn={}));const Kn={step:zn.activating,loading:!1,submitting:!1,resentEmail:!1,activationStrategy:{loading:!1}},qn=t=>rn(Kn,t);let Jn,Yn,Xn,Qn;!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"}(Jn||(Jn={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORDLESS="PASSWORDLESS",t.ACTIVATION_LINK="ACTIVATION_LINK"}(Yn||(Yn={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORD="PASSWORD",t.PHONE_NUMBER="PHONE_NUMBER"}(Xn||(Xn={})),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"}(Qn||(Qn={}));const Zn={profile:Qn.profile,privacy:Qn.privacy,personalApiTokens:Qn.personalApiTokens,account:Qn.account,users:Qn.users,groups:Qn.groups,security:Qn.security,sso:Qn.sso,audits:Qn.audits,webhooks:Qn.webhooks,apiTokens:Qn.apiTokens,roles:Qn.roles,subscriptions:Qn.subscriptions,allAccounts:Qn.allAccounts};let ts,es;function as(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"}(ts||(ts={})),function(t){t.verify="verify",t.recoveryCode="recoveryCode",t.authenticatorApp="authenticatorApp",t.smsSetPhoneNumber="smsSetPhoneNumber",t.smsVerifyCode="smsVerifyCode",t.emailVerifyCode="emailVerifyCode",t.noMFAEnrolledStepUp="noMFAEnrolledStepUp"}(es||(es={}));const ns=t=>{try{return new URL(t),!0}catch(t){return!1}},ss=({authenticatedUrl:t,enforceRedirectToSameSite:e,allowedRedirectOrigins:a,includeQueryParam:n})=>{let s=t;const i=new URL(window.location.href).searchParams.get("redirectUrl");return i?e&&ns(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},is=t=>{const{searchParams:e}=new URL(t),a=e.toString();if(a)return`?${a}`},os=(t,e=!1)=>{const{pathname:a,href:n}=new URL(t);if(e)return n;const s=is(t);return s?a+s:a},rs=t=>{const e=new URLSearchParams(window.location.search).get(t);return null!=e?e:void 0},ls="tenantId",cs=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}},us=t=>{const{numberOfPhoneDevices:e,numberOfAuthenticators:a,numberOfEmails:n,totalDevices:s}=cs(t);if(1===s){if(a)return es.authenticatorApp;if(e)return es.smsVerifyCode;if(n)return es.emailVerifyCode}return es.verify},ds=t=>{if(1===t.length){const[e]=t;if(e===Yt.AuthenticatorApp)return es.authenticatorApp;if(e===Yt.SMS)return es.smsSetPhoneNumber;if(e===Yt.EmailCode)return es.emailVerifyCode}return es.verify},gs=t=>"/oauth/callback"===t;function ps(t){return"email"in t&&"string"==typeof t.email}function hs(t){return"username"in t&&"string"==typeof t.username}const ys=t=>{const e=R.for(t.root.appName).getBasename();return null!=e&&e.endsWith("/")?e.slice(0,-1):e},vs=t=>void 0!==t.passwordExpiresIn&&void 0!==t.notificationPeriod&&t.passwordExpiresIn<=t.notificationPeriod,Ss=(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===yn,o=-1!==a.indexOf(vn),r=void 0!==Sn.find((t=>a.indexOf(t)));return i&&o&&r};function fs(){const t=window.location.pathname+window.location.search;window.localStorage.setItem(On,t)}const ms=(t,e,a)=>{fs();const n=new URLSearchParams(window.location.search);a&&n.set(mn,a.toString()),e(`${t}${n?`?${n}`:""}`,{refresh:!1})},bs=["phoneNumber","email"],As=["authenticatedUrl"],ws=(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)},Ts=(t,e)=>{const a=R.for(e);return t.resetPasswordToken?(a.setAccessToken(null),!0):(a.setAccessToken(t.accessToken),a.setUser(t),!1)},Es=(t,e=[])=>Object.entries(t).reduce(((t,[a,n])=>"object"==typeof n?[...t,...Es(n,[...e,a])]:[...t,{type:[...e,a].join("/"),payload:n}]),[]),Ps=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}},Os=t=>{const{phoneNumber:e,email:a}=t,n=f(t,bs);return null!=a&&a.length&&Object.assign(n,{email:a}),null!=e&&e.length&&Object.assign(n,{phoneNumber:e}),n},Is=(t,e)=>{const a=f(S({},Pn,e),As);return Object.values(a).includes(t)};let ks;!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"}(ks||(ks={}));const _s=["user"],Us=["callback","events"],Rs=["user"],Cs=["callback","events"],Ls=["user"],Ds=["callback"],Ns=["callback"],Ms=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.activateAccountState,e)},i=()=>{Fn(t,["auth","activateAccountState"],Kn)},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,_s);if(l.redirectLocation)window.location.href=l.redirectLocation;else if(ws(l,t.root.appName)){s({step:zn.success});const t=await n.getMfaRequiredState(l);n.setAuthState(t),await _n(1e3),o(r.loginUrl,{preserveQueryParams:!0})}else{var u;s({step:zn.success});const t={email:l.email,origin:Yn.ACTIVATION_LINK,id:l.id,tenantId:l.tenantId,name:l.name,createdAt:new Date};null==a||null==(u=a.userVerified)||u.call(a,t),as(ts.USER_VERIFIED,t),n.afterAuthenticationStateUpdate(S({user:l},c),{isAuthenticated:!0}),await _n(5e3),await n.afterAuthNavigation(),i()}};return{setActivateState:s,resetActivateState:i,setActivateStrategyState:o,activateAccount:async a=>{const{callback:n,events:i}=a,o=f(a,Us);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,Rs);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:Gn(t)})}},preActivateAccount:async a=>{const{userId:i,token:r}=a;s({loading:!0,step:zn.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:zn.activatingForm})}catch(t){s({loading:!1,error:Gn(t)})}},getActivateAccountStrategy:async t=>{const{callback:a}=t,n=f(t,Ds);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:Gn(t)})}},resendActivationEmail:async t=>{const{callback:a}=t,i=f(t,Ns);n.setTeamLoader({key:ks.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:Gn(t)}),null==a||a(null,t)}finally{n.setTeamLoader({key:ks.RESEND_ACTIVATE_LINK,value:!1})}},activateAccountWithCode: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.activateAccountWithOTC(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({submitting:!1,loading:!1,error:Gn(t),step:zn.activating})}}}},Fs={loading:!1,error:void 0,unlockAccountSuccess:!1},xs=t=>rn(Fs,t),$s=(t,e,a)=>{const n=e=>{Object.assign(t.auth.unlockAccountState,e)};return{setUnlockAccountState:n,resetUnlockAccountState:()=>{Fn(t,["auth","activateAccountState"],Fs)},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 _n(5e3),i(o.loginUrl)}catch(t){n({loading:!1,error:Gn(t)})}}}},Gs={apiTokenType:null,showAddTokenDialog:!1,createdByUserIdColumn:"show",deleteTokenDialog:{open:!1,clientId:""},successDialog:{open:!1,secret:"",clientId:""},loaders:{},apiTokensDataTenant:[],apiTokensDataUser:[],roles:[],permissions:[],errors:{}},js=t=>rn(Gs,t);let Bs;!function(t){t.LOAD_API_TOKENS="LOAD_API_TOKENS",t.ADD_API_TOKEN="ADD_API_TOKEN",t.DELETE_API_TOKEN="DELETE_API_TOKEN"}(Bs||(Bs={}));const Vs=(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:()=>{Fn(t,["auth","apiTokensState"],Gs)},loadApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Bs.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:Bs.LOAD_API_TOKENS,value:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var o;s({key:Bs.LOAD_API_TOKENS,value:Gn(e)}),n({key:Bs.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:Bs.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([Rn((()=>e.auth.getUserApiTokensData()),null==t?void 0:t.retryConfig),Rn((()=>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:Bs.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Bs.LOAD_API_TOKENS,value:Gn(e)}),n({key:Bs.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:Bs.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([Rn((()=>e.auth.getTenantApiTokensData()),null==t?void 0:t.retryConfig),Rn((()=>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:Bs.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Bs.LOAD_API_TOKENS,value:Gn(e)}),n({key:Bs.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=Bs.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 _n(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:Gn(t)}),null==c||c(null,t)}finally{n({key:u,value:!1})}},addUserApiToken:async a=>{const{description:o,expires:r,callback:l}=a,c=Bs.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 _n(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:Gn(t)}),null==l||l(null,t)}finally{n({key:c,value:!1})}},deleteUserApiToken:async a=>{const o=Bs.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:Gn(t)})}finally{n({key:o,value:!1})}},deleteTenantApiToken:async a=>{const o=Bs.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:Gn(t)})}finally{n({key:o,value:!1})}}}},Ws={loading:!0,fetching:!0,error:null,userApplications:[],accountApplications:[]},Hs=t=>rn(Ws,t),zs=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:[]},Ks=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.applicationsState,e)},i=async({userIds:t,retryConfig:a})=>{try{const n=await Rn((()=>e.applications.getUsersApplicationsId({userIds:t})),a),s=zs(n),i=await Rn((()=>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===tn.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:Gn(t)})}},o="Assignment action failed. Try again or contact support.";return{setApplicationsState:s,resetApplicationsState:()=>{Fn(t,["auth","applicationsState"],Ws)},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 Rn((()=>e.applications.getUserApplicationsId({userId:o})),r),c=await Rn((()=>e.applications.getApplicationsData({appIds:l})),r);s({userApplications:c,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Gn(t)})}},loadAccountApplications:async t=>{const a=null==t?void 0:t.retryConfig;s({loading:!0,fetching:!0});try{const t=await Rn((()=>e.applications.getTenantsApplications()),a),n=zs(t),i=await Rn((()=>e.applications.getApplicationsData({appIds:n})),a),o=await Rn((()=>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:Gn(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:Gn(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:Gn(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===tn.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}}},qs={loading:!0,error:null},Js=t=>rn(qs,t),Ys=["callback"],Xs=(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:()=>{Fn(t,["auth","customLoginState"],qs)},loadTenantMetadata:async()=>{s({loading:!0});try{const t=await e.metadata.getAdminBoxMetadata();s({tenantMetadata:t,loading:!1})}catch(t){s({loading:!1,error:Gn(t)})}},updateTenantMetadata:async t=>{const{callback:a}=t,n=f(t,Ys);try{s({error:null,saving:!0});const t=Es(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:Gn(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 Rn(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=is(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 Qs;!function(t){t.forgotPassword="forgotPassword",t.success="success"}(Qs||(Qs={}));const Zs={step:Qs.forgotPassword,loading:!1,email:"",passwordConfig:null},ti=t=>rn(Zs,t),ei=["callback"],ai=(t,e,a)=>{const n=e=>{Object.assign(t.auth.forgotPasswordState,e)};return{setForgotPasswordState:n,resetForgotPasswordState:()=>{Fn(t,["auth","forgotPasswordState"],Zs)},forgotPassword:async t=>{n({loading:!0});try{var a;await e.auth.forgotPassword(t),n({loading:!1,error:void 0,step:Qs.success}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;n({loading:!1,error:Gn(e,"Unknown error occurred")}),null==(s=t.callback)||s.call(t,!1,e)}},resetPassword:async t=>{const{callback:a}=t,s=f(t,ei);n({loading:!0});try{await e.auth.resetPassword(s),n({loading:!1,error:void 0,step:Qs.success}),null==a||a(!0)}catch(t){n({loading:!1,error:Gn(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:Gn(t)})}}}};let ni;!function(t){t.success="success",t.notification="notification"}(ni||(ni={}));const si={step:ni.notification},ii=t=>rn(si,t),oi=(t,e,a)=>({setStep:e=>{var a;a={step:e},Object.assign(t.auth.passwordRotationState,a)}}),ri={loaders:{},errors:{},groups:[],groupsConfiguration:{}},li=t=>rn(ri,t);let ci,ui;!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"}(ci||(ci={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(ui||(ui={}));const di=["roleIds","userIds"],gi=(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=ci.GET_GROUPS,r=t.auth.groupsState;n({key:o,value:!0});try{const{groups:t}=await Rn((()=>e.groups.getGroups({_groupsRelations:ui.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:Gn(t)})}finally{n({key:o,value:!1})}},r=async t=>{const a=ci.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:Gn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},l=async t=>{const a=ci.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:Gn(e)})}finally{n({key:a,value:!1})}},c=async t=>{const a=ci.GET_GROUP_CONFIGURATION;n({key:a,value:!0});try{const a=await Rn((()=>e.groups.getGroupConfiguration()),null==t?void 0:t.retryConfig);i({groupsConfiguration:a})}catch(t){s({key:a,value:Gn(t)})}finally{n({key:a,value:!1})}};return{setUsersGroupsLoader:n,setUsersGroupsError:s,setGroupsState:i,resetUsersGroupsState:()=>{Fn(t,["auth","groupsState"],ri)},loadGroups:o,getGroupById:async t=>{const a=ci.GET_GROUP;n({key:a,value:!0});try{const a=await e.groups.getGroupById({groupId:t.groupId},{_groupsRelations:ui.rolesAndUsers});i({selectedGroup:a})}catch(t){s({key:a,value:Gn(t)})}finally{n({key:a,value:!1})}},createGroup:async t=>{const a=ci.CREATE_GROUP,{roleIds:i,userIds:c}=t,u=f(t,di);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:Gn(e)}),null==t||null==(g=t.callback)||g.call(t,!1)}finally{n({key:a,value:!1})}},updateGroup:async t=>{const a=ci.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:Gn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},deleteGroup:async t=>{const a=ci.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:Gn(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=ci.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:Gn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},addUsersToGroup:l,deleteUsersFromGroup:async t=>{const a=ci.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:Gn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},getGroupConfiguration:c,updateGroupConfiguration:async t=>{const a=ci.UPDATE_GROUP_CONFIGURATION;n({key:a,value:!0});try{await e.groups.updateGroupConfiguration(t),await c()}catch(t){s({key:a,value:Gn(t)})}finally{n({key:a,value:!1})}},getTeamUsers:async t=>{const a=ci.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:Gn(t)})}finally{n({key:a,value:!1})}}}},pi={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}},hi=t=>rn(pi,t),yi=(t,e,a)=>({setGroupsDialogsState:e=>{Object.assign(t.auth.groupsDialogsState,e)},resetGroupsDialogsState:()=>{Fn(t,["auth","groupsDialogsState"],pi)},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 vi;!function(t){t.impersonating="impersonating",t.success="success"}(vi||(vi={}));const Si={step:vi.impersonating,loading:!1},fi=t=>rn(Si,t),mi=["callback","events"],bi=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.impersonateState,e)},i=()=>{Fn(t,["auth","impersonateState"],Si)};return{setImpersonateState:s,resetImpersonateState:i,impersonate:async t=>{const{callback:a}=t,o=f(t,mi);s({loading:!0});try{await e.impersonate.impersonate(o),s({step:vi.success}),await _n(1e3),await n.afterAuthNavigation({preventRedirectUrlOriginCleaning:!0}),i(),null==a||a(!0)}catch(t){s({loading:!1,error:Gn(t)})}}}},Ai={flow:An.Login,step:bn.preLogin,loading:!1,email:"",tenants:[]},wi=t=>rn(Ai,t),Ti=(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(On);t&&!ns(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(On);if(e&&!r)return os(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=ss({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(On)}await _n(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(fn),c=t.auth.user;var u;if(l&&(null==(u=window)||u.localStorage.removeItem(fn)),r&&l&&!Ss(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))}}},Ei=["callback"],Pi=["callback"],Oi=["callback"],Ii=["callback","deviceId"],ki=["callback","deviceId"],_i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Ui=new Uint8Array(256);for(let t=0;t<64;t++)Ui[_i.charCodeAt(t)]=t;const Ri=t=>{const e=new Uint8Array(t),a=e.length;let n,s="";for(n=0;n<a;n+=3)s+=_i[e[n]>>2],s+=_i[(3&e[n])<<4|e[n+1]>>4],s+=_i[(15&e[n+1])<<2|e[n+2]>>6],s+=_i[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},Ci=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=Ui[t.charCodeAt(n)],i=Ui[t.charCodeAt(n+1)],o=Ui[t.charCodeAt(n+2)],r=Ui[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 Li(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 Di=t=>{if(t instanceof Array){const e=[];for(const a of t)e.push(Di(a));return e}if(t instanceof ArrayBuffer)return Ri(t);if(t instanceof Object){const e={};for(const a in t)e[a]=Di(t[a]);return e}return t},Ni=t=>new Promise(((e,a)=>{const n=new FileReader;n.readAsText(t),n.onload=()=>e(n.result),n.onerror=a})),Mi=["callback","deviceId"],Fi=["callback","deviceId"],xi="input is invalid type",$i="undefined"!=typeof ArrayBuffer,Gi="0123456789abcdef".split(""),ji=[-2147483648,8388608,32768,128],Bi=[24,16,8,0],Vi=[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],Wi=["hex","array","digest","arrayBuffer"],Hi=[];Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),$i&&!ArrayBuffer.isView&&(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});const zi=function(t){return function(e){const a=new qi(!0).update(e);return null==a?void 0:a[t]()}},Ki=function(t){return function(e,a){const n=new Ji(e,!0).update(a);return null==n?void 0:n[t]()}};class qi{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=()=>qi.prototype.digest(),t?(Hi[0]=Hi[16]=Hi[1]=Hi[2]=Hi[3]=Hi[4]=Hi[5]=Hi[6]=Hi[7]=Hi[8]=Hi[9]=Hi[10]=Hi[11]=Hi[12]=Hi[13]=Hi[14]=Hi[15]=0,this.blocks=Hi):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(xi);if(null===t)throw new Error(xi);if($i&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||$i&&ArrayBuffer.isView(t)))throw new Error(xi);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]<<Bi[3&s++];else for(s=this.start;i<o&&s<64;++i)n=t.charCodeAt(i),n<128?r[s>>2]|=n<<Bi[3&s++]:n<2048?(r[s>>2]|=(192|n>>6)<<Bi[3&s++],r[s>>2]|=(128|63&n)<<Bi[3&s++]):n<55296||n>=57344?(r[s>>2]|=(224|n>>12)<<Bi[3&s++],r[s>>2]|=(128|n>>6&63)<<Bi[3&s++],r[s>>2]|=(128|63&n)<<Bi[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++i)),r[s>>2]|=(240|n>>18)<<Bi[3&s++],r[s>>2]|=(128|n>>12&63)<<Bi[3&s++],r[s>>2]|=(128|n>>6&63)<<Bi[3&s++],r[s>>2]|=(128|63&n)<<Bi[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]|=ji[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+Vi[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+Vi[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+Vi[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+Vi[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=Gi[t>>28&15]+Gi[t>>24&15]+Gi[t>>20&15]+Gi[t>>16&15]+Gi[t>>12&15]+Gi[t>>8&15]+Gi[t>>4&15]+Gi[15&t]+Gi[e>>28&15]+Gi[e>>24&15]+Gi[e>>20&15]+Gi[e>>16&15]+Gi[e>>12&15]+Gi[e>>8&15]+Gi[e>>4&15]+Gi[15&e]+Gi[a>>28&15]+Gi[a>>24&15]+Gi[a>>20&15]+Gi[a>>16&15]+Gi[a>>12&15]+Gi[a>>8&15]+Gi[a>>4&15]+Gi[15&a]+Gi[n>>28&15]+Gi[n>>24&15]+Gi[n>>20&15]+Gi[n>>16&15]+Gi[n>>12&15]+Gi[n>>8&15]+Gi[n>>4&15]+Gi[15&n]+Gi[s>>28&15]+Gi[s>>24&15]+Gi[s>>20&15]+Gi[s>>16&15]+Gi[s>>12&15]+Gi[s>>8&15]+Gi[s>>4&15]+Gi[15&s]+Gi[i>>28&15]+Gi[i>>24&15]+Gi[i>>20&15]+Gi[i>>16&15]+Gi[i>>12&15]+Gi[i>>8&15]+Gi[i>>4&15]+Gi[15&i]+Gi[o>>28&15]+Gi[o>>24&15]+Gi[o>>20&15]+Gi[o>>16&15]+Gi[o>>12&15]+Gi[o>>8&15]+Gi[o>>4&15]+Gi[15&o];return l+=Gi[r>>28&15]+Gi[r>>24&15]+Gi[r>>20&15]+Gi[r>>16&15]+Gi[r>>12&15]+Gi[r>>8&15]+Gi[r>>4&15]+Gi[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 Ji extends qi{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(xi);if(null===t)throw new Error(xi);if($i&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||$i&&ArrayBuffer.isView(t)))throw new Error(xi)}var s;t.length>64&&(t=null==(s=new qi(!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}qi.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();qi.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),qi.prototype.finalize.call(this)}}}const Yi=function(){const t=zi("hex");t.create=function(){return new qi},t.update=function(e){return t.create().update(e)};for(let e=0;e<Wi.length;++e){const a=Wi[e];t[a]=zi(a)}return t}(),Xi=function(){const t=Ki("hex");t.create=function(t){return new Ji(t)},t.update=function(e,a){return t.create(e).update(a)};for(let e=0;e<Wi.length;++e){const a=Wi[e];t[a]=Ki(a)}return t}();async function Qi(t){const e=Yi.digest((new TextEncoder).encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function Zi(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 to(t){var e,a;return null!=(e=window.crypto)&&null!=(a=e.subtle)&&a.digest?Zi(t):(console.warn("Generating CodeChallenge in non-secure domain:",window.location.origin),Qi(t))}function eo(t=16){let e="";for(let a=0;a<t;a++)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return e}var ao=a(8792),no=a.n(ao),so=a(5875);const io=(t="default")=>{if(!R.for(t).shouldLoadEntitlements())throw new Error("You must first enable entitlements via Frontegg options to use this function")},oo=(t,e,a,n,s="default")=>(io(s),(0,so.Me)(e,t,a)),ro=(t,e,a,n,s="default")=>(io(s),(0,so.a_)(e,t,a)),lo=(t,e,a,n,s="default")=>"permissionKey"in e?oo(t,e.permissionKey,a,n,s):ro(t,e.featureKey,a,n,s);function co(t,e){return no()(t,e)}let uo,go;!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"}(uo||(uo={})),function(t){t.Saml="saml",t.Okta="okta",t.Azure="azure",t.Google="google",t.Oidc="oidc"}(go||(go={}));const po=["callback","error"],ho=["callback"],yo=["callback"],vo=["callback"],So=["callback"],fo=["callback","events"],mo=["callback"],bo=["callback"],Ao=["user"],wo=["callback"],To=["callback"],Eo=["callback"],Po=["callback"],Oo=["callback"],Io=["callback"],ko=(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(ws(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?An.RegisterQuickLogin:An.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 co(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 Rn(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 Rn(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=>Cn({callback:(e,a)=>{!a||a.statusCode<500||n.setErrorByRequestName({requestName:t,traceId:Ln(a)})}}),p=async e=>{let{callback:a,error:s}=e,i=f(e,po);const o=t.auth.securityPolicyState.publicPolicy.policy;if(null==o||!o.authStrategy)return n.setLoginState({step:bn.loginWithPassword,loading:!1}),void(null==a||a());(null==o?void 0:o.authStrategy)===N.EmailAndPassword?(n.setLoginState({step:bn.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:bn.loginWithPassword,loading:!1,error:Gn(s)}),null==a||a())},h=async t=>{const{user:e,tenants:a=[],activeTenant:s}=t,i={step:es.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:()=>{Fn(t,["auth","loginState"],Ai)},requestAuthorize:async t=>{const e=[],a=[];e.push(o()),t&&(n.setAuthState({isLoading:!0}),e.push(n.loadSocialLoginsConfigurationV2(Cn())),e.push(n.loadAllowSignUps(g(Jn.LOAD_ALLOW_SIGNUPS))),e.push(n.loadPublicAuthStrategiesPolicy(g(Jn.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY))),e.push(n.loadSignUpStrategies()),e.push(c(g(Jn.LOAD_SSO_PUBLIC_CONFIGURATION))),e.push(n.loadVendorPublicInfo(Cn())),e.push(u(Cn())),a.push(n.loadCustomLoginRoutes(g(Jn.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(Cn())),a.push(n.loadAllowSignUps(g(Jn.LOAD_ALLOW_SIGNUPS))),a.push(c(g(Jn.LOAD_SSO_PUBLIC_CONFIGURATION))),a.push(n.loadSignUpStrategies()),a.push(n.loadVendorPublicInfo(Cn())),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(ws(a,t.root.appName)){const t=await n.getMfaRequiredState(a,kn,!0);n.setAuthState(t),s(i.loginUrl,{preserveQueryParams:!0})}})(e)),a.push(n.loadCustomLoginRoutes(g(Jn.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=rs(ls),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===go.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:bn.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:bn.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(ws(a,t.root.appName)){const t=await n.getMfaRequiredState(a,kn,!0,i);n.setAuthState(t),p(h.loginUrl,{preserveQueryParams:!0})}else{const[e]=await n.getFeatureFlags(["security-center-show-login-flows"]);if(Ts(a,t.root.appName))d({step:bn.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===An.Login?bn.success:o.step,tenants:s,tenantsLoading:!0,isBreachedPassword:a.isBreachedPassword},isAuthenticated:r}),o.flow===An.Login&&(e&&a.isBreachedPassword&&!r?d({step:bn.breachedPassword,loading:!1}):r&&(vs(a)?d({step:bn.passwordRotationNotification,loading:!1}):await n.__shouldShowPromptPasskeys()?(d({step:bn.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:Gn(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()&&le(),n.resetAuthState(),await n.requestAuthorize(!0),null==a||a()},silentLogout:async t=>{var a;try{await e.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&le(),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:bn.preLogin}),n.setAuthState({user:void 0,isAuthenticated:!1}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;d({error:Gn(e),loading:!1}),null==(s=t.callback)||s.call(t,!1,e)}},quickSmsPasswordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,ho);try{d({loading:!0});const t=await e.auth.passwordlessPreLogin(S({},n,{type:N.SmsCode}));d({step:bn.loginWithQuickSmsOtc,loading:!1,phoneNumber:null==t?void 0:t.phoneNumber,error:void 0}),null==a||a(!0)}catch(t){d({error:Gn(t),loading:!1}),null==a||a(!1,t)}},changePhoneNumberWithVerification:async t=>{const{callback:a}=t,n=f(t,yo);try{d({loading:!0});const t=await e.auth.changePhoneNumberWithVerification(n);d({phoneNumber:n.phoneNumber,loading:!1,changePhoneId:t.changePhoneId,step:bn.loginWithQuickSmsOtc,error:void 0}),null==a||a(!0)}catch(t){d({error:Gn(t),loading:!1})}},verifyChangePhoneNumber:async t=>{const{callback:a}=t,n=f(t,vo);try{d({loading:!0}),await e.auth.verifyChangePhoneNumber(n),d({loading:!1}),null==a||a(!0)}catch(t){d({error:Gn(t),loading:!1})}},passwordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,So);try{var s;let t,i;d({loading:!0}),ps(n)&&(t=n.email),hs(n)&&(i=n.username);const o=await e.auth.passwordlessPreLogin(S({},n,{email:t,username:null!=(s=i)?s:""})),r=En[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:Gn(t),loading:!1}),null==a||a(null,t)}},passwordlessPostLogin:async a=>{const{callback:s,events:i}=a,o=f(a,fo);try{d({loading:!0});const{user:l,tenants:c=[],activeTenant:u}=await e.auth.passwordlessPostLoginV2(o),{routes:g,onRedirectTo:p}=t.auth;if(ws(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:Yn.PASSWORDLESS,id:l.id,tenantId:l.tenantId,createdAt:new Date,name:l.name};null==i||null==(r=i.userVerified)||r.call(i,t),as(ts.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===An.Login?await n.__shouldShowPromptPasskeys()?(n.setLoginState({step:bn.promptPasskeys,loading:!1}),p(g.loginUrl,{preserveQueryParams:!0})):(n.setAuthState({isAuthenticated:!0}),a.type===N.MagicLink&&(n.setLoginState({step:bn.magicLinkPostLoginSuccess,loading:!1}),await _n(5e3)),await n.afterAuthNavigation()):p(g.loginUrl,{preserveQueryParams:!0}),localStorage.removeItem("register-quick-login"),null==s||s(!0)}}catch(t){d({error:Gn(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:Gn(t,"We couldn't verify your invitation")})}finally{d({loading:!1})}},webAuthnPrelogin:async t=>{const{callback:a}=t,s=f(t,mo);try{var i;n.setPasskeysState({loading:!0}),d({loading:!0});const{options:t}=await e.auth.webAuthnPreLogin(s);t.challenge=Ci(t.challenge),t.allowCredentials=null==(i=t.allowCredentials)?void 0:i.map((t=>S({},t,{id:Ci(t.id)}))),d({error:void 0}),null==a||a(t)}catch(t){d({error:Gn(t)}),null==a||a(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnPostLogin:async a=>{const{callback:s}=a,i=f(a,bo);try{var o;n.setPasskeysState({loading:!0}),d({loading:!0});const a=Di(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,Ao);if(ws(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:Gn(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=Ci(t.user.id),t.challenge=Ci(t.challenge),t.excludeCredentials=[],null==a||a(t)}catch(t){d({error:Gn(t)}),null==a||a(null)}finally{d({loading:!1})}},webAuthnVerifyNewDeviceSession:async t=>{const{callback:a}=t,n=f(t,wo);try{d({loading:!0});const t=Di(n.publicKey),s="platform"===(null==t?void 0:t.authenticatorAttachment)?Jt.Platform:Jt.CrossPlatform;await e.auth.verifyNewDeviceSession({id:t.id,response:t.response,deviceType:s}),null==a||a(!0)}catch(t){d({error:Gn(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,To);d({loading:!0});try{var s;const t=await e.auth.preEnrollMFAWebAuthnForLogin(n),i=S({},t.options,{challenge:Ci(t.options.challenge),user:S({},t.options.user,{id:Ci(t.options.user.id)}),excludeCredentials:null==(s=t.options.excludeCredentials)?void 0:s.map((t=>S({},t,{id:Ci(t.id)})))});d({loading:!1}),null==a||a({options:i,webauthnToken:t.webauthnToken})}catch(t){d({loading:!1,error:Gn(t)}),null==a||a(null)}},enrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,Eo);d({loading:!0});try{const t=Di(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:Gn(t)}),null==a||a(null)}},enrollMFAAuthenticatorAppForLogin:async t=>{const{callback:a}=t,n=f(t,Po);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:Gn(t)}),null==a||a(null)}},preEnrollMFASMSForLogin:async t=>{const{callback:a}=t,s=f(t,Oo);d({loading:!0});try{const t=await e.auth.preEnrollMFASMSForLogin(s);n.setMfaState({otcToken:t.otcToken,step:es.smsVerifyCode,phoneNumber:t.phoneNumber}),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Gn(t)}),null==a||a(null)}},enrollMFASMSForLogin:async t=>{const{callback:a}=t,n=f(t,Io);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:Gn(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:bn.breachedPasswordSuccess}),n.setAuthState({isAuthenticated:!1})}catch(t){d({loading:!1,error:Gn(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(ws(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:bn.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?An.RegisterQuickLogin:An.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(Ps(l)===i.hostedLoginRedirectUrl)return void console.debug("Calling loginWithRedirect while in hostedLoginCallback route");n.setAuthState({isLoading:!0});const c=eo(),u=eo(),d=await to(u);localStorage.setItem(In,u);const g=ys(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=rs(ls);m&&(v.tenantId=m),o(`${y}?${new URLSearchParams(v).toString()}`,{refresh:!0})};return{requestHostedLoginAuthorize:async e=>{var a;null==(a=localStorage)||a.removeItem(fn);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(fn),l){const e=t.root.urlStrategy,a=Ps(e);if(n.setAuthState({isLoading:!0}),gs(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(In)||"INVALID-CODE-VERIFIER",o=t.auth.routes,r=t.root.urlStrategy,l=ys(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(fn);window.localStorage.removeItem(fn),a&&Ss(e)?await n.afterStepUpAuthNavigation():await n.afterAuthNavigation()}}}})(t,e,a),Ti(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===An.Login){if(o&&s.isBreachedPassword&&!e)return void n.setLoginState({step:bn.breachedPassword,loading:!1});if(Ts(a,t.root.appName))return void n.setLoginState({step:bn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId});if(vs(a))return void n.setLoginState({step:bn.passwordRotationNotification,loading:!1});const r=await n.__shouldShowPromptPasskeys();i===es.smsVerifyCode&&r?n.setLoginState({step:bn.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 te.getFeatureFlags(e,a)}}}(t,0,a),((t,e)=>({getMfaRequiredState:async(a,n,s=!1,i)=>{var o,r,l;let c=bn.loginWithTwoFactor;const u={step:es.verify,loading:!1,saving:!1},d=t.auth.loginState;let g,p;try{const t=await Rn((()=>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:us(a.mfaDevices)}):(Object.assign(u,{step:ds(a.mfaStrategies),qrCode:a.qrCode,recoveryCode:a.recoveryCode,loading:!1,mfaToken:a.mfaToken,mfaStrategies:a.mfaStrategies}),c=bn.forceTwoFactor);let h={};const y=localStorage.getItem("register-quick-login");return y&&(h={quickLoginToRegister:y,flow:An.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,Ei);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===An.Login?bn.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!==An.Login)return;const[o]=await n.getFeatureFlags(["security-center-show-login-flows"]);return o&&i.isBreachedPassword&&!e?(n.setLoginState({step:bn.breachedPassword,loading:!1}),void(null==s||s(!0))):Ts(a,t.root.appName)?(n.setLoginState({step:bn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId}),void(null==s||s(!0))):vs(a)?(n.setLoginState({step:bn.passwordRotationNotification,loading:!1}),void(null==s||s(!0))):(await n.__shouldShowPromptPasskeys()?n.setLoginState({step:bn.promptPasskeys,loading:!1}):await n.afterAuthNavigation(),void(null==s||s(!0)))}(u,a,o)}catch(t){s({loading:!1,error:Gn(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,Pi);(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:es.emailVerifyCode}),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({error:Gn(t)}),null==i||i(null)}},i=async(t,a)=>{var s;let{callback:i}=t,o=f(t,Oi);(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:Gn(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,Ii);a({loading:!1,error:void 0});try{const t=await e.auth.preVerifyMFASMSForLogin(i,o);n.setMfaState({otcToken:t.otcToken,step:es.smsVerifyCode,phoneNumber:t.phoneNumber}),a({loading:!1,error:void 0}),null==s||s(!0)}catch(t){a({loading:!1,error:Gn(t)}),null==s||s(null)}},i=async(t,a,s=!1)=>{let{callback:i,deviceId:o}=t,r=f(t,ki);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:Gn(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,Mi);a({loading:!0});try{var o;const t=await e.auth.preVerifyMFAWebAuthnForLogin(s,i),r=S({},t.options,{challenge:Ci(t.options.challenge),allowCredentials:null==(o=t.options.allowCredentials)?void 0:o.map((t=>S({},t,{id:Ci(t.id)})))});a({loading:!1,error:void 0}),null==n||n({options:r,webauthnToken:t.webauthnToken})}catch(t){a({loading:!1,error:Gn(t)}),null==n||n(null)}},i=async(t,a,s)=>{let{callback:i,deviceId:o}=t,r=f(t,Fi);a({loading:!0});try{const t=Di(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:Gn(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))},_o={step:es.verify,loading:!1,saving:!1},Uo=t=>rn(_o,t),Ro=["callback"],Co=["callback"],Lo=["user"],Do=["deviceId"],No=["deviceId"],Mo=["callback"],Fo=["callback"],xo=["deviceId","callback"],$o=(t,e,a)=>{const n=a;async function s(e){const a=t.auth.mfaState.step;return{step:e.recoveryCode?es.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:()=>{Fn(t,["auth","mfaState"],_o)},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:Gn(t)})}},getMFAStrategies:async t=>{i({loading:!0});try{const a=(await Rn((()=>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:Gn(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:Gn(t)})}},verifyMfa:async a=>{const{callback:o}=a,r=f(a,Ro);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:Gn(t)}),null==o||o(null,t)}},verifyMfaAfterForce:async t=>{const{callback:a}=t,s=f(t,Co);i({loading:!0});try{const t=await e.auth.loginWithMfaV2(s),{user:o}=t,r=f(t,Lo),l={step:es.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:Gn(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:Gn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},preDisableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,Do);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:Gn(t)}),null==(o=n.callback)||o.call(n,!1,t)}},disableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,No);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:Gn(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:Gn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},enrollMfaSms:async t=>{const{callback:a}=t,n=f(t,Mo);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:Gn(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:Ci(s.options.challenge),user:S({},s.options.user,{id:Ci(s.options.user.id)}),excludeCredentials:null==(a=s.options.excludeCredentials)?void 0:a.map((t=>S({},t,{id:Ci(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:Gn(e)}),null==(s=t.callback)||s.call(t,null,e)}},enrollMfaWebAuthn:async t=>{const{callback:a}=t,n=f(t,Fo);i({saving:!0});try{const t=Di(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:Gn(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:Ci(t.options.challenge),allowCredentials:null==(s=t.options.allowCredentials)?void 0:s.map((t=>S({},t,{id:Ci(t.id)})))});i({saving:!1}),null==n||n({options:o,webauthnToken:t.webauthnToken})}catch(t){i({saving:!1,error:Gn(t)}),null==n||n(null,t)}},disableMfaWebAuthn:async t=>{const{deviceId:a,callback:n}=t,s=f(t,xo);i({saving:!0});try{const t=Di(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:Gn(t)}),null==n||n(!1,t)}},__getMfaStateAfterEnroll:s}},Go={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:Gt.DESC,_sortBy:Ha.name},usersPageOffset:0,accountSettings:{}}},jo=t=>rn(Go,t),Bo={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:Da.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:[]}},Vo=t=>rn(Bo,t);let Wo;!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"}(Wo||(Wo={}));const Ho=({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 zo(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=>zo(t,e,a))))?n:[]})}function Ko(t,e){var a;return S({},t,{children:null!=(a=t.children)&&a.length?t.children.filter((t=>t.tenantId!==e)).map((t=>Ko(t,e))):[]})}const qo=(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=>qo(t,e,a))))?n:[]})},Jo=(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=>Jo(t,e,a))))?n:[]})},Yo=(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=>Yo(t,e,a))))?n:[]}):{}},Xo=(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=Wo.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:Gn(t)})}finally{n({key:f,value:!1})}};return{setAllAccountsLoader:n,setAllAccountsError:s,setAllAccountsState:i,setSelectedAccountState:o,resetAllAccountsState:()=>{Fn(t,["auth","allAccountsState"],Go)},clearSelectedAccount:()=>{Fn(t,["auth","allAccountsState","selectedAccount"],Go.selectedAccount)},loadAccounts:async t=>{const a=Wo.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=Ho({items:n},i),u=zo(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=Ho({items:n},o),c=zo(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:Gn(t)})}finally{n({key:a,value:!1})}},searchAccounts:async t=>{const{jwt:a}=t,o=Wo.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:Gn(t)})}finally{n({key:o,value:!1})}},updateSubAccountAccessForUser:async t=>{const a=Wo.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:Gn(t)}),null==d||d(!1)}finally{n({key:a,value:!1})}},createSubAccount:async t=>{const a=Wo.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=zo(t,null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]),g=zo(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=zo(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:Gn(t)}),null==g||g(!1)}finally{n({key:a,value:!1})}},updateSubAccount:async t=>{},deleteSubAccount:async t=>{const a=Wo.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=Ko(a,c),s=Ko(t.accounts,c);i({accounts:n}),o({accounts:s})}else{const{accounts:t}=r();await e.subTenants.deleteSubTenant(c);const a=Ko(t,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Gn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountSettings:async t=>{const a=Wo.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=Jo(t.accounts,d,c);o({name:c,accounts:n});const s=Jo(a,d,c);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenant({tenantId:d},{name:c});const a=Jo(t,d,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Gn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountManagement:async r=>{const l=Wo.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=Yo(a.accounts,g,null!=u&&u);o({accounts:s}),h||o({isReseller:u});const r=Yo(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=Yo(a,g,null!=u&&u);i({accounts:n})}null==d||d(!0)}catch(t){s({key:l,value:Gn(t)}),null==d||d(!1)}finally{n({key:l,value:!1})}},updateSubAccountHierarchySettings:async t=>{const a=Wo.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=qo(t.accounts,u,d);o({subAccountAccessType:d,accounts:n});const s=qo(a,u,d);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d});const a=qo(t,u,d);i({accounts:a})}null==c||c(!0)}catch(t){s({key:a,value:Gn(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=Wo.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:Gn(t)}),null==r||r(!1)}finally{n({key:d,value:!1})}},getAccountUsers:l,deleteUsersFromAccount:async t=>{const a=Wo.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:Gn(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=Wo.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:Gn(t)}),null==c||c(!1)}finally{n({key:u,value:!1})}},getUserJwtForSubAccount:async t=>{const{tenantId:a,callback:i}=t,r=Wo.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:Gn(t)}),o({accessPermission:!1}),null==i||i(!1)}finally{n({key:r,value:!1})}},setRootAccountData:async()=>{const a=Wo.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:Gn(t)})}finally{n({key:a,value:!1})}},setSelectedSubAccountData:async t=>{const{jwt:a}=t,i=Wo.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:Gn(t)})}finally{n({key:i,value:!1})}},loadNumberOfUsersForSelectedSubAccount:async t=>{const{tenantId:a,jwt:i}=t,r=Wo.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:Gn(t)})}finally{n({key:r,value:!1})}}}},Qo=(t,e,a)=>({setAllAccountDialogsState:e=>{Object.assign(t.auth.allAccountsDialogsState,e)},resetAllAccountDialogsState:()=>{Fn(t,["auth","allAccountsDialogsState"],Bo)},openCreateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.createSubAccountDialog,S({},e,{open:!0}))},closeCreateSubAccountDialog:()=>{Fn(t,["auth","allAccountsDialogsState","createSubAccountDialog"],Bo.createSubAccountDialog)},openUpdateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountDialog,S({},e,{open:!0}))},closeUpdateSubAccountDialog:()=>{Fn(t,["auth","allAccountsDialogsState","updateSubAccountDialog"],Bo.updateSubAccountDialog)},openEnableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.enableSubAccountManagementDialog,S({},e,{open:!0}))},closeEnableSubAccountManagementDialog:()=>{Fn(t,["auth","allAccountsDialogsState","enableSubAccountManagementDialog"],Bo.enableSubAccountManagementDialog)},openUpdateSubAccountHierarchySettingsDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountHierarchySettingsDialog,S({},e,{open:!0}))},closeUpdateSubAccountHierarchySettingsDialog:()=>{Fn(t,["auth","allAccountsDialogsState","updateSubAccountHierarchySettingsDialog"],Bo.updateSubAccountHierarchySettingsDialog)},openDisableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.disableSubAccountManagementDialog,S({},e,{open:!0}))},closeDisableSubAccountManagementDialog:()=>{Fn(t,["auth","allAccountsDialogsState","disableSubAccountManagementDialog"],Bo.disableSubAccountManagementDialog)},openDeleteSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteSubAccountDialog,S({},e,{open:!0}))},closeDeleteSubAccountDialog:()=>{Fn(t,["auth","allAccountsDialogsState","deleteSubAccountDialog"],Bo.deleteSubAccountDialog)},openAddUsersToAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.addUsersToAccountDialog,S({},e,{open:!0}))},closeAddUsersToAccountDialog:()=>{Fn(t,["auth","allAccountsDialogsState","addUsersToAccountDialog"],Bo.addUsersToAccountDialog)},openDeleteUserFromAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteUserFromAccountDialog,S({},e,{open:!0}))},closeDeleteUserFromAccountDialog:()=>{Fn(t,["auth","allAccountsDialogsState","deleteUserFromAccountDialog"],Bo.deleteUserFromAccountDialog)},openEditUserRolesDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.editUserRolesDialog,S({},e,{open:!0}))},closeEditUserRolesDialog:()=>{Fn(t,["auth","allAccountsDialogsState","editUserRolesDialog"],Bo.editUserRolesDialog)}}),Zo={devices:[],loading:!1,error:null},tr=t=>rn(Zo,t),er=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.passkeysState,e)};return{setPasskeysState:s,resetPasskeysState:()=>{Fn(t,["auth","passkeysState"],Zo)},loadWebAuthnDevices:async()=>{s({loading:!0});try{const{devices:t}=await e.auth.getWebAuthnDevices();s({devices:t,loading:!1})}catch(t){s({loading:!1,error:Gn(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:Gn(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===qt.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)}}}},ar={loading:!1,error:null},nr=t=>rn(ar,t),sr=["callback","profilePictureUrl"],ir=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.profileState,e)};return{setProfileState:s,resetProfileState:()=>{Fn(t,["auth","profileState"],ar)},loadProfile:async()=>{s({loading:!0});try{const a=await Un(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:Gn(t)})}},saveProfile:async a=>{const{callback:i,profilePictureUrl:o}=a,r=f(a,sr);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=Li(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:Gn(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:Gn(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:Gn(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:Gn(t),loading:!1}),null==o||o(null,t)}}}},or={loading:!1},rr=t=>rn(or,t),lr=["callback"],cr=["id"],ur=(t,e,a)=>{const n=e=>{Object.assign(t.auth.provisioningState,e)},s=async(t,a)=>{const{count:n}=await Rn((()=>e.directory.countConfigurationUsers(t.id)),a);return S({},t,{count:n})};return{setProvisioningState:n,resetProvisioningState:()=>{Fn(t,["auth","provisioningState"],or)},__loadCountForConnection:s,loadProvisionConnections:async t=>{n({loading:!0,error:null});try{const a=null==t?void 0:t.retryConfig,i=await Rn((()=>e.directory.getConfigs()),a),o=await Promise.all(i.map((t=>s(t,a))));n({connections:o,loading:!1})}catch(t){n({error:Gn(t),loading:!1})}},createProvisionConnection:async t=>{const{callback:a}=t,i=f(t,lr);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:Gn(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:Gn(t),loading:!1}),null==i||i(!1,t)}},updateProvisionConnection:async t=>{const{id:a}=t,i=f(t,cr);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:Gn(t),loading:!1})}}}};let dr;!function(t){t.ResetPhoneNumber="ResetPhoneNumber",t.VerifyResetPhoneNumber="VerifyResetPhoneNumber",t.ChangePhoneNumber="ChangePhoneNumber"}(dr||(dr={}));const gr={step:dr.ResetPhoneNumber,loading:!1},pr=t=>rn(gr,t),hr=["callback"],yr=["callback"],vr=["callback"],Sr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.resetPhoneNumberState,e)};return{setResetPhoneNumberState:s,resetResetPhoneNumberState:()=>{Fn(t,["auth","resetPhoneNumberState"],gr)},resetPhoneNumber:async t=>{const{callback:a}=t,i=f(t,hr);s({loading:!0});try{const t=await e.auth.resetPhoneNumber(i);s({loading:!1,error:void 0,resetPhoneNumberToken:t.resetPhoneNumberToken,step:dr.VerifyResetPhoneNumber}),n.setLoginState({email:i.email})}catch(t){s({loading:!1,error:Gn(t)}),null==a||a(null,t)}},verifyResetPhoneNumber:async t=>{const{callback:a}=t,n=f(t,yr);s({loading:!0});try{const t=await e.auth.verifyResetPhoneNumber(n);s({loading:!1,error:void 0,changePhoneNumberToken:t.changePhoneNumberToken,step:dr.ChangePhoneNumber}),null==a||a(!0)}catch(t){s({loading:!1,error:Gn(t)}),null==a||a(null,t)}},changePhoneNumber:async a=>{const{callback:i}=a,o=f(a,vr);s({loading:!0});try{const{onRedirectTo:a,routes:r}=t.auth;await e.auth.changePhoneNumber({phoneNumber:o.phoneNumber,changePhoneNumberToken:o.changePhoneNumberToken}),n.setLoginState({step:bn.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:Gn(t)}),null==i||i(null,t)}}}},fr={loaders:{},errors:{},roles:[],permissions:[],permissionCategories:[]},mr=t=>rn(fr,t);let br;!function(t){t.EDIT_ROLE_DIALOG="editRoleDialog",t.DELETE_ROLE_DIALOG="deleteRoleDialog",t.LOAD_ROLES="loadRoles",t.ADD_ROLE="addRole",t.MANAGE_PERMISSIONS="managePermissions"}(br||(br={}));const Ar=["callback"],wr=["callback"],Tr=["callback"],Er=["callback"],Pr=["callback"],Or=["callback"],Ir=(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=br.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([Rn((()=>e.roles.getRoles()),s),Rn((()=>e.roles.getPermissions()),s),Rn((()=>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:Gn(t)})}finally{s({key:r,value:!1})}},r=async t=>{const{callback:a}=t,r=f(t,Pr),l=br.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:Gn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}};return{setRolesState:n,setRolesStateLoader:s,setRolesStateError:i,resetRolesState:()=>{Fn(t,["auth","rolesState"],fr)},loadRolesAndPermissions:o,addRole:async t=>{const{callback:a}=t,n=f(t,Ar),r=br.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:Gn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},addRoleV2:async t=>{const{callback:a}=t,n=f(t,wr),r=br.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:Gn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},updateRole:async t=>{const{callback:a}=t,r=f(t,Tr),l=br.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:Gn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}},deleteRole:async t=>{const{callback:a}=t,r=f(t,Er),l=br.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:Gn(t)}),null==a||a(!1,t)}finally{s({key:l,value:!1})}},attachPermissionsToRole:r,attachPermissionToRoles:async t=>{const{callback:e}=t,a=f(t,Or),n=br.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:Gn(t)}),null==e||e(null,t)}finally{s({key:n,value:!1})}}}},kr={ipRestrictions:{loading:!1,pagination:{_offset:0,_limit:4,_filter:Kt.ALLOW},totalPages:1,userIpValid:!1},emailDomainRestrictions:{loading:!1}},_r=t=>rn(kr,t),Ur=["callback"],Rr=["callback"],Cr=["callback"],Lr=["callback"],Dr=(t,e,a)=>{const n=a,s=t=>{var e,a,n;return{_filter:null!=(e=null==t?void 0:t._filter)?e:Kt.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(Cn()),await n.loadInsights(Cn()))},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:Gn(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:Gn(t),loading:!1})}})),u=i((async a=>{const{callback:n}=a,i=f(a,Ur);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:Kt.ALLOW},restrictions:p},pagination:u,totalPages:g,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Gn(t)}),null==n||n(null,t)}})),d=i((async a=>{const{callback:n}=a,i=f(a,Rr);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:Gn(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:Kt.ALLOW},restrictions:g},pagination:c,totalPages:d,saving:!1}),null==i||i(!0)}catch(t){o({saving:!1,error:Gn(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:Kt.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:Kt.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:Gn(t),loading:!1})}})),v=i((async a=>{const{callback:n}=a,s=f(a,Cr);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:Gn(t)}),null==n||n(null,t)}})),m=i((async t=>{const{callback:a}=t,n=f(t,Lr);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:Gn(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:Kt.ALLOW},restrictions:t},saving:!1})}catch(t){r({saving:!1,error:Gn(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}},Nr={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}}},Mr=t=>rn(Nr,t);let Fr;!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"}(Fr||(Fr={}));const xr=["callback"],$r=(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:Gn(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:()=>{Fn(t,["auth","securityCenterState"],Nr)},setSecurityCenterStateLoader:o,setSecurityCenterStateError:r,loadRecommendations:async t=>{const a=Fr.RECOMMENDATIONS;o({key:a,value:!0});try{var n;const{recommendations:a,scoring:s}=await Rn((()=>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:Gn(t)})}finally{o({key:a,value:!1})}},loadInsights:async t=>{const a=Fr.INSIGHTS;o({key:a,value:!0});try{const{insights:a}=await await Rn((()=>e.securityCenter.getInsights()),null==t?void 0:t.retryConfig);i({insights:a.items})}catch(t){r({key:a,value:Gn(t)})}finally{o({key:a,value:!1})}},sendResetBreachedPasswordEmail:async t=>{const{callback:a}=t,n=f(t,xr),s=Fr.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:Gn(t)}),null==a||a(!1,t)}finally{o({key:s,value:!1})}},sendBulkResetBreachedPasswordEmails:async t=>{const{callback:a}=t,n=Fr.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:Gn(t)}),null==a||a(!1)}finally{o({key:n,value:!1})}},loadBreachedPasswordUsers:async e=>{var a;const n=Fr.BREACHED_PASSWORD_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.breachedPasswordUsersTable;await s(S({key:n,updateStateKey:"breachedPasswordUsersTable",_preset:za.BREACHED_PASSWORDS,tableState:i},e))},loadUnenrolledMfaUsers:async e=>{var a;const n=Fr.UNENROLLED_MFA_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.unenrolledMfaUsersTable;await s(S({key:n,updateStateKey:"unenrolledMfaUsersTable",_preset:za.MFA_UNENROLLED,tableState:i},e))},loadInactiveUsers:async e=>{var a;const n=Fr.INACTIVE_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.inactiveUsersTable;await s(S({key:n,updateStateKey:"inactiveUsersTable",_preset:za.INACTIVE,tableState:i},e))},markSecurityCenterStateAsChanged:(t=!0)=>{i({hasSecurityChanges:t})}}},Gr={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}},jr=t=>rn(Gr,t);function Br(t,e){const a=null!=e,n=null!=t;if(a||n)return a?n?Math.min(t,e):e:t}const Vr=["callback"],Wr=["callback"],Hr=["callback"],zr=["callback"],Kr=(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 Rn(e.auth.getPublicAuthStrategiesConfigForAuthenticatedUser,a):await Rn(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 Rn((()=>e.auth.getGlobalSecurityPolicy()),null==t?void 0:t.retryConfig);o({policy:a,loading:!1})}catch(t){o({error:Gn(t),loading:!1})}},A=async t=>{l({loading:!0,error:null});try{const a=await Rn((()=>e.auth.getMfaPolicy()),null==t?void 0:t.retryConfig);l({policy:a,loading:!1})}catch(t){l({error:Gn(t),loading:!1})}},w=async t=>{l({loading:!0,error:null});try{const a=await Rn((()=>e.auth.getVendorMfaPolicy()),null==t?void 0:t.retryConfig);c({policy:a,loading:!1})}catch(t){c({error:Gn(t),loading:!1})}},T=async t=>{u({loading:!0,error:null});try{const a=await Rn((()=>e.auth.getLockoutPolicy()),null==t?void 0:t.retryConfig);u({policy:a,loading:!1})}catch(t){u({error:Gn(t),loading:!1})}},E=async t=>{d({loading:!0,error:null});try{const a=await Rn((()=>e.auth.getVendorLockoutPolicy()),null==t?void 0:t.retryConfig);d({policy:a,loading:!1})}catch(t){d({error:Gn(t),loading:!1})}},P=async t=>{u({loading:!0,error:null});try{const a=await Rn((()=>e.auth.getCaptchaPolicy()),null==t?void 0:t.retryConfig);g({policy:a,loading:!1})}catch(t){g({error:Gn(t),loading:!1})}},O=async t=>{h({loading:!0,error:null});try{const a=await Rn((()=>e.auth.getVendorPasswordHistoryPolicy()),null==t?void 0:t.retryConfig);h({policy:a,loading:!1})}catch(t){h({error:Gn(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:Gn(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:()=>{Fn(t,["auth","securityPolicyState"],Gr)},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:Gn(t),loading:!1})}},loadVendorPasswordConfig:async t=>{v({loading:!0,error:null});try{var a;const n=await Rn((()=>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:Gn(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:Gn(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:Br(a.rotationPeriod,t.rotationPeriod)}):a:n.passwordRotationTenantConfig=t),y({policy:S({},n),loading:!1})}catch(t){y({error:Gn(t),loading:!1})}},loadPublicAuthStrategiesPolicy:I,saveSecurityPolicyMfa:async t=>{const{callback:a}=t,n=f(t,Vr);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:Gn(t)}),null==a||a(null,t)}},saveSecurityPolicyLockout:async t=>{const{callback:a}=t,n=f(t,Wr);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:Gn(t)}),null==a||a(null,t)}},saveSecurityPolicyPasswordHistory:async t=>{const{callback:a}=t,n=f(t,Hr);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:Gn(t)}),null==a||a(null,t)}},saveSecurityPolicyPasswordRotation:async t=>{const{callback:a}=t,n=f(t,zr);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:Gn(t)}),null==a||a(null,t)}},__getSecurityPolicyPublicStateWithCustomLogin:s}},qr={loading:!1,configurations:{}},Jr=t=>rn(qr,t),Yr=["callback"],Xr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.sessionsPolicyState,e)};return{setSessionsPolicyState:s,resetSessionsPolicyState:()=>{Fn(t,["auth","sessionsPolicyState"],qr)},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,Yr);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})}}}},Qr={loading:!1,sessions:[]},Zr=t=>rn(Qr,t),tl=(t,e,a)=>{const n=e=>{Object.assign(t.auth.sessionsState,e)},s=async t=>{n({loading:!0,error:null});try{const a=await Rn((()=>e.auth.getCurrentUserSessions()),null==t?void 0:t.retryConfig);n({sessions:a,loading:!1})}catch(t){n({error:Gn(t),loading:!1})}};return{setSessionsState:n,resetSessionsState:()=>{Fn(t,["auth","sessionsState"],Qr)},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:Gn(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:Gn(t),loading:!1})}},deleteAllUserSessions:async()=>{n({loading:!0,error:null});try{await e.auth.deleteAllSessionsForUser(),await s()}catch(t){n({error:Gn(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:Gn(t),loading:!1}),null==a||a(!1)}}}};let el;!function(t){t.SignUp="SignUp",t.SignUpSuccess="SignUpSuccess",t.VerifyPhone="VerifyPhone"}(el||(el={}));const al={loading:!1,allowSignUps:!1,allowNotVerifiedUsersLogin:!1,firstLoad:!0,stage:el.SignUp,strategies:{[F.Email]:{enabled:!0,required:!0},[F.PhoneNumber]:{enabled:!1,required:!1}}},nl=t=>rn(al,t),sl=["events","url"],il=["events","url"],ol=(t,e,a)=>{const n=a,s=R.for(t.root.appName),i=e=>{Object.assign(t.auth.signUpState,e)},o=()=>{Fn(t,["auth","signUpState"],al)},r=(t,e,a,n,s,i=Xn.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),as(ts.SIGNUP_COMPLETED,g)},l=async a=>{const{events:o}=a,l=f(a,sl);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(Os(l));l.invitationToken||r(l,g,i,p,o,Xn.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:bn.loginWithSmsOtc,phoneNumber:l.phoneNumber})}})}catch(t){s.setAccessToken(null),s.setUser(null),i({error:Gn(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,il);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(Os(c));if(c.invitationToken||r(c,g,d,y,o),!l&&u&&ws(u,t.root.appName)){const t=await n.getMfaRequiredState(u,kn,!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:el.SignUpSuccess}),s(e)}else{const e=t.auth.tenantsState;i({loading:!1,shouldActivate:l,stage:el.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:Gn(t)})}finally{i({loading:!1})}},signUpUserWithPhoneNumber:l,loadAllowSignUps:async t=>{i({loading:!0});try{var a;const s=await Rn(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:Gn(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){}}}},rl={loading:!1,error:null,phoneNumbers:void 0},ll=t=>rn(rl,t),cl=["callback"],ul=["callback"],dl=["callback"],gl=["callback","phoneId"],pl=["callback","phoneId"],hl=["callback"],yl=(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:Gn(t)})}finally{n({loading:!1})}},i=async()=>{n({loading:!0});try{const t=await e.userPhoneNumbers.getUserOwnPhoneNumbers();n({phoneNumbers:t})}catch(t){n({error:Gn(t)})}finally{n({loading:!1})}};return{setSmsState:n,resetSmsState:()=>{Fn(t,["auth","smsState"],rl)},loadPhoneNumbers:s,loadUserOwnPhoneNumbers:i,setUpPhoneNumber:async t=>{const{callback:a}=t,i=f(t,ul);try{const{otcToken:t}=await e.userPhoneNumbers.createPhoneNumber(i);n({otcToken:t}),await s(),null==a||a(!0)}catch(t){n({error:Gn(t)}),null==a||a(!1,t)}},setUpOwnPhoneNumber:async t=>{const{callback:a}=t,s=f(t,cl);try{const{otcToken:t}=await e.userPhoneNumbers.createPhoneNumber(s);n({otcToken:t}),await i(),null==a||a(!0)}catch(t){n({error:Gn(t)}),null==a||a(!1,t)}},verifyPhoneNumber:async t=>{const{callback:a}=t,i=f(t,dl);n({loading:!0});try{await e.userPhoneNumbers.verifyPhoneNumber(i),await s(),null==a||a(!0)}catch(t){n({error:Gn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},deletePhoneNumber:async t=>{const{callback:a,phoneId:s}=t;f(t,gl),n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.deletePhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Gn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},verifyDeletePhoneNumber:async t=>{const{callback:a,phoneId:i}=t,o=f(t,pl);n({loading:!0});try{await e.userPhoneNumbers.verifyDeletePhoneNumber(i,o),await s(),null==a||a(!0)}catch(t){n({error:Gn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},preVerifyPhoneNumber:async t=>{const{callback:a}=t,s=f(t,hl);n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.preVerifyPhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Gn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}}}},vl={firstLoad:!0,loading:!1,error:""},Sl=t=>rn(vl,t),fl=["authorizationUrl"],ml=["events","url"],bl=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.socialLoginState,e)};return{setSocialLoginsState:s,resetSocialLoginsState:()=>{Fn(t,["auth","socialLoginState"],vl)},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:Gn(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 Rn(e.auth.getSocialLoginProvidersV2ForAuthenticatedUser,a):await Rn(e.auth.getSocialLoginProvidersV2,a),n})(null==a?void 0:a.retryConfig),{providers:r}=await Rn(e.auth.getCustomSocialLoginProvidersV1,null==a?void 0:a.retryConfig),l={socialLoginsConfigV2:o.map((t=>{let{authorizationUrl:a}=t,n=f(t,fl);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:Gn(t),loading:!1,firstLoad:!1})}},loginViaSocialLogin:async t=>{const{events:a,url:i}=t,o=f(t,ml);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:Xn.SOCIAL_LOGIN});null==a||null==(r=a.signUpComplete)||r.call(a,n),as(ts.SIGNUP_COMPLETED,n);const s=S({},e,{origin:Yn.SOCIAL_LOGIN,name:g});null==a||null==(l=a.userVerified)||l.call(a,s),as(ts.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:Gn(t,"Failed to authenticate"),firstLoad:!1})}}}},Al={firstLoad:!0,loading:!0,saving:!1,errors:{},loaders:{},ssoConfigurations:[]},wl=t=>rn(Al,t),Tl=["callback","samlVendor"],El=["callback"],Pl=["callback","ssoConfigId"],Ol=["callback","ssoConfigId"],Il=["callback","ssoConfigId"],kl=(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:Gn(t)})}},i=e=>{Object.assign(t.auth.ssoState,e)};return{setSSOState:i,resetSSOState:()=>{Fn(t,["auth","ssoState"],Al)},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:Gn(t),loading:!1})}},saveSSOConfigurations:async a=>{const{callback:n,samlVendor:s}=a,o=f(a,Tl),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===go.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=Dn(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:Gn(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 Ni(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:Gn(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 Ni(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:Gn(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:Gn(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:Gn(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:Gn(t)})}})(o),await s(),i({error:void 0,saving:!1}),null==a||a(!0)}catch(t){i({error:Gn(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:Gn(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:Gn(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:Gn(t,"Failed to authenticate"),firstLoad:!1})}}}})(t,e,a),((t,e,a)=>{const n=a,s=async t=>{try{return await Rn((()=>e.auth.getOidcConfiguration()),t)}catch(t){return null}},i=async t=>{try{return await Rn((()=>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:Gn(a)}),null==e||e(null,a)}finally{n.setSSOLoader({key:t,value:!1})}};return{loadSSOConfigurationsV2:async t=>{await o(uo.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 Rn((()=>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,El),r=t.auth.ssoState.ssoConfigurations;await o(uo.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,Pl),l=t.auth.ssoState.ssoConfigurations;await o(uo.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(uo.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,Ol),l=t.auth.ssoState.ssoConfigurations;await o(uo.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(uo.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(uo.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(uo.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(uo.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(uo.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(uo.SAVE_SSO_CONFIGURATION_BY_METADATA,i,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await Ni(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(uo.UPDATE_SSO_CONFIGURATION_BY_METADATA,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await Ni(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(uo.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,Il),l=t.auth.ssoState.ssoConfigurations;await o(uo.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)),_l={loading:!1,mfaDevices:void 0,mfaToken:""},Ul=t=>rn(_l,t),Rl=(t,e,a)=>{const n=a;return S({setStepUpState:e=>{Object.assign(t.auth.stepUpState,e)},resetStepUpState:()=>{Fn(t,["auth","stepUpState"],_l)},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 us(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:es.noMFAEnrolledStepUp});window.localStorage.setItem(fn,"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:yn},{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),fs(),window.localStorage.setItem(fn,"true"),await n.__requestHostedLoginAuthorize(i)}}})(t,0,a))},Cl={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}},Ll=t=>rn(Cl,t),Dl=["callback","appIds"],Nl=["roles"],Ml=["callback","profileImage"],Fl=["callback"],xl=["callback"],$l=["callback"],Gl=["callback","userId"],jl=["callback"],Bl=["callback"],Vl=["callback"],Wl=["callback"],Hl=["callback"],zl=["callback"],Kl=(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:()=>{Fn(t,["auth","teamState"],Cl)},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 Rn((()=>e.groups.getGroups({_groupsRelations:Va.roles})),t);return a}catch(t){return[]}},i=async t=>{n.setTeamLoader({key:ks.ROLES_AND_PERMISSIONS,value:!0});try{var a;const s=null==t?void 0:t.retryConfig,[{items:i},{items:o}]=await Promise.all([Rn((()=>e.teams.loadAvailableRoles()),s),Rn((()=>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:ks.ROLES_AND_PERMISSIONS,value:Gn(e)})}finally{n.setTeamLoader({key:ks.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:ks.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:ks.USERS,value:Gn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:ks.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:ks.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([Rn((()=>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),Rn((()=>e.teams.loadAvailableRoles()),v),Rn((()=>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:ks.USERS,value:Gn(t)}),n.setTeamState({totalPages:0,users:[]}),null==p||p(null,t)}n.setTeamLoader({key:ks.USERS,value:!1})},addUser:async s=>{const{callback:i,appIds:o}=s,r=f(s,Dl),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,Nl),{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:Gn(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,Ml),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));if(void 0!==l){n.setTeamLoader({key:ks.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:ks.UPDATE_USER,value:!1})}catch(t){n.setTeamState({addUserDialogState:S({},r.addUserDialogState,{loading:!1,error:Gn(t)}),users:r.users.map((t=>t.id===i.id?S({},t,l):t))}),n.setTeamLoader({key:ks.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,Fl),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:Gn(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:Gn(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:Gn(t)})}),null==s||s(null,t)}},getTemporaryUsersConfig:async t=>{n.setTeamError({key:ks.CONFIG_TEMPORARY_USERS,value:!1});try{const a=await Rn((()=>e.teams.getTemporaryUserConfiguration()),null==t?void 0:t.retryConfig);n.setTeamState({temporaryUsersConfig:a})}catch(t){n.setTeamError({key:ks.CONFIG_TEMPORARY_USERS,value:Gn(t)})}},updateUserExpirationTime:async a=>{const{callback:s}=a,i=f(a,xl),o=t.auth.teamState;n.setTeamLoader({key:ks.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:ks.UPDATE_USER_EXPIRATION_TIME,value:Gn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:ks.UPDATE_USER_EXPIRATION_TIME,value:!1})}},setUserAsPermanent:async a=>{const{callback:s}=a,i=f(a,$l),o=t.auth.teamState;n.setTeamLoader({key:ks.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:ks.UPDATE_USER_EXPIRATION_TIME,value:Gn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:ks.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:ks.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:ks.USERS,value:Gn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:ks.USERS,value:!1})},setUserRolesForSubTenants:async a=>{const{callback:s,userId:i}=a,o=f(a,Gl),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:Gn(t)})}),null==s||s(null,t)}},deleteUserFromSubTenants:async a=>{const{callback:s}=a,i=f(a,jl),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:Gn(t)})}),null==s||s(null,t)}},addUserToSubTenants:async a=>{const{callback:s}=a,i=f(a,Bl),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:Gn(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:Gn(e)}),null==a||a(null,e)}finally{n.setTeamLoader({key:t,value:!1})}};return{resendActivationLink:async t=>{const{callback:a}=t,n=f(t,Vl);await s(ks.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,Wl);await s(ks.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,Hl);await s(ks.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,zl);await s(ks.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:ks.GET_TOKEN_LINK,value:!1});try{const s=null==a?void 0:a.retryConfig;await(async t=>{n.setTeamError({key:ks.CONFIG_TOKEN_LINK,value:!1});try{const a=await Rn((()=>e.teams.getInviteLinkConfiguration()),t);n.setTeamState({inviteTokenState:S({},a)})}catch(t){n.setTeamError({key:ks.CONFIG_TOKEN_LINK,value:Gn(t)})}})(s);const i=await Rn((()=>e.teams.getInviteUserLink()),s),{inviteTokenState:o}=t.auth.teamState;n.setTeamState({inviteTokenState:S({},o,i)})}catch(t){n.setTeamError({key:ks.GET_TOKEN_LINK,value:Gn(t)})}},createInvitationLink:async a=>{const{callback:s}=a;n.setTeamError({key:ks.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:ks.CREATE_TOKEN_LINK,value:Gn(t)})}},updateInvitationLink:async a=>{const{callback:s,expiresInMinutes:i,shouldSendEmail:o}=a;n.setTeamError({key:ks.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:ks.UPDATE_TOKEN_LINK,value:Gn(t)})}},deleteInvitationLink:async t=>{const{callback:a}=null!=t?t:{};n.setTeamError({key:ks.DELETE_TOKEN_LINK,value:!1});try{await e.teams.deleteInviteUserLink(),n.setTeamState({inviteTokenState:void 0}),null==a||a(!0)}catch(t){n.setTeamError({key:ks.DELETE_TOKEN_LINK,value:Gn(t)}),null==a||a(!1,t)}}}})(t,e,a))},ql={tenants:[],subTenants:[],switchingTenant:!1,loading:!0,tenantTree:null},Jl=t=>rn(ql,t),Yl=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.tenantsState,e)};return{setTenantsState:s,resetTenantsState:()=>{Fn(t,["auth","tenantsState"],ql)},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=ue(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)}}}},Xl={loading:!1,error:null,username:void 0,fetching:!0},Ql=t=>rn(Xl,t),Zl=(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:Gn(t)})}finally{n({loading:!1})}};return{resetUsernamesState:()=>{Fn(t,["auth","usernamesState"],Xl)},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:Gn(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:Gn(t)})}finally{n({loading:!1})}},deleteUserUsername:s}},tc={userEmailPolicyConfig:null,loading:!1},ec=t=>rn(tc,t),ac=(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:Gn(t)})}}}},nc=(t,e,a)=>{const n=e=>{t.auth.user&&(t.auth.user.entitlements=e)},s=e=>{var a;co(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 sc;!function(t){t[t.Email=0]="Email",t[t.Otc=1]="Otc",t[t.Success=2]="Success"}(sc||(sc={}));const ic=["routes"],oc=["requestName"],rc=t=>{const e=null!=t?t:{},{routes:a}=e,n=f(e,ic);return rn(S({routes:S({},Pn,a),onRedirectTo:()=>{},isAuthenticated:!1,isLoading:!0,isSSOAuth:!1,user:null,error:void 0,errorByRequest:{},userIp:void 0,userIpData:{loading:!1}},n,{acceptInvitationState:un(null==n?void 0:n.acceptInvitationState),accountSettingsState:Vn(null==n?void 0:n.accountSettingsState),activateAccountState:qn(null==n?void 0:n.activateAccountState),unlockAccountState:xs(null==n?void 0:n.unlockAccountState),apiTokensState:js(null==n?void 0:n.apiTokensState),applicationsState:Hs(null==n?void 0:n.applicationsState),customLoginState:Js(null==n?void 0:n.customLoginState),forgotPasswordState:ti(null==n?void 0:n.forgotPasswordState),passwordRotationState:ii(null==n?void 0:n.passwordRotationState),groupsState:li(null==n?void 0:n.groupsState),groupsDialogsState:hi(null==n?void 0:n.groupsDialogsState),impersonateState:fi(null==n?void 0:n.impersonateState),loginState:wi(null==n?void 0:n.loginState),mfaState:Uo(null==n?void 0:n.mfaState),allAccountsState:jo(null==n?void 0:n.allAccountsState),allAccountsDialogsState:Vo(null==n?void 0:n.allAccountsDialogsState),passkeysState:tr(null==n?void 0:n.passkeysState),profileState:nr(null==n?void 0:n.profileState),provisioningState:rr(null==n?void 0:n.provisioningState),resetPhoneNumberState:pr(null==n?void 0:n.resetPhoneNumberState),rolesState:mr(null==n?void 0:n.rolesState),restrictionsState:_r(null==n?void 0:n.restrictionsState),securityCenterState:Mr(null==n?void 0:n.securityCenterState),securityPolicyState:jr(null==n?void 0:n.securityPolicyState),sessionsPolicyState:Jr(null==n?void 0:n.sessionsPolicyState),sessionsState:Zr(null==n?void 0:n.sessionsState),signUpState:nl(null==n?void 0:n.signUpState),smsState:ll(null==n?void 0:n.smsState),socialLoginState:Sl(null==n?void 0:n.socialLoginState),ssoState:wl(null==n?void 0:n.ssoState),stepUpState:Ul(null==n?void 0:n.stepUpState),teamState:Ll(null==n?void 0:n.teamState),tenantsState:Jl(null==n?void 0:n.tenantsState),usernamesState:Ql(null==n?void 0:n.usernamesState),userEmailPolicyState:ec(null==n?void 0:n.userEmailPolicyState)}))},lc=(t,e,a,n)=>{const s=e=>{Object.keys(e).forEach((a=>{const n=a;Nn(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))},i={acceptInvitationActions:jn(t,e),accountSettingsActions:Hn(t,e,a),activateAccountActions:Ms(t,e,a),unlockAccountActions:$s(t,e),apiTokensActions:Vs(t,e),applicationsActions:Ks(t,e,a),customLoginActions:Xs(t,e,a),entitlementsActions:nc(t,e),forgotPasswordActions:ai(t,e),passwordRotationActions:oi(t),groupsActions:gi(t,e),groupsDialogsActions:yi(t),impersonateActions:bi(t,e,a),loginActions:ko(t,e,a),mfaActions:$o(t,e,a),allAccountsActions:Xo(t,e,a),allAccountsDialogActions:Qo(t),passkeysActions:er(t,e,a),profileActions:ir(t,e,a),provisioningActions:ur(t,e),resetPhoneNumberActions:Sr(t,e,a),rolesActions:Ir(t,e),restrictionsActions:Dr(t,e,a),securityCenterActions:$r(t,e,a),securityPolicyActions:Kr(t,e,a),sessionsPolicyActions:Xr(t,e,a),sessionsActions:tl(t,e),signUpActions:ol(t,e,a),smsActions:yl(t,e),socialLoginActions:bl(t,e,a),ssoActions:kl(t,e,a),stepUpActions:Rl(t,e,a),teamActions:Kl(t,e,a),tenantsActions:Yl(t,e,a),usernamesActions:Zl(t,e),usersEmailsPolicyActions:ac(t,e)};return[S({setAuthState:s,setErrorByRequestName:e=>{let{requestName:a}=e,n=f(e,oc);t.auth.errorByRequest=S({},t.auth.errorByRequest,{[a]:S({},n,{isError:!0})})},setState:s,resetAuthState:(e={})=>{Fn(t,["auth"],S({},n,e))},setUser:t=>{s({user:t})}},Object.values(i).reduce(((t,e)=>S({},t,e)),{})),i]},cc={isLoading:!1,isSaving:!1,list:[],processIds:[],slackChannels:{isLoading:!1}},uc=t=>rn(cc,t),dc=["email","slack","sms","webhook"],gc={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"}},pc=["id"],hc=["id","enabled"],yc=(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=()=>{Fn(t,["connectivity"],cc)},c=async(t,e,a)=>{try{return await Rn((()=>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:dc;o({isLoading:!0});try{const t=await Promise.all([...e.map((t=>c(t,void 0,kn))),c("categories",void 0,kn),(async()=>(await Promise.all(e.map((t=>c("channelMap",t,kn))))).reduce(((t,a,n)=>S({},t,{[`${e[n]}`]:a})),{}))()]),a=await c("webhook",void 0,kn),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:gc[e[i]].events(n),active:gc[e[i]].isActive(n),platform:gc[e[i]].title,image:gc[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:Gn(t)})}},g=async(e,a)=>{const{list:n}=t.connectivity,s=n.find((({key:t})=>t===e));if(!s)return;const i=gc[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,pc);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,hc);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:Gn(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,Gn(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:Gn(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 vc;!function(t){t.UNKNWON="unknown",t.CARD="card"}(vc||(vc={}));const Sc={loading:!1,error:null,fetching:!0,config:null},fc=t=>rn(Sc,t);let mc,bc,Ac;!function(t){t.STRIPE="Stripe"}(mc||(mc={})),function(t){t.ACTIVE="ACTIVE",t.CANCELED="CANCELED",t.INCOMPLETE="INCOMPLETE",t.EXPIRED="EXPIRED",t.TRIALING="TRIALING"}(bc||(bc={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}(Ac||(Ac={}));const wc=(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:()=>{Fn(t,["subscriptions","config"],Sc)},loadPaymentConfiguration:async()=>{n({loading:!0});try{var t;(null!=(t=await e.subscriptions.getPaymentProviders())?t:[]).find((t=>"1"===t.status&&t.providerType===j.Stripe))?await(async()=>{n({loading:!0});try{const t=await e.subscriptions.getStripePaymentProviderConfiguration(),a={paymentProvider:mc.STRIPE,apiKey:t.publishableKey};n({config:a}),n({loading:!1,fetching:!1})}catch(t){s(Gn(t))}})():s(Gn("Payment provider not configured"))}catch(t){s(Gn(t))}}}},Tc={loading:!1,error:null,fetching:!0},Ec=t=>rn(Tc,t);function Pc({policy:t}){return{policy:Ac.AT_PERIOD_END}}function Oc(t){switch(t){case x.ACTIVE:return bc.ACTIVE;case x.INCOMPLETE:return bc.INCOMPLETE;case x.CANCELED:return bc.CANCELED;case x.EXPIRED:return bc.EXPIRED;case x.TRIALING:return bc.TRIALING;default:return bc.EXPIRED}}const Ic=(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?bc.ACTIVE:Oc(g.status),cancellation:g.cancellation&&Pc(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(Gn(t))}};return{setBillingInformationState:s,resetBillingInformationState:()=>{Fn(t,["subscriptions","billing","information"],Tc)},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 W(s?"Not authorized":"Internal feature failure",500,null))}}},kc={loading:!1,error:null,fetching:!0,invoices:[],invoiceDownload:{loading:!1,error:null}},_c=t=>rn(kc,t),Uc=(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=Gn(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:Gn(t,null)})}};return{setBillingInvoiceState:n,resetBillingInvoiceState:()=>{Fn(t,["subscriptions","billing","invoices"],kc)},loadInvoices:i,loadBillingInvoices:i,downloadInvoice:o,downloadBillingInvoice:o}},Rc={loading:!1,error:null,fetching:!0},Cc=t=>rn(Rc,t),Lc=(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(Gn(t))}};return{setBillingPaymentMethodState:n,resetBillingPaymentMethodState:()=>{Fn(t,["subscriptions","billing","paymentMethod"],Rc)},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(Gn(t)),null==l||l(!1,t)}finally{s(!1)}}}},Dc={loading:!1,error:null,fetching:!0,cancellation:{loading:!1,error:null},renewal:{loading:!1,error:null}},Nc=t=>rn(Dc,t),Mc=(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(Gn(t))}};return{setBillingSubscriptionState:s,resetBillingSubscriptionState:()=>{Fn(t,["subscriptions","billing","subscription"],Dc)},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 W("TenantId is not defined",500,null))},cancelSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void r(new W("Subscription not found",500,null));if(null!=a&&a.externallyManaged)return void r(new W("Billing is externally managed",500,null));const{id:n,cancellation:s,status:i}=a||{};if(!s&&i===x.ACTIVE)try{o(!0),await e.subscriptions.cancelManagedSubscription(n),await u(),o(!1)}catch(t){r(Gn(t))}},renewSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void c(new W("Subscription not found",500,null));if(null!=a&&a.externallyManaged)return void c(new W("Billing is externally managed",500,null));const{id:n,cancellation:s}=a||{};if((null==s?void 0:s.policy)===G.AT_PERIOD_END)try{l(!0),await e.subscriptions.renewManagedSubscription(n),await u(),l(!1)}catch(t){c(Gn(t))}}}},Fc=t=>rn({information:Ec(null==t?void 0:t.information),invoices:_c(null==t?void 0:t.invoices),paymentMethod:Cc(null==t?void 0:t.paymentMethod),subscription:Nc(null==t?void 0:t.subscription)}),xc={loading:!1,error:null,fetching:!0,plans:[]},$c=t=>rn(xc,t),Gc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.plans,e)};return{setPlansState:n,resetPlansState:()=>{Fn(t,["subscriptions","plans"],xc)},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=Gn(e),n({loading:!1,fetching:!1,error:t})}var t}}},jc={fetching:!0,loading:!1,error:null,confirmed:!1},Bc=t=>rn(jc,t),Vc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.checkout,e)};return{setCheckoutState:s,resetCheckoutState:()=>{Fn(t,["subscriptions","checkout"],jc)},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)===x.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:x.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:Gn(t)})}}else s({loading:!1,error:new W("Subscription not found",500,null)})},errorCheckout:t=>{s({loading:!1,error:t})}}},Wc={loading:!1,error:null,cardSetupIntentSecret:null},Hc=t=>rn(Wc,t),zc=(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=Gn(e),Object.assign(t.subscriptions.stripe,{error:s,loading:!1,fetching:!1})}var s},setStripeState:n,resetStripeState:()=>{Fn(t,["subscriptions","stripe"],Wc)}}},Kc={loading:!1,fetching:!0,vendorPublicConfig:null},qc=t=>rn(Kc,t),Jc=(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:()=>{Fn(t,["subscriptions","vendorPublicConfig"],Kc)},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(Gn(t))}}}},Yc=t=>rn({config:fc(null==t?void 0:t.config),billing:Fc(null==t?void 0:t.billing),plans:$c(null==t?void 0:t.plans),checkout:Bc(null==t?void 0:t.checkout),stripe:Hc(null==t?void 0:t.stripe),vendorPublicConfig:qc(null==t?void 0:t.vendorPublicConfig)}),Xc=(t,e,a)=>{const n=wc(t,e),[s,i]=((t,e,a)=>{const n=Ic(t,e,a),s=Lc(t,e),i=Uc(t,e),o=Mc(t,e,a);return[S({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=Gc(t,e),r=Vc(t,e,a),l=zc(t,e),c=Jc(t,e);return[S({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},Qc={loading:!1},Zc=t=>rn(Qc,t),tu=(t,e,a)=>{const n=e=>{Object.assign(t.vendor,e)},s=async t=>{n({loading:!0});try{var a;const s=await Rn((()=>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:()=>{Fn(t,["vendor"],Qc)},loadVendorPublicInfo:s,loadVendorPublicConfiguration:s}},eu={loading:!0,pageOffset:0,pageSize:20,logs:[],sort:[],filter:[],totalPages:0,isDownloadingCsv:!1},au=t=>rn(eu,t),nu=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auditLogs.auditLogsState,e)};return{setAuditLogsState:s,resetAuditLogsState:()=>{Fn(t,["auditLogs","auditLogsState"],eu)},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 Rn((()=>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:Gn(t)}),null==a||null==(p=a.callback)||p.call(a,null,t)}}}},su={loading:!0},iu=t=>rn(su,t),ou=(t,e,a)=>{const n=e=>{Object.assign(t.auditLogs.auditsMetadataState,e)};return{setAuditsMetadataState:n,resetAuditsMetadataState:()=>{Fn(t,["auditLogs","auditsMetadataState"],su)},loadAuditsMetadata:async t=>{n({loading:!0,error:null});try{const{properties:a}=await Rn((()=>e.metadata.getAuditsMetadata()),null==t?void 0:t.retryConfig);n({columns:a,loading:!1})}catch(t){n({error:t,loading:!1})}}}},ru=t=>({auditLogsState:au(null==t?void 0:t.auditLogsState),auditsMetadataState:iu(null==t?void 0:t.auditsMetadataState)}),lu=(t,e,a)=>S({},nu(t,e,a),ou(t,e)),cu={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},uu=(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`)}})}),{}),du={clientId:"CLIENT_ID_16806d3d-8fc3-4450-be97-abdaf66b723e",secret:"SECRET_16806d3d-8fc3-4450-be97-abdaf66b723e",createdAt:"createdAt",description:"Demo API Token (preview only)"},gu=S({},du,{roleIds:[],tenantId:"my-tenant-id",createdByUserId:"createdByUserId"}),pu=[{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"}],hu={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},yu=S({},hu,{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}),vu={loading:!1,error:void 0,saving:!0,profile:hu},Su={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"},fu={allowSignups:!0,allowNotVerifiedUsersLogin:!1,apiTokensEnabled:!0,forcePermissions:!1,authStrategy:N.EmailAndPassword,machineToMachineAuthStrategy:M.ClientCredentials},mu={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date},bu={id:"id",enabled:!0,maxAttempts:1,createdAt:new Date,updatedAt:new Date},Au={id:"id",enabled:!0,historySize:1,createdAt:new Date,updatedAt:new Date},wu={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},Tu={id:"id",createdAt:"createdAt",updatedAt:"updatedAt",properties:[],vendorId:"vendorId",entityName:"saml",isActive:!0,configuration:{acsUrl:"acsUrl",spEntityId:"spEntityId"}},Eu=[{id:"id",description:"description",key:"key",name:"name",permissions:[],permissionLevel:1}],Pu={firstLoad:!1,loading:!1,error:void 0,saving:!1,samlConfiguration:wu,roles:Eu,authorizationRoles:[],errors:{},loaders:{},ssoConfigurations:[]},Ou=[{description:"string",fePermission:!0,id:"id",key:"key",name:"name",roleIds:[],createdAt:new Date,updatedAt:new Date,categoryId:"categoryId"}],Iu={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:[pu[0]],groups:[{id:"id2",name:"Developers",color:"#03A9F4",roles:[pu[0]],managedBy:Wa.FRONTEGG}]},ku={id:Iu.id,email:Iu.email,name:Iu.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:[pu[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},_u={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:[pu[1]],groups:[{id:"id1",name:"Designers",color:"#E1F5E2",roles:[pu[0]],managedBy:Wa.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:[pu[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},Ru={metadata:"",mfaEnrolled:!1,provider:"",sub:"",tenantIds:[],tenants:[],verified:!1,id:"id",email:"email",name:"name",tenantId:"tenantId",createdAt:new Date},Cu=[_u,Iu],Lu=[Uu,ku],Du=[Ru],Nu=[{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}],Mu=[{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"}],Fu={isActive:!0,strategy:Kt.ALLOW},xu=[{updatedAt:new Date,createdAt:new Date,id:"1",ip:"255.255.255.255",isActive:!0,strategy:Kt.ALLOW,description:"My IP"},{updatedAt:new Date,createdAt:new Date,id:"2",ip:"255.255.255.254",isActive:!0,strategy:Kt.ALLOW,description:"IP 2"},{updatedAt:new Date,createdAt:new Date,id:"3",ip:"255.255.255.253",isActive:!0,strategy:Kt.BLOCK,description:"IP 3"},{updatedAt:new Date,createdAt:new Date,id:"4",ip:"255.255.255.253",isActive:!0,strategy:Kt.BLOCK,description:"IP 4"}],$u=t=>{const e=[];return Array.from({length:t}).forEach(((t,a)=>{e.push(S({},_u,{name:"Demo User",id:`id${a}`,profilePictureUrl:null,createdAt:new Date}))})),e},Gu=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"}),ju=[{id:"id1",name:"Designers",color:"#E1F5E2",description:"The whole design team",users:$u(6),roles:[Gu("Editor")],metadata:'{"lastTermsCheck":"2022-08-16T10:31:11.270Z"}',managedBy:Wa.FRONTEGG},{id:"id2",name:"Developers",color:"#03A9F4",description:"All frontend and backend developers",users:$u(44),roles:[Gu("Editor")],managedBy:Wa.FRONTEGG},{id:"id3",name:"Product",color:"#E1583E",description:"PMs and team leads",users:$u(8),roles:[Gu("Viewer")],managedBy:Wa.FRONTEGG},{id:"id4",name:"Management",color:"#9AE0FF",description:"Executives",users:$u(5),roles:[Gu("Admin")],managedBy:Wa.FRONTEGG},{id:"id5",name:"Sales",color:"#ED8E7C",users:$u(21),description:"BDR, AE, and inside sales",roles:[Gu("Viewer")],managedBy:Wa.FRONTEGG},{id:"id6",name:"Support",color:"#A79D7B",users:$u(23),description:"Dev success and customer success",roles:[Gu("Admin")],managedBy:Wa.FRONTEGG},{id:"id7",name:"Marketing",color:"#2CA744",users:$u(10),description:"The marketing department",roles:[Gu("Viewer")],managedBy:Wa.FRONTEGG},{id:"id8",name:"HR",color:"#EAE1C2",users:$u(4),description:"Human resources",roles:[Gu("Viewer")],managedBy:Wa.FRONTEGG},{id:"id9",name:"Finance",color:"#5587C0",users:$u(3),roles:[Gu("Viewer")],managedBy:Wa.FRONTEGG},{id:"id10",name:"Operations",color:"#B1CAE7",users:$u(8),roles:[Gu("Editor")],managedBy:Wa.FRONTEGG},{id:"id11",name:"Legal",color:"#2CA744",users:$u(4),roles:[Gu("Viewer")],managedBy:Wa.FRONTEGG}],Bu={scoring:{score:79},recommendations:{items:[{code:Ja.FORCE_MFA,severity:Qa.WARNING,category:Za.MFA},{code:Ja.ENABLE_FORCE_RELOGIN,severity:Qa.WARNING,category:Za.SESSIONS}]}},Vu={insights:{items:[{category:Za.MFA,code:Ya.PARTIALLY_FORCED_MFA,metadata:{totalUsers:2,mfa:{enrolledUsersCount:1}}},{category:Za.SESSIONS,code:Ya.PARTIAL_SESSION_SETTINGS,metadata:{totalUsers:2,sessions:{idleTimeoutRecommendation:1800}}},{category:Za.PASSWORD,code:Ya.IMPROVE_PASSWORD_HISTORY_POLICY,metadata:{password:{userLockoutRecommendation:5,historyRecommendations:5}}},{category:Za.DOMAIN,code:Ya.NO_IP_RESTRICTIONS,metadata:{restrictions:{ipsCount:1,domainsCount:1}}}]}},Wu={users:Lu,totalUsersItems:2,totalUsersPages:1,usersPageOffset:0},Hu={users:[Lu[0]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0,queryParams:{_maxInactiveSeconds:7776e3}},zu={users:[Lu[1]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0};La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.ASSIGNABLE,new Date,new Date,La.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 Ku,qu=new Uint8Array(16);function Ju(){if(!Ku&&!(Ku="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 Ku(qu)}const Yu=/^(?:[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 Xu=[],Qu=0;Qu<256;++Qu)Xu.push((Qu+256).toString(16).substr(1));const Zu=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(Xu[t[e+0]]+Xu[t[e+1]]+Xu[t[e+2]]+Xu[t[e+3]]+"-"+Xu[t[e+4]]+Xu[t[e+5]]+"-"+Xu[t[e+6]]+Xu[t[e+7]]+"-"+Xu[t[e+8]]+Xu[t[e+9]]+"-"+Xu[t[e+10]]+Xu[t[e+11]]+Xu[t[e+12]]+Xu[t[e+13]]+Xu[t[e+14]]+Xu[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&Yu.test(t)}(a))throw TypeError("Stringified UUID is invalid");return a},td=function(t,e,a){var n=(t=t||{}).random||(t.rng||Ju)();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 Zu(n)},ed=["callback"],ad=["callback"],nd=["callback","profilePictureUrl"],sd=["callback"],id=["callback"],od=["callback"],rd=["callback"],ld=["callback"],cd=["callback"],ud=["callback"],dd=["callback"],gd=["callback","samlVendor"],pd=["callback"],hd=["callback"],yd=["callback","profileImage"],vd=["callback"],Sd=["callback"],fd=["callback"],md=["callback"],bd=["callback"],Ad=["callback"],wd=["callback"],Td=["callback"],Ed=["requestName"],Pd=t=>"createdAt"!==t.id,Od={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`})))},Id={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}]},kd=(t,e,a)=>{const n=((t,e,a)=>{const n=nu(t,e,a),s=uu(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}=Od;let n=a.filter((t=>e=>t.filter(Pd).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:Gn(t)}),null==e||null==(d=e.callback)||d.call(e,null,t)}},s})(t,e,a),s=((t,e)=>{const a=ou(t,e),n=uu(a,["setAuditsMetadataState","resetAuditsMetadataState"]);return n.loadAuditsMetadata=async()=>{n.setAuditsMetadataState({loading:!0,error:null});try{const{properties:t}=Id;n.setAuditsMetadataState({columns:t,loading:!1})}catch(t){n.setAuditsMetadataState({error:t,loading:!1})}},n})(t,e);return S({},n,s)},_d={id:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",externalId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",startDate:"2021-09-20T08:08:51.000Z",status:x.ACTIVE,externallyManaged:!1,cancellation:null,currentPeriodStart:"2021-09-20T08:08:51.000Z",currentPeriodEnd:"2021-10-20T08:08:51.000Z",plan:{slug:"test"}},Ud=[{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"}],Rd=[{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:""}],Cd=[{id:"id",externalId:"externalId",type:$.CARD,isDefault:!0,last4:"4242",expMonth:11,expYear:25,brand:"visa",billingDetails:{name:"Dummy",email:"dummy@email.com"}}],Ld={allowPlanDowngrade:!0,allowPlanCancellation:!0},Dd=(t,e,a)=>{const n=((t,e)=>{const a=wc(t,e),n=uu(a,["setPaymentConfigState","resetPaymentConfigState"]);return n.loadPaymentConfiguration=async()=>{n.setPaymentConfigState({loading:!0}),await _n(500),n.setPaymentConfigState({loading:!1,fetching:!1,config:{paymentProvider:mc.STRIPE,apiKey:""}})},n})(t,e),[s,i]=((t,e,a)=>{const n=((t,e,a)=>{const n=Ic(t,e,a),s=uu(n,["setBillingInformationState","resetBillingInformationState"]);return s.loadBillingInformation=async()=>{var t,e;s.setBillingInformationState({loading:!0}),await _n(500),s.setBillingInformationState({loading:!1,fetching:!1,summary:{subscriptionId:_d.id,paymentMethodId:"mockPaymentMethodId",tenantConfigurationId:"mockTenantConfigurationId",providerType:j.Stripe,externallyManaged:!1,currentPlanId:Ud[0].id,defaultPlanId:Ud[0].id},plan:S({},Ud[0],{price:null==(t=Ud[0].price)?void 0:t.amount,currency:null==(e=Ud[0].price)?void 0:e.currency,recurringInterval:"month"})})},s})(t,e,a),s=((t,e)=>{const a=Lc(t,e),n=uu(a,["setBillingPaymentMethodState","resetBillingPaymentMethodState"]);return n.loadPaymentMethod=async()=>{n.setBillingPaymentMethodState({loading:!0}),await _n(500),n.setBillingPaymentMethodState({paymentMethod:Cd[0],loading:!1,fetching:!1})},n})(t,e),i=((t,e)=>{const a=Uc(t,e),n=uu(a,["setBillingInvoiceState","resetBillingInvoiceState"]);return n.loadBillingInvoices=async()=>{n.setBillingInvoiceState({loading:!0}),await _n(500),n.setBillingInvoiceState({loading:!1,fetching:!1,invoices:Rd.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=Mc(t,e,a),s=uu(n,["setBillingSubscriptionState","resetBillingSubscriptionState","setCancellationLoading","setCancellationError","setRenewalLoading","setRenewalError"]);return s.loadSubscription=async()=>{s.setBillingSubscriptionState({loading:!0}),await _n(500),s.setBillingSubscriptionState({subscription:_d,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=Gc(t,e),n=uu(a,["setPlansState","resetPlansState"]);return n.loadPlans=async()=>{n.setPlansState({loading:!0}),await _n(500),n.setPlansState({fetching:!1,loading:!1,plans:Ud.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=Vc(t,e,a);return uu(n,["setCheckoutState","resetCheckoutState","errorCheckout","resetCheckout"])})(t,e,a),l=((t,e)=>{const a=zc(t,e);return uu(a,[])})(t,e),c=((t,e)=>{const a=Jc(t,e),n=uu(a,["setVendorPublicConfigState","resetVendorPublicConfigState","setVendorPublicConfigError","setVendorPublicConfigLoading"]);return n.loadVendorPublicConfiguration=async()=>{n.setVendorPublicConfigLoading(!0),await _n(),n.setVendorPublicConfigState({fetching:!1,loading:!1,vendorPublicConfig:Ld})},n})(t,e);return[S({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},Nd=(t,e,a,n)=>{const{authActions:s,authStateActions:i}=((t,e,a,n)=>{const s=((t,e)=>{const a=jn(t,e);return uu(a,["setAcceptInvitationState","resetAcceptInvitationState"])})(t,e),i=((t,e,a)=>{const n=Hn(t,e,a),s=uu(n,["setAccountSettingsState","resetAccountSettingsState"]);return s.saveAccountSettings=async e=>{var a;s.setAccountSettingsState({loading:!0}),await _n();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 _n(),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=$s(t,e);return uu(a,["setUnlockAccountState","resetUnlockAccountState"])})(t,e),r=((t,e,a)=>{const n=Ms(t,e,a);return uu(n,["setActivateState","resetActivateState","setActivateStrategyState"])})(t,e,a),l=((t,e,a)=>{const n=Xo(t,e,a);return uu(n,["setAllAccountsLoader","setAllAccountsError","setAllAccountsState","setSelectedAccountState","resetAllAccountsState","clearSelectedAccount"])})(t,e,a),c=Qo(t),u=((t,e)=>{const a=Vs(t,e),n=uu(a,["setApiTokensState","resetApiTokensState","setApiTokensLoader","setApiTokensError"]);return n.addTenantApiToken=async e=>{const{description:a,roleIds:s,callback:i}=e;n.setApiTokensLoader({key:Bs.ADD_API_TOKEN,value:!0});const{apiTokensDataTenant:o}=t.auth.apiTokensState,r=S({},gu,{description:a,roleIds:s,clientId:`CLIENT_ID_${td()}`});n.setApiTokensState({showAddTokenDialog:!1}),await _n(200),n.setApiTokensState({apiTokensDataTenant:[...o,r],successDialog:{open:!0,secret:r.secret,clientId:r.clientId}}),await _n(200),n.setApiTokensLoader({key:Bs.ADD_API_TOKEN,value:!1}),null==i||i(null)},n.deleteTenantApiToken=async t=>{n.setApiTokensLoader({key:Bs.DELETE_API_TOKEN,value:!0}),await _n(200);const e=[gu];n.setApiTokensState({apiTokensDataTenant:e.filter((e=>e.clientId!==t)),deleteTokenDialog:{open:!1,clientId:t}}),n.setApiTokensLoader({key:Bs.DELETE_API_TOKEN,value:!1})},n.loadApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Bs.LOAD_API_TOKENS,value:!0});const a=[du],s=[gu];n.setApiTokensState({apiTokensDataUser:a,apiTokensDataTenant:s}),await _n(200),n.setApiTokensLoader({key:Bs.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:Bs.LOAD_API_TOKENS,value:!0});const a=[du];n.setApiTokensState({apiTokensDataUser:a}),await _n(200),n.setApiTokensLoader({key:Bs.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:Bs.LOAD_API_TOKENS,value:!0});const a=[gu];n.setApiTokensState({apiTokensDataTenant:a}),await _n(200),n.setApiTokensLoader({key:Bs.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n})(t,e),d=((t,e,a)=>{const n=Ks(t,e,a);return uu(n,["setApplicationsState","resetApplicationsState"])})(t,e,a),g=((t,e,a)=>{const n=Xs(t,e,a),s=uu(n,["setCustomLoginState","resetCustomLoginState"]);return s.loadTenantMetadata=async()=>{s.setCustomLoginState({loading:!0}),await _n(),s.setCustomLoginState({loading:!1})},s.updateTenantMetadata=async t=>{const{callback:e}=t;s.setCustomLoginState({loading:!0,error:null}),await _n(),s.setCustomLoginState({loading:!1,error:null}),null==e||e(!0)},s})(t,e,a),p=((t,e)=>{const a=nc(t,e);return uu(a,["setEntitlements","handleFetchedEntitlements"])})(t,e),h=((t,e)=>{const a=ai(t,e),n=uu(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:Gn(t)})}},n})(t,e),y=(t=>{const e=oi(t),a=uu(e,["setStep"]);return a.setStep(ni.success),a})(t),v=((t,e)=>{const a=gi(t,e),n=uu(a,["setGroupsState","resetUsersGroupsState","setUsersGroupsLoader","setUsersGroupsError"]);return n.loadGroups=async()=>{const t=ci.GET_GROUPS;n.setUsersGroupsLoader({key:t,value:!0});const e=ju;n.setGroupsState({groups:e}),n.setUsersGroupsLoader({key:t,value:!1})},n.createGroup=async e=>{var a;const s=ci.CREATE_GROUP,{groups:i}=t.auth.groupsState;n.setUsersGroupsLoader({key:s,value:!0}),await _n(500),n.setGroupsState({groups:[S({},e,{id:`${e.name}ID`,managedBy:Wa.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=ci.UPDATE_GROUP,c=t.auth.groupsState;n.setUsersGroupsLoader({key:l,value:!0}),await _n(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:Wa.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=ci.DELETE_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await _n(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=ci.ADD_ROLES_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await _n(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=ci.DELETE_ROLES_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await _n(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=ci.ADD_USERS_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await _n(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=ci.DELETE_USERS_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await _n(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=ci.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=ci.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=yi(t),b=((t,e,a)=>{const n=bi(t,e,a);return uu(n,["setImpersonateState","resetImpersonateState"])})(t,e,a),A=((t,e,a)=>{const n=a,s=ko(t,e,n),i=uu(s,["setLoginState","resetLoginState","afterAuthNavigation"]);return i.requestAuthorize=async t=>{t&&n.setAuthState({isLoading:!0});const e=yu;await n.loadTenants(),n.setAuthState({user:e,isAuthenticated:!0,isLoading:!1})},i.getUserIP=async t=>{const{callback:e}=t;try{const{ip:t}=xu[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=$o(t,e,n),i=uu(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,ed),t.auth.mfaState);i.setMfaState({saving:!0}),await _n();const o={token:"token",recoveryCode:"recoveryCode"},r={step:es.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({},yu,{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 _n(),i.setMfaState({saving:!1,error:void 0,mfaDevices:S({},s,{authenticators:[]})}),n.setUser(S({},yu)),null==(a=e.callback)||a.call(e,!0)},i.verifyMfaAfterForce=async t=>{const{callback:e}=t,a=f(t,ad);i.setMfaState({loading:!0}),await _n();const s=S({},a,{recoveryCode:"recoveryCode"}),o={step:es.recoveryCode,loading:!1,error:void 0,saving:!1};null!=s&&s.recoveryCode&&(o.recoveryCode=s.recoveryCode),i.setMfaState(o),await _n(),n.setUser(S({},yu,{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:Gn(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 _n(),i.setMfaState({loading:!1,error:void 0,mfaDevices:S({},s,{phones:[]})}),n.setUser(S({},yu)),null==(a=e.callback)||a.call(e,!0)},i.preEnrollMfaSms=async t=>{var e;i.setMfaState({saving:!0}),await _n(),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 _n();const o={token:"token",recoveryCode:"recoveryCode"},r={step:es.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({},yu,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i})(t,e,a),T=((t,e,a)=>{const n=er(t,e,a);return uu(n,["setPasskeysState","resetPasskeysState"])})(t,e,a),E=((t,e,a)=>{const n=ir(t,e,a),s=uu(n,["setProfileState","resetProfileState"]);return s.loadProfile=async()=>{s.setProfileState({loading:!0}),await _n(),a.setUser(S({},yu,hu)),s.setProfileState({loading:!1,profile:hu})},s.saveProfile=async t=>{const{callback:e,profilePictureUrl:n}=t,i=f(t,nd);s.setProfileState({saving:!0,error:null});const o=vu;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=yu;await _n(),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 _n(),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 _n(),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 _n(),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=ur(t,e);return uu(a,["setProvisioningState","resetProvisioningState"])})(t,e),O=((t,e,a)=>{const n=Sr(t,e,a);return uu(n,["setResetPhoneNumberState","resetResetPhoneNumberState"])})(t,e,a),I=((t,e,a)=>{const n=Dr(t,e,a),s=uu(n,["setRestrictionsState","setIpRestrictionsState","setEmailDomainRestrictionsState"]);return s.loadIpRestrictions=async()=>{s.setIpRestrictionsState({loading:!0,error:null}),s.setIpRestrictionsState({data:{restrictions:xu.filter((t=>t.strategy===Fu.strategy)),config:Fu},totalPages:1,pagination:{_filter:Kt.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:Kt.ALLOW}],config:{active:!0,listType:Kt.ALLOW,blockPublicDomains:!1}}})},s.saveIpRestriction=async e=>{var a,n,i;const{callback:o}=e,r=f(e,sd);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:Kt.ALLOW},restrictions:[...c,S({},r,{createdAt:new Date,updatedAt:new Date,id:td(),isActive:null==(i=r.isActive)||i,strategy:l.data.config.strategy})]},totalPages:1,pagination:{_filter:Kt.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,id),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:Kt.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:Kt.ALLOW},restrictions:o.data.restrictions.filter((t=>t.id!==i))},pagination:{_filter:Kt.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=xu[0].ip,n=!!e.data.restrictions.find((t=>t.isActive&&t.ip===a));s.setIpRestrictionsState({userIpValid:n,loading:!1})}catch(t){s.setIpRestrictionsState({error:Gn(t),loading:!1})}},s.saveEmailDomainRestriction=async e=>{var a,n;const{callback:i}=e,o=f(e,od),r=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await _n(),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,rd),o=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await _n(),null==n||n(!0),s.setEmailDomainRestrictionsState({data:{config:{active:i.active,blockPublicDomains:i.blockPublicDomains||!1,listType:i.type||Kt.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 _n(),s.setEmailDomainRestrictionsState({data:{config:(null==(a=o.data)?void 0:a.config)||{active:!1,blockPublicDomains:!1,listType:Kt.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=Ir(t,e),n=uu(a,["setRolesState","setRolesStateError","setRolesStateLoader","resetRolesState"]);return n.loadRolesAndPermissions=async t=>{var e;const a=br.LOAD_ROLES;n.setRolesStateLoader({key:a,value:!(null!=(e=null==t?void 0:t.silentLoading)&&e)});try{n.setRolesState({roles:pu})}catch(t){n.setRolesStateError({key:a,value:Gn(t)})}finally{n.setRolesStateLoader({key:a,value:!1})}},n})(t,e),_=((t,e,a)=>{const n=$r(t,e,a),s=uu(n,["setSecurityCenterState","setSecurityCenterStateError","setSecurityCenterStateLoader","resetSecurityCenterState"]);return s.loadRecommendations=async()=>{const t=Fr.RECOMMENDATIONS;s.setSecurityCenterStateLoader({key:t,value:!0}),await _n(),s.setSecurityCenterState({recommendations:Bu.recommendations.items,score:Bu.scoring.score}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInsights=async()=>{const t=Fr.INSIGHTS;s.setSecurityCenterStateLoader({key:t,value:!0}),await _n(),s.setSecurityCenterState({insights:Vu.insights.items}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadBreachedPasswordUsers=async()=>{const t=Fr.BREACHED_PASSWORD_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await _n(),s.setSecurityCenterState({breachedPasswordUsersTable:Wu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadUnenrolledMfaUsers=async()=>{const t=Fr.UNENROLLED_MFA_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await _n(),s.setSecurityCenterState({unenrolledMfaUsersTable:zu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInactiveUsers=async()=>{const t=Fr.INACTIVE_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await _n(),s.setSecurityCenterState({inactiveUsersTable:Hu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.sendResetBreachedPasswordEmail=async t=>{const{callback:e}=t,a=Fr.SEND_BREACHED_PASSWORD_EMAIL;s.setSecurityCenterStateLoader({key:a,value:!0}),await _n(),null==e||e(!0),s.setSecurityCenterStateLoader({key:a,value:!1})},s})(t,e,a),U=((t,e,a)=>{const n=Kr(t,e,a),s=uu(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 _n(),s.setSecurityPolicyGlobalState({policy:Su,loading:!1})},s.loadPublicSecurityPolicy=async()=>{s.setSecurityPolicyPublicState({loading:!0,error:null});try{s.setSecurityPolicyPublicState({policy:fu,loading:!1})}catch(t){s.setSecurityPolicyPublicState({error:Gn(t),loading:!1})}},s.saveSecurityPolicyMfa=async t=>{var e;const{callback:a}=t,n=f(t,ld);s.setSecurityPolicyMfaState({saving:!0,error:null});const i=S({},bu,{id:null!=(e=n.id)?e:bu.id,enforceMFAType:n.enforceMFAType});await _n(),s.setSecurityPolicyMfaState({policy:i,saving:!1}),null==a||a(i)},s.loadSecurityPolicyMfa=async()=>{s.setSecurityPolicyMfaState({loading:!0,error:null}),await _n(),s.setSecurityPolicyMfaState({policy:mu,loading:!1})},s.loadSecurityPolicyVendorMfa=async()=>{s.setSecurityPolicyVendorMfaState({loading:!0,error:null}),await _n(),s.setSecurityPolicyVendorMfaState({policy:mu,loading:!1})},s.saveSecurityPolicyLockout=async t=>{const{callback:e}=t,a=f(t,cd);s.setSecurityPolicyLockoutState({saving:!0,error:null}),await _n();const n=S({},bu,a,{id:a.id?a.id:bu.id});null==e||e(n),s.setSecurityPolicyLockoutState({policy:n,saving:!1})},s.loadSecurityPolicyLockout=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await _n(),s.setSecurityPolicyLockoutState({policy:bu,loading:!1})},s.loadSecurityPolicyVendorLockout=async()=>{s.setSecurityPolicyVendorLockoutState({loading:!0,error:null}),await _n(),s.setSecurityPolicyVendorLockoutState({policy:bu,loading:!1})},s.loadSecurityPolicyCaptcha=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await _n(),s.setSecurityPolicyLockoutState({policy:bu,loading:!1})},s.saveSecurityPolicyPasswordHistory=async t=>{const{callback:e}=t,a=f(t,ud);s.setSecurityPolicyPasswordHistoryState({saving:!0,error:null}),await _n();const n=S({},Au,a,{id:a.id?a.id:Au.id});null==e||e(n),s.setSecurityPolicyPasswordHistoryState({policy:n,saving:!1})},s.loadSecurityPolicyPasswordHistory=async()=>{s.setSecurityPolicyPasswordHistoryState({loading:!0,error:null}),await _n(),s.setSecurityPolicyPasswordHistoryState({policy:Au,loading:!1})},s.loadSecurityPolicyVendorPasswordHistory=async()=>{s.setSecurityPolicyVendorPasswordHistoryState({loading:!0,error:null}),await _n(),s.setSecurityPolicyVendorPasswordHistoryState({policy:Au,loading:!1})},s})(t,e,a),R=((t,e)=>{const a=tl(t,e),n=uu(a,["setSessionsState","resetSessionsState"]);return n.loadUserSessions=async()=>{n.setSessionsState({loading:!0,error:null}),n.setSessionsState({sessions:Mu,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=Mu.filter((t=>t.current));n.setSessionsState({sessions:t,loading:!1})},n})(t,e),C=((t,e,a)=>{const n=Xr(t,e,a),s=uu(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,dd);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=ol(t,e,a);return uu(n,["setSignUpState","resetSignUpState","resetSignUpStateSoft"])})(t,e,a),D=((t,e)=>{const a=yl(t,e);return uu(a,["setSmsState","resetSmsState"])})(t,e),N=((t,e,a)=>{const n=bl(t,e,a);return uu(n,["setSocialLoginsState","resetSocialLoginsState","setSocialLoginError"])})(t,e,a),M=((t,e,a)=>{const n=kl(t,e,a),s=uu(n,["setSSOState","resetSSOState"]);return s.loadSSOConfigurations=async()=>{s.setSSOState({loading:!0}),await _n(),s.setSSOState({samlConfiguration:wu,loading:!1,firstLoad:!1})},s.saveSSOConfigurations=async t=>{var e,a;const{callback:n,samlVendor:i}=t,o=f(t,gd),r=Pu.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 _n(),l.acsUrl=null==Tu||null==(e=Tu.configuration)?void 0:e.acsUrl,l.spEntityId=null==Tu||null==(a=Tu.configuration)?void 0:a.spEntityId;const u=Dn(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 _n(),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=Pu.samlConfiguration;s.setSSOState({error:void 0,saving:!0}),await _n(),s.setSSOState({samlConfiguration:S({},a,{validated:!0}),error:void 0,saving:!1}),null==e||e(!0)},s.loadSSOAuthorizationRoles=async()=>{await _n(),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 _n(),s.setSSOState({authorizationRoles:a,error:void 0,saving:!1}),null==e||e(!0)},s})(t,e,a),F=((t,e,a)=>{const n=Rl(t,e,a);return uu(n,["setStepUpState","resetStepUpState"])})(t,e,a),x=((t,e,a)=>{const n=Kl(t,e,a),s=uu(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:ks.USERS,value:!r}),s.setTeamState({pageSize:u,pageOffset:d,filterV2:g,sortV2:p}),await _n(),s.setTeamState({users:Cu,totalPages:2,totalItems:10,roles:Eu,permissions:Ou}),s.setTeamLoader({key:ks.USERS,value:!1}),null==l||l(Cu)},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:ks.USERS,value:!l}),s.setTeamState({allUsersQueryParams:{_limit:d,_offset:g,_filter:p,_sortBy:h,_order:y}}),await _n(),s.setTeamState({allUsers:Du,totalPages:2,totalItems:10,roles:Eu,permissions:Ou}),s.setTeamLoader({key:ks.USERS,value:!1}),null==c||c(Du)},s.loadRoles=async t=>{var e;s.setTeamLoader({key:ks.ROLES_AND_PERMISSIONS,value:!0}),await _n(),s.setTeamState({roles:Eu,permissions:Ou}),s.setTeamLoader({key:ks.ROLES_AND_PERMISSIONS,value:!0}),null==t||null==(e=t.callback)||e.call(t,{roles:Eu,permissions:Ou})},s.addUser=async e=>{const{callback:a}=e,n=f(e,pd),i=t.auth.teamState;s.setTeamState({addUserDialogState:S({},i.addUserDialogState,{loading:!0})}),await _n();const o=new Date,r=S({},_u,{groups:[]},n,{id:`${td()}`,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,hd),i=t.auth.teamState;s.setTeamState({addUserDialogState:S({},i.addUserDialogState,{loading:!0})}),await _n();const o=S({},_u,n,{id:`${td()}`});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,yd),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));s.setTeamLoader({key:ks.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 _n();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:ks.UPDATE_USER,value:!1})},s.deleteUser=async e=>{const{callback:a}=e,n=f(e,vd),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:S({},i.deleteUserDialogState,{loading:!0})}),await _n(),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,Sd),i=t.auth.teamState;s.setTeamLoader({key:ks.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 _n(),null==a||a(!0),s.setTeamLoader({key:ks.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.setUserAsPermanent=async e=>{const{callback:a}=e,n=f(e,fd),i=t.auth.teamState;s.setTeamLoader({key:ks.UPDATE_USER_EXPIRATION_TIME,value:!0}),s.setTeamState({users:i.users.map((t=>t.id===n.userId?S({},t,{temporaryExpirationDate:void 0}):t))}),await _n(),null==a||a(!0),s.setTeamLoader({key:ks.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.deleteUserFromSubTenants=async e=>{const{callback:a}=e,n=f(e,md),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:S({},i.deleteUserDialogState,{loading:!0})}),await _n(),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,bd);s.setTeamLoader({key:ks.RESEND_ACTIVATE_LINK,value:a.userId}),await _n(),null==e||e(!0),s.setTeamLoader({key:ks.RESEND_ACTIVATE_LINK,value:!1})},s.resendInvitationLink=async t=>{const{callback:e}=t,a=f(t,Ad);s.setTeamLoader({key:ks.RESEND_INVITATION_LINK,value:a.email}),await _n(),null==e||e(!0),s.setTeamLoader({key:ks.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationEmail=async t=>{const{callback:e}=t,a=f(t,wd);s.setTeamLoader({key:ks.RESEND_INVITATION_LINK,value:a.email}),await _n(),null==e||e(!0),s.setTeamLoader({key:ks.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationLinkToAllSubTenants=async t=>{const{callback:e}=t,a=f(t,Td);s.setTeamLoader({key:ks.RESEND_INVITATION_LINK,value:a.email}),await _n(),null==e||e(!0),s.setTeamLoader({key:ks.RESEND_INVITATION_LINK,value:!1})},s})(t,e,a),$=((t,e,a)=>{const n=Yl(t,e,a),s=uu(n,["setTenantsState","resetTenantsState"]);return s.loadTenants=async()=>{s.setTenantsState({loading:!0}),s.setTenantsState({tenants:Nu,activeTenant:Nu[0],loading:!1})},s})(t,e,a),G=Zl(t,e),j=((t,e)=>{const a=ac(t,e);return uu(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;Nn(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,Ed);t.auth.errorByRequest=S({},t.auth.errorByRequest,{[a]:S({},n,{isError:!0})})},resetAuthState:()=>{Fn(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=yc(t,e,a);return uu(n,["setConnectivityState","resetConnectivityState","initData","resetConnectivityState","cleanWebhookTestData","cleanWebhookLogsData","cleanWebhookTestMessage","cleanError","cleanSlackData"])})(t,e,a),[r,l]=Dd(t,e,a),c=((t,e,a)=>{const n=tu(t,e,a),s=uu(n,["setVendorState","resetVendorState"]);return s.loadVendorPublicInfo=async()=>{try{s.setVendorState({whiteLabelMode:!1}),await _n()}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:kd(t,e,a)}},Md=(t,e,a=!1,n,s,i=!1,o="path")=>Fd({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)}}),Fd=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=rc(null==(e=t.initialState)?void 0:e.auth),m=uc(null==(a=t.initialState)?void 0:a.connectivity),b=Yc(null==(n=t.initialState)?void 0:n.subscriptions),A=Zc(null==(s=t.initialState)?void 0:s.vendor),w=ru(null==(i=t.initialState)?void 0:i.auditLogs),T=(E=null==(o=t.initialState)?void 0:o.audits,rn(cu,E));var E;const P=null==(r=t.initialState)?void 0:r.auth;P&&Object.keys(P).forEach((t=>{hn()(v,t,P[t],{merge:!0})}));const O=JSON.parse(JSON.stringify(v)),C=rn({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({},an(u),{fetch:new jt(u)});if(t.previewMode||t.builderMode){const{authActions:e,authStateActions:a,connectivityActions:n,subscriptionsActions:s,subscriptionsStateActions:i,vendorActions:o,auditsActions:r}=Nd(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]=lc(C,N,D,O),a=yc(C,N,D),[n,s]=Xc(C,N,D),i=tu(C,N,D),o=lu(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 xd,$d,Gd,jd,Bd,Vd,Wd,Hd,zd,Kd,qd,Jd,Yd,Xd;!function(t){t.phoneNumber="phoneNumber"}(xd||(xd={})),function(t){t.ALLOWED="allowedCountries",t.BLOCKED="blockedCountries"}($d||($d={})),function(t){t.Name="name",t.Username="username",t.PhoneNumber="phoneNumber",t.Address="address",t.JobTitle="jobTitle"}(Gd||(Gd={})),function(t){t.LoginSessions="loginSessions",t.Mfa="mfa"}(jd||(jd={})),function(t){t.Name="name",t.PhoneNumber="phoneNumber"}(Bd||(Bd={})),function(t){t.CompanyName="companyName",t.Address="address",t.Website="website",t.Timezone="timezone",t.Currency="currency"}(Vd||(Vd={})),function(t){t.User="user",t.Applications="applications",t.Groups="groups",t.Roles="roles",t.JoinedAt="joinedAt",t.LastSeen="lastSeen",t.ManagedBy="managedBy"}(Wd||(Wd={})),function(t){t.Invoices="invoices"}(Hd||(Hd={})),function(t){t.SessionManagement="sessionManagement",t.GeneralSettings="generalSettings",t.IpRestrictions="ipRestrictions",t.DomainRestrictions="domainRestrictions"}(zd||(zd={})),function(t){t.IdleSessionTimeout="idleSessionTimeout",t.ForceReLogin="forceReLogin",t.MaximumConcurrentSessions="maximumConcurrentSessions"}(Kd||(Kd={})),function(t){t.Mfa="mfa",t.UserLockout="userLockout",t.PasswordHistory="passwordHistory"}(qd||(qd={})),function(t){t.IpAddressRestrictions="ipAddressRestrictions"}(Jd||(Jd={})),function(t){t.RestrictSignupByEmailDomain="restrictSignupByEmailDomain"}(Yd||(Yd={})),function(t){t.Settings="settings",t.CustomLogin="customLogin"}(Xd||(Xd={}));const Qd={hidden:"hidden",viewOnly:"viewOnly",edit:"edit"},Zd={hidden:"hidden",edit:"edit"};function tg(t,e=0,a=1){return Math.min(Math.max(e,t),a)}function eg(t){if(t.type)return t;if("#"===t.charAt(0))return eg(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 ag(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 ng(t){if(0===t.indexOf("#"))return t;const{values:e}=eg(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 sg(t,e){return t=eg(t),e=tg(e),"rgb"!==t.type&&"hsl"!==t.type||(t.type+="a"),"color"===t.type?t.values[3]=`/${e}`:t.values[3]=e,ag(t)}function ig(t,e){if(t=eg(t),e=tg(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 ag(t)}function og(t,e){if(t=eg(t),e=tg(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 ag(t)}const rg=t=>{if(t)return{main:t,light:ng(og(t,.4)),dark:ng(ig(t,.15)),hover:ng(ig(t,.15)),active:ng(ig(t,.2))}},lg=t=>{if(t)return{main:t,light:og(t,.7),dark:ig(t,.2)}},cg=(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({},rg(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({},rg(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({},rg(null==t||null==(c=t.palette)?void 0:c.error),{contrastText:"#FFF"}),success:S({},lg(null==t||null==(u=t.palette)?void 0:u.success),{contrastText:"#FFF"}),error:S({},lg(null==t||null==(d=t.palette)?void 0:d.error),{contrastText:"#FFF"}),warning:S({},lg(null==t||null==(g=t.palette)?void 0:g.warning),{contrastText:"#FFF"}),info:S({},lg(null==t||null==(p=t.palette)?void 0:p.info),{contrastText:"#FFF"})}}):{}},ug={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 dg{constructor(){this._theme=ug.theme,this._themeV2=ug.themeV2,this._navigation=ug.navigation,this._localizations=ug.localizations,this._integrations=ug.integrations}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new dg;return a.set(t),dg._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=on().all([null!=(e=ug.navigation)?e:{},null!=(a=null==t?void 0:t.navigation)?a:{}]),this._theme=on().all([null!=(n=ug.theme)?n:{},cg(null==t?void 0:t.theme,ug.theme)]),this._themeV2=on().all([null!=(s=ug.themeV2)?s:{},null!=(i=null==t?void 0:t.themeV2)?i:{}]),this._localizations=on().all([null!=(o=ug.localizations)?o:{},null!=(r=null==t?void 0:t.localizations)?r:{}]),this._integrations=on().all([null!=(l=ug.integrations)?l:{},null!=(c=null==t?void 0:t.integrations)?c:{}])}catch(t){this._navigation=ug.navigation,this._theme=ug.theme,this._themeV2=ug.themeV2,this._localizations=ug.localizations,this._integrations=ug.integrations}}}dg._instances={};var gg=function(t){return t.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map((function(t){return t.toLowerCase()})).join("")},pg=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},hg=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)}))},yg=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 vg="7.76.0-alpha.0";var Sg={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"},fg=function(t){var e,a=dg.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)}))},mg=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,Rn((function(){return a.sendRequest({url:i,method:"GET",credentials:"omit"})}),n);case 6:if(!(o=t.sent)){t.next=10;break}return r=on()(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)}}(),bg=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(vg),this.assetsUrl="https://adminBox.frontegg.com/admin-box/".concat(vg),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,Rn((function(){return r.fetchClient.get("/metadata",{entityName:"adminBox"})}),kn);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,mg(i,r.fetchClient,kn);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,Jn.LOAD_ADMIN_BOX_METADATA);case 21:dg.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}te.set(Sg,r.name),t.next=16;break;case 4:return t.prev=4,t.next=7,Rn((function(){return r.apiClient.featureFlags.loadFeatureFlags()}),kn);case 7:e=t.sent,r.options.overrideFeatureFlags&&Object.assign(e,r.options.overrideFeatureFlags),te.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,Jn.LOAD_FEATURE_FLAGS);case 16:case"end":return t.stop()}}),t,null,[[4,12]])}))),this.setFeatureFlagsForPreview=function(t){te.set(Object.assign({},Sg,t),r.name)},this.queryFeatureFlags=function(t){return te.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=gg(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 jt(this.name),this.apiClient=an(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=Fd({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:Ln(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(),fg(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;dg.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(xt.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(),yg(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 ro(n,t,s)}},{key:"getPermissionEntitlements",value:function(t,e){var a=this.getEntitlementsQueryData(e),n=a.entitlements,s=a.attributes;return oo(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}):ms(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 Ss(a,e)}},{key:"switchTenant",value:function(t){this.store.dispatch({type:"auth/switchTenant",payload:t})}},{key:"close",value:function(){this.hideAdminPortal(),this.hideCheckoutDialog()}}]),a}(),Ag=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}(),wg=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}(),Tg=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}(),Eg=function(t){var e;return null!=(e=window.FronteggAdminPortal.adminPortalStaticThemesDefaults[t])?e:void 0},Pg=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=Md({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 bg(this.options,e,!0),dg.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,hg(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}(),Og="modern",Ig=function(t){var e,a=window.FronteggAdminPortal.themes;return null!=(e=a[t])?e:a[Og]},kg=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=Md({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 bg(this.options,e,!0,o),dg.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,hg(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 _g(t,e){return _g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_g(t,e)}function Ug(t){return Ug=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ug(t)}function Rg(t,e,a){return Rg=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&&_g(s,a.prototype),s},Rg.apply(null,arguments)}function Cg(t){var e="function"==typeof Map?new Map:void 0;return Cg=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 Rg(t,arguments,Ug(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),_g(n,t)},Cg(t)}function Lg(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=Ug(t);if(e){var s=Ug(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 Dg=function(t){var e=new bg(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&&_g(t,e)}(n,e);var a=Lg(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=pg(this,"div",{id:"frontegg-admin-portal-container-".concat(n.name)}),i=pg(this,"div",{id:"frontegg-login-box-container-".concat(n.name)}),o=pg(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=pg(r,"div",{id:"frontegg-admin-portal-".concat(n.name),class:"frontegg-root-content"}),g=pg(l,"div",{id:"frontegg-login-box-".concat(n.name),class:"frontegg-root-content"}),p=pg(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}(Cg(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(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})()));