1import{d as b,u as v,D as h,o as w,c as s,e as t,f as x,g as m,h as n,t as f,F as k,r as C,x as u,_ as N,b as a,i as _,j as V}from"./aDqk-s0q.js";const E={class:"space-y-6"},S={class:"flex items-end justify-between flex-wrap gap-3"},z={key:0,class:"rounded-xl border border-outline-variant/20 bg-surface-container-lowest p-6 text-sm text-on-surface-variant"},A={key:1,class:"text-xs text-outline px-1"},B={key:2,class:"rounded-xl border border-error/30 bg-error/5 p-4 text-sm text-error"},D={key:3,class:"rounded-xl border border-outline-variant/20 bg-surface-container-lowest p-6 text-sm text-on-surface-variant"},L={key:4,class:"space-y-2"},M={class:"flex-1 min-w-0"},j={class:"flex items-center gap-2"},F={class:"font-bold leading-snug truncate"},$={key:0,class:"text-[10px] font-extrabold uppercase tracking-widest text-outline bg-surface-container px-2 py-0.5 rounded-full"},q={class:"text-xs text-on-surface-variant mt-0.5"},H={class:"text-primary"},Y=b({__name:"manage",setup(O){v({title:"Manage courses · xquare hub"});const g=h(),i=u([]),l=u(!0),d=u(null),c=u(!1);async function y(){l.value=!0,d.value=null;try{const{data:o,error:e}=await g.schema("community").rpc("my_managed_courses");if(e)throw new Error(e.message);i.value=o??[]}catch(o){d.value=o?.message??"failed to load courses",i.value=[]}finally{l.value=!1}}return w(async()=>{const{data:o}=await g.auth.getSession();if(c.value=!!o.session,!c.value){l.value=!1;return}await y()}),(o,e)=>{const p=N;return a(),s("section",E,[t("header",S,[e[1]||(e[1]=t("div",null,[t("h1",{class:"font-bold leading-tight",style:{"font-size":"1.875rem"}},"Manage Courses"),t("p",{class:"text-sm text-on-surface-variant"},"Courses you own or admin via your spaces.")],-1)),x(p,{to:"/courses/create",class:"inline-flex items-center gap-1.5 px-3 py-2 rounded-xl text-sm font-bold bg-primary text-on-primary hover:brightness-110 transition-colors"},{default:m(()=>[...e[0]||(e[0]=[t("span",{class:"material-symbols-outlined",style:{"font-size":"1.1rem"},"aria-hidden":"true"},"add",-1),_(" Add new course ",-1)])]),_:1})]),n(c)?n(l)?(a(),s("div",A,"Loadingâ¦")):n(d)?(a(),s("div",B,f(n(d)),1)):n(i).length?(a(),s("ul",L,[(a(!0),s(k,null,C(n(i),r=>(a(),s("li",{key:r.id,class:"flex items-center gap-4 p-4 bg-surface-container-lowest rounded-xl border border-outline-variant/20 hover:border-primary/30 transition-colors"},[t("div",M,[t("div",j,[t("p",F,f(r.title),1),r.is_published?V("",!0):(a(),s("span",$," Draft "))]),t("p",q,[t("span",H,f(r.space_name),1)])]),x(p,{to:`/courses/${r.slug}`,class:"text-xs font-semibold text-on-surface-variant hover:text-primary px-3 py-1.5 rounded-lg hover:bg-surface-container transition-colors"},{default:m(()=>[...e[2]||(e[2]=[_(" View ",-1)])]),_:1},8,["to"]),x(p,{to:`/courses/${r.slug}/edit`,class:"inline-flex items-center gap-1 text-xs font-bold text-primary px-3 py-1.5 rounded-lg bg-primary/10 hover:bg-primary/15 transition-colors"},{default:m(()=>[...e[3]||(e[3]=[t("span",{class:"material-symbols-outlined",style:{"font-size":"0.9rem"},"aria-hidden":"true"},"edit",-1),_(" Edit ",-1)])]),_:1},8,["to"])]))),128))])):(a(),s("div",D,` You don't own any courses yet. Click "Add new course" to create one. `)):(a(),s("div",z," Sign in to manage courses. "))])}}});export{Y as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.