import{X as e,a3 as a,a4 as t,ao as i,c as s,aw as l,C as o,ap as d,k as p,a0 as r,Z as n,Y as c,an as u,$ as m,am as f}from"./index.9313841a.js";import{Q as v,a as y}from"./QItem.257ec3b6.js";import{a as h,Q as _}from"./QMenu.ee2e6e4d.js";import{Q as b}from"./QChip.ec87464e.js";import{C as g}from"./ClosePopup.dc535399.js";import{l as k}from"./api.c096d0cb.js";import{u as A}from"./use-quasar.ca800b49.js";import{_ as j}from"./plugin-vue_export-helper.21dcd24c.js";const w={class:"relative",style:{height:"205px",width:"100%"}},C=["src"],x={key:1,src:"/assets/placeholder.1a8352b9.png"},D={class:"text-h6"},P={class:"text-subtitle2"},Q={key:0,class:"text-right"};var q=j({__name:"AppCard",props:{app:{type:Object,required:!0},showActions:{type:Boolean,required:!1,default:!1},showPrivateStatus:{type:Boolean,required:!1,default:!1}},emits:["updated","deleted"],setup(j,{emit:q}){const E=q,I={}.API_URL+"/file/",$=A();function z(e,a){k.patch(`t3Apps/${e.id}`,{json:a}).then((()=>{$.loading.hide(),$.notify({message:"App has been updated successfully.",color:"primary",icon:"done"}),E("deleted",e)})).catch((e=>{$.loading.hide(),$.notify({message:"Error: App couldn't be updated! "+e,color:"negative",icon:"error",timeout:0,actions:[{label:"Dismiss",color:"grey-5",handler:()=>{}}]})}))}return(A,q)=>(e(),a(f,{class:"app-card"},{default:t((()=>[(e(),a(i,{key:0,class:"app-card-action-btn hidden absolute right-2.5 top-2.5",id:"app-card-action-btn-"+j.app.id,dense:"",flat:"",size:"md",round:"",color:"primary",icon:"more_vert"},{default:t((()=>[s(h,{"onUpdate:modelValue":q[3]||(q[3]=e=>{return a="app-card-action-btn-"+j.app.id,void document.getElementById(a).classList.toggle("active");var a})},{default:t((()=>[s(_,{style:{"min-width":"70px"}},{default:t((()=>[s(v,{dense:"",to:"/apps-library/"+j.app.id+"/edit"},{default:t((()=>[s(y,{avatar:""},{default:t((()=>[s(l,{name:"edit"})])),_:1}),s(y,null,{default:t((()=>[...q[4]||(q[4]=[o("Edit",-1)])])),_:1})])),_:1},8,["to"]),s(d),p((e(),a(v,{clickable:"",dense:"",onClick:q[0]||(q[0]=e=>{return a=j.app,void $.dialog({title:"Delete Application",message:`Are you sure you want to delete (${a.name}) application?`,ok:{label:"Delete",color:"red-8",flat:!0},cancel:!0,persistent:!0}).onOk((()=>{$.loading.show(),k.delete(`t3Apps/${a.id}`).then((()=>{$.loading.hide(),$.notify({message:"App has been deleted successfully.",color:"primary",icon:"done"}),E("deleted",a)})).catch((e=>{$.loading.hide(),$.notify({message:"Error: App couldn't be deleted! "+e,color:"negative",icon:"error",timeout:0,actions:[{label:"Dismiss",color:"grey-5",handler:()=>{}}]})}))})).onCancel((()=>{})).onDismiss((()=>{}));var a})},{default:t((()=>[s(y,{avatar:""},{default:t((()=>[s(l,{name:"delete"})])),_:1}),s(y,null,{default:t((()=>[...q[5]||(q[5]=[o("Delete",-1)])])),_:1})])),_:1})),[[g]]),s(d),!0===j.app.private?p((e(),a(v,{key:0,clickable:"",dense:"",onClick:q[1]||(q[1]=e=>z(j.app,{private:!1}))},{default:t((()=>[s(y,{avatar:""},{default:t((()=>[s(l,{name:"visibility"})])),_:1}),s(y,null,{default:t((()=>[...q[6]||(q[6]=[o("Make public",-1)])])),_:1})])),_:1})),[[g]]):r("",!0),!1===j.app.private?p((e(),a(v,{key:1,clickable:"",dense:"",onClick:q[2]||(q[2]=e=>z(j.app,{private:!0}))},{default:t((()=>[s(y,{avatar:""},{default:t((()=>[s(l,{name:"visibility_off"})])),_:1}),s(y,null,{default:t((()=>[...q[7]||(q[7]=[o("Make private",-1)])])),_:1})])),_:1})),[[g]]):r("",!0)])),_:1})])),_:1})])),_:1},8,["id"])),n("div",w,[j.app.image?(e(),c("img",{key:0,class:"app-image",src:I+j.app.image.path+"?w=208&h=205"},null,8,C)):(e(),c("img",x))]),s(u,null,{default:t((()=>[n("div",D,m(j.app.name),1),n("div",P,"by "+m(j.app.user.name),1)])),_:1}),s(u,{class:"q-pt-none"},{default:t((()=>[o(m(j.app.description)+" ",1),j.showPrivateStatus?(e(),c("div",Q,[j.app.private?(e(),a(b,{key:0,icon:"visibility_off",size:"md"},{default:t((()=>[...q[8]||(q[8]=[o("Private",-1)])])),_:1})):(e(),a(b,{key:1,icon:"visibility",size:"md"},{default:t((()=>[...q[9]||(q[9]=[o("Public",-1)])])),_:1}))])):r("",!0)])),_:1})])),_:1}))}},[["__scopeId","data-v-1c1b4744"]]);export{q as A};
