1import{aL as A,j as e,h as v,m as w,t as T,H as k,O as u}from"./index.DpMbmDRM.js";import{e as S,r as n}from"./vendor.DRWrrDqG.js";import"./antd.qZt8WDgQ.js";class z{async analyzeArticle(i){var o;try{const a=await A("/api/v1/article-analysis/analyze",i);if(a.code!==200)throw new Error(`HTTP ${a.code}: Request failed`);return a.data}catch(a){if(console.error("Article analysis failed:",a),(o=a.response)!=null&&o.data){const c=a.response.data;throw new Error(c.details||c.error||"Failed to analyze article")}throw new Error(a.message||"Failed to analyze article")}}}const C=new z;function R(){const h=S(),[i,o]=n.useState("url"),[a,c]=n.useState(""),[y,f]=n.useState(""),[d,m]=n.useState(!1),[g,x]=n.useState(null),[t,p]=n.useState(null),b=async s=>{var r;if(s.preventDefault(),!!a){m(!0),x(null);try{const l=await C.analyzeArticle({url:a,analysis_type:"full"});p({url:l.url,title:l.title,content:((r=l.detailedAnalysis)==null?void 0:r.contentSummary)||l.summary,summary:l.summary,keyPoints:l.keyPoints,mainTopic:l.mainTopic,detailedAnalysis:l.detailedAnalysis}),u.success("Article analyzed successfully!")}catch(l){console.error("Article analysis failed:",l),x(l.message||"Failed to extract content from the URL. Please try again."),u.error(l.message||"Failed to analyze article")}finally{m(!1)}}},j=async s=>{if(s.preventDefault(),!!y){m(!0),x(null);try{p({content:y,title:"Content Analysis",summary:"Analysis of the provided content...",keyPoints:["Key point 1 from the text","Key point 2 from the text","Key point 3 from the text"],mainTopic:"Content Analysis"}),u.success("Content analyzed successfully!")}catch(r){console.error("Content analysis failed:",r),x(r.message||"Failed to analyze the content. Please try again."),u.error(r.message||"Failed to analyze content")}finally{m(!1)}}},N=()=>{t&&h("/posts/unified",{state:{inspirationType:"article",inspirationData:t,workflowStep:"content_prompt"}})};return e.jsx("div",{className:"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"px-4 py-6 sm:px-0",children:[e.jsxs("div",{className:"flex items-center mb-6",children:[e.jsx(v,{className:"h-8 w-8 text-orange-500 mr-3"}),e.jsx("h1",{className:"text-2xl font-semibold text-gray-900",children:"Create from Article"})]}),e.jsx("div",{className:"mb-8",children:e.jsxs("div",{className:"flex space-x-4",children:[e.jsxs("button",{onClick:()=>o("url"),className:`px-4 py-2 rounded-md text-sm font-medium ${i==="url"?"bg-orange-100 text-orange-700":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(w,{className:"inline-block mr-2"}),"Enter URL"]}),e.jsxs("button",{onClick:()=>o("text"),className:`px-4 py-2 rounded-md text-sm font-medium ${i==="text"?"bg-orange-100 text-orange-700":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(T,{className:"inline-block mr-2"}),"Paste Text"]})]})}),e.jsxs("div",{className:"bg-white rounded-lg shadow-sm p-6",children:[i==="url"?e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"article-url",className:"block text-sm font-medium text-gray-700 mb-1",children:"Article URL"}),e.jsx("input",{type:"url",id:"article-url",value:a,onChange:s=>c(s.target.value),placeholder:"https://example.com/article",className:"w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-orange-500",required:!0})]}),e.jsx("button",{type:"submit",disabled:d,className:"w-full px-4 py-2 bg-orange-600 text-white rounded-md hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500 disabled:opacity-50",children:d?"Analyzing...":"Analyze Article"})]}):e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"article-text",className:"block text-sm font-medium text-gray-700 mb-1",children:"Article Text"}),e.jsx("textarea",{id:"article-text",value:y,onChange:s=>f(s.target.value),placeholder:"Paste your article text here...",rows:6,className:"w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-orange-500",required:!0})]}),e.jsx("button",{type:"submit",disabled:d,className:"w-full px-4 py-2 bg-orange-600 text-white rounded-md hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500 disabled:opacity-50",children:d?"Analyzing...":"Analyze Text"})]}),g&&e.jsx("div",{className:"mt-4 p-4 bg-red-50 rounded-md",children:e.jsx("p",{className:"text-sm text-red-600",children:g})})]}),t&&e.jsxs("div",{className:"mt-8 bg-white rounded-lg shadow-sm p-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"Article Analysis"}),t.title&&e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Title"}),e.jsx("p",{className:"mt-1 text-sm text-gray-900",children:t.title})]}),t.mainTopic&&e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Main Topic"}),e.jsx("p",{className:"mt-1 text-sm text-gray-900",children:t.mainTopic})]}),t.summary&&e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Summary"}),e.jsx("p",{className:"mt-1 text-sm text-gray-600",children:t.summary})]}),t.keyPoints&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Key Points"}),e.jsx("ul",{className:"mt-2 space-y-2",children:t.keyPoints.map((s,r)=>e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"flex-shrink-0 h-1.5 w-1.5 rounded-full bg-orange-500 mt-2 mr-2"}),e.jsx("span",{className:"text-sm text-gray-600",children:s})]},r))})]}),t.detailedAnalysis&&e.jsxs("div",{className:"mb-6 space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Detailed Analysis"}),t.detailedAnalysis.keyInsights&&t.detailedAnalysis.keyInsights.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-600 mb-2",children:"Key Insights"}),e.jsx("ul",{className:"space-y-1",children:t.detailedAnalysis.keyInsights.map((s,r)=>e.jsxs("li",{className:"text-xs text-gray-600",children:["⢠",s]},r))})]}),t.detailedAnalysis.mainArguments&&t.detailedAnalysis.mainArguments.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-600 mb-2",children:"Main Arguments"}),e.jsx("ul",{className:"space-y-1",children:t.detailedAnalysis.mainArguments.map((s,r)=>e.jsxs("li",{className:"text-xs text-gray-600",children:["⢠",s]},r))})]}),t.detailedAnalysis.targetAudience&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-600 mb-1",children:"Target Audience"}),e.jsx("p",{className:"text-xs text-gray-600",children:t.detailedAnalysis.targetAudience})]}),t.detailedAnalysis.toneAndStyle&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-600 mb-1",children:"Tone & Style"}),e.jsx("p",{className:"text-xs text-gray-600",children:t.detailedAnalysis.toneAndStyle})]})]}),e.jsxs("button",{onClick:N,className:"inline-flex items-center px-4 py-2 border border-transparent roun
1ded-md shadow-sm text-sm font-medium text-white bg-orange-600 hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500",children:["Create Content",e.jsx(k,{className:"ml-2 h-4 w-4"})]})]})]})})}export{R 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.