1import{u as H,r as p,b as E,a as G,j as e,g as U,n as Y,I as k,f as V,N as B,P as $,o as z,m,X as W,k as X,ab as J}from"./index-u0HMC9Vb.js";import{S as L,a as A,b as R,c as K,d as _}from"./select-Eu3KdeOX.js";import"./index-DcEnTV8H.js";import"./index-BegspP2X.js";const Q=["AiHouse","Canva","Other"],Z=["Getting Started","Navigation","Modelling","Materials","Lighting","Rendering","Exporting"];function ee({initial:c,courses:g,modules:j,milestones:f,onSave:I,onCancel:u,saving:F}){var x;const[r,C]=p.useState({title:"",summary:"",video_url:"",thumbnail_url:"",software:"AiHouse",function_group:"Getting Started",tags:"",course_relevance:[],module_id:"",milestone_id:"",...c,tags:((x=c==null?void 0:c.tags)==null?void 0:x.join(", "))||""}),[v,b]=p.useState(!1),[S,O]=p.useState(""),l=(s,i)=>C(N=>({...N,[s]:i})),t=async()=>{if(r.video_url){b(!0),O("");try{const i=(await m.functions.invoke("fetchYouTubeInfo",{url:r.video_url})).data;i.title&&l("title",i.title),i.cover_image_url&&l("thumbnail_url",i.cover_image_url)}catch{O("Could not fetch video info. Check the URL.")}finally{b(!1)}}},n=()=>{I({...r,tags:r.tags?r.tags.split(",").map(s=>s.trim()).filter(Boolean):[]})};return e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-card border border-border w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[e.jsx("h2",{className:"text-sm font-display uppercase tracking-widest",children:c!=null&&c.id?"Edit Tutorial":"New Tutorial"}),e.jsx("button",{onClick:u,children:e.jsx(W,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{children:"Title"}),e.jsx(k,{value:r.title,onChange:s=>l("title",s.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{children:"Summary"}),e.jsx(k,{value:r.summary,onChange:s=>l("summary",s.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{children:"Video URL"}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(k,{value:r.video_url,onChange:s=>l("video_url",s.target.value),placeholder:"https://youtube.com/watch?v=...",className:"flex-1"}),e.jsxs(U,{type:"button",variant:"outline",onClick:t,disabled:v||!r.video_url,className:"flex items-center gap-1.5 shrink-0",children:[v?e.jsx(X,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5"}),"Fetch"]})]}),S&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:S})]}),e.jsxs("div",{children:[e.jsx("label",{children:"Thumbnail URL"}),e.jsx(k,{value:r.thumbnail_url,onChange:s=>l("thumbnail_url",s.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{children:"Software"}),e.jsxs(L,{value:r.software,onValueChange:s=>l("software",s),children:[e.jsx(A,{className:"mt-1",children:e.jsx(R,{})}),e.jsx(K,{children:Q.map(s=>e.jsx(_,{value:s,children:s},s))})]})]}),e.jsxs("div",{children:[e.jsx("label",{children:"Function Group"}),e.jsxs(L,{value:r.function_group,onValueChange:s=>l("function_group",s),children:[e.jsx(A,{className:"mt-1",children:e.jsx(R,{})}),e.jsx(K,{children:Z.map(s=>e.jsx(_,{value:s,children:s},s))})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{children:"Module"}),e.jsxs(L,{value:r.module_id||"",onValueChange:s=>l("module_id",s),children:[e.jsx(A,{className:"mt-1",children:e.jsx(R,{placeholder:"None"})}),e.jsxs(K,{children:[e.jsx(_,{value:null,children:"None"}),j.map(s=>e.jsx(_,{value:s.id,children:s.title},s.id))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{children:"Deliverable (Milestone)"}),e.jsxs(L,{value:r.milestone_id||"",onValueChange:s=>l("milestone_id",s),children:[e.jsx(A,{className:"mt-1",children:e.jsx(R,{placeholder:"None"})}),e.jsxs(K,{children:[e.jsx(_,{value:null,children:"None"}),f.map(s=>e.jsx(_,{value:s.id,children:s.title},s.id))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{children:"Tags (comma-separated)"}),e.jsx(k,{value:r.tags,onChange:s=>l("tags",s.target.value),placeholder:"e.g. lighting, render, beginner",className:"mt-1"})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-border flex gap-2 justify-end",children:[e.jsx(U,{variant:"outline",onClick:u,children:"Cancel"}),e.jsx(U,{onClick:n,disabled:F||!r.title||!r.video_url,children:F?"Savingâ¦":"Save"})]})]})})}function le(){const c=H(),[g,j]=p.useState(null),[f,I]=p.useState("all"),[u,F]=p.useState(""),{data:r=[]}=E({queryKey:["tutorials"],queryFn:()=>m.entities.Tutorial.list()}),{data:C=[]}=E({queryKey:["courses"],queryFn:()=>m.entities.Course.list()}),{data:v=[]}=E({queryKey:["modules"],queryFn:()=>m.entities.Module.list()}),{data:b=[]}=E({queryKey:["milestones"],queryFn:()=>m.entities.Milestone.list()}),S=G({mutationFn:t=>
1t.id?m.entities.Tutorial.update(t.id,t):m.entities.Tutorial.create(t),onSuccess:()=>{c.invalidateQueries({queryKey:["tutorials"]}),j(null)}}),O=G({mutationFn:t=>m.entities.Tutorial.delete(t),onSuccess:()=>c.invalidateQueries({queryKey:["tutorials"]})}),l=p.useMemo(()=>{var x,s,i,N,y,q,o;let t=r;f!=="all"&&(t=t.filter(a=>a.software===f)),u&&(t=t.filter(a=>{var d;return a.title.toLowerCase().includes(u.toLowerCase())||((d=a.tags)==null?void 0:d.some(P=>P.toLowerCase().includes(u.toLowerCase())))}));const n={};for(const a of t){const d=a.software||"Other",P=(x=a.course_relevance)!=null&&x.length?a.course_relevance:["â"],T=a.module_id?((s=v.find(h=>h.id===a.module_id))==null?void 0:s.title)||"Unknown Module":"â",M=a.milestone_id?((i=b.find(h=>h.id===a.milestone_id))==null?void 0:i.title)||"Unknown Deliverable":"â";for(const h of P){const w=h!=="â"?((N=C.find(D=>D.code===h))==null?void 0:N.title)||`Course ${h}`:"â";n[d]??(n[d]={}),(y=n[d])[w]??(y[w]={}),(q=n[d][w])[T]??(q[T]={}),(o=n[d][w][T])[M]??(o[M]=[]),n[d][w][T][M].push(a)}}return n},[r,f,u,v,b,C]);return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsxs("div",{className:"max-w-5xl mx-auto px-6 lg:px-10 pt-12 pb-16",children:[e.jsxs("div",{className:"flex items-end justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-meta uppercase tracking-[0.4em] text-muted-foreground mb-2",children:"Admin"}),e.jsx("h1",{className:"text-3xl font-display font-normal text-foreground tracking-tight",children:"Tech Library"})]}),e.jsxs(U,{onClick:()=>j({}),className:"flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"})," New Tutorial"]})]}),e.jsxs("div",{className:"bg-stone-50 border border-stone-200 px-5 py-4 mb-8",children:[e.jsx("p",{className:"text-[10px] font-meta uppercase tracking-[0.2em] text-stone-500 mb-1",children:"A note on software"}),e.jsx("p",{className:"text-sm text-stone-600 leading-relaxed",children:"AiHouse is our native technical software and the primary tool referenced in this library. That said, you are welcome â and encouraged â to use whichever software best serves your design process and spatial intent. The principles taught here apply across tools."})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx(k,{placeholder:"Search tutorials or tagsâ¦",value:u,onChange:t=>F(t.target.value),className:"max-w-xs"}),e.jsx("div",{className:"flex items-center gap-1 border border-border",children:["all",...Q].map(t=>e.jsx("button",{onClick:()=>I(t),className:`text-[9px] font-meta uppercase tracking-widest px-3 py-2 transition-colors ${f===t?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,children:t==="all"?"All":t},t))})]}),e.jsxs("div",{className:"space-y-8",children:[Object.entries(l).map(([t,n])=>e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-meta uppercase tracking-[0.3em] text-foreground bg-foreground
1/5 border border-border px-3 py-2 mb-3",children:t}),e.jsx("div",{className:"space-y-5 pl-4",children:Object.entries(n).map(([x,s])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(V,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("p",{className:"text-[10px] font-meta uppercase tracking-widest text-muted-foreground",children:x})]}),e.jsx("div",{className:"space-y-3 pl-5",children:Object.entries(s).map(([i,N])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(V,{className:"w-3 h-3 text-muted-foreground/50"}),e.jsx("p",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground/70",children:i})]}),e.jsx("div",{className:"space-y-2 pl-5",children:Object.entries(N).map(([y,q])=>e.jsxs("div",{children:[y!=="â"&&e.jsxs("p",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground/50 mb-1 pl-1 flex items-center gap-1",children:[e.jsx(V,{className:"w-3 h-3"})," ",y]}),e.jsx("div",{className:"space-y-1 pl-2",children:q.map(o=>{var a;return e.jsxs("div",{className:"flex items-center justify-between bg-card border border-border px-4 py-3 hover:border-foreground
1/20 transition-colors group",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-foreground truncate",children:o.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-[9px] font-meta text-muted-foreground uppercase tracking-widest",children:o.function_group}),((a=o.tags)==null?void 0:a.length)>0&&e.jsxs("span",{className:"text-[9px] text-muted-foreground/60",children:["· ",o.tags.join(", ")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-3",children:[o.video_url&&e.jsx("a",{href:o.video_url,target:"_blank",rel:"noreferrer",className:"p-2 text-muted-foreground hover:text-foreground",children:e.jsx(B,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>j(o),className:"p-2 text-muted-foreground hover:text-foreground",children:e.jsx($,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>{confirm("Delete this tutorial?")&&O.mutate(o.id)},className:"p-2 text-muted-foreground hover:text-red-500",children:e.jsx(z,{className:"w-3.5 h-3.5"})})]})]},o.id)})})]},y))})]},i))})]},x))})]},t)),Object.keys(l).length===0&&e.jsx("div",{className:"border border-dashed border-border p-16 text-center",children:e.jsx("p",{className:"text-[10px] font-meta uppercase tracking-widest text-muted-foreground",children:"No tutorials found"})})]})]}),g!==null&&e.jsx(ee,{initial:g!=null&&g.id?g:{},courses:C,modules:v,milestones:b,onSave:t=>S.mutate(t),onCancel:()=>j(null),saving:S.isPending})]})}export{le 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.