import{J as k,G as $,ah as T,r,o as p,l as f,w as t,u as c,f as u,i as S,t as z,j as C,B as E,k as O,e as F,m as G,F as P,a0 as V}from"./vendor.d12b5734.js";import{j as x,u as I,e as M,c as j,g as D}from"./main.465728e1.js";import{u as A,_ as H}from"./NoteModal.ebe10cf0.js";import"./payment.93619753.js";const L={props:{row:{type:Object,default:null},table:{type:Object,default:null},loadData:{type:Function,default:null}},setup(g){const d=g,h=x(),_=I(),{t:a}=k(),o=A(),N=$(),y=M(),b=j();T("utils");function w(n){o.fetchNote(n),b.openModal({title:a("settings.customization.notes.edit_note"),componentName:"NoteModal",size:"md",refreshData:d.loadData})}function s(n){h.openDialog({title:a("general.are_you_sure"),message:a("settings.customization.notes.note_confirm_delete"),yesLabel:a("general.yes"),noLabel:a("general.no"),variant:"danger",hideNoButton:!1,size:"lg"}).then(async()=>{(await o.deleteNote(n)).data.success?_.showNotification({type:"success",message:a("settings.customization.notes.deleted_message")}):_.showNotification({type:"error",message:a("settings.customization.notes.already_in_use")}),d.loadData&&d.loadData()})}return(n,e)=>{const i=r("BaseIcon"),m=r("BaseButton"),B=r("BaseDropdownItem"),l=r("BaseDropdown");return p(),f(l,null,{activator:t(()=>[c(N).name==="notes.view"?(p(),f(m,{key:0,variant:"primary"},{default:t(()=>[u(i,{name:"DotsHorizontalIcon",class:"h-5 text-white"})]),_:1})):(p(),f(i,{key:1,name:"DotsHorizontalIcon",class:"h-5 text-gray-500"}))]),default:t(()=>[c(y).hasAbilities(c(D).MANAGE_NOTE)?(p(),f(B,{key:0,onClick:e[0]||(e[0]=v=>w(g.row.id))},{default:t(()=>[u(i,{name:"PencilIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),S(" "+z(n.$t("general.edit")),1)]),_:1})):C("",!0),c(y).hasAbilities(c(D).MANAGE_NOTE)?(p(),f(B,{key:1,onClick:e[1]||(e[1]=v=>s(g.row.id))},{default:t(()=>[u(i,{name:"TrashIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),S(" "+z(n.$t("general.delete")),1)]),_:1})):C("",!0)]),_:1})}}},K={setup(g){const{t:d}=k(),h=j();x();const _=A();I();const a=M(),o=E(""),N=O(()=>[{key:"name",label:d("settings.customization.notes.name"),thClass:"extra",tdClass:"font-medium text-gray-900"},{key:"type",label:d("settings.customization.notes.type"),thClass:"extra",tdClass:"font-medium text-gray-900"},{key:"actions",label:"",tdClass:"text-right text-sm font-medium",sortable:!1}]);async function y({page:s,filter:n,sort:e}){let i=V({orderByField:e.fieldName||"created_at",orderBy:e.order||"desc",page:s}),m=await _.fetchNotes(i);return{data:m.data.data,pagination:{totalPages:m.data.meta.last_page,currentPage:s,totalCount:m.data.meta.total,limit:5}}}async function b(){await h.openModal({title:d("settings.customization.notes.add_note"),componentName:"NoteModal",size:"md",refreshData:o.value&&o.value.refresh})}async function w(){o.value&&o.value.refresh()}return(s,n)=>{const e=r("BaseIcon"),i=r("BaseButton"),m=r("BaseTable"),B=r("BaseSettingCard");return p(),F(P,null,[u(H),u(B,{title:s.$t("settings.customization.notes.title"),description:s.$t("settings.customization.notes.description")},{action:t(()=>[c(a).hasAbilities(c(D).MANAGE_NOTE)?(p(),f(i,{key:0,variant:"primary-outline",onClick:b},{left:t(l=>[u(e,{class:G(l.class),name:"PlusIcon"},null,8,["class"])]),default:t(()=>[S(" "+z(s.$t("settings.customization.notes.add_note")),1)]),_:1})):C("",!0)]),default:t(()=>[u(m,{ref:(l,v)=>{v.table=l,o.value=l},data:y,columns:c(N),class:"mt-14"},{"cell-actions":t(({row:l})=>[u(L,{row:l.data,table:o.value,"load-data":w},null,8,["row","table"])]),_:1},8,["columns"])]),_:1},8,["title","description"])],64)}}};export{K as default};
