import{_}from"./BButton.vue_vue_type_script_setup_true_lang-D5Eg7-Zv-DDRCX2AG.js";import{_ as M}from"./BButtonToolbar.vue_vue_type_script_setup_true_lang-CxCcFupr-CBdlhxg8.js";import{_ as v}from"./BContainer.vue_vue_type_script_setup_true_lang-Bi1hGl0B-Bd4Gid1V.js";import{_ as C,d as m,o as n,b as s,w as r,c as $,g as k,a as e,t as l,e as c}from"./index-D02r7Zsc.js";import"./BSpinner.vue_vue_type_script_setup_true_lang-H1MzHypA-D8AXjJB0.js";import"./dom-DVb-f0ZG-Crdf0-mU.js";import"./useDefaults-DESCdb0p-CFLjYrdG.js";import"./useColorVariantClasses-ZDE19TZw-Cvu7SygP.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"./index-C0p9vHHI-DoOEDIMw.js";const w={data:function(){return{emptyBookmarksModal:{content:this.$tm("bookmarkedRecords.emptyBookmarksModal"),headerBg:"danger",method:"emptyBookmarks",type:"confirmModal",start:!1},fillCartModal:{content:this.$tm("bookmarkedRecords.fillCartModal"),headerBg:"info",method:"fillCart",type:"confirmModal",start:!1},helpMessage:this.$t("bookmarkedRecords.helpMessage"),sortAlphabetically:!1,sortedBookmarks:[],loadingSort:!1}},computed:{displayedBookmarks(){return this.sortAlphabetically&&this.sortedBookmarks.length>0?this.sortedBookmarks:this.get("bookmarks")}},methods:{emptyBookmarks(){this.getModule("bookmarkbutton").setUserBookmarks([])},fillCart:async function(){this.publish("showOverlay",!0),await this.get("ws").addNoticeToCart(this.get("sessionId"),this.get("bookmarks")),this.publish("showOverlay",!1)},async toggleSort(){this.sortAlphabetically=!this.sortAlphabetically,this.sortAlphabetically?await this.sortBookmarksAlphabetically():this.sortedBookmarks=[]},async sortBookmarksAlphabetically(){this.loadingSort=!0,this.publish("showOverlay",!0);try{const t=(await this.getModule("noticelist").getRecordInformations(this.get("sessionId"),this.get("bookmarks"))).sort((i,h)=>{const p=i.title?.a?.[0]||"",a=h.title?.a?.[0]||"";return p.localeCompare(a,"fr",{sensitivity:"base"})});this.sortedBookmarks=t.map(i=>i.recordId)}catch(o){console.error("Error sorting bookmarks:",o)}finally{this.loadingSort=!1,this.publish("showOverlay",!1)}}}},A={class:"position-relative mb-4 d-flex align-items-center"},R={class:"h3 title text-secondary text-center mb-0 w-100"},I={class:"position-absolute end-0"},S={key:0},N={class:"mb-3 px-3"},O={key:1},z={class:"text-center p-4"};function T(o,t,i,h,p,a){const b=k("help"),u=v,f=k("modal"),d=_,y=M,B=k("noticelist");return n(),m("div",null,[s(u,null,{default:r(()=>[e("div",A,[e("h1",R,l(o.$t("menusLabels.bookmarks.full")),1),e("div",I,[s(b,{help:this.helpMessage},null,8,["help"])])])]),_:1}),o.get("bookmarks").length?(n(),m("div",S,[s(f,{modalInfos:o.emptyBookmarksModal,onModal_emptyBookmarks:a.emptyBookmarks},null,8,["modalInfos","onModal_emptyBookmarks"]),s(f,{modalInfos:o.fillCartModal,onModal_fillCart:a.fillCart},null,8,["modalInfos","onModal_fillCart"]),s(u,null,{default:r(()=>[e("div",N,[s(y,{class:"w-100 mb-2"},{default:r(()=>[s(d,{size:"sm",variant:"outline-third",onClick:t[0]||(t[0]=g=>o.fillCartModal.start=!o.fillCartModal.start)},{default:r(()=>[t[2]||(t[2]=e("i",{class:"bi bi-cart me-1","aria-hidden":"true"},null,-1)),c(" "+l(o.$t("bookmarkedRecords.fillCartButton")),1)]),_:1}),s(d,{size:"sm",variant:"outline-danger",onClick:t[1]||(t[1]=g=>o.emptyBookmarksModal.start=!o.emptyBookmarksModal.start)},{default:r(()=>[t[3]||(t[3]=e("i",{class:"bi bi-trash me-1","aria-hidden":"true"},null,-1)),c(" "+l(o.$t("bookmarkedRecords.emptyBookmarksButton")),1)]),_:1})]),_:1}),s(d,{size:"sm",variant:o.sortAlphabetically?"third":"outline-third",block:"",onClick:a.toggleSort,disabled:o.loadingSort},{default:r(()=>[t[4]||(t[4]=e("i",{class:"bi bi-sort-alpha-down me-1","aria-hidden":"true"},null,-1)),c(" "+l(o.$t("bookmarkedRecords.sortButton")),1)]),_:1},8,["variant","onClick","disabled"])])]),_:1}),(n(),$(B,{key:o.sortAlphabetically?"sorted":"unsorted",records:a.displayedBookmarks,bulletins:[]},null,8,["records"]))])):(n(),m("div",O,[e("p",z,l(o.$t("bookmarkedRecords.noBookmarksText")),1)]))])}const P=C(w,[["render",T]]);export{P as default};
