import{d as L,e as O,aj as S,g as A,A as E,J as i,H as n,j as o,t as l,a8 as c,B as h,C as V,ax as W,r as D,c as s,aI as J}from"./index-DOFLUERq.js";import{I as M}from"./iconify-p99pbjf9.js";import{t as T}from"./timeline-CIH67oDr.js";import{_ as j}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./common-DEIQtiPI.js";const z=["title","disabled"],R=["title"],U=["title","disabled"],q=["title","disabled"],H=["title","disabled"],Y=L({__name:"whiteboard_list_actions",props:{row:{},entity:{},viewMode:{}},emits:["view","edit","delete","like-toggled"],setup(m,{emit:k}){const e=m,d=k,y=O(),_=S(),u=D(!1),b=s(()=>e.row._can_read===1||e.row._can_read===void 0),p=s(()=>e.row._can_write===1||e.row._can_write===void 0),v=s(()=>e.row._can_delete===1||e.row._can_delete===void 0),f=s(()=>_.user?.username||_.user?.name||""),w=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:[]}),r=s(()=>w.value.includes(f.value)),g=s(()=>e.viewMode==="card"?"actions-container card-actions":"actions-container col-actions");function C(){const t=J(e.entity);y.push({name:"WhiteboardEditor",query:{pagetype:t,id:e.row.name}})}async function x(){if(!u.value){u.value=!0;try{await T(e.entity,e.row.name,r.value?"No":"Yes");const t=[...w.value];if(r.value){const a=t.indexOf(f.value);a>=0&&t.splice(a,1)}else t.includes(f.value)||t.push(f.value);e.row._liked_by=JSON.stringify(t),d("like-toggled")}catch{}finally{u.value=!1}}}function N(){d("view",e.row)}function B(){d("edit",e.row)}function I(){d("delete",e.row)}return(t,a)=>(A(),E("div",{class:n(g.value)},[i("button",{class:n(["action-btn like-btn",{liked:r.value}]),onClick:c(x,["stop"]),title:r.value?o(l)("Unlike"):o(l)("Like"),disabled:u.value},[i("i",{class:n(r.value?"fas fa-heart":"far fa-heart")},null,2)],10,z),i("button",{class:"action-btn whiteboard-btn",onClick:c(C,["stop"]),title:o(l)("Open Whiteboard")},[h(o(W),{size:14},{default:V(()=>[h(o(M),{icon:"tabler:chalkboard"})]),_:1})],8,R),i("button",{class:n(["action-btn",{disabled:!b.value}]),onClick:c(N,["stop"]),title:o(l)("View"),disabled:!b.value},[...a[0]||(a[0]=[i("i",{class:"fa fa-eye"},null,-1)])],10,U),i("button",{class:n(["action-btn",{disabled:!p.value}]),onClick:c(B,["stop"]),title:o(l)("Edit"),disabled:!p.value},[...a[1]||(a[1]=[i("i",{class:"fa fa-edit"},null,-1)])],10,q),i("button",{class:n(["action-btn delete-btn",{disabled:!v.value}]),onClick:c(I,["stop"]),title:o(l)("Delete"),disabled:!v.value},[...a[2]||(a[2]=[i("i",{class:"fa fa-trash"},null,-1)])],10,H)],2))}}),X=j(Y,[["__scopeId","data-v-e7b26f7c"]]);export{X as default};
