1import{u as G,x as W,w as X,d as Z,f as a,g as e,k as ee,l as te,a as p,z as C,q as i,v as d,J as k,K as R,h as S,F as v,B as f,c as se,L as le,r as y,o,s as oe,m as A,b as x}from"./AhgHPOeE.js";import{_ as ne}from"./DVDqALhZ.js";import{u as ae}from"./CF3-kHH4.js";import"./DAi_NRsz.js";import"./DxRdcB98.js";const ie={class:"w-full mx-auto md:max-w-screen-lg px-3 pb-8"},de={class:"mt-3 mb-4"},re={key:0,class:"lg:flex lg:gap-4"},ue={class:"lg:flex-1 lg:min-w-0"},pe={class:"mb-4 p-4 rounded-lg border border-gray-200 bg-white"},me={class:"text-sm font-semibold text-gray-700 mb-3 uppercase tracking-wide"},xe={class:"flex flex-col gap-2"},ce={class:"flex gap-4"},ye={class:"flex-1"},_e={class:"w-32"},ge={class:"flex items-center gap-4"},ve=["disabled"],fe={class:"flex items-center gap-2 text-sm text-gray-700"},be={class:"mb-4"},he={class:"flex items-center justify-between mb-3"},we={class:"text-sm font-semibold text-gray-700 uppercase tracking-wide"},Ve={class:"text-gray-400 font-normal"},Ue=["onClick"],Ce={class:"h-8 flex items-center mb-2"},ke={class:"w-1/3 text-center text-lg font-medium text-gray-600"},Te={class:"w-1/3 flex justify-end items-center gap-1"},$e=["onClick"],Be=["onClick"],Se=["onClick"],Ae=["onClick"],Le={key:0},Ne=["onUpdate:modelValue"],qe={key:1},Pe=["onUpdate:modelValue"],ze=["onUpdate:modelValue"],De={key:2},Me=["onUpdate:modelValue"],Re=["onUpdate:modelValue"],Fe=["onUpdate:modelValue"],Ie={class:"flex items-center gap-2 text-xs text-gray-500 cursor-pointer select-none"},Je=["onUpdate:modelValue"],Oe={key:3},He=["onUpdate:modelValue"],Qe=["onUpdate:modelValue"],je={key:4},Ee=["onUpdate:modelValue"],Ye=["onUpdate:modelValue"],Ke=["onUpdate:modelValue"],Ge=["onClick"],We=["onClick"],Xe={key:5},Ze=["onUpdate:modelValue"],et=["onUpdate:modelValue"],tt=["onUpdate:modelValue"],st=["onClick"],lt=["onClick"],ot={key:6},nt=["onUpdate:modelValue"],at=["onUpdate:modelValue"],it=["onClick"],dt=["onClick"],rt={key:7},ut=["onUpdate:modelValue"],pt=["onUpdate:modelValue"],mt=["onClick"],xt=["onClick"],ct={class:"flex flex-wrap gap-2 mt-3"},yt=["onClick"],_t={class:"hidden lg:block lg:w-[400px] lg:shrink-0"},gt={class:"sticky top-4"},vt={class:"border border-gray-200 rounded-lg bg-white p-4 overflow-y-auto max-h-[80vh]"},ft={key:1,class:"text-sm text-gray-400 italic text-center"},bt={key:1,class:"text-center text-gray-500 mt-12"},Tt={__name:"[lessonId]",async setup(ht){let T,q;const $=G(),{$api:F,$toast:P}=W(),z=$.params.id,D=$.params.lessonId,{data:L,refresh:I}=([T,q]=X(()=>ae(()=>`/courses/${z}/lessons/${D}`,{watch:[()=>$.params.lessonId]})),T=await T,q(),T),b=y(""),h=y(""),w=y(""),V=y(null),U=y(!1),B=y(!1),_=y(null),r=y([]),J=[{type:"title",label:"Title"},{type:"text",label:"Text"},{type:"image",label:"Image"},{type:"youtube-video",label:"YouTube"},{type:"faq",label:"FAQ"},{type:"how-to",label:"How-to"},{type:"list",label:"List"},{type:"task-list",label:"Task List"}];Z(L,n=>{n&&(b.value=n.title||"",h.value=n.summary||"",w.value=n.pdfDownloadUrl||"",V.value=n.estimatedMinutes||null,U.value=n.isPublished||!1,r.value=JSON.parse(JSON.stringify(n.blocks||[])))},{immediate:!0});function O(n){return{title:"Title",text:"Text",image:"Image","youtube-video":"YouTube",faq:"FAQ","how-to":"How-to",list:"List","button-link":"Button","task-list":"Task List"}[n]||n}function H(n){const t={title:{__typename:"title",title:"",titleColor:null},text:{__typename:"text",text:"",title:null,titleColor:null,bgColor:null},image:{__typename:"image",src:"",alt:"",caption:""},"youtube-video":{__typename:"youtube-video",videoId:"",caption:""},faq:{__typename:"faq",title:"",titleColor:null,items:[{question:"",answer:""}]},"how-to":{__typename:"how-to",title:"",titleColor:null,steps:[{name:"",text:""}]},list:{__typename:"list",title:"",titleColor:null,markersColor:null,items:[{nodes:[{__typename:"list-item-text",text:""}]}]},"task-list":{__typename:"task-list",title:"",titleColor:null,items:[{text:""}]}};r.value.push(t[n]||{__typename:n}),_.value=r.value.length-1}function Q(n){r.value.splice(n,1),_.value===n&&(_.value=null)}function M(n,t){const g=n+t;if(g<0||g>=r.value.length)return;const N=r.value[n];r.value[n]=r.value[g],r.value[g]=N,r.value=[...r.value],_.value=g}function j(n){const t=JSON.parse(JSON.stringify(r.value[n]));r.value.splice(n+1,0,t),_.value=n+1}async function E(){B.value=!0;try{await F(`/courses/${z}/lessons/${D}`,{method:"PUT",body:{title:b.value.trim(),summary:h.value.trim()||null,estimatedMinutes:V.value||null,blocks:r.value,pdfDownloadUrl:w.value.trim()||null,isPublished:U.value}}),P?.success("Lesson saved"),await I()}catch(n){P?.error(n.data?.detail||n.message||"Save failed")}finally{B.value=!1}}return(n,t)=>{const g=le,N=ne;return o(),a("div",ie,[e("div",de,[ee(g,{to:`/admin/courses/${p($).params.id}`,class:"text-sm text-custom-orange hover:underline"},{default:te(()=>[...t[5]||(t[5]=[S(" â Back to Course ",-1)])]),_:1},8,["to"])]),p(L)?(o(),a("div",re,[e("div",ue,[e("section",pe,[e("h2",me," Lesson "+C(p(L).sortOrder+1),1),e("div",xe,[e("div",null,[t[6]||(t[6]=e("label",{class:"text-xs text-gray-500"},"Title",-1)),i(e("input",{"onUpdate:modelValue":t[0]||(t[0]=s=>k(b)?b.value=s:null),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:border-custom-orange"},null,512),[[d,p(b)]])]),e("div",null,[t[7]||(t[7]=e("label",{class:"text-xs text-gray-500"},"Summary (1-2 sentences for course outline)",-1)),i(e("textarea",{"onUpdate:modelValue":t[1]||(t[1]=s=>k(h)?h.value=s:null),rows:"2",placeholder:"Brief description of what this lesson covers",class:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:border-custom-orange resize-none"}," ",512),[[d,p(h)]])]),e("div",ce,[e("div",ye,[t[8]||(t[8]=e("label",{class:"text-xs text-gray-500"},"PDF Download URL (optional)",-1)),i(e("input",{"onUpdate:modelValue":t[2]||(t[2]=s=>k(w)?w.value=s:null),type:"text",placeholder:"/pdfs/filename.pdf",class:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:border-custom-orange"},null,512),[[d,p(w)]])]),e("div",_e,[t[9]||(t[9]=e("label",{class:"text-xs text-gray-500"},"Est. minutes",-1)),i(e("input",{"onUpdate:modelValue":t[3]||(t[3]=s=>k(V)?V.value=s:null),type:"number",min:"1",placeholder:"5",class:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:border-custom-orange"},null,512),[[d,p(V),void 0,{number:!0}]])])]),e("div",ge,[e("button",{onClick:E,disabled:p(B),class:"px-4 py-2 bg-custom-orange text-white text-sm font-medium rounded-lg hover:bg-orange-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"},C(p(B)?"Saving...":"Save Lesson"),9,ve),e("label",fe,[i(e("input",{type:"checkbox","onUpdate:modelValue":t[4]||(t[4]=s=>k(U)?U.value=s:null),class:"rounded border-gray-300 text-custom-orange focus:ring-custom-orange"},null,512),[[R,p(U)]]),t[10]||(t[10]=S(" Published ",-1))])])])]),e("section",be,[e("div",he,[e("h2",we,[t[11]||(t[11]=S(" Blocks ",-1)),e("span",Ve,"("+C(p(r).length)+")",1)])]),(o(!0),a(v,null,f(p(r),(s,c)=>(o(),a("div",{key:c,class:oe(["bg-white shadow rounded-lg px-3 py-3 mb-3 cursor-pointer transition-all duration-150",p(_)===c?"ring-2 ring-custom-blue":"hover:ring-1 hover:ring-gray-300"]),onClick:l=>_.value=c},[e("div",Ce,[t[13]||(t[13]=e("div",{class:"w-1/3"},null,-1)),e("div",ke,C(O(s.__typename)),1),e("div",Te,[e("button",{onClick:A(l=>j(c),["stop"]),class:"p-1 text-gray-400 hover:text-gray-600",title:"Duplicate block"},[...t[12]||(t[12]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor","stroke-width":"2",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16 17h1a2 2 0 002-2V5a2 2 0 00-2-2H9a2 2 0 00-2 2v1m0 0h6a2 2 0 012 2v10a2 2 0 01-2 2H7a2 2 0 01-2-2V8a2 2 0 012-2z"})],-1)])],8,$e),c>0?(o(),a("button",{key:0,onClick:A(l=>M(c,-1),["stop"]),class:"p-1 text-gray-400 hover:text-gray-700"},"â²",8,Be)):x("",!0),c<p(r).length-1?(o(),a("button",{key:1,onClick:A(l=>M(c,1),["stop"]),class:"p-1 text-gray-400 hover:text-gray-700"},"â¼",8,Se)):x("",!0),e("button",{onClick:A(l=>Q(c),["stop"]),class:"p-1 text-red-400 hover:text-red-600"},"Ã",8,Ae)])]),s.__typename==="title"?(o(),a("div",Le,[t[14]||(t[14]=e("label",{class:"text-xs text-gray-500"},"Title",-1)),i(e("input",{"onUpdate:modelValue":l=>s.title=l,class:"w-full px-3 py-1.5 border rounded text-sm"},null,8,Ne),[[d,s.title]])])):x("",!0),s.__typename==="text"?(o(),a("div",qe,[t[15]||(t[15]=e("label",{class:"text-xs text-gray-500"},"Title (optional)",-1)),i(e("input",{"onUpdate:modelValue":l=>s.title=l,class:"w-full px-3 py-1.5 border rounded text-sm mb-2"},null,8,Pe),[[d,s.title]]),t[16]||(t[16]=e("label",{class:"text-xs text-gray-500"},"Text",-1)),i(e("textarea",{"onUpdate:modelValue":l=>s.text=l,rows:"4",class:"w-full px-3 py-1.5 border rounded text-sm resize-y"},null,8,ze),[[d,s.text]])])):x("",!0),s.__typename==="image"?(o(),a("div",De,[t[18]||(t[18]=e("label",{class:"text-xs text-gray-500"},"Source",-1)),i(e("input",{"onUpdate:modelValue":l=>s.src=l,class:"w-full px-3 py-1.5 border rounded text-sm mb-2"},null,8,Me),[[d,s.src]]),t[19]||(t[19]=e("label",{class:"text-xs text-gray-500"},"Alt text",-1)),i(e("input",{"onUpdate:modelValue":l=>s.alt=l,class:"w-full px-3 py-1.5 border rounded text-sm mb-2"},null,8,Re),[[d,s.alt]]),t[20]||(t[20]=e("label",{class:"text-xs text-gray-500"},"Caption",-1)),i(e("input",{"onUpdate:modelValue":l=>s.caption=l,class:"w-full px-3 py-1.5 border rounded text-sm mb-2"},null,8,Fe),[[d,s.caption]]),e("label",Ie,[i(e("input",{type:"checkbox","onUpdate:modelValue":l=>s.portrait=l,class:"rounded border-gray-300"},null,8,Je),[[R,s.portrait]]),t[17]||(t[17]=S(" Portrait (keep narrow on desktop) ",-1))])])):x("",!0),s.__typename==="youtube-video"?(o(),a("div",Oe,[t[21]||(t[21]=e("label",{class:"text-xs text-gray-500"},"Video ID",-1)),i(e("input",{"onUpdate:modelValue":l=>s.videoId=l,class:"w-full px-3 py-1.5 border rounded text-sm mb-2"},null,8,He),[[d,s.videoId]]),t[22]||(t[22]=e("label",{class:"text-xs text-gray-500"},"Caption",-1)),i(e("input",{"onUpdate:modelValue":l=>s.caption=l,class:"w-full px-3 py-1.5 border rounded text-sm"},null,8,Qe),[[d,s.caption]])])):x("",!0),s.__typename==="faq"?(o(),a("div",je,[t[23]||(t[23]=e("label",{class:"text-xs text-gray-500"},"Title",-1)),i(e("input",{"onUpdate:modelValue":l=>s.title=l,class:"w-full px-3 py-1.5 border rounded text-sm mb-2"},null,8,Ee),[[d,s.title]]),(o(!0),a(v,null,f(s.items,(l,m)=>(o(),a("div",{key:m,class:"p-2 bg-gray-50 rounded mb-2"},[i(e("input",{"onUpdate:modelValue":u=>l.question=u,placeholder:"Question",class:"w-full px-2 py-1 border rounded text-sm mb-1"},null,8,Ye),[[d,l.question]]),i(e("textarea",{"onUpdate:modelValue":u=>l.answer=u,placeholder:"Answer",rows:"2",class:"w-full px-2 py-1 border rounded text-sm resize-y"},null,8,Ke),[[d,l.answer]]),e("button",{onClick:u=>s.items.splice(m,1),class:"text-xs text-red-500 mt-1"},"Remove",8,Ge)]))),128)),e("button",{onClick:l=>s.items.push({question:"",answer:""}),class:"text-xs text-custom-orange underline"},"+ Add Q&A",8,We)])):x("",!0),s.__typename==="how-to"?(o(),a("div",Xe,[t[24]||(t[24]=e("label",{class:"text-xs text-gray-500"},"Title",-1)),i(e("input",{"onUpdate:modelValue":l=>s.title=l,class:"w-full px-3 py-1.5 border rounded text-sm mb-2"},null,8,Ze),[[d,s.title]]),(o(!0),a(v,null,f(s.steps,(l,m)=>(o(),a("div",{key:m,class:"p-2 bg-gray-50 rounded mb-2"},[i(e("input",{"onUpdate:modelValue":u=>l.name=u,placeholder:"Step name",class:"w-full px-2 py-1 border rounded text-sm mb-1"},null,8,et),[[d,l.name]]),i(e("textarea",{"onUpdate:modelValue":u=>l.text=u,placeholder:"Step description",rows:"2",class:"w-full px-2 py-1 border rounded text-sm resize-y"},null,8,tt),[[d,l.text]]),e("button",{onClick:u=>s.steps.splice(m,1),class:"text-xs text-red-500 mt-1"},"Remove",8,st)]))),128)),e("button",{onClick:l=>s.steps.push({name:"",text:""}),class:"text-xs text-custom-orange underline"},"+ Add Step",8,lt)])):x("",!0),s.__typename==="list"?(o(),a("div",ot,[t[25]||(t[25]=e("label",{class:"text-xs text-gray-500"},"Title",-1)),i(e("input",{"onUpdate:modelValue":l=>s.title=l,class:"w-full px-3 py-1.5 border rounded text-sm mb-2"},null,8,nt),[[d,s.title]]),(o(!0),a(v,null,f(s.items,(l,m)=>(o(),a("div",{key:m,class:"p-2 bg-gray-50 rounded mb-2"},[(o(!0),a(v,null,f(l.nodes,(u,Y)=>(o(),a("div",{key:Y},[u.__typename==="list-item-text"?i((o(),a("textarea",{key:0,"onUpdate:modelValue":K=>u.text=K,placeholder:"Item text",rows:"1",class:"w-full px-2 py-1 border rounded text-sm resize-y"},null,8,at)),[[d,u.text]]):x("",!0)]))),128)),e("button",{onClick:u=>s.items.splice(m,1),class:"text-xs text-red-500 mt-1"},"Remove",8,it)]))),128)),e("button",{onClick:l=>s.items.push({nodes:[{__typename:"list-item-text",text:""}]}),class:"text-xs text-custom-orange underline"},"+ Add Item",8,dt)])):x("",!0),s.__typename==="task-list"?(o(),a("div",rt,[t[27]||(t[27]=e("label",{class:"text-xs text-gray-500"},'Title (optional, defaults to "Try it yourself")',-1)),i(e("input",{"onUpdate:modelValue":l=>s.title=l,class:"w-full px-3 py-1.5 border rounded text-sm mb-2"},null,8,ut),[[d,s.title]]),(o(!0),a(v,null,f(s.items,(l,m)=>(o(),a("div",{key:m,class:"flex items-center gap-2 p-2 bg-gray-50 rounded mb-2"},[t[26]||(t[26]=e("span",{class:"text-gray-400 text-sm"},"â",-1)),i(e("input",{"onUpdate:modelValue":u=>l.text=u,placeholder:"Task description",class:"flex-1 px-2 py-1 border rounded text-sm"},null,8,pt),[[d,l.text]]),e("button",{onClick:u=>s.items.splice(m,1),class:"text-xs text-red-500"},"Remove",8,mt)]))),128)),e("button",{onClick:l=>s.items.push({text:""}),class:"text-xs text-custom-orange underline"},"+ Add Task",8,xt)])):x("",!0)],10,Ue))),128)),e("div",ct,[(o(),a(v,null,f(J,s=>e("button",{key:s.type,onClick:c=>H(s.type),class:"px-3 py-1.5 text-xs border border-gray-300 rounded-lg hover:bg-gray-100 transition-colors"}," + "+C(s.label),9,yt)),64))])])]),e("div",_t,[e("div",gt,[t[28]||(t[28]=e("h3",{class:"text-sm font-semibold text-gray-700 mb-2 uppercase tracking-wide"},"Preview",-1)),e("div",vt,[p(r).length?(o(),se(N,{key:0,post:{blocks:p(r)}},null,8,["post"])):(o(),a("p",ft,"No blocks yet"))])])])])):(o(),a("div",bt," Lesson not found. "))])}}};export{Tt 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.