import{d as ie,y as le,z as re,a0 as ce,A as de,c as l,a as s,f as _,h as C,i as A,E as a,U as V,g as K,H as W,F as q,P as D,D as r,G as u,T as O,r as g,j as z,J as B,N as ue,I as pe,n as me,b as S,Q as he,x as ve,q as c,t as ge}from"./index-DnbYEqLr.js";import{P as w}from"./api-CHkUAu4g.js";const fe={class:"pb-6"},be={class:"hidden md:flex items-center gap-4 mb-4"},we={class:"mode-switcher flex-shrink-0"},xe=["placeholder","aria-label"],ye={class:"md:hidden mb-4"},ke={class:"mode-switcher mode-switcher-full mb-3"},_e=["placeholder","aria-label"],Ce={key:0,class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 pb-6"},Ae={key:1,class:"text-center py-16 pb-6"},Se={class:"glass-card p-12 max-w-md mx-auto"},Me={class:"text-xl font-semibold text-white mb-2"},ze={class:"text-white/70 mb-6"},Te={key:2,class:"text-center py-12"},$e={class:"text-white/70"},Le={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 pb-6"},Ee=["data-controller-launch","onClick","onKeydown"],Ve=["onClick","aria-label","title"],Be={class:"flex items-start gap-4"},Pe=["src","alt"],Re={class:"flex-1 min-w-0 overflow-hidden"},He=["title"],Ie={class:"text-sm text-white/70 mb-2 truncate"},Ue={class:"flex items-center gap-2"},je={class:"text-xs text-white/50"},Ne={class:"mt-4 flex gap-2"},Fe=["onClick"],Ke=["onClick","disabled"],We={key:0,class:"animate-spin h-4 w-4","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},qe=["onClick","disabled"],De={key:0,class:"animate-spin h-4 w-4","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},Oe={class:"flex items-start gap-4 mb-4"},Qe={class:"flex-1"},Ye={id:"uninstall-dialog-title",class:"text-xl font-semibold text-white mb-2"},Ze={class:"text-white/70"},Ge={class:"flex gap-3 justify-end"},Je=["disabled"],Xe={key:0,class:"animate-spin h-4 w-4","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24"},et={key:0,class:"fixed bottom-20 left-1/2 -translate-x-1/2 z-50 max-w-md w-full px-4",role:"alert","aria-live":"assertive"},tt={class:"bg-red-500/20 border border-red-500/40 backdrop-blur-sm rounded-lg px-4 py-3 text-red-200 text-sm flex items-center justify-between gap-3"},st=["aria-label"],nt=ie({__name:"Apps",setup(at){const{t:i}=le(),Q=ve(),x=re(),m=g("apps"),P=new Set(["archy-mempool-db","archy-btcpay-db","archy-nbxplorer","archy-tor","immich_postgres","immich_redis","penpot-postgres","penpot-valkey","penpot-backend","penpot-exporter","indeedhub-postgres","indeedhub-redis","indeedhub-minio","indeedhub-relay","indeedhub-build_api_1","indeedhub-build_ffmpeg-worker_1","mysql-mempool"]);function Y(t){if(P.has(t))return!0;const e=t.toLowerCase();return e.includes("_db")||e.includes("-db")&&!e.includes("indeedhub")?P.has(t):!1}const h=g(""),d=g({}),y=g("");let T;function $(t){y.value=t,T&&clearTimeout(T),T=setTimeout(()=>{y.value=""},5e3)}const Z={botfights:"https://botfights.net",nwnn:"https://nwnn.l484.com","484-kitchen":"https://484.kitchen","call-the-operator":"https://cta.tx1138.com","syntropy-institute":"https://syntropy.institute","t-zero":"https://teeminuszero.net"};function b(t){return t in Z}const G={botfights:{state:"running",manifest:{id:"botfights",title:"BotFights",version:"1.0.0",description:{short:"AI bot arena — build, train, and battle autonomous agents",long:""},"release-notes":"",license:"","wrapper-repo":"","upstream-repo":"","support-site":"","marketing-site":"","donation-url":null},"static-files":{license:"",instructions:"",icon:"/assets/img/app-icons/botfights.svg"}},nwnn:{state:"running",manifest:{id:"nwnn",title:"Next Web News Network",version:"1.0.0",description:{short:"Decentralized news aggregator, synced from Telegram",long:""},"release-notes":"",license:"","wrapper-repo":"","upstream-repo":"","support-site":"","marketing-site":"","donation-url":null},"static-files":{license:"",instructions:"",icon:"/assets/img/app-icons/nwnn.png"}},"484-kitchen":{state:"running",manifest:{id:"484-kitchen",title:"484 Kitchen",version:"1.0.0",description:{short:"K484 application platform",long:""},"release-notes":"",license:"","wrapper-repo":"","upstream-repo":"","support-site":"","marketing-site":"","donation-url":null},"static-files":{license:"",instructions:"",icon:"/assets/img/app-icons/484-kitchen.png"}},"call-the-operator":{state:"running",manifest:{id:"call-the-operator",title:"Call the Operator",version:"1.0.0",description:{short:"Escape the Matrix — explore decentralized alternatives",long:""},"release-notes":"",license:"","wrapper-repo":"","upstream-repo":"","support-site":"","marketing-site":"","donation-url":null},"static-files":{license:"",instructions:"",icon:"/assets/img/app-icons/call-the-operator.png"}},"syntropy-institute":{state:"running",manifest:{id:"syntropy-institute",title:"Syntropy Institute",version:"1.0.0",description:{short:"Medicine Reimagined — frequency analysis-therapy",long:""},"release-notes":"",license:"","wrapper-repo":"","upstream-repo":"","support-site":"","marketing-site":"","donation-url":null},"static-files":{license:"",instructions:"",icon:"/assets/img/app-icons/syntropy-institute.png"}},"t-zero":{state:"running",manifest:{id:"t-zero",title:"T-0",version:"1.0.0",description:{short:"Documentary series on decentralization and Bitcoin",long:""},"release-notes":"",license:"","wrapper-repo":"","upstream-repo":"","support-site":"","marketing-site":"","donation-url":null},"static-files":{license:"",instructions:"",icon:"/assets/img/app-icons/t-zero.png"}}},J=z(()=>{const t=x.packages||{};return{...G,...t}}),M=z(()=>Object.entries(J.value).filter(([n])=>{const o=Y(n);return m.value==="services"?o:!o}).sort(([n,o],[E,f])=>{const N=b(n)?0:1,F=b(E)?0:1;return N!==F?N-F:(o.manifest?.title??"").localeCompare(f.manifest?.title??"",void 0,{sensitivity:"base"})})),R=z(()=>{if(!h.value)return M.value;const t=h.value.toLowerCase();return M.value.filter(([e,n])=>(n.manifest?.title??"").toLowerCase().includes(t)||(n.manifest?.description?.short??"").toLowerCase().includes(t)||e.toLowerCase().includes(t))}),v=g({show:!1,appId:"",appTitle:""}),H=g(null),I=g(null);function L(){I.value?.focus?.(),v.value.show=!1}ce(H,z(()=>v.value.show),L,{restoreFocusRef:I});function U(t){if(b(t.manifest.id))return!0;const e=t.manifest.interfaces?.main?.ui||t.installed?.["interface-addresses"]?.main,n=t.state==="running"||t.state==="starting";return!!e&&n}function X(t){he().openSession(t)}function ee(t){switch(t){case w.Running:return"bg-green-500/20 text-green-200";case w.Stopped:return"bg-gray-500/20 text-gray-200";case w.Starting:case w.Stopping:case w.Restarting:return"bg-yellow-500/20 text-yellow-200";case w.Installing:return"bg-blue-500/20 text-blue-200";default:return"bg-gray-500/20 text-gray-200"}}function j(t){Q.push(`/dashboard/apps/${t}`).catch(()=>{})}const p=new Map;async function te(t){d.value[t]=!0;try{await x.startPackage(t),p.has(t)&&clearTimeout(p.get(t)),p.set(t,setTimeout(()=>{d.value[t]=!1,p.delete(t)},5e3))}catch(e){$(`Failed to start app: ${e instanceof Error?e.message:"Unknown error"}`),d.value[t]=!1}}async function se(t){d.value[t]=!0;try{await x.stopPackage(t),p.has(t)&&clearTimeout(p.get(t)),p.set(t,setTimeout(()=>{d.value[t]=!1,p.delete(t)},5e3))}catch(e){$(`Failed to stop app: ${e instanceof Error?e.message:"Unknown error"}`),d.value[t]=!1}}de(()=>{for(const t of p.values())clearTimeout(t);p.clear()});function ne(t,e){v.value={show:!0,appId:t,appTitle:e.manifest.title}}const k=g(!1);async function ae(){const{appId:t}=v.value;k.value=!0;try{await x.uninstallPackage(t),v.value.show=!1}catch(e){$(`Failed to uninstall app: ${e instanceof Error?e.message:"Unknown error"}`),v.value.show=!1}finally{k.value=!1}}function oe(t){const e=t.target,n=e.src,o=`data:image/svg+xml,${encodeURIComponent(` `)}`;n.includes("data:image")||(e.src=o)}return(t,e)=>(c(),l("div",fe,[s("div",be,[s("div",we,[s("button",{class:_(["mode-switcher-btn",{"mode-switcher-btn-active":m.value==="apps"}]),onClick:e[0]||(e[0]=n=>m.value="apps")},"My Apps",2),C(a(V),{to:"/dashboard/marketplace",class:"mode-switcher-btn"},{default:A(()=>[...e[10]||(e[10]=[B("App Store",-1)])]),_:1}),s("button",{class:_(["mode-switcher-btn",{"mode-switcher-btn-active":m.value==="services"}]),onClick:e[1]||(e[1]=n=>m.value="services")},"Services",2)]),K(s("input",{"onUpdate:modelValue":e[2]||(e[2]=n=>h.value=n),type:"text",placeholder:a(i)("apps.searchPlaceholder"),"aria-label":a(i)("apps.searchLabel"),class:"flex-1 px-4 py-2 bg-white/10 border border-white/20 rounded-lg text-white placeholder-white/50 focus:outline-none focus:border-white/40 transition-colors"},null,8,xe),[[W,h.value]])]),s("div",ye,[s("div",ke,[s("button",{class:_(["mode-switcher-btn",{"mode-switcher-btn-active":m.value==="apps"}]),onClick:e[3]||(e[3]=n=>m.value="apps")},"My Apps",2),C(a(V),{to:"/dashboard/marketplace",class:"mode-switcher-btn"},{default:A(()=>[...e[11]||(e[11]=[B("App Store",-1)])]),_:1}),s("button",{class:_(["mode-switcher-btn",{"mode-switcher-btn-active":m.value==="services"}]),onClick:e[4]||(e[4]=n=>m.value="services")},"Services",2)]),K(s("input",{"onUpdate:modelValue":e[5]||(e[5]=n=>h.value=n),type:"text",placeholder:a(i)("apps.searchPlaceholder"),"aria-label":a(i)("apps.searchLabel"),class:"w-full px-4 py-3 bg-white/10 border border-white/20 rounded-lg text-white placeholder-white/50 focus:outline-none focus:border-white/40 transition-colors"},null,8,_e),[[W,h.value]])]),!a(x).isConnected&&M.value.length===0?(c(),l("div",Ce,[(c(),l(q,null,D(3,n=>s("div",{key:n,class:"glass-card p-6 animate-pulse"},[...e[12]||(e[12]=[ue('