@frontegg/js 7.4.0 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see frontegg.production.min.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Frontegg=e():t.Frontegg=e()}(window,(()=>(()=>{var t={3952:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createConditionEvaluator=void 0;const n=a(2904),s=a(9475);e.createConditionEvaluator=function(t){const e=(0,s.useSanitizer)(t.condition.op);if(!e)return()=>!1;const{isSanitized:a,sanitizedValue:i}=e(t.condition.value);if(!a||void 0===i)return()=>!1;const o=(0,n.useOperation)(t.condition.op,i);return e=>{const a=e[t.condition.attribute];if(void 0===a||!o)return!1;const{isValid:n}=o(a);return t.condition.negate?!n:n}}},9838:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(3952),e),s(a(963),e)},963:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3998:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateFeatureFlag=void 0;const n=a(9243);e.evaluateFeatureFlag=function(t,e){if(!t.on)return{treatment:t.offTreatment};const a=function(t,e){var a;return null===(a=t.rules)||void 0===a?void 0:a.find((t=>(0,n.createRuleEvaluator)({rule:t})(e)===n.RuleEvaluationResultEnum.Treatable))}(t,e);return a?{treatment:a.treatment}:{treatment:t.defaultTreatment}}},2152:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(3998),e)},5875:(t,e,a)=>{"use strict";e.Me=e.a_=void 0;a(2152),a(3856),a(9243),a(2752);var n=a(7254);Object.defineProperty(e,"a_",{enumerable:!0,get:function(){return n.evaluateIsEntitledToFeature}}),Object.defineProperty(e,"Me",{enumerable:!0,get:function(){return n.evaluateIsEntitledToPermissions}})},6849:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.BooleanOperationsMapper=void 0;const i=a(2752),o=a(6715);s(a(6715),e),s(a(4965),e),e.BooleanOperationsMapper={[i.OperationEnum.Is]:t=>(0,o.useIsOperation)(t)}},6715:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useIsOperation=void 0,e.useIsOperation=function(t){return e=>({isValid:e===t.boolean})}},4965:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BooleanSanitizersMapper=e.singleBooleanSanitizer=void 0;const n=a(2752);e.singleBooleanSanitizer=t=>{const e=void 0!==t.boolean&&(t=>"boolean"==typeof t)(t.boolean)?{boolean:t.boolean}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.BooleanSanitizersMapper={[n.OperationEnum.Is]:e.singleBooleanSanitizer}},2904:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useOperation=void 0;const n=a(5018),s=a(3922),i=a(3147),o=a(6849),r={...n.StringOperationsMapper,...s.NumericOperationsMapper,...i.DateOperationsMapper,...o.BooleanOperationsMapper};e.useOperation=function(t,e){const a=r[t];return a?a(e):void 0}},9475:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useSanitizer=void 0;const n=a(6849),s=a(1016),i=a(6891),o=a(3922),r={...s.StringSanitizersMapper,...o.NumericSanitizersMapper,...i.DateSanitizersMapper,...n.BooleanSanitizersMapper};e.useSanitizer=function(t){return r[t]}},3147:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.DateOperationsMapper=void 0;const i=a(2752),o=a(1641);s(a(1641),e),s(a(1626),e),e.DateOperationsMapper={[i.OperationEnum.On]:t=>(0,o.useDateOnOperation)(t),[i.OperationEnum.OnOrAfter]:t=>(0,o.useDateOnOrAfterOperation)(t),[i.OperationEnum.OnOrBefore]:t=>(0,o.useDateOnOrBeforeOperation)(t),[i.OperationEnum.BetweenDate]:t=>(0,o.useDateBetweenOperation)(t)}},1641:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useDateBetweenOperation=e.useDateOnOrBeforeOperation=e.useDateOnOrAfterOperation=e.useDateOnOperation=void 0,e.useDateOnOperation=function(t){return e=>({isValid:e.getTime()===t.date.getTime()})},e.useDateOnOrAfterOperation=function(t){return e=>({isValid:e.getTime()>=t.date.getTime()})},e.useDateOnOrBeforeOperation=function(t){return e=>({isValid:e.getTime()<=t.date.getTime()})},e.useDateBetweenOperation=function(t){return e=>({isValid:e.getTime()>=t.start.getTime()&&e.getTime()<=t.end.getTime()})}},6891:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DateSanitizersMapper=e.sanitizeDateRange=e.sanitizeSingleDate=e.isValidDate=e.sanitizeDateValue=void 0;const n=a(2752);e.sanitizeDateValue=t=>new Date(t),e.isValidDate=t=>t instanceof Date&&!isNaN(t),e.sanitizeSingleDate=t=>{const a=t.date?(0,e.sanitizeDateValue)(t.date):void 0,n=a&&(0,e.isValidDate)(a)?{date:a}:void 0;return{isSanitized:!!n,sanitizedValue:n}},e.sanitizeDateRange=t=>{const a=t.start?(0,e.sanitizeDateValue)(t.start):void 0,n=t.end?(0,e.sanitizeDateValue)(t.end):void 0,s=a&&n&&(0,e.isValidDate)(a)&&(0,e.isValidDate)(n)?{start:a,end:n}:void 0;return{isSanitized:!!s,sanitizedValue:s}},e.DateSanitizersMapper={[n.OperationEnum.On]:e.sanitizeSingleDate,[n.OperationEnum.OnOrAfter]:e.sanitizeSingleDate,[n.OperationEnum.OnOrBefore]:e.sanitizeSingleDate,[n.OperationEnum.BetweenDate]:e.sanitizeDateRange}},1626:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3922:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.NumericOperationsMapper=void 0;const i=a(2752),o=a(9194);e.NumericOperationsMapper={[i.OperationEnum.Equal]:t=>(0,o.useEqualsOperation)(t),[i.OperationEnum.GreaterThan]:t=>(0,o.useGreaterThanOperation)(t),[i.OperationEnum.GreaterThanEqual]:t=>(0,o.useGreaterThanEqualOperation)(t),[i.OperationEnum.LesserThan]:t=>(0,o.useLesserThanOperation)(t),[i.OperationEnum.LesserThanEqual]:t=>(0,o.useLesserThanEqualOperation)(t),[i.OperationEnum.BetweenNumeric]:t=>(0,o.useBetweenNumericOperation)(t)},s(a(9194),e),s(a(5168),e),s(a(7695),e)},9194:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useBetweenNumericOperation=e.useLesserThanEqualOperation=e.useLesserThanOperation=e.useGreaterThanEqualOperation=e.useGreaterThanOperation=e.useEqualsOperation=void 0,e.useEqualsOperation=function(t){return e=>({isValid:e===t.number})},e.useGreaterThanOperation=function(t){return e=>({isValid:e>t.number})},e.useGreaterThanEqualOperation=function(t){return e=>({isValid:e>=t.number})},e.useLesserThanOperation=function(t){return e=>({isValid:e<t.number})},e.useLesserThanEqualOperation=function(t){return e=>({isValid:e<=t.number})},e.useBetweenNumericOperation=function(t){return e=>({isValid:e>=t.start&&e<=t.end})}},5168:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NumericSanitizersMapper=e.sanitizeNumericRange=e.sanitizeSingleNumber=void 0;const n=a(2752),s=t=>"number"==typeof t;e.sanitizeSingleNumber=t=>{const e=void 0!==t.number&&s(t.number)?{number:t.number}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.sanitizeNumericRange=t=>{const e=void 0!==t.start&&void 0!==t.end&&s(t.start)&&s(t.end)?{start:t.start,end:t.end}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.NumericSanitizersMapper={[n.OperationEnum.Equal]:e.sanitizeSingleNumber,[n.OperationEnum.GreaterThan]:e.sanitizeSingleNumber,[n.OperationEnum.GreaterThanEqual]:e.sanitizeSingleNumber,[n.OperationEnum.LesserThan]:e.sanitizeSingleNumber,[n.OperationEnum.LesserThanEqual]:e.sanitizeSingleNumber,[n.OperationEnum.BetweenNumeric]:e.sanitizeNumericRange}},7695:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},5018:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.StringOperationsMapper=void 0;const i=a(2752),o=a(5154);s(a(5154),e),s(a(4503),e),e.StringOperationsMapper={[i.OperationEnum.StartsWith]:t=>(0,o.useStartsWithOperation)(t),[i.OperationEnum.EndsWith]:t=>(0,o.useEndsWithOperation)(t),[i.OperationEnum.Contains]:t=>(0,o.useContainsOperation)(t),[i.OperationEnum.InList]:t=>(0,o.useInListOperation)(t),[i.OperationEnum.Matches]:t=>(0,o.useMatchesOperation)(t)}},5154:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useMatchesOperation=e.useInListOperation=e.useContainsOperation=e.useEndsWithOperation=e.useStartsWithOperation=void 0,e.useStartsWithOperation=function(t){return e=>({isValid:t.list.some((t=>e.startsWith(t)))})},e.useEndsWithOperation=function(t){return e=>({isValid:t.list.some((t=>e.endsWith(t)))})},e.useContainsOperation=function(t){return e=>({isValid:t.list.some((t=>e.includes(t)))})},e.useInListOperation=function(t){return e=>({isValid:t.list.includes(e)})},e.useMatchesOperation=function(t){return e=>{let a;try{a=new RegExp(t.string)}catch(t){return{isValid:!1}}return{isValid:a.test(e)}}}},1016:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StringSanitizersMapper=e.sanitizeListString=e.sanitizeSingleString=void 0;const n=a(2752),s=t=>"string"==typeof t;e.sanitizeSingleString=t=>{const e=void 0!==t.string&&s(t.string)?{string:t.string}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.sanitizeListString=t=>{const e=void 0!==t.list&&t.list.every((t=>s(t)))?{list:t.list}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.StringSanitizersMapper={[n.OperationEnum.Matches]:e.sanitizeSingleString,[n.OperationEnum.Contains]:e.sanitizeListString,[n.OperationEnum.StartsWith]:e.sanitizeListString,[n.OperationEnum.EndsWith]:e.sanitizeListString,[n.OperationEnum.InList]:e.sanitizeListString}},4503:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},2752:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7158),e)},7158:(t,e)=>{"use strict";var a;Object.defineProperty(e,"__esModule",{value:!0}),e.OperationEnum=void 0,(a=e.OperationEnum||(e.OperationEnum={})).InList="in_list",a.StartsWith="starts_with",a.EndsWith="ends_with",a.Contains="contains",a.Matches="matches",a.Equal="equal",a.GreaterThan="greater_than",a.GreaterThanEqual="greater_than_equal",a.LesserThan="lower_than",a.LesserThanEqual="lower_than_equal",a.BetweenNumeric="between_numeric",a.Is="is",a.On="on",a.BetweenDate="between_date",a.OnOrAfter="on_or_after",a.OnOrBefore="on_or_before"},3856:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(6334),e)},6334:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluatePlan=void 0;const n=a(9243);e.evaluatePlan=function(t,e){const a=function(t,e){var a;return null===(a=t.rules)||void 0===a?void 0:a.find((t=>(0,n.createRuleEvaluator)({rule:t})(e)===n.RuleEvaluationResultEnum.Treatable))}(t,e);return a?{treatment:a.treatment}:{treatment:t.defaultTreatment}}},9243:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(5546),e),s(a(4874),e)},4874:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createRuleEvaluator=void 0;const n=a(5546),s=a(9838);e.createRuleEvaluator=function(t){return e=>t.rule.conditions.every((t=>(0,s.createConditionEvaluator)({condition:t})(e)))?n.RuleEvaluationResultEnum.Treatable:n.RuleEvaluationResultEnum.Insufficient}},5546:(t,e)=>{"use strict";var a,n;Object.defineProperty(e,"__esModule",{value:!0}),e.RuleEvaluationResultEnum=e.TreatmentEnum=e.ConditionLogicEnum=void 0,(e.ConditionLogicEnum||(e.ConditionLogicEnum={})).And="and",(n=e.TreatmentEnum||(e.TreatmentEnum={})).True="true",n.False="false",(a=e.RuleEvaluationResultEnum||(e.RuleEvaluationResultEnum={})).Treatable="treatable",a.Insufficient="insufficient"},7254:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7416),e),s(a(3817),e),s(a(395),e),s(a(6816),e)},1711:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.directEntitlementEvalutor=void 0;const n=a(395);e.directEntitlementEvalutor=function(t,e,a={}){const s=e.features[t];let i=!1;return s&&null!==s.expireTime&&(i=s.expireTime!==n.NO_EXPIRATION_TIME&&s.expireTime<Date.now(),!i)?{isEntitled:!0}:{isEntitled:!1,justification:i?n.NotEntitledJustification.BUNDLE_EXPIRED:n.NotEntitledJustification.MISSING_FEATURE}}},1343:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.featureFlagEvaluator=void 0;const n=a(395),s=a(2152),i=a(8552),o=a(9243);e.featureFlagEvaluator=function(t,e,a={}){const r=e.features[t];if(r&&r.featureFlag){const t=(0,i.prepareAttributes)(a),{treatment:e}=(0,s.evaluateFeatureFlag)(r.featureFlag,t);if(e===o.TreatmentEnum.True)return{isEntitled:!0}}return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE}}},2031:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getIsEntitledEvaluators=void 0;const n=a(1711),s=a(1343),i=a(3155);e.getIsEntitledEvaluators=function(){return[n.directEntitlementEvalutor,s.featureFlagEvaluator,i.planTargetingRulesEvalutor]}},3155:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.planTargetingRulesEvalutor=void 0;const n=a(395),s=a(8552),i=a(9243),o=a(3856);e.planTargetingRulesEvalutor=function(t,e,a={}){const r=e.features[t];if(r&&r.planIds&&r.planIds.length>0){const t=(0,s.prepareAttributes)(a),n=e.plans;for(const e of r.planIds){const a=n[e];if(a){const{treatment:e}=(0,o.evaluatePlan)(a,t);if(e===i.TreatmentEnum.True)return{isEntitled:!0}}}}return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE}}},7416:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(9398),e)},9398:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateIsEntitledToFeature=void 0;const n=a(395),s=a(6816),i=a(2031);e.evaluateIsEntitledToFeature=function(t,e,a={}){if(!e)return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE};const o=[];for(const n of(0,i.getIsEntitledEvaluators)())if(o.push(n(t,e,a)),!(0,s.shouldContinue)(o))break;return(0,s.getResult)(o)}},3817:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(1474),e)},1474:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateIsEntitledToPermissions=void 0;const n=a(9398),s=a(395),i=a(6816),o=a(7943);e.evaluateIsEntitledToPermissions=function(t,e,a){if(!e)return{isEntitled:!1,justification:s.NotEntitledJustification.MISSING_PERMISSION};if(!(0,o.checkPermission)(e.permissions,t))return{isEntitled:!1,justification:s.NotEntitledJustification.MISSING_PERMISSION};const r=function(t,e){return Object.keys(e.features).filter((a=>e.features[a].linkedPermissions.includes(t)))}(t,e);if(!r.length)return{isEntitled:!0};const l=[];for(const t of r)if(l.push((0,n.evaluateIsEntitledToFeature)(t,e,a)),!(0,i.shouldContinue)(l))break;return(0,i.getResult)(l)}},395:(t,e)=>{"use strict";var a;Object.defineProperty(e,"__esModule",{value:!0}),e.NO_EXPIRATION_TIME=e.NotEntitledJustification=void 0,(a=e.NotEntitledJustification||(e.NotEntitledJustification={})).MISSING_FEATURE="MISSING_FEATURE",a.MISSING_PERMISSION="MISSING_PERMISSION",a.BUNDLE_EXPIRED="BUNDLE_EXPIRED",e.NO_EXPIRATION_TIME=-1},8552:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.modifyObjectKeysWithPrefix=e.defaultFronteggAttributesMapper=e.prepareAttributes=void 0;const n=a(1857);function s(t){return{email:t.email,emailVerified:t.email_verified,tenantId:t.tenantId,userId:t.id}}function i(t,e){return Object.keys(t).reduce(((a,n)=>(a[`${e}${n}`]=t[n],a)),{})}e.prepareAttributes=function(t={},e){const{custom:a={},jwt:o={}}=t,r=(0,n.flatten)(o);return{...a,...i(e?e(o):s(o),"frontegg."),...i(r,"jwt.")}},e.defaultFronteggAttributesMapper=s,e.modifyObjectKeysWithPrefix=i},8843:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.shouldContinue=e.getResult=void 0;const n=a(395);e.getResult=function(t){let e=!1;for(const a of t){if(a.isEntitled)return a;a.justification===n.NotEntitledJustification.BUNDLE_EXPIRED&&(e=!0)}return{isEntitled:!1,justification:e?n.NotEntitledJustification.BUNDLE_EXPIRED:n.NotEntitledJustification.MISSING_FEATURE}},e.shouldContinue=function(t){return t.every((({isEntitled:t})=>!t))}},1857:(t,e)=>{"use strict";function a(t){return t}Object.defineProperty(e,"__esModule",{value:!0}),e.flatten=void 0,e.flatten=function(t,e){const n=(null==(e=e||{})?void 0:e.delimiter)||".",s=null==e?void 0:e.maxDepth,i=(null==e?void 0:e.transformKey)||a,o={};return function t(a,r,l){l=l||1,Object.keys(a).forEach((function(c){const u=a[c],d=(null==e?void 0:e.safe)&&Array.isArray(u),p=Object.prototype.toString.call(u),g=(h=u)&&h.constructor&&"function"==typeof h.constructor.isBuffer&&h.constructor.isBuffer(h);var h;const y="[object Object]"===p||"[object Array]"===p,S=r?r+n+i(c):i(c);if(!d&&!g&&y&&Object.keys(u).length&&(!(null==e?void 0:e.maxDepth)||s&&l<s))return t(u,S,l+1);o[S]=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}},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 p(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 g(t,e,a){try{return{type:"normal",arg:t.call(e,a)}}catch(t){return{type:"throw",arg:t}}}e.wrap=p;var h={};function y(){}function S(){}function v(){}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=v.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=g(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=I(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=g(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 I(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,I(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=g(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 P(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 S.prototype=v,o(A,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:S,configurable:!0}),S.displayName=d(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===S||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,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(p(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(P),!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),P(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;P(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:()=>_d,AdminPortalRenderer:()=>Rd,AppHolder:()=>c,CheckoutDialog:()=>Ud,FronteggApp:()=>Pd,HostedLogin:()=>kd,LoginBoxRenderer:()=>Nd,createElement:()=>Ad,defaultTheme:()=>Dd,formatName:()=>bd,getOverriddenMetadata:()=>Od,getThemeAdminByName:()=>Ld,getThemeByName:()=>Cd,initialize:()=>jd,mockFlagsList:()=>Ed,restoreSearchParams:()=>Td,waitThemeSetter:()=>wd});var t={};a.r(t),a.d(t,{ADMIN_PORTAL_ENTITLEMENTS_FF:()=>Kt,ApplicationAccessType:()=>Va,AuthStrategyEnum:()=>N,ContextHolder:()=>L,DirectoryApi:()=>oa,FRONTEGG_SEPARATE_TABS_BY_TENANT:()=>Zt,FeatureFlags:()=>Yt,FeatureFlagsApi:()=>Qt,FetchClient:()=>Nt,FronteggApiError:()=>B,FronteggContext:()=>D,FronteggFrameworks:()=>Dt,GetUsersFilterPreset:()=>Na,GroupManagedByEnum:()=>Da,GroupRelations:()=>Ra,ISubscriptionCancellationPolicy:()=>$,ISubscriptionStatus:()=>F,InsightCode:()=>xa,LOAD_AUTHORIZATION_FF:()=>Ht,MFAStrategyEnum:()=>Wt,MachineToMachineAuthStrategy:()=>M,NotEntitledJustification:()=>zt,PaginationOrderEnum:()=>Ct,PaymentMethodType:()=>x,PermissionAssignmentTypeEnum:()=>wa,ProviderType:()=>G,RecommendationActionKey:()=>$a,RecommendationCode:()=>Fa,RecommendationSeverity:()=>Ga,RequestSource:()=>Rt,RestrictionType:()=>jt,ScimConnectionSource:()=>La,SecondaryAuthStrategy:()=>Vt,SecurityCategory:()=>ja,SocialLoginProviders:()=>C,SortByEnum:()=>Ca,SubAccountAccessTypeEnum:()=>Ta,TenantSortByEnum:()=>ba,TenantType:()=>Aa,UserManagedByEnum:()=>ma,WebAuthnDeviceType:()=>Bt,api:()=>Ba,createApiClient:()=>Wa,default:()=>Ha,fetch:()=>Mt,fronteggAuthApiRoutesRegex:()=>Ea,fronteggEntitlementsV2Url:()=>Ua,fronteggHeaders:()=>Lt,fronteggRefreshTokenUrl:()=>Ia,fronteggSilentRefreshTokenUrl:()=>Oa,fronteggTenantsUrl:()=>ka,fronteggTenantsV3Url:()=>_a,fronteggUsersUrl:()=>Pa,getCurrentUserTenantsFunction:()=>oe,getTabTenantFromSessionStorage:()=>ie,providersArray:()=>Ma,removeTabTenantFromSessionStorage:()=>se,setTabTenantInSessionStorage:()=>ne});var e={};a.r(e),a.d(e,{ACR_VALUE:()=>os,AMR_ADDITIONAL_VALUE:()=>ls,AMR_MFA_VALUE:()=>rs,AcceptInvitationStep:()=>Qa,ActivateAccountStep:()=>Xa,AdminPortalPages:()=>_n,AdminPortalPagesForEvents:()=>kn,AllAccountsStateKeys:()=>fn,ApiStateKeys:()=>Za,AuthStrategyEnum:()=>N,AuthenticationTypes:()=>Pn,FRONTEGG_AFTER_AUTH_REDIRECT_URL:()=>ds,ForgotPasswordStep:()=>cn,FronteggNativeModule:()=>S,GTMEventAction:()=>Wn,GroupRelations:()=>dn,GroupsStateKeys:()=>un,HOSTED_LOGIN_VERIFIER_KEY:()=>ps,ImpersonateStep:()=>pn,LoginActionTypes:()=>Sn,LoginFlow:()=>hn,LoginStep:()=>gn,MFAStep:()=>vn,MachineToMachineAuthStrategy:()=>M,PaymentMethodType:()=>El,PaymentProvider:()=>Pl,QuickLoginStrategy:()=>yn,ResetPhoneNumberStep:()=>mn,RolesStateKeys:()=>bn,SHOULD_STEP_UP_KEY:()=>cs,SSOStateKeys:()=>Tn,STEP_UP_MAX_AGE_PARAM_NAME:()=>us,SamlVendors:()=>En,SecurityCenterStateKeys:()=>An,SignUpStage:()=>wn,SubscriptionCancellationPolicy:()=>_l,SubscriptionStatus:()=>kl,TENANT_ID_PARAM_KEY:()=>Zn,TeamStateKeys:()=>In,UserVeirifedOriginTypes:()=>On,authStrategyLoginStepMap:()=>zn,base64ToFormData:()=>vi,base64urlDecode:()=>Si,base64urlEncode:()=>yi,buildAuditsActions:()=>Sc,buildAuthActions:()=>Sl,buildConnectivityActions:()=>Tl,buildSubscriptionsActions:()=>ic,buildVendorActions:()=>lc,createAuditsState:()=>yc,createAuthState:()=>yl,createConnectivityState:()=>fl,createFronteggStore:()=>Hu,createProxy:()=>Rn,createRandomString:()=>xi,createStore:()=>zu,createSubscriptionsState:()=>sc,createVendorState:()=>rc,deepClone:()=>za,defaultFronteggRoutes:()=>Kn,delay:()=>Ka,errorHandler:()=>Mn,extractPhoneNumber:()=>As,generateCodeChallenge:()=>Fi,generateCodeChallengeNative:()=>Mi,generateCodeChallengePureJs:()=>Ni,getBaseNameWithoutSlashSuffix:()=>is,getEntitlements:()=>rn,getFeatureEntitlements:()=>on,getMfaStepForEnrolledUsers:()=>es,getMfaStepForNotEnrolledUsers:()=>as,getNumberOfMfaDevices:()=>ts,getPathAndSearchParamsFromUrl:()=>Qn,getPermissionEntitlements:()=>sn,getRedirectUrl:()=>Jn,getSearchParam:()=>Xn,getSearchParamsFromUrl:()=>Yn,getUri:()=>bs,isAbsoluteUrl:()=>qn,isAuthRoute:()=>ws,isEmailPayload:()=>ss,isEntitlementsDeeplyEqual:()=>ln,isError:()=>Nn,isMfaRequired:()=>fs,isOauthCallbackRoute:()=>ns,isProxy:()=>Ya,isSteppedUp:()=>gs,mapMetaDataObjectToActions:()=>ms,omitProps:()=>Ja,publicKeyCredentialToJSON:()=>fi,readFileAsText:()=>mi,redirectByStepUpUrl:()=>ys,reportGTMEvent:()=>Hn,retry:()=>qa,setAfterAuthRedirectUrlForStepUp:()=>hs,snapshot:()=>k,subscribe:()=>P});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:()=>id,AccountPageFields:()=>Qu,DomainRestrictionsTabFields:()=>sd,GeneralSettingsTabFields:()=>ad,InviteUserModalFields:()=>Yu,IpRestrictionsTabFields:()=>nd,Metadata:()=>md,PrivacyPageFields:()=>Ju,ProfilePageFields:()=>qu,SecurityPageTabs:()=>td,SessionManagementTabFields:()=>ed,SignupFields:()=>Ku,SubscriptionsPageFields:()=>Zu,UsersTableColumns:()=>Xu,alpha:()=>pd,fieldAppearance:()=>od,tabAppearance:()=>rd});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 p(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 g(t){return function(){var e=this,a=arguments;return new Promise((function(n,s){var i=t.apply(e,a);function o(t){p(i,n,s,o,r,"next",t)}function r(t){p(i,n,s,o,r,"throw",t)}o(void 0)}))}}c._apps={};var h=a(5799),y=a.n(h);const S=new class{constructor(){this.loginWithSSO=t=>{if(this.isWebkitAvailable()){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.isJsInterfaceAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSSO(t)}},this.loginWithSocialLogin=t=>{if(this.isWebkitAvailable()){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.isJsInterfaceAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSocialLogin(t)}},this.promptSocialLoginConsent=()=>{var t,e;return null!=(t=null==(e=window.FronteggNativeBridgeFunctions)?void 0:e.shouldPromptSocialLoginConsent)&&t}}isWebkitAvailable(){var t,e;return null!=(null==(t=window.webkit)||null==(e=t.messageHandlers)?void 0:e.FronteggNativeBridge)}isJsInterfaceAvailable(){return null!=window.FronteggNativeBridge}isSocialLoginAvailable(){return this.isAvailable("loginWithSocialLogin")}isLoginWithSSOAvailable(){return this.isAvailable("loginWithSSO")}isAvailable(t){var e,a;return!(!this.isWebkitAvailable()&&!this.isJsInterfaceAvailable())&&null!=(e=null==(a=window.FronteggNativeBridgeFunctions)?void 0:a[t])&&e}};function v(){return v=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},v.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,I=new WeakSet;const[O]=function(t=Object.is,e=(t,e)=>new Proxy(t,e),a=t=>T(t)&&!I.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(I.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 p=r[1];const g=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))},S=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),v=e(S,{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 p;y(n),T(s)&&(s=(t=>t&&(A.has(t)?A.get(t):b(t)===Object.prototype||b(t)===Array.prototype))(p=s)&&p[m]||s);let S=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)&&(S=l(s));const t=!I.has(S)&&E.get(S);t&&((t,e)=>{if(u.size){const a=e[3](g(t));h.set(t,[e,a])}else h.set(t,[e])})(n,t)}return Reflect.set(e,n,S,i),d(["set",[n],s,c]),!0}});o.set(n,v);const f=[S,(t=++r[1])=>(p===t||u.size||(p=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](g(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(v,f),Reflect.ownKeys(n).forEach((t=>{const e=Object.getOwnPropertyDescriptor(n,t);"value"in e&&(v[t]=n[t],delete e.value,delete e.writable),Object.defineProperty(S,t,e)})),v}){return[l,E,I,t,e,a,n,s,i,o,r]}();function P(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 L{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.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.getAppName=()=>this.appName}static default(){return L.getInstance(R)}static for(t){return L.getInstance(t)}static getInstance(t="default"){return L._apps||(L._apps={}),L._apps[t]||(L._apps[t]=new L),L._apps[t]}static createInstance(t="default"){return L._apps[t]=new L,L._apps[t].appName=t,L._apps[t]}static setContext(t,e="default"){L.for(e).context=t}static setAccessToken(t,e=R){L.for(e).accessToken=t}static setUser(t,e="default"){L.for(e).user=t}static setRequestSource(t,e="default"){L.for(e).requestSource=t}static setOnRedirectTo(t,e="default"){L.for(e).onRedirectTo=t}static setLogout(t,e,a="default"){const n=L.for(a);n.logout=a=>{a?t(a):n.onRedirectTo(e,void 0)}}static setEntitlementsOptions(t,e="default"){L.for(e).entitlementsOptions=t}static setSessionContext(t,e="default"){L.for(e).sessionContext=t}static setAppName(t){L.for(t).appName=t}static getContext(t="default"){var e;return null!=(e=L.for(t).context)?e:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}}static getAccessToken(t="default"){return L.for(t).accessToken}static getRequestSource(t="default"){return L.for(t).requestSource}static getBasename(t="default"){return L.for(t).basename}getBasename(){return this.basename}static setBasename(t,e=R){L.for(e).basename=t}setBasename(t){this.basename=t}static getUser(t="default"){return L.for(t).user}static onRedirectTo(t,e,a="default"){return L.for(a).onRedirectTo(t,e)}static logout(t,e="default"){return L.for(e).logout(t)}static shouldLoadEntitlements(t="default"){var e;return(null==(e=L.for(t).entitlementsOptions)?void 0:e.enabled)||!1}static isSessionPerTenantEnabled(t="default"){var e;return(null==(e=L.for(t).sessionContext)?void 0:e.enableSessionPerTenant)||!1}static getAppName(t="default"){return L.for(t).appName}}L._apps=void 0;const R="default",D={getContext:()=>L.getContext(R),getAccessToken:()=>L.getAccessToken(R),setAccessToken:t=>L.setAccessToken(t,R),getUser:()=>L.getUser(R),setUser:t=>L.setUser(t,R),onRedirectTo:(t,e)=>L.onRedirectTo(t,e,R),setOnRedirectTo:t=>L.setOnRedirectTo(t,R),logout:t=>L.logout(t,R),getRequestSource:()=>L.getRequestSource(R),setRequestSource:t=>L.setRequestSource(t,R),isSessionPerTenantEnabled:()=>L.isSessionPerTenantEnabled(R),shouldLoadEntitlements:()=>L.shouldLoadEntitlements(R),getAppName:()=>L.getAppName(R),setEntitlementsOptions:t=>L.setEntitlementsOptions(t,R),setSessionContext:t=>L.setSessionContext(t,R),getBasename:()=>L.getBasename(R),setBasename:t=>L.setBasename(t,R)};let C,N,M,F,x,$,G,j,V;!function(t){t.Microsoft="microsoft",t.Facebook="facebook",t.Google="google",t.Github="github",t.Slack="slack",t.Apple="apple",t.Linkedin="linkedin"}(C||(C={})),function(t){t.EmailAndPassword="EmailAndPassword",t.MagicLink="MagicLink",t.Code="Code",t.NoLocalAuthentication="NoLocalAuthentication",t.SmsCode="SmsCode"}(N||(N={})),function(t){t.ClientCredentials="ClientCredentials",t.AccessToken="AccessToken"}(M||(M={})),function(t){t.ACTIVE="active",t.CANCELED="canceled",t.INCOMPLETE="incomplete",t.EXPIRED="expired",t.TRIALING="trialing",t.TRIAL_ENDED="trialEnded"}(F||(F={})),function(t){t.UNKNWON="unknown",t.CARD="card"}(x||(x={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}($||($={})),function(t){t.Stripe="Stripe"}(G||(G={})),function(t){t.CHANGE_TO_DEFAULT="change_to_default",t.RETAIN_TRIAL="retain_trial"}(j||(j={})),function(t){t.CREATE="create_customer"}(V||(V={}));class B extends Error{constructor(t,e){super(t),this._statusCode=void 0,this._statusCode=e}get statusCode(){return this._statusCode}}const W={v1:"/identity/resources/users/webauthn/v1/devices"},H={v1:"/identity/resources/auth/v1",v2:"/identity/resources/auth/v2"},z={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"}}},K={v1:"/identity/resources/configurations/v1"},q={emailDomain:{v1:"/identity/resources/configurations/restrictions/v1/email-domain"},ip:{v1:"/identity/resources/configurations/v1/restrictions/ip"}},J={v1:"/identity/resources/sso/v1",v2:"/identity/resources/sso/v2",custom:{v1:"/identity/resources/sso/custom/v1"}},Y={v1:"/identity/resources/permissions/v1"},Q={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"}},X={v1:"/identity/resources/roles/v1",v2:"/identity/resources/roles/v2"},Z={v1:"/identity/resources/sub-tenants/users/v1",v2:"/identity/resources/sub-tenants/users/v2"},tt={v1:"/identity/resources/impersonation/v1"},et={v1:"/identity/resources/applications/v1"},at={v1:"/identity/resources/groups/v1",configurations:{v1:"/identity/resources/groups/v1/config"},getByIds:{v1:"/identity/resources/groups/v1/bulkGet"}},nt={v1:"/identity/resources/users/phone-numbers/v1"},st={v1:"/team/resources/sso/v1",v2:"/team/resources/sso/v2"},it={v1:"/team/resources/members/v1"},ot={v1:"/team/resources/roles/v1"},rt={v1:"/team/resources/stats/v1"},lt={v1:"/team/resources/profile"},ct={v1:"/tenants/resources/account-settings/v1"},ut={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"}},dt={v1:"/tenants/resources/sub-tenants/v1"},pt={v1:"/integrations/resources/configurations/v1",v2:"/integrations/resources/configurations/v2"},gt={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"}}}},ht={v1:"/subscriptions/resources/payment-providers/v1"},yt={v1:"/subscriptions/resources/subscriptions/v1"},St={v1:"/reports/resources/reports/v1",v2:"/reports/resources/reports/v2"},vt={v1:"/reports/engine/resources/triggers/v1"},ft="/notification",mt="/audits",bt={v1:"/event/resources/configurations/v1"},At="/webhook",wt="/oauth",Tt="/flags",Et="/directory/resources/v1/configurations/scim2",It="/directory/resources/scim/temp",Ot="/entitlements/api/v2/user-entitlements",Pt={v1:"/security-center/resources/recommendations/v1"},kt={v1:"/security-center/resources/insights/v1"},_t="/applications/resources/applications/v1",Ut={v1:"/applications/resources/applications/tenant-assignments/v1"},Lt={frameWork:"x-frontegg-framework",fronteggSdkVersion:"x-frontegg-sdk",contentType:"Content-Type",source:"frontegg-source",scopedTenant:"frontegg-scoped-tenant"};let Rt,Dt,Ct;!function(t){t.AdminPortal="admin-portal",t.LoginBox="login-box"}(Rt||(Rt={})),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"}(Dt||(Dt={})),function(t){t.ASC="ASC",t.DESC="DESC"}(Ct||(Ct={}));class Nt{constructor(t){this.appName=void 0,this.getFronteggContext=()=>L.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=Nt.getMetadataHeaders(n),i=await(null!=(e=null==n?void 0:n.tokenResolver)?e:a.getAccessToken)(),o=a.getRequestSource(),r=Nt.getScopedTenant();t&&(s[Lt.contentType]=t),o&&(s[Lt.source]=o),i&&(s.Authorization=`Bearer ${i}`),r&&(s[Lt.scopedTenant]=r);for(const t of await this.getAdditionalHeaders(n))s[`${t.key}`]=`${t.value}`;return s},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=await fetch(o,{body:t.body?"application/json"===t.contentType?JSON.stringify(t.body):t.body:null,method:null!=(e=t.method)?e:"GET",headers:v({},i,t.headers),credentials:null!=(a=null!=(n=t.credentials)?n:s.requestCredentials)?a:"same-origin"});if(302===r.status)return window.location.href=await r.text(),new Promise((()=>{}));if(!r.ok){var l,c;if(413===r.status)throw new B("Error request is too large",r.status);let t,e=!0;try{t=await r.text(),t=JSON.parse(t)}catch(t){e=!1}throw t.errors?t=t.errors.join(", "):"string"!=typeof t&&(t=`Error ${r.status} - ${r.statusText}`),r.status>=400&&r.status<500&&["warn"].includes(null!=(l=s.logLevel)?l:"")?console.warn(t):500===r.status&&["warn","error"].includes(null!=(c=s.logLevel)?c:"")&&console.error(t),new B(e?t:"We're facing some difficulties, Please try again",r.status)}if(t.responseType&&"json"!==t.responseType){if("blob"===t.responseType){const{outputFileName:e}=t.params;return await r.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 r.text()}try{return await r.json()}catch(t){return{}}},this.get=async(t,e,a)=>this.sendRequest(v({url:t,method:"GET",contentType:"application/json",params:e},a)),this.post=async(t,e,a)=>this.sendRequest(v({url:t,method:"POST",contentType:"application/json",body:e},a)),this.patch=async(t,e,a)=>this.sendRequest(v({url:t,method:"PATCH",contentType:"application/json",body:e},a)),this.put=async(t,e,a)=>this.sendRequest(v({url:t,method:"PUT",contentType:"application/json",body:e},a)),this.delete=async(t,e,a)=>this.sendRequest(v({url:t,method:"DELETE",contentType:"application/json",body:e},a)),this.postDownload=async(t,e,a,n)=>this.sendRequest(v({url:t,method:"POST",contentType:"application/json",responseType:"blob",body:e,params:a},n)),this.extractHeadersFromOptions=(t={})=>v({},t.jwt?{Authorization:t.jwt}:{}),this.getBaseUrl=(t,e,a=!0)=>Nt.getBaseUrl(t,e,a),this.getContextBaseUrl=(t,e=!0)=>{const a=this.getFronteggContext().getContext();return this.getBaseUrl(a,t,e)},this.getMetadataHeaders=t=>Nt.getMetadataHeaders(t),this.getContextMetadataHeaders=()=>{const t=this.getFronteggContext().getContext();return Nt.getMetadataHeaders(t)},this.appName=t}}Nt.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},Nt.getMetadataHeaders=t=>{var e,a;const n={};return null!=t&&null!=(e=t.metadataHeaders)&&e.fronteggSdkVersion&&(n[Lt.fronteggSdkVersion]=t.metadataHeaders.fronteggSdkVersion),null!=t&&null!=(a=t.metadataHeaders)&&a.framework&&(n[Lt.frameWork]=t.metadataHeaders.framework),n},Nt.getScopedTenant=()=>new URLSearchParams(window.location.search).get("tenantId")||null;const Mt=new Nt("default");class Ft extends Error{constructor(t){super(t)}}const xt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){const e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ft("'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 $t extends Error{constructor(t){super(t)}}const Gt=(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(xt(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 xt(e)}})(t.split(".")[a]))}catch(t){throw new $t("Invalid token specified: "+t.message)}};let jt,Vt,Bt,Wt;!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"}(Vt||(Vt={})),function(t){t.Platform="Platform",t.CrossPlatform="CrossPlatform"}(Bt||(Bt={})),function(t){t.AuthenticatorApp="AuthenticatorApp",t.WebAuthnPlatform="WebAuthnPlatform",t.WebAuthnCrossPlatform="WebAuthnCrossPlatform",t.SMS="SMS",t.EmailCode="EmailCode"}(Wt||(Wt={}));const Ht="admin_portal_should_load_authorization";let zt;!function(t){t.MISSING_PERMISSION="MISSING_PERMISSION",t.MISSING_FEATURE="MISSING_FEATURE",t.BUNDLE_EXPIRED="BUNDLE_EXPIRED"}(zt||(zt={}));const Kt="admin_portal_entitlements";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 Nt(t)}}const Jt={flags:{}};class Yt{constructor(){var t;this._flags={},this._flags=null!=(t=Jt.flags)?t:{}}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new Yt;return a.set(t),Yt._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=v({},null!=(e=null==Jt?void 0:Jt.flags)?e:{},null!=t?t:{})}}Yt._instances={};class Qt extends qt{constructor(t){super(t),this.loadFeatureFlags=async()=>this.get(Tt)}}const Xt=new Qt("default"),Zt="FRONTEGG_SEPARATE_TABS_BY_TENANT",te="admin_portal_use_current_user_tenants_v1_endpoint";class ee extends qt{constructor(t){super(t),this.GetUserJwt=async t=>this.post(`${z.v3}/me/token`,t),this.getUsersV2=async(t,e)=>this.get(z.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersV3=async(t,e)=>this.get(z.v3,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersRoles=async(t,e)=>this.get(z.roles.v3,v({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getUsersGroups=async(t,e)=>this.get(z.groups.v3,v({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getCurrentUserTenantsV3=async t=>this.get(z.tenants.me.v3,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getCurrentUserTenantsV1=async t=>this.get(z.tenants.me.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.sendResetBreachedPasswordEmails=async()=>this.post(z.passwords.resetBreachedPasswords.v1),this.updateUserProfileV2=async t=>this.put(`${z.v2}/me`,t),this.unlockMe=async t=>this.post(`${z.v3}/me/unlock`,t)}}const ae=new ee("default");function ne(t){t&&sessionStorage.setItem(Zt,t)}function se(){sessionStorage.removeItem(Zt)}function ie(t){return L.for(t).isSessionPerTenantEnabled()?sessionStorage.getItem(Zt):null}function oe(t){const e=new ee(t),[a]=Yt.getFeatureFlags([te],t);return L.for(t).isSessionPerTenantEnabled()||a?e.getCurrentUserTenantsV1:e.getCurrentUserTenantsV3}class re extends qt{constructor(t){super(t),this.switchTenant=async t=>(L.for(this.appName).isSessionPerTenantEnabled()&&ne(t.tenantId),this.put(`${z.v1}/tenant`,t)),this.getTenants=async()=>this.get(`${z.v2}/me/tenants`),this.getSubTenants=async t=>this.get(ut.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getSubTenantsAsTree=async t=>this.get(ut.tree.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenants=async t=>this.get(ut.parents.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenantsById=async(t,e)=>this.get(`${ut.parents.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getTenantsUsersCount=async(t,e)=>this.post(`${Q.users.v1}/count`,t,{headers:this.extractHeadersFromOptions(e)}),this.searchSubTenants=async(t,e)=>this.get(ut.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getHierarchyMetadata=async(t,e)=>this.get(ut.metadata.v2,v({},t,{_tenantIds:t._tenantIds.join(",")}),{headers:this.extractHeadersFromOptions(e)})}}const le=new re("default");class ce extends qt{constructor(t){super(t),this.loadEntitlementsV2=async()=>this.get(Ot)}}const ue=new ce("default");class de extends qt{constructor(t){super(t),this.getGlobalSecurityPolicy=async()=>this.get(K.v1),this.getMfaPolicy=async()=>this.get(`${K.v1}/mfa-policy`),this.getVendorMfaPolicy=async()=>this.get(`${K.v1}/mfa-policy/vendor`),this.saveMfaPolicy=async t=>t.id?this.patch(`${K.v1}/mfa-policy`,t):this.post(`${K.v1}/mfa-policy`,t),this.getLockoutPolicy=async()=>this.get(`${K.v1}/lockout-policy`),this.getVendorLockoutPolicy=async()=>this.get(`${K.v1}/lockout-policy/vendor`),this.saveLockoutPolicy=async t=>t.id?this.patch(`${K.v1}/lockout-policy`,t):this.post(`${K.v1}/lockout-policy`,t),this.getCaptchaPolicy=async()=>{try{return await this.get(`${K.v1}/captcha-policy/public`)}catch{return null}},this.getPasswordHistoryPolicy=async()=>this.get(`${K.v1}/password-history-policy`),this.getVendorPasswordHistoryPolicy=async()=>this.get(`${K.v1}/password-history-policy/vendor`),this.savePasswordHistoryPolicy=async t=>t.id?this.patch(`${K.v1}/password-history-policy`,t):this.post(`${K.v1}/password-history-policy`,t),this.getPasswordConfigPolicy=async()=>this.get(`${K.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 pe=new de("default"),ge=["type"],he=["type"],ye=["type"];class Se extends qt{constructor(t){super(t),this.tenantsApi=new re(this.appName),this.entitlementsApi=new ce(this.appName),this.securityPolicy=new de(this.appName),this.generateLoginResponse=async t=>{if(!t.accessToken)return t;const e=L.for(this.appName);e.setAccessToken(t.accessToken);const a=await this.getMeAndEntitlements(),n=v({},t,t.accessToken?Gt(t.accessToken):{},a);return e.setUser(n),n},this.generateLoginResponseV2=async t=>{if(!t.accessToken)return{user:t};const e=L.for(this.appName);e.setAccessToken(t.accessToken);const[a,n]=await Promise.all([this.getMeAndEntitlements(),this.tenantsApi.getTenants()]),s=v({},t,t.accessToken?Gt(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=L.for(this.appName);a.setAccessToken(e);const[n,s]=await Promise.all([this.getMeAndEntitlements(),oe(this.appName)()]),i=v({},t,e?Gt(e):{},n);return a.isSessionPerTenantEnabled()&&ne(i.tenantId),a.setUser(i),{user:i,tenants:s.tenants,activeTenant:s.activeTenant}},this.generateLoginResponseFromOAuthResponse=async t=>{const e=L.for(this.appName);e.setAccessToken(t.id_token);const a=await this.getMeAndEntitlements(),n=t.id_token?Gt(t.id_token):{},s=v({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=L.for(this.appName);e.setAccessToken(t.id_token);const[a,n]=await Promise.all([this.getMeAndEntitlements(),oe(this.appName)()]),s=t.id_token?Gt(t.id_token):{},i=v({mfaRequired:!1,accessToken:t.id_token,refreshToken:t.refresh_token},s,a,{expiresIn:t.expires_in||300});return e.isSessionPerTenantEnabled()&&ne(i.tenantId),e.setUser(i),{user:i,tenants:n.tenants,activeTenant:n.activeTenant}},this.preLogin=async t=>{try{const{address:e}=await this.post(`${H.v1}/user/saml/prelogin`,t);return e}catch{return null}},this.preLoginWithIdpType=async t=>this.post(`${H.v1}/user/saml/prelogin`,t),this.postLogin=async t=>{const e=await this.post(`${H.v1}/user/saml/postlogin`,t);return this.generateLoginResponse(e)},this.oidcPostLogin=async t=>{const e=await this.post(`${H.v1}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.login=async t=>{const e=await this.post(`${H.v1}/user`,t);return this.generateLoginResponse(e)},this.loginv2=async t=>{const e=await this.post(`${H.v1}/user`,t);return this.generateLoginResponseV3(e)},this.loginWithMfa=async t=>{const e=await this.post(`${H.v1}/user/mfa/verify`,t);return this.generateLoginResponse(e)},this.loginWithMfaV2=async t=>{const e=await this.post(`${H.v1}/user/mfa/verify`,t);return this.generateLoginResponseV3(e)},this.activateAccount=async t=>this.post(`${z.v1}/activate`,t),this.activateAccountV2=async t=>{const e=await this.post(`${z.v1}/activate`,t);return this.generateLoginResponseV3(e)},this.getActivateAccountStrategy=async t=>this.get(`${z.v1}/activate/strategy`,t),this.resendActivationEmail=async t=>this.post(`${z.v1}/activate/reset`,t),this.resendInvitationEmail=async t=>this.post(`${z.v1}/invitation/reset`,t),this.acceptInvitation=async t=>this.post(`${z.v1}/invitation/accept`,t),this.refreshToken=async()=>{const t=ie(this.appName),e=await this.post(`${H.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponse(e)},this.refreshTokenV2=async()=>{const t=ie(this.appName),e=await this.post(`${H.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV2(e)},this.refreshTokenV3=async()=>{const t=ie(this.appName),e=await this.post(`${H.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV3(e)},this.logout=async()=>this.post(`${H.v1}/logout`),this.OAuthLogout=async t=>this.get(`${wt}/logout`,t),this.forgotPassword=async t=>this.post(`${z.v1}/passwords/reset`,t),this.resetPassword=async t=>this.post(`${z.v1}/passwords/reset/verify`,t),this.loadPasswordConfig=async t=>this.get(`${z.v1}/passwords/config`,t),this.recoverMfaToken=async t=>this.post(`${H.v1}/user/mfa/recover`,t),this.enrollMfa=async()=>this.post(`${z.v1}/mfa/enroll`),this.preEnrollMFAAuthenticatorApp=async()=>this.post(`${z.v1}/mfa/authenticator/enroll`),this.enrollMFAAuthenticatorApp=async t=>this.post(`${z.v1}/mfa/authenticator/enroll/verify`,t),this.preEnrollMFASMS=async t=>this.post(`${z.v1}/mfa/sms/enroll`,t),this.enrollMFASMS=async t=>this.post(`${z.v1}/mfa/sms/enroll/verify`,t),this.preEnrollMFAWebAuthn=async()=>this.post(`${z.v1}/mfa/webauthn/enroll`),this.enrollMFAWebAuthn=async t=>this.post(`${z.v1}/mfa/webauthn/enroll/verify`,t),this.verifyMfa=async t=>this.post(`${z.v1}/mfa/enroll/verify`,t),this.disableMfa=async t=>this.post(`${z.v1}/mfa/disable`,t),this.disableMFAAuthenticatorApp=async(t,e)=>this.post(`${z.v1}/mfa/authenticator/${t}/disable/verify`,e),this.preDisableMFASMS=async t=>this.post(`${z.v1}/mfa/sms/${t}/disable`),this.disableMFASMS=async(t,e)=>this.post(`${z.v1}/mfa/sms/${t}/disable/verify`,e),this.preDisableMFAWebAuthn=async t=>this.post(`${z.v1}/mfa/webauthn/${t}/disable`),this.disableMFAWebAuthn=async(t,e)=>this.post(`${z.v1}/mfa/webauthn/${t}/disable/verify`,e),this.getMFADevices=async()=>this.get(`${z.v1}/mfa/devices`),this.preEnrollMFAAuthenticatorAppForLogin=async t=>this.post(`${H.v1}/user/mfa/authenticator/enroll`,t),this.enrollMFAAuthenticatorAppForLogin=async t=>this.post(`${H.v1}/user/mfa/authenticator/enroll/verify`,t),this.enrollMFAAuthenticatorAppForLoginV2=async t=>{const e=await this.post(`${H.v1}/user/mfa/authenticator/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.verifyMFAAuthenticatorAppForLogin=async(t,e)=>this.post(`${H.v1}/user/mfa/authenticator/${t}/verify`,e),this.preVerifyMFAEmailCode=async t=>this.post(`${H.v1}/user/mfa/emailcode`,t),this.verifyMFAEmailCode=async t=>this.post(`${H.v1}/user/mfa/emailcode/verify`,t),this.verifyMFAEmailCodeV2=async t=>{const e=await this.post(`${H.v1}/user/mfa/emailcode/verify`,t);return this.generateLoginResponseV3(e)},this.preEnrollMFASMSForLogin=async t=>this.post(`${H.v1}/user/mfa/sms/enroll`,t),this.enrollMFASMSForLogin=async t=>this.post(`${H.v1}/user/mfa/sms/enroll/verify`,t),this.enrollMFASMSForLoginV2=async t=>{const e=await this.post(`${H.v1}/user/mfa/sms/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFASMSForLogin=async(t,e)=>this.post(`${H.v1}/user/mfa/sms/${t}`,e),this.verifyMFASMSForLogin=async(t,e)=>this.post(`${H.v1}/user/mfa/sms/${t}/verify`,e),this.verifyMFASMSForLoginV2=async(t,e)=>{const a=await this.post(`${H.v1}/user/mfa/sms/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.preEnrollMFAWebAuthnForLogin=async t=>this.post(`${H.v1}/user/mfa/webauthn/enroll`,t),this.enrollMFAWebAuthnForLogin=async t=>this.post(`${H.v1}/user/mfa/webauthn/enroll/verify`,t),this.enrollMFAWebAuthnForLoginV2=async t=>{const e=await this.post(`${H.v1}/user/mfa/webauthn/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${H.v1}/user/mfa/webauthn/${t}`,e),this.verifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${H.v1}/user/mfa/webauthn/${t}/verify`,e),this.verifyMFAWebAuthnForLoginV2=async(t,e)=>{const a=await this.post(`${H.v1}/user/mfa/webauthn/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.getSamlConfiguration=async()=>this.get(`${st.v1}/saml/configurations`),this.updateSamlConfiguration=async t=>this.post(`${st.v1}/saml/configurations`,t),this.getSamlVendorConfiguration=async()=>this.get(`${st.v1}/saml/configurations/vendor-config`),this.updateSamlVendorMetadata=async t=>this.put(`${st.v1}/saml/configurations/metadata`,t),this.validateSamlDomain=async()=>this.put(`${st.v1}/saml/validations/domain`),this.getSamlRoles=async()=>this.get(`${st.v1}/saml/configurations/roles/default`),this.getSamlRolesGroups=async()=>this.get(`${st.v2}/saml/configurations/groups`),this.updateSamlRoles=async({roleIds:t})=>this.post(`${st.v1}/saml/configurations/roles/default`,{roleIds:t}),this.createSamlGroup=async({roleIds:t,group:e})=>this.post(`${st.v2}/saml/configurations/groups`,{group:e,roleIds:t}),this.updateSamlGroup=async({roleIds:t,group:e,id:a})=>this.patch(`${st.v2}/saml/configurations/groups/${a}`,{group:e,roleIds:t}),this.deleteSamlGroup=async({id:t})=>this.delete(`${st.v2}/saml/configurations/groups/${t}`),this.getOidcConfiguration=async()=>this.get(`${st.v1}/oidc/configurations`),this.getSSOPublicConfiguration=async()=>this.get(`${st.v2}/configurations/public`),this.getSocialLoginProviders=async()=>this.get(J.v1),this.getSocialLoginProvidersV2=async()=>this.get(J.v2),this.getSocialLoginProvidersV2ForAuthenticatedUser=async()=>this.get(`${J.v2}/authenticated`),this.getCustomSocialLoginProvidersV1=async()=>this.get(J.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.state&&(e.state=t.state),this.post(`${H.v1}/user/sso/${t.provider}/postlogin`,{metadata:t.metadata,invitationToken:t.invitationToken},{params:e})},this.getVendorConfig=async()=>this.get(`${K.v1}/public`),this.signUpUser=async t=>{const{shouldActivate:e,authResponse:a,userId:n,tenantId:s}=await this.post(`${z.v1}/signUp`,t),i={shouldActivate:e,userId:n,tenantId:s};if(!e&&a){const{user:t,tenants:e,activeTenant:n}=await this.generateLoginResponseV3(a);return v({},i,{user:t,tenants:e,activeTenant:n})}return i},this.getCurrentUserSessions=async()=>this.get(z.sessions.currentUser.v1),this.getCurrentUserSession=async()=>this.get(`${z.sessions.currentUser.v1}/current`),this.revokeSessionsForUser=async t=>this.post(`${z.sessions.v1}/revoke`,{userId:t}),this.getSessionConfigurations=async()=>this.get(z.sessions.configurations.v1),this.createOrUpdateSessionConfigrations=async t=>{await this.post(z.sessions.configurations.v1,t)},this.deleteSessionForUser=async t=>{await this.delete(`${z.sessions.currentUser.v1}/${t}`)},this.deleteAllSessionsForUser=async()=>{await this.delete(`${z.sessions.currentUser.v1}/all`)},this.getUserAccessTokensData=async()=>this.get(z.accessTokens.v1),this.getTenantAccessTokensData=async()=>this.get(Q.accessTokens.v1),this.deleteTenantAccessToken=async({id:t})=>{await this.delete(`${Q.accessTokens.v1}/${t}`)},this.deleteUserAccessToken=async({id:t})=>{await this.delete(`${z.accessTokens.v1}/${t}`)},this.createUserAccessToken=async t=>this.post(z.accessTokens.v1,t),this.createTenantAccessToken=async t=>this.post(Q.accessTokens.v1,t),this.getUserApiTokensData=async()=>this.get(z.apiTokens.v1),this.getTenantApiTokensData=async()=>this.get(Q.apiTokens.v1),this.updateUserApiTokensData=async t=>this.post(z.apiTokens.v1,t),this.updateTenantApiTokensData=async t=>this.post(Q.apiTokens.v2,t),this.deleteTenantApiToken=async({tokenId:t})=>{await this.delete(`${Q.apiTokens.v1}/${t}`)},this.deleteUserApiToken=async({tokenId:t})=>{await this.delete(`${z.apiTokens.v1}/${t}`)},this.getUserById=async({userId:t})=>this.get(`${z.v1}/${t}`),this.checkIfAllowToRememberMfaDevice=async t=>this.get(`${K.v1}/mfa-policy/allow-remember-device`,{mfaToken:t}),this.passwordlessPreLogin=async t=>{let{type:e}=t,a=f(t,ge);return this.post(`${H.v1}/passwordless/${e.toLocaleLowerCase()}/prelogin`,a)},this.passwordlessPostLoginV2=async t=>{let{type:e}=t,a=f(t,he);const n=await this.post(`${H.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a);return this.generateLoginResponseV3(n)},this.passwordlessPostLogin=async t=>{let{type:e}=t,a=f(t,ye);return this.post(`${H.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a)},this.verifyInviteToken=async({token:t})=>this.post(Q.invites.verify.v1,{token:t}),this.getSSOConfigurations=async()=>this.get(`${st.v1}/configurations`),this.createSSOConfiguration=async t=>this.post(`${st.v1}/configurations`,t),this.updateSSOConfiguration=async(t,e)=>this.patch(`${st.v1}/configurations/${t}`,e),this.deleteSSOConfiguration=async t=>{await this.delete(`${st.v1}/configurations/${t}`)},this.createSSOConfigurationByMetadata=async t=>this.post(`${st.v1}/configurations/metadata`,t),this.updateSSOConfigurationByMetadata=async(t,e)=>this.put(`${st.v1}/configurations/${t}/metadata`,e),this.createSSOConfigurationByMetadataUrl=async t=>this.post(`${st.v1}/configurations/metadata-url`,t),this.updateSSOConfigurationByMetadataUrl=async(t,e)=>this.put(`${st.v1}/configurations/${t}/metadata-url`,e),this.createSSODomain=async(t,e)=>this.post(`${st.v1}/configurations/${t}/domains`,e),this.deleteSSODomain=async(t,e)=>this.delete(`${st.v1}/configurations/${t}/domains/${e}`),this.validateSSODomain=async(t,e)=>this.put(`${st.v1}/configurations/${t}/domains/${e}/validate`),this.validateSSODomainV2=async(t,e)=>this.put(`${st.v2}/configurations/${t}/domains/${e}/validate`),this.getSSODefaultRoles=async t=>this.get(`${st.v1}/configurations/${t}/roles`),this.setSSODefaultRoles=async(t,e)=>this.put(`${st.v1}/configurations/${t}/roles`,e),this.createSSOGroup=async(t,e)=>this.post(`${st.v1}/configurations/${t}/groups`,e),this.updateSSOGroup=async(t,{roleIds:e,group:a,id:n})=>this.patch(`${st.v1}/configurations/${t}/groups/${n}`,{group:a,roleIds:e}),this.deleteSSOGroup=async(t,e)=>this.delete(`${st.v1}/configurations/${t}/groups/${e}`),this.getSSOGroups=async t=>this.get(`${st.v1}/configurations/${t}/groups`),this.preLoginV2=async t=>this.post(`${H.v2}/user/sso/prelogin`,t),this.oidcPostLoginV2=async t=>{const e=await this.post(`${H.v2}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.exchangeOAuthTokensV2=async t=>{const e=await this.post(`${wt}/token`,t);return this.generateLoginResponseFromOAuthResponseV2(e)},this.silentOAuthRefreshTokenV2=async()=>{const t=ie(this.appName),e=await this.post(`${wt}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponseV2(e)},this.exchangeOAuthTokens=async t=>{const e=await this.post(`${wt}/token`,t);return this.generateLoginResponseFromOAuthResponse(e)},this.silentOAuthRefreshToken=async()=>{const t=ie(this.appName),e=await this.post(`${wt}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponse(e)},this.resetPhoneNumber=async t=>this.post(`${z.v1}/phone/reset`,t),this.verifyResetPhoneNumber=async t=>this.post(`${z.v1}/phone/reset/verify`,t),this.changePhoneNumberWithVerification=async t=>this.post(`${z.v1}/phone`,t),this.verifyChangePhoneNumber=async t=>this.post(`${z.v1}/phone/verify`,t),this.changePhoneNumber=async t=>this.put(`${z.v1}/phone/change`,t),this.webAuthnPreLogin=async t=>this.post(`${H.v1}/webauthn/prelogin`,t),this.webAuthnPostLogin=async t=>this.post(`${H.v1}/webauthn/postlogin`,t),this.webAuthnPostLoginV2=async t=>{const e=await this.post(`${H.v1}/webauthn/postlogin`,t);return this.generateLoginResponseV3(e)},this.webAuthnCreateNewDeviceSession=async()=>this.post(W.v1),this.getWebAuthnDevices=async()=>this.get(W.v1),this.deleteWebAuthnDevice=async t=>this.delete(`${W.v1}/${t}`),this.verifyNewDeviceSession=async t=>this.post(`${W.v1}/verify`,t),this.getVendorPublicAuthStrategiesConfig=async()=>this.get(`${K.v1}/auth/strategies/public`),this.getPublicAuthStrategiesConfigForAuthenticatedUser=async()=>this.get(`${K.v1}/auth/strategies`),this.getMFAStrategiesConfig=async()=>this.get(`${K.v1}/mfa/strategies`),this.getUserAuthorization=async()=>this.get(`${z.authorization.v1}`),this.getMeV2=async()=>this.get(`${z.v2}/me`),this.noThrowLoadEntitlements=async()=>{try{return await this.entitlementsApi.loadEntitlementsV2()}catch(t){}},this.getMeAndEntitlements=async()=>{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=ie(this.appName);return s&&(e.tenantId=s),v({},e,null!=n?n:{},{entitlements:a})},this.generateStepupSession=async t=>{const e=await this.post(`${H.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(){if(!L.for(this.appName).shouldLoadEntitlements())return!1;const[t]=Yt.getFeatureFlags([Kt],this.appName||"");return t}shouldLoadMeAuthorization(){const[t]=Yt.getFeatureFlags([Ht],this.appName);return t}}const ve=new Se("default");class fe extends qt{constructor(t){super(t),this.getProfile=async t=>this.get(`${z.v2}/me`,null!=t?t:{addRoles:!0}),this.updateProfile=async t=>this.put(`${z.v2}/me`,t),this.updateProfileImage=async t=>this.put(`${lt.v1}/me/image/v1`,t,{responseType:"plain",contentType:void 0}),this.changePassword=async t=>this.post(`${z.v1}/passwords/change`,t),this.loadUsers=async t=>{var e,a,n,s,i,o;const r=(t.filter||[]).reduce(((t,e)=>v({},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(it.v1,v({pageOffset:t.pageOffset,pageSize:t.pageSize},r,l))},this.addUser=async t=>this.post(z.v2,v({},t,{provider:"local"})),this.deleteUser=async t=>this.delete(`${it.v1}/${t.userId}`),this.updateUser=async t=>this.put(it.v1,t),this.updateUserExpirationTime=async t=>{const{userId:e,expirationInSeconds:a}=t;return this.put(`${z.temporary.v1}/${e}`,{expirationInSeconds:a})},this.setPermanentUser=async t=>this.delete(`${z.temporary.v1}/${t}`),this.getTemporaryUserConfiguration=async()=>this.get(z.temporary.configuration.v1),this.createInviteUserLink=async t=>this.post(Q.invites.user.v1,v({},t)),this.updateInviteUserLink=async t=>this.patch(Q.invites.user.v1,v({},t)),this.deleteInviteUserLink=async()=>this.delete(Q.invites.user.v1),this.getInviteUserLink=async()=>this.get(Q.invites.user.v1),this.getInviteLinkConfiguration=async()=>this.get(Q.invites.configuration.v1),this.loadAvailableRoles=async()=>this.get(ot.v1),this.loadAvailablePermissions=async()=>this.get(Y.v1),this.loadStats=async()=>this.get(`${rt.v1}/members`),this.resendActivationLink=async t=>this.post(`${it.v1}/${t.userId}/resendActivationEmail`,{}),this.resendInvitationLink=async t=>this.post(z.v2,v({},t,{provider:"local"})),this.resendInvitationLinkToAllTenants=async t=>this.post(z.invitation.resendAll.v1,v({},t)),this.disableUser=async t=>this.post(`${Q.users.v1}/${t}/disable`),this.enableUser=async t=>this.post(`${Q.users.v1}/${t}/enable`)}}const me=new fe("default");class be 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 Ae=new be("default"),we=["dataFilters"],Te=["templateId","dataFilters"],Ee=["dataFilters"];class Ie extends qt{constructor(t){super(t),this.getReports=async t=>this.get(`${St.v2}/tenant-reports`,t),this.getReport=async t=>this.get(`${St.v2}/${t.id}/tenant-reports`),this.renderReport=async t=>{let{dataFilters:e}=t,a=f(t,we);return{html:await this.get(`${vt.v1}/preview-report`,v({},a,{dataFilters:btoa(JSON.stringify(e||{})),responseType:"html"}),{responseType:"plain"})}},this.scheduleReport=async t=>{let{templateId:e,dataFilters:a}=t,n=f(t,Te);return this.post(`${St.v2}/${e}/tenant-reports`,v({},n,{dataFilters:btoa(JSON.stringify(a||{}))}))},this.downloadReport=async t=>{let{dataFilters:e}=t,a=f(t,Ee);const n=await this.get(`${vt.v1}/preview-report`,v({},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(`${vt.v1}/tenant-reports`,t)}}const Oe=new Ie("default"),Pe=["eventKey"],ke=["eventKey"];class _e extends qt{constructor(t){super(t),this.getSlackConfiguration=()=>this.get(`${pt.v1}/slack`),this.getSlackScope=()=>this.get(`${pt.v1}/slack/applications`),this.getSlackChannels=()=>this.get(`${pt.v1}/slack/channels`),this.postSlackConfiguration=t=>t.id?this.patch(`${pt.v1}/slack/subscription/${t.id}`,t):this.post(`${pt.v1}/slack/subscriptions`,t),this.deleteSlackConfiguration=t=>this.delete(`${pt.v1}/slack/subscriptions/${t.id}`),this.postSlackCode=t=>this.post(`${pt.v1}/slack/applications/registrations`,{code:t}),this.getEmailConfiguration=()=>this.get(`${pt.v1}/emails`),this.postEmailConfiguration=t=>{let{eventKey:e}=t,a=f(t,Pe);return this.post(`${pt.v1}/emails/${e}`,a)},this.patchEmailConfiguration=({eventKey:t,enabled:e})=>this.patch(`${pt.v1}/emails/${t}`,{enabled:e}),this.deleteEmailSubscriptions=(t,e)=>this.delete(`${pt.v1}/emails/${t}/subscriptions/${e}`),this.putEmailSubscriptions=(t,e,a)=>this.put(`${pt.v1}/emails/${e}/subscriptions/${t}`,a),this.deleteEmailConfiguration=t=>this.delete(`${pt.v1}/emails/${t}`),this.getSMSConfiguration=()=>this.get(`${pt.v2}/sms`),this.postSMSConfiguration=t=>{let{eventKey:e}=t,a=f(t,ke);return this.post(`${pt.v2}/sms/${e}`,a)},this.patchSMSConfiguration=({eventKey:t,enabled:e})=>this.patch(`${pt.v2}/sms/${t}`,{enabled:e}),this.deleteSMSSubscriptions=(t,e)=>this.delete(`${pt.v2}/sms/${t}/subscriptions/${e}`),this.putSMSSubscriptions=(t,e,a)=>this.put(`${pt.v2}/sms/${e}/subscriptions/${t}`,a),this.deleteSMSConfiguration=t=>this.delete(`${pt.v2}/sms/${t}`),this.getWebhooksConfigurations=()=>this.get(At),this.postWebhooksConfiguration=t=>t._id?this.patch(`${At}/${t._id}`,t):this.post(`${At}/custom`,t),this.deleteWebhooksConfiguration=t=>this.delete(`${At}/${t}`),this.getWebhookLog=(t,e=0,a=10)=>{const n=new URLSearchParams({id:t,offset:`${e}`,limit:`${a}`});return this.get(`${At}/logs/?${n.toString()}`)},this.postWebhookTest=t=>this.post(`${At}/test`,t),this.postWebhookRetry=t=>this.post(`${At}/logs/${t}/retries`),this.getCategories=()=>this.get(`${bt.v1}/categories`),this.getChannelMaps=t=>this.get(bt.v1,{channels:t})}}const Ue=new _e("default");class Le extends qt{constructor(t){super(t),this.getNotifications=async t=>this.get(ft,{params:t}),this.updateNotificationStatus=async t=>this.put(`${ft}/status`,{params:t}),this.updateNotificationIsPinned=async t=>{const{notificationId:e,pinStatus:a}=t;return this.put(`${ft}/${a}`,{notificationId:e})},this.markAllAsRead=async()=>this.post(`${ft}/status/mark-all-read`)}}const Re=new Le("default"),De=["endpoint","headerProps"];class Ce extends qt{constructor(t){super(t),this.getAudits=async t=>this.get(mt,t),this.getAuditsStats=async t=>this.get(`${mt}/stats`,t),this.exportAudits=async t=>{const{endpoint:e,headerProps:a}=t,n=f(t,De);return this.postDownload(`${mt}/export/${e}`,{properties:a},n)}}}const Ne=new Ce("default");class Me extends qt{constructor(t){super(t),this.updateSettings=async(t,e)=>this.put(ct.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.getSettings=async t=>this.get(ct.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getPublicSettings=async()=>this.get(`${ct.v1}/public`)}}const Fe=new Me("default"),xe=["roleId"],$e=["roleId"],Ge=["permissionId"];class je extends qt{constructor(t){super(t),this.getRoles=async()=>this.get(X.v1),this.addRole=async t=>this.post(X.v1,t),this.deleteRole=async({roleId:t})=>this.delete(`${X.v1}/${t}`),this.updateRole=async t=>{let{roleId:e}=t,a=f(t,xe);return this.patch(`${X.v1}/${e}`,a)},this.attachPermissionsToRole=async t=>{let{roleId:e}=t,a=f(t,$e);return this.put(`${X.v1}/${e}/permissions`,a)},this.getPermissions=async()=>this.get(Y.v1),this.attachPermissionToRoles=async t=>{let{permissionId:e}=t,a=f(t,Ge);return this.put(`${Y.v1}/${e}/roles`,a)},this.getPermissionCategories=async()=>this.get(`${Y.v1}/categories`),this.addRoleV2=async t=>this.post(X.v2,t)}}const Ve=new je("default");class Be extends qt{constructor(...t){super(...t),this.getSubscriptionInvoices=async()=>this.get(gt.invoices.v1),this.getSubscriptionInvoice=async t=>this.get(`${gt.invoices.v1}/${t}`),this.getSubscriptionInvoicePdf=async(t,e)=>this.get(`${gt.invoices.v1}/${t}/pdf`,{outputFileName:e},{responseType:"blob"})}}class We extends qt{constructor(...t){super(...t),this.getManagedSubscription=async t=>this.get(`${yt.v1}/${t}`),this.getManagedSubscriptions=async()=>this.get(yt.v1),this.cancelManagedSubscription=async t=>this.put(`${yt.v1}/${t}/cancellations/`,{}),this.renewManagedSubscription=async t=>this.put(`${yt.v1}/${t}/renewals/`,{}),this.updateManagedSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${yt.v1}/${t}`,{paymentMethodId:e,planId:a})}}const He=["email"];class ze extends qt{constructor(...t){super(...t),this.getPaymentMethods=async()=>this.get(gt.paymentMethods.v1),this.getPaymentMethod=async t=>this.get(`${gt.paymentMethods.v1}/${t}`),this.updatePaymentMethodBillingDetails=async(t,e)=>{let{email:a}=e,n=f(e,He);return this.patch(`${gt.paymentMethods.v1}/${t}/billing-details`,{email:a,address:n})}}}class Ke extends qt{constructor(...t){super(...t),this.getPaymentProviders=async()=>this.get(ht.v1)}}class qe extends qt{constructor(...t){super(...t),this.getSubscriptionPlans=async()=>this.get(gt.plans.v1),this.getSubscriptionPlan=async t=>this.get(`${gt.plans.v1}/${t}`)}}class Je extends qt{constructor(...t){super(...t),this.getSubscriptions=async()=>this.get(gt.subscriptions.v1),this.getSubscription=async t=>this.get(`${gt.subscriptions.v1}/${t}`),this.cancelSubscription=async t=>this.put(`${gt.subscriptions.v1}/${t}/cancellations/`,{}),this.renewSubscription=async t=>this.put(`${gt.subscriptions.v1}/${t}/renewals/`,{}),this.updateSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${gt.subscriptions.v1}/${t}`,{paymentMethodId:e,planId:a})}}class Ye extends qt{constructor(...t){super(...t),this.getSubscriptionSummaries=async t=>this.get(`${gt.summaries.v1}/${t}`)}}class Qe extends qt{constructor(...t){super(...t),this.getTenantConfiguration=async t=>this.get(`${gt.tenantConfiguration.v1}/${t}`),this.createTenantConfiguration=async t=>this.post(gt.tenantConfiguration.v1,t)}}class Xe extends qt{constructor(...t){super(...t),this.getVendorPublicConfigurations=async()=>this.get(gt.configurations.vendorPublicConfigurations.v1)}}class Ze extends qt{constructor(...t){super(...t),this.createSubscription=async t=>this.post(gt.paymentProviders.stripe.subscriptions.v1,t),this.getStripeCustomer=async t=>this.get(`${gt.paymentProviders.stripe.customers.v1}/${t}`),this.createStripeCustomer=async t=>this.post(gt.paymentProviders.stripe.customers.v1,t),this.getStripePaymentProviderConfiguration=async()=>this.get(gt.paymentProviders.stripe.publicConfigurations.v1),this.createStripePaymentMethodSetupIntentSecret=async t=>this.post(gt.paymentProviders.stripe.setupIntents.v1,t)}}class ta extends qt{constructor(t){super(t),this.invoicesApi=new Be(this.appName),this.managedSubscriptionApi=new We(this.appName),this.paymentMethodsApi=new ze(this.appName),this.paymentProvidersApi=new Ke(this.appName),this.plansApi=new qe(this.appName),this.subscriptionApi=new Je(this.appName),this.summariesApi=new Ye(this.appName),this.subscriptionTenantConfigApi=new Qe(this.appName),this.vendorPublicConfigApi=new Xe(this.appName),this.stripeProviderApi=new Ze(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 ea=new ta("default");class aa extends qt{constructor(t){super(t),this.getVendorPublicInfo=async()=>this.get("/vendors/public")}}const na=new aa("default");class sa extends qt{constructor(t){super(t),this.loadAllUsers=async t=>this.get(Z.v1,t),this.addUserToTenantAndSubTenants=async t=>this.post(Z.v1,t),this.removeUserFromTenantAndSubTenants=async(t,e)=>this.delete(Z.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.addUserRolesForSubTenants=async(t,e,a)=>this.post(`${Z.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.removeUserRolesFromSubTenants=async(t,e,a)=>this.delete(`${Z.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.setUserRolesForSubTenants=async(t,e,a)=>this.patch(`${Z.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.createSubTenant=async(t,e)=>this.post(dt.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.deleteSubTenant=async(t,e)=>this.delete(`${dt.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.updateSubTenant=async({tenantId:t},e,a)=>this.patch(`${dt.v1}/${t}`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubTenantManagement=async({tenantId:t},e,a)=>this.put(`${dt.v1}/${t}/management`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubAccountAccess=async(t,e,a)=>this.put(`${Z.v1}/${t}/access`,e,{headers:this.extractHeadersFromOptions(a)}),this.addUsersToSubTenant=async(t,e)=>this.post(`${Z.v2}/`,t,{headers:this.extractHeadersFromOptions(e)})}updateSubTenantHierarchySettings({tenantId:t},e,a){return this.put(`${dt.v1}/${t}/hierarchy-settings`,e,{headers:this.extractHeadersFromOptions(a)})}}const ia=new sa("default");class oa extends qt{constructor(t){super(t),this.getConfigs=async()=>this.get(`${Et}`),this.updateConfiguration=async(t,e)=>this.patch(`${Et}/${t}`,e),this.createConfiguration=async t=>this.post(`${Et}`,t),this.deleteConfiguration=async t=>this.delete(`${Et}/${t}`),this.countConfigurationUsers=async t=>this.get(`${It}/${t}/Users/count`)}}const ra=new oa("default");class la extends qt{constructor(t){super(t),this.impersonate=async t=>this.post(`${tt.v1}`,t)}}const ca=new la("default"),ua=["groupId"];class da extends qt{constructor(t){super(t),this.getGroupById=async({groupId:t},e)=>this.get(`${at.v1}/${t}`,v({},e)),this.getGroups=async t=>this.get(`${at.v1}`,v({},t)),this.getGroupsByIds=async(t,e)=>this.post(`${at.getByIds.v1}`,t,{params:e}),this.createGroup=async t=>this.post(`${at.v1}`,t),this.updateGroup=async t=>{let{groupId:e}=t,a=f(t,ua);return this.patch(`${at.v1}/${e}`,a)},this.deleteGroup=async t=>this.delete(`${at.v1}/${t}`),this.addRolesToGroup=async(t,e)=>this.post(`${at.v1}/${t}/roles`,e),this.deleteRolesFromGroup=async(t,e)=>this.delete(`${at.v1}/${t}/roles`,e),this.addUsersToGroup=async(t,e)=>this.post(`${at.v1}/${t}/users`,e),this.deleteUsersFromGroup=async(t,e)=>this.delete(`${at.v1}/${t}/users`,e),this.getGroupConfiguration=async()=>this.get(`${at.configurations.v1}`),this.updateGroupConfiguration=async t=>this.post(`${at.configurations.v1}`,t)}}const pa=new da("default");class ga extends qt{constructor(t){super(t),this.getRecommendations=async()=>this.get(Pt.v1),this.getInsights=async()=>this.get(kt.v1)}}const ha=new ga("default");class ya extends qt{constructor(t){super(t),this.getUserPhoneNumbers=async t=>this.get(`${nt.v1}`,t),this.createPhoneNumber=async t=>this.post(`${nt.v1}`,t),this.deletePhoneNumber=async t=>this.delete(`${nt.v1}/${t}`),this.preVerifyPhoneNumber=async t=>this.post(`${nt.v1}/preverify`,t),this.verifyPhoneNumber=async t=>this.post(`${nt.v1}/verify`,t),this.verifyDeletePhoneNumber=async(t,e)=>this.post(`${nt.v1}/${t}/delete/verify`,e)}}const Sa=new ya("default");class va extends qt{constructor(t){super(t),this.getUserApplicationsId=async({userId:t})=>this.get(`${et.v1}/${t}/apps`),this.getUsersApplicationsId=async({userIds:t})=>this.get(`${et.v1}/users-apps`,{userIds:t.join(",")}),this.getTenantsApplications=async()=>this.get(Ut.v1),this.getApplicationsData=async({appIds:t,includeFreeAccess:e=!0})=>this.get(_t,{ids:t.join(","),_includeFreeAccess:e}),this.assignUserToApplications=async t=>this.post(`${et.v1}/apps-user`,t),this.unassignUserFromApplications=async t=>this.delete(`${et.v1}/user-apps`,t),this.getUsersOfApplications=async({appIds:t})=>this.get(`${et.v1}/apps-users`,{appIds:t.join(",")})}}const fa=new va("default");let ma,ba,Aa,wa,Ta;!function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}(ma||(ma={})),function(t){t.createdAt="createdAt",t.name="name",t.tenantId="tenantId"}(ba||(ba={})),function(t){t.CUSTOMER="customer",t.SPAM="spam",t.TEST="test",t.RESELLER="reseller",t.HEADQUARTER="headquarter"}(Aa||(Aa={})),function(t){t.NEVER="NEVER",t.ALWAYS="ALWAYS",t.ASSIGNABLE="ASSIGNABLE"}(wa||(wa={})),function(t){t.DEFAULT_OFF="defaultOff",t.DEFAULT_ON="defaultOn",t.ALWAYS_ON="alwaysOn"}(Ta||(Ta={}));const Ea=[/^(.*)\/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]*$/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],Ia=`${H.v1}/user/token/refresh`,Oa=`${wt}/authorize/silent`,Pa=`${z.v2}/me`,ka=`${z.v2}/me/tenants`,_a=`${z.v3}/me/tenants`,Ua=Ot;let La,Ra,Da,Ca,Na;!function(t){t.FRONTEGG="frontegg",t.OKTA="okta",t.AZURE_AD="azure-ad",t.OTHER="other"}(La||(La={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(Ra||(Ra={})),function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}(Da||(Da={})),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"}(Ca||(Ca={})),function(t){t.MFA_UNENROLLED="mfa-unenrolled",t.BREACHED_PASSWORDS="breached-passwords",t.INACTIVE="inactive"}(Na||(Na={}));const Ma=["local","saml","google","github","facebook","microsoft","scim2","slack"];let Fa,xa,$a,Ga,ja,Va;!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"}(Fa||(Fa={})),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"}(xa||(xa={})),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"}($a||($a={})),function(t){t.SEVERE="SEVERE",t.WARNING="WARNING",t.INFO="INFO"}(Ga||(Ga={})),function(t){t.MFA="MFA",t.SESSIONS="SESSIONS",t.PASSWORD="PASSWORD",t.INACTIVITY="INACTIVITY",t.IP="IP",t.DOMAIN="DOMAIN",t.SSO="SSO"}(ja||(ja={})),function(t){t.FREE_ACCESS="FREE_ACCESS",t.MANAGED_ACCESS="MANAGED_ACCESS"}(Va||(Va={}));const Ba={auth:ve,securityPolicy:pe,teams:me,metadata:Ae,reports:Oe,connectivity:Ue,notifications:Re,audits:Ne,tenants:le,accountSettings:Fe,roles:Ve,subscriptions:ea,vendor:na,subTenants:ia,featureFlags:Xt,directory:ra,impersonate:ca,groups:pa,users:ae,entitlements:ue,securityCenter:ha,userPhoneNumbers:Sa,applications:fa},Wa=t=>({auth:new Se(t),securityPolicy:new de(t),teams:new fe(t),metadata:new be(t),reports:new Ie(t),connectivity:new _e(t),notifications:new Le(t),audits:new Ce(t),tenants:new re(t),accountSettings:new Me(t),roles:new je(t),subscriptions:new ta(t),vendor:new aa(t),subTenants:new sa(t),featureFlags:new Qt(t),directory:new oa(t),impersonate:new la(t),groups:new da(t),users:new ee(t),entitlements:new ce(t),securityCenter:new ga(t),userPhoneNumbers:new ya(t),applications:new va(t)}),Ha={fetch:Mt,FetchClient:Nt,ContextHolder:L,FronteggContext:D,api:Ba,createApiClient:Wa,FronteggApiError:B,AuthStrategyEnum:N,MachineToMachineAuthStrategy:M,SocialLoginProviders:C,ISubscriptionCancellationPolicy:$,ISubscriptionStatus:F,PaymentMethodType:x,ProviderType:G},za=t=>JSON.parse(JSON.stringify(t)),Ka=(t=500)=>new Promise((e=>{setTimeout(e,t)})),qa=async(t,e,a)=>{let n=0;for(;n<e-1;)try{return await t()}catch(t){if(n++,n>=e)throw t;await new Promise((t=>setTimeout(t,a)))}return await t()};function Ja(t,e){const a=v({},t);return e.forEach((t=>{delete a[t]})),a}function Ya(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}let Qa,Xa,Za;!function(t){t.validate="validate",t.invalid="invalid",t.pending="pending",t.success="success",t.failed="failed"}(Qa||(Qa={})),function(t){t.activating="activating",t.success="success",t.resend="resend",t.activatingForm="activatingForm"}(Xa||(Xa={})),function(t){t.LOAD_API_TOKENS="LOAD_API_TOKENS",t.ADD_API_TOKEN="ADD_API_TOKEN",t.DELETE_API_TOKEN="DELETE_API_TOKEN"}(Za||(Za={}));var tn=a(8792),en=a.n(tn),an=a(5875);const nn=(t="default")=>{if(!L.for(t).shouldLoadEntitlements())throw new Error("You must first enable entitlements via Frontegg options to use this function")},sn=(t,e,a,n,s="default")=>(nn(s),(0,an.Me)(e,t,a)),on=(t,e,a,n,s="default")=>(nn(s),(0,an.a_)(e,t,a)),rn=(t,e,a,n,s="default")=>"permissionKey"in e?sn(t,e.permissionKey,a,n,s):on(t,e.featureKey,a,n,s);function ln(t,e){return en()(t,e)}let cn,un,dn,pn,gn,hn,yn,Sn,vn,fn,mn,bn,An,wn,Tn,En,In,On,Pn,kn;!function(t){t.forgotPassword="forgotPassword",t.success="success"}(cn||(cn={})),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"}(un||(un={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(dn||(dn={})),function(t){t.impersonating="impersonating",t.success="success"}(pn||(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"}(gn||(gn={})),function(t){t.Login="login",t.RegisterQuickLogin="registerQuickLogin"}(hn||(hn={})),function(t){t.Internal="internal",t.UsbKey="usb-key",t.Android="android",t.Sms="sms"}(yn||(yn={})),function(t){t["social-login"]="social-login",t["custom-social-login"]="custom-social-login",t.direct="direct"}(Sn||(Sn={})),function(t){t.verify="verify",t.recoveryCode="recoveryCode",t.authenticatorApp="authenticatorApp",t.smsSetPhoneNumber="smsSetPhoneNumber",t.smsVerifyCode="smsVerifyCode",t.emailVerifyCode="emailVerifyCode",t.noMFAEnrolledStepUp="noMFAEnrolledStepUp"}(vn||(vn={})),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"}(fn||(fn={})),function(t){t.ResetPhoneNumber="ResetPhoneNumber",t.VerifyResetPhoneNumber="VerifyResetPhoneNumber",t.ChangePhoneNumber="ChangePhoneNumber"}(mn||(mn={})),function(t){t.EDIT_ROLE_DIALOG="editRoleDialog",t.DELETE_ROLE_DIALOG="deleteRoleDialog",t.LOAD_ROLES="loadRoles",t.ADD_ROLE="addRole",t.MANAGE_PERMISSIONS="managePermissions"}(bn||(bn={})),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"}(An||(An={})),function(t){t.SignUp="SignUp",t.SignUpSuccess="SignUpSuccess"}(wn||(wn={})),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"}(Tn||(Tn={})),function(t){t.Saml="saml",t.Okta="okta",t.Azure="azure",t.Google="google",t.Oidc="oidc"}(En||(En={})),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"}(In||(In={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORDLESS="PASSWORDLESS",t.ACTIVATION_LINK="ACTIVATION_LINK"}(On||(On={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORD="PASSWORD"}(Pn||(Pn={})),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"}(kn||(kn={}));const _n={profile:kn.profile,privacy:kn.privacy,personalApiTokens:kn.personalApiTokens,account:kn.account,users:kn.users,groups:kn.groups,security:kn.security,sso:kn.sso,audits:kn.audits,webhooks:kn.webhooks,apiTokens:kn.apiTokens,roles:kn.roles,subscriptions:kn.subscriptions,allAccounts:kn.allAccounts};var Un=a(2743),Ln=a.n(Un);const Rn=(t,e)=>{const a=Ln()(t,v({},e));return function(t={}){return O(t)}(v({__isProxy:!0},a))},Dn={step:Qa.validate},Cn=t=>Rn(Dn,t),Nn=t=>t instanceof Error||(null==t?void 0:t.message)&&(null==t?void 0:t.stack)&&"Error"===(null==t?void 0:t.name),Mn=(t,e)=>t?(t=>Boolean(null==t?void 0:t.statusCode))(t)?t.message:(Nn(t)?console.error(t.message):"string"==typeof t&&console.error(t),null!=e?e:"We're facing some difficulties, Please try again"):e,Fn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.acceptInvitationState,e)};return{setAcceptInvitationState:n,resetAcceptInvitationState:()=>{t.auth.acceptInvitationState=za(Dn)},acceptInvitation:async t=>{if(t.token&&t.userId)try{n({error:void 0,step:Qa.pending}),await e.auth.acceptInvitation(t),n({step:Qa.success})}catch(t){n({step:Qa.failed,error:Mn(t)})}else n({error:void 0,step:Qa.invalid})}}},xn={loading:!1},$n=t=>Rn(xn,t),Gn=["activeTenant","tenants"],jn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.accountSettingsState,e)};return{setAccountSettingsState:n,resetAccountSettingsState:()=>{t.auth.accountSettingsState=za(xn)},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,p=await e.accountSettings.updateSettings(v({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,Gn),r=i.map((t=>t.id!==(null==s?void 0:s.id)?t:v({},t,e))),l=v({},s,e);a.setTenantsState(v({},o,{tenants:r,activeTenant:l}))})({newSettingValues:p}),n(v({},p,{loading:!1})),null==(i=s.callback)||i.call(s,p)}catch(t){var o;n({loading:!1,error:Mn(t)}),null==(o=s.callback)||o.call(s,null,t)}},loadAccountSettings:async t=>{n({loading:!(null!=t&&t.silentLoading),error:null});try{const t=await e.accountSettings.getSettings();n(v({},t,{loading:!1}))}catch(t){n({loading:!1,error:Mn(t)})}}}},Vn={step:Xa.activating,loading:!1,resentEmail:!1,activationStrategy:{loading:!1}},Bn=t=>Rn(Vn,t);let Wn;function Hn(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"}(Wn||(Wn={}));const zn={[N.Code]:gn.loginWithOtc,[N.EmailAndPassword]:gn.loginWithPassword,[N.MagicLink]:gn.magicLinkPreLoginSuccess,[N.SmsCode]:gn.loginWithSmsOtc},Kn={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"},qn=t=>{try{return new URL(t),!0}catch(t){return!1}},Jn=({authenticatedUrl:t,enforceRedirectToSameSite:e,allowedRedirectOrigins:a,includeQueryParam:n})=>{let s=t;const i=new URL(window.location.href).searchParams.get("redirectUrl");return i?e&&qn(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},Yn=t=>{const{searchParams:e}=new URL(t),a=e.toString();if(a)return`?${a}`},Qn=t=>{const{pathname:e}=new URL(t),a=Yn(t);return a?e+a:e},Xn=t=>{const e=new URLSearchParams(window.location.search).get(t);return null!=e?e:void 0},Zn="tenantId",ts=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}},es=t=>{const{numberOfPhoneDevices:e,numberOfAuthenticators:a,numberOfEmails:n,totalDevices:s}=ts(t);if(1===s){if(a)return vn.authenticatorApp;if(e)return vn.smsVerifyCode;if(n)return vn.emailVerifyCode}return vn.verify},as=t=>{if(1===t.length){const[e]=t;if(e===Wt.AuthenticatorApp)return vn.authenticatorApp;if(e===Wt.SMS)return vn.smsSetPhoneNumber;if(e===Wt.EmailCode)return vn.emailVerifyCode}return vn.verify},ns=t=>"/oauth/callback"===t;function ss(t){return"email"in t}const is=t=>{const e=L.for(t.root.appName).getBasename();return null!=e&&e.endsWith("/")?e.slice(0,-1):e},os="http://schemas.openid.net/pape/policies/2007/06/multi-factor",rs="mfa",ls=["otp","sms","hwk"],cs="SHOULD_STEP_UP",us="maxAge",ds="FRONTEGG_AFTER_AUTH_REDIRECT_URL",ps="HOSTED_LOGIN_VERIFIER_KEY",gs=(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===os,o=-1!==a.indexOf(rs),r=void 0!==ls.find((t=>a.indexOf(t)));return i&&o&&r};function hs(){const t=window.location.pathname+window.location.search;window.localStorage.setItem(ds,t)}const ys=(t,e,a)=>{hs();const n=new URLSearchParams(window.location.search);a&&n.set(us,a.toString()),e(`${t}${n?`?${n}`:""}`,{refresh:!1})},Ss=["phoneNumber"],vs=["authenticatedUrl"],fs=(t,e)=>{const a=L.for(e);return t.mfaRequired&&t.mfaToken?(a.setAccessToken(null),a.setUser(null),!0):(a.setAccessToken(t.accessToken),a.setUser(t),!1)},ms=(t,e=[])=>Object.entries(t).reduce(((t,[a,n])=>"object"==typeof n?[...t,...ms(n,[...e,a])]:[...t,{type:[...e,a].join("/"),payload:n}]),[]),bs=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}},As=t=>f(t,Ss),ws=(t,e)=>{const a=f(v({},Kn,e),vs);return Object.values(a).includes(t)},Ts=["callback","events"],Es=["user"],Is=["callback"],Os=["callback"],Ps=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.activateAccountState,e)},i=()=>{t.auth.activateAccountState=za(Vn)},o=e=>{Object.assign(t.auth.activateAccountState.activationStrategy,e)};return{setActivateState:s,resetActivateState:i,setActivateStrategyState:o,activateAccount:async a=>{const{callback:o,events:r}=a,l=f(a,Ts);s({loading:!0});try{const a=L.for(t.root.appName).onRedirectTo,u=t.auth.routes,d=await e.auth.activateAccountV2(l),{user:p}=d,g=f(d,Es);if(p.redirectLocation)return void(window.location.href=p.redirectLocation);if(fs(p,t.root.appName)){s({step:Xa.success});const t=await n.getMfaRequiredState(p);n.setAuthState(t),await Ka(1e3),a(u.loginUrl,{preserveQueryParams:!0})}else{var c;s({step:Xa.success});const t={email:p.email,origin:On.ACTIVATION_LINK,id:p.id,tenantId:p.tenantId,name:p.name,createdAt:new Date};null==r||null==(c=r.userVerified)||c.call(r,t),Hn(Wn.USER_VERIFIED,t),await n.afterAuthenticationStateUpdate(v({user:p},g),{isAuthenticated:!0}),await Ka(1e3),await n.afterAuthNavigation(),i()}null==o||o(!0)}catch(t){s({loading:!1,error:Mn(t)})}},preActivateAccount:async a=>{const{userId:i,token:r}=a;s({loading:!0,step:Xa.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:Xa.activatingForm})}catch(t){s({loading:!1,error:Mn(t)})}},getActivateAccountStrategy:async t=>{const{callback:a}=t,n=f(t,Is);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:Mn(t)})}},resendActivationEmail:async t=>{const{callback:a}=t,i=f(t,Os);n.setTeamLoader({key:In.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:Mn(t)}),null==a||a(null,t)}finally{n.setTeamLoader({key:In.RESEND_ACTIVATE_LINK,value:!1})}}}},ks={loading:!1,error:void 0,unlockAccountSuccess:!1},_s=t=>Rn(ks,t),Us=(t,e,a)=>{const n=e=>{Object.assign(t.auth.unlockAccountState,e)};return{setUnlockAccountState:n,resetUnlockAccountState:()=>{t.auth.activateAccountState=za(ks)},unlockAccount:async a=>{const{token:s}=a,i=L.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 Ka(1e3),i(o.loginUrl)}catch(t){n({loading:!1,error:Mn(t)})}}}},Ls={apiTokenType:null,searchValue:"",showAddTokenDialog:!1,createdByUserIdColumn:"show",deleteTokenDialog:{open:!1,clientId:""},successDialog:{open:!1,secret:"",clientId:""},loaders:{},apiTokensDataTenant:[],apiTokensDataUser:[],roles:[],permissions:[],errors:{}},Rs=t=>Rn(Ls,t),Ds=(t,e,a)=>{const n=e=>{Object.assign(t.auth.apiTokensState,{loaders:v({},t.auth.apiTokensState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.apiTokensState,{errors:v({},t.auth.apiTokensState.errors,{[e.key]:e.value}),loaders:v({},t.auth.apiTokensState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.apiTokensState,e)};return{setApiTokensLoader:n,setApiTokensError:s,setApiTokensState:i,resetApiTokensState:()=>{t.auth.apiTokensState=za(Ls)},loadApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Za.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:Za.LOAD_API_TOKENS,value:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var o;s({key:Za.LOAD_API_TOKENS,value:Mn(e)}),n({key:Za.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:Za.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([e.auth.getUserApiTokensData(),e.auth.getUserAccessTokensData()]),l=(null!=(a=r.accessTokens)?a:[]).map((t=>v({},t,{type:M.AccessToken}))).concat(s.map((t=>v({},t,{type:M.ClientCredentials})))).sort(((t,e)=>new Date(e.createdAt)-new Date(t.createdAt)));i({apiTokensDataUser:null!=l?l:[]}),n({key:Za.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Za.LOAD_API_TOKENS,value:Mn(e)}),n({key:Za.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:Za.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([e.auth.getTenantApiTokensData(),e.auth.getTenantAccessTokensData()]),l=(null!=(a=null==r?void 0:r.accessTokens)?a:[]).map((t=>v({},t,{type:M.AccessToken}))).concat(s.map((t=>v({},t,{type:M.ClientCredentials})))).sort(((t,e)=>new Date(e.createdAt)-new Date(t.createdAt)));i({apiTokensDataTenant:null!=l?l:[]}),n({key:Za.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Za.LOAD_API_TOKENS,value:Mn(e)}),n({key:Za.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=Za.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 Ka(200);const d=n?M.AccessToken:M.ClientCredentials;t.auth.apiTokensState.apiTokensDataTenant.unshift(v({},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:Mn(t)}),null==c||c(null,t)}finally{n({key:u,value:!1})}},addUserApiToken:async a=>{const{description:o,expires:r,callback:l}=a,c=Za.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 Ka(200);const u=n?M.AccessToken:M.ClientCredentials;t.auth.apiTokensState.apiTokensDataUser.unshift(v({},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:Mn(t)}),null==l||l(null,t)}finally{n({key:c,value:!1})}},deleteUserApiToken:async a=>{const o=Za.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:Mn(t)})}finally{n({key:o,value:!1})}},deleteTenantApiToken:async a=>{const o=Za.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:Mn(t)})}finally{n({key:o,value:!1})}}}},Cs={loading:!0,fetching:!0,error:null,userApplications:[],accountApplications:[]},Ns=t=>Rn(Cs,t),Ms=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:[]},Fs=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.applicationsState,e)},i=async({userIds:t})=>{try{const a=await e.applications.getUsersApplicationsId({userIds:t}),n=Ms(a),s=await e.applications.getApplicationsData({appIds:n});return t.reduce(((t,e)=>{var n,i,o;const r=null==(n=a.find((t=>t.userId==e)))?void 0:n.appIds;return t[e]=[...s.filter((t=>t.accessType===Va.FREE_ACCESS)),...null!=(i=null==r||null==(o=r.map((t=>s.find((e=>t===e.id)))))?void 0:o.filter((t=>!!t)))?i:[]],t}),{})}catch(t){s({error:Mn(t)})}},o="Assignment action failed. Try again or contact support.";return{setApplicationsState:s,resetApplicationsState:()=>{t.auth.applicationsState=za(Cs)},loadUserApplications:async()=>{s({loading:!0,fetching:!0});try{var a,n;const i=null!=(a=null==(n=t.auth.user)?void 0:n.id)?a:"",o=await e.applications.getUserApplicationsId({userId:i}),r=await e.applications.getApplicationsData({appIds:o});s({userApplications:r,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Mn(t)})}},loadAccountApplications:async()=>{s({loading:!0,fetching:!0});try{const t=await e.applications.getTenantsApplications(),a=Ms(t),n=await e.applications.getApplicationsData({appIds:a}),i=await e.applications.getUsersOfApplications({appIds:a}),o=n.map((t=>{var e;return v({},t,{userIds:null==(e=i.find((e=>e.appId===t.id)))?void 0:e.userIds})}));s({accountApplications:o,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Mn(t)})}},loadMultipleUsersApplications:i,assignUserToApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,p,g,h,y,S,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==(p=t.auth)||null==(g=p.applicationsState)?void 0:g.accountApplications,o=null!=(h=null==(y=t.auth)||null==(S=y.teamState)?void 0:S.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?v({},t,{applications:[...null!=(e=t.applications)?e:[],...m]}):t}))}),null==l||l(!0)}catch(t){s({error:Mn(t,o)}),null==l||l(!1)}},unassignUserFromApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,p,g,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!=(p=null==(g=t.auth)||null==(h=g.teamState)?void 0:h.users)?p:[],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?v({},t,{applications:o.filter((t=>!r.includes(t.id)))}):t))}),null==l||l(!0)}catch(t){s({error:Mn(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===Va.FREE_ACCESS)))?r:[];if(null!=a&&a.length){var d,p,g;const n=null!=(d=null==(p=t.auth)||null==(g=p.user)?void 0:g.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})=>{const[n]=await a.getFeatureFlags(["multi-apps-admin-portal"]);if(!n||!t)return e;const s=e.map((t=>t.id)),o=await i({userIds:s});return o?e.map((t=>null!=o&&o[t.id]?v({},t,{applications:o[t.id]}):t)):e}}},xs={loading:!0,error:null},$s=t=>Rn(xs,t),Gs=["callback"],js=(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=L.for(t.root.appName).getContext())||null==(n=a.tenantResolver)?void 0:n.call(a)))?void 0:e.tenant)};return{setCustomLoginState:s,resetCustomLoginState:()=>{t.auth.customLoginState=za(xs)},loadTenantMetadata:async()=>{s({loading:!0});try{const t=await e.metadata.getAdminBoxMetadata();s({tenantMetadata:t,loading:!1})}catch(t){s({loading:!1,error:Mn(t)})}},updateTenantMetadata:async t=>{const{callback:a}=t,n=f(t,Gs);try{s({error:null,saving:!0});const t=ms(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:Mn(t,"No changes to update"),saving:!1}),null==a||a(null,t)}},customLoginEnabled:i,loadCustomLoginRoutes:async()=>{try{var a;if(!await i())return;const o=t.auth.isAuthenticated,{getSettings:r,getPublicSettings:l}=e.accountSettings,{applicationUrl:c}=await(o?r():l());if(!c)return;const u=t.auth.routes,d=null!=(a=Yn(c))?a:"";n.setAuthState({routes:v({},u,{customLoginAuthenticatedUrl:c,customLoginUrl:u.loginUrl+d})}),s({customLoginSearchParams:null!=d?d:void 0})}catch{}}}},Vs={step:cn.forgotPassword,loading:!1,email:"",passwordConfig:null},Bs=t=>Rn(Vs,t),Ws=["callback"],Hs=(t,e,a)=>{const n=e=>{Object.assign(t.auth.forgotPasswordState,e)};return{setForgotPasswordState:n,resetForgotPasswordState:()=>{t.auth.forgotPasswordState=za(Vs)},forgotPassword:async t=>{n({loading:!0});try{var a;await e.auth.forgotPassword(t),n({loading:!1,error:void 0,step:cn.success}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;n({loading:!1,error:Mn(e,"Unknown error occurred")}),null==(s=t.callback)||s.call(t,!1,e)}},resetPassword:async t=>{const{callback:a}=t,s=f(t,Ws);n({loading:!0});try{await e.auth.resetPassword(s),n({loading:!1,error:void 0,step:cn.success}),null==a||a(!0)}catch(t){n({loading:!1,error:Mn(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:Mn(t)})}}}},zs={loaders:{},errors:{},groups:[],groupsConfiguration:{}},Ks=t=>Rn(zs,t),qs=["roleIds","userIds"],Js=(t,e,a)=>{const n=e=>{Object.assign(t.auth.groupsState,{loaders:v({},t.auth.groupsState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.groupsState,{errors:v({},t.auth.groupsState.errors,{[e.key]:e.value}),loaders:v({},t.auth.groupsState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.groupsState,e)},o=async()=>{const a=un.GET_GROUPS,o=t.auth.groupsState;n({key:a,value:!0});try{const{groups:t}=await e.groups.getGroups({_groupsRelations:dn.rolesAndUsers});i(v({groups:t},o.selectedGroup&&{selectedGroup:t.find((t=>{var e;return t.id===(null==(e=o.selectedGroup)?void 0:e.id)}))}))}catch(t){s({key:a,value:Mn(t)})}finally{n({key:a,value:!1})}},r=async t=>{const a=un.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:Mn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},l=async t=>{const a=un.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:Mn(e)})}finally{n({key:a,value:!1})}},c=async()=>{const t=un.GET_GROUP_CONFIGURATION;n({key:t,value:!0});try{const t=await e.groups.getGroupConfiguration();i({groupsConfiguration:t})}catch(e){s({key:t,value:Mn(e)})}finally{n({key:t,value:!1})}};return{setUsersGroupsLoader:n,setUsersGroupsError:s,setGroupsState:i,resetUsersGroupsState:()=>{t.auth.groupsState=za(zs)},loadGroups:o,getGroupById:async t=>{const a=un.GET_GROUP;n({key:a,value:!0});try{const a=await e.groups.getGroupById({groupId:t.groupId},{_groupsRelations:dn.rolesAndUsers});i({selectedGroup:a})}catch(t){s({key:a,value:Mn(t)})}finally{n({key:a,value:!1})}},createGroup:async t=>{const a=un.CREATE_GROUP,{roleIds:i,userIds:c}=t,u=f(t,qs);n({key:a,value:!0});try{var d;const a=await e.groups.createGroup(v({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 p;s({key:a,value:Mn(e)}),null==t||null==(p=t.callback)||p.call(t,!1)}finally{n({key:a,value:!1})}},updateGroup:async t=>{const a=un.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:Mn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},deleteGroup:async t=>{const a=un.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:Mn(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=un.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:Mn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},addUsersToGroup:l,deleteUsersFromGroup:async t=>{const a=un.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:Mn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},getGroupConfiguration:c,updateGroupConfiguration:async t=>{const a=un.UPDATE_GROUP_CONFIGURATION;n({key:a,value:!0});try{await e.groups.updateGroupConfiguration(t),await c()}catch(t){s({key:a,value:Mn(t)})}finally{n({key:a,value:!1})}},getTeamUsers:async t=>{const a=un.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:Mn(t)})}finally{n({key:a,value:!1})}}}},Ys={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}},Qs=t=>Rn(Ys,t),Xs=(t,e,a)=>({setGroupsDialogsState:e=>{Object.assign(t.auth.groupsDialogsState,e)},resetGroupsDialogsState:()=>{t.auth.groupsDialogsState=za(Ys)},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,v({},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,v({},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})}}),Zs={step:pn.impersonating,loading:!1},ti=t=>Rn(Zs,t),ei=["callback","events"],ai=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.impersonateState,e)},i=()=>{t.auth.impersonateState=za(Zs)};return{setImpersonateState:s,resetImpersonateState:i,impersonate:async t=>{const{callback:a}=t,o=f(t,ei);s({loading:!0});try{await e.impersonate.impersonate(o),s({step:pn.success}),await Ka(1e3),await n.afterAuthNavigation({preventRedirectUrlOriginCleaning:!0}),i(),null==a||a(!0)}catch(t){s({loading:!1,error:Mn(t)})}}}},ni={flow:hn.Login,step:gn.preLogin,loading:!1,email:"",tenants:[]},si=t=>Rn(ni,t),ii=(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(ds);t&&!qn(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;if(e)return Qn(e);const{authenticatedUrl:r,loginUrl:l,logoutUrl:c,socialLoginCallbackUrl:u,activateUrl:d}=n;let p=window.localStorage.getItem(ds);p&&![l,c,u,d].includes(p)||(p=r);const g=Jn({authenticatedUrl:p,includeQueryParam:s,enforceRedirectToSameSite:i,allowedRedirectOrigins:o});return a?g:(h=g).startsWith(null==(y=window)?void 0:y.location.origin)?h.replace(null==(S=window)?void 0:S.location.origin,""):h;var h,y,S}({customLoginAuthenticatedUrl:n,preventRedirectUrlOriginCleaning:o})),null==(c=window)||c.localStorage.removeItem(ds)}await Ka(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(cs),c=t.auth.user;var u;if(l&&(null==(u=window)||u.localStorage.removeItem(cs)),r&&l&&!gs(c))return s(n.resetLoginState,{forceStepUpUrl:r});let d=o;var p;return o||(await n.loadCustomLoginRoutes(),d=null==(p=t.auth.routes)?void 0:p.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(v({user:e,tenantsState:v({},o,{tenants:a,activeTenant:s,loading:!1})},i))}}},oi={step:vn.verify,loading:!1,saving:!1},ri=t=>Rn(oi,t),li=["callback"],ci=["callback"],ui=["callback"],di=["callback","deviceId"],pi=["callback","deviceId"],gi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",hi=new Uint8Array(256);for(let t=0;t<64;t++)hi[gi.charCodeAt(t)]=t;const yi=t=>{const e=new Uint8Array(t),a=e.length;let n,s="";for(n=0;n<a;n+=3)s+=gi[e[n]>>2],s+=gi[(3&e[n])<<4|e[n+1]>>4],s+=gi[(15&e[n+1])<<2|e[n+2]>>6],s+=gi[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},Si=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=hi[t.charCodeAt(n)],i=hi[t.charCodeAt(n+1)],o=hi[t.charCodeAt(n+2)],r=hi[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 vi(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 fi=t=>{if(t instanceof Array){const e=[];for(const a of t)e.push(fi(a));return e}if(t instanceof ArrayBuffer)return yi(t);if(t instanceof Object){const e={};for(const a in t)e[a]=fi(t[a]);return e}return t},mi=t=>new Promise(((e,a)=>{const n=new FileReader;n.readAsText(t),n.onload=()=>e(n.result),n.onerror=a})),bi=["callback","deviceId"],Ai=["callback","deviceId"],wi="input is invalid type",Ti="undefined"!=typeof ArrayBuffer,Ei="0123456789abcdef".split(""),Ii=[-2147483648,8388608,32768,128],Oi=[24,16,8,0],Pi=[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],ki=["hex","array","digest","arrayBuffer"],_i=[];Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Ti&&!ArrayBuffer.isView&&(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});const Ui=function(t){return function(e){const a=new Ri(!0).update(e);return null==a?void 0:a[t]()}},Li=function(t){return function(e,a){const n=new Di(e,!0).update(a);return null==n?void 0:n[t]()}};class Ri{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=()=>Ri.prototype.digest(),t?(_i[0]=_i[16]=_i[1]=_i[2]=_i[3]=_i[4]=_i[5]=_i[6]=_i[7]=_i[8]=_i[9]=_i[10]=_i[11]=_i[12]=_i[13]=_i[14]=_i[15]=0,this.blocks=_i):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(wi);if(null===t)throw new Error(wi);if(Ti&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||Ti&&ArrayBuffer.isView(t)))throw new Error(wi);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]<<Oi[3&s++];else for(s=this.start;i<o&&s<64;++i)n=t.charCodeAt(i),n<128?r[s>>2]|=n<<Oi[3&s++]:n<2048?(r[s>>2]|=(192|n>>6)<<Oi[3&s++],r[s>>2]|=(128|63&n)<<Oi[3&s++]):n<55296||n>=57344?(r[s>>2]|=(224|n>>12)<<Oi[3&s++],r[s>>2]|=(128|n>>6&63)<<Oi[3&s++],r[s>>2]|=(128|63&n)<<Oi[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++i)),r[s>>2]|=(240|n>>18)<<Oi[3&s++],r[s>>2]|=(128|n>>12&63)<<Oi[3&s++],r[s>>2]|=(128|n>>6&63)<<Oi[3&s++],r[s>>2]|=(128|63&n)<<Oi[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]|=Ii[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,p=this.h1,g=this.h2,h=this.h3,y=this.h4,S=this.h5,v=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=p&g,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&p,n=r^d&g^u,o=y&S^~y&v,s=f+a+o+Pi[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&p^r,o=f&y^~f&S,s=v+a+o+Pi[t+1]+m[t+1],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),c=g&h,n=c^g&d^l,o=v&f^~v&y,s=S+a+o+Pi[t+2]+m[t+2],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),u=p&g,n=u^p&h^c,o=S&v^~S&f,s=y+a+o+Pi[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+p|0,this.h2=this.h2+g|0,this.h3=this.h3+h|0,this.h4=this.h4+y|0,this.h5=this.h5+S|0,this.h6=this.h6+v|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=Ei[t>>28&15]+Ei[t>>24&15]+Ei[t>>20&15]+Ei[t>>16&15]+Ei[t>>12&15]+Ei[t>>8&15]+Ei[t>>4&15]+Ei[15&t]+Ei[e>>28&15]+Ei[e>>24&15]+Ei[e>>20&15]+Ei[e>>16&15]+Ei[e>>12&15]+Ei[e>>8&15]+Ei[e>>4&15]+Ei[15&e]+Ei[a>>28&15]+Ei[a>>24&15]+Ei[a>>20&15]+Ei[a>>16&15]+Ei[a>>12&15]+Ei[a>>8&15]+Ei[a>>4&15]+Ei[15&a]+Ei[n>>28&15]+Ei[n>>24&15]+Ei[n>>20&15]+Ei[n>>16&15]+Ei[n>>12&15]+Ei[n>>8&15]+Ei[n>>4&15]+Ei[15&n]+Ei[s>>28&15]+Ei[s>>24&15]+Ei[s>>20&15]+Ei[s>>16&15]+Ei[s>>12&15]+Ei[s>>8&15]+Ei[s>>4&15]+Ei[15&s]+Ei[i>>28&15]+Ei[i>>24&15]+Ei[i>>20&15]+Ei[i>>16&15]+Ei[i>>12&15]+Ei[i>>8&15]+Ei[i>>4&15]+Ei[15&i]+Ei[o>>28&15]+Ei[o>>24&15]+Ei[o>>20&15]+Ei[o>>16&15]+Ei[o>>12&15]+Ei[o>>8&15]+Ei[o>>4&15]+Ei[15&o];return l+=Ei[r>>28&15]+Ei[r>>24&15]+Ei[r>>20&15]+Ei[r>>16&15]+Ei[r>>12&15]+Ei[r>>8&15]+Ei[r>>4&15]+Ei[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 Di extends Ri{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(wi);if(null===t)throw new Error(wi);if(Ti&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||Ti&&ArrayBuffer.isView(t)))throw new Error(wi)}var s;t.length>64&&(t=null==(s=new Ri(!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}Ri.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();Ri.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),Ri.prototype.finalize.call(this)}}}const Ci=function(){const t=Ui("hex");t.create=function(){return new Ri},t.update=function(e){return t.create().update(e)};for(let e=0;e<ki.length;++e){const a=ki[e];t[a]=Ui(a)}return t}();async function Ni(t){const e=Ci.digest((new TextEncoder).encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function Mi(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 Fi(t){var e,a;return null!=(e=window.crypto)&&null!=(a=e.subtle)&&a.digest?Mi(t):(console.warn("Generating CodeChallenge in non-secure domain:",window.location.origin),Ni(t))}function xi(t=16){let e="";for(let a=0;a<t;a++)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return e}!function(){const t=Li("hex");t.create=function(t){return new Di(t)},t.update=function(e,a){return t.create(e).update(a)};for(let e=0;e<ki.length;++e){const a=ki[e];t[a]=Li(a)}}();const $i=["callback"],Gi=["callback"],ji=["callback"],Vi=["callback"],Bi=["callback"],Wi=["callback","events"],Hi=["callback"],zi=["callback"],Ki=["user"],qi=["callback"],Ji=["callback"],Yi=["callback"],Qi=["callback"],Xi=["callback"],Zi=["callback"],to=(t,e,a)=>{const n=a,s=L.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(v({},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:p}=await e.auth.refreshTokenV3();if(fs(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:p},{loginState:v({},o,{quickLoginToRegister:t,flow:e?hn.RegisterQuickLogin:hn.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 ln(n,null==e?void 0:e.entitlements)?v({},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];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()=>{try{const{isActive:t}=await e.auth.getSSOPublicConfiguration();n.setAuthState({isSSOAuth:t})}catch(t){n.setAuthState({isSSOAuth:!1})}},u=async()=>{let t;try{var a;const n=await e.metadata.getSamlMetadata();t=null==n||null==(a=n.configuration)?void 0:a.acsUrl}catch(t){console.error(t)}n.setAuthState({ssoACS:t})},d=e=>{Object.assign(t.auth.loginState,e)},p=async e=>{let{callback:a}=e,s=f(e,$i);const i=t.auth.securityPolicyState.publicPolicy.policy;if(null==i||!i.authStrategy)return n.setLoginState({step:gn.loginWithPassword,loading:!1}),void(null==a||a());(null==i?void 0:i.authStrategy)===N.EmailAndPassword?(n.setLoginState({step:gn.loginWithPassword,loading:!1}),null==a||a()):[N.MagicLink,N.Code,N.SmsCode].includes(null==i?void 0:i.authStrategy)?await n.passwordlessPreLogin(v({},s,{type:null==i?void 0:i.authStrategy,callback:a})):(n.setLoginState({step:gn.loginWithPassword,loading:!1}),null==a||a())},g=async t=>{const{user:e,tenants:a=[],activeTenant:s}=t,i={step:vn.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 v({setLoginState:d,resetLoginState:()=>{t.auth.loginState=za(ni)},requestAuthorize:async t=>{const e=[],a=[];e.push(o()),t&&(n.setAuthState({isLoading:!0}),e.push(n.loadSocialLoginsConfigurationV2()),e.push(n.loadAllowSignUps()),e.push(n.loadPublicAuthStrategiesPolicy()),e.push(c()),e.push(n.loadVendorPublicInfo()),e.push(u()),a.push(n.loadCustomLoginRoutes())),await Promise.all(e),a.length>0&&await Promise.all(a),n.setAuthState({isLoading:!1})},requestAuthorizeSSR:async e=>{const a=[];a.push(n.loadSocialLoginsConfigurationV2()),a.push(n.loadAllowSignUps()),a.push(c()),a.push(n.loadVendorPublicInfo()),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(fs(a,t.root.appName)){const t=await n.getMfaRequiredState(a);n.setAuthState(t),s(i.loginUrl,{preserveQueryParams:!0})}})(e)),a.push(n.loadCustomLoginRoutes()),await Promise.all(a)},preLogin:async a=>{const{email:n,recaptchaToken:s,invitationToken:i,callback:o}=a;d({loading:!0});try{const a=t.auth.onRedirectTo,r=Xn(Zn),l=await e.auth.preLoginV2({email:n,tenantId:r}),{address:c,idpType:u}=null!=l?l:{};if(c){let e=c;if(u===En.Oidc&&!e.includes("redirect_uri")){const{oidcRedirectUrl:a}=t.auth.routes;e+=`&redirect_uri=${window.location.origin}${a}`}S.isLoginWithSSOAvailable()?(S.loginWithSSO(n),d({loading:!1}),null==o||o()):(d({step:gn.redirectToSSO,loading:!1,ssoRedirectUrl:e}),setTimeout((()=>{a(e,{refresh:!0})}),2e3))}else await p({email:n,recaptchaToken:s,callback:o,invitationToken:i})}catch(t){await p({email:n,recaptchaToken:s,callback:o,invitationToken:i})}},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:gn.loginWithSSOFailed,loading:!1})}},login:async a=>{const{email:i,password:o,recaptchaToken:r,invitationToken:l,callback:c}=a;d({loading:!0});try{const{user:a,tenants:s=[],activeTenant:u}=await e.auth.loginv2({email:i,password:o,recaptchaToken:r,invitationToken:l}),{onRedirectTo:p,routes:g}=t.auth;if(fs(a,t.root.appName)){const t=await n.getMfaRequiredState(a);n.setAuthState(t),p(g.loginUrl,{preserveQueryParams:!0})}else{const e=t.auth.loginState,o=!!a.accessToken;a.id&&localStorage.setItem("userId",a.id),n.afterAuthenticationStateUpdate({user:a,tenants:s,activeTenant:u},{loginState:{flow:e.flow,quickLoginToRegister:e.quickLoginToRegister,email:i,loading:!1,error:void 0,mfaToken:a.mfaToken,step:e.flow===hn.Login?gn.success:e.step,tenants:s,tenantsLoading:!0,isBreachedPassword:a.isBreachedPassword},isAuthenticated:o});const[r]=await n.getFeatureFlags(["security-center-show-login-flows"]);e.flow===hn.Login&&(r&&a.isBreachedPassword&&!o?d({step:gn.breachedPassword,loading:!1}):o&&(await n.__shouldShowPromptPasskeys()?(d({step:gn.promptPasskeys,loading:!1}),p(g.loginUrl,{preserveQueryParams:!0})):await n.afterAuthNavigation()))}localStorage.removeItem("register-quick-login"),null==c||c(!0)}catch(t){s.setAccessToken(null),s.setUser(null),null==c||c(!1,t),d({email:i,error:Mn(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()&&se(),n.resetAuthState(),await n.requestAuthorize(!0),null==a||a()},silentLogout:async t=>{var a;try{await e.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&se(),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:gn.preLogin}),n.setAuthState({user:void 0,isAuthenticated:!1}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;d({error:Mn(e),loading:!1}),null==(s=t.callback)||s.call(t,!1,e)}},quickSmsPasswordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,Gi);try{d({loading:!0});const t=await e.auth.passwordlessPreLogin(v({},n,{type:N.SmsCode}));d({step:gn.loginWithQuickSmsOtc,loading:!1,phoneNumber:null==t?void 0:t.phoneNumber,error:void 0}),null==a||a(!0)}catch(t){d({error:Mn(t),loading:!1}),null==a||a(!1,t)}},changePhoneNumberWithVerification:async t=>{const{callback:a}=t,n=f(t,ji);try{d({loading:!0});const t=await e.auth.changePhoneNumberWithVerification(n);d({phoneNumber:n.phoneNumber,loading:!1,changePhoneId:t.changePhoneId,step:gn.loginWithQuickSmsOtc,error:void 0}),null==a||a(!0)}catch(t){d({error:Mn(t),loading:!1})}},verifyChangePhoneNumber:async t=>{const{callback:a}=t,n=f(t,Vi);try{d({loading:!0}),await e.auth.verifyChangePhoneNumber(n),d({loading:!1}),null==a||a(!0)}catch(t){d({error:Mn(t),loading:!1})}},passwordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,Bi);try{let t;d({loading:!0}),ss(n)&&(t=n.email);const s=await e.auth.passwordlessPreLogin(n),i=zn[n.type];d({step:i,loading:!1,phoneNumber:null==s?void 0:s.phoneNumber,email:t,error:void 0}),null==a||a()}catch(t){d({error:Mn(t),loading:!1}),null==a||a(null,t)}},passwordlessPostLogin:async a=>{const{callback:s,events:i}=a,o=f(a,Wi);try{d({loading:!0});const{user:a,tenants:l=[],activeTenant:c}=await e.auth.passwordlessPostLoginV2(o),{routes:u,onRedirectTo:p}=t.auth;if(fs(a,t.root.appName)){const t=await n.getMfaRequiredState(a);n.setAuthState(t),p(u.loginUrl,{preserveQueryParams:!0})}else{const e=t.auth.loginState;if(a.emailVerified){var r;const t={email:a.email,origin:On.PASSWORDLESS,id:a.id,tenantId:a.tenantId,createdAt:new Date,name:a.name};null==i||null==(r=i.userVerified)||r.call(i,t),Hn(Wn.USER_VERIFIED,t)}a.id&&localStorage.setItem("userId",a.id),n.afterAuthenticationStateUpdate({user:a,tenants:l,activeTenant:c}),d({error:void 0}),n.setAuthState({isLoading:!1}),e.flow===hn.Login?await n.__shouldShowPromptPasskeys()?(n.setLoginState({step:gn.promptPasskeys,loading:!1}),p(u.loginUrl,{preserveQueryParams:!0})):(n.setAuthState({isAuthenticated:!0}),await n.afterAuthNavigation()):p(u.loginUrl,{preserveQueryParams:!0}),localStorage.removeItem("register-quick-login"),null==s||s(!0)}}catch(t){d({error:Mn(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:Mn(t,"We couldn't verify your invitation")})}finally{d({loading:!1})}},webAuthnPrelogin:async t=>{const{callback:a}=t,s=f(t,Hi);try{var i;n.setPasskeysState({loading:!0}),d({loading:!0});const{options:t}=await e.auth.webAuthnPreLogin(s);t.challenge=Si(t.challenge),t.allowCredentials=null==(i=t.allowCredentials)?void 0:i.map((t=>v({},t,{id:Si(t.id)}))),d({error:void 0}),null==a||a(t)}catch(t){d({error:Mn(t)}),null==a||a(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnPostLogin:async a=>{const{callback:s}=a,i=f(a,zi);try{var o;n.setPasskeysState({loading:!0}),d({loading:!0});const a=fi(i.publicKey),r=await e.auth.webAuthnPostLoginV2(v({},a,{response:v({},a.response,{userHandle:null!=(o=a.response.userHandle)?o:void 0}),recaptchaToken:i.recaptchaToken,invitationToken:i.invitationToken})),{user:l}=r,c=f(r,Ki);if(fs(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(v({user:l},c),{isAuthenticated:!0}),d({error:void 0}),await n.afterAuthNavigation(),null==s||s(!0)}catch(t){d({error:Mn(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=Si(t.user.id),t.challenge=Si(t.challenge),t.excludeCredentials=[],null==a||a(t)}catch(t){d({error:Mn(t)}),null==a||a(null)}finally{d({loading:!1})}},webAuthnVerifyNewDeviceSession:async t=>{const{callback:a}=t,n=f(t,qi);try{d({loading:!0});const t=fi(n.publicKey),s="platform"===(null==t?void 0:t.authenticatorAttachment)?Bt.Platform:Bt.CrossPlatform;await e.auth.verifyNewDeviceSession({id:t.id,response:t.response,deviceType:s}),null==a||a(!0)}catch(t){d({error:Mn(t)}),null==a||a(null)}finally{d({loading:!1})}},getUserIP:async t=>{const{callback:a}=t;try{const{ip:t}=await e.metadata.getCurrentUserIpMetadata();n.setAuthState({userIp:t}),null==a||a(!0)}catch(t){null==a||a(!1)}},preEnrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,Ji);d({loading:!0});try{var s;const t=await e.auth.preEnrollMFAWebAuthnForLogin(n),i=v({},t.options,{challenge:Si(t.options.challenge),user:v({},t.options.user,{id:Si(t.options.user.id)}),excludeCredentials:null==(s=t.options.excludeCredentials)?void 0:s.map((t=>v({},t,{id:Si(t.id)})))});d({loading:!1}),null==a||a({options:i,webauthnToken:t.webauthnToken})}catch(t){d({loading:!1,error:Mn(t)}),null==a||a(null)}},enrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,Yi);d({loading:!0});try{const t=fi(n.publicKey),s=await e.auth.enrollMFAWebAuthnForLoginV2(v({},n,{options:t}));await g(s),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Mn(t)}),null==a||a(null)}},enrollMFAAuthenticatorAppForLogin:async t=>{const{callback:a}=t,n=f(t,Qi);d({loading:!0});try{const t=await e.auth.enrollMFAAuthenticatorAppForLoginV2(n);await g(t),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Mn(t)}),null==a||a(null)}},preEnrollMFASMSForLogin:async t=>{const{callback:a}=t,s=f(t,Xi);d({loading:!0});try{const t=await e.auth.preEnrollMFASMSForLogin(s);n.setMfaState({otcToken:t.otcToken,step:vn.smsVerifyCode,phoneNumber:t.phoneNumber}),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Mn(t)}),null==a||a(null)}},enrollMFASMSForLogin:async t=>{const{callback:a}=t,n=f(t,Zi);d({loading:!0});try{const t=await e.auth.enrollMFASMSForLoginV2(n);await g(t),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Mn(t)}),null==a||a(null)}},handleEnrollMFAResponse:g,resetBreachedPassword:async t=>{d({loading:!0});try{await e.auth.forgotPassword(t),d({loading:!1,error:void 0,step:gn.breachedPasswordSuccess}),n.setAuthState({isAuthenticated:!1})}catch(t){d({loading:!1,error:Mn(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(v({},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:p}=await e.auth.refreshTokenV3();if(fs(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:gn.promptPasskeys,loading:!1}),n.afterAuthenticationStateUpdate({user:t,tenants:d,activeTenant:p},{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:p},{loginState:v({},o,{quickLoginToRegister:e,flow:s?hn.RegisterQuickLogin:hn.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(bs(l)===i.hostedLoginRedirectUrl)return void console.debug("Calling loginWithRedirect while in hostedLoginCallback route");n.setAuthState({isLoading:!0});const c=xi(),u=xi(),d=await Fi(u);localStorage.setItem(ps,u);const p=is(t);let g=`${window.location.origin}${"path"===l?"":"#"}${null!=p?p:""}${i.hostedLoginRedirectUrl}`;await n.loadCustomLoginRoutes();const h=null==(s=t.auth.customLoginState)?void 0:s.customLoginSearchParams;h&&(g.endsWith("/")&&(g=g.slice(0,-1)),g+=h);const y=`${e.fetch.getBaseUrl(r,"/oauth/authorize")}/oauth/authorize`,S=v({response_type:"code",client_id:r.clientId||"INVALID-CLIENT-ID",scope:"openid email profile",redirect_uri:g,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&&(S.organization=t.tenant)}const m=Xn(Zn);m&&(S.tenantId=m),o(`${y}?${new URLSearchParams(S).toString()}`,{refresh:!0})};return{requestHostedLoginAuthorize:async e=>{var a;null==(a=localStorage)||a.removeItem(cs);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(cs),l){const e=t.root.urlStrategy,a=bs(e);if(n.setAuthState({isLoading:!0}),ns(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(ps)||"INVALID-CODE-VERIFIER",o=t.auth.routes,r=t.root.urlStrategy,l=is(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(cs);window.localStorage.removeItem(cs),a&&gs(e)?await n.afterStepUpAuthNavigation():await n.afterAuthNavigation()}}}})(t,e,a),ii(t,0,a),function(t,e,a){const n=a,s=async e=>{const a=t.root.appName;return Yt.getFeatureFlags(e,a)},i=async()=>await n.afterStepUpAuthNavigation(),o=async e=>{const a=t.auth.loginState,i=t.auth.mfaState.step,[o]=await s(["security-center-show-login-flows"]);if(a.flow===hn.Login)if(o&&a.isBreachedPassword&&!e)n.setLoginState({step:gn.breachedPassword,loading:!1});else{const t=await n.__shouldShowPromptPasskeys();i===vn.smsVerifyCode&&t?n.setLoginState({step:gn.promptPasskeys,loading:!1}):await n.afterAuthNavigation()}};return{postHandleVerifyMFAResponseForStepUp:i,postHandleVerifyMFAResponseForLogin:o,handleVerifyMFAResponse:async(t,e=!1)=>{const{user:a,tenants:s,activeTenant:r}=t;n.setUser(a),n.setTenantsState({tenants:s,activeTenant:r,loading:!1}),a.id&&localStorage.setItem("userId",a.id);const l=!!a.accessToken;return n.setAuthState({isAuthenticated:l}),e?await i():await o(l)},getFeatureFlags:s}}(t,0,a),((t,e)=>({getMfaRequiredState:async a=>{let n=gn.loginWithTwoFactor;const s=za(oi),i=t.auth.loginState,{isAllowedToRemember:o,mfaDeviceExpiration:r}=await e.auth.checkIfAllowToRememberMfaDevice(a.mfaToken);!a.hasOwnProperty("mfaEnrolled")||a.mfaEnrolled?Object.assign(s,{mfaDevices:a.mfaDevices,step:es(a.mfaDevices)}):(Object.assign(s,{step:as(a.mfaStrategies),qrCode:a.qrCode,recoveryCode:a.recoveryCode,loading:!1,mfaToken:a.mfaToken,mfaStrategies:a.mfaStrategies}),n=gn.forceTwoFactor);let l={};const c=localStorage.getItem("register-quick-login");return c&&(l={quickLoginToRegister:c,flow:hn.RegisterQuickLogin}),{user:void 0,isAuthenticated:!1,mfaState:s,loginState:v({},i,l,{mfaToken:a.mfaToken,mfaRequired:a.mfaRequired,loading:!1,error:void 0,step:n,tenantsLoading:!0,email:a.userEmail,tenants:[],allowRememberMfaDevice:o,mfaDeviceExpiration:r,isBreachedPassword:a.isBreachedPassword})}}}))(t,e),((t,e,a)=>{const n=a,s=async(a,s,i)=>{let{callback:o}=a,r=f(a,li);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===hn.Login?gn.success:s.step;i={loginState:{flow:s.flow,quickLoginToRegister:s.quickLoginToRegister,loading:!1,step:t,error:void 0,tenants:e}}}return v({},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){const s=t.auth.loginState;if(s.flow!==hn.Login)return;const[i]=await n.getFeatureFlags(["security-center-show-login-flows"]);i&&s.isBreachedPassword&&!e?n.setLoginState({step:gn.breachedPassword,loading:!1}):await n.__shouldShowPromptPasskeys()?n.setLoginState({step:gn.promptPasskeys,loading:!1}):await n.afterAuthNavigation(),null==a||a(!0)}(u,o)}catch(t){s({loading:!1,error:Mn(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,ci);(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:vn.emailVerifyCode}),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({error:Mn(t)}),null==i||i(null)}},i=async(t,a)=>{var s;let{callback:i}=t,o=f(t,ui);(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:Mn(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,di);a({loading:!1,error:void 0});try{const t=await e.auth.preVerifyMFASMSForLogin(i,o);n.setMfaState({otcToken:t.otcToken,step:vn.smsVerifyCode,phoneNumber:t.phoneNumber}),a({loading:!1,error:void 0}),null==s||s(!0)}catch(t){a({loading:!1,error:Mn(t)}),null==s||s(null)}},i=async(t,a,s=!1)=>{let{callback:i,deviceId:o}=t,r=f(t,pi);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:Mn(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,bi);a({loading:!0});try{var o;const t=await e.auth.preVerifyMFAWebAuthnForLogin(s,i),r=v({},t.options,{challenge:Si(t.options.challenge),allowCredentials:null==(o=t.options.allowCredentials)?void 0:o.map((t=>v({},t,{id:Si(t.id)})))});a({loading:!1,error:void 0}),null==n||n({options:r,webauthnToken:t.webauthnToken})}catch(t){a({loading:!1,error:Mn(t)}),null==n||n(null)}},i=async(t,a,s)=>{let{callback:i,deviceId:o}=t,r=f(t,Ai);a({loading:!0});try{const t=fi(r.publicKey),l=await e.auth.verifyMFAWebAuthnForLoginV2(o,v({},r,{options:t}));await n.handleVerifyMFAResponse(l,s),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Mn(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))},eo=["callback"],ao=["callback"],no=["user"],so=["deviceId"],io=["deviceId"],oo=["callback"],ro=["callback"],lo=["deviceId","callback"],co=(t,e,a)=>{const n=a;async function s(e){const a=t.auth.mfaState.step;return{step:e.recoveryCode?vn.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:()=>{t.auth.mfaState=za(oi)},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:Mn(t)})}},getMFAStrategies:async()=>{i({loading:!0});try{const t=(await e.auth.getMFAStrategiesConfig()).strategies.filter((({isActive:t})=>t)).map((({strategy:t})=>t));i({loading:!1,error:void 0,mfaStrategies:t})}catch(t){i({loading:!1,error:Mn(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:Mn(t)})}},verifyMfa:async a=>{const{callback:o}=a,r=f(a,eo);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(v({},u,{mfaDevices:c})),n.setUser(v({},a,{mfaEnrolled:!0})),null==o||o(u.recoveryCode)}catch(t){i({saving:!1,error:Mn(t)}),null==o||o(null,t)}},verifyMfaAfterForce:async t=>{const{callback:a}=t,s=f(t,ao);i({loading:!0});try{const t=await e.auth.loginWithMfaV2(s),{user:o}=t,r=f(t,no),l={step:vn.recoveryCode,loading:!1,saving:!1,error:void 0};null!=o&&o.recoveryCode&&(l.recoveryCode=o.recoveryCode),i(l),await n.afterAuthenticationStateUpdate(v({user:o},r)),null==a||a(l.recoveryCode)}catch(t){i({loading:!1,error:Mn(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:Mn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},preDisableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,so);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:Mn(t)}),null==(o=n.callback)||o.call(n,!1,t)}},disableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,io);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:Mn(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:Mn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},enrollMfaSms:async t=>{const{callback:a}=t,n=f(t,oo);i({saving:!0});try{const t=await e.auth.enrollMFASMS(n),o=await e.auth.getMFADevices(),r=await s(t);i(v({},r,{mfaDevices:o})),null==a||a(r.recoveryCode)}catch(t){i({saving:!1,error:Mn(t)}),null==a||a(null,t)}},preEnrollMfaWebAuthn:async t=>{i({saving:!0});try{var a,n;const s=await e.auth.preEnrollMFAWebAuthn(),o=v({},s.options,{challenge:Si(s.options.challenge),user:v({},s.options.user,{id:Si(s.options.user.id)}),excludeCredentials:null==(a=s.options.excludeCredentials)?void 0:a.map((t=>v({},t,{id:Si(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:Mn(e)}),null==(s=t.callback)||s.call(t,null,e)}},enrollMfaWebAuthn:async t=>{const{callback:a}=t,n=f(t,ro);i({saving:!0});try{const t=fi(n.publicKey),o=await e.auth.enrollMFAWebAuthn(v({},n,{options:t})),r=await e.auth.getMFADevices(),l=await s(o);i(v({},l,{mfaDevices:r})),null==a||a(l.recoveryCode)}catch(t){i({saving:!1,error:Mn(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=v({},t.options,{challenge:Si(t.options.challenge),allowCredentials:null==(s=t.options.allowCredentials)?void 0:s.map((t=>v({},t,{id:Si(t.id)})))});i({saving:!1}),null==n||n({options:o,webauthnToken:t.webauthnToken})}catch(t){i({saving:!1,error:Mn(t)}),null==n||n(null,t)}},disableMfaWebAuthn:async t=>{const{deviceId:a,callback:n}=t,s=f(t,lo);i({saving:!0});try{const t=fi(s.publicKey);await e.auth.disableMFAWebAuthn(a,v({},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:Mn(t)}),null==n||n(!1,t)}},__getMfaStateAfterEnroll:s}},uo={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:Ct.DESC,_sortBy:Ca.name},usersPageOffset:0,accountSettings:{}}},po=t=>Rn(uo,t),go=({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 ho(t,e,a){var n,s,i;return t.tenantId===e?v({},t,{children:[...null!=(i=null==t?void 0:t.children)?i:[],...a].filter(((t,e,a)=>e===a.findIndex((e=>e.tenantId===t.tenantId))))}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>ho(t,e,a))))?n:[]})}function yo(t,e){var a;return v({},t,{children:null!=(a=t.children)&&a.length?t.children.filter((t=>t.tenantId!==e)).map((t=>yo(t,e))):[]})}const So=(t,e,a)=>{var n,s;return t.tenantId===e?v({},t,{subAccountAccessType:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>So(t,e,a))))?n:[]})},vo=(t,e,a)=>{var n,s;return t.tenantId===e?v({},t,{name:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>vo(t,e,a))))?n:[]})},fo=(t,e,a)=>{var n,s;return t?t.tenantId===e?v({},t,{isReseller:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>fo(t,e,a))))?n:[]}):{}},mo=(t,e,a)=>{const n=e=>{Object.assign(t.auth.allAccountsState,{loaders:v({},t.auth.allAccountsState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.allAccountsState,{errors:v({},t.auth.allAccountsState.errors,{[e.key]:e.value}),loaders:v({},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,p,g;const{jwt:h,_tenantId:y,_email:S}=t,f=fn.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==(p=m.selectedAccount)||null==(g=p.usersQueryParams)?void 0:g._limit)?u:10,w=v({_offset:b,_limit:A,_tenantId:y,_includeSubTenants:!1},!!S&&{_email:S});try{const{items:t,_metadata:{totalItems:a,totalPages:n}}=await e.users.getUsersV3(w,{jwt:h}),s={totalUsersItems:a,totalUsersPages:n,usersQueryParams:v({_offset:null!=b?b:0,_limit:null!=A?A:10},!!S&&{_email:S})};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 v({},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(v({users:r},s))}else o(v({users:[]},s))}catch(t){s({key:f,value:Mn(t)})}finally{n({key:f,value:!1})}};return{setAllAccountsLoader:n,setAllAccountsError:s,setAllAccountsState:i,setSelectedAccountState:o,resetAllAccountsState:()=>{t.auth.allAccountsState=za(uo)},clearSelectedAccount:()=>{t.auth.allAccountsState.selectedAccount=za(uo.selectedAccount)},loadAccounts:async t=>{const a=fn.GET_ACCOUNTS;n({key:a,value:!0});const{accountsQueryParams:l}=r(),{jwt:c,_limit:u,_offset:d}=t,p={_offset:null!=d?d:l._offset,_limit:null!=u?u:l._limit,_subTenantId:null==t?void 0:t._subTenantId};try{if(c){var g;const{selectedAccount:a}=r(),{items:n,_links:s}=await e.tenants.searchSubTenants(p,{jwt:c}),i=await e.tenants.getTenantsUsersCount({tenantIds:n.map((t=>t.tenantId))},{jwt:c}),l=go({items:n},i),u=ho(a.accounts?a.accounts:a,null!=(g=null==t?void 0:t._subTenantId)?g:"",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(p),o=await e.tenants.getTenantsUsersCount({tenantIds:n.map((t=>t.tenantId))}),l=go({items:n},o),c=ho(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:Mn(t)})}finally{n({key:a,value:!1})}},searchAccounts:async t=>{const{jwt:a}=t,o=fn.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:Mn(t)})}finally{n({key:o,value:!1})}},updateSubAccountAccessForUser:async t=>{const a=fn.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 p;await e.subTenants.updateSubAccountAccess(l,{allowAccess:c},{jwt:u}),o({users:null==i||null==(p=i.users)?void 0:p.map((t=>t.id===l?v({},t,{subAccountAccessAllowed:c}):t))}),null==d||d(!0)}catch(t){s({key:a,value:Mn(t)}),null==d||d(!1)}finally{n({key:a,value:!1})}},createSubAccount:async t=>{const a=fn.CREATE_SUB_ACCOUNT;n({key:a,value:!0});const{name:l,parentTenantId:c,tenantId:u,jwt:d,callback:p}=t;try{if(d){const{accounts:t,selectedAccount:a}=r(),n=await e.subTenants.createSubTenant({name:l,parentTenantId:c,tenantId:u},{jwt:d}),s=ho(t,null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]),p=ho(v({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:p})}else{const{accounts:t}=r(),a=await e.subTenants.createSubTenant({name:l,tenantId:u,parentTenantId:c}),n=ho(t,null!=c?c:"",[{name:a.name,tenantId:a.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:n})}null==p||p(!0)}catch(t){s({key:a,value:Mn(t)}),null==p||p(!1)}finally{n({key:a,value:!1})}},updateSubAccount:async t=>{},deleteSubAccount:async t=>{const a=fn.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=yo(a,c),s=yo(t.accounts,c);i({accounts:n}),o({accounts:s})}else{const{accounts:t}=r();await e.subTenants.deleteSubTenant(c);const a=yo(t,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Mn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountSettings:async t=>{const a=fn.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=vo(t.accounts,d,c);o({name:c,accounts:n});const s=vo(a,d,c);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenant({tenantId:d},{name:c});const a=vo(t,d,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Mn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountManagement:async r=>{const l=fn.UPDATE_SUB_ACCOUNT_MANAGEMENT;a.setAllAccountsLoader({key:l,value:!0});const{jwt:c,isReseller:u,callback:d,tenantId:p,shouldUpdateSelectedAccount:g}=r,h=!!c;try{if(g){const{selectedAccount:a,accounts:n}=t.auth.allAccountsState;await e.subTenants.updateSubTenantManagement({tenantId:p},{isReseller:u},c?{jwt:c}:void 0);const s=fo(a.accounts,p,null!=u&&u);o({accounts:s}),h||o({isReseller:u});const r=fo(n,p,null!=u&&u);i({accounts:r})}else{const{accounts:a}=t.auth.allAccountsState;e.subTenants.updateSubTenantManagement({tenantId:p},{isReseller:u},c?{jwt:c}:void 0);const n=fo(a,p,null!=u&&u);i({accounts:n})}null==d||d(!0)}catch(t){s({key:l,value:Mn(t)}),null==d||d(!1)}finally{n({key:l,value:!1})}},updateSubAccountHierarchySettings:async t=>{const a=fn.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=So(t.accounts,u,d);o({subAccountAccessType:d,accounts:n});const s=So(a,u,d);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d});const a=So(t,u,d);i({accounts:a})}null==c||c(!0)}catch(t){s({key:a,value:Mn(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=fn.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:Mn(t)}),null==r||r(!1)}finally{n({key:d,value:!1})}},getAccountUsers:l,deleteUsersFromAccount:async t=>{const a=fn.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:Mn(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=fn.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:Mn(t)}),null==c||c(!1)}finally{n({key:u,value:!1})}},getUserJwtForSubAccount:async t=>{const{tenantId:a,callback:i}=t,r=fn.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:Mn(t)}),o({accessPermission:!1}),null==i||i(!1)}finally{n({key:r,value:!1})}},setRootAccountData:async()=>{const a=fn.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:v({},l,a)})}catch(t){s({key:a,value:Mn(t)})}finally{n({key:a,value:!1})}},setSelectedSubAccountData:async t=>{const{jwt:a}=t,i=fn.SET_SELECTED_SUB_ACCOUNT_DATA;try{var r,c,u,d,p,g,h;n({key:i,value:!0});const t=await e.accountSettings.getSettings({jwt:a}),[s,y,S]=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=S[0])?void 0:d.totalSubTenants,accountSettings:t,accounts:{name:t.name,tenantId:null!=(p=t.tenantId)?p:"",numberOfUsers:null==(g=s[0])?void 0:g.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:Mn(t)})}finally{n({key:i,value:!1})}},loadNumberOfUsersForSelectedSubAccount:async t=>{const{tenantId:a,jwt:i}=t,r=fn.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:Mn(t)})}finally{n({key:r,value:!1})}}}},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:Ta.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:[]}},Ao=t=>Rn(bo,t),wo=(t,e,a)=>{const n=za(bo);return{setAllAccountDialogsState:e=>{Object.assign(t.auth.allAccountsDialogsState,e)},resetAllAccountDialogsState:()=>{t.auth.allAccountsDialogsState=za(bo)},openCreateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.createSubAccountDialog,v({},e,{open:!0}))},closeCreateSubAccountDialog:()=>{t.auth.allAccountsDialogsState.createSubAccountDialog=n.createSubAccountDialog},openUpdateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountDialog,v({},e,{open:!0}))},closeUpdateSubAccountDialog:()=>{t.auth.allAccountsDialogsState.updateSubAccountDialog=n.updateSubAccountDialog},openEnableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.enableSubAccountManagementDialog,v({},e,{open:!0}))},closeEnableSubAccountManagementDialog:()=>{t.auth.allAccountsDialogsState.enableSubAccountManagementDialog=n.enableSubAccountManagementDialog},openUpdateSubAccountHierarchySettingsDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountHierarchySettingsDialog,v({},e,{open:!0}))},closeUpdateSubAccountHierarchySettingsDialog:()=>{t.auth.allAccountsDialogsState.updateSubAccountHierarchySettingsDialog=n.updateSubAccountHierarchySettingsDialog},openDisableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.disableSubAccountManagementDialog,v({},e,{open:!0}))},closeDisableSubAccountManagementDialog:()=>{t.auth.allAccountsDialogsState.disableSubAccountManagementDialog=n.disableSubAccountManagementDialog},openDeleteSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteSubAccountDialog,v({},e,{open:!0}))},closeDeleteSubAccountDialog:()=>{t.auth.allAccountsDialogsState.deleteSubAccountDialog=n.deleteSubAccountDialog},openAddUsersToAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.addUsersToAccountDialog,v({},e,{open:!0}))},closeAddUsersToAccountDialog:()=>{t.auth.allAccountsDialogsState.addUsersToAccountDialog=n.addUsersToAccountDialog},openDeleteUserFromAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteUserFromAccountDialog,v({},e,{open:!0}))},closeDeleteUserFromAccountDialog:()=>{t.auth.allAccountsDialogsState.deleteUserFromAccountDialog=n.deleteUserFromAccountDialog},openEditUserRolesDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.editUserRolesDialog,v({},e,{open:!0}))},closeEditUserRolesDialog:()=>{t.auth.allAccountsDialogsState.editUserRolesDialog=n.editUserRolesDialog}}},To={devices:[],loading:!1,error:null},Eo=t=>Rn(To,t),Io=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.passkeysState,e)};return{setPasskeysState:s,resetPasskeysState:()=>{t.auth.passkeysState=za(To)},loadWebAuthnDevices:async()=>{s({loading:!0});try{const{devices:t}=await e.auth.getWebAuthnDevices();s({devices:t,loading:!1})}catch(t){s({loading:!1,error:Mn(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:Mn(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===Vt.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)}}}},Oo={loading:!1,error:null},Po=t=>Rn(Oo,t),ko=["callback","profilePictureUrl"],_o=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.profileState,e)};return{setProfileState:s,resetProfileState:()=>{t.auth.profileState=za(Oo)},loadProfile:async()=>{s({loading:!0});try{const a=await qa(e.teams.getProfile,3,2e3),i=t.auth.user;n.setUser(v({},i,a)),s({profile:a,loading:!1})}catch(t){s({loading:!1,error:Mn(t)})}},saveProfile:async a=>{const{callback:i,profilePictureUrl:o}=a,r=f(a,ko);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=vi(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=v({},a,r,{profilePictureUrl:s}),u=await e.users.updateUserProfileV2(c),d=t.auth.user;n.setUser(v({},d,u)),n.setProfileState({profile:u,saving:!1,loading:!1}),null==i||i(c)}catch(t){s({saving:!1,error:Mn(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:Mn(e)}),null==(n=t.callback)||n.call(t,null,e)}}}},Uo={loading:!1},Lo=t=>Rn(Uo,t),Ro=["callback"],Do=["id"],Co=(t,e,a)=>{const n=e=>{Object.assign(t.auth.provisioningState,e)},s=async t=>{const{count:a}=await e.directory.countConfigurationUsers(t.id);return v({},t,{count:a})};return{setProvisioningState:n,resetProvisioningState:()=>{t.auth.provisioningState=za(Uo)},__loadCountForConnection:s,loadProvisionConnections:async()=>{n({loading:!0,error:null});try{const t=await e.directory.getConfigs(),a=await Promise.all(t.map((t=>s(t))));n({connections:a,loading:!1})}catch(t){n({error:Mn(t),loading:!1})}},createProvisionConnection:async t=>{const{callback:a}=t,i=f(t,Ro);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:Mn(t),loading:!1})}},deleteProvisionConnection:async t=>{const{id:a,callback:i}=t;n({loading:!0,error:null});try{await e.directory.deleteConfiguration(a);const t=await e.directory.getConfigs(),o=await Promise.all(t.map((t=>s(t))));n({connections:o,loading:!1}),null==i||i(!0)}catch(t){n({error:Mn(t),loading:!1}),null==i||i(!1,t)}},updateProvisionConnection:async t=>{const{id:a}=t,i=f(t,Do);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:Mn(t),loading:!1})}}}},No={step:mn.ResetPhoneNumber,loading:!1},Mo=t=>Rn(No,t),Fo=["callback"],xo=["callback"],$o=["callback"],Go=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.resetPhoneNumberState,e)};return{setResetPhoneNumberState:s,resetResetPhoneNumberState:()=>{t.auth.resetPhoneNumberState=za(No)},resetPhoneNumber:async t=>{const{callback:a}=t,i=f(t,Fo);s({loading:!0});try{const t=await e.auth.resetPhoneNumber(i);s({loading:!1,error:void 0,resetPhoneNumberToken:t.resetPhoneNumberToken,step:mn.VerifyResetPhoneNumber}),n.setLoginState({email:i.email})}catch(t){s({loading:!1,error:Mn(t)}),null==a||a(null,t)}},verifyResetPhoneNumber:async t=>{const{callback:a}=t,n=f(t,xo);s({loading:!0});try{const t=await e.auth.verifyResetPhoneNumber(n);s({loading:!1,error:void 0,changePhoneNumberToken:t.changePhoneNumberToken,step:mn.ChangePhoneNumber}),null==a||a(!0)}catch(t){s({loading:!1,error:Mn(t)}),null==a||a(null,t)}},changePhoneNumber:async a=>{const{callback:i}=a,o=f(a,$o);s({loading:!0});try{const{onRedirectTo:a,routes:r}=t.auth;await e.auth.changePhoneNumber({phoneNumber:o.phoneNumber,changePhoneNumberToken:o.changePhoneNumberToken}),n.setLoginState({step:gn.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:Mn(t)}),null==i||i(null,t)}}}},jo={loaders:{},errors:{},roles:[],permissions:[],permissionCategories:[]},Vo=t=>Rn(jo,t),Bo=["callback"],Wo=["callback"],Ho=["callback"],zo=["callback"],Ko=["callback"],qo=["callback"],Jo=(t,e,a)=>{const n=e=>{Object.assign(t.auth.rolesState,e)},s=e=>{Object.assign(t.auth.rolesState,{loaders:v({},t.auth.rolesState.loaders,{[e.key]:e.value})})},i=e=>{Object.assign(t.auth.rolesState,{errors:v({},t.auth.rolesState.errors,{[e.key]:e.value}),loaders:v({},t.auth.rolesState.loaders,{[e.key]:!1})})},o=async a=>{var o;const r=bn.LOAD_ROLES;s({key:r,value:!(null!=(o=null==a?void 0:a.silentLoading)&&o)});try{const[a,s,i]=await Promise.all([e.roles.getRoles(),e.roles.getPermissions(),e.roles.getPermissionCategories()]),{selectedRole:o}=t.auth.rolesState,r=null==a?void 0:a.find((({id:t})=>(null==o?void 0:o.id)===t));n({roles:a,permissions:s,permissionCategories:i,selectedRole:r})}catch(t){i({key:r,value:Mn(t)})}finally{s({key:r,value:!1})}},r=async t=>{const{callback:a}=t,r=f(t,Ko),l=bn.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:Mn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}};return{setRolesState:n,setRolesStateLoader:s,setRolesStateError:i,resetRolesState:()=>{t.auth.rolesState=za(jo)},loadRolesAndPermissions:o,addRole:async t=>{const{callback:a}=t,n=f(t,Bo),r=bn.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:Mn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},addRoleV2:async t=>{const{callback:a}=t,n=f(t,Wo),r=bn.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:Mn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},updateRole:async t=>{const{callback:a}=t,r=f(t,Ho),l=bn.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:Mn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}},deleteRole:async t=>{const{callback:a}=t,r=f(t,zo),l=bn.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:Mn(t)}),null==a||a(!1,t)}finally{s({key:l,value:!1})}},attachPermissionsToRole:r,attachPermissionToRoles:async t=>{const{callback:e}=t,a=f(t,qo),n=bn.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:Mn(t)}),null==e||e(null,t)}finally{s({key:n,value:!1})}}}},Yo={ipRestrictions:{loading:!1,pagination:{_offset:0,_limit:4,_filter:jt.ALLOW},totalPages:1,userIpValid:!1},emailDomainRestrictions:{loading:!0}},Qo=t=>Rn(Yo,t),Xo=["callback"],Zo=["callback"],tr=["callback"],er=["callback"],ar=(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(),await n.loadInsights())},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:Mn(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:Mn(t),loading:!1})}})),u=i((async a=>{const{callback:n}=a,i=f(a,Xo);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:p}}=await e.auth.getIPRestrictions(u),g=d;await l(),o({data:{config:null!=(r=null==(c=a.data)?void 0:c.config)?r:{isActive:!1,strategy:jt.ALLOW},restrictions:g},pagination:u,totalPages:p,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Mn(t)}),null==n||n(null,t)}})),d=i((async a=>{const{callback:n}=a,i=f(a,Zo);o({saving:!0,error:null});try{await e.auth.updateIPRestrictionConfig(i);const a=t.auth.restrictionsState.ipRestrictions,r=await e.auth.getIPRestrictionsConfig(),c=s(v({},a.pagination,{_filter:r.strategy})),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),p=u;await l(),o({data:{config:r,restrictions:p},pagination:c,totalPages:d,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Mn(t)}),null==n||n(null,t)}})),p=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),p=u;await l(),o({data:{config:(null==(r=a.data)?void 0:r.config)||{isActive:!1,strategy:jt.ALLOW},restrictions:p},pagination:c,totalPages:d,saving:!1}),null==i||i(!0)}catch(t){o({saving:!1,error:Mn(t)}),null==i||i(null,t)}})),g=i(l),h=i((async a=>{const{callback:n}=a;o({saving:!0,error:null});try{var i;const a=null!=(i=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 r=t.auth.restrictionsState.ipRestrictions,l=s(r.pagination),{items:c,_metadata:{totalPages:u}}=await e.auth.getIPRestrictions(l),d=c;o({data:{config:{isActive:!0,strategy:jt.ALLOW},restrictions:d},userIpValid:!0,pagination:l,totalPages:u,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:Mn(t),loading:!1})}})),S=i((async a=>{const{callback:n}=a,s=f(a,tr);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:Mn(t)}),null==n||n(null,t)}})),m=i((async t=>{const{callback:a}=t,n=f(t,er);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:Mn(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:Mn(t)})}}));return{setRestrictionsState:e=>{Object.assign(t.auth.restrictionsState,e)},setIpRestrictionsState:o,setEmailDomainRestrictionsState:r,__securityCenterSagaWrapper:i,loadIpRestrictions:c,saveIpRestriction:u,saveIpRestrictionsConfig:d,deleteIpRestriction:p,checkIfUserIpValid:g,addCurrentUserIpAndActivate:h,loadEmailDomainRestrictions:y,saveEmailDomainRestriction:S,saveEmailDomainRestrictionsConfig:m,deleteEmailDomainRestriction:b}},nr={loaders:{},errors:{},recommendations:void 0,insights:void 0,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}}},sr=t=>Rn(nr,t),ir=["callback"],or=(t,e,a)=>{const n=a,s=async t=>{var a,s,l,c;const{key:u,tableState:d,updateStateKey:p,_offset:g,_limit:h,_preset:y,_email:S,_maxInactiveSeconds:f}=t;r({key:u,value:!1}),o({key:u,value:!0});const m=null!=(a=null!=g?g: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=v({_offset:m,_limit:b,_includeSubTenants:!1,_preset:y,_maxInactiveSeconds:f},!!S&&{_email:S});try{const{items:t,_metadata:{totalItems:a,totalPages:s}}=await e.users.getUsersV3(A),o={totalUsersItems:a,totalUsersPages:s,usersPageOffset:m,queryParams:v({_offset:m,_limit:b,_maxInactiveSeconds:f},!!S&&{_email:S})};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 v({},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({[p]:v({users:a},o)})}else i({[p]:v({users:[]},o)})}catch(t){r({key:u,value:Mn(t)})}finally{o({key:u,value:!1})}},i=e=>{Object.assign(t.auth.securityCenterState,e)},o=e=>{Object.assign(t.auth.securityCenterState,{loaders:v({},t.auth.securityCenterState.loaders,{[e.key]:e.value})})},r=e=>{Object.assign(t.auth.securityCenterState,{errors:v({},t.auth.securityCenterState.errors,{[e.key]:e.value}),loaders:v({},t.auth.securityCenterState.loaders,{[e.key]:!1})})};return{setSecurityCenterState:i,resetSecurityCenterState:()=>{t.auth.securityCenterState=za(nr)},setSecurityCenterStateLoader:o,setSecurityCenterStateError:r,loadRecommendations:async()=>{const t=An.RECOMMENDATIONS;o({key:t,value:!0});try{var a;const{recommendations:t,scoring:n}=await e.securityCenter.getRecommendations();i({recommendations:t.items,score:null!=(a=null==n?void 0:n.score)?a:0})}catch(e){r({key:t,value:Mn(e)})}finally{o({key:t,value:!1})}},loadInsights:async()=>{const t=An.INSIGHTS;o({key:t,value:!0});try{const{insights:t}=await e.securityCenter.getInsights();i({insights:t.items})}catch(e){r({key:t,value:Mn(e)})}finally{o({key:t,value:!1})}},sendResetBreachedPasswordEmail:async t=>{const{callback:a}=t,n=f(t,ir),s=An.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:Mn(t)}),null==a||a(!1,t)}finally{o({key:s,value:!1})}},sendBulkResetBreachedPasswordEmails:async t=>{const{callback:a}=t,n=An.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:Mn(t)}),null==a||a(!1)}finally{o({key:n,value:!1})}},loadBreachedPasswordUsers:async e=>{var a;const n=An.BREACHED_PASSWORD_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.breachedPasswordUsersTable;await s(v({key:n,updateStateKey:"breachedPasswordUsersTable",_preset:Na.BREACHED_PASSWORDS,tableState:i},e))},loadUnenrolledMfaUsers:async e=>{var a;const n=An.UNENROLLED_MFA_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.unenrolledMfaUsersTable;await s(v({key:n,updateStateKey:"unenrolledMfaUsersTable",_preset:Na.MFA_UNENROLLED,tableState:i},e))},loadInactiveUsers:async e=>{var a;const n=An.INACTIVE_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.inactiveUsersTable;await s(v({key:n,updateStateKey:"inactiveUsersTable",_preset:Na.INACTIVE,tableState:i},e))}}},rr={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}},lr=t=>Rn(rr,t),cr=["callback"],ur=["callback"],dr=["callback"],pr=(t,e,a)=>{const n=a,s=async t=>{var e,a;if(!await n.customLoginEnabled())return t;const s=await i();return null!=s&&null!=(e=s.mainAuthStrategies)&&null!=(a=e[0])&&a.strategy?v({},t,{authStrategy:s.mainAuthStrategies[0].strategy}):t},i=async()=>{let a;return a=t.auth.isAuthenticated?await e.auth.getPublicAuthStrategiesConfigForAuthenticatedUser():await e.auth.getVendorPublicAuthStrategiesConfig(),a},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)},p=e=>{Object.assign(t.auth.securityPolicyState.captchaPolicy,e)},g=e=>{Object.assign(t.auth.securityPolicyState.passwordHistoryPolicy,e)},h=e=>{Object.assign(t.auth.securityPolicyState.vendorPasswordHistoryPolicy,e)},y=e=>{Object.assign(t.auth.securityPolicyState.passwordPolicy,e)},S=e=>{Object.assign(t.auth.securityPolicyState.publicAuthStrategyPolicy,e)},m=async()=>{o({loading:!0,error:null});try{const t=await e.auth.getGlobalSecurityPolicy();o({policy:t,loading:!1})}catch(t){o({error:Mn(t),loading:!1})}},b=async()=>{l({loading:!0,error:null});try{const t=await e.auth.getMfaPolicy();l({policy:t,loading:!1})}catch(t){l({error:Mn(t),loading:!1})}},A=async()=>{l({loading:!0,error:null});try{const t=await e.auth.getVendorMfaPolicy();c({policy:t,loading:!1})}catch(t){c({error:Mn(t),loading:!1})}},w=async()=>{u({loading:!0,error:null});try{const t=await e.auth.getLockoutPolicy();u({policy:t,loading:!1})}catch(t){u({error:Mn(t),loading:!1})}},T=async()=>{d({loading:!0,error:null});try{const t=await e.auth.getVendorLockoutPolicy();d({policy:t,loading:!1})}catch(t){d({error:Mn(t),loading:!1})}},E=async()=>{u({loading:!0,error:null});try{const t=await e.auth.getCaptchaPolicy();p({policy:t,loading:!1})}catch(t){p({error:Mn(t),loading:!1})}},I=async()=>{h({loading:!0,error:null});try{const t=await e.auth.getVendorPasswordHistoryPolicy();h({policy:t,loading:!1})}catch(t){h({error:Mn(t),loading:!1})}},O=async()=>{S({loading:!0,error:null});try{var e,a;const s=await i();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:v({},o,{authStrategy:e}),loading:!1})})(null==s||null==(e=s.mainAuthStrategies)||null==(a=e[0])?void 0:a.strategy),S({policy:s,loading:!1})}catch(t){S({error:Mn(t),loading:!1})}};return{setSecurityPolicyState:e=>{Object.assign(t.auth.securityPolicyState,e)},setSecurityPolicyGlobalState:o,setSecurityPolicyPublicState:r,setSecurityPolicyMfaState:l,setSecurityPolicyVendorMfaState:c,setSecurityPolicyLockoutState:u,setSecurityPolicyVendorLockoutState:d,setSecurityPolicyCaptchaState:p,setSecurityPolicyPasswordHistoryState:g,setSecurityPolicyVendorPasswordHistoryState:h,resetSecurityPolicyState:()=>{t.auth.securityPolicyState=za(rr)},setSecurityPolicyPasswordState:y,setSecurityPolicyAuthStrategyPublicState:S,loadSecurityPolicy:async()=>{await Promise.all([m(),b(),A(),w(),T(),I(),E(),O()])},loadGlobalSecurityPolicy:m,loadPublicSecurityPolicy:async()=>{r({loading:!0,error:null});try{const t=await e.auth.getVendorConfig(),a=await s(t);r({policy:a,loading:!1})}catch(t){r({error:Mn(t),loading:!1})}},loadVendorPasswordConfig:async()=>{y({loading:!0,error:null});try{const t=await e.auth.getPasswordConfigPolicy();y({policy:t,loading:!1})}catch(t){y({error:Mn(t),loading:!1})}},loadSecurityPolicyMfa:b,loadSecurityPolicyVendorMfa:A,loadSecurityPolicyLockout:w,loadSecurityPolicyVendorLockout:T,loadSecurityPolicyCaptcha:E,loadSecurityPolicyPasswordHistory:async()=>{g({loading:!0,error:null});try{const t=await e.auth.getPasswordHistoryPolicy();g({policy:t,loading:!1})}catch(t){g({error:Mn(t),loading:!1})}},loadSecurityPolicyVendorPasswordHistory:I,loadPublicAuthStrategiesPolicy:O,saveSecurityPolicyMfa:async t=>{const{callback:a}=t,n=f(t,cr);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:Mn(t)}),null==a||a(null,t)}},saveSecurityPolicyLockout:async t=>{const{callback:a}=t,n=f(t,ur);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:Mn(t)}),null==a||a(null,t)}},saveSecurityPolicyPasswordHistory:async t=>{const{callback:a}=t,n=f(t,dr);g({saving:!0,error:null});try{const t=await e.auth.savePasswordHistoryPolicy(n);g({policy:t,saving:!1}),null==a||a(t)}catch(t){g({saving:!1,error:Mn(t)}),null==a||a(null,t)}},__getSecurityPolicyPublicStateWithCustomLogin:s}},gr={loading:!1,configurations:{}},hr=t=>Rn(gr,t),yr=["callback"],Sr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.sessionsPolicyState,e)};return{setSessionsPolicyState:s,resetSessionsPolicyState:()=>{t.auth.sessionsPolicyState=za(gr)},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})}}}},vr={loading:!1,sessions:[]},fr=t=>Rn(vr,t),mr=(t,e,a)=>{const n=e=>{Object.assign(t.auth.sessionsState,e)},s=async()=>{n({loading:!0,error:null});try{const t=await e.auth.getCurrentUserSessions();n({sessions:t,loading:!1})}catch(t){n({error:Mn(t),loading:!1})}};return{setSessionsState:n,resetSessionsState:()=>{t.auth.sessionsState=za(vr)},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:Mn(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:Mn(t),loading:!1})}},deleteAllUserSessions:async()=>{n({loading:!0,error:null});try{await e.auth.deleteAllSessionsForUser(),await s()}catch(t){n({error:Mn(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:Mn(t),loading:!1}),null==a||a(!1)}}}},br={loading:!1,allowSignUps:!1,allowNotVerifiedUsersLogin:!1,firstLoad:!0,stage:wn.SignUp},Ar=t=>Rn(br,t),wr=["events","url"],Tr=(t,e,a)=>{const n=a,s=L.for(t.root.appName),i=e=>{Object.assign(t.auth.signUpState,e)},o=()=>{t.auth.signUpState=za(br)};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,url:r}=a,l=f(a,wr);i({loading:!0});try{const{routes:a,onRedirectTo:s}=t.auth,{shouldActivate:u,user:d,tenantId:p,userId:g,tenants:h=[],activeTenant:y}=await e.auth.signUpUser(As(l));if(!l.invitationToken){var c;const{email:t,name:e,companyName:a,phoneNumber:n}=l,s={email:t,name:e,companyName:a,url:r,phoneNumber:n||void 0,authenticationType:Pn.PASSWORD,id:g,tenantId:p,createdAt:new Date};null==o||null==(c=o.signUpComplete)||c.call(o,s),Hn(Wn.SIGNUP_COMPLETED,s)}if(!u&&d&&fs(d,t.root.appName)){const t=await n.getMfaRequiredState(d);n.setAuthState(t),s(a.loginUrl)}else{const e=t.auth.tenantsState;i({loading:!1,shouldActivate:u,stage:wn.SignUpSuccess}),n.setAuthState({user:d,isAuthenticated:!(null==d||!d.accessToken),tenantsState:v({},e,{tenants:h,activeTenant:y})})}}catch(t){s.setAccessToken(null),s.setUser(null),i({error:Mn(t)})}finally{i({loading:!1})}},loadAllowSignUps:async()=>{i({loading:!0});try{const t=await e.auth.getVendorConfig(),a=await n.__getSecurityPolicyPublicStateWithCustomLogin(t),{allowSignups:s,allowNotVerifiedUsersLogin:o}=t;i({loading:!1,allowSignUps:s,allowNotVerifiedUsersLogin:o,firstLoad:!1}),n.setSecurityPolicyPublicState({policy:a,loading:!1})}catch(t){i({loading:!1,error:Mn(t),firstLoad:!1})}}}},Er={loading:!1,error:null,phoneNumbers:void 0},Ir=t=>Rn(Er,t),Or=["callback"],Pr=["callback"],kr=["callback","phoneId"],_r=["callback","phoneId"],Ur=["callback"],Lr=(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:Mn(t)})}finally{n({loading:!1})}};return{setSmsState:n,resetSmsState:()=>{t.auth.smsState=za(Er)},loadPhoneNumbers:s,setUpPhoneNumber:async t=>{const{callback:a}=t,i=f(t,Or);n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.createPhoneNumber(i);n({otcToken:t}),await s(),null==a||a(!0)}catch(t){n({error:Mn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},verifyPhoneNumber:async t=>{const{callback:a}=t,i=f(t,Pr);n({loading:!0});try{await e.userPhoneNumbers.verifyPhoneNumber(i),await s(),null==a||a(!0)}catch(t){n({error:Mn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},deletePhoneNumber:async t=>{const{callback:a,phoneId:s}=t;f(t,kr),n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.deletePhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Mn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},verifyDeletePhoneNumber:async t=>{const{callback:a,phoneId:i}=t,o=f(t,_r);n({loading:!0});try{await e.userPhoneNumbers.verifyDeletePhoneNumber(i,o),await s(),null==a||a(!0)}catch(t){n({error:Mn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},preVerifyPhoneNumber:async t=>{const{callback:a}=t,s=f(t,Ur);n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.preVerifyPhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Mn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}}}},Rr={firstLoad:!0,loading:!1,error:""},Dr=t=>Rn(Rr,t),Cr=["authorizationUrl"],Nr=["events","url"],Mr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.socialLoginState,e)};return{setSocialLoginsState:s,resetSocialLoginsState:()=>{t.auth.socialLoginState=za(Rr)},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:Mn(t),loading:!1,firstLoad:!1})}},loadSocialLoginsConfigurationV2:async a=>{try{var n;const i=t.root.context;s({loading:!0});const o=await(async()=>{let a;return a=t.auth.isAuthenticated?await e.auth.getSocialLoginProvidersV2ForAuthenticatedUser():await e.auth.getSocialLoginProvidersV2(),a})(),{providers:r}=await e.auth.getCustomSocialLoginProvidersV1(),l={socialLoginsConfigV2:o.map((t=>{let{authorizationUrl:a}=t,n=f(t,Cr);const s=e.fetch.getBaseUrl(i,null!=a?a:"");return v({},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:Mn(t),loading:!1,firstLoad:!1})}},loginViaSocialLogin:async t=>{const{events:a,url:i}=t,o=f(t,Nr);try{s({loading:!0});const{email:t,isNewUser:c,userId:u,tenantId:d,name:p}=await e.auth.loginViaSocialLogin(o);if(c){var r,l;const e={email:t,url:i,createdAt:new Date,id:u,tenantId:d},n=v({},e,{socialProvider:o.provider,authenticationType:Pn.SOCIAL_LOGIN});null==a||null==(r=a.signUpComplete)||r.call(a,n),Hn(Wn.SIGNUP_COMPLETED,n);const s=v({},e,{origin:On.SOCIAL_LOGIN,name:p});null==a||null==(l=a.userVerified)||l.call(a,s),Hn(Wn.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:Mn(t,"Failed to authenticate"),firstLoad:!1})}}}},Fr={firstLoad:!0,loading:!0,saving:!1,errors:{},loaders:{},ssoConfigurations:[]},xr=t=>Rn(Fr,t),$r=["callback","samlVendor"],Gr=["callback"],jr=["callback","ssoConfigId"],Vr=["callback","ssoConfigId"],Br=["callback","ssoConfigId"],Wr=(t,e,a)=>v({},((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:Mn(t)})}},i=e=>{Object.assign(t.auth.ssoState,e)};return{setSSOState:i,resetSSOState:()=>{t.auth.ssoState=za(Fr)},setSSOLoader:e=>{Object.assign(t.auth.ssoState,{loaders:v({},t.auth.ssoState.loaders,{[e.key]:e.value})})},setSSOError:e=>{Object.assign(t.auth.ssoState,{errors:v({},t.auth.ssoState.errors,{[e.key]:e.value}),loaders:v({},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:Mn(t),loading:!1})}},saveSSOConfigurations:async a=>{const{callback:n,samlVendor:s}=a,o=f(a,$r),r=t.auth.ssoState.samlConfiguration,l=v({},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:v({},r,l)});if(i({error:void 0,[c]:!0}),a.type===En.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=Ja(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:Mn(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 mi(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:Mn(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 mi(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:Mn(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:v({},s,{validated:!0}),error:void 0,saving:!1}),null==n||n(!0)}catch(t){i({samlConfiguration:v({},s,{validated:!1}),error:Mn(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:Mn(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:Mn(t)})}})(o),await s(),i({error:void 0,saving:!1}),null==a||a(!0)}catch(t){i({error:Mn(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:Mn(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:Mn(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:Mn(t,"Failed to authenticate"),firstLoad:!1})}}}})(t,e,a),((t,e,a)=>{const n=a,s=async()=>{try{return await e.auth.getOidcConfiguration()}catch(t){return null}},i=async()=>{try{return await e.metadata.getSamlMetadata()}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:Mn(a)}),null==e||e(null,a)}finally{n.setSSOLoader({key:t,value:!1})}};return{loadSSOConfigurationsV2:async()=>{await o(Tn.LOAD_SSO_CONFIGURATIONS,void 0,(async()=>{const[t,a]=await Promise.all([s(),i()]),o=await e.auth.getSSOConfigurations();n.setSSOState({ssoConfigurations:o,oidcConfiguration:t,samlMetadata:a})}))},saveSSOConfigurationV2:async a=>{const{callback:s}=a,i=f(a,Gr),r=t.auth.ssoState.ssoConfigurations;await o(Tn.SAVE_SSO_CONFIGURATION,s,(async()=>{var t;const a=await e.auth.createSSOConfiguration(v({},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,jr),l=t.auth.ssoState.ssoConfigurations;await o(Tn.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(Tn.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,Vr),l=t.auth.ssoState.ssoConfigurations;await o(Tn.SAVE_SSO_DOMAIN,s,(async()=>{const t=await e.auth.createSSODomain(i,r),a=l.map((e=>e.id===i?v({},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(Tn.DELETE_SSO_DOMAIN,r,(async()=>{await e.auth.deleteSSODomain(s,i);const t=l.map((t=>t.id===s?v({},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(Tn.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?v({},t,{domains:t.domains.map((t=>t.id===i?v({},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(Tn.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?v({},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(Tn.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(Tn.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?v({},t,{roleIds:r}):t));n.setSSOState({ssoConfigurations:o}),null==s||s(!0)}))},saveSSOConfigurationByMetadata:async a=>{const{configFile:s,callback:i}=a;await o(Tn.SAVE_SSO_CONFIGURATION_BY_METADATA,i,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await mi(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(Tn.UPDATE_SSO_CONFIGURATION_BY_METADATA,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await mi(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(Tn.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,Br),l=t.auth.ssoState.ssoConfigurations;await o(Tn.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)),Hr={loading:!1,mfaDevices:void 0,mfaToken:""},zr=t=>Rn(Hr,t),Kr=(t,e,a)=>{const n=a;return v({setStepUpState:e=>{Object.assign(t.auth.stepUpState,e)},resetStepUpState:()=>{t.auth.stepUpState=za(Hr)},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 es(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:vn.noMFAEnrolledStepUp});window.localStorage.setItem(cs,"true");const a=t.auth.routes;L.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:os},{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),hs(),window.localStorage.setItem(cs,"true"),await n.__requestHostedLoginAuthorize(i)}}})(t,0,a))},qr={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}},Jr=t=>Rn(qr,t),Yr=["callback","appIds"],Qr=["roles"],Xr=["callback","profileImage"],Zr=["callback"],tl=["callback"],el=["callback"],al=["callback","userId"],nl=["callback"],sl=["callback"],il=["callback"],ol=["callback"],rl=["callback"],ll=["callback"],cl=(t,e,a)=>{const n=e=>{Object.assign(t.auth.teamState,e)};return v({setTeamLoader:e=>{Object.assign(t.auth.teamState,{loaders:v({},t.auth.teamState.loaders,{[e.key]:e.value})})},setTeamError:e=>{Object.assign(t.auth.teamState,{errors:v({},t.auth.teamState.errors,{[e.key]:e.value}),loaders:v({},t.auth.teamState.loaders,{[e.key]:!1})})},setTeamState:n,resetTeamState:()=>{t.auth.teamState=za(qr)},openAddUserDialog:t=>{n({addUserDialogState:v({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:v({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()=>{try{const{groups:t}=await e.groups.getGroups({_groupsRelations:Ra.roles});return t}catch(t){return[]}},i=async t=>{n.setTeamLoader({key:In.ROLES_AND_PERMISSIONS,value:!0});try{var a;const[{items:s},{items:i}]=await Promise.all([e.teams.loadAvailableRoles(),e.teams.loadAvailablePermissions()]);n.setTeamState({roles:s,permissions:i}),null==t||null==(a=t.callback)||a.call(t,{roles:s,permissions:i})}catch(e){var s;null==t||null==(s=t.callback)||s.call(t,null,e),n.setTeamError({key:In.ROLES_AND_PERMISSIONS,value:Mn(e)})}finally{n.setTeamLoader({key:In.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,p=null!=(s=a.pageSize)?s:d.pageSize,g=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:In.USERS,value:!c}),n.setTeamState({pageSize:p,pageOffset:g,filter:h,sort:y});try{const[{items:t,totalPages:a,totalItems:s}]=await Promise.all([e.teams.loadUsers({pageSize:p,pageOffset:g,filter:h,sort:y}),i()]);n.setTeamState({users:t,totalPages:a,totalItems:s}),null==u||u(t)}catch(t){n.setTeamError({key:In.USERS,value:Mn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:In.USERS,value:!1})},loadUsersV2:async o=>{var r,l,c,u,d;const{silentLoading:p,callback:g,shouldLoadRoles:h=!0,shouldLoadApps:y}=o,S=t.auth.teamState,f=null!=(r=o.pageSize)?r:S.pageSize,m=null!=(l=o.pageOffset)?l:S.pageOffset,b=null!=(c=o.filter)?c:S.filterV2,A=null!=(u=o.sort)?u:S.sortV2,w=null!=(d=null==o?void 0:o.shouldShowSubTenantUsersIfReseller)?d:null==S?void 0:S.shouldShowSubTenantUsersIfReseller;n.setTeamLoader({key:In.USERS,value:!p}),n.setTeamState({pageSize:f,pageOffset:m,filterV2:b,sortV2:A});try{const[{items:t,_metadata:{totalPages:n,totalItems:r}},{items:l},{items:c},u]=await Promise.all([e.users.getUsersV2(v({},(null==b?void 0:b.length)&&{_filter:b},A&&{_sortBy:A},o.order&&{_order:o.order},{_offset:m,_limit:f,_includeSubTenants:w})),e.teams.loadAvailableRoles(),e.teams.loadAvailablePermissions(),s(),h?i():void 0]),d=t.map((t=>{var e;return v({},t,{groups:null==t||null==(e=t.groups)?void 0:e.map((t=>u.filter((e=>e.id===t.id)))).flat()})})).map((t=>v({},t,{roleIds:t.roles.map((t=>t.id))}))),p=await a.mapUsersWithApplicationData({shouldLoadApps:y,users:d});a.setTeamState({users:p,totalPages:n,totalItems:r,roles:l,permissions:c}),null==g||g(t)}catch(t){console.error("Failed to load users",t),n.setTeamError({key:In.USERS,value:Mn(t)}),n.setTeamState({totalPages:0,users:[]}),null==g||g(null,t)}n.setTeamLoader({key:In.USERS,value:!1})},addUser:async s=>{const{callback:i,appIds:o}=s,r=f(s,Yr),l=t.auth.teamState;n.setTeamState({addUserDialogState:v({},l.addUserDialogState,{loading:!0})});try{var c;const t=await e.teams.addUser(r),{roles:s}=t,u=v({},f(t,Qr),{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:v({},l.addUserDialogState,{loading:!1,error:Mn(t)})}),null==i||i(null,t)}},addUsersBulk:async a=>{const{callback:s}=a,i=t.auth.teamState;n.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})});const o=[],r=[],l=a.emails.map((t=>v({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,Xr),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));if(void 0!==l){n.setTeamLoader({key:In.UPDATE_USER,value:o||""}),n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0})}),n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0}),users:r.users.map((t=>t.id===i.id?v({},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?v({},e,t,{groups:e.groups,createdAt:e.createdAt,customData:e.customData,lastLogin:e.lastLogin}):e))}),n.setTeamLoader({key:In.UPDATE_USER,value:!1})}catch(t){n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!1,error:Mn(t)}),users:r.users.map((t=>t.id===i.id?v({},t,l):t))}),n.setTeamLoader({key:In.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,Zr),o=t.auth.teamState;n.setTeamState({deleteUserDialogState:v({},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:v({},o.deleteUserDialogState,{loading:!1,error:Mn(t)})}),null==s||s(null,t)}},enableUser:async a=>{const{callback:s,userId:i}=a,o=t.auth.teamState;n.setTeamState({enableUserDialogState:v({},o.enableUserDialogState,{loading:!0})});try{await e.teams.enableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((t=>t.id===i?v({},t,{isDisabled:!1}):t)),enableUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({enableUserDialogState:v({},o.enableUserDialogState,{loading:!1,error:Mn(t)})}),null==s||s(null,t)}},disableUser:async a=>{const{callback:s,userId:i}=a,o=t.auth.teamState;n.setTeamState({disableUserDialogState:v({},o.disableUserDialogState,{loading:!0})});try{await e.teams.disableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((t=>t.id===i?v({},t,{isDisabled:!0}):t)),disableUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({disableUserDialogState:v({},o.disableUserDialogState,{loading:!1,error:Mn(t)})}),null==s||s(null,t)}},getTemporaryUsersConfig:async()=>{n.setTeamError({key:In.CONFIG_TEMPORARY_USERS,value:!1});try{const t=await e.teams.getTemporaryUserConfiguration();n.setTeamState({temporaryUsersConfig:t})}catch(t){n.setTeamError({key:In.CONFIG_TEMPORARY_USERS,value:Mn(t)})}},updateUserExpirationTime:async a=>{const{callback:s}=a,i=f(a,tl),o=t.auth.teamState;n.setTeamLoader({key:In.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?v({},e,{temporaryExpirationDate:new Date(t.temporaryExpirationDate)}):e))}),null==s||s(!0)}catch(t){n.setTeamError({key:In.UPDATE_USER_EXPIRATION_TIME,value:Mn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!1})}},setUserAsPermanent:async a=>{const{callback:s}=a,i=f(a,el),o=t.auth.teamState;n.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!0});try{await e.teams.setPermanentUser(i.userId),n.setTeamState({users:o.users.map((t=>t.id===i.userId?v({},t,{temporaryExpirationDate:void 0}):t))}),null==s||s(!0)}catch(t){n.setTeamError({key:In.UPDATE_USER_EXPIRATION_TIME,value:Mn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:In.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,p={_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:In.USERS,value:!c}),n.setTeamState({allUsersQueryParams:p});try{const[{items:t,_metadata:{totalPages:a,totalItems:s}},{items:i},{items:o}]=await Promise.all([e.subTenants.loadAllUsers(v({},p)),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:In.USERS,value:Mn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:In.USERS,value:!1})},setUserRolesForSubTenants:async a=>{const{callback:s,userId:i}=a,o=f(a,al),r=t.auth.teamState;n.setTeamState({addUserDialogState:v({},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 v({},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?[v({},t,{tenants:a})]:[]],addUserDialogState:{open:!1,loading:!1}}),null==s||s(!0)}catch(t){n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!1,error:Mn(t)})}),null==s||s(null,t)}},deleteUserFromSubTenants:async a=>{const{callback:s}=a,i=f(a,nl),o=t.auth.teamState;n.setTeamState({deleteUserDialogState:v({},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:v({},o.deleteUserDialogState,{loading:!1,error:Mn(t)})}),null==s||s(null,t)}},addUserToSubTenants:async a=>{const{callback:s}=a,i=f(a,sl),o=t.auth.teamState;n.setTeamState({addUserDialogState:v({},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:v({},o.addUserDialogState,{loading:!1,error:Mn(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:Mn(e)}),null==a||a(null,e)}finally{n.setTeamLoader({key:t,value:!1})}};return{resendActivationLink:async t=>{const{callback:a}=t,n=f(t,il);await s(In.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,ol);await s(In.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,rl);await s(In.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,ll);await s(In.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()=>{n.setTeamError({key:In.GET_TOKEN_LINK,value:!1});try{await(async()=>{n.setTeamError({key:In.CONFIG_TOKEN_LINK,value:!1});try{const t=await e.teams.getInviteLinkConfiguration();n.setTeamState({inviteTokenState:v({},t)})}catch(t){n.setTeamError({key:In.CONFIG_TOKEN_LINK,value:Mn(t)})}})();const a=await e.teams.getInviteUserLink(),{inviteTokenState:s}=t.auth.teamState;n.setTeamState({inviteTokenState:v({},s,a)})}catch(t){n.setTeamError({key:In.GET_TOKEN_LINK,value:Mn(t)})}},createInvitationLink:async a=>{const{callback:s}=a;n.setTeamError({key:In.CREATE_TOKEN_LINK,value:!1});const{inviteTokenState:i}=t.auth.teamState;try{const t=await e.teams.createInviteUserLink({expiresInMinutes:43200});n.setTeamState({inviteTokenState:v({},i,t)}),null==s||s(t.token)}catch(t){null==s||s(null,t),n.setTeamError({key:In.CREATE_TOKEN_LINK,value:Mn(t)})}},updateInvitationLink:async a=>{const{callback:s,expiresInMinutes:i,shouldSendEmail:o}=a;n.setTeamError({key:In.UPDATE_TOKEN_LINK,value:!1});try{const{inviteTokenState:a}=t.auth.teamState,r=await e.teams.updateInviteUserLink({expiresInMinutes:i,shouldSendEmail:o});n.setTeamState({inviteTokenState:v({},a,r)}),null==s||s(!0)}catch(t){null==s||s(null,t),n.setTeamError({key:In.UPDATE_TOKEN_LINK,value:Mn(t)})}},deleteInvitationLink:async t=>{const{callback:a}=null!=t?t:{};n.setTeamError({key:In.DELETE_TOKEN_LINK,value:!1});try{await e.teams.deleteInviteUserLink(),n.setTeamState({inviteTokenState:void 0}),null==a||a(!0)}catch(t){n.setTeamError({key:In.DELETE_TOKEN_LINK,value:Mn(t)}),null==a||a(!1,t)}}}})(t,e,a))},ul={tenants:[],subTenants:[],loading:!0,tenantTree:null},dl=t=>Rn(ul,t),pl=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.tenantsState,e)};return{setTenantsState:s,resetTenantsState:()=>{t.auth.tenantsState=za(ul)},switchTenant:async t=>{const{tenantId:a,callback:s}=t;n.setAuthState({isLoading:!0});try{await e.tenants.switchTenant({tenantId:a}),await n.__refreshToken(),(null==s?void 0:s(!0))||n.setAuthState({isLoading:!1})}catch(t){n.setAuthState({isLoading:!1}),null==s||s(!1,t)}},loadTenants:async e=>{s({loading:!0});try{var a;const n=oe(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 e.tenants.getSubTenants();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)}}}},gl=(t,e,a)=>{const n=e=>{t.auth.user&&(t.auth.user.entitlements=e)},s=e=>{var a;ln(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)}}}},hl=["routes"],yl=t=>{const e=null!=t?t:{},{routes:a}=e,n=f(e,hl);return Rn(v({routes:v({},Kn,a),onRedirectTo:()=>{},isAuthenticated:!1,isLoading:!0,isSSOAuth:!1,user:null,error:void 0,userIp:void 0},n,{acceptInvitationState:Cn(null==n?void 0:n.acceptInvitationState),accountSettingsState:$n(null==n?void 0:n.accountSettingsState),activateAccountState:Bn(null==n?void 0:n.activateAccountState),unlockAccountState:_s(null==n?void 0:n.unlockAccountState),apiTokensState:Rs(null==n?void 0:n.apiTokensState),applicationsState:Ns(null==n?void 0:n.applicationsState),customLoginState:$s(null==n?void 0:n.customLoginState),forgotPasswordState:Bs(null==n?void 0:n.forgotPasswordState),groupsState:Ks(null==n?void 0:n.groupsState),groupsDialogsState:Qs(null==n?void 0:n.groupsDialogsState),impersonateState:ti(null==n?void 0:n.impersonateState),loginState:si(null==n?void 0:n.loginState),mfaState:ri(null==n?void 0:n.mfaState),allAccountsState:po(null==n?void 0:n.allAccountsState),allAccountsDialogsState:Ao(null==n?void 0:n.allAccountsDialogsState),passkeysState:Eo(null==n?void 0:n.passkeysState),profileState:Po(null==n?void 0:n.profileState),provisioningState:Lo(null==n?void 0:n.provisioningState),resetPhoneNumberState:Mo(null==n?void 0:n.resetPhoneNumberState),rolesState:Vo(null==n?void 0:n.rolesState),restrictionsState:Qo(null==n?void 0:n.restrictionsState),securityCenterState:sr(null==n?void 0:n.securityCenterState),securityPolicyState:lr(null==n?void 0:n.securityPolicyState),sessionsPolicyState:hr(null==n?void 0:n.sessionsPolicyState),sessionsState:fr(null==n?void 0:n.sessionsState),signUpState:Ar(null==n?void 0:n.signUpState),smsState:Ir(null==n?void 0:n.smsState),socialLoginState:Dr(null==n?void 0:n.socialLoginState),ssoState:xr(null==n?void 0:n.ssoState),stepUpState:zr(null==n?void 0:n.stepUpState),teamState:Jr(null==n?void 0:n.teamState),tenantsState:dl(null==n?void 0:n.tenantsState)}))},Sl=(t,e,a,n)=>{const s=e=>{Object.keys(e).forEach((a=>{const n=a;Ya(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))},i={acceptInvitationActions:Fn(t,e),accountSettingsActions:jn(t,e,a),activateAccountActions:Ps(t,e,a),unlockAccountActions:Us(t,e),apiTokensActions:Ds(t,e),applicationsActions:Fs(t,e,a),customLoginActions:js(t,e,a),entitlementsActions:gl(t,e),forgotPasswordActions:Hs(t,e),groupsActions:Js(t,e),groupsDialogsActions:Xs(t),impersonateActions:ai(t,e,a),loginActions:to(t,e,a),mfaActions:co(t,e,a),allAccountsActions:mo(t,e,a),allAccountsDialogActions:wo(t),passkeysActions:Io(t,e,a),profileActions:_o(t,e,a),provisioningActions:Co(t,e),resetPhoneNumberActions:Go(t,e,a),rolesActions:Jo(t,e),restrictionsActions:ar(t,e,a),securityCenterActions:or(t,e,a),securityPolicyActions:pr(t,e,a),sessionsPolicyActions:Sr(t,e,a),sessionsActions:mr(t,e),signUpActions:Tr(t,e,a),smsActions:Lr(t,e),socialLoginActions:Mr(t,e,a),ssoActions:Wr(t,e,a),stepUpActions:Kr(t,e,a),teamActions:cl(t,e,a),tenantsActions:pl(t,e,a)};return[v({setAuthState:s,setState:s,resetAuthState:()=>{s(n)},setUser:t=>{s({user:t})}},Object.values(i).reduce(((t,e)=>v({},t,e)),{})),i]},vl={isLoading:!1,isSaving:!1,list:[],processIds:[],slackChannels:{isLoading:!1}},fl=t=>Rn(vl,t),ml=["email","slack","sms","webhook"],bl={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"}},Al=["id"],wl=["id","enabled"],Tl=(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=v({},n,e)},l=()=>{t.connectivity=za(vl)},c=async(t,e)=>{try{return await n[t](e)}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:ml;o({isLoading:!0});try{const t=await Promise.all([...e.map((t=>c(t))),c("categories"),(async()=>(await Promise.all(e.map((t=>c("channelMap",t))))).reduce(((t,a,n)=>v({},t,{[`${e[n]}`]:a})),{}))()]),a=await c("webhook"),n=t.reduce(((a,n,i)=>e[i]?t[t.length-1][e[i]].length?v({},a,{[`${e[i]}`]:n,list:[...a.list,{id:i,key:e[i],events:bl[e[i]].events(n),active:bl[e[i]].isActive(n),platform:bl[e[i]].title,image:bl[e[i]].image}]}):a:v({},a,{[`${s[i-e.length]}`]:n})),{list:[],webhook:a});o(v({},n,{error:void 0,isSaving:!1,isLoading:!1}))}catch(t){o({isLoading:!1,error:Mn(t)})}},p=async(e,a)=>{const{list:n}=t.connectivity,s=n.find((({key:t})=>t===e));if(!s)return;const i=bl[e].isActive(a);i!==s.active&&o({list:n.map((t=>t.key===e?v({},t,{active:i}):t))})},g=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,Al);return a===e.id&&JSON.stringify(v({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,wl);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,v({},l,{enabled:r})):e.connectivity.putSMSSubscriptions(o,s,v({},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 p(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 p(n,t),null==r||r(!0)}}catch(t){o({error:Mn(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:v({},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}})}},S=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,Mn(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:Mn(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:v({},r,{isLoading:!0})});const t=await e.connectivity.getWebhookLog(n,i,s);o({error:void 0,webhookLogs:v({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:g,postChannelData:g,postCodeAction:h,postSlackCode:h,loadScope:y,loadSlackPermissions:y,deleteWebhookConfigAction:S,deleteWebhookConfig:S,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 El;!function(t){t.UNKNWON="unknown",t.CARD="card"}(El||(El={}));const Il={loading:!1,error:null,fetching:!0,config:null},Ol=t=>Rn(Il,t);let Pl,kl,_l;!function(t){t.STRIPE="Stripe"}(Pl||(Pl={})),function(t){t.ACTIVE="ACTIVE",t.CANCELED="CANCELED",t.INCOMPLETE="INCOMPLETE",t.EXPIRED="EXPIRED",t.TRIALING="TRIALING"}(kl||(kl={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}(_l||(_l={}));const Ul=(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:()=>{t.subscriptions.config=za(Il)},loadPaymentConfiguration:async()=>{n({loading:!0});try{var t;(null!=(t=await e.subscriptions.getPaymentProviders())?t:[]).find((t=>"1"===t.status&&t.providerType===G.Stripe))?await(async()=>{n({loading:!0});try{const t=await e.subscriptions.getStripePaymentProviderConfiguration(),a={paymentProvider:Pl.STRIPE,apiKey:t.publishableKey};n({config:a}),n({loading:!1,fetching:!1})}catch(t){s(Mn(t))}})():s(Mn("Payment provider not configured"))}catch(t){s(Mn(t))}}}},Ll={loading:!1,error:null,fetching:!0},Rl=t=>Rn(Ll,t);function Dl({policy:t}){return{policy:_l.AT_PERIOD_END}}function Cl(t){switch(t){case F.ACTIVE:return kl.ACTIVE;case F.INCOMPLETE:return kl.INCOMPLETE;case F.CANCELED:return kl.CANCELED;case F.EXPIRED:return kl.EXPIRED;case F.TRIALING:return kl.TRIALING;default:return kl.EXPIRED}}const Nl=(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,p=null;u?d=await e.subscriptions.getSubscriptionPlan(c):([,d]=await Promise.all([n.loadSubscription(),e.subscriptions.getSubscriptionPlan(c)]),p=t.subscriptions.billing.subscription.subscription||null),s(v({loading:!1,fetching:!1,summary:i},p?{subscription:{id:p.id,externalId:p.externalId,startDate:p.startDate,currentPeriodStart:p.currentPeriodStart,currentPeriodEnd:p.currentPeriodEnd,status:o?kl.ACTIVE:Cl(p.status),cancellation:p.cancellation&&Dl(p.cancellation),trialEnd:p.trialEnd?p.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(Mn(t))}};return{setBillingInformationState:s,resetBillingInformationState:()=>{t.subscriptions.billing.information=za(Ll)},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(s?"Not authorized":"Internal feature failure")}}},Ml={loading:!1,error:null,fetching:!0,invoices:[],invoiceDownload:{loading:!1,error:null}},Fl=t=>Rn(Ml,t),xl=(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=Mn(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:Mn(t,null)})}};return{setBillingInvoiceState:n,resetBillingInvoiceState:()=>{t.subscriptions.billing.invoices=za(Ml)},loadInvoices:i,loadBillingInvoices:i,downloadInvoice:o,downloadBillingInvoice:o}},$l={loading:!1,error:null,fetching:!0},Gl=t=>Rn($l,t),jl=(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(Mn(t))}};return{setBillingPaymentMethodState:n,resetBillingPaymentMethodState:()=>{t.subscriptions.billing.paymentMethod=za($l)},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,v({email:n},r)),await o(),null==l||l(!0)}catch(t){i(Mn(t)),null==l||l(!1,t)}finally{s(!1)}}}},Vl={loading:!1,error:null,fetching:!0,cancellation:{loading:!1,error:null},renewal:{loading:!1,error:null}},Bl=t=>Rn(Vl,t),Wl=(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(Mn(t))}};return{setBillingSubscriptionState:s,resetBillingSubscriptionState:()=>{t.subscriptions.billing.subscription=za(Vl)},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("TenantId is not defined")},cancelSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void r("Subscription not found.");if(null!=a&&a.externallyManaged)return void r("Billing is externally managed.");const{id:n,cancellation:s,status:i}=a||{};if(!s&&i===F.ACTIVE)try{o(!0),await e.subscriptions.cancelManagedSubscription(n),await u(),o(!1)}catch(t){r(Mn(t))}},renewSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void c("Subscription not found.");if(null!=a&&a.externallyManaged)return void c("Billing is externally managed");const{id:n,cancellation:s}=a||{};if((null==s?void 0:s.policy)===$.AT_PERIOD_END)try{l(!0),await e.subscriptions.renewManagedSubscription(n),await u(),l(!1)}catch(t){c(Mn(t))}}}},Hl=t=>Rn({information:Rl(null==t?void 0:t.information),invoices:Fl(null==t?void 0:t.invoices),paymentMethod:Gl(null==t?void 0:t.paymentMethod),subscription:Bl(null==t?void 0:t.subscription)}),zl={loading:!1,error:null,fetching:!0,plans:[]},Kl=t=>Rn(zl,t),ql=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.plans,e)};return{setPlansState:n,resetPlansState:()=>{t.subscriptions.plans=za(zl)},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=Mn(e),n({loading:!1,fetching:!1,error:t})}var t}}},Jl={fetching:!0,loading:!1,error:null,confirmed:!1},Yl=t=>Rn(Jl,t),Ql=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.checkout,e)};return{setCheckoutState:s,resetCheckoutState:()=>{t.subscriptions.checkout=za(Jl)},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)===F.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:v({},r,{status:F.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:Mn(t)})}}else s({loading:!1,error:"Subscription not found"})},errorCheckout:t=>{s({loading:!1,error:t})}}},Xl={loading:!1,error:null,cardSetupIntentSecret:null},Zl=t=>Rn(Xl,t),tc=(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=Mn(e),Object.assign(t.subscriptions.stripe,{error:s,loading:!1,fetching:!1})}var s}}},ec={loading:!1,fetching:!0,vendorPublicConfig:null},ac=t=>Rn(ec,t),nc=(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:()=>{t.subscriptions.vendorPublicConfig=za(ec)},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(Mn(t))}}}},sc=t=>Rn({config:Ol(null==t?void 0:t.config),billing:Hl(null==t?void 0:t.billing),plans:Kl(null==t?void 0:t.plans),checkout:Yl(null==t?void 0:t.checkout),stripe:Zl(null==t?void 0:t.stripe),vendorPublicConfig:ac(null==t?void 0:t.vendorPublicConfig)}),ic=(t,e,a)=>{const n=Ul(t,e),[s,i]=((t,e,a)=>{const n=Nl(t,e,a),s=jl(t,e),i=xl(t,e),o=Wl(t,e,a);return[v({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=ql(t,e),r=Ql(t,e,a),l=tc(t,e),c=nc(t,e);return[v({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},oc={loading:!1},rc=t=>Rn(oc,t),lc=(t,e,a)=>{const n=e=>{Object.assign(t.vendor,e)},s=async()=>{n({loading:!0});try{var t;const a=await e.vendor.getVendorPublicInfo();a.whiteLabelMode=null!=(t=a.whiteLabelMode)&&t,n(v({},a,{loading:!1}))}catch(t){n({loading:!1}),console.error("failed to getVendorPublicInfo - ",t)}};return{setVendorState:n,resetVendorState:()=>{t.vendor=za(oc)},loadVendorPublicInfo:s,loadVendorPublicConfiguration:s}},cc={loading:!0,pageOffset:0,pageSize:20,logs:[],sort:[],filter:[],totalPages:0,isDownloadingCsv:!1},uc=t=>Rn(cc,t),dc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auditLogs.auditLogsState,e)};return{setAuditLogsState:s,resetAuditLogsState:()=>{t.auditLogs.auditLogsState=za(cc)},exportAuditsCsv:async()=>{const a=t.auditLogs.auditLogsState,{columns:n}=t.auditLogs.auditsMetadataState;try{const t=a.filter,i=a.sort.reduce(((t,e)=>v({},t,{sortBy:e.id,sortDirection:e.desc?"desc":"asc"})),{}),o=t.reduce(((t,e)=>v({},t,{[e.id]:e.value})),{});s({isDownloadingCsv:!0});const r="audits.csv";await e.audits.exportAudits(v({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,{columns:o}=t.auditLogs.auditsMetadataState;try{var r,l,c,u,d;const t=null!=(r=a.pageSize)?r:i.pageSize,p=null!=(l=a.pageOffset)?l:i.pageOffset,g=null!=(c=a.filter)?c:i.filter,h=null!=(u=a.sort)?u:i.sort;s({pageSize:t,pageOffset:p,filter:g,sort:h});const y=h.reduce(((t,e)=>v({},t,{sortBy:e.id,sortDirection:e.desc?"desc":"asc"})),{}),S=g.reduce(((t,e)=>v({},t,{[e.id]:e.value})),{});o||await n.loadAuditsMetadata();const{data:f,total:m}=await e.audits.getAudits(v({offset:p,count:t},y,S));s({loading:!1,logs:null!=f?f:[],totalPages:+Math.ceil(m/t)}),null==a||null==(d=a.callback)||d.call(a,!0)}catch(t){var p;s({loading:!1,error:Mn(t)}),null==a||null==(p=a.callback)||p.call(a,null,t)}}}},pc={loading:!0},gc=t=>Rn(pc,t),hc=(t,e,a)=>{const n=e=>{Object.assign(t.auditLogs.auditsMetadataState,e)};return{setAuditsMetadataState:n,resetAuditsMetadataState:()=>{t.auditLogs.auditsMetadataState=za(pc)},loadAuditsMetadata:async()=>{n({loading:!0,error:null});try{const{properties:t}=await e.metadata.getAuditsMetadata();n({columns:t,loading:!1})}catch(t){n({error:t,loading:!1})}}}},yc=t=>({auditLogsState:uc(null==t?void 0:t.auditLogsState),auditsMetadataState:gc(null==t?void 0:t.auditsMetadataState)}),Sc=(t,e,a)=>v({},dc(t,e,a),hc(t,e));var vc=a(1098),fc=a.n(vc);const mc={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},bc=(t,e)=>Object.keys(t).reduce(((a,n)=>{const s=n;return e.includes(n)?v({},a,{[n]:t[s]}):v({},a,{[n]:()=>{console.debug(`Action ${String(n)} was called`)}})}),{}),Ac={clientId:"CLIENT_ID_16806d3d-8fc3-4450-be97-abdaf66b723e",secret:"SECRET_16806d3d-8fc3-4450-be97-abdaf66b723e",createdAt:"createdAt",description:"Demo API Token (preview only)"},wc=v({},Ac,{roleIds:[],tenantId:"my-tenant-id",createdByUserId:"createdByUserId"}),Tc=[{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"}],Ec={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},Ic=v({},Ec,{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}),Oc={loading:!1,error:void 0,saving:!0,profile:Ec},Pc={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"},kc={allowSignups:!0,allowNotVerifiedUsersLogin:!1,apiTokensEnabled:!0,forcePermissions:!1,authStrategy:N.EmailAndPassword,machineToMachineAuthStrategy:M.ClientCredentials},_c={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date},Uc={id:"id",enabled:!0,maxAttempts:1,createdAt:new Date,updatedAt:new Date},Lc={id:"id",enabled:!0,historySize:1,createdAt:new Date,updatedAt:new Date},Rc={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},Dc={id:"id",createdAt:"createdAt",updatedAt:"updatedAt",properties:[],vendorId:"vendorId",entityName:"saml",isActive:!0,configuration:{acsUrl:"acsUrl",spEntityId:"spEntityId"}},Cc=[{id:"id",description:"description",key:"key",name:"name",permissions:[],permissionLevel:1}],Nc={firstLoad:!1,loading:!1,error:void 0,saving:!1,samlConfiguration:Rc,roles:Cc,authorizationRoles:[],errors:{},loaders:{},ssoConfigurations:[]},Mc=[{description:"string",fePermission:!0,id:"id",key:"key",name:"name",roleIds:[],createdAt:new Date,updatedAt:new Date,categoryId:"categoryId"}],Fc={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:[Tc[0]],groups:[{id:"id2",name:"Developers",color:"#03A9F4",roles:[Tc[0]],managedBy:Da.FRONTEGG}]},xc={id:Fc.id,email:Fc.email,name:Fc.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:[Tc[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},$c={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:[Tc[1]],groups:[{id:"id1",name:"Designers",color:"#E1F5E2",roles:[Tc[0]],managedBy:Da.FRONTEGG}]},Gc={id:$c.id,email:$c.email,name:$c.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:[Tc[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},jc={metadata:"",mfaEnrolled:!1,provider:"",sub:"",tenantIds:[],tenants:[],verified:!1,id:"id",email:"email",name:"name",tenantId:"tenantId",createdAt:new Date},Vc=[$c,Fc],Bc=[Gc,xc],Wc=[jc],Hc=[{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}],zc=[{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"}],Kc={isActive:!0,strategy:jt.ALLOW},qc=[{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"}],Jc=t=>{const e=[];return Array.from({length:t}).forEach(((t,a)=>{e.push(v({},$c,{name:"Demo User",id:`id${a}`,profilePictureUrl:null,createdAt:new Date}))})),e},Yc=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"}),Qc=[{id:"id1",name:"Designers",color:"#E1F5E2",description:"The whole design team",users:Jc(6),roles:[Yc("Editor")],metadata:'{"lastTermsCheck":"2022-08-16T10:31:11.270Z"}',managedBy:Da.FRONTEGG},{id:"id2",name:"Developers",color:"#03A9F4",description:"All frontend and backend developers",users:Jc(44),roles:[Yc("Editor")],managedBy:Da.FRONTEGG},{id:"id3",name:"Product",color:"#E1583E",description:"PMs and team leads",users:Jc(8),roles:[Yc("Viewer")],managedBy:Da.FRONTEGG},{id:"id4",name:"Management",color:"#9AE0FF",description:"Executives",users:Jc(5),roles:[Yc("Admin")],managedBy:Da.FRONTEGG},{id:"id5",name:"Sales",color:"#ED8E7C",users:Jc(21),description:"BDR, AE, and inside sales",roles:[Yc("Viewer")],managedBy:Da.FRONTEGG},{id:"id6",name:"Support",color:"#A79D7B",users:Jc(23),description:"Dev success and customer success",roles:[Yc("Admin")],managedBy:Da.FRONTEGG},{id:"id7",name:"Marketing",color:"#2CA744",users:Jc(10),description:"The marketing department",roles:[Yc("Viewer")],managedBy:Da.FRONTEGG},{id:"id8",name:"HR",color:"#EAE1C2",users:Jc(4),description:"Human resources",roles:[Yc("Viewer")],managedBy:Da.FRONTEGG},{id:"id9",name:"Finance",color:"#5587C0",users:Jc(3),roles:[Yc("Viewer")],managedBy:Da.FRONTEGG},{id:"id10",name:"Operations",color:"#B1CAE7",users:Jc(8),roles:[Yc("Editor")],managedBy:Da.FRONTEGG},{id:"id11",name:"Legal",color:"#2CA744",users:Jc(4),roles:[Yc("Viewer")],managedBy:Da.FRONTEGG}],Xc={scoring:{score:79},recommendations:{items:[{code:Fa.FORCE_MFA,severity:Ga.WARNING,category:ja.MFA},{code:Fa.ENABLE_FORCE_RELOGIN,severity:Ga.WARNING,category:ja.SESSIONS}]}},Zc={insights:{items:[{category:ja.MFA,code:xa.PARTIALLY_FORCED_MFA,metadata:{totalUsers:2,mfa:{enrolledUsersCount:1}}},{category:ja.SESSIONS,code:xa.PARTIAL_SESSION_SETTINGS,metadata:{totalUsers:2,sessions:{idleTimeoutRecommendation:1800}}},{category:ja.PASSWORD,code:xa.IMPROVE_PASSWORD_HISTORY_POLICY,metadata:{password:{userLockoutRecommendation:5,historyRecommendations:5}}},{category:ja.DOMAIN,code:xa.NO_IP_RESTRICTIONS,metadata:{restrictions:{ipsCount:1,domainsCount:1}}}]}},tu={users:Bc,totalUsersItems:2,totalUsersPages:1,usersPageOffset:0},eu={users:[Bc[0]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0,queryParams:{_maxInactiveSeconds:7776e3}},au={users:[Bc[1]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0};wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.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 nu,su=new Uint8Array(16);function iu(){if(!nu&&!(nu="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 nu(su)}const ou=/^(?:[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 ru=[],lu=0;lu<256;++lu)ru.push((lu+256).toString(16).substr(1));const cu=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(ru[t[e+0]]+ru[t[e+1]]+ru[t[e+2]]+ru[t[e+3]]+"-"+ru[t[e+4]]+ru[t[e+5]]+"-"+ru[t[e+6]]+ru[t[e+7]]+"-"+ru[t[e+8]]+ru[t[e+9]]+"-"+ru[t[e+10]]+ru[t[e+11]]+ru[t[e+12]]+ru[t[e+13]]+ru[t[e+14]]+ru[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&ou.test(t)}(a))throw TypeError("Stringified UUID is invalid");return a},uu=function(t,e,a){var n=(t=t||{}).random||(t.rng||iu)();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 cu(n)},du=["callback"],pu=["callback"],gu=["callback","profilePictureUrl"],hu=["callback"],yu=["callback"],Su=["callback"],vu=["callback"],fu=["callback"],mu=["callback"],bu=["callback"],Au=["callback"],wu=["callback","samlVendor"],Tu=["callback"],Eu=["callback"],Iu=["callback","profileImage"],Ou=["callback"],Pu=["callback"],ku=["callback"],_u=["callback"],Uu=["callback"],Lu=["callback"],Ru=["callback"],Du=["callback"],Cu=t=>"createdAt"!==t.id,Nu={total:20,data:Array.from(Array(5).keys()).map((t=>v({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`})))},Mu={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}]},Fu=(t,e,a)=>{const n=((t,e,a)=>{const n=dc(t,e,a),s=bc(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,p=null!=(l=e.filter)?l:n.filter,g=null!=(c=e.sort)?c:n.sort;s.setAuditLogsState({pageSize:t,pageOffset:d,filter:p,sort:g}),i||await a.loadAuditsMetadata();const{data:h,total:y}=((t,e)=>{const{data:a}=Nu;let n=a.filter((t=>e=>t.filter(Cu).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}})(p,g);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:Mn(t)}),null==e||null==(d=e.callback)||d.call(e,null,t)}},s})(t,e,a),s=((t,e)=>{const a=hc(t,e),n=bc(a,["setAuditsMetadataState","resetAuditsMetadataState"]);return n.loadAuditsMetadata=async()=>{n.setAuditsMetadataState({loading:!0,error:null});try{const{properties:t}=Mu;n.setAuditsMetadataState({columns:t,loading:!1})}catch(t){n.setAuditsMetadataState({error:t,loading:!1})}},n})(t,e);return v({},n,s)},xu={id:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",externalId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",startDate:"2021-09-20T08:08:51.000Z",status:F.ACTIVE,externallyManaged:!1,cancellation:null,currentPeriodStart:"2021-09-20T08:08:51.000Z",currentPeriodEnd:"2021-10-20T08:08:51.000Z",plan:{slug:"test"}},$u=[{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"}],Gu=[{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:""}],ju=[{id:"id",externalId:"externalId",type:x.CARD,isDefault:!0,last4:"4242",expMonth:11,expYear:25,brand:"visa",billingDetails:{name:"Dummy",email:"dummy@email.com"}}],Vu={allowPlanDowngrade:!0,allowPlanCancellation:!0},Bu=(t,e,a)=>{const n=((t,e)=>{const a=Ul(t,e),n=bc(a,["setPaymentConfigState","resetPaymentConfigState"]);return n.loadPaymentConfiguration=async()=>{n.setPaymentConfigState({loading:!0}),await Ka(500),n.setPaymentConfigState({loading:!1,fetching:!1,config:{paymentProvider:Pl.STRIPE,apiKey:""}})},n})(t,e),[s,i]=((t,e,a)=>{const n=((t,e,a)=>{const n=Nl(t,e,a),s=bc(n,["setBillingInformationState","resetBillingInformationState"]);return s.loadBillingInformation=async()=>{var t,e;s.setBillingInformationState({loading:!0}),await Ka(500),s.setBillingInformationState({loading:!1,fetching:!1,summary:{subscriptionId:xu.id,paymentMethodId:"mockPaymentMethodId",tenantConfigurationId:"mockTenantConfigurationId",providerType:G.Stripe,externallyManaged:!1,currentPlanId:$u[0].id,defaultPlanId:$u[0].id},plan:v({},$u[0],{price:null==(t=$u[0].price)?void 0:t.amount,currency:null==(e=$u[0].price)?void 0:e.currency,recurringInterval:"month"})})},s})(t,e,a),s=((t,e)=>{const a=jl(t,e),n=bc(a,["setBillingPaymentMethodState","resetBillingPaymentMethodState"]);return n.loadPaymentMethod=async()=>{n.setBillingPaymentMethodState({loading:!0}),await Ka(500),n.setBillingPaymentMethodState({paymentMethod:ju[0],loading:!1,fetching:!1})},n})(t,e),i=((t,e)=>{const a=xl(t,e),n=bc(a,["setBillingInvoiceState","resetBillingInvoiceState"]);return n.loadBillingInvoices=async()=>{n.setBillingInvoiceState({loading:!0}),await Ka(500),n.setBillingInvoiceState({loading:!1,fetching:!1,invoices:Gu.map((t=>v({},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=Wl(t,e,a),s=bc(n,["setBillingSubscriptionState","resetBillingSubscriptionState","setCancellationLoading","setCancellationError","setRenewalLoading","setRenewalError"]);return s.loadSubscription=async()=>{s.setBillingSubscriptionState({loading:!0}),await Ka(500),s.setBillingSubscriptionState({subscription:xu,fetching:!1,loading:!1,error:null})},s})(t,e,a);return[v({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=((t,e)=>{const a=ql(t,e),n=bc(a,["setPlansState","resetPlansState"]);return n.loadPlans=async()=>{n.setPlansState({loading:!0}),await Ka(500),n.setPlansState({fetching:!1,loading:!1,plans:$u.map((t=>{var e,a;return v({},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=Ql(t,e,a);return bc(n,["setCheckoutState","resetCheckoutState","errorCheckout","resetCheckout"])})(t,e,a),l=((t,e)=>{const a=tc(t,e);return bc(a,[])})(t,e),c=((t,e)=>{const a=nc(t,e),n=bc(a,["setVendorPublicConfigState","resetVendorPublicConfigState","setVendorPublicConfigError","setVendorPublicConfigLoading"]);return n.loadVendorPublicConfiguration=async()=>{n.setVendorPublicConfigLoading(!0),await Ka(),n.setVendorPublicConfigState({fetching:!1,loading:!1,vendorPublicConfig:Vu})},n})(t,e);return[v({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},Wu=(t,e,a)=>{const{authActions:n,authStateActions:s}=((t,e,a)=>{const n=((t,e)=>{const a=Fn(t,e);return bc(a,["setAcceptInvitationState","resetAcceptInvitationState"])})(t,e),s=((t,e,a)=>{const n=jn(t,e,a),s=bc(n,["setAccountSettingsState","resetAccountSettingsState"]);return s.saveAccountSettings=async e=>{var a;s.setAccountSettingsState({loading:!0}),await Ka();const n=t.auth.accountSettingsState,{address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u}=n,d=v({address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u},e);s.setAccountSettingsState(v({},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 Ka(),s.setAccountSettingsState(v({address:"Tel-aviv",timezone:"Asia/Jerusalem",dateFormat:"DD/MM/YYYY",timeFormat:"HH:mm",currency:"USD",loading:!1},t))},s})(t,e,a),i=((t,e)=>{const a=Us(t,e);return bc(a,["setUnlockAccountState","resetUnlockAccountState"])})(t,e),o=((t,e,a)=>{const n=Ps(t,e,a);return bc(n,["setActivateState","resetActivateState","setActivateStrategyState"])})(t,e,a),r=((t,e,a)=>{const n=mo(t,e,a);return bc(n,["setAllAccountsLoader","setAllAccountsError","setAllAccountsState","setSelectedAccountState","resetAllAccountsState","clearSelectedAccount"])})(t,e,a),l=wo(t),c=((t,e)=>{const a=Ds(t,e),n=bc(a,["setApiTokensState","resetApiTokensState","setApiTokensLoader","setApiTokensError"]);return n.addTenantApiToken=async e=>{const{description:a,roleIds:s,callback:i}=e;n.setApiTokensLoader({key:Za.ADD_API_TOKEN,value:!0});const{apiTokensDataTenant:o}=t.auth.apiTokensState,r=v({},wc,{description:a,roleIds:s,clientId:`CLIENT_ID_${uu()}`});n.setApiTokensState({showAddTokenDialog:!1}),await Ka(200),n.setApiTokensState({apiTokensDataTenant:[...o,r],successDialog:{open:!0,secret:r.secret,clientId:r.clientId}}),await Ka(200),n.setApiTokensLoader({key:Za.ADD_API_TOKEN,value:!1}),null==i||i(null)},n.deleteTenantApiToken=async t=>{n.setApiTokensLoader({key:Za.DELETE_API_TOKEN,value:!0}),await Ka(200);const e=[wc];n.setApiTokensState({apiTokensDataTenant:e.filter((e=>e.clientId!==t)),deleteTokenDialog:{open:!1,clientId:t}}),n.setApiTokensLoader({key:Za.DELETE_API_TOKEN,value:!1})},n.loadApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Za.LOAD_API_TOKENS,value:!0});const a=[Ac],s=[wc];n.setApiTokensState({apiTokensDataUser:a,apiTokensDataTenant:s}),await Ka(200),n.setApiTokensLoader({key:Za.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:Za.LOAD_API_TOKENS,value:!0});const a=[Ac];n.setApiTokensState({apiTokensDataUser:a}),await Ka(200),n.setApiTokensLoader({key:Za.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:Za.LOAD_API_TOKENS,value:!0});const a=[wc];n.setApiTokensState({apiTokensDataTenant:a}),await Ka(200),n.setApiTokensLoader({key:Za.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n})(t,e),u=((t,e,a)=>{const n=Fs(t,e,a);return bc(n,["setApplicationsState","resetApplicationsState"])})(t,e,a),d=((t,e,a)=>{const n=js(t,e,a),s=bc(n,["setCustomLoginState","resetCustomLoginState"]);return s.loadTenantMetadata=async()=>{s.setCustomLoginState({loading:!0}),await Ka(),s.setCustomLoginState({loading:!1})},s.updateTenantMetadata=async t=>{const{callback:e}=t;s.setCustomLoginState({loading:!0,error:null}),await Ka(),s.setCustomLoginState({loading:!1,error:null}),null==e||e(!0)},s})(t,e,a),p=((t,e)=>{const a=gl(t,e);return bc(a,["setEntitlements","handleFetchedEntitlements"])})(t,e),g=((t,e)=>{const a=Hs(t,e),n=bc(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:Mn(t)})}},n})(t,e),h=((t,e)=>{const a=Js(t,e),n=bc(a,["setGroupsState","resetUsersGroupsState","setUsersGroupsLoader","setUsersGroupsError"]);return n.loadGroups=async()=>{const t=un.GET_GROUPS;n.setUsersGroupsLoader({key:t,value:!0});const e=Qc;n.setGroupsState({groups:e}),n.setUsersGroupsLoader({key:t,value:!1})},n.createGroup=async e=>{var a;const s=un.CREATE_GROUP,{groups:i}=t.auth.groupsState;n.setUsersGroupsLoader({key:s,value:!0}),await Ka(500),n.setGroupsState({groups:[v({},e,{id:`${e.name}ID`,managedBy:Da.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=un.UPDATE_GROUP,c=t.auth.groupsState;n.setUsersGroupsLoader({key:l,value:!0}),await Ka(500),n.setGroupsState({groups:null==c||null==(a=c.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},e,{id:e.groupId,name:null!=(a=null==e?void 0:e.name)?a:"",managedBy:Da.FRONTEGG}):t})),selectedGroup:v({},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=un.DELETE_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Ka(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=un.ADD_ROLES_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Ka(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},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=un.DELETE_ROLES_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Ka(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},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=un.ADD_USERS_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Ka(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},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=un.DELETE_USERS_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Ka(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},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=un.GET_GROUP_CONFIGURATION,{groupsConfiguration:a}=t.auth.groupsState;n.setUsersGroupsLoader({key:e,value:!0}),a&&n.setGroupsState({groupsConfiguration:v({},a)}),n.setUsersGroupsLoader({key:e,value:!1})},n.updateGroupConfiguration=async e=>{const a=un.UPDATE_GROUP_CONFIGURATION,{groupsConfiguration:s}=t.auth.groupsState;n.setUsersGroupsLoader({key:a,value:!0}),s&&n.setGroupsState({groupsConfiguration:v({},s,e)}),n.setUsersGroupsLoader({key:a,value:!1})},n})(t,e),y=Xs(t),S=((t,e,a)=>{const n=ai(t,e,a);return bc(n,["setImpersonateState","resetImpersonateState"])})(t,e,a),m=((t,e,a)=>{const n=a,s=to(t,e,n),i=bc(s,["setLoginState","resetLoginState","afterAuthNavigation"]);return i.requestAuthorize=async t=>{t&&n.setAuthState({isLoading:!0});const e=Ic;await n.loadTenants(),n.setAuthState({user:e,isAuthenticated:!0,isLoading:!1})},i.getUserIP=async t=>{const{callback:e}=t;try{const{ip:t}=qc[0];await n.setAuthState({userIp:t}),null==e||e(!0,t)}catch(t){null==e||e(!1,t)}},i})(t,e,a),b=((t,e,a)=>{const n=a,s=co(t,e,n),i=bc(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,du),t.auth.mfaState);i.setMfaState({saving:!0}),await Ka();const o={token:"token",recoveryCode:"recoveryCode"},r={step:vn.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:v({},s,{authenticators:[{id:"authenticator-id"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(v({},Ic,{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 Ka(),i.setMfaState({saving:!1,error:void 0,mfaDevices:v({},s,{authenticators:[]})}),n.setUser(v({},Ic)),null==(a=e.callback)||a.call(e,!0)},i.verifyMfaAfterForce=async t=>{const{callback:e}=t,a=f(t,pu);i.setMfaState({loading:!0}),await Ka();const s=v({},a,{recoveryCode:"recoveryCode"}),o={step:vn.recoveryCode,loading:!1,error:void 0,saving:!1};null!=s&&s.recoveryCode&&(o.recoveryCode=s.recoveryCode),i.setMfaState(o),await Ka(),n.setUser(v({},Ic,{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:Mn(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 Ka(),i.setMfaState({loading:!1,error:void 0,mfaDevices:v({},s,{phones:[]})}),n.setUser(v({},Ic)),null==(a=e.callback)||a.call(e,!0)},i.preEnrollMfaSms=async t=>{var e;i.setMfaState({saving:!0}),await Ka(),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 Ka();const o={token:"token",recoveryCode:"recoveryCode"},r={step:vn.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:v({},s,{phones:[{id:"phone-id",phoneNumber:"+972504589346"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(v({},Ic,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i})(t,e,a),A=((t,e,a)=>{const n=Io(t,e,a);return bc(n,["setPasskeysState","resetPasskeysState"])})(t,e,a),w=((t,e,a)=>{const n=_o(t,e,a),s=bc(n,["setProfileState","resetProfileState"]);return s.loadProfile=async()=>{s.setProfileState({loading:!0}),await Ka(),a.setUser(v({},Ic,Ec)),s.setProfileState({loading:!1,profile:Ec})},s.saveProfile=async t=>{const{callback:e,profilePictureUrl:n}=t,i=f(t,gu);s.setProfileState({saving:!0,error:null});const o=Oc;let r=o.profile.profilePictureUrl;n!==o.profile.profilePictureUrl&&n&&(n||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)&&(r=n);const l=v({},o.profile,i,{profilePictureUrl:r}),c=Ic;await Ka(),a.setUser(v({},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 Ka(),s.setProfileState({loading:!1,error:void 0}),null==(e=t.callback)||e.call(t,!0)},s})(t,e,a),T=((t,e)=>{const a=Co(t,e);return bc(a,["setProvisioningState","resetProvisioningState"])})(t,e),E=((t,e,a)=>{const n=Go(t,e,a);return bc(n,["setResetPhoneNumberState","resetResetPhoneNumberState"])})(t,e,a),I=((t,e,a)=>{const n=ar(t,e,a),s=bc(n,["setRestrictionsState","setIpRestrictionsState","setEmailDomainRestrictionsState"]);return s.loadIpRestrictions=async()=>{s.setIpRestrictionsState({loading:!0,error:null}),s.setIpRestrictionsState({data:{restrictions:qc.filter((t=>t.strategy===Kc.strategy)),config:Kc},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,hu);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,v({},r,{createdAt:new Date,updatedAt:new Date,id:uu(),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,yu),l=t.auth.restrictionsState.ipRestrictions;s.setIpRestrictionsState({saving:!0,error:null}),s.setIpRestrictionsState({data:{config:v({},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=qc[0].ip,n=!!e.data.restrictions.find((t=>t.isActive&&t.ip===a));s.setIpRestrictionsState({userIpValid:n,loading:!1})}catch(t){s.setIpRestrictionsState({error:Mn(t),loading:!1})}},s.saveEmailDomainRestriction=async e=>{var a,n;const{callback:i}=e,o=f(e,Su),r=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await Ka(),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)||[],v({},o,{id:Date.now().toString()})]},saving:!1})},s.saveEmailDomainRestrictionsConfig=async e=>{var a;const{callback:n}=e,i=f(e,vu),o=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await Ka(),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 Ka(),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),O=((t,e)=>{const a=Jo(t,e),n=bc(a,["setRolesState","setRolesStateError","setRolesStateLoader","resetRolesState"]);return n.loadRolesAndPermissions=async t=>{var e;const a=bn.LOAD_ROLES;n.setRolesStateLoader({key:a,value:!(null!=(e=null==t?void 0:t.silentLoading)&&e)});try{n.setRolesState({roles:Tc})}catch(t){n.setRolesStateError({key:a,value:Mn(t)})}finally{n.setRolesStateLoader({key:a,value:!1})}},n})(t,e),P=((t,e,a)=>{const n=or(t,e,a),s=bc(n,["setSecurityCenterState","setSecurityCenterStateError","setSecurityCenterStateLoader","resetSecurityCenterState"]);return s.loadRecommendations=async()=>{const t=An.RECOMMENDATIONS;s.setSecurityCenterStateLoader({key:t,value:!0}),await Ka(),s.setSecurityCenterState({recommendations:Xc.recommendations.items,score:Xc.scoring.score}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInsights=async()=>{const t=An.INSIGHTS;s.setSecurityCenterStateLoader({key:t,value:!0}),await Ka(),s.setSecurityCenterState({insights:Zc.insights.items}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadBreachedPasswordUsers=async()=>{const t=An.BREACHED_PASSWORD_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await Ka(),s.setSecurityCenterState({breachedPasswordUsersTable:tu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadUnenrolledMfaUsers=async()=>{const t=An.UNENROLLED_MFA_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await Ka(),s.setSecurityCenterState({unenrolledMfaUsersTable:au}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInactiveUsers=async()=>{const t=An.INACTIVE_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await Ka(),s.setSecurityCenterState({inactiveUsersTable:eu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.sendResetBreachedPasswordEmail=async t=>{const{callback:e}=t,a=An.SEND_BREACHED_PASSWORD_EMAIL;s.setSecurityCenterStateLoader({key:a,value:!0}),await Ka(),null==e||e(!0),s.setSecurityCenterStateLoader({key:a,value:!1})},s})(t,e,a),k=((t,e,a)=>{const n=pr(t,e,a),s=bc(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 Ka(),s.setSecurityPolicyGlobalState({policy:Pc,loading:!1})},s.loadPublicSecurityPolicy=async()=>{s.setSecurityPolicyPublicState({loading:!0,error:null});try{s.setSecurityPolicyPublicState({policy:kc,loading:!1})}catch(t){s.setSecurityPolicyPublicState({error:Mn(t),loading:!1})}},s.saveSecurityPolicyMfa=async t=>{var e;const{callback:a}=t,n=f(t,fu);s.setSecurityPolicyMfaState({saving:!0,error:null});const i=v({},Uc,{id:null!=(e=n.id)?e:Uc.id,enforceMFAType:n.enforceMFAType});await Ka(),s.setSecurityPolicyMfaState({policy:i,saving:!1}),null==a||a(i)},s.loadSecurityPolicyMfa=async()=>{s.setSecurityPolicyMfaState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyMfaState({policy:_c,loading:!1})},s.loadSecurityPolicyVendorMfa=async()=>{s.setSecurityPolicyVendorMfaState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyVendorMfaState({policy:_c,loading:!1})},s.saveSecurityPolicyLockout=async t=>{const{callback:e}=t,a=f(t,mu);s.setSecurityPolicyLockoutState({saving:!0,error:null}),await Ka();const n=v({},Uc,a,{id:a.id?a.id:Uc.id});null==e||e(n),s.setSecurityPolicyLockoutState({policy:n,saving:!1})},s.loadSecurityPolicyLockout=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyLockoutState({policy:Uc,loading:!1})},s.loadSecurityPolicyVendorLockout=async()=>{s.setSecurityPolicyVendorLockoutState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyVendorLockoutState({policy:Uc,loading:!1})},s.loadSecurityPolicyCaptcha=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyLockoutState({policy:Uc,loading:!1})},s.saveSecurityPolicyPasswordHistory=async t=>{const{callback:e}=t,a=f(t,bu);s.setSecurityPolicyPasswordHistoryState({saving:!0,error:null}),await Ka();const n=v({},Lc,a,{id:a.id?a.id:Lc.id});null==e||e(n),s.setSecurityPolicyPasswordHistoryState({policy:n,saving:!1})},s.loadSecurityPolicyPasswordHistory=async()=>{s.setSecurityPolicyPasswordHistoryState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyPasswordHistoryState({policy:Lc,loading:!1})},s.loadSecurityPolicyVendorPasswordHistory=async()=>{s.setSecurityPolicyVendorPasswordHistoryState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyVendorPasswordHistoryState({policy:Lc,loading:!1})},s})(t,e,a),_=((t,e)=>{const a=mr(t,e),n=bc(a,["setSessionsState","resetSessionsState"]);return n.loadUserSessions=async()=>{n.setSessionsState({loading:!0,error:null}),n.setSessionsState({sessions:zc,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=zc.filter((t=>t.current));n.setSessionsState({sessions:t,loading:!1})},n})(t,e),U=((t,e,a)=>{const n=Sr(t,e,a),s=bc(n,["setSessionsPolicyState","resetSessionsPolicyState"]);return s.loadSessionsPolicy=async()=>{s.setSessionsPolicyState({loading:!0,error:null});const e=t.auth.sessionsPolicyState;s.setSessionsPolicyState(v({},e,{loading:!1}))},s.createOrUpdateSessionsPolicy=async t=>{const{callback:e}=t,a=f(t,Au);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=Tr(t,e,a);return bc(n,["setSignUpState","resetSignUpState","resetSignUpStateSoft"])})(t,e,a),R=((t,e)=>{const a=Lr(t,e);return bc(a,["setSmsState","resetSmsState"])})(t,e),D=((t,e,a)=>{const n=Mr(t,e,a);return bc(n,["setSocialLoginsState","resetSocialLoginsState","setSocialLoginError"])})(t,e,a),C=((t,e,a)=>{const n=Wr(t,e,a),s=bc(n,["setSSOState","resetSSOState"]);return s.loadSSOConfigurations=async()=>{s.setSSOState({loading:!0}),await Ka(),s.setSSOState({samlConfiguration:Rc,loading:!1,firstLoad:!1})},s.saveSSOConfigurations=async t=>{var e,a;const{callback:n,samlVendor:i}=t,o=f(t,wu),r=Nc.samlConfiguration,l=v({},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:v({},r,l)});s.setSSOState({error:void 0,[c]:!0}),await Ka(),l.acsUrl=null==Dc||null==(e=Dc.configuration)?void 0:e.acsUrl,l.spEntityId=null==Dc||null==(a=Dc.configuration)?void 0:a.spEntityId;const u=Ja(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 Ka(),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=v({},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=Nc.samlConfiguration;s.setSSOState({error:void 0,saving:!0}),await Ka(),s.setSSOState({samlConfiguration:v({},a,{validated:!0}),error:void 0,saving:!1}),null==e||e(!0)},s.loadSSOAuthorizationRoles=async()=>{await Ka(),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 Ka(),s.setSSOState({authorizationRoles:a,error:void 0,saving:!1}),null==e||e(!0)},s})(t,e,a),N=((t,e,a)=>{const n=Kr(t,e,a);return bc(n,["setStepUpState","resetStepUpState"])})(t,e,a),M=((t,e,a)=>{const n=cl(t,e,a),s=bc(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,p=null!=(i=e.filter)?i:c.filterV2,g=null!=(o=e.sort)?o:c.sortV2;s.setTeamLoader({key:In.USERS,value:!r}),s.setTeamState({pageSize:u,pageOffset:d,filterV2:p,sortV2:g}),await Ka(),s.setTeamState({users:Vc,totalPages:2,totalItems:10,roles:Cc,permissions:Mc}),s.setTeamLoader({key:In.USERS,value:!1}),null==l||l(Vc)},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,p=null!=(n=e._offset)?n:u.allUsersQueryParams._offset,g=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:In.USERS,value:!l}),s.setTeamState({allUsersQueryParams:{_limit:d,_offset:p,_filter:g,_sortBy:h,_order:y}}),await Ka(),s.setTeamState({allUsers:Wc,totalPages:2,totalItems:10,roles:Cc,permissions:Mc}),s.setTeamLoader({key:In.USERS,value:!1}),null==c||c(Wc)},s.loadRoles=async t=>{var e;s.setTeamLoader({key:In.ROLES_AND_PERMISSIONS,value:!0}),await Ka(),s.setTeamState({roles:Cc,permissions:Mc}),s.setTeamLoader({key:In.ROLES_AND_PERMISSIONS,value:!0}),null==t||null==(e=t.callback)||e.call(t,{roles:Cc,permissions:Mc})},s.addUser=async e=>{const{callback:a}=e,n=f(e,Tu),i=t.auth.teamState;s.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})}),await Ka();const o=new Date,r=v({},$c,{groups:[]},n,{id:`${uu()}`,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,Eu),i=t.auth.teamState;s.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})}),await Ka();const o=v({},$c,n,{id:`${uu()}`});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,Iu),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));s.setTeamLoader({key:In.UPDATE_USER,value:o||""}),s.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0})}),s.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0}),users:r.users.map((t=>t.id===i.id?v({},t,i):t))}),l.roleIds.length>0&&0===(null==(a=i.roleIds)?void 0:a.length)&&(i.roleIds=[""]),await Ka();const c=v({},l,i);null==n||n(c),s.setTeamState({users:r.users.map((t=>t.id===c.id?v({},t,c,{createdAt:t.createdAt,customData:t.customData,lastLogin:t.lastLogin}):t))}),s.setTeamLoader({key:In.UPDATE_USER,value:!1})},s.deleteUser=async e=>{const{callback:a}=e,n=f(e,Ou),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:v({},i.deleteUserDialogState,{loading:!0})}),await Ka(),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,Pu),i=t.auth.teamState;s.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!0});const o=new Date;s.setTeamState({users:i.users.map((t=>t.id===n.userId?v({},t,{temporaryExpirationDate:n.expirationInSeconds?new Date(o.setSeconds(o.getSeconds()+n.expirationInSeconds)):void 0}):t))}),await Ka(),null==a||a(!0),s.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.setUserAsPermanent=async e=>{const{callback:a}=e,n=f(e,ku),i=t.auth.teamState;s.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!0}),s.setTeamState({users:i.users.map((t=>t.id===n.userId?v({},t,{temporaryExpirationDate:void 0}):t))}),await Ka(),null==a||a(!0),s.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.deleteUserFromSubTenants=async e=>{const{callback:a}=e,n=f(e,_u),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:v({},i.deleteUserDialogState,{loading:!0})}),await Ka(),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,Uu);s.setTeamLoader({key:In.RESEND_ACTIVATE_LINK,value:a.userId}),await Ka(),null==e||e(!0),s.setTeamLoader({key:In.RESEND_ACTIVATE_LINK,value:!1})},s.resendInvitationLink=async t=>{const{callback:e}=t,a=f(t,Lu);s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:a.email}),await Ka(),null==e||e(!0),s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationEmail=async t=>{const{callback:e}=t,a=f(t,Ru);s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:a.email}),await Ka(),null==e||e(!0),s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationLinkToAllSubTenants=async t=>{const{callback:e}=t,a=f(t,Du);s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:a.email}),await Ka(),null==e||e(!0),s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:!1})},s})(t,e,a),F=((t,e,a)=>{const n=pl(t,e,a),s=bc(n,["setTenantsState","resetTenantsState"]);return s.loadTenants=async()=>{s.setTenantsState({loading:!0}),s.setTenantsState({tenants:Hc,activeTenant:Hc[0],loading:!1})},s})(t,e,a),x={acceptInvitationActions:n,accountSettingsActions:s,unlockAccountActions:i,activateAccountActions:o,allAccountsActions:r,allAccountsDialogActions:l,apiTokensActions:c,applicationsActions:u,customLoginActions:d,entitlementsActions:p,forgotPasswordActions:g,groupsActions:h,groupsDialogsActions:y,impersonateActions:S,loginActions:m,mfaActions:b,passkeysActions:A,profileActions:w,provisioningActions:T,resetPhoneNumberActions:E,restrictionsActions:I,rolesActions:O,securityCenterActions:P,securityPolicyActions:k,sessionsActions:_,sessionsPolicyActions:U,signUpActions:L,smsActions:R,socialLoginActions:D,ssoActions:C,stepUpActions:N,teamActions:M,tenantsActions:F},$=e=>{Object.keys(e).forEach((a=>{const n=a;Ya(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))};return{authActions:v({setState:$,setAuthState:$,resetAuthState:()=>{},setUser:t=>{$({user:t})}},n,s,o,i,r,l,c,u,d,p,g,h,y,S,m,b,A,w,T,E,I,O,P,k,_,U,L,R,D,C,N,M,F),authStateActions:x}})(t,e,a),i=((t,e,a)=>{const n=Tl(t,e,a);return bc(n,["setConnectivityState","resetConnectivityState","initData","resetConnectivityState","cleanWebhookTestData","cleanWebhookLogsData","cleanWebhookTestMessage","cleanError","cleanSlackData"])})(t,e,a),[o,r]=Bu(t,e,a),l=((t,e,a)=>{const n=lc(t,e,a),s=bc(n,["setVendorState","resetVendorState"]);return s.loadVendorPublicInfo=async()=>{try{s.setVendorState({whiteLabelMode:!1}),await Ka()}catch(t){console.error("failed to getVendorPublicInfo - ",t)}},s.loadVendorPublicConfiguration=s.loadVendorPublicInfo,s})(t,e,a);return{authActions:n,authStateActions:s,connectivityActions:i,subscriptionsActions:o,subscriptionsStateActions:r,vendorActions:l,auditsActions:Fu(t,e,a)}},Hu=(t,e,a=!1,n,s,i=!1,o="path")=>zu({name:t.appName,context:t.context,storeHolder:e,previewMode:a,builderMode:i,urlStrategy:o,initialState:{root:v({},t),auth:v({},null==s?void 0:s.auth,n),connectivity:v({},null==s?void 0:s.connectivity),subscriptions:v({},null==s?void 0:s.subscriptions),vendor:v({},null==s?void 0:s.vendor),auditLogs:v({},null==s?void 0:s.auditLogs),audits:v({},null==s?void 0:s.audits)}}),zu=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:p=!1,builderMode:g=!1,urlStrategy:h="path"}=t,y=L.for(u);p||g||y.setContext(d),void 0===d.requestCredentials&&(d.requestCredentials="include");const S=yl(null==(e=t.initialState)?void 0:e.auth),m=fl(null==(a=t.initialState)?void 0:a.connectivity),b=sc(null==(n=t.initialState)?void 0:n.subscriptions),A=rc(null==(s=t.initialState)?void 0:s.vendor),w=yc(null==(i=t.initialState)?void 0:i.auditLogs),T=(E=null==(o=t.initialState)?void 0:o.audits,Rn(mc,E));var E;const I=null==(r=t.initialState)?void 0:r.auth;I&&Object.keys(I).forEach((t=>{fc()(S,t,I[t],{merge:!0})}));const O=za(S),R=Rn({root:{appName:u,context:d,urlStrategy:h,previewMode:p},auth:S,connectivity:m,subscriptions:b,vendor:A,auditLogs:w,audits:T});"undefined"!=typeof window&&"true"===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(v({name:s},i));P(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))}(R,{name:`${u} Store`,enabled:!0});const D={},C={};y.setContext(t.context),y.setAppName(u);const N=v({},Wa(u),{fetch:new Nt(u)});if(t.previewMode||t.builderMode){const{authActions:e,authStateActions:a,connectivityActions:n,subscriptionsActions:s,subscriptionsStateActions:i,vendorActions:o,auditsActions:r}=Wu(R,N,C);D.auth=a,D.connectivity=n,D.subscriptions=i,D.vendor=o,D.auditLogs=r,D.audits={},Object.assign(C,v({},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:()=>R,subscribe:t=>P(R,t),store:R,actions:C,stateActions:D};return t.previewMode&&l.dispatch({type:"auth/requestAuthorize",payload:!0}),c&&(c.store=l),l}{const[t,e]=Sl(R,N,C,O),a=Tl(R,N,C),[n,s]=ic(R,N,C),i=lc(R,N,C),o=Sc(R,N,C),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:p=d,onlyOneLoad:g=!0,offset:h=0}=s||{},{rowsData:y}=p?t.audits:{rowsData:[]};try{const n=r(i),{data:s,total:p}=await e.audits.getAudits(v({},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:p}),g&&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(v({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}}}})(R,N);return D.auth=e,D.connectivity=a,D.subscriptions=s,D.vendor=i,D.auditLogs=o,D.audits=r,Object.assign(C,v({},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:()=>R,subscribe:t=>P(R,t),store:R,actions:C,stateActions:D}}};let Ku,qu,Ju,Yu,Qu,Xu,Zu,td,ed,ad,nd,sd,id;!function(t){t.phoneNumber="phoneNumber"}(Ku||(Ku={})),function(t){t.Name="name",t.PhoneNumber="phoneNumber",t.Address="address",t.JobTitle="jobTitle"}(qu||(qu={})),function(t){t.LoginSessions="loginSessions",t.Mfa="mfa"}(Ju||(Ju={})),function(t){t.Name="name",t.PhoneNumber="phoneNumber"}(Yu||(Yu={})),function(t){t.CompanyName="companyName",t.Address="address",t.Website="website",t.Timezone="timezone",t.Currency="currency"}(Qu||(Qu={})),function(t){t.User="user",t.Applications="applications",t.Groups="groups",t.Roles="roles",t.JoinedAt="joinedAt",t.LastSeen="lastSeen",t.ManagedBy="managedBy"}(Xu||(Xu={})),function(t){t.Invoices="invoices"}(Zu||(Zu={})),function(t){t.SessionManagement="sessionManagement",t.GeneralSettings="generalSettings",t.IpRestrictions="ipRestrictions",t.DomainRestrictions="domainRestrictions"}(td||(td={})),function(t){t.IdleSessionTimeout="idleSessionTimeout",t.ForceReLogin="forceReLogin",t.MaximumConcurrentSessions="maximumConcurrentSessions"}(ed||(ed={})),function(t){t.Mfa="mfa",t.UserLockout="userLockout",t.PasswordHistory="passwordHistory"}(ad||(ad={})),function(t){t.IpAddressRestrictions="ipAddressRestrictions"}(nd||(nd={})),function(t){t.RestrictSignupByEmailDomain="restrictSignupByEmailDomain"}(sd||(sd={})),function(t){t.Settings="settings",t.CustomLogin="customLogin"}(id||(id={}));const od={hidden:"hidden",viewOnly:"viewOnly",edit:"edit"},rd={hidden:"hidden",edit:"edit"};function ld(t,e=0,a=1){return Math.min(Math.max(e,t),a)}function cd(t){if(t.type)return t;if("#"===t.charAt(0))return cd(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 ud(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 dd(t){if(0===t.indexOf("#"))return t;const{values:e}=cd(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 pd(t,e){return t=cd(t),e=ld(e),"rgb"!==t.type&&"hsl"!==t.type||(t.type+="a"),"color"===t.type?t.values[3]=`/${e}`:t.values[3]=e,ud(t)}function gd(t,e){if(t=cd(t),e=ld(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 ud(t)}function hd(t,e){if(t=cd(t),e=ld(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 ud(t)}const yd=t=>{if(t)return{main:t,light:dd(hd(t,.4)),dark:dd(gd(t,.15)),hover:dd(gd(t,.15)),active:dd(gd(t,.2))}},Sd=t=>{if(t)return{main:t,light:hd(t,.7),dark:gd(t,.2)}},vd=(t,e)=>{var a,n,s,i,o,r,l,c,u,d,p,g;return null!=t&&t.palette&&"string"==typeof(null==t||null==(a=t.palette)?void 0:a.primary)?v({},e,{palette:{primary:v({},yd(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:v({},yd(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:v({},yd(null==t||null==(c=t.palette)?void 0:c.error),{contrastText:"#FFF"}),success:v({},Sd(null==t||null==(u=t.palette)?void 0:u.success),{contrastText:"#FFF"}),error:v({},Sd(null==t||null==(d=t.palette)?void 0:d.error),{contrastText:"#FFF"}),warning:v({},Sd(null==t||null==(p=t.palette)?void 0:p.warning),{contrastText:"#FFF"}),info:v({},Sd(null==t||null==(g=t.palette)?void 0:g.info),{contrastText:"#FFF"})}}):{}},fd={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 md{constructor(){this._theme=fd.theme,this._themeV2=fd.themeV2,this._navigation=fd.navigation,this._localizations=fd.localizations,this._integrations=fd.integrations}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new md;return a.set(t),md._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=fd.navigation)?e:{},null!=(a=null==t?void 0:t.navigation)?a:{}]),this._theme=Ln().all([null!=(n=fd.theme)?n:{},vd(null==t?void 0:t.theme,fd.theme)]),this._themeV2=Ln().all([null!=(s=fd.themeV2)?s:{},null!=(i=null==t?void 0:t.themeV2)?i:{}]),this._localizations=Ln().all([null!=(o=fd.localizations)?o:{},null!=(r=null==t?void 0:t.localizations)?r:{}]),this._integrations=Ln().all([null!=(l=fd.integrations)?l:{},null!=(c=null==t?void 0:t.integrations)?c:{}])}catch(t){this._navigation=fd.navigation,this._theme=fd.theme,this._themeV2=fd.themeV2,this._localizations=fd.localizations,this._integrations=fd.integrations}}}md._instances={};var bd=function(t){return t.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map((function(t){return t.toLowerCase()})).join("")},Ad=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},wd=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)}))},Td=function(t){var e=t.toString();if(e){var a=new URL(window.location.href);a.search=e,window.history.pushState(null,"",a.toString())}};var Ed={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"},Id=function(t){var e,a=md.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)}))},Od=function(){var t=g(y().mark((function t(e,a){var n,s,i,o;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=null==(n=e.metadataOverrides)?void 0:n.url){t.next=3;break}return t.abrupt("return",e);case 3:return t.prev=3,t.next=6,a.sendRequest({url:s,method:"GET",credentials:"omit"});case 6:if(!(i=t.sent)){t.next=10;break}return o=Ln()(e,i),t.abrupt("return",o);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){return t.apply(this,arguments)}}(),Pd=function(){function a(t,e){var n,s,o=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=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("7.4.0"),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=g(y().mark((function t(){var e,a,n,s,i;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o.options.metadata){t.next=14;break}return t.prev=1,t.next=4,o.fetchClient.get("/metadata",{entityName:"adminBox"});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.next=8,Od(i,o.fetchClient);case 8:o.options.metadata=t.sent,t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),console.error("failed to get admin portal metadata",t.t0);case 14:md.set(o.options.metadata,o.name);case 15:case"end":return t.stop()}}),t,null,[[1,11]])}))),this.requestAuthorize=g(y().mark((function t(){var e,a,n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=null==(e=o.options.authOptions)||null==(a=e.hostedLoginOptions)?void 0:a.loadUserOnFirstLoad,o.options.builderMode||"nextjs"===o.options.framework||(o.options.hostedLoginBox&&!o.options.customLoginBox?n&&o.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:{shouldRedirectToLogin:!1,firstTime:!0}}):o.store.dispatch({type:"auth/requestAuthorize",payload:!0}));case 2:case"end":return t.stop()}}),t)}))),this.loadFeatureFlags=g(y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!o.options.previewMode&&!o.options.builderMode){t.next=4;break}Yt.set(Ed,o.name),t.next=15;break;case 4:return t.prev=4,t.next=7,o.apiClient.featureFlags.loadFeatureFlags();case 7:e=t.sent,o.options.overrideFeatureFlags&&Object.assign(e,o.options.overrideFeatureFlags),Yt.set(e,o.name),t.next=15;break;case 12:t.prev=12,t.t0=t.catch(4),console.error("failed to get admin portal feature flags",t.t0);case 15:case"end":return t.stop()}}),t,null,[[4,12]])}))),this.setFeatureFlagsForPreview=function(t){Yt.set(Object.assign({},Ed,t),o.name)},this.queryFeatureFlags=function(t){return Yt.getFeatureFlags(t,o.name)},this.updateLocalizationsSetter=function(t){o.updateLocalizations=t},this.getEntitlementsFromStore=function(){var t;return null==(t=o.store.getState().auth.user)?void 0:t.entitlements},this.getUserFromStore=function(){return o.store.getState().auth.user},this.getEntitlementsQueryData=function(t){var e=o.getUserFromStore();return{entitlements:o.getEntitlementsFromStore(),attributes:{custom:t,jwt:e}}};var u=bd(e),d="frontegg-app-".concat(u);this.iframeRendering=r,this.name=u,this.options=Object.assign({},t,{contextOptions:Object.assign({requestCredentials:"include"},t.contextOptions)}),this.fetchClient=new Nt(this.name),this.apiClient=Wa(this.name),this.options.cdnUrl&&(this.cdnUrl=this.options.cdnUrl),this.customElementName=d;var p,h,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,!l&&this.options.store.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=zu({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!=(p=this.options.authOptions)?p:{}),auditLogs:Object.assign({},null!=(h=this.options.auditsOptions)?h:{})}});c.setInstance(u,this);var v=L.for(u);v.setAppName(u),this.setEntitlementsOptions(t.entitlementsOptions),this.setSessionContext({enableSessionPerTenant:null==(s=t.authOptions)?void 0:s.enableSessionPerTenant});var f=t.basename;f&&v.setBasename(f)}var n,o,r,u;return l(a,[{key:"setEntitlementsOptions",value:function(t){L.for(this.name).setEntitlementsOptions(Object.assign({},t))}},{key:"setSessionContext",value:function(t){L.for(this.name).setSessionContext(Object.assign({},t))}},{key:"initContainers",value:(u=g(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,this.loadFeatureFlags();case 9:return t.next=11,Promise.all([this.loadAdminBoxMetadata(),this.requestAuthorize()]);case 11:this.options.previewMode||this.options.customLoginBox||(this.loadLoginBox(),Id(this.name)),this.options.lazyLoadAdminPortal||this.loadScript("FronteggAdminPortal");case 13:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"updateMetadata",value:function(t){var e;md.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:"logout",value:function(){this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/logout"})}},{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=g(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=g(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],L.for(this.name).setRequestSource(Rt.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(),Td(e),L.for(this.name).setRequestSource(null)}catch(t){console.error("Failed to unmount admin portal",t)}}},{key:"showCheckoutDialog",value:(n=g(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 on(n,t,s)}},{key:"getPermissionEntitlements",value:function(t,e){var a=this.getEntitlementsQueryData(e),n=a.entitlements,s=a.attributes;return sn(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}):ys(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 gs(a,e)}},{key:"switchTenant",value:function(t){this.store.dispatch({type:"auth/switchTenant",payload:t})}},{key:"close",value:function(){this.hideAdminPortal(),this.hideCheckoutDialog()}}]),a}(),kd=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=L.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}(),_d=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}(),Ud=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}(),Ld=function(t){var e;return null!=(e=window.FronteggAdminPortal.adminPortalStaticThemesDefaults[t])?e:void 0},Rd=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=Hu({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 Pd(this.options,e,!0),md.set({},e)}var e;return l(t,[{key:"render",value:(e=g(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,wd(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}(),Dd="modern",Cd=function(t){var e,a=window.FronteggAdminPortal.themes;return null!=(e=a[t])?e:a[Dd]},Nd=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=Hu({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 Pd(this.options,e,!0,o),md.set({},e)}var e;return l(t,[{key:"render",value:(e=g(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,wd(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 Md(t,e){return Md=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Md(t,e)}function Fd(t){return Fd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Fd(t)}function xd(t,e,a){return xd=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&&Md(s,a.prototype),s},xd.apply(null,arguments)}function $d(t){var e="function"==typeof Map?new Map:void 0;return $d=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 xd(t,arguments,Fd(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Md(n,t)},$d(t)}function Gd(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=Fd(t);if(e){var s=Fd(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 jd=function(t){var e=new Pd(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(t){!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&&Md(t,e)}(a,t);var e=Gd(a);function a(){var t;i(this,a);for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];return(t=e.call.apply(e,[this].concat(s))).app=null,t}return l(a,[{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 t,e=null!=(t=this.getAttribute("app-name"))?t:"default",a=c.getInstance(e);if(null===a)throw Error("FronteggApp not found for appName: '".concat(e,"'"));this.setAttribute("id","frontegg-app-".concat(a.name));var n=Ad(this,"div",{id:"frontegg-admin-portal-container-".concat(a.name)}),s=Ad(this,"div",{id:"frontegg-login-box-container-".concat(a.name)}),i=Ad(this,"div",{id:"frontegg-checkout-dialog-container-".concat(a.name)}),o=n.attachShadow({mode:"open"}),r=s.attachShadow({mode:"open"}),l=i.attachShadow({mode:"open"}),u=Ad(o,"div",{id:"frontegg-admin-portal-".concat(a.name),class:"frontegg-root-content"}),d=Ad(r,"div",{id:"frontegg-login-box-".concat(a.name),class:"frontegg-root-content"}),p=Ad(l,"div",{id:"frontegg-checkout-dialog-".concat(a.name),class:"frontegg-root-content"});a.initContainers({adminPortalEl:u,loginBoxEl:d,adminPortalContainer:n,loginBoxContainer:s,checkoutDialogContainer:i,checkoutDialogEl:p})}}],[{key:"observedAttributes",get:function(){return["app-name"]}}]),a}($d(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),p=Object.prototype.toString.call(u),g=(h=u)&&h.constructor&&"function"==typeof h.constructor.isBuffer&&h.constructor.isBuffer(h);var h;const y="[object Object]"===p||"[object Array]"===p,S=r?r+n+i(c):i(c);if(!d&&!g&&y&&Object.keys(u).length&&(!(null==e?void 0:e.maxDepth)||s&&l<s))return t(u,S,l+1);o[S]=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}},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 p(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 g(t,e,a){try{return{type:"normal",arg:t.call(e,a)}}catch(t){return{type:"throw",arg:t}}}e.wrap=p;var h={};function y(){}function S(){}function v(){}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=v.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=g(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=I(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=g(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 I(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,I(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=g(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 P(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 S.prototype=v,o(A,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:S,configurable:!0}),S.displayName=d(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===S||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,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(p(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(P),!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),P(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;P(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:()=>_d,AdminPortalRenderer:()=>Rd,AppHolder:()=>c,CheckoutDialog:()=>Ud,FronteggApp:()=>Pd,HostedLogin:()=>kd,LoginBoxRenderer:()=>Nd,createElement:()=>Ad,defaultTheme:()=>Dd,formatName:()=>bd,getOverriddenMetadata:()=>Od,getThemeAdminByName:()=>Ld,getThemeByName:()=>Cd,initialize:()=>jd,mockFlagsList:()=>Ed,restoreSearchParams:()=>Td,waitThemeSetter:()=>wd});var t={};a.r(t),a.d(t,{ADMIN_PORTAL_ENTITLEMENTS_FF:()=>Kt,ApplicationAccessType:()=>Va,AuthStrategyEnum:()=>N,ContextHolder:()=>L,DirectoryApi:()=>oa,FRONTEGG_SEPARATE_TABS_BY_TENANT:()=>Zt,FeatureFlags:()=>Yt,FeatureFlagsApi:()=>Qt,FetchClient:()=>Nt,FronteggApiError:()=>B,FronteggContext:()=>D,FronteggFrameworks:()=>Dt,GetUsersFilterPreset:()=>Na,GroupManagedByEnum:()=>Da,GroupRelations:()=>Ra,ISubscriptionCancellationPolicy:()=>$,ISubscriptionStatus:()=>F,InsightCode:()=>xa,LOAD_AUTHORIZATION_FF:()=>Ht,MFAStrategyEnum:()=>Wt,MachineToMachineAuthStrategy:()=>M,NotEntitledJustification:()=>zt,PaginationOrderEnum:()=>Ct,PaymentMethodType:()=>x,PermissionAssignmentTypeEnum:()=>wa,ProviderType:()=>G,RecommendationActionKey:()=>$a,RecommendationCode:()=>Fa,RecommendationSeverity:()=>Ga,RequestSource:()=>Rt,RestrictionType:()=>jt,ScimConnectionSource:()=>La,SecondaryAuthStrategy:()=>Vt,SecurityCategory:()=>ja,SocialLoginProviders:()=>C,SortByEnum:()=>Ca,SubAccountAccessTypeEnum:()=>Ta,TenantSortByEnum:()=>ba,TenantType:()=>Aa,UserManagedByEnum:()=>ma,WebAuthnDeviceType:()=>Bt,api:()=>Ba,createApiClient:()=>Wa,default:()=>Ha,fetch:()=>Mt,fronteggAuthApiRoutesRegex:()=>Ea,fronteggEntitlementsV2Url:()=>Ua,fronteggHeaders:()=>Lt,fronteggRefreshTokenUrl:()=>Ia,fronteggSilentRefreshTokenUrl:()=>Oa,fronteggTenantsUrl:()=>ka,fronteggTenantsV3Url:()=>_a,fronteggUsersUrl:()=>Pa,getCurrentUserTenantsFunction:()=>oe,getTabTenantFromSessionStorage:()=>ie,providersArray:()=>Ma,removeTabTenantFromSessionStorage:()=>se,setTabTenantInSessionStorage:()=>ne});var e={};a.r(e),a.d(e,{ACR_VALUE:()=>os,AMR_ADDITIONAL_VALUE:()=>ls,AMR_MFA_VALUE:()=>rs,AcceptInvitationStep:()=>Qa,ActivateAccountStep:()=>Xa,AdminPortalPages:()=>_n,AdminPortalPagesForEvents:()=>kn,AllAccountsStateKeys:()=>fn,ApiStateKeys:()=>Za,AuthStrategyEnum:()=>N,AuthenticationTypes:()=>Pn,FRONTEGG_AFTER_AUTH_REDIRECT_URL:()=>ds,ForgotPasswordStep:()=>cn,FronteggNativeModule:()=>S,GTMEventAction:()=>Wn,GroupRelations:()=>dn,GroupsStateKeys:()=>un,HOSTED_LOGIN_VERIFIER_KEY:()=>ps,ImpersonateStep:()=>pn,LoginActionTypes:()=>Sn,LoginFlow:()=>hn,LoginStep:()=>gn,MFAStep:()=>vn,MachineToMachineAuthStrategy:()=>M,PaymentMethodType:()=>El,PaymentProvider:()=>Pl,QuickLoginStrategy:()=>yn,ResetPhoneNumberStep:()=>mn,RolesStateKeys:()=>bn,SHOULD_STEP_UP_KEY:()=>cs,SSOStateKeys:()=>Tn,STEP_UP_MAX_AGE_PARAM_NAME:()=>us,SamlVendors:()=>En,SecurityCenterStateKeys:()=>An,SignUpStage:()=>wn,SubscriptionCancellationPolicy:()=>_l,SubscriptionStatus:()=>kl,TENANT_ID_PARAM_KEY:()=>Zn,TeamStateKeys:()=>In,UserVeirifedOriginTypes:()=>On,authStrategyLoginStepMap:()=>zn,base64ToFormData:()=>vi,base64urlDecode:()=>Si,base64urlEncode:()=>yi,buildAuditsActions:()=>Sc,buildAuthActions:()=>Sl,buildConnectivityActions:()=>Tl,buildSubscriptionsActions:()=>ic,buildVendorActions:()=>lc,createAuditsState:()=>yc,createAuthState:()=>yl,createConnectivityState:()=>fl,createFronteggStore:()=>Hu,createProxy:()=>Rn,createRandomString:()=>xi,createStore:()=>zu,createSubscriptionsState:()=>sc,createVendorState:()=>rc,deepClone:()=>za,defaultFronteggRoutes:()=>Kn,delay:()=>Ka,errorHandler:()=>Mn,extractPhoneNumber:()=>As,generateCodeChallenge:()=>Fi,generateCodeChallengeNative:()=>Mi,generateCodeChallengePureJs:()=>Ni,getBaseNameWithoutSlashSuffix:()=>is,getEntitlements:()=>rn,getFeatureEntitlements:()=>on,getMfaStepForEnrolledUsers:()=>es,getMfaStepForNotEnrolledUsers:()=>as,getNumberOfMfaDevices:()=>ts,getPathAndSearchParamsFromUrl:()=>Qn,getPermissionEntitlements:()=>sn,getRedirectUrl:()=>Jn,getSearchParam:()=>Xn,getSearchParamsFromUrl:()=>Yn,getUri:()=>bs,isAbsoluteUrl:()=>qn,isAuthRoute:()=>ws,isEmailPayload:()=>ss,isEntitlementsDeeplyEqual:()=>ln,isError:()=>Nn,isMfaRequired:()=>fs,isOauthCallbackRoute:()=>ns,isProxy:()=>Ya,isSteppedUp:()=>gs,mapMetaDataObjectToActions:()=>ms,omitProps:()=>Ja,publicKeyCredentialToJSON:()=>fi,readFileAsText:()=>mi,redirectByStepUpUrl:()=>ys,reportGTMEvent:()=>Hn,retry:()=>qa,setAfterAuthRedirectUrlForStepUp:()=>hs,snapshot:()=>k,subscribe:()=>P});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:()=>id,AccountPageFields:()=>Qu,DomainRestrictionsTabFields:()=>sd,GeneralSettingsTabFields:()=>ad,InviteUserModalFields:()=>Yu,IpRestrictionsTabFields:()=>nd,Metadata:()=>md,PrivacyPageFields:()=>Ju,ProfilePageFields:()=>qu,SecurityPageTabs:()=>td,SessionManagementTabFields:()=>ed,SignupFields:()=>Ku,SubscriptionsPageFields:()=>Zu,UsersTableColumns:()=>Xu,alpha:()=>pd,fieldAppearance:()=>od,tabAppearance:()=>rd});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 p(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 g(t){return function(){var e=this,a=arguments;return new Promise((function(n,s){var i=t.apply(e,a);function o(t){p(i,n,s,o,r,"next",t)}function r(t){p(i,n,s,o,r,"throw",t)}o(void 0)}))}}c._apps={};var h=a(5799),y=a.n(h);const S=new class{constructor(){this.loginWithSSO=t=>{if(this.isWebkitAvailable()){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.isJsInterfaceAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSSO(t)}},this.loginWithSocialLogin=t=>{if(this.isWebkitAvailable()){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.isJsInterfaceAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSocialLogin(t)}},this.promptSocialLoginConsent=()=>{var t,e;return null!=(t=null==(e=window.FronteggNativeBridgeFunctions)?void 0:e.shouldPromptSocialLoginConsent)&&t}}isWebkitAvailable(){var t,e;return null!=(null==(t=window.webkit)||null==(e=t.messageHandlers)?void 0:e.FronteggNativeBridge)}isJsInterfaceAvailable(){return null!=window.FronteggNativeBridge}isSocialLoginAvailable(){return this.isAvailable("loginWithSocialLogin")}isLoginWithSSOAvailable(){return this.isAvailable("loginWithSSO")}isAvailable(t){var e,a;return!(!this.isWebkitAvailable()&&!this.isJsInterfaceAvailable())&&null!=(e=null==(a=window.FronteggNativeBridgeFunctions)?void 0:a[t])&&e}};function v(){return v=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},v.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,I=new WeakSet;const[O]=function(t=Object.is,e=(t,e)=>new Proxy(t,e),a=t=>T(t)&&!I.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(I.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 p=r[1];const g=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))},S=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),v=e(S,{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 p;y(n),T(s)&&(s=(t=>t&&(A.has(t)?A.get(t):b(t)===Object.prototype||b(t)===Array.prototype))(p=s)&&p[m]||s);let S=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)&&(S=l(s));const t=!I.has(S)&&E.get(S);t&&((t,e)=>{if(u.size){const a=e[3](g(t));h.set(t,[e,a])}else h.set(t,[e])})(n,t)}return Reflect.set(e,n,S,i),d(["set",[n],s,c]),!0}});o.set(n,v);const f=[S,(t=++r[1])=>(p===t||u.size||(p=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](g(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(v,f),Reflect.ownKeys(n).forEach((t=>{const e=Object.getOwnPropertyDescriptor(n,t);"value"in e&&(v[t]=n[t],delete e.value,delete e.writable),Object.defineProperty(S,t,e)})),v}){return[l,E,I,t,e,a,n,s,i,o,r]}();function P(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 L{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.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.getAppName=()=>this.appName}static default(){return L.getInstance(R)}static for(t){return L.getInstance(t)}static getInstance(t="default"){return L._apps||(L._apps={}),L._apps[t]||(L._apps[t]=new L),L._apps[t]}static createInstance(t="default"){return L._apps[t]=new L,L._apps[t].appName=t,L._apps[t]}static setContext(t,e="default"){L.for(e).context=t}static setAccessToken(t,e=R){L.for(e).accessToken=t}static setUser(t,e="default"){L.for(e).user=t}static setRequestSource(t,e="default"){L.for(e).requestSource=t}static setOnRedirectTo(t,e="default"){L.for(e).onRedirectTo=t}static setLogout(t,e,a="default"){const n=L.for(a);n.logout=a=>{a?t(a):n.onRedirectTo(e,void 0)}}static setEntitlementsOptions(t,e="default"){L.for(e).entitlementsOptions=t}static setSessionContext(t,e="default"){L.for(e).sessionContext=t}static setAppName(t){L.for(t).appName=t}static getContext(t="default"){var e;return null!=(e=L.for(t).context)?e:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}}static getAccessToken(t="default"){return L.for(t).accessToken}static getRequestSource(t="default"){return L.for(t).requestSource}static getBasename(t="default"){return L.for(t).basename}getBasename(){return this.basename}static setBasename(t,e=R){L.for(e).basename=t}setBasename(t){this.basename=t}static getUser(t="default"){return L.for(t).user}static onRedirectTo(t,e,a="default"){return L.for(a).onRedirectTo(t,e)}static logout(t,e="default"){return L.for(e).logout(t)}static shouldLoadEntitlements(t="default"){var e;return(null==(e=L.for(t).entitlementsOptions)?void 0:e.enabled)||!1}static isSessionPerTenantEnabled(t="default"){var e;return(null==(e=L.for(t).sessionContext)?void 0:e.enableSessionPerTenant)||!1}static getAppName(t="default"){return L.for(t).appName}}L._apps=void 0;const R="default",D={getContext:()=>L.getContext(R),getAccessToken:()=>L.getAccessToken(R),setAccessToken:t=>L.setAccessToken(t,R),getUser:()=>L.getUser(R),setUser:t=>L.setUser(t,R),onRedirectTo:(t,e)=>L.onRedirectTo(t,e,R),setOnRedirectTo:t=>L.setOnRedirectTo(t,R),logout:t=>L.logout(t,R),getRequestSource:()=>L.getRequestSource(R),setRequestSource:t=>L.setRequestSource(t,R),isSessionPerTenantEnabled:()=>L.isSessionPerTenantEnabled(R),shouldLoadEntitlements:()=>L.shouldLoadEntitlements(R),getAppName:()=>L.getAppName(R),setEntitlementsOptions:t=>L.setEntitlementsOptions(t,R),setSessionContext:t=>L.setSessionContext(t,R),getBasename:()=>L.getBasename(R),setBasename:t=>L.setBasename(t,R)};let C,N,M,F,x,$,G,j,V;!function(t){t.Microsoft="microsoft",t.Facebook="facebook",t.Google="google",t.Github="github",t.Slack="slack",t.Apple="apple",t.Linkedin="linkedin"}(C||(C={})),function(t){t.EmailAndPassword="EmailAndPassword",t.MagicLink="MagicLink",t.Code="Code",t.NoLocalAuthentication="NoLocalAuthentication",t.SmsCode="SmsCode"}(N||(N={})),function(t){t.ClientCredentials="ClientCredentials",t.AccessToken="AccessToken"}(M||(M={})),function(t){t.ACTIVE="active",t.CANCELED="canceled",t.INCOMPLETE="incomplete",t.EXPIRED="expired",t.TRIALING="trialing",t.TRIAL_ENDED="trialEnded"}(F||(F={})),function(t){t.UNKNWON="unknown",t.CARD="card"}(x||(x={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}($||($={})),function(t){t.Stripe="Stripe"}(G||(G={})),function(t){t.CHANGE_TO_DEFAULT="change_to_default",t.RETAIN_TRIAL="retain_trial"}(j||(j={})),function(t){t.CREATE="create_customer"}(V||(V={}));class B extends Error{constructor(t,e){super(t),this._statusCode=void 0,this._statusCode=e}get statusCode(){return this._statusCode}}const W={v1:"/identity/resources/users/webauthn/v1/devices"},H={v1:"/identity/resources/auth/v1",v2:"/identity/resources/auth/v2"},z={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"}}},K={v1:"/identity/resources/configurations/v1"},q={emailDomain:{v1:"/identity/resources/configurations/restrictions/v1/email-domain"},ip:{v1:"/identity/resources/configurations/v1/restrictions/ip"}},J={v1:"/identity/resources/sso/v1",v2:"/identity/resources/sso/v2",custom:{v1:"/identity/resources/sso/custom/v1"}},Y={v1:"/identity/resources/permissions/v1"},Q={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"}},X={v1:"/identity/resources/roles/v1",v2:"/identity/resources/roles/v2"},Z={v1:"/identity/resources/sub-tenants/users/v1",v2:"/identity/resources/sub-tenants/users/v2"},tt={v1:"/identity/resources/impersonation/v1"},et={v1:"/identity/resources/applications/v1"},at={v1:"/identity/resources/groups/v1",configurations:{v1:"/identity/resources/groups/v1/config"},getByIds:{v1:"/identity/resources/groups/v1/bulkGet"}},nt={v1:"/identity/resources/users/phone-numbers/v1"},st={v1:"/team/resources/sso/v1",v2:"/team/resources/sso/v2"},it={v1:"/team/resources/members/v1"},ot={v1:"/team/resources/roles/v1"},rt={v1:"/team/resources/stats/v1"},lt={v1:"/team/resources/profile"},ct={v1:"/tenants/resources/account-settings/v1"},ut={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"}},dt={v1:"/tenants/resources/sub-tenants/v1"},pt={v1:"/integrations/resources/configurations/v1",v2:"/integrations/resources/configurations/v2"},gt={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"}}}},ht={v1:"/subscriptions/resources/payment-providers/v1"},yt={v1:"/subscriptions/resources/subscriptions/v1"},St={v1:"/reports/resources/reports/v1",v2:"/reports/resources/reports/v2"},vt={v1:"/reports/engine/resources/triggers/v1"},ft="/notification",mt="/audits",bt={v1:"/event/resources/configurations/v1"},At="/webhook",wt="/oauth",Tt="/flags",Et="/directory/resources/v1/configurations/scim2",It="/directory/resources/scim/temp",Ot="/entitlements/api/v2/user-entitlements",Pt={v1:"/security-center/resources/recommendations/v1"},kt={v1:"/security-center/resources/insights/v1"},_t="/applications/resources/applications/v1",Ut={v1:"/applications/resources/applications/tenant-assignments/v1"},Lt={frameWork:"x-frontegg-framework",fronteggSdkVersion:"x-frontegg-sdk",contentType:"Content-Type",source:"frontegg-source",scopedTenant:"frontegg-scoped-tenant"};let Rt,Dt,Ct;!function(t){t.AdminPortal="admin-portal",t.LoginBox="login-box"}(Rt||(Rt={})),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"}(Dt||(Dt={})),function(t){t.ASC="ASC",t.DESC="DESC"}(Ct||(Ct={}));class Nt{constructor(t){this.appName=void 0,this.getFronteggContext=()=>L.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=Nt.getMetadataHeaders(n),i=await(null!=(e=null==n?void 0:n.tokenResolver)?e:a.getAccessToken)(),o=a.getRequestSource(),r=Nt.getScopedTenant();t&&(s[Lt.contentType]=t),o&&(s[Lt.source]=o),i&&(s.Authorization=`Bearer ${i}`),r&&(s[Lt.scopedTenant]=r);for(const t of await this.getAdditionalHeaders(n))s[`${t.key}`]=`${t.value}`;return s},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=await fetch(o,{body:t.body?"application/json"===t.contentType?JSON.stringify(t.body):t.body:null,method:null!=(e=t.method)?e:"GET",headers:v({},i,t.headers),credentials:null!=(a=null!=(n=t.credentials)?n:s.requestCredentials)?a:"same-origin"});if(302===r.status)return window.location.href=await r.text(),new Promise((()=>{}));if(!r.ok){var l,c;if(413===r.status)throw new B("Error request is too large",r.status);let t,e=!0;try{t=await r.text(),t=JSON.parse(t)}catch(t){e=!1}throw t.errors?t=t.errors.join(", "):"string"!=typeof t&&(t=`Error ${r.status} - ${r.statusText}`),r.status>=400&&r.status<500&&["warn"].includes(null!=(l=s.logLevel)?l:"")?console.warn(t):500===r.status&&["warn","error"].includes(null!=(c=s.logLevel)?c:"")&&console.error(t),new B(e?t:"We're facing some difficulties, Please try again",r.status)}if(t.responseType&&"json"!==t.responseType){if("blob"===t.responseType){const{outputFileName:e}=t.params;return await r.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 r.text()}try{return await r.json()}catch(t){return{}}},this.get=async(t,e,a)=>this.sendRequest(v({url:t,method:"GET",contentType:"application/json",params:e},a)),this.post=async(t,e,a)=>this.sendRequest(v({url:t,method:"POST",contentType:"application/json",body:e},a)),this.patch=async(t,e,a)=>this.sendRequest(v({url:t,method:"PATCH",contentType:"application/json",body:e},a)),this.put=async(t,e,a)=>this.sendRequest(v({url:t,method:"PUT",contentType:"application/json",body:e},a)),this.delete=async(t,e,a)=>this.sendRequest(v({url:t,method:"DELETE",contentType:"application/json",body:e},a)),this.postDownload=async(t,e,a,n)=>this.sendRequest(v({url:t,method:"POST",contentType:"application/json",responseType:"blob",body:e,params:a},n)),this.extractHeadersFromOptions=(t={})=>v({},t.jwt?{Authorization:t.jwt}:{}),this.getBaseUrl=(t,e,a=!0)=>Nt.getBaseUrl(t,e,a),this.getContextBaseUrl=(t,e=!0)=>{const a=this.getFronteggContext().getContext();return this.getBaseUrl(a,t,e)},this.getMetadataHeaders=t=>Nt.getMetadataHeaders(t),this.getContextMetadataHeaders=()=>{const t=this.getFronteggContext().getContext();return Nt.getMetadataHeaders(t)},this.appName=t}}Nt.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},Nt.getMetadataHeaders=t=>{var e,a;const n={};return null!=t&&null!=(e=t.metadataHeaders)&&e.fronteggSdkVersion&&(n[Lt.fronteggSdkVersion]=t.metadataHeaders.fronteggSdkVersion),null!=t&&null!=(a=t.metadataHeaders)&&a.framework&&(n[Lt.frameWork]=t.metadataHeaders.framework),n},Nt.getScopedTenant=()=>new URLSearchParams(window.location.search).get("tenantId")||null;const Mt=new Nt("default");class Ft extends Error{constructor(t){super(t)}}const xt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){const e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ft("'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 $t extends Error{constructor(t){super(t)}}const Gt=(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(xt(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 xt(e)}})(t.split(".")[a]))}catch(t){throw new $t("Invalid token specified: "+t.message)}};let jt,Vt,Bt,Wt;!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"}(Vt||(Vt={})),function(t){t.Platform="Platform",t.CrossPlatform="CrossPlatform"}(Bt||(Bt={})),function(t){t.AuthenticatorApp="AuthenticatorApp",t.WebAuthnPlatform="WebAuthnPlatform",t.WebAuthnCrossPlatform="WebAuthnCrossPlatform",t.SMS="SMS",t.EmailCode="EmailCode"}(Wt||(Wt={}));const Ht="admin_portal_should_load_authorization";let zt;!function(t){t.MISSING_PERMISSION="MISSING_PERMISSION",t.MISSING_FEATURE="MISSING_FEATURE",t.BUNDLE_EXPIRED="BUNDLE_EXPIRED"}(zt||(zt={}));const Kt="admin_portal_entitlements";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 Nt(t)}}const Jt={flags:{}};class Yt{constructor(){var t;this._flags={},this._flags=null!=(t=Jt.flags)?t:{}}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new Yt;return a.set(t),Yt._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=v({},null!=(e=null==Jt?void 0:Jt.flags)?e:{},null!=t?t:{})}}Yt._instances={};class Qt extends qt{constructor(t){super(t),this.loadFeatureFlags=async()=>this.get(Tt)}}const Xt=new Qt("default"),Zt="FRONTEGG_SEPARATE_TABS_BY_TENANT",te="admin_portal_use_current_user_tenants_v1_endpoint";class ee extends qt{constructor(t){super(t),this.GetUserJwt=async t=>this.post(`${z.v3}/me/token`,t),this.getUsersV2=async(t,e)=>this.get(z.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersV3=async(t,e)=>this.get(z.v3,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersRoles=async(t,e)=>this.get(z.roles.v3,v({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getUsersGroups=async(t,e)=>this.get(z.groups.v3,v({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getCurrentUserTenantsV3=async t=>this.get(z.tenants.me.v3,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getCurrentUserTenantsV1=async t=>this.get(z.tenants.me.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.sendResetBreachedPasswordEmails=async()=>this.post(z.passwords.resetBreachedPasswords.v1),this.updateUserProfileV2=async t=>this.put(`${z.v2}/me`,t),this.unlockMe=async t=>this.post(`${z.v3}/me/unlock`,t)}}const ae=new ee("default");function ne(t){t&&sessionStorage.setItem(Zt,t)}function se(){sessionStorage.removeItem(Zt)}function ie(t){return L.for(t).isSessionPerTenantEnabled()?sessionStorage.getItem(Zt):null}function oe(t){const e=new ee(t),[a]=Yt.getFeatureFlags([te],t);return L.for(t).isSessionPerTenantEnabled()||a?e.getCurrentUserTenantsV1:e.getCurrentUserTenantsV3}class re extends qt{constructor(t){super(t),this.switchTenant=async t=>(L.for(this.appName).isSessionPerTenantEnabled()&&ne(t.tenantId),this.put(`${z.v1}/tenant`,t)),this.getTenants=async()=>this.get(`${z.v2}/me/tenants`),this.getSubTenants=async t=>this.get(ut.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getSubTenantsAsTree=async t=>this.get(ut.tree.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenants=async t=>this.get(ut.parents.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenantsById=async(t,e)=>this.get(`${ut.parents.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getTenantsUsersCount=async(t,e)=>this.post(`${Q.users.v1}/count`,t,{headers:this.extractHeadersFromOptions(e)}),this.searchSubTenants=async(t,e)=>this.get(ut.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getHierarchyMetadata=async(t,e)=>this.get(ut.metadata.v2,v({},t,{_tenantIds:t._tenantIds.join(",")}),{headers:this.extractHeadersFromOptions(e)})}}const le=new re("default");class ce extends qt{constructor(t){super(t),this.loadEntitlementsV2=async()=>this.get(Ot)}}const ue=new ce("default");class de extends qt{constructor(t){super(t),this.getGlobalSecurityPolicy=async()=>this.get(K.v1),this.getMfaPolicy=async()=>this.get(`${K.v1}/mfa-policy`),this.getVendorMfaPolicy=async()=>this.get(`${K.v1}/mfa-policy/vendor`),this.saveMfaPolicy=async t=>t.id?this.patch(`${K.v1}/mfa-policy`,t):this.post(`${K.v1}/mfa-policy`,t),this.getLockoutPolicy=async()=>this.get(`${K.v1}/lockout-policy`),this.getVendorLockoutPolicy=async()=>this.get(`${K.v1}/lockout-policy/vendor`),this.saveLockoutPolicy=async t=>t.id?this.patch(`${K.v1}/lockout-policy`,t):this.post(`${K.v1}/lockout-policy`,t),this.getCaptchaPolicy=async()=>{try{return await this.get(`${K.v1}/captcha-policy/public`)}catch{return null}},this.getPasswordHistoryPolicy=async()=>this.get(`${K.v1}/password-history-policy`),this.getVendorPasswordHistoryPolicy=async()=>this.get(`${K.v1}/password-history-policy/vendor`),this.savePasswordHistoryPolicy=async t=>t.id?this.patch(`${K.v1}/password-history-policy`,t):this.post(`${K.v1}/password-history-policy`,t),this.getPasswordConfigPolicy=async()=>this.get(`${K.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 pe=new de("default"),ge=["type"],he=["type"],ye=["type"];class Se extends qt{constructor(t){super(t),this.tenantsApi=new re(this.appName),this.entitlementsApi=new ce(this.appName),this.securityPolicy=new de(this.appName),this.generateLoginResponse=async t=>{if(!t.accessToken)return t;const e=L.for(this.appName);e.setAccessToken(t.accessToken);const a=await this.getMeAndEntitlements(),n=v({},t,t.accessToken?Gt(t.accessToken):{},a);return e.setUser(n),n},this.generateLoginResponseV2=async t=>{if(!t.accessToken)return{user:t};const e=L.for(this.appName);e.setAccessToken(t.accessToken);const[a,n]=await Promise.all([this.getMeAndEntitlements(),this.tenantsApi.getTenants()]),s=v({},t,t.accessToken?Gt(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=L.for(this.appName);a.setAccessToken(e);const[n,s]=await Promise.all([this.getMeAndEntitlements(),oe(this.appName)()]),i=v({},t,e?Gt(e):{},n);return a.isSessionPerTenantEnabled()&&ne(i.tenantId),a.setUser(i),{user:i,tenants:s.tenants,activeTenant:s.activeTenant}},this.generateLoginResponseFromOAuthResponse=async t=>{const e=L.for(this.appName);e.setAccessToken(t.id_token);const a=await this.getMeAndEntitlements(),n=t.id_token?Gt(t.id_token):{},s=v({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=L.for(this.appName);e.setAccessToken(t.id_token);const[a,n]=await Promise.all([this.getMeAndEntitlements(),oe(this.appName)()]),s=t.id_token?Gt(t.id_token):{},i=v({mfaRequired:!1,accessToken:t.id_token,refreshToken:t.refresh_token},s,a,{expiresIn:t.expires_in||300});return e.isSessionPerTenantEnabled()&&ne(i.tenantId),e.setUser(i),{user:i,tenants:n.tenants,activeTenant:n.activeTenant}},this.preLogin=async t=>{try{const{address:e}=await this.post(`${H.v1}/user/saml/prelogin`,t);return e}catch{return null}},this.preLoginWithIdpType=async t=>this.post(`${H.v1}/user/saml/prelogin`,t),this.postLogin=async t=>{const e=await this.post(`${H.v1}/user/saml/postlogin`,t);return this.generateLoginResponse(e)},this.oidcPostLogin=async t=>{const e=await this.post(`${H.v1}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.login=async t=>{const e=await this.post(`${H.v1}/user`,t);return this.generateLoginResponse(e)},this.loginv2=async t=>{const e=await this.post(`${H.v1}/user`,t);return this.generateLoginResponseV3(e)},this.loginWithMfa=async t=>{const e=await this.post(`${H.v1}/user/mfa/verify`,t);return this.generateLoginResponse(e)},this.loginWithMfaV2=async t=>{const e=await this.post(`${H.v1}/user/mfa/verify`,t);return this.generateLoginResponseV3(e)},this.activateAccount=async t=>this.post(`${z.v1}/activate`,t),this.activateAccountV2=async t=>{const e=await this.post(`${z.v1}/activate`,t);return this.generateLoginResponseV3(e)},this.getActivateAccountStrategy=async t=>this.get(`${z.v1}/activate/strategy`,t),this.resendActivationEmail=async t=>this.post(`${z.v1}/activate/reset`,t),this.resendInvitationEmail=async t=>this.post(`${z.v1}/invitation/reset`,t),this.acceptInvitation=async t=>this.post(`${z.v1}/invitation/accept`,t),this.refreshToken=async()=>{const t=ie(this.appName),e=await this.post(`${H.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponse(e)},this.refreshTokenV2=async()=>{const t=ie(this.appName),e=await this.post(`${H.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV2(e)},this.refreshTokenV3=async()=>{const t=ie(this.appName),e=await this.post(`${H.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV3(e)},this.logout=async()=>this.post(`${H.v1}/logout`),this.OAuthLogout=async t=>this.get(`${wt}/logout`,t),this.forgotPassword=async t=>this.post(`${z.v1}/passwords/reset`,t),this.resetPassword=async t=>this.post(`${z.v1}/passwords/reset/verify`,t),this.loadPasswordConfig=async t=>this.get(`${z.v1}/passwords/config`,t),this.recoverMfaToken=async t=>this.post(`${H.v1}/user/mfa/recover`,t),this.enrollMfa=async()=>this.post(`${z.v1}/mfa/enroll`),this.preEnrollMFAAuthenticatorApp=async()=>this.post(`${z.v1}/mfa/authenticator/enroll`),this.enrollMFAAuthenticatorApp=async t=>this.post(`${z.v1}/mfa/authenticator/enroll/verify`,t),this.preEnrollMFASMS=async t=>this.post(`${z.v1}/mfa/sms/enroll`,t),this.enrollMFASMS=async t=>this.post(`${z.v1}/mfa/sms/enroll/verify`,t),this.preEnrollMFAWebAuthn=async()=>this.post(`${z.v1}/mfa/webauthn/enroll`),this.enrollMFAWebAuthn=async t=>this.post(`${z.v1}/mfa/webauthn/enroll/verify`,t),this.verifyMfa=async t=>this.post(`${z.v1}/mfa/enroll/verify`,t),this.disableMfa=async t=>this.post(`${z.v1}/mfa/disable`,t),this.disableMFAAuthenticatorApp=async(t,e)=>this.post(`${z.v1}/mfa/authenticator/${t}/disable/verify`,e),this.preDisableMFASMS=async t=>this.post(`${z.v1}/mfa/sms/${t}/disable`),this.disableMFASMS=async(t,e)=>this.post(`${z.v1}/mfa/sms/${t}/disable/verify`,e),this.preDisableMFAWebAuthn=async t=>this.post(`${z.v1}/mfa/webauthn/${t}/disable`),this.disableMFAWebAuthn=async(t,e)=>this.post(`${z.v1}/mfa/webauthn/${t}/disable/verify`,e),this.getMFADevices=async()=>this.get(`${z.v1}/mfa/devices`),this.preEnrollMFAAuthenticatorAppForLogin=async t=>this.post(`${H.v1}/user/mfa/authenticator/enroll`,t),this.enrollMFAAuthenticatorAppForLogin=async t=>this.post(`${H.v1}/user/mfa/authenticator/enroll/verify`,t),this.enrollMFAAuthenticatorAppForLoginV2=async t=>{const e=await this.post(`${H.v1}/user/mfa/authenticator/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.verifyMFAAuthenticatorAppForLogin=async(t,e)=>this.post(`${H.v1}/user/mfa/authenticator/${t}/verify`,e),this.preVerifyMFAEmailCode=async t=>this.post(`${H.v1}/user/mfa/emailcode`,t),this.verifyMFAEmailCode=async t=>this.post(`${H.v1}/user/mfa/emailcode/verify`,t),this.verifyMFAEmailCodeV2=async t=>{const e=await this.post(`${H.v1}/user/mfa/emailcode/verify`,t);return this.generateLoginResponseV3(e)},this.preEnrollMFASMSForLogin=async t=>this.post(`${H.v1}/user/mfa/sms/enroll`,t),this.enrollMFASMSForLogin=async t=>this.post(`${H.v1}/user/mfa/sms/enroll/verify`,t),this.enrollMFASMSForLoginV2=async t=>{const e=await this.post(`${H.v1}/user/mfa/sms/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFASMSForLogin=async(t,e)=>this.post(`${H.v1}/user/mfa/sms/${t}`,e),this.verifyMFASMSForLogin=async(t,e)=>this.post(`${H.v1}/user/mfa/sms/${t}/verify`,e),this.verifyMFASMSForLoginV2=async(t,e)=>{const a=await this.post(`${H.v1}/user/mfa/sms/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.preEnrollMFAWebAuthnForLogin=async t=>this.post(`${H.v1}/user/mfa/webauthn/enroll`,t),this.enrollMFAWebAuthnForLogin=async t=>this.post(`${H.v1}/user/mfa/webauthn/enroll/verify`,t),this.enrollMFAWebAuthnForLoginV2=async t=>{const e=await this.post(`${H.v1}/user/mfa/webauthn/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${H.v1}/user/mfa/webauthn/${t}`,e),this.verifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${H.v1}/user/mfa/webauthn/${t}/verify`,e),this.verifyMFAWebAuthnForLoginV2=async(t,e)=>{const a=await this.post(`${H.v1}/user/mfa/webauthn/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.getSamlConfiguration=async()=>this.get(`${st.v1}/saml/configurations`),this.updateSamlConfiguration=async t=>this.post(`${st.v1}/saml/configurations`,t),this.getSamlVendorConfiguration=async()=>this.get(`${st.v1}/saml/configurations/vendor-config`),this.updateSamlVendorMetadata=async t=>this.put(`${st.v1}/saml/configurations/metadata`,t),this.validateSamlDomain=async()=>this.put(`${st.v1}/saml/validations/domain`),this.getSamlRoles=async()=>this.get(`${st.v1}/saml/configurations/roles/default`),this.getSamlRolesGroups=async()=>this.get(`${st.v2}/saml/configurations/groups`),this.updateSamlRoles=async({roleIds:t})=>this.post(`${st.v1}/saml/configurations/roles/default`,{roleIds:t}),this.createSamlGroup=async({roleIds:t,group:e})=>this.post(`${st.v2}/saml/configurations/groups`,{group:e,roleIds:t}),this.updateSamlGroup=async({roleIds:t,group:e,id:a})=>this.patch(`${st.v2}/saml/configurations/groups/${a}`,{group:e,roleIds:t}),this.deleteSamlGroup=async({id:t})=>this.delete(`${st.v2}/saml/configurations/groups/${t}`),this.getOidcConfiguration=async()=>this.get(`${st.v1}/oidc/configurations`),this.getSSOPublicConfiguration=async()=>this.get(`${st.v2}/configurations/public`),this.getSocialLoginProviders=async()=>this.get(J.v1),this.getSocialLoginProvidersV2=async()=>this.get(J.v2),this.getSocialLoginProvidersV2ForAuthenticatedUser=async()=>this.get(`${J.v2}/authenticated`),this.getCustomSocialLoginProvidersV1=async()=>this.get(J.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.state&&(e.state=t.state),this.post(`${H.v1}/user/sso/${t.provider}/postlogin`,{metadata:t.metadata,invitationToken:t.invitationToken},{params:e})},this.getVendorConfig=async()=>this.get(`${K.v1}/public`),this.signUpUser=async t=>{const{shouldActivate:e,authResponse:a,userId:n,tenantId:s}=await this.post(`${z.v1}/signUp`,t),i={shouldActivate:e,userId:n,tenantId:s};if(!e&&a){const{user:t,tenants:e,activeTenant:n}=await this.generateLoginResponseV3(a);return v({},i,{user:t,tenants:e,activeTenant:n})}return i},this.getCurrentUserSessions=async()=>this.get(z.sessions.currentUser.v1),this.getCurrentUserSession=async()=>this.get(`${z.sessions.currentUser.v1}/current`),this.revokeSessionsForUser=async t=>this.post(`${z.sessions.v1}/revoke`,{userId:t}),this.getSessionConfigurations=async()=>this.get(z.sessions.configurations.v1),this.createOrUpdateSessionConfigrations=async t=>{await this.post(z.sessions.configurations.v1,t)},this.deleteSessionForUser=async t=>{await this.delete(`${z.sessions.currentUser.v1}/${t}`)},this.deleteAllSessionsForUser=async()=>{await this.delete(`${z.sessions.currentUser.v1}/all`)},this.getUserAccessTokensData=async()=>this.get(z.accessTokens.v1),this.getTenantAccessTokensData=async()=>this.get(Q.accessTokens.v1),this.deleteTenantAccessToken=async({id:t})=>{await this.delete(`${Q.accessTokens.v1}/${t}`)},this.deleteUserAccessToken=async({id:t})=>{await this.delete(`${z.accessTokens.v1}/${t}`)},this.createUserAccessToken=async t=>this.post(z.accessTokens.v1,t),this.createTenantAccessToken=async t=>this.post(Q.accessTokens.v1,t),this.getUserApiTokensData=async()=>this.get(z.apiTokens.v1),this.getTenantApiTokensData=async()=>this.get(Q.apiTokens.v1),this.updateUserApiTokensData=async t=>this.post(z.apiTokens.v1,t),this.updateTenantApiTokensData=async t=>this.post(Q.apiTokens.v2,t),this.deleteTenantApiToken=async({tokenId:t})=>{await this.delete(`${Q.apiTokens.v1}/${t}`)},this.deleteUserApiToken=async({tokenId:t})=>{await this.delete(`${z.apiTokens.v1}/${t}`)},this.getUserById=async({userId:t})=>this.get(`${z.v1}/${t}`),this.checkIfAllowToRememberMfaDevice=async t=>this.get(`${K.v1}/mfa-policy/allow-remember-device`,{mfaToken:t}),this.passwordlessPreLogin=async t=>{let{type:e}=t,a=f(t,ge);return this.post(`${H.v1}/passwordless/${e.toLocaleLowerCase()}/prelogin`,a)},this.passwordlessPostLoginV2=async t=>{let{type:e}=t,a=f(t,he);const n=await this.post(`${H.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a);return this.generateLoginResponseV3(n)},this.passwordlessPostLogin=async t=>{let{type:e}=t,a=f(t,ye);return this.post(`${H.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a)},this.verifyInviteToken=async({token:t})=>this.post(Q.invites.verify.v1,{token:t}),this.getSSOConfigurations=async()=>this.get(`${st.v1}/configurations`),this.createSSOConfiguration=async t=>this.post(`${st.v1}/configurations`,t),this.updateSSOConfiguration=async(t,e)=>this.patch(`${st.v1}/configurations/${t}`,e),this.deleteSSOConfiguration=async t=>{await this.delete(`${st.v1}/configurations/${t}`)},this.createSSOConfigurationByMetadata=async t=>this.post(`${st.v1}/configurations/metadata`,t),this.updateSSOConfigurationByMetadata=async(t,e)=>this.put(`${st.v1}/configurations/${t}/metadata`,e),this.createSSOConfigurationByMetadataUrl=async t=>this.post(`${st.v1}/configurations/metadata-url`,t),this.updateSSOConfigurationByMetadataUrl=async(t,e)=>this.put(`${st.v1}/configurations/${t}/metadata-url`,e),this.createSSODomain=async(t,e)=>this.post(`${st.v1}/configurations/${t}/domains`,e),this.deleteSSODomain=async(t,e)=>this.delete(`${st.v1}/configurations/${t}/domains/${e}`),this.validateSSODomain=async(t,e)=>this.put(`${st.v1}/configurations/${t}/domains/${e}/validate`),this.validateSSODomainV2=async(t,e)=>this.put(`${st.v2}/configurations/${t}/domains/${e}/validate`),this.getSSODefaultRoles=async t=>this.get(`${st.v1}/configurations/${t}/roles`),this.setSSODefaultRoles=async(t,e)=>this.put(`${st.v1}/configurations/${t}/roles`,e),this.createSSOGroup=async(t,e)=>this.post(`${st.v1}/configurations/${t}/groups`,e),this.updateSSOGroup=async(t,{roleIds:e,group:a,id:n})=>this.patch(`${st.v1}/configurations/${t}/groups/${n}`,{group:a,roleIds:e}),this.deleteSSOGroup=async(t,e)=>this.delete(`${st.v1}/configurations/${t}/groups/${e}`),this.getSSOGroups=async t=>this.get(`${st.v1}/configurations/${t}/groups`),this.preLoginV2=async t=>this.post(`${H.v2}/user/sso/prelogin`,t),this.oidcPostLoginV2=async t=>{const e=await this.post(`${H.v2}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.exchangeOAuthTokensV2=async t=>{const e=await this.post(`${wt}/token`,t);return this.generateLoginResponseFromOAuthResponseV2(e)},this.silentOAuthRefreshTokenV2=async()=>{const t=ie(this.appName),e=await this.post(`${wt}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponseV2(e)},this.exchangeOAuthTokens=async t=>{const e=await this.post(`${wt}/token`,t);return this.generateLoginResponseFromOAuthResponse(e)},this.silentOAuthRefreshToken=async()=>{const t=ie(this.appName),e=await this.post(`${wt}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponse(e)},this.resetPhoneNumber=async t=>this.post(`${z.v1}/phone/reset`,t),this.verifyResetPhoneNumber=async t=>this.post(`${z.v1}/phone/reset/verify`,t),this.changePhoneNumberWithVerification=async t=>this.post(`${z.v1}/phone`,t),this.verifyChangePhoneNumber=async t=>this.post(`${z.v1}/phone/verify`,t),this.changePhoneNumber=async t=>this.put(`${z.v1}/phone/change`,t),this.webAuthnPreLogin=async t=>this.post(`${H.v1}/webauthn/prelogin`,t),this.webAuthnPostLogin=async t=>this.post(`${H.v1}/webauthn/postlogin`,t),this.webAuthnPostLoginV2=async t=>{const e=await this.post(`${H.v1}/webauthn/postlogin`,t);return this.generateLoginResponseV3(e)},this.webAuthnCreateNewDeviceSession=async()=>this.post(W.v1),this.getWebAuthnDevices=async()=>this.get(W.v1),this.deleteWebAuthnDevice=async t=>this.delete(`${W.v1}/${t}`),this.verifyNewDeviceSession=async t=>this.post(`${W.v1}/verify`,t),this.getVendorPublicAuthStrategiesConfig=async()=>this.get(`${K.v1}/auth/strategies/public`),this.getPublicAuthStrategiesConfigForAuthenticatedUser=async()=>this.get(`${K.v1}/auth/strategies`),this.getMFAStrategiesConfig=async()=>this.get(`${K.v1}/mfa/strategies`),this.getUserAuthorization=async()=>this.get(`${z.authorization.v1}`),this.getMeV2=async()=>this.get(`${z.v2}/me`),this.noThrowLoadEntitlements=async()=>{try{return await this.entitlementsApi.loadEntitlementsV2()}catch(t){}},this.getMeAndEntitlements=async()=>{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=ie(this.appName);return s&&(e.tenantId=s),v({},e,null!=n?n:{},{entitlements:a})},this.generateStepupSession=async t=>{const e=await this.post(`${H.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(){if(!L.for(this.appName).shouldLoadEntitlements())return!1;const[t]=Yt.getFeatureFlags([Kt],this.appName||"");return t}shouldLoadMeAuthorization(){const[t]=Yt.getFeatureFlags([Ht],this.appName);return t}}const ve=new Se("default");class fe extends qt{constructor(t){super(t),this.getProfile=async t=>this.get(`${z.v2}/me`,null!=t?t:{addRoles:!0}),this.updateProfile=async t=>this.put(`${z.v2}/me`,t),this.updateProfileImage=async t=>this.put(`${lt.v1}/me/image/v1`,t,{responseType:"plain",contentType:void 0}),this.changePassword=async t=>this.post(`${z.v1}/passwords/change`,t),this.loadUsers=async t=>{var e,a,n,s,i,o;const r=(t.filter||[]).reduce(((t,e)=>v({},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(it.v1,v({pageOffset:t.pageOffset,pageSize:t.pageSize},r,l))},this.addUser=async t=>this.post(z.v2,v({},t,{provider:"local"})),this.deleteUser=async t=>this.delete(`${it.v1}/${t.userId}`),this.updateUser=async t=>this.put(it.v1,t),this.updateUserExpirationTime=async t=>{const{userId:e,expirationInSeconds:a}=t;return this.put(`${z.temporary.v1}/${e}`,{expirationInSeconds:a})},this.setPermanentUser=async t=>this.delete(`${z.temporary.v1}/${t}`),this.getTemporaryUserConfiguration=async()=>this.get(z.temporary.configuration.v1),this.createInviteUserLink=async t=>this.post(Q.invites.user.v1,v({},t)),this.updateInviteUserLink=async t=>this.patch(Q.invites.user.v1,v({},t)),this.deleteInviteUserLink=async()=>this.delete(Q.invites.user.v1),this.getInviteUserLink=async()=>this.get(Q.invites.user.v1),this.getInviteLinkConfiguration=async()=>this.get(Q.invites.configuration.v1),this.loadAvailableRoles=async()=>this.get(ot.v1),this.loadAvailablePermissions=async()=>this.get(Y.v1),this.loadStats=async()=>this.get(`${rt.v1}/members`),this.resendActivationLink=async t=>this.post(`${it.v1}/${t.userId}/resendActivationEmail`,{}),this.resendInvitationLink=async t=>this.post(z.v2,v({},t,{provider:"local"})),this.resendInvitationLinkToAllTenants=async t=>this.post(z.invitation.resendAll.v1,v({},t)),this.disableUser=async t=>this.post(`${Q.users.v1}/${t}/disable`),this.enableUser=async t=>this.post(`${Q.users.v1}/${t}/enable`)}}const me=new fe("default");class be 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 Ae=new be("default"),we=["dataFilters"],Te=["templateId","dataFilters"],Ee=["dataFilters"];class Ie extends qt{constructor(t){super(t),this.getReports=async t=>this.get(`${St.v2}/tenant-reports`,t),this.getReport=async t=>this.get(`${St.v2}/${t.id}/tenant-reports`),this.renderReport=async t=>{let{dataFilters:e}=t,a=f(t,we);return{html:await this.get(`${vt.v1}/preview-report`,v({},a,{dataFilters:btoa(JSON.stringify(e||{})),responseType:"html"}),{responseType:"plain"})}},this.scheduleReport=async t=>{let{templateId:e,dataFilters:a}=t,n=f(t,Te);return this.post(`${St.v2}/${e}/tenant-reports`,v({},n,{dataFilters:btoa(JSON.stringify(a||{}))}))},this.downloadReport=async t=>{let{dataFilters:e}=t,a=f(t,Ee);const n=await this.get(`${vt.v1}/preview-report`,v({},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(`${vt.v1}/tenant-reports`,t)}}const Oe=new Ie("default"),Pe=["eventKey"],ke=["eventKey"];class _e extends qt{constructor(t){super(t),this.getSlackConfiguration=()=>this.get(`${pt.v1}/slack`),this.getSlackScope=()=>this.get(`${pt.v1}/slack/applications`),this.getSlackChannels=()=>this.get(`${pt.v1}/slack/channels`),this.postSlackConfiguration=t=>t.id?this.patch(`${pt.v1}/slack/subscription/${t.id}`,t):this.post(`${pt.v1}/slack/subscriptions`,t),this.deleteSlackConfiguration=t=>this.delete(`${pt.v1}/slack/subscriptions/${t.id}`),this.postSlackCode=t=>this.post(`${pt.v1}/slack/applications/registrations`,{code:t}),this.getEmailConfiguration=()=>this.get(`${pt.v1}/emails`),this.postEmailConfiguration=t=>{let{eventKey:e}=t,a=f(t,Pe);return this.post(`${pt.v1}/emails/${e}`,a)},this.patchEmailConfiguration=({eventKey:t,enabled:e})=>this.patch(`${pt.v1}/emails/${t}`,{enabled:e}),this.deleteEmailSubscriptions=(t,e)=>this.delete(`${pt.v1}/emails/${t}/subscriptions/${e}`),this.putEmailSubscriptions=(t,e,a)=>this.put(`${pt.v1}/emails/${e}/subscriptions/${t}`,a),this.deleteEmailConfiguration=t=>this.delete(`${pt.v1}/emails/${t}`),this.getSMSConfiguration=()=>this.get(`${pt.v2}/sms`),this.postSMSConfiguration=t=>{let{eventKey:e}=t,a=f(t,ke);return this.post(`${pt.v2}/sms/${e}`,a)},this.patchSMSConfiguration=({eventKey:t,enabled:e})=>this.patch(`${pt.v2}/sms/${t}`,{enabled:e}),this.deleteSMSSubscriptions=(t,e)=>this.delete(`${pt.v2}/sms/${t}/subscriptions/${e}`),this.putSMSSubscriptions=(t,e,a)=>this.put(`${pt.v2}/sms/${e}/subscriptions/${t}`,a),this.deleteSMSConfiguration=t=>this.delete(`${pt.v2}/sms/${t}`),this.getWebhooksConfigurations=()=>this.get(At),this.postWebhooksConfiguration=t=>t._id?this.patch(`${At}/${t._id}`,t):this.post(`${At}/custom`,t),this.deleteWebhooksConfiguration=t=>this.delete(`${At}/${t}`),this.getWebhookLog=(t,e=0,a=10)=>{const n=new URLSearchParams({id:t,offset:`${e}`,limit:`${a}`});return this.get(`${At}/logs/?${n.toString()}`)},this.postWebhookTest=t=>this.post(`${At}/test`,t),this.postWebhookRetry=t=>this.post(`${At}/logs/${t}/retries`),this.getCategories=()=>this.get(`${bt.v1}/categories`),this.getChannelMaps=t=>this.get(bt.v1,{channels:t})}}const Ue=new _e("default");class Le extends qt{constructor(t){super(t),this.getNotifications=async t=>this.get(ft,{params:t}),this.updateNotificationStatus=async t=>this.put(`${ft}/status`,{params:t}),this.updateNotificationIsPinned=async t=>{const{notificationId:e,pinStatus:a}=t;return this.put(`${ft}/${a}`,{notificationId:e})},this.markAllAsRead=async()=>this.post(`${ft}/status/mark-all-read`)}}const Re=new Le("default"),De=["endpoint","headerProps"];class Ce extends qt{constructor(t){super(t),this.getAudits=async t=>this.get(mt,t),this.getAuditsStats=async t=>this.get(`${mt}/stats`,t),this.exportAudits=async t=>{const{endpoint:e,headerProps:a}=t,n=f(t,De);return this.postDownload(`${mt}/export/${e}`,{properties:a},n)}}}const Ne=new Ce("default");class Me extends qt{constructor(t){super(t),this.updateSettings=async(t,e)=>this.put(ct.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.getSettings=async t=>this.get(ct.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getPublicSettings=async()=>this.get(`${ct.v1}/public`)}}const Fe=new Me("default"),xe=["roleId"],$e=["roleId"],Ge=["permissionId"];class je extends qt{constructor(t){super(t),this.getRoles=async()=>this.get(X.v1),this.addRole=async t=>this.post(X.v1,t),this.deleteRole=async({roleId:t})=>this.delete(`${X.v1}/${t}`),this.updateRole=async t=>{let{roleId:e}=t,a=f(t,xe);return this.patch(`${X.v1}/${e}`,a)},this.attachPermissionsToRole=async t=>{let{roleId:e}=t,a=f(t,$e);return this.put(`${X.v1}/${e}/permissions`,a)},this.getPermissions=async()=>this.get(Y.v1),this.attachPermissionToRoles=async t=>{let{permissionId:e}=t,a=f(t,Ge);return this.put(`${Y.v1}/${e}/roles`,a)},this.getPermissionCategories=async()=>this.get(`${Y.v1}/categories`),this.addRoleV2=async t=>this.post(X.v2,t)}}const Ve=new je("default");class Be extends qt{constructor(...t){super(...t),this.getSubscriptionInvoices=async()=>this.get(gt.invoices.v1),this.getSubscriptionInvoice=async t=>this.get(`${gt.invoices.v1}/${t}`),this.getSubscriptionInvoicePdf=async(t,e)=>this.get(`${gt.invoices.v1}/${t}/pdf`,{outputFileName:e},{responseType:"blob"})}}class We extends qt{constructor(...t){super(...t),this.getManagedSubscription=async t=>this.get(`${yt.v1}/${t}`),this.getManagedSubscriptions=async()=>this.get(yt.v1),this.cancelManagedSubscription=async t=>this.put(`${yt.v1}/${t}/cancellations/`,{}),this.renewManagedSubscription=async t=>this.put(`${yt.v1}/${t}/renewals/`,{}),this.updateManagedSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${yt.v1}/${t}`,{paymentMethodId:e,planId:a})}}const He=["email"];class ze extends qt{constructor(...t){super(...t),this.getPaymentMethods=async()=>this.get(gt.paymentMethods.v1),this.getPaymentMethod=async t=>this.get(`${gt.paymentMethods.v1}/${t}`),this.updatePaymentMethodBillingDetails=async(t,e)=>{let{email:a}=e,n=f(e,He);return this.patch(`${gt.paymentMethods.v1}/${t}/billing-details`,{email:a,address:n})}}}class Ke extends qt{constructor(...t){super(...t),this.getPaymentProviders=async()=>this.get(ht.v1)}}class qe extends qt{constructor(...t){super(...t),this.getSubscriptionPlans=async()=>this.get(gt.plans.v1),this.getSubscriptionPlan=async t=>this.get(`${gt.plans.v1}/${t}`)}}class Je extends qt{constructor(...t){super(...t),this.getSubscriptions=async()=>this.get(gt.subscriptions.v1),this.getSubscription=async t=>this.get(`${gt.subscriptions.v1}/${t}`),this.cancelSubscription=async t=>this.put(`${gt.subscriptions.v1}/${t}/cancellations/`,{}),this.renewSubscription=async t=>this.put(`${gt.subscriptions.v1}/${t}/renewals/`,{}),this.updateSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${gt.subscriptions.v1}/${t}`,{paymentMethodId:e,planId:a})}}class Ye extends qt{constructor(...t){super(...t),this.getSubscriptionSummaries=async t=>this.get(`${gt.summaries.v1}/${t}`)}}class Qe extends qt{constructor(...t){super(...t),this.getTenantConfiguration=async t=>this.get(`${gt.tenantConfiguration.v1}/${t}`),this.createTenantConfiguration=async t=>this.post(gt.tenantConfiguration.v1,t)}}class Xe extends qt{constructor(...t){super(...t),this.getVendorPublicConfigurations=async()=>this.get(gt.configurations.vendorPublicConfigurations.v1)}}class Ze extends qt{constructor(...t){super(...t),this.createSubscription=async t=>this.post(gt.paymentProviders.stripe.subscriptions.v1,t),this.getStripeCustomer=async t=>this.get(`${gt.paymentProviders.stripe.customers.v1}/${t}`),this.createStripeCustomer=async t=>this.post(gt.paymentProviders.stripe.customers.v1,t),this.getStripePaymentProviderConfiguration=async()=>this.get(gt.paymentProviders.stripe.publicConfigurations.v1),this.createStripePaymentMethodSetupIntentSecret=async t=>this.post(gt.paymentProviders.stripe.setupIntents.v1,t)}}class ta extends qt{constructor(t){super(t),this.invoicesApi=new Be(this.appName),this.managedSubscriptionApi=new We(this.appName),this.paymentMethodsApi=new ze(this.appName),this.paymentProvidersApi=new Ke(this.appName),this.plansApi=new qe(this.appName),this.subscriptionApi=new Je(this.appName),this.summariesApi=new Ye(this.appName),this.subscriptionTenantConfigApi=new Qe(this.appName),this.vendorPublicConfigApi=new Xe(this.appName),this.stripeProviderApi=new Ze(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 ea=new ta("default");class aa extends qt{constructor(t){super(t),this.getVendorPublicInfo=async()=>this.get("/vendors/public")}}const na=new aa("default");class sa extends qt{constructor(t){super(t),this.loadAllUsers=async t=>this.get(Z.v1,t),this.addUserToTenantAndSubTenants=async t=>this.post(Z.v1,t),this.removeUserFromTenantAndSubTenants=async(t,e)=>this.delete(Z.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.addUserRolesForSubTenants=async(t,e,a)=>this.post(`${Z.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.removeUserRolesFromSubTenants=async(t,e,a)=>this.delete(`${Z.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.setUserRolesForSubTenants=async(t,e,a)=>this.patch(`${Z.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.createSubTenant=async(t,e)=>this.post(dt.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.deleteSubTenant=async(t,e)=>this.delete(`${dt.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.updateSubTenant=async({tenantId:t},e,a)=>this.patch(`${dt.v1}/${t}`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubTenantManagement=async({tenantId:t},e,a)=>this.put(`${dt.v1}/${t}/management`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubAccountAccess=async(t,e,a)=>this.put(`${Z.v1}/${t}/access`,e,{headers:this.extractHeadersFromOptions(a)}),this.addUsersToSubTenant=async(t,e)=>this.post(`${Z.v2}/`,t,{headers:this.extractHeadersFromOptions(e)})}updateSubTenantHierarchySettings({tenantId:t},e,a){return this.put(`${dt.v1}/${t}/hierarchy-settings`,e,{headers:this.extractHeadersFromOptions(a)})}}const ia=new sa("default");class oa extends qt{constructor(t){super(t),this.getConfigs=async()=>this.get(`${Et}`),this.updateConfiguration=async(t,e)=>this.patch(`${Et}/${t}`,e),this.createConfiguration=async t=>this.post(`${Et}`,t),this.deleteConfiguration=async t=>this.delete(`${Et}/${t}`),this.countConfigurationUsers=async t=>this.get(`${It}/${t}/Users/count`)}}const ra=new oa("default");class la extends qt{constructor(t){super(t),this.impersonate=async t=>this.post(`${tt.v1}`,t)}}const ca=new la("default"),ua=["groupId"];class da extends qt{constructor(t){super(t),this.getGroupById=async({groupId:t},e)=>this.get(`${at.v1}/${t}`,v({},e)),this.getGroups=async t=>this.get(`${at.v1}`,v({},t)),this.getGroupsByIds=async(t,e)=>this.post(`${at.getByIds.v1}`,t,{params:e}),this.createGroup=async t=>this.post(`${at.v1}`,t),this.updateGroup=async t=>{let{groupId:e}=t,a=f(t,ua);return this.patch(`${at.v1}/${e}`,a)},this.deleteGroup=async t=>this.delete(`${at.v1}/${t}`),this.addRolesToGroup=async(t,e)=>this.post(`${at.v1}/${t}/roles`,e),this.deleteRolesFromGroup=async(t,e)=>this.delete(`${at.v1}/${t}/roles`,e),this.addUsersToGroup=async(t,e)=>this.post(`${at.v1}/${t}/users`,e),this.deleteUsersFromGroup=async(t,e)=>this.delete(`${at.v1}/${t}/users`,e),this.getGroupConfiguration=async()=>this.get(`${at.configurations.v1}`),this.updateGroupConfiguration=async t=>this.post(`${at.configurations.v1}`,t)}}const pa=new da("default");class ga extends qt{constructor(t){super(t),this.getRecommendations=async()=>this.get(Pt.v1),this.getInsights=async()=>this.get(kt.v1)}}const ha=new ga("default");class ya extends qt{constructor(t){super(t),this.getUserPhoneNumbers=async t=>this.get(`${nt.v1}`,t),this.createPhoneNumber=async t=>this.post(`${nt.v1}`,t),this.deletePhoneNumber=async t=>this.delete(`${nt.v1}/${t}`),this.preVerifyPhoneNumber=async t=>this.post(`${nt.v1}/preverify`,t),this.verifyPhoneNumber=async t=>this.post(`${nt.v1}/verify`,t),this.verifyDeletePhoneNumber=async(t,e)=>this.post(`${nt.v1}/${t}/delete/verify`,e)}}const Sa=new ya("default");class va extends qt{constructor(t){super(t),this.getUserApplicationsId=async({userId:t})=>this.get(`${et.v1}/${t}/apps`),this.getUsersApplicationsId=async({userIds:t})=>this.get(`${et.v1}/users-apps`,{userIds:t.join(",")}),this.getTenantsApplications=async()=>this.get(Ut.v1),this.getApplicationsData=async({appIds:t,includeFreeAccess:e=!0})=>this.get(_t,{ids:t.join(","),_includeFreeAccess:e}),this.assignUserToApplications=async t=>this.post(`${et.v1}/apps-user`,t),this.unassignUserFromApplications=async t=>this.delete(`${et.v1}/user-apps`,t),this.getUsersOfApplications=async({appIds:t})=>this.get(`${et.v1}/apps-users`,{appIds:t.join(",")})}}const fa=new va("default");let ma,ba,Aa,wa,Ta;!function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}(ma||(ma={})),function(t){t.createdAt="createdAt",t.name="name",t.tenantId="tenantId"}(ba||(ba={})),function(t){t.CUSTOMER="customer",t.SPAM="spam",t.TEST="test",t.RESELLER="reseller",t.HEADQUARTER="headquarter"}(Aa||(Aa={})),function(t){t.NEVER="NEVER",t.ALWAYS="ALWAYS",t.ASSIGNABLE="ASSIGNABLE"}(wa||(wa={})),function(t){t.DEFAULT_OFF="defaultOff",t.DEFAULT_ON="defaultOn",t.ALWAYS_ON="alwaysOn"}(Ta||(Ta={}));const Ea=[/^(.*)\/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]*$/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],Ia=`${H.v1}/user/token/refresh`,Oa=`${wt}/authorize/silent`,Pa=`${z.v2}/me`,ka=`${z.v2}/me/tenants`,_a=`${z.v3}/me/tenants`,Ua=Ot;let La,Ra,Da,Ca,Na;!function(t){t.FRONTEGG="frontegg",t.OKTA="okta",t.AZURE_AD="azure-ad",t.OTHER="other"}(La||(La={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(Ra||(Ra={})),function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}(Da||(Da={})),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"}(Ca||(Ca={})),function(t){t.MFA_UNENROLLED="mfa-unenrolled",t.BREACHED_PASSWORDS="breached-passwords",t.INACTIVE="inactive"}(Na||(Na={}));const Ma=["local","saml","google","github","facebook","microsoft","scim2","slack"];let Fa,xa,$a,Ga,ja,Va;!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"}(Fa||(Fa={})),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"}(xa||(xa={})),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"}($a||($a={})),function(t){t.SEVERE="SEVERE",t.WARNING="WARNING",t.INFO="INFO"}(Ga||(Ga={})),function(t){t.MFA="MFA",t.SESSIONS="SESSIONS",t.PASSWORD="PASSWORD",t.INACTIVITY="INACTIVITY",t.IP="IP",t.DOMAIN="DOMAIN",t.SSO="SSO"}(ja||(ja={})),function(t){t.FREE_ACCESS="FREE_ACCESS",t.MANAGED_ACCESS="MANAGED_ACCESS"}(Va||(Va={}));const Ba={auth:ve,securityPolicy:pe,teams:me,metadata:Ae,reports:Oe,connectivity:Ue,notifications:Re,audits:Ne,tenants:le,accountSettings:Fe,roles:Ve,subscriptions:ea,vendor:na,subTenants:ia,featureFlags:Xt,directory:ra,impersonate:ca,groups:pa,users:ae,entitlements:ue,securityCenter:ha,userPhoneNumbers:Sa,applications:fa},Wa=t=>({auth:new Se(t),securityPolicy:new de(t),teams:new fe(t),metadata:new be(t),reports:new Ie(t),connectivity:new _e(t),notifications:new Le(t),audits:new Ce(t),tenants:new re(t),accountSettings:new Me(t),roles:new je(t),subscriptions:new ta(t),vendor:new aa(t),subTenants:new sa(t),featureFlags:new Qt(t),directory:new oa(t),impersonate:new la(t),groups:new da(t),users:new ee(t),entitlements:new ce(t),securityCenter:new ga(t),userPhoneNumbers:new ya(t),applications:new va(t)}),Ha={fetch:Mt,FetchClient:Nt,ContextHolder:L,FronteggContext:D,api:Ba,createApiClient:Wa,FronteggApiError:B,AuthStrategyEnum:N,MachineToMachineAuthStrategy:M,SocialLoginProviders:C,ISubscriptionCancellationPolicy:$,ISubscriptionStatus:F,PaymentMethodType:x,ProviderType:G},za=t=>JSON.parse(JSON.stringify(t)),Ka=(t=500)=>new Promise((e=>{setTimeout(e,t)})),qa=async(t,e,a)=>{let n=0;for(;n<e-1;)try{return await t()}catch(t){if(n++,n>=e)throw t;await new Promise((t=>setTimeout(t,a)))}return await t()};function Ja(t,e){const a=v({},t);return e.forEach((t=>{delete a[t]})),a}function Ya(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}let Qa,Xa,Za;!function(t){t.validate="validate",t.invalid="invalid",t.pending="pending",t.success="success",t.failed="failed"}(Qa||(Qa={})),function(t){t.activating="activating",t.success="success",t.resend="resend",t.activatingForm="activatingForm"}(Xa||(Xa={})),function(t){t.LOAD_API_TOKENS="LOAD_API_TOKENS",t.ADD_API_TOKEN="ADD_API_TOKEN",t.DELETE_API_TOKEN="DELETE_API_TOKEN"}(Za||(Za={}));var tn=a(8792),en=a.n(tn),an=a(5875);const nn=(t="default")=>{if(!L.for(t).shouldLoadEntitlements())throw new Error("You must first enable entitlements via Frontegg options to use this function")},sn=(t,e,a,n,s="default")=>(nn(s),(0,an.Me)(e,t,a)),on=(t,e,a,n,s="default")=>(nn(s),(0,an.a_)(e,t,a)),rn=(t,e,a,n,s="default")=>"permissionKey"in e?sn(t,e.permissionKey,a,n,s):on(t,e.featureKey,a,n,s);function ln(t,e){return en()(t,e)}let cn,un,dn,pn,gn,hn,yn,Sn,vn,fn,mn,bn,An,wn,Tn,En,In,On,Pn,kn;!function(t){t.forgotPassword="forgotPassword",t.success="success"}(cn||(cn={})),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"}(un||(un={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(dn||(dn={})),function(t){t.impersonating="impersonating",t.success="success"}(pn||(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"}(gn||(gn={})),function(t){t.Login="login",t.RegisterQuickLogin="registerQuickLogin"}(hn||(hn={})),function(t){t.Internal="internal",t.UsbKey="usb-key",t.Android="android",t.Sms="sms"}(yn||(yn={})),function(t){t["social-login"]="social-login",t["custom-social-login"]="custom-social-login",t.direct="direct"}(Sn||(Sn={})),function(t){t.verify="verify",t.recoveryCode="recoveryCode",t.authenticatorApp="authenticatorApp",t.smsSetPhoneNumber="smsSetPhoneNumber",t.smsVerifyCode="smsVerifyCode",t.emailVerifyCode="emailVerifyCode",t.noMFAEnrolledStepUp="noMFAEnrolledStepUp"}(vn||(vn={})),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"}(fn||(fn={})),function(t){t.ResetPhoneNumber="ResetPhoneNumber",t.VerifyResetPhoneNumber="VerifyResetPhoneNumber",t.ChangePhoneNumber="ChangePhoneNumber"}(mn||(mn={})),function(t){t.EDIT_ROLE_DIALOG="editRoleDialog",t.DELETE_ROLE_DIALOG="deleteRoleDialog",t.LOAD_ROLES="loadRoles",t.ADD_ROLE="addRole",t.MANAGE_PERMISSIONS="managePermissions"}(bn||(bn={})),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"}(An||(An={})),function(t){t.SignUp="SignUp",t.SignUpSuccess="SignUpSuccess"}(wn||(wn={})),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"}(Tn||(Tn={})),function(t){t.Saml="saml",t.Okta="okta",t.Azure="azure",t.Google="google",t.Oidc="oidc"}(En||(En={})),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"}(In||(In={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORDLESS="PASSWORDLESS",t.ACTIVATION_LINK="ACTIVATION_LINK"}(On||(On={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORD="PASSWORD"}(Pn||(Pn={})),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"}(kn||(kn={}));const _n={profile:kn.profile,privacy:kn.privacy,personalApiTokens:kn.personalApiTokens,account:kn.account,users:kn.users,groups:kn.groups,security:kn.security,sso:kn.sso,audits:kn.audits,webhooks:kn.webhooks,apiTokens:kn.apiTokens,roles:kn.roles,subscriptions:kn.subscriptions,allAccounts:kn.allAccounts};var Un=a(2743),Ln=a.n(Un);const Rn=(t,e)=>{const a=Ln()(t,v({},e));return function(t={}){return O(t)}(v({__isProxy:!0},a))},Dn={step:Qa.validate},Cn=t=>Rn(Dn,t),Nn=t=>t instanceof Error||(null==t?void 0:t.message)&&(null==t?void 0:t.stack)&&"Error"===(null==t?void 0:t.name),Mn=(t,e)=>t?(t=>Boolean(null==t?void 0:t.statusCode))(t)?t.message:(Nn(t)?console.error(t.message):"string"==typeof t&&console.error(t),null!=e?e:"We're facing some difficulties, Please try again"):e,Fn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.acceptInvitationState,e)};return{setAcceptInvitationState:n,resetAcceptInvitationState:()=>{t.auth.acceptInvitationState=za(Dn)},acceptInvitation:async t=>{if(t.token&&t.userId)try{n({error:void 0,step:Qa.pending}),await e.auth.acceptInvitation(t),n({step:Qa.success})}catch(t){n({step:Qa.failed,error:Mn(t)})}else n({error:void 0,step:Qa.invalid})}}},xn={loading:!1},$n=t=>Rn(xn,t),Gn=["activeTenant","tenants"],jn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.accountSettingsState,e)};return{setAccountSettingsState:n,resetAccountSettingsState:()=>{t.auth.accountSettingsState=za(xn)},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,p=await e.accountSettings.updateSettings(v({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,Gn),r=i.map((t=>t.id!==(null==s?void 0:s.id)?t:v({},t,e))),l=v({},s,e);a.setTenantsState(v({},o,{tenants:r,activeTenant:l}))})({newSettingValues:p}),n(v({},p,{loading:!1})),null==(i=s.callback)||i.call(s,p)}catch(t){var o;n({loading:!1,error:Mn(t)}),null==(o=s.callback)||o.call(s,null,t)}},loadAccountSettings:async t=>{n({loading:!(null!=t&&t.silentLoading),error:null});try{const t=await e.accountSettings.getSettings();n(v({},t,{loading:!1}))}catch(t){n({loading:!1,error:Mn(t)})}}}},Vn={step:Xa.activating,loading:!1,resentEmail:!1,activationStrategy:{loading:!1}},Bn=t=>Rn(Vn,t);let Wn;function Hn(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"}(Wn||(Wn={}));const zn={[N.Code]:gn.loginWithOtc,[N.EmailAndPassword]:gn.loginWithPassword,[N.MagicLink]:gn.magicLinkPreLoginSuccess,[N.SmsCode]:gn.loginWithSmsOtc},Kn={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"},qn=t=>{try{return new URL(t),!0}catch(t){return!1}},Jn=({authenticatedUrl:t,enforceRedirectToSameSite:e,allowedRedirectOrigins:a,includeQueryParam:n})=>{let s=t;const i=new URL(window.location.href).searchParams.get("redirectUrl");return i?e&&qn(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},Yn=t=>{const{searchParams:e}=new URL(t),a=e.toString();if(a)return`?${a}`},Qn=t=>{const{pathname:e}=new URL(t),a=Yn(t);return a?e+a:e},Xn=t=>{const e=new URLSearchParams(window.location.search).get(t);return null!=e?e:void 0},Zn="tenantId",ts=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}},es=t=>{const{numberOfPhoneDevices:e,numberOfAuthenticators:a,numberOfEmails:n,totalDevices:s}=ts(t);if(1===s){if(a)return vn.authenticatorApp;if(e)return vn.smsVerifyCode;if(n)return vn.emailVerifyCode}return vn.verify},as=t=>{if(1===t.length){const[e]=t;if(e===Wt.AuthenticatorApp)return vn.authenticatorApp;if(e===Wt.SMS)return vn.smsSetPhoneNumber;if(e===Wt.EmailCode)return vn.emailVerifyCode}return vn.verify},ns=t=>"/oauth/callback"===t;function ss(t){return"email"in t}const is=t=>{const e=L.for(t.root.appName).getBasename();return null!=e&&e.endsWith("/")?e.slice(0,-1):e},os="http://schemas.openid.net/pape/policies/2007/06/multi-factor",rs="mfa",ls=["otp","sms","hwk"],cs="SHOULD_STEP_UP",us="maxAge",ds="FRONTEGG_AFTER_AUTH_REDIRECT_URL",ps="HOSTED_LOGIN_VERIFIER_KEY",gs=(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===os,o=-1!==a.indexOf(rs),r=void 0!==ls.find((t=>a.indexOf(t)));return i&&o&&r};function hs(){const t=window.location.pathname+window.location.search;window.localStorage.setItem(ds,t)}const ys=(t,e,a)=>{hs();const n=new URLSearchParams(window.location.search);a&&n.set(us,a.toString()),e(`${t}${n?`?${n}`:""}`,{refresh:!1})},Ss=["phoneNumber"],vs=["authenticatedUrl"],fs=(t,e)=>{const a=L.for(e);return t.mfaRequired&&t.mfaToken?(a.setAccessToken(null),a.setUser(null),!0):(a.setAccessToken(t.accessToken),a.setUser(t),!1)},ms=(t,e=[])=>Object.entries(t).reduce(((t,[a,n])=>"object"==typeof n?[...t,...ms(n,[...e,a])]:[...t,{type:[...e,a].join("/"),payload:n}]),[]),bs=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}},As=t=>f(t,Ss),ws=(t,e)=>{const a=f(v({},Kn,e),vs);return Object.values(a).includes(t)},Ts=["callback","events"],Es=["user"],Is=["callback"],Os=["callback"],Ps=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.activateAccountState,e)},i=()=>{t.auth.activateAccountState=za(Vn)},o=e=>{Object.assign(t.auth.activateAccountState.activationStrategy,e)};return{setActivateState:s,resetActivateState:i,setActivateStrategyState:o,activateAccount:async a=>{const{callback:o,events:r}=a,l=f(a,Ts);s({loading:!0});try{const a=L.for(t.root.appName).onRedirectTo,u=t.auth.routes,d=await e.auth.activateAccountV2(l),{user:p}=d,g=f(d,Es);if(p.redirectLocation)return void(window.location.href=p.redirectLocation);if(fs(p,t.root.appName)){s({step:Xa.success});const t=await n.getMfaRequiredState(p);n.setAuthState(t),await Ka(1e3),a(u.loginUrl,{preserveQueryParams:!0})}else{var c;s({step:Xa.success});const t={email:p.email,origin:On.ACTIVATION_LINK,id:p.id,tenantId:p.tenantId,name:p.name,createdAt:new Date};null==r||null==(c=r.userVerified)||c.call(r,t),Hn(Wn.USER_VERIFIED,t),await n.afterAuthenticationStateUpdate(v({user:p},g),{isAuthenticated:!0}),await Ka(1e3),await n.afterAuthNavigation(),i()}null==o||o(!0)}catch(t){s({loading:!1,error:Mn(t)})}},preActivateAccount:async a=>{const{userId:i,token:r}=a;s({loading:!0,step:Xa.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:Xa.activatingForm})}catch(t){s({loading:!1,error:Mn(t)})}},getActivateAccountStrategy:async t=>{const{callback:a}=t,n=f(t,Is);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:Mn(t)})}},resendActivationEmail:async t=>{const{callback:a}=t,i=f(t,Os);n.setTeamLoader({key:In.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:Mn(t)}),null==a||a(null,t)}finally{n.setTeamLoader({key:In.RESEND_ACTIVATE_LINK,value:!1})}}}},ks={loading:!1,error:void 0,unlockAccountSuccess:!1},_s=t=>Rn(ks,t),Us=(t,e,a)=>{const n=e=>{Object.assign(t.auth.unlockAccountState,e)};return{setUnlockAccountState:n,resetUnlockAccountState:()=>{t.auth.activateAccountState=za(ks)},unlockAccount:async a=>{const{token:s}=a,i=L.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 Ka(1e3),i(o.loginUrl)}catch(t){n({loading:!1,error:Mn(t)})}}}},Ls={apiTokenType:null,searchValue:"",showAddTokenDialog:!1,createdByUserIdColumn:"show",deleteTokenDialog:{open:!1,clientId:""},successDialog:{open:!1,secret:"",clientId:""},loaders:{},apiTokensDataTenant:[],apiTokensDataUser:[],roles:[],permissions:[],errors:{}},Rs=t=>Rn(Ls,t),Ds=(t,e,a)=>{const n=e=>{Object.assign(t.auth.apiTokensState,{loaders:v({},t.auth.apiTokensState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.apiTokensState,{errors:v({},t.auth.apiTokensState.errors,{[e.key]:e.value}),loaders:v({},t.auth.apiTokensState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.apiTokensState,e)};return{setApiTokensLoader:n,setApiTokensError:s,setApiTokensState:i,resetApiTokensState:()=>{t.auth.apiTokensState=za(Ls)},loadApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Za.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:Za.LOAD_API_TOKENS,value:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var o;s({key:Za.LOAD_API_TOKENS,value:Mn(e)}),n({key:Za.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:Za.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([e.auth.getUserApiTokensData(),e.auth.getUserAccessTokensData()]),l=(null!=(a=r.accessTokens)?a:[]).map((t=>v({},t,{type:M.AccessToken}))).concat(s.map((t=>v({},t,{type:M.ClientCredentials})))).sort(((t,e)=>new Date(e.createdAt)-new Date(t.createdAt)));i({apiTokensDataUser:null!=l?l:[]}),n({key:Za.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Za.LOAD_API_TOKENS,value:Mn(e)}),n({key:Za.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:Za.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([e.auth.getTenantApiTokensData(),e.auth.getTenantAccessTokensData()]),l=(null!=(a=null==r?void 0:r.accessTokens)?a:[]).map((t=>v({},t,{type:M.AccessToken}))).concat(s.map((t=>v({},t,{type:M.ClientCredentials})))).sort(((t,e)=>new Date(e.createdAt)-new Date(t.createdAt)));i({apiTokensDataTenant:null!=l?l:[]}),n({key:Za.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Za.LOAD_API_TOKENS,value:Mn(e)}),n({key:Za.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=Za.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 Ka(200);const d=n?M.AccessToken:M.ClientCredentials;t.auth.apiTokensState.apiTokensDataTenant.unshift(v({},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:Mn(t)}),null==c||c(null,t)}finally{n({key:u,value:!1})}},addUserApiToken:async a=>{const{description:o,expires:r,callback:l}=a,c=Za.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 Ka(200);const u=n?M.AccessToken:M.ClientCredentials;t.auth.apiTokensState.apiTokensDataUser.unshift(v({},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:Mn(t)}),null==l||l(null,t)}finally{n({key:c,value:!1})}},deleteUserApiToken:async a=>{const o=Za.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:Mn(t)})}finally{n({key:o,value:!1})}},deleteTenantApiToken:async a=>{const o=Za.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:Mn(t)})}finally{n({key:o,value:!1})}}}},Cs={loading:!0,fetching:!0,error:null,userApplications:[],accountApplications:[]},Ns=t=>Rn(Cs,t),Ms=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:[]},Fs=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.applicationsState,e)},i=async({userIds:t})=>{try{const a=await e.applications.getUsersApplicationsId({userIds:t}),n=Ms(a),s=await e.applications.getApplicationsData({appIds:n});return t.reduce(((t,e)=>{var n,i,o;const r=null==(n=a.find((t=>t.userId==e)))?void 0:n.appIds;return t[e]=[...s.filter((t=>t.accessType===Va.FREE_ACCESS)),...null!=(i=null==r||null==(o=r.map((t=>s.find((e=>t===e.id)))))?void 0:o.filter((t=>!!t)))?i:[]],t}),{})}catch(t){s({error:Mn(t)})}},o="Assignment action failed. Try again or contact support.";return{setApplicationsState:s,resetApplicationsState:()=>{t.auth.applicationsState=za(Cs)},loadUserApplications:async()=>{s({loading:!0,fetching:!0});try{var a,n;const i=null!=(a=null==(n=t.auth.user)?void 0:n.id)?a:"",o=await e.applications.getUserApplicationsId({userId:i}),r=await e.applications.getApplicationsData({appIds:o});s({userApplications:r,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Mn(t)})}},loadAccountApplications:async()=>{s({loading:!0,fetching:!0});try{const t=await e.applications.getTenantsApplications(),a=Ms(t),n=await e.applications.getApplicationsData({appIds:a}),i=await e.applications.getUsersOfApplications({appIds:a}),o=n.map((t=>{var e;return v({},t,{userIds:null==(e=i.find((e=>e.appId===t.id)))?void 0:e.userIds})}));s({accountApplications:o,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Mn(t)})}},loadMultipleUsersApplications:i,assignUserToApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,p,g,h,y,S,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==(p=t.auth)||null==(g=p.applicationsState)?void 0:g.accountApplications,o=null!=(h=null==(y=t.auth)||null==(S=y.teamState)?void 0:S.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?v({},t,{applications:[...null!=(e=t.applications)?e:[],...m]}):t}))}),null==l||l(!0)}catch(t){s({error:Mn(t,o)}),null==l||l(!1)}},unassignUserFromApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,p,g,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!=(p=null==(g=t.auth)||null==(h=g.teamState)?void 0:h.users)?p:[],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?v({},t,{applications:o.filter((t=>!r.includes(t.id)))}):t))}),null==l||l(!0)}catch(t){s({error:Mn(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===Va.FREE_ACCESS)))?r:[];if(null!=a&&a.length){var d,p,g;const n=null!=(d=null==(p=t.auth)||null==(g=p.user)?void 0:g.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})=>{const[n]=await a.getFeatureFlags(["multi-apps-admin-portal"]);if(!n||!t)return e;const s=e.map((t=>t.id)),o=await i({userIds:s});return o?e.map((t=>null!=o&&o[t.id]?v({},t,{applications:o[t.id]}):t)):e}}},xs={loading:!0,error:null},$s=t=>Rn(xs,t),Gs=["callback"],js=(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=L.for(t.root.appName).getContext())||null==(n=a.tenantResolver)?void 0:n.call(a)))?void 0:e.tenant)};return{setCustomLoginState:s,resetCustomLoginState:()=>{t.auth.customLoginState=za(xs)},loadTenantMetadata:async()=>{s({loading:!0});try{const t=await e.metadata.getAdminBoxMetadata();s({tenantMetadata:t,loading:!1})}catch(t){s({loading:!1,error:Mn(t)})}},updateTenantMetadata:async t=>{const{callback:a}=t,n=f(t,Gs);try{s({error:null,saving:!0});const t=ms(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:Mn(t,"No changes to update"),saving:!1}),null==a||a(null,t)}},customLoginEnabled:i,loadCustomLoginRoutes:async()=>{try{var a;if(!await i())return;const o=t.auth.isAuthenticated,{getSettings:r,getPublicSettings:l}=e.accountSettings,{applicationUrl:c}=await(o?r():l());if(!c)return;const u=t.auth.routes,d=null!=(a=Yn(c))?a:"";n.setAuthState({routes:v({},u,{customLoginAuthenticatedUrl:c,customLoginUrl:u.loginUrl+d})}),s({customLoginSearchParams:null!=d?d:void 0})}catch{}}}},Vs={step:cn.forgotPassword,loading:!1,email:"",passwordConfig:null},Bs=t=>Rn(Vs,t),Ws=["callback"],Hs=(t,e,a)=>{const n=e=>{Object.assign(t.auth.forgotPasswordState,e)};return{setForgotPasswordState:n,resetForgotPasswordState:()=>{t.auth.forgotPasswordState=za(Vs)},forgotPassword:async t=>{n({loading:!0});try{var a;await e.auth.forgotPassword(t),n({loading:!1,error:void 0,step:cn.success}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;n({loading:!1,error:Mn(e,"Unknown error occurred")}),null==(s=t.callback)||s.call(t,!1,e)}},resetPassword:async t=>{const{callback:a}=t,s=f(t,Ws);n({loading:!0});try{await e.auth.resetPassword(s),n({loading:!1,error:void 0,step:cn.success}),null==a||a(!0)}catch(t){n({loading:!1,error:Mn(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:Mn(t)})}}}},zs={loaders:{},errors:{},groups:[],groupsConfiguration:{}},Ks=t=>Rn(zs,t),qs=["roleIds","userIds"],Js=(t,e,a)=>{const n=e=>{Object.assign(t.auth.groupsState,{loaders:v({},t.auth.groupsState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.groupsState,{errors:v({},t.auth.groupsState.errors,{[e.key]:e.value}),loaders:v({},t.auth.groupsState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.groupsState,e)},o=async()=>{const a=un.GET_GROUPS,o=t.auth.groupsState;n({key:a,value:!0});try{const{groups:t}=await e.groups.getGroups({_groupsRelations:dn.rolesAndUsers});i(v({groups:t},o.selectedGroup&&{selectedGroup:t.find((t=>{var e;return t.id===(null==(e=o.selectedGroup)?void 0:e.id)}))}))}catch(t){s({key:a,value:Mn(t)})}finally{n({key:a,value:!1})}},r=async t=>{const a=un.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:Mn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},l=async t=>{const a=un.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:Mn(e)})}finally{n({key:a,value:!1})}},c=async()=>{const t=un.GET_GROUP_CONFIGURATION;n({key:t,value:!0});try{const t=await e.groups.getGroupConfiguration();i({groupsConfiguration:t})}catch(e){s({key:t,value:Mn(e)})}finally{n({key:t,value:!1})}};return{setUsersGroupsLoader:n,setUsersGroupsError:s,setGroupsState:i,resetUsersGroupsState:()=>{t.auth.groupsState=za(zs)},loadGroups:o,getGroupById:async t=>{const a=un.GET_GROUP;n({key:a,value:!0});try{const a=await e.groups.getGroupById({groupId:t.groupId},{_groupsRelations:dn.rolesAndUsers});i({selectedGroup:a})}catch(t){s({key:a,value:Mn(t)})}finally{n({key:a,value:!1})}},createGroup:async t=>{const a=un.CREATE_GROUP,{roleIds:i,userIds:c}=t,u=f(t,qs);n({key:a,value:!0});try{var d;const a=await e.groups.createGroup(v({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 p;s({key:a,value:Mn(e)}),null==t||null==(p=t.callback)||p.call(t,!1)}finally{n({key:a,value:!1})}},updateGroup:async t=>{const a=un.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:Mn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},deleteGroup:async t=>{const a=un.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:Mn(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=un.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:Mn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},addUsersToGroup:l,deleteUsersFromGroup:async t=>{const a=un.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:Mn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},getGroupConfiguration:c,updateGroupConfiguration:async t=>{const a=un.UPDATE_GROUP_CONFIGURATION;n({key:a,value:!0});try{await e.groups.updateGroupConfiguration(t),await c()}catch(t){s({key:a,value:Mn(t)})}finally{n({key:a,value:!1})}},getTeamUsers:async t=>{const a=un.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:Mn(t)})}finally{n({key:a,value:!1})}}}},Ys={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}},Qs=t=>Rn(Ys,t),Xs=(t,e,a)=>({setGroupsDialogsState:e=>{Object.assign(t.auth.groupsDialogsState,e)},resetGroupsDialogsState:()=>{t.auth.groupsDialogsState=za(Ys)},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,v({},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,v({},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})}}),Zs={step:pn.impersonating,loading:!1},ti=t=>Rn(Zs,t),ei=["callback","events"],ai=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.impersonateState,e)},i=()=>{t.auth.impersonateState=za(Zs)};return{setImpersonateState:s,resetImpersonateState:i,impersonate:async t=>{const{callback:a}=t,o=f(t,ei);s({loading:!0});try{await e.impersonate.impersonate(o),s({step:pn.success}),await Ka(1e3),await n.afterAuthNavigation({preventRedirectUrlOriginCleaning:!0}),i(),null==a||a(!0)}catch(t){s({loading:!1,error:Mn(t)})}}}},ni={flow:hn.Login,step:gn.preLogin,loading:!1,email:"",tenants:[]},si=t=>Rn(ni,t),ii=(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(ds);t&&!qn(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;if(e)return Qn(e);const{authenticatedUrl:r,loginUrl:l,logoutUrl:c,socialLoginCallbackUrl:u,activateUrl:d}=n;let p=window.localStorage.getItem(ds);p&&![l,c,u,d].includes(p)||(p=r);const g=Jn({authenticatedUrl:p,includeQueryParam:s,enforceRedirectToSameSite:i,allowedRedirectOrigins:o});return a?g:(h=g).startsWith(null==(y=window)?void 0:y.location.origin)?h.replace(null==(S=window)?void 0:S.location.origin,""):h;var h,y,S}({customLoginAuthenticatedUrl:n,preventRedirectUrlOriginCleaning:o})),null==(c=window)||c.localStorage.removeItem(ds)}await Ka(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(cs),c=t.auth.user;var u;if(l&&(null==(u=window)||u.localStorage.removeItem(cs)),r&&l&&!gs(c))return s(n.resetLoginState,{forceStepUpUrl:r});let d=o;var p;return o||(await n.loadCustomLoginRoutes(),d=null==(p=t.auth.routes)?void 0:p.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(v({user:e,tenantsState:v({},o,{tenants:a,activeTenant:s,loading:!1})},i))}}},oi={step:vn.verify,loading:!1,saving:!1},ri=t=>Rn(oi,t),li=["callback"],ci=["callback"],ui=["callback"],di=["callback","deviceId"],pi=["callback","deviceId"],gi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",hi=new Uint8Array(256);for(let t=0;t<64;t++)hi[gi.charCodeAt(t)]=t;const yi=t=>{const e=new Uint8Array(t),a=e.length;let n,s="";for(n=0;n<a;n+=3)s+=gi[e[n]>>2],s+=gi[(3&e[n])<<4|e[n+1]>>4],s+=gi[(15&e[n+1])<<2|e[n+2]>>6],s+=gi[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},Si=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=hi[t.charCodeAt(n)],i=hi[t.charCodeAt(n+1)],o=hi[t.charCodeAt(n+2)],r=hi[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 vi(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 fi=t=>{if(t instanceof Array){const e=[];for(const a of t)e.push(fi(a));return e}if(t instanceof ArrayBuffer)return yi(t);if(t instanceof Object){const e={};for(const a in t)e[a]=fi(t[a]);return e}return t},mi=t=>new Promise(((e,a)=>{const n=new FileReader;n.readAsText(t),n.onload=()=>e(n.result),n.onerror=a})),bi=["callback","deviceId"],Ai=["callback","deviceId"],wi="input is invalid type",Ti="undefined"!=typeof ArrayBuffer,Ei="0123456789abcdef".split(""),Ii=[-2147483648,8388608,32768,128],Oi=[24,16,8,0],Pi=[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],ki=["hex","array","digest","arrayBuffer"],_i=[];Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Ti&&!ArrayBuffer.isView&&(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});const Ui=function(t){return function(e){const a=new Ri(!0).update(e);return null==a?void 0:a[t]()}},Li=function(t){return function(e,a){const n=new Di(e,!0).update(a);return null==n?void 0:n[t]()}};class Ri{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=()=>Ri.prototype.digest(),t?(_i[0]=_i[16]=_i[1]=_i[2]=_i[3]=_i[4]=_i[5]=_i[6]=_i[7]=_i[8]=_i[9]=_i[10]=_i[11]=_i[12]=_i[13]=_i[14]=_i[15]=0,this.blocks=_i):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(wi);if(null===t)throw new Error(wi);if(Ti&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||Ti&&ArrayBuffer.isView(t)))throw new Error(wi);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]<<Oi[3&s++];else for(s=this.start;i<o&&s<64;++i)n=t.charCodeAt(i),n<128?r[s>>2]|=n<<Oi[3&s++]:n<2048?(r[s>>2]|=(192|n>>6)<<Oi[3&s++],r[s>>2]|=(128|63&n)<<Oi[3&s++]):n<55296||n>=57344?(r[s>>2]|=(224|n>>12)<<Oi[3&s++],r[s>>2]|=(128|n>>6&63)<<Oi[3&s++],r[s>>2]|=(128|63&n)<<Oi[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++i)),r[s>>2]|=(240|n>>18)<<Oi[3&s++],r[s>>2]|=(128|n>>12&63)<<Oi[3&s++],r[s>>2]|=(128|n>>6&63)<<Oi[3&s++],r[s>>2]|=(128|63&n)<<Oi[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]|=Ii[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,p=this.h1,g=this.h2,h=this.h3,y=this.h4,S=this.h5,v=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=p&g,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&p,n=r^d&g^u,o=y&S^~y&v,s=f+a+o+Pi[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&p^r,o=f&y^~f&S,s=v+a+o+Pi[t+1]+m[t+1],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),c=g&h,n=c^g&d^l,o=v&f^~v&y,s=S+a+o+Pi[t+2]+m[t+2],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),u=p&g,n=u^p&h^c,o=S&v^~S&f,s=y+a+o+Pi[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+p|0,this.h2=this.h2+g|0,this.h3=this.h3+h|0,this.h4=this.h4+y|0,this.h5=this.h5+S|0,this.h6=this.h6+v|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=Ei[t>>28&15]+Ei[t>>24&15]+Ei[t>>20&15]+Ei[t>>16&15]+Ei[t>>12&15]+Ei[t>>8&15]+Ei[t>>4&15]+Ei[15&t]+Ei[e>>28&15]+Ei[e>>24&15]+Ei[e>>20&15]+Ei[e>>16&15]+Ei[e>>12&15]+Ei[e>>8&15]+Ei[e>>4&15]+Ei[15&e]+Ei[a>>28&15]+Ei[a>>24&15]+Ei[a>>20&15]+Ei[a>>16&15]+Ei[a>>12&15]+Ei[a>>8&15]+Ei[a>>4&15]+Ei[15&a]+Ei[n>>28&15]+Ei[n>>24&15]+Ei[n>>20&15]+Ei[n>>16&15]+Ei[n>>12&15]+Ei[n>>8&15]+Ei[n>>4&15]+Ei[15&n]+Ei[s>>28&15]+Ei[s>>24&15]+Ei[s>>20&15]+Ei[s>>16&15]+Ei[s>>12&15]+Ei[s>>8&15]+Ei[s>>4&15]+Ei[15&s]+Ei[i>>28&15]+Ei[i>>24&15]+Ei[i>>20&15]+Ei[i>>16&15]+Ei[i>>12&15]+Ei[i>>8&15]+Ei[i>>4&15]+Ei[15&i]+Ei[o>>28&15]+Ei[o>>24&15]+Ei[o>>20&15]+Ei[o>>16&15]+Ei[o>>12&15]+Ei[o>>8&15]+Ei[o>>4&15]+Ei[15&o];return l+=Ei[r>>28&15]+Ei[r>>24&15]+Ei[r>>20&15]+Ei[r>>16&15]+Ei[r>>12&15]+Ei[r>>8&15]+Ei[r>>4&15]+Ei[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 Di extends Ri{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(wi);if(null===t)throw new Error(wi);if(Ti&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||Ti&&ArrayBuffer.isView(t)))throw new Error(wi)}var s;t.length>64&&(t=null==(s=new Ri(!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}Ri.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();Ri.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),Ri.prototype.finalize.call(this)}}}const Ci=function(){const t=Ui("hex");t.create=function(){return new Ri},t.update=function(e){return t.create().update(e)};for(let e=0;e<ki.length;++e){const a=ki[e];t[a]=Ui(a)}return t}();async function Ni(t){const e=Ci.digest((new TextEncoder).encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function Mi(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 Fi(t){var e,a;return null!=(e=window.crypto)&&null!=(a=e.subtle)&&a.digest?Mi(t):(console.warn("Generating CodeChallenge in non-secure domain:",window.location.origin),Ni(t))}function xi(t=16){let e="";for(let a=0;a<t;a++)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return e}!function(){const t=Li("hex");t.create=function(t){return new Di(t)},t.update=function(e,a){return t.create(e).update(a)};for(let e=0;e<ki.length;++e){const a=ki[e];t[a]=Li(a)}}();const $i=["callback"],Gi=["callback"],ji=["callback"],Vi=["callback"],Bi=["callback"],Wi=["callback","events"],Hi=["callback"],zi=["callback"],Ki=["user"],qi=["callback"],Ji=["callback"],Yi=["callback"],Qi=["callback"],Xi=["callback"],Zi=["callback"],to=(t,e,a)=>{const n=a,s=L.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(v({},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:p}=await e.auth.refreshTokenV3();if(fs(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:p},{loginState:v({},o,{quickLoginToRegister:t,flow:e?hn.RegisterQuickLogin:hn.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 ln(n,null==e?void 0:e.entitlements)?v({},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];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()=>{try{const{isActive:t}=await e.auth.getSSOPublicConfiguration();n.setAuthState({isSSOAuth:t})}catch(t){n.setAuthState({isSSOAuth:!1})}},u=async()=>{let t;try{var a;const n=await e.metadata.getSamlMetadata();t=null==n||null==(a=n.configuration)?void 0:a.acsUrl}catch(t){console.error(t)}n.setAuthState({ssoACS:t})},d=e=>{Object.assign(t.auth.loginState,e)},p=async e=>{let{callback:a}=e,s=f(e,$i);const i=t.auth.securityPolicyState.publicPolicy.policy;if(null==i||!i.authStrategy)return n.setLoginState({step:gn.loginWithPassword,loading:!1}),void(null==a||a());(null==i?void 0:i.authStrategy)===N.EmailAndPassword?(n.setLoginState({step:gn.loginWithPassword,loading:!1}),null==a||a()):[N.MagicLink,N.Code,N.SmsCode].includes(null==i?void 0:i.authStrategy)?await n.passwordlessPreLogin(v({},s,{type:null==i?void 0:i.authStrategy,callback:a})):(n.setLoginState({step:gn.loginWithPassword,loading:!1}),null==a||a())},g=async t=>{const{user:e,tenants:a=[],activeTenant:s}=t,i={step:vn.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 v({setLoginState:d,resetLoginState:()=>{t.auth.loginState=za(ni)},requestAuthorize:async t=>{const e=[],a=[];e.push(o()),t&&(n.setAuthState({isLoading:!0}),e.push(n.loadSocialLoginsConfigurationV2()),e.push(n.loadAllowSignUps()),e.push(n.loadPublicAuthStrategiesPolicy()),e.push(c()),e.push(n.loadVendorPublicInfo()),e.push(u()),a.push(n.loadCustomLoginRoutes())),await Promise.all(e),a.length>0&&await Promise.all(a),n.setAuthState({isLoading:!1})},requestAuthorizeSSR:async e=>{const a=[];a.push(n.loadSocialLoginsConfigurationV2()),a.push(n.loadAllowSignUps()),a.push(c()),a.push(n.loadVendorPublicInfo()),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(fs(a,t.root.appName)){const t=await n.getMfaRequiredState(a);n.setAuthState(t),s(i.loginUrl,{preserveQueryParams:!0})}})(e)),a.push(n.loadCustomLoginRoutes()),await Promise.all(a)},preLogin:async a=>{const{email:n,recaptchaToken:s,invitationToken:i,callback:o}=a;d({loading:!0});try{const a=t.auth.onRedirectTo,r=Xn(Zn),l=await e.auth.preLoginV2({email:n,tenantId:r}),{address:c,idpType:u}=null!=l?l:{};if(c){let e=c;if(u===En.Oidc&&!e.includes("redirect_uri")){const{oidcRedirectUrl:a}=t.auth.routes;e+=`&redirect_uri=${window.location.origin}${a}`}S.isLoginWithSSOAvailable()?(S.loginWithSSO(n),d({loading:!1}),null==o||o()):(d({step:gn.redirectToSSO,loading:!1,ssoRedirectUrl:e}),setTimeout((()=>{a(e,{refresh:!0})}),2e3))}else await p({email:n,recaptchaToken:s,callback:o,invitationToken:i})}catch(t){await p({email:n,recaptchaToken:s,callback:o,invitationToken:i})}},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:gn.loginWithSSOFailed,loading:!1})}},login:async a=>{const{email:i,password:o,recaptchaToken:r,invitationToken:l,callback:c}=a;d({loading:!0});try{const{user:a,tenants:s=[],activeTenant:u}=await e.auth.loginv2({email:i,password:o,recaptchaToken:r,invitationToken:l}),{onRedirectTo:p,routes:g}=t.auth;if(fs(a,t.root.appName)){const t=await n.getMfaRequiredState(a);n.setAuthState(t),p(g.loginUrl,{preserveQueryParams:!0})}else{const e=t.auth.loginState,o=!!a.accessToken;a.id&&localStorage.setItem("userId",a.id),n.afterAuthenticationStateUpdate({user:a,tenants:s,activeTenant:u},{loginState:{flow:e.flow,quickLoginToRegister:e.quickLoginToRegister,email:i,loading:!1,error:void 0,mfaToken:a.mfaToken,step:e.flow===hn.Login?gn.success:e.step,tenants:s,tenantsLoading:!0,isBreachedPassword:a.isBreachedPassword},isAuthenticated:o});const[r]=await n.getFeatureFlags(["security-center-show-login-flows"]);e.flow===hn.Login&&(r&&a.isBreachedPassword&&!o?d({step:gn.breachedPassword,loading:!1}):o&&(await n.__shouldShowPromptPasskeys()?(d({step:gn.promptPasskeys,loading:!1}),p(g.loginUrl,{preserveQueryParams:!0})):await n.afterAuthNavigation()))}localStorage.removeItem("register-quick-login"),null==c||c(!0)}catch(t){s.setAccessToken(null),s.setUser(null),null==c||c(!1,t),d({email:i,error:Mn(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()&&se(),n.resetAuthState(),await n.requestAuthorize(!0),null==a||a()},silentLogout:async t=>{var a;try{await e.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&se(),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:gn.preLogin}),n.setAuthState({user:void 0,isAuthenticated:!1}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;d({error:Mn(e),loading:!1}),null==(s=t.callback)||s.call(t,!1,e)}},quickSmsPasswordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,Gi);try{d({loading:!0});const t=await e.auth.passwordlessPreLogin(v({},n,{type:N.SmsCode}));d({step:gn.loginWithQuickSmsOtc,loading:!1,phoneNumber:null==t?void 0:t.phoneNumber,error:void 0}),null==a||a(!0)}catch(t){d({error:Mn(t),loading:!1}),null==a||a(!1,t)}},changePhoneNumberWithVerification:async t=>{const{callback:a}=t,n=f(t,ji);try{d({loading:!0});const t=await e.auth.changePhoneNumberWithVerification(n);d({phoneNumber:n.phoneNumber,loading:!1,changePhoneId:t.changePhoneId,step:gn.loginWithQuickSmsOtc,error:void 0}),null==a||a(!0)}catch(t){d({error:Mn(t),loading:!1})}},verifyChangePhoneNumber:async t=>{const{callback:a}=t,n=f(t,Vi);try{d({loading:!0}),await e.auth.verifyChangePhoneNumber(n),d({loading:!1}),null==a||a(!0)}catch(t){d({error:Mn(t),loading:!1})}},passwordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,Bi);try{let t;d({loading:!0}),ss(n)&&(t=n.email);const s=await e.auth.passwordlessPreLogin(n),i=zn[n.type];d({step:i,loading:!1,phoneNumber:null==s?void 0:s.phoneNumber,email:t,error:void 0}),null==a||a()}catch(t){d({error:Mn(t),loading:!1}),null==a||a(null,t)}},passwordlessPostLogin:async a=>{const{callback:s,events:i}=a,o=f(a,Wi);try{d({loading:!0});const{user:a,tenants:l=[],activeTenant:c}=await e.auth.passwordlessPostLoginV2(o),{routes:u,onRedirectTo:p}=t.auth;if(fs(a,t.root.appName)){const t=await n.getMfaRequiredState(a);n.setAuthState(t),p(u.loginUrl,{preserveQueryParams:!0})}else{const e=t.auth.loginState;if(a.emailVerified){var r;const t={email:a.email,origin:On.PASSWORDLESS,id:a.id,tenantId:a.tenantId,createdAt:new Date,name:a.name};null==i||null==(r=i.userVerified)||r.call(i,t),Hn(Wn.USER_VERIFIED,t)}a.id&&localStorage.setItem("userId",a.id),n.afterAuthenticationStateUpdate({user:a,tenants:l,activeTenant:c}),d({error:void 0}),n.setAuthState({isLoading:!1}),e.flow===hn.Login?await n.__shouldShowPromptPasskeys()?(n.setLoginState({step:gn.promptPasskeys,loading:!1}),p(u.loginUrl,{preserveQueryParams:!0})):(n.setAuthState({isAuthenticated:!0}),await n.afterAuthNavigation()):p(u.loginUrl,{preserveQueryParams:!0}),localStorage.removeItem("register-quick-login"),null==s||s(!0)}}catch(t){d({error:Mn(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:Mn(t,"We couldn't verify your invitation")})}finally{d({loading:!1})}},webAuthnPrelogin:async t=>{const{callback:a}=t,s=f(t,Hi);try{var i;n.setPasskeysState({loading:!0}),d({loading:!0});const{options:t}=await e.auth.webAuthnPreLogin(s);t.challenge=Si(t.challenge),t.allowCredentials=null==(i=t.allowCredentials)?void 0:i.map((t=>v({},t,{id:Si(t.id)}))),d({error:void 0}),null==a||a(t)}catch(t){d({error:Mn(t)}),null==a||a(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnPostLogin:async a=>{const{callback:s}=a,i=f(a,zi);try{var o;n.setPasskeysState({loading:!0}),d({loading:!0});const a=fi(i.publicKey),r=await e.auth.webAuthnPostLoginV2(v({},a,{response:v({},a.response,{userHandle:null!=(o=a.response.userHandle)?o:void 0}),recaptchaToken:i.recaptchaToken,invitationToken:i.invitationToken})),{user:l}=r,c=f(r,Ki);if(fs(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(v({user:l},c),{isAuthenticated:!0}),d({error:void 0}),await n.afterAuthNavigation(),null==s||s(!0)}catch(t){d({error:Mn(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=Si(t.user.id),t.challenge=Si(t.challenge),t.excludeCredentials=[],null==a||a(t)}catch(t){d({error:Mn(t)}),null==a||a(null)}finally{d({loading:!1})}},webAuthnVerifyNewDeviceSession:async t=>{const{callback:a}=t,n=f(t,qi);try{d({loading:!0});const t=fi(n.publicKey),s="platform"===(null==t?void 0:t.authenticatorAttachment)?Bt.Platform:Bt.CrossPlatform;await e.auth.verifyNewDeviceSession({id:t.id,response:t.response,deviceType:s}),null==a||a(!0)}catch(t){d({error:Mn(t)}),null==a||a(null)}finally{d({loading:!1})}},getUserIP:async t=>{const{callback:a}=t;try{const{ip:t}=await e.metadata.getCurrentUserIpMetadata();n.setAuthState({userIp:t}),null==a||a(!0)}catch(t){null==a||a(!1)}},preEnrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,Ji);d({loading:!0});try{var s;const t=await e.auth.preEnrollMFAWebAuthnForLogin(n),i=v({},t.options,{challenge:Si(t.options.challenge),user:v({},t.options.user,{id:Si(t.options.user.id)}),excludeCredentials:null==(s=t.options.excludeCredentials)?void 0:s.map((t=>v({},t,{id:Si(t.id)})))});d({loading:!1}),null==a||a({options:i,webauthnToken:t.webauthnToken})}catch(t){d({loading:!1,error:Mn(t)}),null==a||a(null)}},enrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,Yi);d({loading:!0});try{const t=fi(n.publicKey),s=await e.auth.enrollMFAWebAuthnForLoginV2(v({},n,{options:t}));await g(s),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Mn(t)}),null==a||a(null)}},enrollMFAAuthenticatorAppForLogin:async t=>{const{callback:a}=t,n=f(t,Qi);d({loading:!0});try{const t=await e.auth.enrollMFAAuthenticatorAppForLoginV2(n);await g(t),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Mn(t)}),null==a||a(null)}},preEnrollMFASMSForLogin:async t=>{const{callback:a}=t,s=f(t,Xi);d({loading:!0});try{const t=await e.auth.preEnrollMFASMSForLogin(s);n.setMfaState({otcToken:t.otcToken,step:vn.smsVerifyCode,phoneNumber:t.phoneNumber}),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Mn(t)}),null==a||a(null)}},enrollMFASMSForLogin:async t=>{const{callback:a}=t,n=f(t,Zi);d({loading:!0});try{const t=await e.auth.enrollMFASMSForLoginV2(n);await g(t),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Mn(t)}),null==a||a(null)}},handleEnrollMFAResponse:g,resetBreachedPassword:async t=>{d({loading:!0});try{await e.auth.forgotPassword(t),d({loading:!1,error:void 0,step:gn.breachedPasswordSuccess}),n.setAuthState({isAuthenticated:!1})}catch(t){d({loading:!1,error:Mn(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(v({},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:p}=await e.auth.refreshTokenV3();if(fs(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:gn.promptPasskeys,loading:!1}),n.afterAuthenticationStateUpdate({user:t,tenants:d,activeTenant:p},{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:p},{loginState:v({},o,{quickLoginToRegister:e,flow:s?hn.RegisterQuickLogin:hn.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(bs(l)===i.hostedLoginRedirectUrl)return void console.debug("Calling loginWithRedirect while in hostedLoginCallback route");n.setAuthState({isLoading:!0});const c=xi(),u=xi(),d=await Fi(u);localStorage.setItem(ps,u);const p=is(t);let g=`${window.location.origin}${"path"===l?"":"#"}${null!=p?p:""}${i.hostedLoginRedirectUrl}`;await n.loadCustomLoginRoutes();const h=null==(s=t.auth.customLoginState)?void 0:s.customLoginSearchParams;h&&(g.endsWith("/")&&(g=g.slice(0,-1)),g+=h);const y=`${e.fetch.getBaseUrl(r,"/oauth/authorize")}/oauth/authorize`,S=v({response_type:"code",client_id:r.clientId||"INVALID-CLIENT-ID",scope:"openid email profile",redirect_uri:g,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&&(S.organization=t.tenant)}const m=Xn(Zn);m&&(S.tenantId=m),o(`${y}?${new URLSearchParams(S).toString()}`,{refresh:!0})};return{requestHostedLoginAuthorize:async e=>{var a;null==(a=localStorage)||a.removeItem(cs);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(cs),l){const e=t.root.urlStrategy,a=bs(e);if(n.setAuthState({isLoading:!0}),ns(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(ps)||"INVALID-CODE-VERIFIER",o=t.auth.routes,r=t.root.urlStrategy,l=is(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(cs);window.localStorage.removeItem(cs),a&&gs(e)?await n.afterStepUpAuthNavigation():await n.afterAuthNavigation()}}}})(t,e,a),ii(t,0,a),function(t,e,a){const n=a,s=async e=>{const a=t.root.appName;return Yt.getFeatureFlags(e,a)},i=async()=>await n.afterStepUpAuthNavigation(),o=async e=>{const a=t.auth.loginState,i=t.auth.mfaState.step,[o]=await s(["security-center-show-login-flows"]);if(a.flow===hn.Login)if(o&&a.isBreachedPassword&&!e)n.setLoginState({step:gn.breachedPassword,loading:!1});else{const t=await n.__shouldShowPromptPasskeys();i===vn.smsVerifyCode&&t?n.setLoginState({step:gn.promptPasskeys,loading:!1}):await n.afterAuthNavigation()}};return{postHandleVerifyMFAResponseForStepUp:i,postHandleVerifyMFAResponseForLogin:o,handleVerifyMFAResponse:async(t,e=!1)=>{const{user:a,tenants:s,activeTenant:r}=t;n.setUser(a),n.setTenantsState({tenants:s,activeTenant:r,loading:!1}),a.id&&localStorage.setItem("userId",a.id);const l=!!a.accessToken;return n.setAuthState({isAuthenticated:l}),e?await i():await o(l)},getFeatureFlags:s}}(t,0,a),((t,e)=>({getMfaRequiredState:async a=>{let n=gn.loginWithTwoFactor;const s=za(oi),i=t.auth.loginState,{isAllowedToRemember:o,mfaDeviceExpiration:r}=await e.auth.checkIfAllowToRememberMfaDevice(a.mfaToken);!a.hasOwnProperty("mfaEnrolled")||a.mfaEnrolled?Object.assign(s,{mfaDevices:a.mfaDevices,step:es(a.mfaDevices)}):(Object.assign(s,{step:as(a.mfaStrategies),qrCode:a.qrCode,recoveryCode:a.recoveryCode,loading:!1,mfaToken:a.mfaToken,mfaStrategies:a.mfaStrategies}),n=gn.forceTwoFactor);let l={};const c=localStorage.getItem("register-quick-login");return c&&(l={quickLoginToRegister:c,flow:hn.RegisterQuickLogin}),{user:void 0,isAuthenticated:!1,mfaState:s,loginState:v({},i,l,{mfaToken:a.mfaToken,mfaRequired:a.mfaRequired,loading:!1,error:void 0,step:n,tenantsLoading:!0,email:a.userEmail,tenants:[],allowRememberMfaDevice:o,mfaDeviceExpiration:r,isBreachedPassword:a.isBreachedPassword})}}}))(t,e),((t,e,a)=>{const n=a,s=async(a,s,i)=>{let{callback:o}=a,r=f(a,li);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===hn.Login?gn.success:s.step;i={loginState:{flow:s.flow,quickLoginToRegister:s.quickLoginToRegister,loading:!1,step:t,error:void 0,tenants:e}}}return v({},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){const s=t.auth.loginState;if(s.flow!==hn.Login)return;const[i]=await n.getFeatureFlags(["security-center-show-login-flows"]);i&&s.isBreachedPassword&&!e?n.setLoginState({step:gn.breachedPassword,loading:!1}):await n.__shouldShowPromptPasskeys()?n.setLoginState({step:gn.promptPasskeys,loading:!1}):await n.afterAuthNavigation(),null==a||a(!0)}(u,o)}catch(t){s({loading:!1,error:Mn(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,ci);(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:vn.emailVerifyCode}),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({error:Mn(t)}),null==i||i(null)}},i=async(t,a)=>{var s;let{callback:i}=t,o=f(t,ui);(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:Mn(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,di);a({loading:!1,error:void 0});try{const t=await e.auth.preVerifyMFASMSForLogin(i,o);n.setMfaState({otcToken:t.otcToken,step:vn.smsVerifyCode,phoneNumber:t.phoneNumber}),a({loading:!1,error:void 0}),null==s||s(!0)}catch(t){a({loading:!1,error:Mn(t)}),null==s||s(null)}},i=async(t,a,s=!1)=>{let{callback:i,deviceId:o}=t,r=f(t,pi);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:Mn(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,bi);a({loading:!0});try{var o;const t=await e.auth.preVerifyMFAWebAuthnForLogin(s,i),r=v({},t.options,{challenge:Si(t.options.challenge),allowCredentials:null==(o=t.options.allowCredentials)?void 0:o.map((t=>v({},t,{id:Si(t.id)})))});a({loading:!1,error:void 0}),null==n||n({options:r,webauthnToken:t.webauthnToken})}catch(t){a({loading:!1,error:Mn(t)}),null==n||n(null)}},i=async(t,a,s)=>{let{callback:i,deviceId:o}=t,r=f(t,Ai);a({loading:!0});try{const t=fi(r.publicKey),l=await e.auth.verifyMFAWebAuthnForLoginV2(o,v({},r,{options:t}));await n.handleVerifyMFAResponse(l,s),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Mn(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))},eo=["callback"],ao=["callback"],no=["user"],so=["deviceId"],io=["deviceId"],oo=["callback"],ro=["callback"],lo=["deviceId","callback"],co=(t,e,a)=>{const n=a;async function s(e){const a=t.auth.mfaState.step;return{step:e.recoveryCode?vn.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:()=>{t.auth.mfaState=za(oi)},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:Mn(t)})}},getMFAStrategies:async()=>{i({loading:!0});try{const t=(await e.auth.getMFAStrategiesConfig()).strategies.filter((({isActive:t})=>t)).map((({strategy:t})=>t));i({loading:!1,error:void 0,mfaStrategies:t})}catch(t){i({loading:!1,error:Mn(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:Mn(t)})}},verifyMfa:async a=>{const{callback:o}=a,r=f(a,eo);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(v({},u,{mfaDevices:c})),n.setUser(v({},a,{mfaEnrolled:!0})),null==o||o(u.recoveryCode)}catch(t){i({saving:!1,error:Mn(t)}),null==o||o(null,t)}},verifyMfaAfterForce:async t=>{const{callback:a}=t,s=f(t,ao);i({loading:!0});try{const t=await e.auth.loginWithMfaV2(s),{user:o}=t,r=f(t,no),l={step:vn.recoveryCode,loading:!1,saving:!1,error:void 0};null!=o&&o.recoveryCode&&(l.recoveryCode=o.recoveryCode),i(l),await n.afterAuthenticationStateUpdate(v({user:o},r)),null==a||a(l.recoveryCode)}catch(t){i({loading:!1,error:Mn(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:Mn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},preDisableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,so);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:Mn(t)}),null==(o=n.callback)||o.call(n,!1,t)}},disableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,io);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:Mn(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:Mn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},enrollMfaSms:async t=>{const{callback:a}=t,n=f(t,oo);i({saving:!0});try{const t=await e.auth.enrollMFASMS(n),o=await e.auth.getMFADevices(),r=await s(t);i(v({},r,{mfaDevices:o})),null==a||a(r.recoveryCode)}catch(t){i({saving:!1,error:Mn(t)}),null==a||a(null,t)}},preEnrollMfaWebAuthn:async t=>{i({saving:!0});try{var a,n;const s=await e.auth.preEnrollMFAWebAuthn(),o=v({},s.options,{challenge:Si(s.options.challenge),user:v({},s.options.user,{id:Si(s.options.user.id)}),excludeCredentials:null==(a=s.options.excludeCredentials)?void 0:a.map((t=>v({},t,{id:Si(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:Mn(e)}),null==(s=t.callback)||s.call(t,null,e)}},enrollMfaWebAuthn:async t=>{const{callback:a}=t,n=f(t,ro);i({saving:!0});try{const t=fi(n.publicKey),o=await e.auth.enrollMFAWebAuthn(v({},n,{options:t})),r=await e.auth.getMFADevices(),l=await s(o);i(v({},l,{mfaDevices:r})),null==a||a(l.recoveryCode)}catch(t){i({saving:!1,error:Mn(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=v({},t.options,{challenge:Si(t.options.challenge),allowCredentials:null==(s=t.options.allowCredentials)?void 0:s.map((t=>v({},t,{id:Si(t.id)})))});i({saving:!1}),null==n||n({options:o,webauthnToken:t.webauthnToken})}catch(t){i({saving:!1,error:Mn(t)}),null==n||n(null,t)}},disableMfaWebAuthn:async t=>{const{deviceId:a,callback:n}=t,s=f(t,lo);i({saving:!0});try{const t=fi(s.publicKey);await e.auth.disableMFAWebAuthn(a,v({},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:Mn(t)}),null==n||n(!1,t)}},__getMfaStateAfterEnroll:s}},uo={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:Ct.DESC,_sortBy:Ca.name},usersPageOffset:0,accountSettings:{}}},po=t=>Rn(uo,t),go=({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 ho(t,e,a){var n,s,i;return t.tenantId===e?v({},t,{children:[...null!=(i=null==t?void 0:t.children)?i:[],...a].filter(((t,e,a)=>e===a.findIndex((e=>e.tenantId===t.tenantId))))}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>ho(t,e,a))))?n:[]})}function yo(t,e){var a;return v({},t,{children:null!=(a=t.children)&&a.length?t.children.filter((t=>t.tenantId!==e)).map((t=>yo(t,e))):[]})}const So=(t,e,a)=>{var n,s;return t.tenantId===e?v({},t,{subAccountAccessType:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>So(t,e,a))))?n:[]})},vo=(t,e,a)=>{var n,s;return t.tenantId===e?v({},t,{name:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>vo(t,e,a))))?n:[]})},fo=(t,e,a)=>{var n,s;return t?t.tenantId===e?v({},t,{isReseller:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>fo(t,e,a))))?n:[]}):{}},mo=(t,e,a)=>{const n=e=>{Object.assign(t.auth.allAccountsState,{loaders:v({},t.auth.allAccountsState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.allAccountsState,{errors:v({},t.auth.allAccountsState.errors,{[e.key]:e.value}),loaders:v({},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,p,g;const{jwt:h,_tenantId:y,_email:S}=t,f=fn.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==(p=m.selectedAccount)||null==(g=p.usersQueryParams)?void 0:g._limit)?u:10,w=v({_offset:b,_limit:A,_tenantId:y,_includeSubTenants:!1},!!S&&{_email:S});try{const{items:t,_metadata:{totalItems:a,totalPages:n}}=await e.users.getUsersV3(w,{jwt:h}),s={totalUsersItems:a,totalUsersPages:n,usersQueryParams:v({_offset:null!=b?b:0,_limit:null!=A?A:10},!!S&&{_email:S})};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 v({},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(v({users:r},s))}else o(v({users:[]},s))}catch(t){s({key:f,value:Mn(t)})}finally{n({key:f,value:!1})}};return{setAllAccountsLoader:n,setAllAccountsError:s,setAllAccountsState:i,setSelectedAccountState:o,resetAllAccountsState:()=>{t.auth.allAccountsState=za(uo)},clearSelectedAccount:()=>{t.auth.allAccountsState.selectedAccount=za(uo.selectedAccount)},loadAccounts:async t=>{const a=fn.GET_ACCOUNTS;n({key:a,value:!0});const{accountsQueryParams:l}=r(),{jwt:c,_limit:u,_offset:d}=t,p={_offset:null!=d?d:l._offset,_limit:null!=u?u:l._limit,_subTenantId:null==t?void 0:t._subTenantId};try{if(c){var g;const{selectedAccount:a}=r(),{items:n,_links:s}=await e.tenants.searchSubTenants(p,{jwt:c}),i=await e.tenants.getTenantsUsersCount({tenantIds:n.map((t=>t.tenantId))},{jwt:c}),l=go({items:n},i),u=ho(a.accounts?a.accounts:a,null!=(g=null==t?void 0:t._subTenantId)?g:"",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(p),o=await e.tenants.getTenantsUsersCount({tenantIds:n.map((t=>t.tenantId))}),l=go({items:n},o),c=ho(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:Mn(t)})}finally{n({key:a,value:!1})}},searchAccounts:async t=>{const{jwt:a}=t,o=fn.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:Mn(t)})}finally{n({key:o,value:!1})}},updateSubAccountAccessForUser:async t=>{const a=fn.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 p;await e.subTenants.updateSubAccountAccess(l,{allowAccess:c},{jwt:u}),o({users:null==i||null==(p=i.users)?void 0:p.map((t=>t.id===l?v({},t,{subAccountAccessAllowed:c}):t))}),null==d||d(!0)}catch(t){s({key:a,value:Mn(t)}),null==d||d(!1)}finally{n({key:a,value:!1})}},createSubAccount:async t=>{const a=fn.CREATE_SUB_ACCOUNT;n({key:a,value:!0});const{name:l,parentTenantId:c,tenantId:u,jwt:d,callback:p}=t;try{if(d){const{accounts:t,selectedAccount:a}=r(),n=await e.subTenants.createSubTenant({name:l,parentTenantId:c,tenantId:u},{jwt:d}),s=ho(t,null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]),p=ho(v({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:p})}else{const{accounts:t}=r(),a=await e.subTenants.createSubTenant({name:l,tenantId:u,parentTenantId:c}),n=ho(t,null!=c?c:"",[{name:a.name,tenantId:a.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:n})}null==p||p(!0)}catch(t){s({key:a,value:Mn(t)}),null==p||p(!1)}finally{n({key:a,value:!1})}},updateSubAccount:async t=>{},deleteSubAccount:async t=>{const a=fn.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=yo(a,c),s=yo(t.accounts,c);i({accounts:n}),o({accounts:s})}else{const{accounts:t}=r();await e.subTenants.deleteSubTenant(c);const a=yo(t,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Mn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountSettings:async t=>{const a=fn.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=vo(t.accounts,d,c);o({name:c,accounts:n});const s=vo(a,d,c);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenant({tenantId:d},{name:c});const a=vo(t,d,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Mn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountManagement:async r=>{const l=fn.UPDATE_SUB_ACCOUNT_MANAGEMENT;a.setAllAccountsLoader({key:l,value:!0});const{jwt:c,isReseller:u,callback:d,tenantId:p,shouldUpdateSelectedAccount:g}=r,h=!!c;try{if(g){const{selectedAccount:a,accounts:n}=t.auth.allAccountsState;await e.subTenants.updateSubTenantManagement({tenantId:p},{isReseller:u},c?{jwt:c}:void 0);const s=fo(a.accounts,p,null!=u&&u);o({accounts:s}),h||o({isReseller:u});const r=fo(n,p,null!=u&&u);i({accounts:r})}else{const{accounts:a}=t.auth.allAccountsState;e.subTenants.updateSubTenantManagement({tenantId:p},{isReseller:u},c?{jwt:c}:void 0);const n=fo(a,p,null!=u&&u);i({accounts:n})}null==d||d(!0)}catch(t){s({key:l,value:Mn(t)}),null==d||d(!1)}finally{n({key:l,value:!1})}},updateSubAccountHierarchySettings:async t=>{const a=fn.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=So(t.accounts,u,d);o({subAccountAccessType:d,accounts:n});const s=So(a,u,d);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d});const a=So(t,u,d);i({accounts:a})}null==c||c(!0)}catch(t){s({key:a,value:Mn(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=fn.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:Mn(t)}),null==r||r(!1)}finally{n({key:d,value:!1})}},getAccountUsers:l,deleteUsersFromAccount:async t=>{const a=fn.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:Mn(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=fn.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:Mn(t)}),null==c||c(!1)}finally{n({key:u,value:!1})}},getUserJwtForSubAccount:async t=>{const{tenantId:a,callback:i}=t,r=fn.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:Mn(t)}),o({accessPermission:!1}),null==i||i(!1)}finally{n({key:r,value:!1})}},setRootAccountData:async()=>{const a=fn.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:v({},l,a)})}catch(t){s({key:a,value:Mn(t)})}finally{n({key:a,value:!1})}},setSelectedSubAccountData:async t=>{const{jwt:a}=t,i=fn.SET_SELECTED_SUB_ACCOUNT_DATA;try{var r,c,u,d,p,g,h;n({key:i,value:!0});const t=await e.accountSettings.getSettings({jwt:a}),[s,y,S]=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=S[0])?void 0:d.totalSubTenants,accountSettings:t,accounts:{name:t.name,tenantId:null!=(p=t.tenantId)?p:"",numberOfUsers:null==(g=s[0])?void 0:g.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:Mn(t)})}finally{n({key:i,value:!1})}},loadNumberOfUsersForSelectedSubAccount:async t=>{const{tenantId:a,jwt:i}=t,r=fn.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:Mn(t)})}finally{n({key:r,value:!1})}}}},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:Ta.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:[]}},Ao=t=>Rn(bo,t),wo=(t,e,a)=>{const n=za(bo);return{setAllAccountDialogsState:e=>{Object.assign(t.auth.allAccountsDialogsState,e)},resetAllAccountDialogsState:()=>{t.auth.allAccountsDialogsState=za(bo)},openCreateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.createSubAccountDialog,v({},e,{open:!0}))},closeCreateSubAccountDialog:()=>{t.auth.allAccountsDialogsState.createSubAccountDialog=n.createSubAccountDialog},openUpdateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountDialog,v({},e,{open:!0}))},closeUpdateSubAccountDialog:()=>{t.auth.allAccountsDialogsState.updateSubAccountDialog=n.updateSubAccountDialog},openEnableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.enableSubAccountManagementDialog,v({},e,{open:!0}))},closeEnableSubAccountManagementDialog:()=>{t.auth.allAccountsDialogsState.enableSubAccountManagementDialog=n.enableSubAccountManagementDialog},openUpdateSubAccountHierarchySettingsDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountHierarchySettingsDialog,v({},e,{open:!0}))},closeUpdateSubAccountHierarchySettingsDialog:()=>{t.auth.allAccountsDialogsState.updateSubAccountHierarchySettingsDialog=n.updateSubAccountHierarchySettingsDialog},openDisableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.disableSubAccountManagementDialog,v({},e,{open:!0}))},closeDisableSubAccountManagementDialog:()=>{t.auth.allAccountsDialogsState.disableSubAccountManagementDialog=n.disableSubAccountManagementDialog},openDeleteSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteSubAccountDialog,v({},e,{open:!0}))},closeDeleteSubAccountDialog:()=>{t.auth.allAccountsDialogsState.deleteSubAccountDialog=n.deleteSubAccountDialog},openAddUsersToAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.addUsersToAccountDialog,v({},e,{open:!0}))},closeAddUsersToAccountDialog:()=>{t.auth.allAccountsDialogsState.addUsersToAccountDialog=n.addUsersToAccountDialog},openDeleteUserFromAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteUserFromAccountDialog,v({},e,{open:!0}))},closeDeleteUserFromAccountDialog:()=>{t.auth.allAccountsDialogsState.deleteUserFromAccountDialog=n.deleteUserFromAccountDialog},openEditUserRolesDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.editUserRolesDialog,v({},e,{open:!0}))},closeEditUserRolesDialog:()=>{t.auth.allAccountsDialogsState.editUserRolesDialog=n.editUserRolesDialog}}},To={devices:[],loading:!1,error:null},Eo=t=>Rn(To,t),Io=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.passkeysState,e)};return{setPasskeysState:s,resetPasskeysState:()=>{t.auth.passkeysState=za(To)},loadWebAuthnDevices:async()=>{s({loading:!0});try{const{devices:t}=await e.auth.getWebAuthnDevices();s({devices:t,loading:!1})}catch(t){s({loading:!1,error:Mn(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:Mn(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===Vt.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)}}}},Oo={loading:!1,error:null},Po=t=>Rn(Oo,t),ko=["callback","profilePictureUrl"],_o=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.profileState,e)};return{setProfileState:s,resetProfileState:()=>{t.auth.profileState=za(Oo)},loadProfile:async()=>{s({loading:!0});try{const a=await qa(e.teams.getProfile,3,2e3),i=t.auth.user;n.setUser(v({},i,a)),s({profile:a,loading:!1})}catch(t){s({loading:!1,error:Mn(t)})}},saveProfile:async a=>{const{callback:i,profilePictureUrl:o}=a,r=f(a,ko);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=vi(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=v({},a,r,{profilePictureUrl:s}),u=await e.users.updateUserProfileV2(c),d=t.auth.user;n.setUser(v({},d,u)),n.setProfileState({profile:u,saving:!1,loading:!1}),null==i||i(c)}catch(t){s({saving:!1,error:Mn(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:Mn(e)}),null==(n=t.callback)||n.call(t,null,e)}}}},Uo={loading:!1},Lo=t=>Rn(Uo,t),Ro=["callback"],Do=["id"],Co=(t,e,a)=>{const n=e=>{Object.assign(t.auth.provisioningState,e)},s=async t=>{const{count:a}=await e.directory.countConfigurationUsers(t.id);return v({},t,{count:a})};return{setProvisioningState:n,resetProvisioningState:()=>{t.auth.provisioningState=za(Uo)},__loadCountForConnection:s,loadProvisionConnections:async()=>{n({loading:!0,error:null});try{const t=await e.directory.getConfigs(),a=await Promise.all(t.map((t=>s(t))));n({connections:a,loading:!1})}catch(t){n({error:Mn(t),loading:!1})}},createProvisionConnection:async t=>{const{callback:a}=t,i=f(t,Ro);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:Mn(t),loading:!1})}},deleteProvisionConnection:async t=>{const{id:a,callback:i}=t;n({loading:!0,error:null});try{await e.directory.deleteConfiguration(a);const t=await e.directory.getConfigs(),o=await Promise.all(t.map((t=>s(t))));n({connections:o,loading:!1}),null==i||i(!0)}catch(t){n({error:Mn(t),loading:!1}),null==i||i(!1,t)}},updateProvisionConnection:async t=>{const{id:a}=t,i=f(t,Do);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:Mn(t),loading:!1})}}}},No={step:mn.ResetPhoneNumber,loading:!1},Mo=t=>Rn(No,t),Fo=["callback"],xo=["callback"],$o=["callback"],Go=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.resetPhoneNumberState,e)};return{setResetPhoneNumberState:s,resetResetPhoneNumberState:()=>{t.auth.resetPhoneNumberState=za(No)},resetPhoneNumber:async t=>{const{callback:a}=t,i=f(t,Fo);s({loading:!0});try{const t=await e.auth.resetPhoneNumber(i);s({loading:!1,error:void 0,resetPhoneNumberToken:t.resetPhoneNumberToken,step:mn.VerifyResetPhoneNumber}),n.setLoginState({email:i.email})}catch(t){s({loading:!1,error:Mn(t)}),null==a||a(null,t)}},verifyResetPhoneNumber:async t=>{const{callback:a}=t,n=f(t,xo);s({loading:!0});try{const t=await e.auth.verifyResetPhoneNumber(n);s({loading:!1,error:void 0,changePhoneNumberToken:t.changePhoneNumberToken,step:mn.ChangePhoneNumber}),null==a||a(!0)}catch(t){s({loading:!1,error:Mn(t)}),null==a||a(null,t)}},changePhoneNumber:async a=>{const{callback:i}=a,o=f(a,$o);s({loading:!0});try{const{onRedirectTo:a,routes:r}=t.auth;await e.auth.changePhoneNumber({phoneNumber:o.phoneNumber,changePhoneNumberToken:o.changePhoneNumberToken}),n.setLoginState({step:gn.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:Mn(t)}),null==i||i(null,t)}}}},jo={loaders:{},errors:{},roles:[],permissions:[],permissionCategories:[]},Vo=t=>Rn(jo,t),Bo=["callback"],Wo=["callback"],Ho=["callback"],zo=["callback"],Ko=["callback"],qo=["callback"],Jo=(t,e,a)=>{const n=e=>{Object.assign(t.auth.rolesState,e)},s=e=>{Object.assign(t.auth.rolesState,{loaders:v({},t.auth.rolesState.loaders,{[e.key]:e.value})})},i=e=>{Object.assign(t.auth.rolesState,{errors:v({},t.auth.rolesState.errors,{[e.key]:e.value}),loaders:v({},t.auth.rolesState.loaders,{[e.key]:!1})})},o=async a=>{var o;const r=bn.LOAD_ROLES;s({key:r,value:!(null!=(o=null==a?void 0:a.silentLoading)&&o)});try{const[a,s,i]=await Promise.all([e.roles.getRoles(),e.roles.getPermissions(),e.roles.getPermissionCategories()]),{selectedRole:o}=t.auth.rolesState,r=null==a?void 0:a.find((({id:t})=>(null==o?void 0:o.id)===t));n({roles:a,permissions:s,permissionCategories:i,selectedRole:r})}catch(t){i({key:r,value:Mn(t)})}finally{s({key:r,value:!1})}},r=async t=>{const{callback:a}=t,r=f(t,Ko),l=bn.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:Mn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}};return{setRolesState:n,setRolesStateLoader:s,setRolesStateError:i,resetRolesState:()=>{t.auth.rolesState=za(jo)},loadRolesAndPermissions:o,addRole:async t=>{const{callback:a}=t,n=f(t,Bo),r=bn.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:Mn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},addRoleV2:async t=>{const{callback:a}=t,n=f(t,Wo),r=bn.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:Mn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},updateRole:async t=>{const{callback:a}=t,r=f(t,Ho),l=bn.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:Mn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}},deleteRole:async t=>{const{callback:a}=t,r=f(t,zo),l=bn.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:Mn(t)}),null==a||a(!1,t)}finally{s({key:l,value:!1})}},attachPermissionsToRole:r,attachPermissionToRoles:async t=>{const{callback:e}=t,a=f(t,qo),n=bn.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:Mn(t)}),null==e||e(null,t)}finally{s({key:n,value:!1})}}}},Yo={ipRestrictions:{loading:!1,pagination:{_offset:0,_limit:4,_filter:jt.ALLOW},totalPages:1,userIpValid:!1},emailDomainRestrictions:{loading:!0}},Qo=t=>Rn(Yo,t),Xo=["callback"],Zo=["callback"],tr=["callback"],er=["callback"],ar=(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(),await n.loadInsights())},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:Mn(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:Mn(t),loading:!1})}})),u=i((async a=>{const{callback:n}=a,i=f(a,Xo);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:p}}=await e.auth.getIPRestrictions(u),g=d;await l(),o({data:{config:null!=(r=null==(c=a.data)?void 0:c.config)?r:{isActive:!1,strategy:jt.ALLOW},restrictions:g},pagination:u,totalPages:p,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Mn(t)}),null==n||n(null,t)}})),d=i((async a=>{const{callback:n}=a,i=f(a,Zo);o({saving:!0,error:null});try{await e.auth.updateIPRestrictionConfig(i);const a=t.auth.restrictionsState.ipRestrictions,r=await e.auth.getIPRestrictionsConfig(),c=s(v({},a.pagination,{_filter:r.strategy})),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),p=u;await l(),o({data:{config:r,restrictions:p},pagination:c,totalPages:d,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Mn(t)}),null==n||n(null,t)}})),p=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),p=u;await l(),o({data:{config:(null==(r=a.data)?void 0:r.config)||{isActive:!1,strategy:jt.ALLOW},restrictions:p},pagination:c,totalPages:d,saving:!1}),null==i||i(!0)}catch(t){o({saving:!1,error:Mn(t)}),null==i||i(null,t)}})),g=i(l),h=i((async a=>{const{callback:n}=a;o({saving:!0,error:null});try{var i;const a=null!=(i=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 r=t.auth.restrictionsState.ipRestrictions,l=s(r.pagination),{items:c,_metadata:{totalPages:u}}=await e.auth.getIPRestrictions(l),d=c;o({data:{config:{isActive:!0,strategy:jt.ALLOW},restrictions:d},userIpValid:!0,pagination:l,totalPages:u,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:Mn(t),loading:!1})}})),S=i((async a=>{const{callback:n}=a,s=f(a,tr);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:Mn(t)}),null==n||n(null,t)}})),m=i((async t=>{const{callback:a}=t,n=f(t,er);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:Mn(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:Mn(t)})}}));return{setRestrictionsState:e=>{Object.assign(t.auth.restrictionsState,e)},setIpRestrictionsState:o,setEmailDomainRestrictionsState:r,__securityCenterSagaWrapper:i,loadIpRestrictions:c,saveIpRestriction:u,saveIpRestrictionsConfig:d,deleteIpRestriction:p,checkIfUserIpValid:g,addCurrentUserIpAndActivate:h,loadEmailDomainRestrictions:y,saveEmailDomainRestriction:S,saveEmailDomainRestrictionsConfig:m,deleteEmailDomainRestriction:b}},nr={loaders:{},errors:{},recommendations:void 0,insights:void 0,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}}},sr=t=>Rn(nr,t),ir=["callback"],or=(t,e,a)=>{const n=a,s=async t=>{var a,s,l,c;const{key:u,tableState:d,updateStateKey:p,_offset:g,_limit:h,_preset:y,_email:S,_maxInactiveSeconds:f}=t;r({key:u,value:!1}),o({key:u,value:!0});const m=null!=(a=null!=g?g: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=v({_offset:m,_limit:b,_includeSubTenants:!1,_preset:y,_maxInactiveSeconds:f},!!S&&{_email:S});try{const{items:t,_metadata:{totalItems:a,totalPages:s}}=await e.users.getUsersV3(A),o={totalUsersItems:a,totalUsersPages:s,usersPageOffset:m,queryParams:v({_offset:m,_limit:b,_maxInactiveSeconds:f},!!S&&{_email:S})};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 v({},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({[p]:v({users:a},o)})}else i({[p]:v({users:[]},o)})}catch(t){r({key:u,value:Mn(t)})}finally{o({key:u,value:!1})}},i=e=>{Object.assign(t.auth.securityCenterState,e)},o=e=>{Object.assign(t.auth.securityCenterState,{loaders:v({},t.auth.securityCenterState.loaders,{[e.key]:e.value})})},r=e=>{Object.assign(t.auth.securityCenterState,{errors:v({},t.auth.securityCenterState.errors,{[e.key]:e.value}),loaders:v({},t.auth.securityCenterState.loaders,{[e.key]:!1})})};return{setSecurityCenterState:i,resetSecurityCenterState:()=>{t.auth.securityCenterState=za(nr)},setSecurityCenterStateLoader:o,setSecurityCenterStateError:r,loadRecommendations:async()=>{const t=An.RECOMMENDATIONS;o({key:t,value:!0});try{var a;const{recommendations:t,scoring:n}=await e.securityCenter.getRecommendations();i({recommendations:t.items,score:null!=(a=null==n?void 0:n.score)?a:0})}catch(e){r({key:t,value:Mn(e)})}finally{o({key:t,value:!1})}},loadInsights:async()=>{const t=An.INSIGHTS;o({key:t,value:!0});try{const{insights:t}=await e.securityCenter.getInsights();i({insights:t.items})}catch(e){r({key:t,value:Mn(e)})}finally{o({key:t,value:!1})}},sendResetBreachedPasswordEmail:async t=>{const{callback:a}=t,n=f(t,ir),s=An.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:Mn(t)}),null==a||a(!1,t)}finally{o({key:s,value:!1})}},sendBulkResetBreachedPasswordEmails:async t=>{const{callback:a}=t,n=An.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:Mn(t)}),null==a||a(!1)}finally{o({key:n,value:!1})}},loadBreachedPasswordUsers:async e=>{var a;const n=An.BREACHED_PASSWORD_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.breachedPasswordUsersTable;await s(v({key:n,updateStateKey:"breachedPasswordUsersTable",_preset:Na.BREACHED_PASSWORDS,tableState:i},e))},loadUnenrolledMfaUsers:async e=>{var a;const n=An.UNENROLLED_MFA_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.unenrolledMfaUsersTable;await s(v({key:n,updateStateKey:"unenrolledMfaUsersTable",_preset:Na.MFA_UNENROLLED,tableState:i},e))},loadInactiveUsers:async e=>{var a;const n=An.INACTIVE_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.inactiveUsersTable;await s(v({key:n,updateStateKey:"inactiveUsersTable",_preset:Na.INACTIVE,tableState:i},e))}}},rr={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}},lr=t=>Rn(rr,t),cr=["callback"],ur=["callback"],dr=["callback"],pr=(t,e,a)=>{const n=a,s=async t=>{var e,a;if(!await n.customLoginEnabled())return t;const s=await i();return null!=s&&null!=(e=s.mainAuthStrategies)&&null!=(a=e[0])&&a.strategy?v({},t,{authStrategy:s.mainAuthStrategies[0].strategy}):t},i=async()=>{let a;return a=t.auth.isAuthenticated?await e.auth.getPublicAuthStrategiesConfigForAuthenticatedUser():await e.auth.getVendorPublicAuthStrategiesConfig(),a},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)},p=e=>{Object.assign(t.auth.securityPolicyState.captchaPolicy,e)},g=e=>{Object.assign(t.auth.securityPolicyState.passwordHistoryPolicy,e)},h=e=>{Object.assign(t.auth.securityPolicyState.vendorPasswordHistoryPolicy,e)},y=e=>{Object.assign(t.auth.securityPolicyState.passwordPolicy,e)},S=e=>{Object.assign(t.auth.securityPolicyState.publicAuthStrategyPolicy,e)},m=async()=>{o({loading:!0,error:null});try{const t=await e.auth.getGlobalSecurityPolicy();o({policy:t,loading:!1})}catch(t){o({error:Mn(t),loading:!1})}},b=async()=>{l({loading:!0,error:null});try{const t=await e.auth.getMfaPolicy();l({policy:t,loading:!1})}catch(t){l({error:Mn(t),loading:!1})}},A=async()=>{l({loading:!0,error:null});try{const t=await e.auth.getVendorMfaPolicy();c({policy:t,loading:!1})}catch(t){c({error:Mn(t),loading:!1})}},w=async()=>{u({loading:!0,error:null});try{const t=await e.auth.getLockoutPolicy();u({policy:t,loading:!1})}catch(t){u({error:Mn(t),loading:!1})}},T=async()=>{d({loading:!0,error:null});try{const t=await e.auth.getVendorLockoutPolicy();d({policy:t,loading:!1})}catch(t){d({error:Mn(t),loading:!1})}},E=async()=>{u({loading:!0,error:null});try{const t=await e.auth.getCaptchaPolicy();p({policy:t,loading:!1})}catch(t){p({error:Mn(t),loading:!1})}},I=async()=>{h({loading:!0,error:null});try{const t=await e.auth.getVendorPasswordHistoryPolicy();h({policy:t,loading:!1})}catch(t){h({error:Mn(t),loading:!1})}},O=async()=>{S({loading:!0,error:null});try{var e,a;const s=await i();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:v({},o,{authStrategy:e}),loading:!1})})(null==s||null==(e=s.mainAuthStrategies)||null==(a=e[0])?void 0:a.strategy),S({policy:s,loading:!1})}catch(t){S({error:Mn(t),loading:!1})}};return{setSecurityPolicyState:e=>{Object.assign(t.auth.securityPolicyState,e)},setSecurityPolicyGlobalState:o,setSecurityPolicyPublicState:r,setSecurityPolicyMfaState:l,setSecurityPolicyVendorMfaState:c,setSecurityPolicyLockoutState:u,setSecurityPolicyVendorLockoutState:d,setSecurityPolicyCaptchaState:p,setSecurityPolicyPasswordHistoryState:g,setSecurityPolicyVendorPasswordHistoryState:h,resetSecurityPolicyState:()=>{t.auth.securityPolicyState=za(rr)},setSecurityPolicyPasswordState:y,setSecurityPolicyAuthStrategyPublicState:S,loadSecurityPolicy:async()=>{await Promise.all([m(),b(),A(),w(),T(),I(),E(),O()])},loadGlobalSecurityPolicy:m,loadPublicSecurityPolicy:async()=>{r({loading:!0,error:null});try{const t=await e.auth.getVendorConfig(),a=await s(t);r({policy:a,loading:!1})}catch(t){r({error:Mn(t),loading:!1})}},loadVendorPasswordConfig:async()=>{y({loading:!0,error:null});try{const t=await e.auth.getPasswordConfigPolicy();y({policy:t,loading:!1})}catch(t){y({error:Mn(t),loading:!1})}},loadSecurityPolicyMfa:b,loadSecurityPolicyVendorMfa:A,loadSecurityPolicyLockout:w,loadSecurityPolicyVendorLockout:T,loadSecurityPolicyCaptcha:E,loadSecurityPolicyPasswordHistory:async()=>{g({loading:!0,error:null});try{const t=await e.auth.getPasswordHistoryPolicy();g({policy:t,loading:!1})}catch(t){g({error:Mn(t),loading:!1})}},loadSecurityPolicyVendorPasswordHistory:I,loadPublicAuthStrategiesPolicy:O,saveSecurityPolicyMfa:async t=>{const{callback:a}=t,n=f(t,cr);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:Mn(t)}),null==a||a(null,t)}},saveSecurityPolicyLockout:async t=>{const{callback:a}=t,n=f(t,ur);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:Mn(t)}),null==a||a(null,t)}},saveSecurityPolicyPasswordHistory:async t=>{const{callback:a}=t,n=f(t,dr);g({saving:!0,error:null});try{const t=await e.auth.savePasswordHistoryPolicy(n);g({policy:t,saving:!1}),null==a||a(t)}catch(t){g({saving:!1,error:Mn(t)}),null==a||a(null,t)}},__getSecurityPolicyPublicStateWithCustomLogin:s}},gr={loading:!1,configurations:{}},hr=t=>Rn(gr,t),yr=["callback"],Sr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.sessionsPolicyState,e)};return{setSessionsPolicyState:s,resetSessionsPolicyState:()=>{t.auth.sessionsPolicyState=za(gr)},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})}}}},vr={loading:!1,sessions:[]},fr=t=>Rn(vr,t),mr=(t,e,a)=>{const n=e=>{Object.assign(t.auth.sessionsState,e)},s=async()=>{n({loading:!0,error:null});try{const t=await e.auth.getCurrentUserSessions();n({sessions:t,loading:!1})}catch(t){n({error:Mn(t),loading:!1})}};return{setSessionsState:n,resetSessionsState:()=>{t.auth.sessionsState=za(vr)},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:Mn(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:Mn(t),loading:!1})}},deleteAllUserSessions:async()=>{n({loading:!0,error:null});try{await e.auth.deleteAllSessionsForUser(),await s()}catch(t){n({error:Mn(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:Mn(t),loading:!1}),null==a||a(!1)}}}},br={loading:!1,allowSignUps:!1,allowNotVerifiedUsersLogin:!1,firstLoad:!0,stage:wn.SignUp},Ar=t=>Rn(br,t),wr=["events","url"],Tr=(t,e,a)=>{const n=a,s=L.for(t.root.appName),i=e=>{Object.assign(t.auth.signUpState,e)},o=()=>{t.auth.signUpState=za(br)};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,url:r}=a,l=f(a,wr);i({loading:!0});try{const{routes:a,onRedirectTo:s}=t.auth,{shouldActivate:u,user:d,tenantId:p,userId:g,tenants:h=[],activeTenant:y}=await e.auth.signUpUser(As(l));if(!l.invitationToken){var c;const{email:t,name:e,companyName:a,phoneNumber:n}=l,s={email:t,name:e,companyName:a,url:r,phoneNumber:n||void 0,authenticationType:Pn.PASSWORD,id:g,tenantId:p,createdAt:new Date};null==o||null==(c=o.signUpComplete)||c.call(o,s),Hn(Wn.SIGNUP_COMPLETED,s)}if(!u&&d&&fs(d,t.root.appName)){const t=await n.getMfaRequiredState(d);n.setAuthState(t),s(a.loginUrl)}else{const e=t.auth.tenantsState;i({loading:!1,shouldActivate:u,stage:wn.SignUpSuccess}),n.setAuthState({user:d,isAuthenticated:!(null==d||!d.accessToken),tenantsState:v({},e,{tenants:h,activeTenant:y})})}}catch(t){s.setAccessToken(null),s.setUser(null),i({error:Mn(t)})}finally{i({loading:!1})}},loadAllowSignUps:async()=>{i({loading:!0});try{const t=await e.auth.getVendorConfig(),a=await n.__getSecurityPolicyPublicStateWithCustomLogin(t),{allowSignups:s,allowNotVerifiedUsersLogin:o}=t;i({loading:!1,allowSignUps:s,allowNotVerifiedUsersLogin:o,firstLoad:!1}),n.setSecurityPolicyPublicState({policy:a,loading:!1})}catch(t){i({loading:!1,error:Mn(t),firstLoad:!1})}}}},Er={loading:!1,error:null,phoneNumbers:void 0},Ir=t=>Rn(Er,t),Or=["callback"],Pr=["callback"],kr=["callback","phoneId"],_r=["callback","phoneId"],Ur=["callback"],Lr=(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:Mn(t)})}finally{n({loading:!1})}};return{setSmsState:n,resetSmsState:()=>{t.auth.smsState=za(Er)},loadPhoneNumbers:s,setUpPhoneNumber:async t=>{const{callback:a}=t,i=f(t,Or);n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.createPhoneNumber(i);n({otcToken:t}),await s(),null==a||a(!0)}catch(t){n({error:Mn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},verifyPhoneNumber:async t=>{const{callback:a}=t,i=f(t,Pr);n({loading:!0});try{await e.userPhoneNumbers.verifyPhoneNumber(i),await s(),null==a||a(!0)}catch(t){n({error:Mn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},deletePhoneNumber:async t=>{const{callback:a,phoneId:s}=t;f(t,kr),n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.deletePhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Mn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},verifyDeletePhoneNumber:async t=>{const{callback:a,phoneId:i}=t,o=f(t,_r);n({loading:!0});try{await e.userPhoneNumbers.verifyDeletePhoneNumber(i,o),await s(),null==a||a(!0)}catch(t){n({error:Mn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},preVerifyPhoneNumber:async t=>{const{callback:a}=t,s=f(t,Ur);n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.preVerifyPhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Mn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}}}},Rr={firstLoad:!0,loading:!1,error:""},Dr=t=>Rn(Rr,t),Cr=["authorizationUrl"],Nr=["events","url"],Mr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.socialLoginState,e)};return{setSocialLoginsState:s,resetSocialLoginsState:()=>{t.auth.socialLoginState=za(Rr)},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:Mn(t),loading:!1,firstLoad:!1})}},loadSocialLoginsConfigurationV2:async a=>{try{var n;const i=t.root.context;s({loading:!0});const o=await(async()=>{let a;return a=t.auth.isAuthenticated?await e.auth.getSocialLoginProvidersV2ForAuthenticatedUser():await e.auth.getSocialLoginProvidersV2(),a})(),{providers:r}=await e.auth.getCustomSocialLoginProvidersV1(),l={socialLoginsConfigV2:o.map((t=>{let{authorizationUrl:a}=t,n=f(t,Cr);const s=e.fetch.getBaseUrl(i,null!=a?a:"");return v({},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:Mn(t),loading:!1,firstLoad:!1})}},loginViaSocialLogin:async t=>{const{events:a,url:i}=t,o=f(t,Nr);try{s({loading:!0});const{email:t,isNewUser:c,userId:u,tenantId:d,name:p}=await e.auth.loginViaSocialLogin(o);if(c){var r,l;const e={email:t,url:i,createdAt:new Date,id:u,tenantId:d},n=v({},e,{socialProvider:o.provider,authenticationType:Pn.SOCIAL_LOGIN});null==a||null==(r=a.signUpComplete)||r.call(a,n),Hn(Wn.SIGNUP_COMPLETED,n);const s=v({},e,{origin:On.SOCIAL_LOGIN,name:p});null==a||null==(l=a.userVerified)||l.call(a,s),Hn(Wn.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:Mn(t,"Failed to authenticate"),firstLoad:!1})}}}},Fr={firstLoad:!0,loading:!0,saving:!1,errors:{},loaders:{},ssoConfigurations:[]},xr=t=>Rn(Fr,t),$r=["callback","samlVendor"],Gr=["callback"],jr=["callback","ssoConfigId"],Vr=["callback","ssoConfigId"],Br=["callback","ssoConfigId"],Wr=(t,e,a)=>v({},((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:Mn(t)})}},i=e=>{Object.assign(t.auth.ssoState,e)};return{setSSOState:i,resetSSOState:()=>{t.auth.ssoState=za(Fr)},setSSOLoader:e=>{Object.assign(t.auth.ssoState,{loaders:v({},t.auth.ssoState.loaders,{[e.key]:e.value})})},setSSOError:e=>{Object.assign(t.auth.ssoState,{errors:v({},t.auth.ssoState.errors,{[e.key]:e.value}),loaders:v({},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:Mn(t),loading:!1})}},saveSSOConfigurations:async a=>{const{callback:n,samlVendor:s}=a,o=f(a,$r),r=t.auth.ssoState.samlConfiguration,l=v({},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:v({},r,l)});if(i({error:void 0,[c]:!0}),a.type===En.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=Ja(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:Mn(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 mi(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:Mn(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 mi(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:Mn(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:v({},s,{validated:!0}),error:void 0,saving:!1}),null==n||n(!0)}catch(t){i({samlConfiguration:v({},s,{validated:!1}),error:Mn(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:Mn(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:Mn(t)})}})(o),await s(),i({error:void 0,saving:!1}),null==a||a(!0)}catch(t){i({error:Mn(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:Mn(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:Mn(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:Mn(t,"Failed to authenticate"),firstLoad:!1})}}}})(t,e,a),((t,e,a)=>{const n=a,s=async()=>{try{return await e.auth.getOidcConfiguration()}catch(t){return null}},i=async()=>{try{return await e.metadata.getSamlMetadata()}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:Mn(a)}),null==e||e(null,a)}finally{n.setSSOLoader({key:t,value:!1})}};return{loadSSOConfigurationsV2:async()=>{await o(Tn.LOAD_SSO_CONFIGURATIONS,void 0,(async()=>{const[t,a]=await Promise.all([s(),i()]),o=await e.auth.getSSOConfigurations();n.setSSOState({ssoConfigurations:o,oidcConfiguration:t,samlMetadata:a})}))},saveSSOConfigurationV2:async a=>{const{callback:s}=a,i=f(a,Gr),r=t.auth.ssoState.ssoConfigurations;await o(Tn.SAVE_SSO_CONFIGURATION,s,(async()=>{var t;const a=await e.auth.createSSOConfiguration(v({},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,jr),l=t.auth.ssoState.ssoConfigurations;await o(Tn.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(Tn.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,Vr),l=t.auth.ssoState.ssoConfigurations;await o(Tn.SAVE_SSO_DOMAIN,s,(async()=>{const t=await e.auth.createSSODomain(i,r),a=l.map((e=>e.id===i?v({},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(Tn.DELETE_SSO_DOMAIN,r,(async()=>{await e.auth.deleteSSODomain(s,i);const t=l.map((t=>t.id===s?v({},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(Tn.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?v({},t,{domains:t.domains.map((t=>t.id===i?v({},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(Tn.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?v({},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(Tn.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(Tn.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?v({},t,{roleIds:r}):t));n.setSSOState({ssoConfigurations:o}),null==s||s(!0)}))},saveSSOConfigurationByMetadata:async a=>{const{configFile:s,callback:i}=a;await o(Tn.SAVE_SSO_CONFIGURATION_BY_METADATA,i,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await mi(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(Tn.UPDATE_SSO_CONFIGURATION_BY_METADATA,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await mi(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(Tn.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,Br),l=t.auth.ssoState.ssoConfigurations;await o(Tn.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)),Hr={loading:!1,mfaDevices:void 0,mfaToken:""},zr=t=>Rn(Hr,t),Kr=(t,e,a)=>{const n=a;return v({setStepUpState:e=>{Object.assign(t.auth.stepUpState,e)},resetStepUpState:()=>{t.auth.stepUpState=za(Hr)},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 es(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:vn.noMFAEnrolledStepUp});window.localStorage.setItem(cs,"true");const a=t.auth.routes;L.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:os},{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),hs(),window.localStorage.setItem(cs,"true"),await n.__requestHostedLoginAuthorize(i)}}})(t,0,a))},qr={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}},Jr=t=>Rn(qr,t),Yr=["callback","appIds"],Qr=["roles"],Xr=["callback","profileImage"],Zr=["callback"],tl=["callback"],el=["callback"],al=["callback","userId"],nl=["callback"],sl=["callback"],il=["callback"],ol=["callback"],rl=["callback"],ll=["callback"],cl=(t,e,a)=>{const n=e=>{Object.assign(t.auth.teamState,e)};return v({setTeamLoader:e=>{Object.assign(t.auth.teamState,{loaders:v({},t.auth.teamState.loaders,{[e.key]:e.value})})},setTeamError:e=>{Object.assign(t.auth.teamState,{errors:v({},t.auth.teamState.errors,{[e.key]:e.value}),loaders:v({},t.auth.teamState.loaders,{[e.key]:!1})})},setTeamState:n,resetTeamState:()=>{t.auth.teamState=za(qr)},openAddUserDialog:t=>{n({addUserDialogState:v({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:v({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()=>{try{const{groups:t}=await e.groups.getGroups({_groupsRelations:Ra.roles});return t}catch(t){return[]}},i=async t=>{n.setTeamLoader({key:In.ROLES_AND_PERMISSIONS,value:!0});try{var a;const[{items:s},{items:i}]=await Promise.all([e.teams.loadAvailableRoles(),e.teams.loadAvailablePermissions()]);n.setTeamState({roles:s,permissions:i}),null==t||null==(a=t.callback)||a.call(t,{roles:s,permissions:i})}catch(e){var s;null==t||null==(s=t.callback)||s.call(t,null,e),n.setTeamError({key:In.ROLES_AND_PERMISSIONS,value:Mn(e)})}finally{n.setTeamLoader({key:In.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,p=null!=(s=a.pageSize)?s:d.pageSize,g=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:In.USERS,value:!c}),n.setTeamState({pageSize:p,pageOffset:g,filter:h,sort:y});try{const[{items:t,totalPages:a,totalItems:s}]=await Promise.all([e.teams.loadUsers({pageSize:p,pageOffset:g,filter:h,sort:y}),i()]);n.setTeamState({users:t,totalPages:a,totalItems:s}),null==u||u(t)}catch(t){n.setTeamError({key:In.USERS,value:Mn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:In.USERS,value:!1})},loadUsersV2:async o=>{var r,l,c,u,d;const{silentLoading:p,callback:g,shouldLoadRoles:h=!0,shouldLoadApps:y}=o,S=t.auth.teamState,f=null!=(r=o.pageSize)?r:S.pageSize,m=null!=(l=o.pageOffset)?l:S.pageOffset,b=null!=(c=o.filter)?c:S.filterV2,A=null!=(u=o.sort)?u:S.sortV2,w=null!=(d=null==o?void 0:o.shouldShowSubTenantUsersIfReseller)?d:null==S?void 0:S.shouldShowSubTenantUsersIfReseller;n.setTeamLoader({key:In.USERS,value:!p}),n.setTeamState({pageSize:f,pageOffset:m,filterV2:b,sortV2:A});try{const[{items:t,_metadata:{totalPages:n,totalItems:r}},{items:l},{items:c},u]=await Promise.all([e.users.getUsersV2(v({},(null==b?void 0:b.length)&&{_filter:b},A&&{_sortBy:A},o.order&&{_order:o.order},{_offset:m,_limit:f,_includeSubTenants:w})),e.teams.loadAvailableRoles(),e.teams.loadAvailablePermissions(),s(),h?i():void 0]),d=t.map((t=>{var e;return v({},t,{groups:null==t||null==(e=t.groups)?void 0:e.map((t=>u.filter((e=>e.id===t.id)))).flat()})})).map((t=>v({},t,{roleIds:t.roles.map((t=>t.id))}))),p=await a.mapUsersWithApplicationData({shouldLoadApps:y,users:d});a.setTeamState({users:p,totalPages:n,totalItems:r,roles:l,permissions:c}),null==g||g(t)}catch(t){console.error("Failed to load users",t),n.setTeamError({key:In.USERS,value:Mn(t)}),n.setTeamState({totalPages:0,users:[]}),null==g||g(null,t)}n.setTeamLoader({key:In.USERS,value:!1})},addUser:async s=>{const{callback:i,appIds:o}=s,r=f(s,Yr),l=t.auth.teamState;n.setTeamState({addUserDialogState:v({},l.addUserDialogState,{loading:!0})});try{var c;const t=await e.teams.addUser(r),{roles:s}=t,u=v({},f(t,Qr),{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:v({},l.addUserDialogState,{loading:!1,error:Mn(t)})}),null==i||i(null,t)}},addUsersBulk:async a=>{const{callback:s}=a,i=t.auth.teamState;n.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})});const o=[],r=[],l=a.emails.map((t=>v({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,Xr),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));if(void 0!==l){n.setTeamLoader({key:In.UPDATE_USER,value:o||""}),n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0})}),n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0}),users:r.users.map((t=>t.id===i.id?v({},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?v({},e,t,{groups:e.groups,createdAt:e.createdAt,customData:e.customData,lastLogin:e.lastLogin}):e))}),n.setTeamLoader({key:In.UPDATE_USER,value:!1})}catch(t){n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!1,error:Mn(t)}),users:r.users.map((t=>t.id===i.id?v({},t,l):t))}),n.setTeamLoader({key:In.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,Zr),o=t.auth.teamState;n.setTeamState({deleteUserDialogState:v({},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:v({},o.deleteUserDialogState,{loading:!1,error:Mn(t)})}),null==s||s(null,t)}},enableUser:async a=>{const{callback:s,userId:i}=a,o=t.auth.teamState;n.setTeamState({enableUserDialogState:v({},o.enableUserDialogState,{loading:!0})});try{await e.teams.enableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((t=>t.id===i?v({},t,{isDisabled:!1}):t)),enableUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({enableUserDialogState:v({},o.enableUserDialogState,{loading:!1,error:Mn(t)})}),null==s||s(null,t)}},disableUser:async a=>{const{callback:s,userId:i}=a,o=t.auth.teamState;n.setTeamState({disableUserDialogState:v({},o.disableUserDialogState,{loading:!0})});try{await e.teams.disableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((t=>t.id===i?v({},t,{isDisabled:!0}):t)),disableUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({disableUserDialogState:v({},o.disableUserDialogState,{loading:!1,error:Mn(t)})}),null==s||s(null,t)}},getTemporaryUsersConfig:async()=>{n.setTeamError({key:In.CONFIG_TEMPORARY_USERS,value:!1});try{const t=await e.teams.getTemporaryUserConfiguration();n.setTeamState({temporaryUsersConfig:t})}catch(t){n.setTeamError({key:In.CONFIG_TEMPORARY_USERS,value:Mn(t)})}},updateUserExpirationTime:async a=>{const{callback:s}=a,i=f(a,tl),o=t.auth.teamState;n.setTeamLoader({key:In.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?v({},e,{temporaryExpirationDate:new Date(t.temporaryExpirationDate)}):e))}),null==s||s(!0)}catch(t){n.setTeamError({key:In.UPDATE_USER_EXPIRATION_TIME,value:Mn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!1})}},setUserAsPermanent:async a=>{const{callback:s}=a,i=f(a,el),o=t.auth.teamState;n.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!0});try{await e.teams.setPermanentUser(i.userId),n.setTeamState({users:o.users.map((t=>t.id===i.userId?v({},t,{temporaryExpirationDate:void 0}):t))}),null==s||s(!0)}catch(t){n.setTeamError({key:In.UPDATE_USER_EXPIRATION_TIME,value:Mn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:In.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,p={_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:In.USERS,value:!c}),n.setTeamState({allUsersQueryParams:p});try{const[{items:t,_metadata:{totalPages:a,totalItems:s}},{items:i},{items:o}]=await Promise.all([e.subTenants.loadAllUsers(v({},p)),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:In.USERS,value:Mn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:In.USERS,value:!1})},setUserRolesForSubTenants:async a=>{const{callback:s,userId:i}=a,o=f(a,al),r=t.auth.teamState;n.setTeamState({addUserDialogState:v({},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 v({},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?[v({},t,{tenants:a})]:[]],addUserDialogState:{open:!1,loading:!1}}),null==s||s(!0)}catch(t){n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!1,error:Mn(t)})}),null==s||s(null,t)}},deleteUserFromSubTenants:async a=>{const{callback:s}=a,i=f(a,nl),o=t.auth.teamState;n.setTeamState({deleteUserDialogState:v({},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:v({},o.deleteUserDialogState,{loading:!1,error:Mn(t)})}),null==s||s(null,t)}},addUserToSubTenants:async a=>{const{callback:s}=a,i=f(a,sl),o=t.auth.teamState;n.setTeamState({addUserDialogState:v({},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:v({},o.addUserDialogState,{loading:!1,error:Mn(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:Mn(e)}),null==a||a(null,e)}finally{n.setTeamLoader({key:t,value:!1})}};return{resendActivationLink:async t=>{const{callback:a}=t,n=f(t,il);await s(In.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,ol);await s(In.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,rl);await s(In.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,ll);await s(In.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()=>{n.setTeamError({key:In.GET_TOKEN_LINK,value:!1});try{await(async()=>{n.setTeamError({key:In.CONFIG_TOKEN_LINK,value:!1});try{const t=await e.teams.getInviteLinkConfiguration();n.setTeamState({inviteTokenState:v({},t)})}catch(t){n.setTeamError({key:In.CONFIG_TOKEN_LINK,value:Mn(t)})}})();const a=await e.teams.getInviteUserLink(),{inviteTokenState:s}=t.auth.teamState;n.setTeamState({inviteTokenState:v({},s,a)})}catch(t){n.setTeamError({key:In.GET_TOKEN_LINK,value:Mn(t)})}},createInvitationLink:async a=>{const{callback:s}=a;n.setTeamError({key:In.CREATE_TOKEN_LINK,value:!1});const{inviteTokenState:i}=t.auth.teamState;try{const t=await e.teams.createInviteUserLink({expiresInMinutes:43200});n.setTeamState({inviteTokenState:v({},i,t)}),null==s||s(t.token)}catch(t){null==s||s(null,t),n.setTeamError({key:In.CREATE_TOKEN_LINK,value:Mn(t)})}},updateInvitationLink:async a=>{const{callback:s,expiresInMinutes:i,shouldSendEmail:o}=a;n.setTeamError({key:In.UPDATE_TOKEN_LINK,value:!1});try{const{inviteTokenState:a}=t.auth.teamState,r=await e.teams.updateInviteUserLink({expiresInMinutes:i,shouldSendEmail:o});n.setTeamState({inviteTokenState:v({},a,r)}),null==s||s(!0)}catch(t){null==s||s(null,t),n.setTeamError({key:In.UPDATE_TOKEN_LINK,value:Mn(t)})}},deleteInvitationLink:async t=>{const{callback:a}=null!=t?t:{};n.setTeamError({key:In.DELETE_TOKEN_LINK,value:!1});try{await e.teams.deleteInviteUserLink(),n.setTeamState({inviteTokenState:void 0}),null==a||a(!0)}catch(t){n.setTeamError({key:In.DELETE_TOKEN_LINK,value:Mn(t)}),null==a||a(!1,t)}}}})(t,e,a))},ul={tenants:[],subTenants:[],loading:!0,tenantTree:null},dl=t=>Rn(ul,t),pl=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.tenantsState,e)};return{setTenantsState:s,resetTenantsState:()=>{t.auth.tenantsState=za(ul)},switchTenant:async t=>{const{tenantId:a,callback:s}=t;n.setAuthState({isLoading:!0});try{await e.tenants.switchTenant({tenantId:a}),await n.__refreshToken(),(null==s?void 0:s(!0))||n.setAuthState({isLoading:!1})}catch(t){n.setAuthState({isLoading:!1}),null==s||s(!1,t)}},loadTenants:async e=>{s({loading:!0});try{var a;const n=oe(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 e.tenants.getSubTenants();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)}}}},gl=(t,e,a)=>{const n=e=>{t.auth.user&&(t.auth.user.entitlements=e)},s=e=>{var a;ln(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)}}}},hl=["routes"],yl=t=>{const e=null!=t?t:{},{routes:a}=e,n=f(e,hl);return Rn(v({routes:v({},Kn,a),onRedirectTo:()=>{},isAuthenticated:!1,isLoading:!0,isSSOAuth:!1,user:null,error:void 0,userIp:void 0},n,{acceptInvitationState:Cn(null==n?void 0:n.acceptInvitationState),accountSettingsState:$n(null==n?void 0:n.accountSettingsState),activateAccountState:Bn(null==n?void 0:n.activateAccountState),unlockAccountState:_s(null==n?void 0:n.unlockAccountState),apiTokensState:Rs(null==n?void 0:n.apiTokensState),applicationsState:Ns(null==n?void 0:n.applicationsState),customLoginState:$s(null==n?void 0:n.customLoginState),forgotPasswordState:Bs(null==n?void 0:n.forgotPasswordState),groupsState:Ks(null==n?void 0:n.groupsState),groupsDialogsState:Qs(null==n?void 0:n.groupsDialogsState),impersonateState:ti(null==n?void 0:n.impersonateState),loginState:si(null==n?void 0:n.loginState),mfaState:ri(null==n?void 0:n.mfaState),allAccountsState:po(null==n?void 0:n.allAccountsState),allAccountsDialogsState:Ao(null==n?void 0:n.allAccountsDialogsState),passkeysState:Eo(null==n?void 0:n.passkeysState),profileState:Po(null==n?void 0:n.profileState),provisioningState:Lo(null==n?void 0:n.provisioningState),resetPhoneNumberState:Mo(null==n?void 0:n.resetPhoneNumberState),rolesState:Vo(null==n?void 0:n.rolesState),restrictionsState:Qo(null==n?void 0:n.restrictionsState),securityCenterState:sr(null==n?void 0:n.securityCenterState),securityPolicyState:lr(null==n?void 0:n.securityPolicyState),sessionsPolicyState:hr(null==n?void 0:n.sessionsPolicyState),sessionsState:fr(null==n?void 0:n.sessionsState),signUpState:Ar(null==n?void 0:n.signUpState),smsState:Ir(null==n?void 0:n.smsState),socialLoginState:Dr(null==n?void 0:n.socialLoginState),ssoState:xr(null==n?void 0:n.ssoState),stepUpState:zr(null==n?void 0:n.stepUpState),teamState:Jr(null==n?void 0:n.teamState),tenantsState:dl(null==n?void 0:n.tenantsState)}))},Sl=(t,e,a,n)=>{const s=e=>{Object.keys(e).forEach((a=>{const n=a;Ya(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))},i={acceptInvitationActions:Fn(t,e),accountSettingsActions:jn(t,e,a),activateAccountActions:Ps(t,e,a),unlockAccountActions:Us(t,e),apiTokensActions:Ds(t,e),applicationsActions:Fs(t,e,a),customLoginActions:js(t,e,a),entitlementsActions:gl(t,e),forgotPasswordActions:Hs(t,e),groupsActions:Js(t,e),groupsDialogsActions:Xs(t),impersonateActions:ai(t,e,a),loginActions:to(t,e,a),mfaActions:co(t,e,a),allAccountsActions:mo(t,e,a),allAccountsDialogActions:wo(t),passkeysActions:Io(t,e,a),profileActions:_o(t,e,a),provisioningActions:Co(t,e),resetPhoneNumberActions:Go(t,e,a),rolesActions:Jo(t,e),restrictionsActions:ar(t,e,a),securityCenterActions:or(t,e,a),securityPolicyActions:pr(t,e,a),sessionsPolicyActions:Sr(t,e,a),sessionsActions:mr(t,e),signUpActions:Tr(t,e,a),smsActions:Lr(t,e),socialLoginActions:Mr(t,e,a),ssoActions:Wr(t,e,a),stepUpActions:Kr(t,e,a),teamActions:cl(t,e,a),tenantsActions:pl(t,e,a)};return[v({setAuthState:s,setState:s,resetAuthState:()=>{s(n)},setUser:t=>{s({user:t})}},Object.values(i).reduce(((t,e)=>v({},t,e)),{})),i]},vl={isLoading:!1,isSaving:!1,list:[],processIds:[],slackChannels:{isLoading:!1}},fl=t=>Rn(vl,t),ml=["email","slack","sms","webhook"],bl={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"}},Al=["id"],wl=["id","enabled"],Tl=(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=v({},n,e)},l=()=>{t.connectivity=za(vl)},c=async(t,e)=>{try{return await n[t](e)}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:ml;o({isLoading:!0});try{const t=await Promise.all([...e.map((t=>c(t))),c("categories"),(async()=>(await Promise.all(e.map((t=>c("channelMap",t))))).reduce(((t,a,n)=>v({},t,{[`${e[n]}`]:a})),{}))()]),a=await c("webhook"),n=t.reduce(((a,n,i)=>e[i]?t[t.length-1][e[i]].length?v({},a,{[`${e[i]}`]:n,list:[...a.list,{id:i,key:e[i],events:bl[e[i]].events(n),active:bl[e[i]].isActive(n),platform:bl[e[i]].title,image:bl[e[i]].image}]}):a:v({},a,{[`${s[i-e.length]}`]:n})),{list:[],webhook:a});o(v({},n,{error:void 0,isSaving:!1,isLoading:!1}))}catch(t){o({isLoading:!1,error:Mn(t)})}},p=async(e,a)=>{const{list:n}=t.connectivity,s=n.find((({key:t})=>t===e));if(!s)return;const i=bl[e].isActive(a);i!==s.active&&o({list:n.map((t=>t.key===e?v({},t,{active:i}):t))})},g=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,Al);return a===e.id&&JSON.stringify(v({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,wl);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,v({},l,{enabled:r})):e.connectivity.putSMSSubscriptions(o,s,v({},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 p(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 p(n,t),null==r||r(!0)}}catch(t){o({error:Mn(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:v({},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}})}},S=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,Mn(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:Mn(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:v({},r,{isLoading:!0})});const t=await e.connectivity.getWebhookLog(n,i,s);o({error:void 0,webhookLogs:v({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:g,postChannelData:g,postCodeAction:h,postSlackCode:h,loadScope:y,loadSlackPermissions:y,deleteWebhookConfigAction:S,deleteWebhookConfig:S,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 El;!function(t){t.UNKNWON="unknown",t.CARD="card"}(El||(El={}));const Il={loading:!1,error:null,fetching:!0,config:null},Ol=t=>Rn(Il,t);let Pl,kl,_l;!function(t){t.STRIPE="Stripe"}(Pl||(Pl={})),function(t){t.ACTIVE="ACTIVE",t.CANCELED="CANCELED",t.INCOMPLETE="INCOMPLETE",t.EXPIRED="EXPIRED",t.TRIALING="TRIALING"}(kl||(kl={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}(_l||(_l={}));const Ul=(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:()=>{t.subscriptions.config=za(Il)},loadPaymentConfiguration:async()=>{n({loading:!0});try{var t;(null!=(t=await e.subscriptions.getPaymentProviders())?t:[]).find((t=>"1"===t.status&&t.providerType===G.Stripe))?await(async()=>{n({loading:!0});try{const t=await e.subscriptions.getStripePaymentProviderConfiguration(),a={paymentProvider:Pl.STRIPE,apiKey:t.publishableKey};n({config:a}),n({loading:!1,fetching:!1})}catch(t){s(Mn(t))}})():s(Mn("Payment provider not configured"))}catch(t){s(Mn(t))}}}},Ll={loading:!1,error:null,fetching:!0},Rl=t=>Rn(Ll,t);function Dl({policy:t}){return{policy:_l.AT_PERIOD_END}}function Cl(t){switch(t){case F.ACTIVE:return kl.ACTIVE;case F.INCOMPLETE:return kl.INCOMPLETE;case F.CANCELED:return kl.CANCELED;case F.EXPIRED:return kl.EXPIRED;case F.TRIALING:return kl.TRIALING;default:return kl.EXPIRED}}const Nl=(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,p=null;u?d=await e.subscriptions.getSubscriptionPlan(c):([,d]=await Promise.all([n.loadSubscription(),e.subscriptions.getSubscriptionPlan(c)]),p=t.subscriptions.billing.subscription.subscription||null),s(v({loading:!1,fetching:!1,summary:i},p?{subscription:{id:p.id,externalId:p.externalId,startDate:p.startDate,currentPeriodStart:p.currentPeriodStart,currentPeriodEnd:p.currentPeriodEnd,status:o?kl.ACTIVE:Cl(p.status),cancellation:p.cancellation&&Dl(p.cancellation),trialEnd:p.trialEnd?p.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(Mn(t))}};return{setBillingInformationState:s,resetBillingInformationState:()=>{t.subscriptions.billing.information=za(Ll)},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(s?"Not authorized":"Internal feature failure")}}},Ml={loading:!1,error:null,fetching:!0,invoices:[],invoiceDownload:{loading:!1,error:null}},Fl=t=>Rn(Ml,t),xl=(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=Mn(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:Mn(t,null)})}};return{setBillingInvoiceState:n,resetBillingInvoiceState:()=>{t.subscriptions.billing.invoices=za(Ml)},loadInvoices:i,loadBillingInvoices:i,downloadInvoice:o,downloadBillingInvoice:o}},$l={loading:!1,error:null,fetching:!0},Gl=t=>Rn($l,t),jl=(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(Mn(t))}};return{setBillingPaymentMethodState:n,resetBillingPaymentMethodState:()=>{t.subscriptions.billing.paymentMethod=za($l)},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,v({email:n},r)),await o(),null==l||l(!0)}catch(t){i(Mn(t)),null==l||l(!1,t)}finally{s(!1)}}}},Vl={loading:!1,error:null,fetching:!0,cancellation:{loading:!1,error:null},renewal:{loading:!1,error:null}},Bl=t=>Rn(Vl,t),Wl=(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(Mn(t))}};return{setBillingSubscriptionState:s,resetBillingSubscriptionState:()=>{t.subscriptions.billing.subscription=za(Vl)},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("TenantId is not defined")},cancelSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void r("Subscription not found.");if(null!=a&&a.externallyManaged)return void r("Billing is externally managed.");const{id:n,cancellation:s,status:i}=a||{};if(!s&&i===F.ACTIVE)try{o(!0),await e.subscriptions.cancelManagedSubscription(n),await u(),o(!1)}catch(t){r(Mn(t))}},renewSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void c("Subscription not found.");if(null!=a&&a.externallyManaged)return void c("Billing is externally managed");const{id:n,cancellation:s}=a||{};if((null==s?void 0:s.policy)===$.AT_PERIOD_END)try{l(!0),await e.subscriptions.renewManagedSubscription(n),await u(),l(!1)}catch(t){c(Mn(t))}}}},Hl=t=>Rn({information:Rl(null==t?void 0:t.information),invoices:Fl(null==t?void 0:t.invoices),paymentMethod:Gl(null==t?void 0:t.paymentMethod),subscription:Bl(null==t?void 0:t.subscription)}),zl={loading:!1,error:null,fetching:!0,plans:[]},Kl=t=>Rn(zl,t),ql=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.plans,e)};return{setPlansState:n,resetPlansState:()=>{t.subscriptions.plans=za(zl)},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=Mn(e),n({loading:!1,fetching:!1,error:t})}var t}}},Jl={fetching:!0,loading:!1,error:null,confirmed:!1},Yl=t=>Rn(Jl,t),Ql=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.checkout,e)};return{setCheckoutState:s,resetCheckoutState:()=>{t.subscriptions.checkout=za(Jl)},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)===F.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:v({},r,{status:F.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:Mn(t)})}}else s({loading:!1,error:"Subscription not found"})},errorCheckout:t=>{s({loading:!1,error:t})}}},Xl={loading:!1,error:null,cardSetupIntentSecret:null},Zl=t=>Rn(Xl,t),tc=(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=Mn(e),Object.assign(t.subscriptions.stripe,{error:s,loading:!1,fetching:!1})}var s}}},ec={loading:!1,fetching:!0,vendorPublicConfig:null},ac=t=>Rn(ec,t),nc=(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:()=>{t.subscriptions.vendorPublicConfig=za(ec)},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(Mn(t))}}}},sc=t=>Rn({config:Ol(null==t?void 0:t.config),billing:Hl(null==t?void 0:t.billing),plans:Kl(null==t?void 0:t.plans),checkout:Yl(null==t?void 0:t.checkout),stripe:Zl(null==t?void 0:t.stripe),vendorPublicConfig:ac(null==t?void 0:t.vendorPublicConfig)}),ic=(t,e,a)=>{const n=Ul(t,e),[s,i]=((t,e,a)=>{const n=Nl(t,e,a),s=jl(t,e),i=xl(t,e),o=Wl(t,e,a);return[v({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=ql(t,e),r=Ql(t,e,a),l=tc(t,e),c=nc(t,e);return[v({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},oc={loading:!1},rc=t=>Rn(oc,t),lc=(t,e,a)=>{const n=e=>{Object.assign(t.vendor,e)},s=async()=>{n({loading:!0});try{var t;const a=await e.vendor.getVendorPublicInfo();a.whiteLabelMode=null!=(t=a.whiteLabelMode)&&t,n(v({},a,{loading:!1}))}catch(t){n({loading:!1}),console.error("failed to getVendorPublicInfo - ",t)}};return{setVendorState:n,resetVendorState:()=>{t.vendor=za(oc)},loadVendorPublicInfo:s,loadVendorPublicConfiguration:s}},cc={loading:!0,pageOffset:0,pageSize:20,logs:[],sort:[],filter:[],totalPages:0,isDownloadingCsv:!1},uc=t=>Rn(cc,t),dc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auditLogs.auditLogsState,e)};return{setAuditLogsState:s,resetAuditLogsState:()=>{t.auditLogs.auditLogsState=za(cc)},exportAuditsCsv:async()=>{const a=t.auditLogs.auditLogsState,{columns:n}=t.auditLogs.auditsMetadataState;try{const t=a.filter,i=a.sort.reduce(((t,e)=>v({},t,{sortBy:e.id,sortDirection:e.desc?"desc":"asc"})),{}),o=t.reduce(((t,e)=>v({},t,{[e.id]:e.value})),{});s({isDownloadingCsv:!0});const r="audits.csv";await e.audits.exportAudits(v({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,{columns:o}=t.auditLogs.auditsMetadataState;try{var r,l,c,u,d;const t=null!=(r=a.pageSize)?r:i.pageSize,p=null!=(l=a.pageOffset)?l:i.pageOffset,g=null!=(c=a.filter)?c:i.filter,h=null!=(u=a.sort)?u:i.sort;s({pageSize:t,pageOffset:p,filter:g,sort:h});const y=h.reduce(((t,e)=>v({},t,{sortBy:e.id,sortDirection:e.desc?"desc":"asc"})),{}),S=g.reduce(((t,e)=>v({},t,{[e.id]:e.value})),{});o||await n.loadAuditsMetadata();const{data:f,total:m}=await e.audits.getAudits(v({offset:p,count:t},y,S));s({loading:!1,logs:null!=f?f:[],totalPages:+Math.ceil(m/t)}),null==a||null==(d=a.callback)||d.call(a,!0)}catch(t){var p;s({loading:!1,error:Mn(t)}),null==a||null==(p=a.callback)||p.call(a,null,t)}}}},pc={loading:!0},gc=t=>Rn(pc,t),hc=(t,e,a)=>{const n=e=>{Object.assign(t.auditLogs.auditsMetadataState,e)};return{setAuditsMetadataState:n,resetAuditsMetadataState:()=>{t.auditLogs.auditsMetadataState=za(pc)},loadAuditsMetadata:async()=>{n({loading:!0,error:null});try{const{properties:t}=await e.metadata.getAuditsMetadata();n({columns:t,loading:!1})}catch(t){n({error:t,loading:!1})}}}},yc=t=>({auditLogsState:uc(null==t?void 0:t.auditLogsState),auditsMetadataState:gc(null==t?void 0:t.auditsMetadataState)}),Sc=(t,e,a)=>v({},dc(t,e,a),hc(t,e));var vc=a(1098),fc=a.n(vc);const mc={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},bc=(t,e)=>Object.keys(t).reduce(((a,n)=>{const s=n;return e.includes(n)?v({},a,{[n]:t[s]}):v({},a,{[n]:()=>{console.debug(`Action ${String(n)} was called`)}})}),{}),Ac={clientId:"CLIENT_ID_16806d3d-8fc3-4450-be97-abdaf66b723e",secret:"SECRET_16806d3d-8fc3-4450-be97-abdaf66b723e",createdAt:"createdAt",description:"Demo API Token (preview only)"},wc=v({},Ac,{roleIds:[],tenantId:"my-tenant-id",createdByUserId:"createdByUserId"}),Tc=[{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"}],Ec={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},Ic=v({},Ec,{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}),Oc={loading:!1,error:void 0,saving:!0,profile:Ec},Pc={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"},kc={allowSignups:!0,allowNotVerifiedUsersLogin:!1,apiTokensEnabled:!0,forcePermissions:!1,authStrategy:N.EmailAndPassword,machineToMachineAuthStrategy:M.ClientCredentials},_c={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date},Uc={id:"id",enabled:!0,maxAttempts:1,createdAt:new Date,updatedAt:new Date},Lc={id:"id",enabled:!0,historySize:1,createdAt:new Date,updatedAt:new Date},Rc={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},Dc={id:"id",createdAt:"createdAt",updatedAt:"updatedAt",properties:[],vendorId:"vendorId",entityName:"saml",isActive:!0,configuration:{acsUrl:"acsUrl",spEntityId:"spEntityId"}},Cc=[{id:"id",description:"description",key:"key",name:"name",permissions:[],permissionLevel:1}],Nc={firstLoad:!1,loading:!1,error:void 0,saving:!1,samlConfiguration:Rc,roles:Cc,authorizationRoles:[],errors:{},loaders:{},ssoConfigurations:[]},Mc=[{description:"string",fePermission:!0,id:"id",key:"key",name:"name",roleIds:[],createdAt:new Date,updatedAt:new Date,categoryId:"categoryId"}],Fc={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:[Tc[0]],groups:[{id:"id2",name:"Developers",color:"#03A9F4",roles:[Tc[0]],managedBy:Da.FRONTEGG}]},xc={id:Fc.id,email:Fc.email,name:Fc.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:[Tc[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},$c={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:[Tc[1]],groups:[{id:"id1",name:"Designers",color:"#E1F5E2",roles:[Tc[0]],managedBy:Da.FRONTEGG}]},Gc={id:$c.id,email:$c.email,name:$c.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:[Tc[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},jc={metadata:"",mfaEnrolled:!1,provider:"",sub:"",tenantIds:[],tenants:[],verified:!1,id:"id",email:"email",name:"name",tenantId:"tenantId",createdAt:new Date},Vc=[$c,Fc],Bc=[Gc,xc],Wc=[jc],Hc=[{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}],zc=[{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"}],Kc={isActive:!0,strategy:jt.ALLOW},qc=[{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"}],Jc=t=>{const e=[];return Array.from({length:t}).forEach(((t,a)=>{e.push(v({},$c,{name:"Demo User",id:`id${a}`,profilePictureUrl:null,createdAt:new Date}))})),e},Yc=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"}),Qc=[{id:"id1",name:"Designers",color:"#E1F5E2",description:"The whole design team",users:Jc(6),roles:[Yc("Editor")],metadata:'{"lastTermsCheck":"2022-08-16T10:31:11.270Z"}',managedBy:Da.FRONTEGG},{id:"id2",name:"Developers",color:"#03A9F4",description:"All frontend and backend developers",users:Jc(44),roles:[Yc("Editor")],managedBy:Da.FRONTEGG},{id:"id3",name:"Product",color:"#E1583E",description:"PMs and team leads",users:Jc(8),roles:[Yc("Viewer")],managedBy:Da.FRONTEGG},{id:"id4",name:"Management",color:"#9AE0FF",description:"Executives",users:Jc(5),roles:[Yc("Admin")],managedBy:Da.FRONTEGG},{id:"id5",name:"Sales",color:"#ED8E7C",users:Jc(21),description:"BDR, AE, and inside sales",roles:[Yc("Viewer")],managedBy:Da.FRONTEGG},{id:"id6",name:"Support",color:"#A79D7B",users:Jc(23),description:"Dev success and customer success",roles:[Yc("Admin")],managedBy:Da.FRONTEGG},{id:"id7",name:"Marketing",color:"#2CA744",users:Jc(10),description:"The marketing department",roles:[Yc("Viewer")],managedBy:Da.FRONTEGG},{id:"id8",name:"HR",color:"#EAE1C2",users:Jc(4),description:"Human resources",roles:[Yc("Viewer")],managedBy:Da.FRONTEGG},{id:"id9",name:"Finance",color:"#5587C0",users:Jc(3),roles:[Yc("Viewer")],managedBy:Da.FRONTEGG},{id:"id10",name:"Operations",color:"#B1CAE7",users:Jc(8),roles:[Yc("Editor")],managedBy:Da.FRONTEGG},{id:"id11",name:"Legal",color:"#2CA744",users:Jc(4),roles:[Yc("Viewer")],managedBy:Da.FRONTEGG}],Xc={scoring:{score:79},recommendations:{items:[{code:Fa.FORCE_MFA,severity:Ga.WARNING,category:ja.MFA},{code:Fa.ENABLE_FORCE_RELOGIN,severity:Ga.WARNING,category:ja.SESSIONS}]}},Zc={insights:{items:[{category:ja.MFA,code:xa.PARTIALLY_FORCED_MFA,metadata:{totalUsers:2,mfa:{enrolledUsersCount:1}}},{category:ja.SESSIONS,code:xa.PARTIAL_SESSION_SETTINGS,metadata:{totalUsers:2,sessions:{idleTimeoutRecommendation:1800}}},{category:ja.PASSWORD,code:xa.IMPROVE_PASSWORD_HISTORY_POLICY,metadata:{password:{userLockoutRecommendation:5,historyRecommendations:5}}},{category:ja.DOMAIN,code:xa.NO_IP_RESTRICTIONS,metadata:{restrictions:{ipsCount:1,domainsCount:1}}}]}},tu={users:Bc,totalUsersItems:2,totalUsersPages:1,usersPageOffset:0},eu={users:[Bc[0]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0,queryParams:{_maxInactiveSeconds:7776e3}},au={users:[Bc[1]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0};wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.ASSIGNABLE,new Date,new Date,wa.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 nu,su=new Uint8Array(16);function iu(){if(!nu&&!(nu="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 nu(su)}const ou=/^(?:[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 ru=[],lu=0;lu<256;++lu)ru.push((lu+256).toString(16).substr(1));const cu=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(ru[t[e+0]]+ru[t[e+1]]+ru[t[e+2]]+ru[t[e+3]]+"-"+ru[t[e+4]]+ru[t[e+5]]+"-"+ru[t[e+6]]+ru[t[e+7]]+"-"+ru[t[e+8]]+ru[t[e+9]]+"-"+ru[t[e+10]]+ru[t[e+11]]+ru[t[e+12]]+ru[t[e+13]]+ru[t[e+14]]+ru[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&ou.test(t)}(a))throw TypeError("Stringified UUID is invalid");return a},uu=function(t,e,a){var n=(t=t||{}).random||(t.rng||iu)();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 cu(n)},du=["callback"],pu=["callback"],gu=["callback","profilePictureUrl"],hu=["callback"],yu=["callback"],Su=["callback"],vu=["callback"],fu=["callback"],mu=["callback"],bu=["callback"],Au=["callback"],wu=["callback","samlVendor"],Tu=["callback"],Eu=["callback"],Iu=["callback","profileImage"],Ou=["callback"],Pu=["callback"],ku=["callback"],_u=["callback"],Uu=["callback"],Lu=["callback"],Ru=["callback"],Du=["callback"],Cu=t=>"createdAt"!==t.id,Nu={total:20,data:Array.from(Array(5).keys()).map((t=>v({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`})))},Mu={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}]},Fu=(t,e,a)=>{const n=((t,e,a)=>{const n=dc(t,e,a),s=bc(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,p=null!=(l=e.filter)?l:n.filter,g=null!=(c=e.sort)?c:n.sort;s.setAuditLogsState({pageSize:t,pageOffset:d,filter:p,sort:g}),i||await a.loadAuditsMetadata();const{data:h,total:y}=((t,e)=>{const{data:a}=Nu;let n=a.filter((t=>e=>t.filter(Cu).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}})(p,g);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:Mn(t)}),null==e||null==(d=e.callback)||d.call(e,null,t)}},s})(t,e,a),s=((t,e)=>{const a=hc(t,e),n=bc(a,["setAuditsMetadataState","resetAuditsMetadataState"]);return n.loadAuditsMetadata=async()=>{n.setAuditsMetadataState({loading:!0,error:null});try{const{properties:t}=Mu;n.setAuditsMetadataState({columns:t,loading:!1})}catch(t){n.setAuditsMetadataState({error:t,loading:!1})}},n})(t,e);return v({},n,s)},xu={id:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",externalId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",startDate:"2021-09-20T08:08:51.000Z",status:F.ACTIVE,externallyManaged:!1,cancellation:null,currentPeriodStart:"2021-09-20T08:08:51.000Z",currentPeriodEnd:"2021-10-20T08:08:51.000Z",plan:{slug:"test"}},$u=[{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"}],Gu=[{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:""}],ju=[{id:"id",externalId:"externalId",type:x.CARD,isDefault:!0,last4:"4242",expMonth:11,expYear:25,brand:"visa",billingDetails:{name:"Dummy",email:"dummy@email.com"}}],Vu={allowPlanDowngrade:!0,allowPlanCancellation:!0},Bu=(t,e,a)=>{const n=((t,e)=>{const a=Ul(t,e),n=bc(a,["setPaymentConfigState","resetPaymentConfigState"]);return n.loadPaymentConfiguration=async()=>{n.setPaymentConfigState({loading:!0}),await Ka(500),n.setPaymentConfigState({loading:!1,fetching:!1,config:{paymentProvider:Pl.STRIPE,apiKey:""}})},n})(t,e),[s,i]=((t,e,a)=>{const n=((t,e,a)=>{const n=Nl(t,e,a),s=bc(n,["setBillingInformationState","resetBillingInformationState"]);return s.loadBillingInformation=async()=>{var t,e;s.setBillingInformationState({loading:!0}),await Ka(500),s.setBillingInformationState({loading:!1,fetching:!1,summary:{subscriptionId:xu.id,paymentMethodId:"mockPaymentMethodId",tenantConfigurationId:"mockTenantConfigurationId",providerType:G.Stripe,externallyManaged:!1,currentPlanId:$u[0].id,defaultPlanId:$u[0].id},plan:v({},$u[0],{price:null==(t=$u[0].price)?void 0:t.amount,currency:null==(e=$u[0].price)?void 0:e.currency,recurringInterval:"month"})})},s})(t,e,a),s=((t,e)=>{const a=jl(t,e),n=bc(a,["setBillingPaymentMethodState","resetBillingPaymentMethodState"]);return n.loadPaymentMethod=async()=>{n.setBillingPaymentMethodState({loading:!0}),await Ka(500),n.setBillingPaymentMethodState({paymentMethod:ju[0],loading:!1,fetching:!1})},n})(t,e),i=((t,e)=>{const a=xl(t,e),n=bc(a,["setBillingInvoiceState","resetBillingInvoiceState"]);return n.loadBillingInvoices=async()=>{n.setBillingInvoiceState({loading:!0}),await Ka(500),n.setBillingInvoiceState({loading:!1,fetching:!1,invoices:Gu.map((t=>v({},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=Wl(t,e,a),s=bc(n,["setBillingSubscriptionState","resetBillingSubscriptionState","setCancellationLoading","setCancellationError","setRenewalLoading","setRenewalError"]);return s.loadSubscription=async()=>{s.setBillingSubscriptionState({loading:!0}),await Ka(500),s.setBillingSubscriptionState({subscription:xu,fetching:!1,loading:!1,error:null})},s})(t,e,a);return[v({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=((t,e)=>{const a=ql(t,e),n=bc(a,["setPlansState","resetPlansState"]);return n.loadPlans=async()=>{n.setPlansState({loading:!0}),await Ka(500),n.setPlansState({fetching:!1,loading:!1,plans:$u.map((t=>{var e,a;return v({},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=Ql(t,e,a);return bc(n,["setCheckoutState","resetCheckoutState","errorCheckout","resetCheckout"])})(t,e,a),l=((t,e)=>{const a=tc(t,e);return bc(a,[])})(t,e),c=((t,e)=>{const a=nc(t,e),n=bc(a,["setVendorPublicConfigState","resetVendorPublicConfigState","setVendorPublicConfigError","setVendorPublicConfigLoading"]);return n.loadVendorPublicConfiguration=async()=>{n.setVendorPublicConfigLoading(!0),await Ka(),n.setVendorPublicConfigState({fetching:!1,loading:!1,vendorPublicConfig:Vu})},n})(t,e);return[v({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},Wu=(t,e,a)=>{const{authActions:n,authStateActions:s}=((t,e,a)=>{const n=((t,e)=>{const a=Fn(t,e);return bc(a,["setAcceptInvitationState","resetAcceptInvitationState"])})(t,e),s=((t,e,a)=>{const n=jn(t,e,a),s=bc(n,["setAccountSettingsState","resetAccountSettingsState"]);return s.saveAccountSettings=async e=>{var a;s.setAccountSettingsState({loading:!0}),await Ka();const n=t.auth.accountSettingsState,{address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u}=n,d=v({address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u},e);s.setAccountSettingsState(v({},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 Ka(),s.setAccountSettingsState(v({address:"Tel-aviv",timezone:"Asia/Jerusalem",dateFormat:"DD/MM/YYYY",timeFormat:"HH:mm",currency:"USD",loading:!1},t))},s})(t,e,a),i=((t,e)=>{const a=Us(t,e);return bc(a,["setUnlockAccountState","resetUnlockAccountState"])})(t,e),o=((t,e,a)=>{const n=Ps(t,e,a);return bc(n,["setActivateState","resetActivateState","setActivateStrategyState"])})(t,e,a),r=((t,e,a)=>{const n=mo(t,e,a);return bc(n,["setAllAccountsLoader","setAllAccountsError","setAllAccountsState","setSelectedAccountState","resetAllAccountsState","clearSelectedAccount"])})(t,e,a),l=wo(t),c=((t,e)=>{const a=Ds(t,e),n=bc(a,["setApiTokensState","resetApiTokensState","setApiTokensLoader","setApiTokensError"]);return n.addTenantApiToken=async e=>{const{description:a,roleIds:s,callback:i}=e;n.setApiTokensLoader({key:Za.ADD_API_TOKEN,value:!0});const{apiTokensDataTenant:o}=t.auth.apiTokensState,r=v({},wc,{description:a,roleIds:s,clientId:`CLIENT_ID_${uu()}`});n.setApiTokensState({showAddTokenDialog:!1}),await Ka(200),n.setApiTokensState({apiTokensDataTenant:[...o,r],successDialog:{open:!0,secret:r.secret,clientId:r.clientId}}),await Ka(200),n.setApiTokensLoader({key:Za.ADD_API_TOKEN,value:!1}),null==i||i(null)},n.deleteTenantApiToken=async t=>{n.setApiTokensLoader({key:Za.DELETE_API_TOKEN,value:!0}),await Ka(200);const e=[wc];n.setApiTokensState({apiTokensDataTenant:e.filter((e=>e.clientId!==t)),deleteTokenDialog:{open:!1,clientId:t}}),n.setApiTokensLoader({key:Za.DELETE_API_TOKEN,value:!1})},n.loadApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Za.LOAD_API_TOKENS,value:!0});const a=[Ac],s=[wc];n.setApiTokensState({apiTokensDataUser:a,apiTokensDataTenant:s}),await Ka(200),n.setApiTokensLoader({key:Za.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:Za.LOAD_API_TOKENS,value:!0});const a=[Ac];n.setApiTokensState({apiTokensDataUser:a}),await Ka(200),n.setApiTokensLoader({key:Za.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:Za.LOAD_API_TOKENS,value:!0});const a=[wc];n.setApiTokensState({apiTokensDataTenant:a}),await Ka(200),n.setApiTokensLoader({key:Za.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n})(t,e),u=((t,e,a)=>{const n=Fs(t,e,a);return bc(n,["setApplicationsState","resetApplicationsState"])})(t,e,a),d=((t,e,a)=>{const n=js(t,e,a),s=bc(n,["setCustomLoginState","resetCustomLoginState"]);return s.loadTenantMetadata=async()=>{s.setCustomLoginState({loading:!0}),await Ka(),s.setCustomLoginState({loading:!1})},s.updateTenantMetadata=async t=>{const{callback:e}=t;s.setCustomLoginState({loading:!0,error:null}),await Ka(),s.setCustomLoginState({loading:!1,error:null}),null==e||e(!0)},s})(t,e,a),p=((t,e)=>{const a=gl(t,e);return bc(a,["setEntitlements","handleFetchedEntitlements"])})(t,e),g=((t,e)=>{const a=Hs(t,e),n=bc(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:Mn(t)})}},n})(t,e),h=((t,e)=>{const a=Js(t,e),n=bc(a,["setGroupsState","resetUsersGroupsState","setUsersGroupsLoader","setUsersGroupsError"]);return n.loadGroups=async()=>{const t=un.GET_GROUPS;n.setUsersGroupsLoader({key:t,value:!0});const e=Qc;n.setGroupsState({groups:e}),n.setUsersGroupsLoader({key:t,value:!1})},n.createGroup=async e=>{var a;const s=un.CREATE_GROUP,{groups:i}=t.auth.groupsState;n.setUsersGroupsLoader({key:s,value:!0}),await Ka(500),n.setGroupsState({groups:[v({},e,{id:`${e.name}ID`,managedBy:Da.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=un.UPDATE_GROUP,c=t.auth.groupsState;n.setUsersGroupsLoader({key:l,value:!0}),await Ka(500),n.setGroupsState({groups:null==c||null==(a=c.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},e,{id:e.groupId,name:null!=(a=null==e?void 0:e.name)?a:"",managedBy:Da.FRONTEGG}):t})),selectedGroup:v({},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=un.DELETE_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Ka(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=un.ADD_ROLES_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Ka(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},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=un.DELETE_ROLES_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Ka(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},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=un.ADD_USERS_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Ka(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},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=un.DELETE_USERS_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await Ka(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},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=un.GET_GROUP_CONFIGURATION,{groupsConfiguration:a}=t.auth.groupsState;n.setUsersGroupsLoader({key:e,value:!0}),a&&n.setGroupsState({groupsConfiguration:v({},a)}),n.setUsersGroupsLoader({key:e,value:!1})},n.updateGroupConfiguration=async e=>{const a=un.UPDATE_GROUP_CONFIGURATION,{groupsConfiguration:s}=t.auth.groupsState;n.setUsersGroupsLoader({key:a,value:!0}),s&&n.setGroupsState({groupsConfiguration:v({},s,e)}),n.setUsersGroupsLoader({key:a,value:!1})},n})(t,e),y=Xs(t),S=((t,e,a)=>{const n=ai(t,e,a);return bc(n,["setImpersonateState","resetImpersonateState"])})(t,e,a),m=((t,e,a)=>{const n=a,s=to(t,e,n),i=bc(s,["setLoginState","resetLoginState","afterAuthNavigation"]);return i.requestAuthorize=async t=>{t&&n.setAuthState({isLoading:!0});const e=Ic;await n.loadTenants(),n.setAuthState({user:e,isAuthenticated:!0,isLoading:!1})},i.getUserIP=async t=>{const{callback:e}=t;try{const{ip:t}=qc[0];await n.setAuthState({userIp:t}),null==e||e(!0,t)}catch(t){null==e||e(!1,t)}},i})(t,e,a),b=((t,e,a)=>{const n=a,s=co(t,e,n),i=bc(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,du),t.auth.mfaState);i.setMfaState({saving:!0}),await Ka();const o={token:"token",recoveryCode:"recoveryCode"},r={step:vn.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:v({},s,{authenticators:[{id:"authenticator-id"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(v({},Ic,{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 Ka(),i.setMfaState({saving:!1,error:void 0,mfaDevices:v({},s,{authenticators:[]})}),n.setUser(v({},Ic)),null==(a=e.callback)||a.call(e,!0)},i.verifyMfaAfterForce=async t=>{const{callback:e}=t,a=f(t,pu);i.setMfaState({loading:!0}),await Ka();const s=v({},a,{recoveryCode:"recoveryCode"}),o={step:vn.recoveryCode,loading:!1,error:void 0,saving:!1};null!=s&&s.recoveryCode&&(o.recoveryCode=s.recoveryCode),i.setMfaState(o),await Ka(),n.setUser(v({},Ic,{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:Mn(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 Ka(),i.setMfaState({loading:!1,error:void 0,mfaDevices:v({},s,{phones:[]})}),n.setUser(v({},Ic)),null==(a=e.callback)||a.call(e,!0)},i.preEnrollMfaSms=async t=>{var e;i.setMfaState({saving:!0}),await Ka(),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 Ka();const o={token:"token",recoveryCode:"recoveryCode"},r={step:vn.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:v({},s,{phones:[{id:"phone-id",phoneNumber:"+972504589346"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(v({},Ic,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i})(t,e,a),A=((t,e,a)=>{const n=Io(t,e,a);return bc(n,["setPasskeysState","resetPasskeysState"])})(t,e,a),w=((t,e,a)=>{const n=_o(t,e,a),s=bc(n,["setProfileState","resetProfileState"]);return s.loadProfile=async()=>{s.setProfileState({loading:!0}),await Ka(),a.setUser(v({},Ic,Ec)),s.setProfileState({loading:!1,profile:Ec})},s.saveProfile=async t=>{const{callback:e,profilePictureUrl:n}=t,i=f(t,gu);s.setProfileState({saving:!0,error:null});const o=Oc;let r=o.profile.profilePictureUrl;n!==o.profile.profilePictureUrl&&n&&(n||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)&&(r=n);const l=v({},o.profile,i,{profilePictureUrl:r}),c=Ic;await Ka(),a.setUser(v({},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 Ka(),s.setProfileState({loading:!1,error:void 0}),null==(e=t.callback)||e.call(t,!0)},s})(t,e,a),T=((t,e)=>{const a=Co(t,e);return bc(a,["setProvisioningState","resetProvisioningState"])})(t,e),E=((t,e,a)=>{const n=Go(t,e,a);return bc(n,["setResetPhoneNumberState","resetResetPhoneNumberState"])})(t,e,a),I=((t,e,a)=>{const n=ar(t,e,a),s=bc(n,["setRestrictionsState","setIpRestrictionsState","setEmailDomainRestrictionsState"]);return s.loadIpRestrictions=async()=>{s.setIpRestrictionsState({loading:!0,error:null}),s.setIpRestrictionsState({data:{restrictions:qc.filter((t=>t.strategy===Kc.strategy)),config:Kc},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,hu);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,v({},r,{createdAt:new Date,updatedAt:new Date,id:uu(),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,yu),l=t.auth.restrictionsState.ipRestrictions;s.setIpRestrictionsState({saving:!0,error:null}),s.setIpRestrictionsState({data:{config:v({},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=qc[0].ip,n=!!e.data.restrictions.find((t=>t.isActive&&t.ip===a));s.setIpRestrictionsState({userIpValid:n,loading:!1})}catch(t){s.setIpRestrictionsState({error:Mn(t),loading:!1})}},s.saveEmailDomainRestriction=async e=>{var a,n;const{callback:i}=e,o=f(e,Su),r=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await Ka(),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)||[],v({},o,{id:Date.now().toString()})]},saving:!1})},s.saveEmailDomainRestrictionsConfig=async e=>{var a;const{callback:n}=e,i=f(e,vu),o=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await Ka(),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 Ka(),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),O=((t,e)=>{const a=Jo(t,e),n=bc(a,["setRolesState","setRolesStateError","setRolesStateLoader","resetRolesState"]);return n.loadRolesAndPermissions=async t=>{var e;const a=bn.LOAD_ROLES;n.setRolesStateLoader({key:a,value:!(null!=(e=null==t?void 0:t.silentLoading)&&e)});try{n.setRolesState({roles:Tc})}catch(t){n.setRolesStateError({key:a,value:Mn(t)})}finally{n.setRolesStateLoader({key:a,value:!1})}},n})(t,e),P=((t,e,a)=>{const n=or(t,e,a),s=bc(n,["setSecurityCenterState","setSecurityCenterStateError","setSecurityCenterStateLoader","resetSecurityCenterState"]);return s.loadRecommendations=async()=>{const t=An.RECOMMENDATIONS;s.setSecurityCenterStateLoader({key:t,value:!0}),await Ka(),s.setSecurityCenterState({recommendations:Xc.recommendations.items,score:Xc.scoring.score}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInsights=async()=>{const t=An.INSIGHTS;s.setSecurityCenterStateLoader({key:t,value:!0}),await Ka(),s.setSecurityCenterState({insights:Zc.insights.items}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadBreachedPasswordUsers=async()=>{const t=An.BREACHED_PASSWORD_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await Ka(),s.setSecurityCenterState({breachedPasswordUsersTable:tu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadUnenrolledMfaUsers=async()=>{const t=An.UNENROLLED_MFA_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await Ka(),s.setSecurityCenterState({unenrolledMfaUsersTable:au}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInactiveUsers=async()=>{const t=An.INACTIVE_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await Ka(),s.setSecurityCenterState({inactiveUsersTable:eu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.sendResetBreachedPasswordEmail=async t=>{const{callback:e}=t,a=An.SEND_BREACHED_PASSWORD_EMAIL;s.setSecurityCenterStateLoader({key:a,value:!0}),await Ka(),null==e||e(!0),s.setSecurityCenterStateLoader({key:a,value:!1})},s})(t,e,a),k=((t,e,a)=>{const n=pr(t,e,a),s=bc(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 Ka(),s.setSecurityPolicyGlobalState({policy:Pc,loading:!1})},s.loadPublicSecurityPolicy=async()=>{s.setSecurityPolicyPublicState({loading:!0,error:null});try{s.setSecurityPolicyPublicState({policy:kc,loading:!1})}catch(t){s.setSecurityPolicyPublicState({error:Mn(t),loading:!1})}},s.saveSecurityPolicyMfa=async t=>{var e;const{callback:a}=t,n=f(t,fu);s.setSecurityPolicyMfaState({saving:!0,error:null});const i=v({},Uc,{id:null!=(e=n.id)?e:Uc.id,enforceMFAType:n.enforceMFAType});await Ka(),s.setSecurityPolicyMfaState({policy:i,saving:!1}),null==a||a(i)},s.loadSecurityPolicyMfa=async()=>{s.setSecurityPolicyMfaState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyMfaState({policy:_c,loading:!1})},s.loadSecurityPolicyVendorMfa=async()=>{s.setSecurityPolicyVendorMfaState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyVendorMfaState({policy:_c,loading:!1})},s.saveSecurityPolicyLockout=async t=>{const{callback:e}=t,a=f(t,mu);s.setSecurityPolicyLockoutState({saving:!0,error:null}),await Ka();const n=v({},Uc,a,{id:a.id?a.id:Uc.id});null==e||e(n),s.setSecurityPolicyLockoutState({policy:n,saving:!1})},s.loadSecurityPolicyLockout=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyLockoutState({policy:Uc,loading:!1})},s.loadSecurityPolicyVendorLockout=async()=>{s.setSecurityPolicyVendorLockoutState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyVendorLockoutState({policy:Uc,loading:!1})},s.loadSecurityPolicyCaptcha=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyLockoutState({policy:Uc,loading:!1})},s.saveSecurityPolicyPasswordHistory=async t=>{const{callback:e}=t,a=f(t,bu);s.setSecurityPolicyPasswordHistoryState({saving:!0,error:null}),await Ka();const n=v({},Lc,a,{id:a.id?a.id:Lc.id});null==e||e(n),s.setSecurityPolicyPasswordHistoryState({policy:n,saving:!1})},s.loadSecurityPolicyPasswordHistory=async()=>{s.setSecurityPolicyPasswordHistoryState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyPasswordHistoryState({policy:Lc,loading:!1})},s.loadSecurityPolicyVendorPasswordHistory=async()=>{s.setSecurityPolicyVendorPasswordHistoryState({loading:!0,error:null}),await Ka(),s.setSecurityPolicyVendorPasswordHistoryState({policy:Lc,loading:!1})},s})(t,e,a),_=((t,e)=>{const a=mr(t,e),n=bc(a,["setSessionsState","resetSessionsState"]);return n.loadUserSessions=async()=>{n.setSessionsState({loading:!0,error:null}),n.setSessionsState({sessions:zc,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=zc.filter((t=>t.current));n.setSessionsState({sessions:t,loading:!1})},n})(t,e),U=((t,e,a)=>{const n=Sr(t,e,a),s=bc(n,["setSessionsPolicyState","resetSessionsPolicyState"]);return s.loadSessionsPolicy=async()=>{s.setSessionsPolicyState({loading:!0,error:null});const e=t.auth.sessionsPolicyState;s.setSessionsPolicyState(v({},e,{loading:!1}))},s.createOrUpdateSessionsPolicy=async t=>{const{callback:e}=t,a=f(t,Au);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=Tr(t,e,a);return bc(n,["setSignUpState","resetSignUpState","resetSignUpStateSoft"])})(t,e,a),R=((t,e)=>{const a=Lr(t,e);return bc(a,["setSmsState","resetSmsState"])})(t,e),D=((t,e,a)=>{const n=Mr(t,e,a);return bc(n,["setSocialLoginsState","resetSocialLoginsState","setSocialLoginError"])})(t,e,a),C=((t,e,a)=>{const n=Wr(t,e,a),s=bc(n,["setSSOState","resetSSOState"]);return s.loadSSOConfigurations=async()=>{s.setSSOState({loading:!0}),await Ka(),s.setSSOState({samlConfiguration:Rc,loading:!1,firstLoad:!1})},s.saveSSOConfigurations=async t=>{var e,a;const{callback:n,samlVendor:i}=t,o=f(t,wu),r=Nc.samlConfiguration,l=v({},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:v({},r,l)});s.setSSOState({error:void 0,[c]:!0}),await Ka(),l.acsUrl=null==Dc||null==(e=Dc.configuration)?void 0:e.acsUrl,l.spEntityId=null==Dc||null==(a=Dc.configuration)?void 0:a.spEntityId;const u=Ja(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 Ka(),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=v({},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=Nc.samlConfiguration;s.setSSOState({error:void 0,saving:!0}),await Ka(),s.setSSOState({samlConfiguration:v({},a,{validated:!0}),error:void 0,saving:!1}),null==e||e(!0)},s.loadSSOAuthorizationRoles=async()=>{await Ka(),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 Ka(),s.setSSOState({authorizationRoles:a,error:void 0,saving:!1}),null==e||e(!0)},s})(t,e,a),N=((t,e,a)=>{const n=Kr(t,e,a);return bc(n,["setStepUpState","resetStepUpState"])})(t,e,a),M=((t,e,a)=>{const n=cl(t,e,a),s=bc(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,p=null!=(i=e.filter)?i:c.filterV2,g=null!=(o=e.sort)?o:c.sortV2;s.setTeamLoader({key:In.USERS,value:!r}),s.setTeamState({pageSize:u,pageOffset:d,filterV2:p,sortV2:g}),await Ka(),s.setTeamState({users:Vc,totalPages:2,totalItems:10,roles:Cc,permissions:Mc}),s.setTeamLoader({key:In.USERS,value:!1}),null==l||l(Vc)},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,p=null!=(n=e._offset)?n:u.allUsersQueryParams._offset,g=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:In.USERS,value:!l}),s.setTeamState({allUsersQueryParams:{_limit:d,_offset:p,_filter:g,_sortBy:h,_order:y}}),await Ka(),s.setTeamState({allUsers:Wc,totalPages:2,totalItems:10,roles:Cc,permissions:Mc}),s.setTeamLoader({key:In.USERS,value:!1}),null==c||c(Wc)},s.loadRoles=async t=>{var e;s.setTeamLoader({key:In.ROLES_AND_PERMISSIONS,value:!0}),await Ka(),s.setTeamState({roles:Cc,permissions:Mc}),s.setTeamLoader({key:In.ROLES_AND_PERMISSIONS,value:!0}),null==t||null==(e=t.callback)||e.call(t,{roles:Cc,permissions:Mc})},s.addUser=async e=>{const{callback:a}=e,n=f(e,Tu),i=t.auth.teamState;s.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})}),await Ka();const o=new Date,r=v({},$c,{groups:[]},n,{id:`${uu()}`,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,Eu),i=t.auth.teamState;s.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})}),await Ka();const o=v({},$c,n,{id:`${uu()}`});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,Iu),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));s.setTeamLoader({key:In.UPDATE_USER,value:o||""}),s.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0})}),s.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0}),users:r.users.map((t=>t.id===i.id?v({},t,i):t))}),l.roleIds.length>0&&0===(null==(a=i.roleIds)?void 0:a.length)&&(i.roleIds=[""]),await Ka();const c=v({},l,i);null==n||n(c),s.setTeamState({users:r.users.map((t=>t.id===c.id?v({},t,c,{createdAt:t.createdAt,customData:t.customData,lastLogin:t.lastLogin}):t))}),s.setTeamLoader({key:In.UPDATE_USER,value:!1})},s.deleteUser=async e=>{const{callback:a}=e,n=f(e,Ou),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:v({},i.deleteUserDialogState,{loading:!0})}),await Ka(),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,Pu),i=t.auth.teamState;s.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!0});const o=new Date;s.setTeamState({users:i.users.map((t=>t.id===n.userId?v({},t,{temporaryExpirationDate:n.expirationInSeconds?new Date(o.setSeconds(o.getSeconds()+n.expirationInSeconds)):void 0}):t))}),await Ka(),null==a||a(!0),s.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.setUserAsPermanent=async e=>{const{callback:a}=e,n=f(e,ku),i=t.auth.teamState;s.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!0}),s.setTeamState({users:i.users.map((t=>t.id===n.userId?v({},t,{temporaryExpirationDate:void 0}):t))}),await Ka(),null==a||a(!0),s.setTeamLoader({key:In.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.deleteUserFromSubTenants=async e=>{const{callback:a}=e,n=f(e,_u),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:v({},i.deleteUserDialogState,{loading:!0})}),await Ka(),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,Uu);s.setTeamLoader({key:In.RESEND_ACTIVATE_LINK,value:a.userId}),await Ka(),null==e||e(!0),s.setTeamLoader({key:In.RESEND_ACTIVATE_LINK,value:!1})},s.resendInvitationLink=async t=>{const{callback:e}=t,a=f(t,Lu);s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:a.email}),await Ka(),null==e||e(!0),s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationEmail=async t=>{const{callback:e}=t,a=f(t,Ru);s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:a.email}),await Ka(),null==e||e(!0),s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationLinkToAllSubTenants=async t=>{const{callback:e}=t,a=f(t,Du);s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:a.email}),await Ka(),null==e||e(!0),s.setTeamLoader({key:In.RESEND_INVITATION_LINK,value:!1})},s})(t,e,a),F=((t,e,a)=>{const n=pl(t,e,a),s=bc(n,["setTenantsState","resetTenantsState"]);return s.loadTenants=async()=>{s.setTenantsState({loading:!0}),s.setTenantsState({tenants:Hc,activeTenant:Hc[0],loading:!1})},s})(t,e,a),x={acceptInvitationActions:n,accountSettingsActions:s,unlockAccountActions:i,activateAccountActions:o,allAccountsActions:r,allAccountsDialogActions:l,apiTokensActions:c,applicationsActions:u,customLoginActions:d,entitlementsActions:p,forgotPasswordActions:g,groupsActions:h,groupsDialogsActions:y,impersonateActions:S,loginActions:m,mfaActions:b,passkeysActions:A,profileActions:w,provisioningActions:T,resetPhoneNumberActions:E,restrictionsActions:I,rolesActions:O,securityCenterActions:P,securityPolicyActions:k,sessionsActions:_,sessionsPolicyActions:U,signUpActions:L,smsActions:R,socialLoginActions:D,ssoActions:C,stepUpActions:N,teamActions:M,tenantsActions:F},$=e=>{Object.keys(e).forEach((a=>{const n=a;Ya(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))};return{authActions:v({setState:$,setAuthState:$,resetAuthState:()=>{},setUser:t=>{$({user:t})}},n,s,o,i,r,l,c,u,d,p,g,h,y,S,m,b,A,w,T,E,I,O,P,k,_,U,L,R,D,C,N,M,F),authStateActions:x}})(t,e,a),i=((t,e,a)=>{const n=Tl(t,e,a);return bc(n,["setConnectivityState","resetConnectivityState","initData","resetConnectivityState","cleanWebhookTestData","cleanWebhookLogsData","cleanWebhookTestMessage","cleanError","cleanSlackData"])})(t,e,a),[o,r]=Bu(t,e,a),l=((t,e,a)=>{const n=lc(t,e,a),s=bc(n,["setVendorState","resetVendorState"]);return s.loadVendorPublicInfo=async()=>{try{s.setVendorState({whiteLabelMode:!1}),await Ka()}catch(t){console.error("failed to getVendorPublicInfo - ",t)}},s.loadVendorPublicConfiguration=s.loadVendorPublicInfo,s})(t,e,a);return{authActions:n,authStateActions:s,connectivityActions:i,subscriptionsActions:o,subscriptionsStateActions:r,vendorActions:l,auditsActions:Fu(t,e,a)}},Hu=(t,e,a=!1,n,s,i=!1,o="path")=>zu({name:t.appName,context:t.context,storeHolder:e,previewMode:a,builderMode:i,urlStrategy:o,initialState:{root:v({},t),auth:v({},null==s?void 0:s.auth,n),connectivity:v({},null==s?void 0:s.connectivity),subscriptions:v({},null==s?void 0:s.subscriptions),vendor:v({},null==s?void 0:s.vendor),auditLogs:v({},null==s?void 0:s.auditLogs),audits:v({},null==s?void 0:s.audits)}}),zu=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:p=!1,builderMode:g=!1,urlStrategy:h="path"}=t,y=L.for(u);p||g||y.setContext(d),void 0===d.requestCredentials&&(d.requestCredentials="include");const S=yl(null==(e=t.initialState)?void 0:e.auth),m=fl(null==(a=t.initialState)?void 0:a.connectivity),b=sc(null==(n=t.initialState)?void 0:n.subscriptions),A=rc(null==(s=t.initialState)?void 0:s.vendor),w=yc(null==(i=t.initialState)?void 0:i.auditLogs),T=(E=null==(o=t.initialState)?void 0:o.audits,Rn(mc,E));var E;const I=null==(r=t.initialState)?void 0:r.auth;I&&Object.keys(I).forEach((t=>{fc()(S,t,I[t],{merge:!0})}));const O=za(S),R=Rn({root:{appName:u,context:d,urlStrategy:h,previewMode:p},auth:S,connectivity:m,subscriptions:b,vendor:A,auditLogs:w,audits:T});"undefined"!=typeof window&&"true"===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(v({name:s},i));P(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))}(R,{name:`${u} Store`,enabled:!0});const D={},C={};y.setContext(t.context),y.setAppName(u);const N=v({},Wa(u),{fetch:new Nt(u)});if(t.previewMode||t.builderMode){const{authActions:e,authStateActions:a,connectivityActions:n,subscriptionsActions:s,subscriptionsStateActions:i,vendorActions:o,auditsActions:r}=Wu(R,N,C);D.auth=a,D.connectivity=n,D.subscriptions=i,D.vendor=o,D.auditLogs=r,D.audits={},Object.assign(C,v({},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:()=>R,subscribe:t=>P(R,t),store:R,actions:C,stateActions:D};return t.previewMode&&l.dispatch({type:"auth/requestAuthorize",payload:!0}),c&&(c.store=l),l}{const[t,e]=Sl(R,N,C,O),a=Tl(R,N,C),[n,s]=ic(R,N,C),i=lc(R,N,C),o=Sc(R,N,C),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:p=d,onlyOneLoad:g=!0,offset:h=0}=s||{},{rowsData:y}=p?t.audits:{rowsData:[]};try{const n=r(i),{data:s,total:p}=await e.audits.getAudits(v({},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:p}),g&&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(v({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}}}})(R,N);return D.auth=e,D.connectivity=a,D.subscriptions=s,D.vendor=i,D.auditLogs=o,D.audits=r,Object.assign(C,v({},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:()=>R,subscribe:t=>P(R,t),store:R,actions:C,stateActions:D}}};let Ku,qu,Ju,Yu,Qu,Xu,Zu,td,ed,ad,nd,sd,id;!function(t){t.phoneNumber="phoneNumber"}(Ku||(Ku={})),function(t){t.Name="name",t.PhoneNumber="phoneNumber",t.Address="address",t.JobTitle="jobTitle"}(qu||(qu={})),function(t){t.LoginSessions="loginSessions",t.Mfa="mfa"}(Ju||(Ju={})),function(t){t.Name="name",t.PhoneNumber="phoneNumber"}(Yu||(Yu={})),function(t){t.CompanyName="companyName",t.Address="address",t.Website="website",t.Timezone="timezone",t.Currency="currency"}(Qu||(Qu={})),function(t){t.User="user",t.Applications="applications",t.Groups="groups",t.Roles="roles",t.JoinedAt="joinedAt",t.LastSeen="lastSeen",t.ManagedBy="managedBy"}(Xu||(Xu={})),function(t){t.Invoices="invoices"}(Zu||(Zu={})),function(t){t.SessionManagement="sessionManagement",t.GeneralSettings="generalSettings",t.IpRestrictions="ipRestrictions",t.DomainRestrictions="domainRestrictions"}(td||(td={})),function(t){t.IdleSessionTimeout="idleSessionTimeout",t.ForceReLogin="forceReLogin",t.MaximumConcurrentSessions="maximumConcurrentSessions"}(ed||(ed={})),function(t){t.Mfa="mfa",t.UserLockout="userLockout",t.PasswordHistory="passwordHistory"}(ad||(ad={})),function(t){t.IpAddressRestrictions="ipAddressRestrictions"}(nd||(nd={})),function(t){t.RestrictSignupByEmailDomain="restrictSignupByEmailDomain"}(sd||(sd={})),function(t){t.Settings="settings",t.CustomLogin="customLogin"}(id||(id={}));const od={hidden:"hidden",viewOnly:"viewOnly",edit:"edit"},rd={hidden:"hidden",edit:"edit"};function ld(t,e=0,a=1){return Math.min(Math.max(e,t),a)}function cd(t){if(t.type)return t;if("#"===t.charAt(0))return cd(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 ud(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 dd(t){if(0===t.indexOf("#"))return t;const{values:e}=cd(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 pd(t,e){return t=cd(t),e=ld(e),"rgb"!==t.type&&"hsl"!==t.type||(t.type+="a"),"color"===t.type?t.values[3]=`/${e}`:t.values[3]=e,ud(t)}function gd(t,e){if(t=cd(t),e=ld(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 ud(t)}function hd(t,e){if(t=cd(t),e=ld(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 ud(t)}const yd=t=>{if(t)return{main:t,light:dd(hd(t,.4)),dark:dd(gd(t,.15)),hover:dd(gd(t,.15)),active:dd(gd(t,.2))}},Sd=t=>{if(t)return{main:t,light:hd(t,.7),dark:gd(t,.2)}},vd=(t,e)=>{var a,n,s,i,o,r,l,c,u,d,p,g;return null!=t&&t.palette&&"string"==typeof(null==t||null==(a=t.palette)?void 0:a.primary)?v({},e,{palette:{primary:v({},yd(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:v({},yd(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:v({},yd(null==t||null==(c=t.palette)?void 0:c.error),{contrastText:"#FFF"}),success:v({},Sd(null==t||null==(u=t.palette)?void 0:u.success),{contrastText:"#FFF"}),error:v({},Sd(null==t||null==(d=t.palette)?void 0:d.error),{contrastText:"#FFF"}),warning:v({},Sd(null==t||null==(p=t.palette)?void 0:p.warning),{contrastText:"#FFF"}),info:v({},Sd(null==t||null==(g=t.palette)?void 0:g.info),{contrastText:"#FFF"})}}):{}},fd={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 md{constructor(){this._theme=fd.theme,this._themeV2=fd.themeV2,this._navigation=fd.navigation,this._localizations=fd.localizations,this._integrations=fd.integrations}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new md;return a.set(t),md._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=fd.navigation)?e:{},null!=(a=null==t?void 0:t.navigation)?a:{}]),this._theme=Ln().all([null!=(n=fd.theme)?n:{},vd(null==t?void 0:t.theme,fd.theme)]),this._themeV2=Ln().all([null!=(s=fd.themeV2)?s:{},null!=(i=null==t?void 0:t.themeV2)?i:{}]),this._localizations=Ln().all([null!=(o=fd.localizations)?o:{},null!=(r=null==t?void 0:t.localizations)?r:{}]),this._integrations=Ln().all([null!=(l=fd.integrations)?l:{},null!=(c=null==t?void 0:t.integrations)?c:{}])}catch(t){this._navigation=fd.navigation,this._theme=fd.theme,this._themeV2=fd.themeV2,this._localizations=fd.localizations,this._integrations=fd.integrations}}}md._instances={};var bd=function(t){return t.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map((function(t){return t.toLowerCase()})).join("")},Ad=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},wd=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)}))},Td=function(t){var e=t.toString();if(e){var a=new URL(window.location.href);a.search=e,window.history.pushState(null,"",a.toString())}};var Ed={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"},Id=function(t){var e,a=md.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)}))},Od=function(){var t=g(y().mark((function t(e,a){var n,s,i,o;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=null==(n=e.metadataOverrides)?void 0:n.url){t.next=3;break}return t.abrupt("return",e);case 3:return t.prev=3,t.next=6,a.sendRequest({url:s,method:"GET",credentials:"omit"});case 6:if(!(i=t.sent)){t.next=10;break}return o=Ln()(e,i),t.abrupt("return",o);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){return t.apply(this,arguments)}}(),Pd=function(){function a(t,e){var n,s,o=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=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("7.5.0"),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=g(y().mark((function t(){var e,a,n,s,i;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o.options.metadata){t.next=14;break}return t.prev=1,t.next=4,o.fetchClient.get("/metadata",{entityName:"adminBox"});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.next=8,Od(i,o.fetchClient);case 8:o.options.metadata=t.sent,t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),console.error("failed to get admin portal metadata",t.t0);case 14:md.set(o.options.metadata,o.name);case 15:case"end":return t.stop()}}),t,null,[[1,11]])}))),this.requestAuthorize=g(y().mark((function t(){var e,a,n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=null==(e=o.options.authOptions)||null==(a=e.hostedLoginOptions)?void 0:a.loadUserOnFirstLoad,o.options.builderMode||"nextjs"===o.options.framework||(o.options.hostedLoginBox&&!o.options.customLoginBox?n&&o.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:{shouldRedirectToLogin:!1,firstTime:!0}}):o.store.dispatch({type:"auth/requestAuthorize",payload:!0}));case 2:case"end":return t.stop()}}),t)}))),this.loadFeatureFlags=g(y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!o.options.previewMode&&!o.options.builderMode){t.next=4;break}Yt.set(Ed,o.name),t.next=15;break;case 4:return t.prev=4,t.next=7,o.apiClient.featureFlags.loadFeatureFlags();case 7:e=t.sent,o.options.overrideFeatureFlags&&Object.assign(e,o.options.overrideFeatureFlags),Yt.set(e,o.name),t.next=15;break;case 12:t.prev=12,t.t0=t.catch(4),console.error("failed to get admin portal feature flags",t.t0);case 15:case"end":return t.stop()}}),t,null,[[4,12]])}))),this.setFeatureFlagsForPreview=function(t){Yt.set(Object.assign({},Ed,t),o.name)},this.queryFeatureFlags=function(t){return Yt.getFeatureFlags(t,o.name)},this.updateLocalizationsSetter=function(t){o.updateLocalizations=t},this.getEntitlementsFromStore=function(){var t;return null==(t=o.store.getState().auth.user)?void 0:t.entitlements},this.getUserFromStore=function(){return o.store.getState().auth.user},this.getEntitlementsQueryData=function(t){var e=o.getUserFromStore();return{entitlements:o.getEntitlementsFromStore(),attributes:{custom:t,jwt:e}}};var u=bd(e),d="frontegg-app-".concat(u);this.iframeRendering=r,this.name=u,this.options=Object.assign({},t,{contextOptions:Object.assign({requestCredentials:"include"},t.contextOptions)}),this.fetchClient=new Nt(this.name),this.apiClient=Wa(this.name),this.options.cdnUrl&&(this.cdnUrl=this.options.cdnUrl),this.customElementName=d;var p,h,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,!l&&this.options.store.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=zu({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!=(p=this.options.authOptions)?p:{}),auditLogs:Object.assign({},null!=(h=this.options.auditsOptions)?h:{})}});c.setInstance(u,this);var v=L.for(u);v.setAppName(u),this.setEntitlementsOptions(t.entitlementsOptions),this.setSessionContext({enableSessionPerTenant:null==(s=t.authOptions)?void 0:s.enableSessionPerTenant});var f=t.basename;f&&v.setBasename(f)}var n,o,r,u;return l(a,[{key:"setEntitlementsOptions",value:function(t){L.for(this.name).setEntitlementsOptions(Object.assign({},t))}},{key:"setSessionContext",value:function(t){L.for(this.name).setSessionContext(Object.assign({},t))}},{key:"initContainers",value:(u=g(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,this.loadFeatureFlags();case 9:return t.next=11,Promise.all([this.loadAdminBoxMetadata(),this.requestAuthorize()]);case 11:this.options.previewMode||this.options.customLoginBox||(this.loadLoginBox(),Id(this.name)),this.options.lazyLoadAdminPortal||this.loadScript("FronteggAdminPortal");case 13:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"updateMetadata",value:function(t){var e;md.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:"logout",value:function(){this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/logout"})}},{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=g(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=g(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],L.for(this.name).setRequestSource(Rt.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(),Td(e),L.for(this.name).setRequestSource(null)}catch(t){console.error("Failed to unmount admin portal",t)}}},{key:"showCheckoutDialog",value:(n=g(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 on(n,t,s)}},{key:"getPermissionEntitlements",value:function(t,e){var a=this.getEntitlementsQueryData(e),n=a.entitlements,s=a.attributes;return sn(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}):ys(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 gs(a,e)}},{key:"switchTenant",value:function(t){this.store.dispatch({type:"auth/switchTenant",payload:t})}},{key:"close",value:function(){this.hideAdminPortal(),this.hideCheckoutDialog()}}]),a}(),kd=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=L.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}(),_d=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}(),Ud=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}(),Ld=function(t){var e;return null!=(e=window.FronteggAdminPortal.adminPortalStaticThemesDefaults[t])?e:void 0},Rd=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=Hu({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 Pd(this.options,e,!0),md.set({},e)}var e;return l(t,[{key:"render",value:(e=g(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,wd(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}(),Dd="modern",Cd=function(t){var e,a=window.FronteggAdminPortal.themes;return null!=(e=a[t])?e:a[Dd]},Nd=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=Hu({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 Pd(this.options,e,!0,o),md.set({},e)}var e;return l(t,[{key:"render",value:(e=g(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,wd(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 Md(t,e){return Md=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Md(t,e)}function Fd(t){return Fd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Fd(t)}function xd(t,e,a){return xd=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&&Md(s,a.prototype),s},xd.apply(null,arguments)}function $d(t){var e="function"==typeof Map?new Map:void 0;return $d=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 xd(t,arguments,Fd(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Md(n,t)},$d(t)}function Gd(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=Fd(t);if(e){var s=Fd(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 jd=function(t){var e=new Pd(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(t){!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&&Md(t,e)}(a,t);var e=Gd(a);function a(){var t;i(this,a);for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];return(t=e.call.apply(e,[this].concat(s))).app=null,t}return l(a,[{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 t,e=null!=(t=this.getAttribute("app-name"))?t:"default",a=c.getInstance(e);if(null===a)throw Error("FronteggApp not found for appName: '".concat(e,"'"));this.setAttribute("id","frontegg-app-".concat(a.name));var n=Ad(this,"div",{id:"frontegg-admin-portal-container-".concat(a.name)}),s=Ad(this,"div",{id:"frontegg-login-box-container-".concat(a.name)}),i=Ad(this,"div",{id:"frontegg-checkout-dialog-container-".concat(a.name)}),o=n.attachShadow({mode:"open"}),r=s.attachShadow({mode:"open"}),l=i.attachShadow({mode:"open"}),u=Ad(o,"div",{id:"frontegg-admin-portal-".concat(a.name),class:"frontegg-root-content"}),d=Ad(r,"div",{id:"frontegg-login-box-".concat(a.name),class:"frontegg-root-content"}),p=Ad(l,"div",{id:"frontegg-checkout-dialog-".concat(a.name),class:"frontegg-root-content"});a.initContainers({adminPortalEl:u,loginBoxEl:d,adminPortalContainer:n,loginBoxContainer:s,checkoutDialogContainer:i,checkoutDialogEl:p})}}],[{key:"observedAttributes",get:function(){return["app-name"]}}]),a}($d(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})()));