import{d as x,aj as A,g as B,A as D,H as l,J as i,j as o,t as r,a8 as f,r as N,c as s}from"./index-DOFLUERq.js";import{t as S}from"./timeline-CIH67oDr.js";import{_ as E}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./common-DEIQtiPI.js";const J=["title","disabled"],M=["title","disabled"],O=["title","disabled"],V=["title","disabled"],j=x({__name:"default_list_actions",props:{row:{},entity:{},viewMode:{}},emits:["view","edit","delete","like-toggled"],setup(k,{emit:m}){const e=k,d=m,v=A(),c=N(!1),_=s(()=>e.row._can_read===1||e.row._can_read===void 0),w=s(()=>e.row._can_write===1||e.row._can_write===void 0),b=s(()=>e.row._can_delete===1||e.row._can_delete===void 0),u=s(()=>v.user?.username||v.user?.name||""),p=s(()=>{const t=e.row?._liked_by;if(!t)return[];if(typeof t=="string")try{return JSON.parse(t)}catch{return[]}return Array.isArray(t)?t:[]}),n=s(()=>p.value.includes(u.value));async function y(){if(!c.value){c.value=!0;try{await S(e.entity,e.row.name,n.value?"No":"Yes");const t=[...p.value];if(n.value){const a=t.indexOf(u.value);a>=0&&t.splice(a,1)}else t.includes(u.value)||t.push(u.value);e.row._liked_by=JSON.stringify(t),d("like-toggled")}catch{}finally{c.value=!1}}}const g=s(()=>e.viewMode==="card"?"actions-container card-actions":"actions-container col-actions");function h(){d("view",e.row)}function C(){d("edit",e.row)}function L(){d("delete",e.row)}return(t,a)=>(B(),D("div",{class:l(g.value)},[i("button",{class:l(["action-btn like-btn",{liked:n.value}]),onClick:f(y,["stop"]),title:n.value?o(r)("Unlike"):o(r)("Like"),disabled:c.value},[i("i",{class:l(n.value?"fas fa-heart":"far fa-heart")},null,2)],10,J),i("button",{class:l(["action-btn",{disabled:!_.value}]),onClick:f(h,["stop"]),title:o(r)("View"),disabled:!_.value},[...a[0]||(a[0]=[i("i",{class:"fa fa-eye"},null,-1)])],10,M),i("button",{class:l(["action-btn",{disabled:!w.value}]),onClick:f(C,["stop"]),title:o(r)("Edit"),disabled:!w.value},[...a[1]||(a[1]=[i("i",{class:"fa fa-edit"},null,-1)])],10,O),i("button",{class:l(["action-btn delete-btn",{disabled:!b.value}]),onClick:f(L,["stop"]),title:o(r)("Delete"),disabled:!b.value},[...a[2]||(a[2]=[i("i",{class:"fa fa-trash"},null,-1)])],10,V)],2))}}),R=E(j,[["__scopeId","data-v-4a42e390"]]);export{R as default};
