import{v as A}from"./index-jEdKdJVQ.js";import{_ as v}from"./index-CwP5gtrp-D2vs7vDd.js";import{_ as w}from"./BFormSelect.vue_vue_type_script_setup_true_lang-CkLgnxVA-_BER9NPg.js";import{_ as y}from"./useFormSelect-DvaFh_iu-BGTVaqMd.js";import{_ as $}from"./BButton.vue_vue_type_script_setup_true_lang-D5Eg7-Zv-DDRCX2AG.js";import{_ as I,d as c,o as a,f as S,b as l,c as f,w as o,a as i,n as k,t as n,e as r,F as M,r as C}from"./index-D02r7Zsc.js";import"./constants-Cx335y3L-Cz4s3oUD.js";import"./index-C0p9vHHI-DoOEDIMw.js";import"./getElement-DrDVR-jO-jZgQ3Xxs.js";import"./BCloseButton.vue_vue_type_script_setup_true_lang-byZmQ_ot-CWP55Z5N.js";import"./useDefaults-DESCdb0p-CFLjYrdG.js";import"./useId-t29UARy6-BH5d2231.js";import"./dom-DVb-f0ZG-Crdf0-mU.js";import"./useColorVariantClasses-ZDE19TZw-Cvu7SygP.js";import"./useShowHide-717t6y_D-BZTBbOpd.js";import"./classes-BW_GpXTu-AKwVND4h.js";import"./useStateClass-BGbSLWFN-BcKQ8Z3i.js";import"./object-0ALvRU0O-3BORTTD-.js";import"./BSpinner.vue_vue_type_script_setup_true_lang-H1MzHypA-D8AXjJB0.js";import"./BLink.vue_vue_type_script_setup_true_lang-Ct47WhzE-DDPYis_D.js";import"./stringUtils-gJJ6T6UC-g5BZrMym.js";const B={props:{deactivate:{type:Boolean,required:!0}},data:function(){return{accounts:[],selectedAccount:"",component:"",isAssociatedAccount:!1,showModal:!1}},watch:{deactivate(){this.deactivation()}},created:function(){localStorage.getItem("associatedAccounts")&&JSON.parse(localStorage.getItem("associatedAccounts"))[this.get("userId")]&&(this.accounts=this.decryptAccountsArray(JSON.parse(localStorage.getItem("associatedAccounts"))[this.get("userId")]),this.getModule("accountselector").isAssociatedAccount()&&(this.isAssociatedAccount=!0),this.component=this.$route.name)},methods:{async newConnection(){this.showModal=!1,this.publish("showOverlay",!0);let t=await this.get("ws").login(this.selectedAccount.login,this.selectedAccount.password);t&&(this.set("sessionId",t),await this.getModule("start").setData(this.get("sessionId"),this.component),this.isAssociatedAccount=!0),this.publish("showOverlay",!1),this.publish("accountChange")},async deactivation(t=!1){if(this.showModal=!1,!this.accounts.length){this.publish("deactivationFinished");return}this.getModule("accountselector").isAssociatedAccount()&&(this.publish("showOverlay",!0),await this.get("ws").logout(this.get("sessionId")),this.set("sessionId",this.getModule("start").getUserInfos(localStorage.getItem("mainAccount")).sessionId),await this.getModule("start").setData(this.get("sessionId"),this.component),this.publish("showOverlay",!1)),this.publish("deactivationFinished"),t&&this.publish("reload")},decryptAccountsArray(t){var e=[];for(let d in t)e.push(this.getModule("start").getUserInfos(t[d]));return e}}},V={key:0,class:"d-flex align-items-baseline"},T={class:"d-flex w-100 align-items-center bg-primary text-light p-3"},O={class:"mb-0"},z=["onClick"],N={key:1};function D(t,e,d,F,U,u){const h=$,m=y,g=w,b=v,_=A;return t.accounts.length?(a(),c("div",V,[S((a(),f(h,{pill:"",size:"sm",variant:"outline-third","aria-label":t.$t("ariaLabels.associatedAccounts.associatedAccountsButton")},{default:o(()=>[i("i",{"aria-hidden":"true",class:k(`${this.isAssociatedAccount?"bi bi-people-fill":"bi bi-person-lines-fill"}`),style:{"font-size":"1.1rem"}},null,2)]),_:1},8,["aria-label"])),[[_,void 0,void 0,{accountSelector:!0}]]),l(b,{modelValue:t.showModal,"onUpdate:modelValue":e[3]||(e[3]=s=>t.showModal=s),"no-footer":!t.isAssociatedAccount,"ok-disabled":"",centered:"","header-class":"bg-primary text-light title",id:"accountSelector",title:t.$t("account.associatedAccountsTitle")},{header:o(({close:s})=>[i("div",T,[i("h5",O,n(t.$t("account.associatedAccountsTitle")),1),i("button",{type:"button",class:"btn-close btn-close-white ms-auto",onClick:p=>s(),"aria-label":"Close"},null,8,z)])]),footer:o(()=>[l(h,{size:"sm",variant:"outline-primary",onClick:e[2]||(e[2]=s=>u.deactivation(!0))},{default:o(()=>[e[4]||(e[4]=i("i",{"aria-hidden":"true",class:"bi bi-arrow-bar-left"},null,-1)),r(" "+n(t.$t("accountSelector.backText")),1)]),_:1})]),default:o(()=>[i("p",null,n(t.$t("accountSelector.switchText")),1),l(g,{onChange:e[0]||(e[0]=s=>u.newConnection()),size:"sm",modelValue:t.selectedAccount,"onUpdate:modelValue":e[1]||(e[1]=s=>t.selectedAccount=s)},{default:o(()=>[l(m,{value:"",disabled:""},{default:o(()=>[r(n(t.$t("accountSelector.selectorText")),1)]),_:1}),(a(!0),c(M,null,C(this.accounts,(s,p)=>(a(),f(m,{value:s,key:p},{default:o(()=>[r(n(s.login),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["modelValue","no-footer","title"])])):(a(),c("div",N,"   "))}const at=I(B,[["render",D]]);export{at as default};
