1import{u as D,ac as U,r as a,aI as y,j as e,al as B,b9 as x,c9 as q,bm as z,bt as O,aq as C}from"./vendor-CMvvE79M.js";import{aJ as G,C as R,e as V,f as H,Y as Q,c as W,I as w,$ as S,S as Y,t as _,v as $,w as J,x as K,B as X,_ as Z}from"./index-CJhDLLQN.js";import{S as ee}from"./slider-CUI_8__q.js";import{L as r}from"./label-B2udOYFm.js";import{S as p}from"./separator-C55a0Ko7.js";import"./pdf-Bf_FUwzp.js";const te=[{value:"energy-qc",label:"Energy QC"},{value:"insight-solar",label:"InsightSolar"},{value:"ground-lease",label:"Ground Lease"},{value:"echo-mh",label:"Echo MH (Manufactured Housing)"},{value:"echo-volt",label:"Echo Volt"},{value:"echo-str",label:"STR Analysis"}];function ce(){const E=D(),[,k]=U(),i=a.useRef(null),[d,I]=a.useState(""),[h,A]=a.useState(""),[o,g]=a.useState(""),[j,T]=a.useState(""),[f,F]=a.useState(""),[u,P]=a.useState(4),[b,L]=a.useState([]),[v,m]=a.useState(""),N=y({mutationFn:async t=>{const s=new FormData;s.append("file",t);const l=await fetch("/api/learning/ai/parse-document",{method:"POST",body:s,credentials:"include"});if(!l.ok){const c=await l.json();throw new Error(c.error||"Upload failed")}return l.json()},onSuccess:(t,s)=>{const l=o?` 2 3--- 4 5`:"";g(c=>c+l+t.text),L(c=>[...c,{name:s.name,size:t.text.length}]),m(""),t.truncated&&m("Document was large â first 50,000 characters were extracted.")},onError:t=>{m(t.message)}}),M=t=>{const s=t.target.files?.[0];s&&N.mutate(s),i.current&&(i.current.value="")},n=y({mutationFn:async()=>(await Z("POST","/api/learning/ai/generate-course",{topic:d,description:h||void 0,contentText:o||void 0,extractionPrompt:j||void 0,linkedModuleId:f||void 0,lessonCount:u})).json(),onSuccess:t=>{E.invalidateQueries({queryKey:["/api/learning/courses"]}),k(`/learning/admin/course/${t.id}`)}});return e.jsx("div",{className:"min-h-screen",style:{backgroundColor:"#EDE8E4"},children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("button",{onClick:()=>window.history.back(),className:"p-1.5 rounded-md hover:bg-black/5 transition-colors","data-testid":"button-back","aria-label":"Go back",children:e.jsx(B,{className:"h-5 w-5",style:{color:"#072034"}})}),e.jsx("img",{src:G,alt:"Banks Tech",className:"h-8"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",style:{color:"#072034"},"data-testid":"text-builder-title",children:"Course Builder"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"AI-powered course generation"})]})]}
5),e.jsxs(R,{children:[e.jsxs(V,{children:[e.jsxs(H,{className:"flex items-center gap-2",style:{color:"#072034"},children:[e.jsx(x,{className:"h-5 w-5",style:{color:"#8E7A60"}}),"Generate a New Course"]}),e.jsx(Q,{children:"Provide a topic, upload reference documents, and tell the AI what to focus on."})]}),e.jsxs(W,{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx(r,{htmlFor:"topic",children:"Topic *"}),e.jsx(w,{id:"topic",placeholder:"e.g., Understanding Solar Panel Valuation",value:d,onChange:t=>I(t.target.value),"data-testid":"input-topic"})]}),e.jsxs("div",{children:[e.jsx(r,{htmlFor:"description",children:"Description"}),e.jsx(w,{id:"description",placeholder:"Brief description of the course",value:h,onChange:t=>A(t.target.value),"data-testid":"input-description"})]}),e.jsx(p,{}),e.jsxs("div",{children:[e.jsxs(r,{className:"text-base font-semibold flex items-center gap-2",style:{color:"#072034"},children:[e.jsx(q,{className:"h-4 w-4",style:{color:"#8E7A60"}}),"Source Content"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 mb-3",children:"Upload documents or paste content. The AI will use this as reference material for generating lessons."}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center cursor-pointer hover:border-[#8E7A60] transition-colors mb-3",style:{borderColor:"#8E7A60"},onClick:()=>i.current?.click(),"data-testid":"dropzone-upload",children:[e.jsx("input",{ref:i,type:"file",accept:".pdf,.docx,.txt",onCh
5ange:M,className:"hidden","data-testid":"input-file-upload"}),e.jsx(z,{className:"h-8 w-8 mx-auto mb-2",style:{color:"#8E7A60"}}),e.jsx("p",{className:"text-sm font-medium",style:{color:"#072034"},children:N.isPending?"Extracting text...":"Click to upload a document"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"PDF, Word (.docx), or Text files up to 10MB"})]}),b.length>0&&e.jsx("div",{className:"space-y-1 mb-3",children:b.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs px-3 py-1.5 rounded-md",style:{backgroundColor:"#F5F0EC"},children:[e.jsx(O,{className:"h-3 w-3",style:{color:"#8E7A60"}}),e.jsx("span",{className:"font-medium",style:{color:"#072034"},children:t.name}),e.jsxs("span",{className:"text-muted-foreground",children:["(",(t.size/1e3).toFixed(0),"k chars extracted)"]})]},s))}),v&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-700 bg-amber-50 px-3 py-2 rounded-md mb-3",children:[e.jsx(C,{className:"h-3 w-3"}),v]}),e.jsx(S,{id:"content",placeholder:"Or paste reference material directly here... You can combine uploaded documents with pasted content.",value:o,onChange:t=>g(t.target.value),rows:8,"data-testid":"textarea-content"}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[o.length.toLocaleString()," characters of reference content"]})]}),e.jsxs("div",{children:[e.jsxs(r,{htmlFor:"extraction-prompt",className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-3 w-3",style:{color:"#8E7A60"}}
5),"AI Instructions"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Tell the AI what to focus on from your content. What topics should it pull out? What should it emphasize?"}),e.jsx(S,{id:"extraction-prompt",placeholder:"e.g., Focus on the solar panel depreciation methods and how they affect property value. Include practical examples of cost vs. income approach for solar valuations. Emphasize USPAP compliance requirements...",value:j,onChange:t=>T(t.target.value),rows:4,"data-testid":"textarea-extraction-prompt"})]}),e.jsx(p,{}),e.jsxs("div",{children:[e.jsx(r,{children:"Linked Module"}),e.jsxs(Y,{value:f,onValueChange:F,children:[e.jsx(_,{"data-testid":"select-module",children:e.jsx($,{placeholder:"Select a module (optional)"})}),e.jsx(J,{children:te.map(t=>e.jsx(K,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{children:[e.jsxs(r,{children:["Number of Lessons: ",u]}),e.jsx(ee,{value:[u],onValueChange:([t])=>P(t),min:2,max:8,step:1,className:"mt-2","data-testid":"slider-lesson-count"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mt-1",children:[e.jsx("span",{children:"2"}),e.jsx("span",{children:"8"})]})]}),e.jsx(p,{}),e.jsx(X,{size:"lg",className:"w-full",style:{backgroundColor:"#072034",color:"#EDE8E4"},disabled:!d.trim()||n.isPending,onClick:()=>n.mutate(),"data-testid":"button-generate",children:n.isPending?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"animate-spin h-4 w-4 border-2 border-current border-t-transparent rounded-full"}),"Generating Course..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-4 w-4"}),"Generate Course with AI"]})}),n.isError&&e.jsxs("div",{className:"text-sm text-red-600 text-center p-3 bg-red-50 rounded-md",children:[e.jsx(C,{className:"h-4 w-4 inline mr-1"}),n.error?.message||"Error generating course. Please try again."]})]})]})]})})}export{ce 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.