import{I as y}from"./iconify-p99pbjf9.js";import{d as N,aa as j,ah as B,t as e,h as u,an as f,a as g,o as F,A as T,J as r,B as l,C as o,j as n,ax as v,_ as x,P as m,as as U,r as c,g as S,aJ as V}from"./index-DOFLUERq.js";import{_ as D}from"./_plugin-vue_export-helper-DlAUqK2U.js";const E={class:"installed-apps-page"},M={class:"page-header"},P={class:"header-content"},$={class:"page-title"},z={class:"page-description"},J={class:"apps-section"},G=N({__name:"InstalledApps",setup(L){const _=c([]),i=c(!1),h=c(!1),p=c(null),t=j(),A=B(),k=[{title:e("App Name"),key:"name",width:200},{title:e("Version"),key:"version",width:100,render:a=>a.version||"1.0.0"},{title:e("Git Branch"),key:"git_branch",width:120,render:a=>a.git_branch||"main"},{title:e("Actions"),key:"actions",width:280,render:a=>u("div",{class:"action-buttons"},[u(f,{size:"small",type:"default",loading:p.value===a.name,disabled:a.name==="jingrow",onClick:()=>w(a)},{default:()=>e("Export Package")}),u(f,{size:"small",type:"error",style:"margin-left: 8px;",disabled:!a.uninstallable,onClick:()=>C(a)},{default:()=>a.uninstallable?e("Uninstall"):e("System App")})])}],d=async()=>{try{i.value=!0;const a=await g.get("/jingrow/installed-apps");a.data.success?_.value=a.data.data.apps||[]:t.error(a.data.error||e("Failed to load apps"))}catch(a){console.error("Load apps error:",a),t.error(a.response?.data?.error||e("Failed to load apps"))}finally{i.value=!1}},b=()=>{d()},w=async a=>{if(a.name==="jingrow"){t.warning(e("System App")+" "+e("cannot be exported"));return}try{p.value=a.name;const s=await g.post(`/jingrow/export-app-package/${a.name}`,{});if(s.data.success){if(t.success(e("App package exported successfully: {0}").replace("{0}",s.data.filename||a.name)),s.data.filename){const I=`/files/${s.data.filename}`;window.open(I,"_blank")}}else t.error(s.data.error||e("Failed to export app package"))}catch(s){console.error("Export app error:",s),t.error(s.response?.data?.error||e("Failed to export app package"))}finally{p.value=null}},C=async a=>{if(!a.uninstallable){t.warning(e("System App")+" "+e("cannot be uninstalled"));return}A.warning({title:e("Uninstall App"),content:e("Are you sure you want to uninstall '{0}'? This action cannot be undone.").replace("{0}",a.name),positiveText:e("Uninstall"),negativeText:e("Cancel"),onPositiveClick:async()=>{try{h.value=!0;const s=await g.post(`/jingrow/uninstall/${a.name}`,{});s.data.success?(t.success(e("App '{0}' uninstalled successfully").replace("{0}",a.name)),await d()):t.error(s.data.error||e("Failed to uninstall app"))}catch(s){console.error("Uninstall app error:",s),t.error(s.response?.data?.error||e("Failed to uninstall app"))}finally{h.value=!1}}})};return F(()=>{d()}),(a,s)=>(S(),T("div",E,[r("div",M,[r("div",P,[r("h1",$,[l(n(v),null,{default:o(()=>[l(n(y),{icon:"tabler:apps"})]),_:1}),x(" "+m(n(e)("Installed Apps")),1)]),r("p",z,m(n(e)("Manage your locally installed applications")),1)])]),r("div",J,[l(n(U),{class:"apps-card"},{"header-extra":o(()=>[l(n(f),{onClick:b,loading:i.value},{icon:o(()=>[l(n(v),null,{default:o(()=>[l(n(y),{icon:"tabler:refresh"})]),_:1})]),default:o(()=>[x(" "+m(n(e)("Refresh")),1)]),_:1},8,["loading"])]),default:o(()=>[l(n(V),{columns:k,data:_.value,loading:i.value,pagination:!1},null,8,["data","loading"])]),_:1})])]))}}),K=D(G,[["__scopeId","data-v-ff60a689"]]);export{K as default};
