1import{d as U,u as D,b as I,f as N,c as E,e as K,r as a,D as F,g as u,h as $,i as e,t as o,B as z,k as V,C as B,y as f,F as P,A as R,L as J,_ as O,o as c,q as Q,z as H,s as X}from"./DzfUrCz9.js";import{_ as G}from"./BtWPo5Mx.js";const W={class:"min-h-screen bg-[#F8F9FA] font-sans flex flex-col"},Y={class:"flex-grow max-w-7xl mx-auto w-full px-4 sm:px-6 lg:px-8 py-12 pt-24 relative z-10"},Z={class:"text-center mb-12"},ee={class:"text-3xl md:text-4xl font-black text-slate-900 mb-4 drop-shadow-sm"},te={class:"text-lg text-slate-700 max-w-2xl mx-auto mb-4 font-bold"},se={class:"inline-block bg-amber-50 border border-amber-200 text-amber-700 px-4 py-2 rounded-lg text-sm font-bold"},oe={class:"grid grid-cols-1 lg:grid-cols-2 gap-8 items-start"},ne={class:"bg-white rounded-2xl shadow-sm border border-slate-100 p-6 flex flex-col h-[600px]"},le={class:"flex justify-between items-center mb-4"},ae={class:"font-bold text-slate-900 flex items-center gap-2"},ie={class:"relative overflow-hidden inline-block"},re={class:"text-sm font-bold text-red-600 hover:text-red-700 bg-red-50 hover:bg-red-100 px-3 py-1.5 rounded-lg transition-colors"},de=["placeholder"],ue={class:"bg-white rounded-2xl shadow-sm border border-slate-100 p-6 flex flex-col h-[600px] relative"},ce={key:0,class:"absolute inset-0 bg-white/90 backdrop-blur-sm z-10 flex flex-col items-center justify-center rounded-2xl"},pe={class:"font-bold text-slate-800"},me={key:0,class:"text-sm text-slate-500 mt-2"},_e={class:"flex justify-between items-center mb-4"},ge={class:"font-bold text-slate-900 flex items-center gap-2"},fe={key:0,class:"h-full flex flex-col items-center justify-center text-center opacity-40"},ve={class:"text-sm"},be={key:0,class:"text-[10px] text-slate-400 mt-1 font-mono"},he={key:1,class:"flex self-start items-center space-x-2 text-slate-400 text-sm py-2"},xe={class:"border-t border-slate-100 pt-4"},we={class:"flex gap-2"},ye=["placeholder"],ke=["disabled"],qe={class:"mt-24 grid grid-cols-1 md:grid-cols-3 gap-8"},$e={class:"bg-white p-6 rounded-xl border border-slate-100"},Ce={class:"font-bold text-slate-900 mb-2"},Me={class:"text-sm text-slate-500"},je={class:"bg-white p-6 rounded-xl border border-slate-100"},Ae={class:"font-bold text-slate-900 mb-2"},Fe={class:"text-sm text-slate-500"},ze={class:"bg-white p-6 rounded-xl border border-slate-100"},Ve={class:"font-bold text-slate-900 mb-2"},Be={class:"text-sm text-slate-500"},Le=U({__name:"ai-question-answering",setup(He){const{t:r}=D(),l=I(),m=N(()=>({name:l.site.name,name_upper:l.site.name.toUpperCase(),domain:l.site.domain,domain_upper:l.site.domain.toUpperCase(),url:l.site.url,email:l.site.contact.email,x_handle:l.site.contact.xHandle}));E({title:()=>`${r("ai_question_answering.title",m.value)} - ${l.site.name}`,ogTitle:()=>`${r("ai_question_answering.title",m.value)} - ${l.site.name}`,description:()=>r("ai_question_answering.desc",m.value),ogDescription:()=>r("ai_question_answering.desc",m.value),ogImage:l.site.ogImage,twitterCard:"summary_large_image"}),K({script:[{type:"application/ld+json",innerHTML:JSON.stringify({"@context":l.site.schema.context,"@type":"SoftwareApplication",name:`${l.site.name} Smart Document QA`,applicationCategory:"ArtificialIntelligenceApplication",operatingSystem:"Any",description:r("ai_question_answering.desc",m.value)})}]});const i=a(""),p=a(""),d=a([]),_=a(!1),v=a(!1),k=a(0),b=a(""),q=a(!1),C=a(""),M=s=>{C.value=s,q.value=!0};let h=null;const T=async()=>{if(!h){v.value=!0,b.value="Initiating...";try{h=await G("question-answering","Xenova/distilbert-base-uncased-distilled-squad",{progress_callback:s=>{s.status==="progress"?(k.value=Math.round(s.progress||0),b.value=`Loading model... ${k.value}%`):s.status==="ready"&&(b.value="Ready")}})}catch(s){console.error("Failed to load model:",s),d.value.push({role:"ai",content:`Error loading model: ${s}`})}finally{v.value=!1}}},x=a(null),j=async()=>{setTimeout(()=>{x.value&&(x.value.scrollTop=x.value.scrollHeight)},100)};F(d,()=>{j()},{deep:!0}),F(_,()=>{j()});const S=s=>{const t=s.target;if(t.files&&t.files[0]){const g=t.files[0],w=new FileReader;w.onload=n=>{if(n.target?.result){const y=n.target.result;i.value?i.value+=` 2 3`+y:i.value=y}},w.readAsText(g)}},A=async()=>
3{if(!i.value.trim()){M(r("ai_question_answering.error_no_context"));return}if(!p.value.trim()){M(r("ai_question_answering.error_no_question"));return}h||await T();const s=p.value;d.value.push({role:"user",content:s}),p.value="",_.value=!0;try{const t=await h(s,i.value);console.log("Answer: ",t);const g=t.answer&&t.answer.trim().length>0?t.answer:r("ai_question_answering.error_no_answer");d.value.push({role:"ai",content:g,score:t.score})}catch(t){console.error(t),d.value.push({role:"ai",content:"An error occurred while analyzing."})}finally{_.value=!1}},L=()=>{i.value="",d.value=[],p.value=""};return(s,t)=>{const g=Q,w=X;return c(),u("div",W,[$(g),t[14]||(t[14]=e("div",{class:"absolute top-0 left-0 w-full h-[400px] z-0 pointer-events-none"},[e("div",{class:"absolute inset-0 bg-cover bg-center bg-no-repeat",style:{"background-image":"url('/images/banners/ai-qa-banner.jpg')"}}),e("div",{class:"absolute inset-0 bg-gradient-to-b from-white/30 via-[#F8F9FA]/80 to-[#F8F9FA]"})],-1)),e("div",Y,[e("div",Z,[e("h1",ee,o(s.$t("ai_question_answering.title")),1),e("p",te,o(s.$t("ai_question_answering.subtitle")),1),e("div",se,o(s.$t("ai_question_answering.english_only")),1)]),e("div",oe,[e("div",ne,[e("div",le,[e("label",ae,[t[3]||(t[3]=e("svg",{class:"w-5 h-5 text-red-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})],-1)),V(" "+o(s.$t("ai_question_answering.context_label")),1)]),e("div",ie,[e("input",{type:"file",onChange:S,accept:".txt,.md,.json,.csv",class:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"},null,32),e("button",re,o(s.$t("ai_question_answering.file_upload_label")),1)])]),z(e("textarea",{"onUpdate:modelValue":t[0]||(t[0]=n=>i.value=n),placeholder:s.$t("ai_question_answering.context_placeholder"),class:"flex-grow w-full resize-none border border-slate-200 rounded-xl p-4 focus:outline-none focus:border-red-500 focus:ring-1 focus:ring-red-500 transition-all font-mono text-sm leading-relaxed"},null,8,de),[[B,i.value]])]),e("div",ue,[v.value?(c(),u("div",ce,[t[4]||(t[4]=e("div",{class:"w-16 h-16 border-4 border-red-100 border-t-red-500 rounded-full animate-spin mb-4"},null,-1)),e("p",pe,o(s.$t("ai_question_answering.loading_model")),1),k.value>0?(c(),u("p",me,o(b.value),1)):f("",!0)])):f("",!0),e("div",_e,[e("label",ge,[t[5]||(t[5]=e("svg",{class:"w-5 h-5 text-red-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})],-1)),V(" "+o(s.$t("ai_question_answering.chat_label")),1)]),e("button",{onClick:L,class:"text-sm font-medium text-slate-400 hover:text-red-500 transition-colors"},o(s.$t("ai_question_answering.clear_btn")),1)]),e("div",{ref_key:"chatContainer",ref:x,class:"flex-grow overflow-y-auto space-y-4 mb-4 pr-2 scroll-smooth"},[d.value.length===0?(c(),u("div",fe,[t[6]||(t[6]=e("svg",{class:"w-16 h-16 text-slate-300 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-3.582 8-8 8H8l-4 4v-4H4c-4.418 0-8-3.582-8-8s3.582-8 8-8h9c4.418 0 8 3.582 8 8z"})],-1)),e("p",ve,o(s.$t("ai_question_answering.guide.step1_desc")),1)])):f("",!0),(c(!0),u(P,null,R(d.value,(n,y)=>(c(),u("div",{key:y,class:H(["flex flex-col max-w-[90%]",n.role==="user"?"self-end items-end ml-auto":"self-start items-start mr-auto"])},[e("div",{class:H(["px-4 py-3 rounded-2xl text-sm font-medium leading-relaxed",n.role==="user"?"bg-red-500 text-white rounded-br-none":"bg-slate-100 text-slate-800 rounded-bl-none"])},o(n.content),3),n.role==="ai"&&n.score!==void 0?(c(),u("div",be,o(s.$t("ai_question_answering.score_label"))+" "+o((n.score*100).toFixed(1))+"% ",1)):f("",!0)],2))),128)),_.value?(c(),u("div",he,[t[7]||(t[7]=e("div",{class:"w-2 h-2 bg-slate-400 rounded-full animate-bounce",style:{"animation-delay":"0s"}},null,-1)),t[8]||(t[8]=e("div",{class:"w-2 h-2 bg-slate-400 rounded-full animate-bounce",style:{"animation-delay":"0.2s"}},null,-1)),t[9]||(t[9]=e("div",{class:"w-2 h-2 bg-slate-400 rounded-full animate-bounce",style:{"animation-delay":"0.4s"}},null,-1)),e("span",null,o(s.$t("ai_question_answering.processing")),1)])):f("",!0)],512),e("div",xe,[e("div",we,[z(e("input",{"onUpdate:modelValue":t[1]||(t[1]=n=>p.value=n),type:"text",onKeydown:J(A,["enter"]),placeholder:s.$t("ai_question_answering.chat_placeholder"),class:"flex-grow px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:outline-none focus:border-red-500 focus:ring-1 focus:ring-red-500 text-slate-900"},null,40,ye),[[B,p.value]]),e("button",{onClick:A,disabled:_.value||v.value||!i.value,class:"px-6 py-3 bg-slate-900 hover:bg-red-600 disabled:bg-slate-300 disabled:cursor-not-allowed text-white font-bold rounded-xl transition-colors flex items-center gap-2"},[e("span",null,o(s.$t("ai_question_answering.ask_btn")),1),t[10]||(t[10]=e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"})],-1))],8,ke)])])])]),e("div",qe,[e("div",$e,[t[11]||(t[11]=e("div",{class:"w-10 h-10 rounded-full bg-red-50 text-red-500 flex items-center justify-center mb-4"},[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})])],-1)),e("h3",Ce,o(s.$t("ai_question_answering.features.local")),1),e("p",Me,o(s.$t("ai_question_answering.features.local_desc")),1
3)]),e("div",je,[t[12]||(t[12]=e("div",{class:"w-10 h-10 rounded-full bg-blue-50 text-blue-500 flex items-center justify-center mb-4"},[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 10V3L4 14h7v7l9-11h-7z"})])],-1)),e("h3",Ae,o(s.$t("ai_question_answering.features.smart")),1),e("p",Fe,o(s.$t("ai_question_answering.features.smart_desc")),1)]),e("div",ze,[t[13]||(t[13]=e("div",{class:"w-10 h-10 rounded-full bg-emerald-50 text-emerald-500 flex items-center justify-center mb-4"},[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})])],-1)),e("h3",Ve,o(s.$t("ai_question_answering.features.versatile")),1),e("p",Be,o(s.$t("ai_question_answering.features.versatile_desc")),1)])])]),$(w),$(O,{show:q.value,"onUpdate:show":t[2]||(t[2]=n=>q.value=n),message:C.value},null,8,["show","message"])])}}});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.