import{b as S,a1 as I,g as k,x as N,o,c as i,a as l,n as x,t as n,d as f,w as g,N as E,q as M,r as C,s as p,a0 as b}from"./app-583c7dce.js";import{u as T}from"./useEmitter-7699a4d3.js";const $=["id","aria-labelledby"],D={class:"modal-dialog modal-dialog-centered"},L={class:"modal-content"},V={class:"modal-body"},_={class:"text-left"},F={class:"text-left font-weight-bold msg-white"},U={key:0,class:"text-center"},Y={class:"text-left"},q={key:1,class:"text-left d-flex gap-2"},z={key:2,class:"text-left"},G={__name:"DeleteModal",props:{modalId:{type:String,default:"app-delete-modal"},title:String,icon:String,subTitle:String,message:String,modalClass:String,firstButtonName:String,secondButtonName:String,showFooter:{type:Boolean,default:!0},selectedUrl:String,tableId:String,callBackEmit:{type:Boolean,default:!1}},emits:["cancelled","confirmed","confirmSuccess"],setup(e,{emit:y}){const s=e,c=y,m=S(!1),r=I(),h=T(),v=()=>{u(),c("cancelled",!1)},B=async()=>{m.value=!0,await p.delete(s.selectedUrl).then(t=>{u(),r.success(t.data.message),h.emit("reload-"+s.tableId),s.callBackEmit&&c("confirmSuccess")}).catch(t=>{var a,d;(d=(a=t.response)==null?void 0:a.data)!=null&&d.message&&r.error(t.response.data.message)}).finally(()=>m.value=!1)},w=()=>{new b(document.getElementById(s.modalId)).show()},u=()=>{b.getInstance(document.getElementById(s.modalId)).hide()};return k(()=>{w();let t=document.getElementById(s.modalId),a=document.getElementsByTagName("html")[0];t.addEventListener("hidden.bs.modal",()=>{c("cancelled"),a.style.overflowY="auto"}),t.addEventListener("shown.bs.modal",()=>{a.style.overflowY="hidden"})}),(t,a)=>{const d=N("app-button-loader");return o(),i("div",{class:"modal fade",id:e.modalId,tabindex:"-1","aria-labelledby":`${e.modalId}-ModalLabel`,"aria-hidden":"true"},[l("div",D,[l("div",L,[l("div",V,[l("div",_,[l("i",{class:x([[e.icon?e.icon:"bi bi-trash-fill",e.modalClass?e.modalClass:"text-danger"],"custom-delete-icon display-3"])},null,2)]),a[1]||(a[1]=l("br",null,null,-1)),l("h4",F,n(e.title?e.title:t.$t("are_you_sure_you_want_to_delete")),1),e.subTitle?(o(),i("p",U,n(e.subTitle),1)):f("",!0),l("p",Y,n(e.message?e.message:t.$t("this_content_will_be_deleted_permanently")),1),a[2]||(a[2]=l("div",{class:"border-top my-4"},null,-1)),e.showFooter?(o(),i("div",q,[l("button",{class:"btn btn-primary-danger-outline mx-1","data-dismiss":"modal",onClick:g(v,["prevent"])},n(e.secondButtonName?e.secondButtonName:t.$t("cancel")),1),l("button",{class:"btn btn-primary-danger btn-danger","data-dismiss":"modal",onClick:g(B,["prevent"])},[m.value?(o(),E(d,{key:0})):f("",!0),a[0]||(a[0]=l("i",{class:"bi bi-trash"},null,-1)),M(" "+n(e.firstButtonName?e.firstButtonName:t.$t("delete")),1)])])):(o(),i("div",z,[C(t.$slots,"footer")]))])])])],8,$)}}};export{G as default};
