import{_ as v}from"./index-CwP5gtrp-D2vs7vDd.js";import{_ as w,a as R}from"./BListGroupItem.vue_vue_type_script_setup_true_lang-J0Ydbiva-Cr65tDD4.js";import{_ as c}from"./BButton.vue_vue_type_script_setup_true_lang-D5Eg7-Zv-DDRCX2AG.js";import{_ as L,d as m,h as y,o as r,b as d,w as n,a as l,F as k,r as N,c as g,e as C,t as M}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"./BLink.vue_vue_type_script_setup_true_lang-Ct47WhzE-DDPYis_D.js";import"./object-0ALvRU0O-3BORTTD-.js";import"./stringUtils-gJJ6T6UC-g5BZrMym.js";import"./BSpinner.vue_vue_type_script_setup_true_lang-H1MzHypA-D8AXjJB0.js";const B={props:{element:{type:Object,required:!0}},data(){return{showModal:!1,recordReadingLists:[]}},computed:{show:function(){return!(this.getConfig().disabledElements.includes("readinglistslist")||this.recordReadingLists.length==0)}},methods:{addNoticeToReadingList:async function(i){this.publish("showOverlay",!0);let e=await this.get("ws").addNoticesToReadingList(this.get("sessionId"),i,[this.element.recordId]);this.publish("showOverlay",!1),e&&(this.set("readinglists",this.get("readinglists").map(s=>(s.reading_list_id==i&&s.reading_list_notice_ids.push(this.element.recordId.toString()),s))),this.initRecordReadingList())},removeNoticeFromReadingList:async function(i){this.publish("showOverlay",!0);let e=await this.get("ws").removeNoticesFromReadingList(this.get("sessionId"),i,[this.element.recordId]);this.publish("showOverlay",!1),e&&(this.set("readinglists",this.get("readinglists").map(s=>(s.reading_list_id==i&&s.reading_list_notice_ids.splice(s.reading_list_notice_ids.indexOf(this.element.recordId.toString()),1),s))),this.initRecordReadingList(),this.$route.name==="readinglistitem"&&(this.showModal=!1))},initRecordReadingList:function(){this.recordReadingLists=[];for(let i of this.get("readinglists"))i.reading_list_notice_ids&&i.reading_list_notice_ids.includes(this.element.recordId.toString())&&this.recordReadingLists.push(i.reading_list_id)},startModal:function(){this.initRecordReadingList(),this.showModal=!0}}},x={key:0};function O(i,e,s,$,o,a){const u=c,_=c,h=R,f=w,p=v;return a.show?(r(),m("div",x,[d(u,{size:"",variant:"transparent",onClick:a.startModal},{default:n(()=>[...e[2]||(e[2]=[l("i",{"aria-hidden":"true",class:"bi bi-list-ul text-medium-green",style:{"font-size":"1.7rem"}},null,-1)])]),_:1},8,["onClick"]),d(p,{id:"readinglistModal",show:o.showModal,onHide:e[0]||(e[0]=t=>o.showModal=!1),title:i.$t("readingListButton.selectReadingListTitle"),centered:"","header-bg-variant":"medium-green","header-class":"text-light title","body-bg-variant":"light","footer-bg-variant":"light","ok-variant":"outline-info","ok-only":"",onOk:e[1]||(e[1]=t=>o.showModal=!1)},{default:n(()=>[d(f,null,{default:n(()=>[(r(!0),m(k,null,N(i.get("readinglists"),t=>(r(),g(h,{key:t.reading_list_id,value:t.reading_list_id,class:"d-flex justify-content-between align-items-center"},{default:n(()=>[C(M(t.reading_list_name)+" ",1),o.recordReadingLists.includes(t.reading_list_id)?(r(),g(_,{key:0,size:"sm",variant:"outline-danger",disabled:t.reading_list_readonly==1,onClick:b=>a.removeNoticeFromReadingList(t.reading_list_id)},{default:n(()=>[...e[3]||(e[3]=[l("i",{"aria-hidden":"true",class:"bi bi-trash"},null,-1)])]),_:1},8,["disabled","onClick"])):(r(),g(_,{key:1,size:"sm",variant:"outline-info",disabled:t.reading_list_readonly==1,onClick:b=>a.addNoticeToReadingList(t.reading_list_id)},{default:n(()=>[...e[4]||(e[4]=[l("i",{"aria-hidden":"true",class:"bi bi-plus"},null,-1)])]),_:1},8,["disabled","onClick"]))]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["show","title"])])):y("",!0)}const U=L(B,[["render",O]]);export{U as default};
