import{_ as g}from"./index-CwP5gtrp-D2vs7vDd.js";import{_ as b}from"./BButton.vue_vue_type_script_setup_true_lang-D5Eg7-Zv-DDRCX2AG.js";import{_ as w}from"./BFormSelect.vue_vue_type_script_setup_true_lang-CkLgnxVA-_BER9NPg.js";import{_ as A}from"./useFormSelect-DvaFh_iu-BGTVaqMd.js";import{_ as v,c as m,o as i,w as o,a as l,b as r,t as a,d as y,e as c,F as I,r as S}from"./index-D02r7Zsc.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"./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"./object-0ALvRU0O-3BORTTD-.js";import"./stringUtils-gJJ6T6UC-g5BZrMym.js";import"./useStateClass-BGbSLWFN-BcKQ8Z3i.js";const $={props:{id:{type:Number,required:!0},bullId:{type:Number,required:!1}},data:function(){return{accounts:[],selectedAccount:"",showModal:!1}},created:function(){localStorage.getItem("associatedAccounts")&&(this.accounts=this.getModule("accountselector").decryptAccountsArray(JSON.parse(localStorage.getItem("associatedAccounts"))[this.get("userId")]))},methods:{async reserve(){if(this.showModal=!1,this.publish("showOverlay",!0),Object.keys(this.selectedAccount).length>0){let s=await this.getModule("start").login(this.selectedAccount.login,this.selectedAccount.password,!0);var e=await this.get("ws").addResa(s,this.id,this.bullId?this.bullId:"",JSON.parse(localStorage.getItem("userDefaultLocation")));await this.get("ws").logout(s),await this.getModule("start").login(null,null,!0)}else{var e=await this.get("ws").addResa(this.get("sessionId"),this.id,this.bullId?this.bullId:"",JSON.parse(localStorage.getItem("userDefaultLocation")));this.getModule("start").setData(this.get("sessionId"),"loans")}this.publish("showOverlay",!1),this.selectedAccount="",this.$emit("resa_sent",e)}}},k={class:"d-flex w-100 align-items-center bg-primary text-light p-3"},C={class:"mb-0"},V=["onClick"];function M(e,s,p,N,B,n){const d=A,h=w,_=b,f=g;return i(),m(f,{modelValue:e.showModal,"onUpdate:modelValue":s[1]||(s[1]=t=>e.showModal=t),size:"sm","ok-disabled":"",centered:"","header-class":"bg-primary text-light title",id:"accountResaSelector_"+p.id,title:"Comptes associés"},{header:o(({close:t})=>[l("div",k,[l("h5",C,a(e.$t("account.associatedAccountsTitle")),1),l("button",{type:"button",class:"btn-close btn-close-white ms-auto",onClick:u=>t(),"aria-label":"Close"},null,8,V)])]),footer:o(()=>[r(_,{size:"sm",variant:"outline-third",onClick:n.reserve},{default:o(()=>[c(a(e.$t("accountResaSelector.ownAccountButton")),1)]),_:1},8,["onClick"])]),default:o(()=>[l("p",null,a(e.$t("accountResaSelector.content")),1),r(h,{onChange:n.reserve,size:"sm",modelValue:e.selectedAccount,"onUpdate:modelValue":s[0]||(s[0]=t=>e.selectedAccount=t)},{default:o(()=>[r(d,{value:"",disabled:""},{default:o(()=>[c(a(e.$t("accountSelector.selectorText")),1)]),_:1}),(i(!0),y(I,null,S(e.accounts,(t,u)=>(i(),m(d,{value:t,key:u},{default:o(()=>[c(a(t.login),1)]),_:2},1032,["value"]))),128))]),_:1},8,["onChange","modelValue"])]),_:1},8,["modelValue","id"])}const X=v($,[["render",M]]);export{X as default};
