import{r as t,h as s,g as e}from"./p-1a7a8b00.js";import{n as i,_ as n,P as a,p as o,q as h,r,b as c}from"./p-a44cd541.js";import{s as u}from"./p-b4467cc2.js";const d=class{constructor(s){t(this,s),this.handleSubscriptions=()=>{this.storeUnsubscribe&&this.storeUnsubscribe(),u.mapDispatchToProps(this,{updateActiveQuestionSet:i,removeActiveAnswerId:n}),this.storeUnsubscribe=u.mapStateToProps(this,this.mapStateToProps)},this.mapStateToProps=t=>({activeQuestionSetId:a(t),areParentQuestionSetsInNavigationEnabled:o(t),isQuestionSetNavigationEnabled:h(t),parentQuestionSets:r(t),questionSetsList:c(t)}),this.activeQuestionSetId=void 0,this.areParentQuestionSetsInNavigationEnabled=void 0,this.isQuestionSetNavigationEnabled=void 0,this.parentQuestionSets=[],this.questionSetsList=[],this.useExternal=!1,this.questionSets=[]}resetState(){this.questionSets=[]}onQuestionSetPropsChange(){const t=new WeakMap;this.questionSets=this.areParentQuestionSetsInNavigationEnabled?this.questionSetsList.reduce(((s,e)=>{if(e.parentQuestionSetId){const i=this.parentQuestionSets.find((t=>t.id===e.parentQuestionSetId));i&&!t.has(i)&&(t.set(i,!0),s.push(Object.assign(Object.assign({},i),{question_set_id:e.question_set_id,isParent:!0}))),s.push(Object.assign(Object.assign({},e),{isChild:!0}))}else s.push(e);return s}),[]):this.questionSetsList}connectedCallback(){this.resetState(),this.handleSubscriptions()}componentWillLoad(){this.useExternal=!!customElements.get("bp-sdk-external-question-set-navigation-container"),customElements.whenDefined("bp-sdk-external-question-set-navigation-container").then((()=>{this.useExternal=!0})),this.handleSubscriptions(),this.onQuestionSetPropsChange()}onRemoveActiveAnswerRequest(){this.removeActiveAnswerId()}disconnectedCallback(){this.storeUnsubscribe&&this.storeUnsubscribe()}handleActiveQuestionSetUpdate(t){this.useExternal||(t.detail&&this.updateActiveQuestionSet(t.detail),this.removeActiveAnswerId())}componentWillUpdate(){this.handleSubscriptions()}render(){return[this.useExternal&&this.renderExternal(),!this.useExternal&&this.renderInternal()]}renderExternal(){return s("bp-sdk-external-question-set-navigation-container",{activeQuestionSetId:this.activeQuestionSetId,areParentQuestionSetsInNavigationEnabled:this.areParentQuestionSetsInNavigationEnabled,isQuestionSetNavigationEnabled:this.isQuestionSetNavigationEnabled,parentQuestionSets:this.parentQuestionSets,questionSets:this.questionSets,questionSetsList:this.questionSetsList})}renderInternal(){return s("bp-sdk-question-set-navigation",{activeId:this.activeQuestionSetId,questionSets:this.questionSets,isNavigationEnabled:this.isQuestionSetNavigationEnabled})}get el(){return e(this)}static get watchers(){return{questionSetsList:["onQuestionSetPropsChange"],parentQuestionSets:["onQuestionSetPropsChange"]}}};export{d as bp_sdk_question_set_navigation_container}