import{an as e,dn as t,it as n}from"./design-system-components-BwTjgxr6.mjs";import{d as r,i,l as a,n as o}from"./zod-CNzXUhj9.mjs";var s=a({name:r(),url:r()}),c=a({repositories:i(s)}),l=a({version:r(),minOpenCloud:r().optional(),url:r(),filename:r().optional()}),u=a({label:r(),color:o([`primary`,`success`,`danger`]).optional().default(`primary`)}),d=a({name:r(),email:r().optional(),url:r().optional()}),f=a({url:r(),caption:r().optional()}),p=a({url:r(),label:r(),icon:r().optional()}),m=a({id:r(),name:r(),subtitle:r(),badge:u.optional(),description:r().optional(),license:r(),versions:i(l),authors:i(d),tags:i(r()),coverImage:f.optional(),screenshots:i(f).optional().default([]),resources:i(p).optional().default([])});m.extend({repository:s,mostRecentVersion:l});var h=a({apps:i(m)}),g=`app-store`,_=n(`${g}-repositories`,()=>{let t=e([]);return{repositories:t,setRepositories:e=>{t.value=e}}}),v=()=>{let r=_();return n(`${g}-apps`,()=>{let n=e([]);return{apps:n,getById:e=>t(n).find(t=>t.id===e),loadApps:async()=>{let e=async e=>{try{let t=await(await fetch(e.url)).json();return h.parse(t).apps.map(t=>({...t,repository:e,mostRecentVersion:t.versions[0]})).sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase()))}catch(e){return console.error(e),[]}},t=[];for(let n of r.repositories)t.push(e(n));n.value=(await Promise.all(t)).flat()}}})()};export{c as i,_ as n,g as r,v as t};