8 lines
16 KiB
JavaScript
8 lines
16 KiB
JavaScript
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(`
|
||
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<rect width="64" height="64" rx="12" fill="rgba(255,255,255,0.1)"/>
|
||
<path d="M32 20L40 28H36V40H28V28H24L32 20Z" fill="rgba(255,255,255,0.6)"/>
|
||
<path d="M20 44H44V48H20V44Z" fill="rgba(255,255,255,0.4)"/>
|
||
</svg>
|
||
`)}`;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('<div class="flex items-start gap-4" data-v-5129aeb7><div class="w-16 h-16 rounded-lg bg-white/10" data-v-5129aeb7></div><div class="flex-1" data-v-5129aeb7><div class="h-5 w-32 bg-white/10 rounded mb-2" data-v-5129aeb7></div><div class="h-4 w-48 bg-white/5 rounded mb-3" data-v-5129aeb7></div><div class="h-6 w-20 bg-white/5 rounded" data-v-5129aeb7></div></div></div><div class="mt-4 flex gap-2" data-v-5129aeb7><div class="flex-1 h-9 bg-white/5 rounded-lg" data-v-5129aeb7></div></div>',2)])])),64))])):M.value.length===0&&!h.value?(c(),l("div",Ae,[s("div",Se,[e[13]||(e[13]=s("svg",{class:"w-16 h-16 mx-auto text-white/40 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})],-1)),s("h3",Me,r(a(i)("apps.noAppsTitle")),1),s("p",ze,r(a(i)("apps.noAppsMessage")),1),C(a(V),{to:"/dashboard/marketplace",class:"inline-block glass-button px-6 py-3 rounded-lg font-medium transition-all hover:bg-black/70 hover:border-white/30"},{default:A(()=>[B(r(a(i)("apps.browseAppStore")),1)]),_:1})])])):u("",!0),R.value.length===0&&h.value?(c(),l("div",Te,[s("p",$e,r(a(i)("apps.noResults",{query:h.value})),1)])):u("",!0),s("div",Le,[(c(!0),l(q,null,D(R.value,([n,o],E)=>(c(),l("div",{key:n,"data-controller-container":"","data-controller-launch":U(o)?"":void 0,tabindex:"0",role:"link",class:"glass-card card-stagger p-6 transition-all hover:-translate-y-1 cursor-pointer relative min-w-0 overflow-hidden",style:me({"--stagger-index":E}),onClick:f=>j(n),onKeydown:pe(f=>j(n),["enter"])},[b(n)?u("",!0):(c(),l("button",{key:0,onClick:S(f=>ne(n,o),["stop"]),class:"absolute top-4 right-4 p-2 rounded-lg text-white/60 hover:text-red-400 hover:bg-red-500/20 transition-colors z-10","aria-label":`${a(i)("common.uninstall")} ${o.manifest?.title||n}`,title:a(i)("common.uninstall")},[...e[14]||(e[14]=[s("svg",{class:"w-5 h-5","aria-hidden":"true",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,Ve)),s("div",Be,[s("img",{src:o["static-files"]?.icon||`/assets/img/app-icons/${n}.png`,alt:o.manifest?.title||String(n),class:"w-16 h-16 rounded-lg object-cover bg-white/10",onError:oe},null,40,Pe),s("div",Re,[s("h3",{class:"text-lg font-semibold text-white mb-1 truncate",title:o.manifest.title},r(o.manifest.title),9,He),s("p",Ie,r(o.manifest?.description?.short||""),1),s("div",Ue,[s("span",{class:_(["inline-flex items-center px-2 py-1 rounded text-xs font-medium",ee(o.state)])},r(o.state),3),s("span",je," v"+r(o.manifest.version),1)])])]),s("div",Ne,[U(o)?(c(),l("button",{key:0,"data-controller-launch-btn":"",onClick:S(f=>X(n),["stop"]),class:"flex-1 px-4 py-2 glass-button glass-button-sm rounded-lg text-sm font-medium"},r(a(i)("common.launch")),9,Fe)):u("",!0),!b(n)&&(o.state==="stopped"||o.state==="exited")?(c(),l("button",{key:1,onClick:S(f=>te(n),["stop"]),disabled:d.value[n],class:"flex-1 px-4 py-2 bg-green-500/20 border border-green-500/40 rounded-lg text-green-200 text-sm font-medium hover:bg-green-500/30 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[d.value[n]?(c(),l("svg",We,[...e[15]||(e[15]=[s("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),s("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):u("",!0),s("span",null,r(d.value[n]?a(i)("common.starting"):a(i)("common.start")),1)],8,Ke)):u("",!0),!b(n)&&(o.state==="running"||o.state==="starting")?(c(),l("button",{key:2,onClick:S(f=>se(n),["stop"]),disabled:d.value[n],class:"flex-1 px-4 py-2 bg-yellow-500/20 border border-yellow-500/40 rounded-lg text-yellow-200 text-sm font-medium hover:bg-yellow-500/30 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[d.value[n]?(c(),l("svg",De,[...e[16]||(e[16]=[s("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),s("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):u("",!0),s("span",null,r(d.value[n]?a(i)("common.stopping"):a(i)("common.stop")),1)],8,qe)):u("",!0)])],44,Ee))),128))]),C(O,{name:"modal"},{default:A(()=>[v.value.show?(c(),l("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:e[8]||(e[8]=n=>L())},[e[19]||(e[19]=s("div",{class:"absolute inset-0 bg-black/60 backdrop-blur-md"},null,-1)),s("div",{ref_key:"uninstallModalRef",ref:H,onClick:e[7]||(e[7]=S(()=>{},["stop"])),role:"dialog","aria-modal":"true","aria-labelledby":"uninstall-dialog-title",class:"glass-card p-6 max-w-2xl w-full relative z-10"},[s("div",Oe,[e[17]||(e[17]=s("div",{class:"p-3 bg-red-500/20 rounded-lg"},[s("svg",{class:"w-6 h-6 text-red-400","aria-hidden":"true",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})])],-1)),s("div",Qe,[s("h3",Ye,r(a(i)("apps.uninstallTitle")),1),s("p",Ze,r(a(i)("apps.uninstallConfirm",{name:v.value.appTitle})),1)])]),s("div",Ge,[s("button",{onClick:e[6]||(e[6]=n=>L()),class:"px-4 py-2 glass-button rounded-lg text-sm font-medium"},r(a(i)("common.cancel")),1),s("button",{onClick:ae,disabled:k.value,class:"px-4 py-2 bg-red-600/80 hover:bg-red-600 rounded-lg text-white text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[k.value?(c(),l("svg",Xe,[...e[18]||(e[18]=[s("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),s("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)])])):u("",!0),s("span",null,r(k.value?a(i)("common.uninstalling"):a(i)("common.uninstall")),1)],8,Je)])],512)])):u("",!0)]),_:1}),C(O,{name:"fade"},{default:A(()=>[y.value?(c(),l("div",et,[s("div",tt,[s("span",null,r(y.value),1),s("button",{onClick:e[9]||(e[9]=n=>y.value=""),"aria-label":a(i)("apps.dismissError"),class:"text-red-300 hover:text-white shrink-0"},"×",8,st)])])):u("",!0)]),_:1})]))}}),lt=ge(nt,[["__scopeId","data-v-5129aeb7"]]);export{lt as default};
|