1import{b as fe,r,j as e,R as je}from"./vendor-react-Zq6SgdQO.js";import{C as M,B as p,L as b,e as be,aB as U,a6 as X,E as Ne}from"./index-CIS_QymX.js";import{I as y}from"./input-CuT5g_7k.js";import{T as N}from"./textarea-Cs5Je6WD.js";import{L as n}from"./label-Dv6mLkXp.js";import{B as A}from"./badge-nxxmFwJ4.js";import{S as O,a as z,b as K,c as Q,d as f}from"./select-C-ckcqwJ.js";import{C as ve,a as T,b as I,d as E,c as C}from"./card-OXKQZjm9.js";import{a as we,s as ye,b as Ce,p as Se,r as ke,c as _e,e as Ae}from"./blog-BSFB9IdX.js";import{W as Te}from"./wand-2-m347jqpR.js";import{L as Z}from"./lightbulb-InWhY6_6.js";import{C as J}from"./chevron-left-6Itstacm.js";import{S as F}from"./sparkles-BBZ2zzzG.js";import{E as ee}from"./eye-8D29qktP.js";import{I as Ie}from"./image-CeqFzI3E.js";import{S as Ee}from"./save-C6d_Z-X-.js";import{S as Re}from"./send-BzM5P-re.js";import"./vendor-query-BEQz81D2.js";import"./index-BdQq_4o_.js";import"./chevron-up-DPdtOcgM.js";const R=[{id:"reflection",label:"Reflection",icon:e.jsx(Z,{className:"h-4 w-4"})},{id:"research",label:"Research",icon:e.jsx(X,{className:"h-4 w-4"})},{id:"questions",label:"Deep Dive",icon:e.jsx(U,{className:"h-4 w-4"})},{id:"generate",label:"Generate",icon:e.jsx(F,{className:"h-4 w-4"})},{id:"review",label:"Review",icon:e.jsx(ee,{className:"h-4 w-4"})}],Ze=()=>{var D,W,V,Y,$;const se=fe(),[m,h]=r.useState("reflection"),[c,o]=r.useState(!1),[L,l]=r.useState(null),[v,ae]=r.useState(""),[w,re]=r.useState(""),[S,te]=r.useState(""),[P,le]=r.useState("Business leaders and decision makers"),[q,ne]=r.useState("professional"),[x,oe]=r.useState(null),[i,ie]=r.useState(null),[ce,de]=r.useState([]),[k,B]=r.useState({}),[t,me]=r.useState(null),[u,g]=r.useState({title:"",content:"",excerpt:"",meta_description:"",author_name:""});r.useEffect(()=>{(async()=>{try{const a=await we();de(a.categories)}catch(a){console.error("Failed to load categories:",a)}})()},[]);const xe=async()=>{if(!v.trim()||!w.trim()){l("Topic and reflection are required");return}o(!0),l(null);try{const s=await ye({topic:v,reflection:w,category:S,target_audience:P,tone:q});oe(s.sessionId),h("research"),await ue(s.sessionId)}catch(s){l(s.message||"Could not start session")}finally{o(!1)}},ue=async s=>{const a=s||x;if(a){o(!0),l(null);try{const d=await ke(a),_=await _e(a);ie(_.session);const H={};d.questions.forEach(pe=>{H[pe]=""}),B(H),h("questions")}catch(d){l(d.message||"Research failed")}finally{o(!1)}}},he=async()=>{if(!x)return;const s=Object.values(k).filter(a=>!a.trim()).length;if(s>0){l(`Please answer all ${s} remaining questions`);return}o(!0),l(null);try{await Ce(x,k),h("generate"),await ge()}catch(a){l(a.message||"Could not save answers")}finally{o(!1)}},ge=async()=>{if(x){o(!0),l(null);try{const s=await Ae(x,!0);me(s.post),s.post&&g({title:s.post.title,content:s.post.content,excerpt:s.post.excerpt,meta_description:s.post.meta_description,author_name:""}),h("review")}catch(s){l(s.message||"Generation failed")}finally{o(!1)}}},G=async s=>{if(x){o(!0),l(null);try{await Se(x,{...u,category:S,tags:t==null?void 0:t.tags,og_image:t==null?void 0:t.og_image,status:s}),se("/admin/blog")}catch(a){l(a.message||"Publishing failed")}finally{o(!1)}}},j=R.findIndex(s=>s.id===m);return e.jsx("div",{className:"min-h-screen bg-background text-foreground p-6",children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Te,{className:"h-8 w-8 text-blue-400"}),e.jsx("h1",{className:"text-3xl font-light",children:"Blog Composer"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Create professional blog articles through a guided AI-assisted workflow"})]}),e.jsx("div",{className:"mb-8",children:e.jsx("div",{className:"flex items-center justify-between",children:R.map((s,a)=>e.jsxs(je.Fragment,{children:[e.jsxs("div",{className:`flex items-center gap-2 ${a<=j?"text-blue-400":"text-muted-foreground"}`,children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center border-2 transition-all ${a<j?"bg-blue-500 border-blue-500":a===j?"border-blue-500 bg-blue-500/20":"border-border bg-transparent"}`,children:a<j?e.jsx(M,{className:"h-5 w-5 text-white"}):s.icon}),e.jsx("span",{className:"hidden sm:block text-sm font-light",children:s.label})]}),a<R.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-4 ${a<j?"bg-blue-500":"bg-accent"}`})]},s.id))})}),L&&e.jsx("div",{className:"mb-6 p-4 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400",children:L}),e.jsxs(ve,{className:"bg-muted/50 border-border",children:[m==="reflection"&&e.jsxs(e.Fragment,{children:[e.jsxs(T,{children:[e.jsxs(I,{className:"flex items-center gap-2 text-foreground",children:[e.jsx(Z,{className:"h-5 w-5 text-amber-400"}),"Step 1: Your Reflection"]}),e.jsx(E,{className:"text-muted-foreground",children:"Describe the topic and share your initial thoughts. The AI will then ask in-depth questions."})]}),e.jsxs(C,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"text-muted-foreground",children:"Topic / Title Idea"}
1),e.jsx(y,{value:v,onChange:s=>ae(s.target.value),placeholder:"E.g. 'How AI is changing the due diligence process'",className:"bg-muted border-border text-foreground"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"text-muted-foreground",children:"Your Reflection"}),e.jsx(N,{value:w,onChange:s=>re(s.target.value),placeholder:"Write your thoughts, insights and perspectives on the topic. What do you want to convey? What experiences do you have? What do you think is important?",className:"bg-muted border-border text-foreground min-h-[200px]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: Be personal and specific. Feel free to share specific experiences or examples."})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"text-muted-foreground",children:"Category (optional)"}),e.jsxs(O,{value:S,onValueChange:te,children:[e.jsx(z,{className:"bg-muted border-border text-foreground",children:e.jsx(K,{placeholder:"Select category"})}),e.jsxs(Q,{children:[e.jsx(f,{value:"general",children:"General"}),ce.map(s=>e.jsx(f,{value:s.slug,children:s.name},s.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"text-muted-foreground",children:"Target Audience"}),e.jsx(y,{value:P,onChange:s=>le(s.target.value),placeholder:"E.g. 'CFOs and finance managers'",className:"bg-muted border-border text-foreground"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"text-muted-foreground",children:"Tone"}),e.jsxs(O,{value:q,onValueChange:ne,children:[e.jsx(z,{className:"bg-muted border-border text-foreground",children:e.jsx(K,{})}),e.jsxs(Q,{children:[e.jsx(f,{value:"professional",children:"Professional & Authoritative"}),e.jsx(f,{value:"conversational",children:"Conversational & Accessible"}),e.jsx(f,{value:"educational",children:"Educational & Pedagogical"}),e.jsx(f,{value:"thought-leader",children:"Thought Leader & Visionary"})]})]})]}),e.jsx(p,{onClick:xe,disabled:c||!v.trim()||!w.trim(),className:"w-full bg-blue-500 hover:bg-blue-600",children:c?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"h-4 w-4 mr-2 animate-spin"}),"Starting research..."]}):e.jsxs(e.Fragment,{children:["Start Research",e.jsx(be,{className:"h-4 w-4 ml-2"})]})})]})]}),(m==="research"||m==="questions")&&e.jsxs(e.Fragment,{children:[e.jsxs(T,{children:[e.jsxs(I,{className:"flex items-center gap-2 text-foreground",children:[e.jsx(U,{className:"h-5 w-5 text-cyan-400"}),"Step 2: In-Depth Questions"]}),e.jsx(E,{className:"text-muted-foreground",children:"Answer these questions to give the AI more context and personal insights."})]}),e.jsx(C,{className:"space-y-6",children:c&&m==="research"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-4",children:[e.jsx(b,{className:"h-8 w-8 animate-spin text-blue-400"}),e.jsx("p",{className:"text-muted-foreground",children:"Analyzing the topic and generating questions..."})]}):e.jsxs(e.Fragment,{children:[((D=i==null?void 0:i.research_results)==null?void 0:D.answer)&&e.jsxs("div",{className:"p-4 bg-blue-500/10 border border-blue-500/20 rounded-lg mb-6",children:[e.jsxs("h4",{className:"text-sm font-medium text-blue-400 mb-2 flex items-center gap-2",children:[e.jsx(X,{className:"h-4 w-4"}),"Current Context"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i.research_results.answer}),((W=i.research_results.sources)==null?void 0:W.length)>0&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.research_results.sources.map((s,a)=>{var d;return e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-blue-400 hover:text-blue-300 flex items-center gap-1",children:[e.jsx(Ne,{className:"h-3 w-3"}),(d=s.title)==null?void 0:d.substring(0,30),"..."]},a)})})]}),e.jsx("div",{className:"space-y-6",children:(V=i==null?void 0:i.questions)==null?void 0:V.map((s,a)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(n,{className:"text-foreground flex items-start gap-2",children:[e.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-cyan-500/20 text-cyan-400 flex items-center justify-center text-sm",children:a+1}),e.jsx("span",{children:s})]}),e.jsx(N,{value:k[s]||"",onChange:d=>B(_=>({..._,[s]:d.target.value})),placeholder:"Your answer...",className:"bg-muted border-border text-foreground min-h-[100px] ml-8"})]},a))}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(p,{variant:"outline",onClick:()=>h("reflection"),className:"border-border text-foreground sidebar-icon-hover",children:[e.jsx(J,{className:"h-4 w-4 mr-2"}),"Previous step"]}
1),e.jsx(p,{onClick:he,disabled:c,className:"flex-1 bg-blue-500 hover:bg-blue-600",children:c?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating article..."]}):e.jsxs(e.Fragment,{children:["Generate Article",e.jsx(F,{className:"h-4 w-4 ml-2"})]})})]})]})})]}),m==="generate"&&e.jsx(C,{className:"py-16",children:e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx(F,{className:"h-16 w-16 text-blue-400 animate-pulse"}),e.jsx("div",{className:"absolute inset-0 bg-blue-500/20 blur-xl rounded-full"})]}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("h3",{className:"text-xl font-light text-foreground",children:"Creating your article..."}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"The AI combines your reflections and answers into a professional, polished article. This usually takes 30-60 seconds."})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[e.jsx(b,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:"Generating content and image..."})]})]})}),m==="review"&&t&&e.jsxs(e.Fragment,{children:[e.jsxs(T,{children:[e.jsxs(I,{className:"flex items-center gap-2 text-foreground",children:[e.jsx(ee,{className:"h-5 w-5 text-green-600 dark:text-green-400"}),"Step 3: Review & Publish"]}),e.jsx(E,{className:"text-muted-foreground",children:"Edit and fine-tune the article before publishing."})]}),e.jsxs(C,{className:"space-y-6",children:[t.og_image&&e.jsxs("div",{className:"relative aspect-[2/1] rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:t.og_image,alt:"Generated header",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute bottom-3 right-3",children:e.jsxs(A,{className:"bg-black/60 text-white border-0",children:[e.jsx(Ie,{className:"h-3 w-3 mr-1"}),"AI-generated image"]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(A,{variant:"outline",className:"border-border text-muted-foreground",children:[t.reading_time_minutes," min read"]}),(Y=t.tags)==null?void 0:Y.map((s,a)=>e.jsx(A,{variant:"outline",className:"border-blue-500/30 text-blue-400",children:s},a))]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"text-muted-foreground",children:"Title"}),e.jsx(y,{value:u.title,onChange:s=>g(a=>({...a,title:s.target.value})),className:"bg-muted border-border text-foreground text-lg"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"text-muted-foreground",children:"Excerpt (for listings)"}),e.jsx(N,{value:u.excerpt,onChange:s=>g(a=>({...a,excerpt:s.target.value})),className:"bg-muted border-border text-foreground",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"text-muted-foreground",children:"Meta Description (SEO)"}),e.jsx(N,{value:u.meta_description,onChange:s=>g(a=>({...a,meta_description:s.target.value})),className:"bg-muted border-border text-foreground",rows:2,maxLength:160}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[u.meta_description.length,"/160 characters"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"text-muted-foreground",children:"Author"}),e.jsx(y,{value:u.author_name,onChange:s=>g(a=>({...a,author_name:s.target.value})),placeholder:"Your name",className:"bg-muted border-border text-foreground"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"text-muted-foreground",children:"Content"}),e.jsx(N,{value:u.content,onChange:s=>g(a=>({...a,content:s.target.value})),className:"bg-muted border-border text-foreground font-mono text-sm min-h-[400px]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"HTML format supported"})]})]}),(($=t.key_takeaways)==null?void 0:$.length)>0&&e.jsxs("div",{className:"p-4 bg-green-500/10 border border-green-500/20 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-green-600 dark:text-green-400 mb-2",children:"Key Takeaways"}),e.jsx("ul",{className:"space-y-1",children:t.key_takeaways.map((s,a)=>e.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[e.jsx(M,{className:"h-4 w-4 text-green-600 dark:text-green-400 flex-shrink-0 mt-0.5"}),s]},a))})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t border-border",children:[e.jsxs(p,{variant:"outline",onClick:()=>h("questions"),className:"border-border text-foreground sidebar-icon-hover",children:[e.jsx(J,{className:"h-4 w-4 mr-2"}),"Previous step"]}),e.jsxs(p,{variant:"outline",onClick:()=>
1G("draft"),disabled:c,className:"border-border text-foreground sidebar-icon-hover",children:[e.jsx(Ee,{className:"h-4 w-4 mr-2"}),"Save as Draft"]}),e.jsx(p,{onClick:()=>G("published"),disabled:c,className:"flex-1 bg-gradient-to-r from-green-500 to-emerald-500 hover:from-green-600 hover:to-emerald-600",children:c?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"h-4 w-4 mr-2 animate-spin"}),"Publishing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"h-4 w-4 mr-2"}),"Publish Article"]})})]})]})]})]})]})})};export{Ze as BlogComposer,Ze 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.