1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9860],{29860:(e,t,r)=>{r.d(t,{default:()=>p});var a=r(95155),n=r(12115),s=r(81398),o=r(66271),i=r(78192),l=r(65229),c=r(35299),d=r(20908),u=r(7013),x=r(18085),g=r(26497),h=r(8751),b=r(48564);let m=()=>{let[e,t]=(0,n.useState)(!1),[r,s]=(0,n.useState)([]),[o,m]=(0,n.useState)(""),[f,p]=(0,n.useState)(!1),[v,y]=(0,n.useState)(!1),[w,j]=(0,n.useState)("en"),N=(0,n.useRef)(null),_=(0,b.l)(w,"hud"),E=[{text:_.preset_1_text,label:_.preset_1_label},{text:_.preset_2_text,label:_.preset_2_label},{text:_.preset_3_text,label:_.preset_3_label},{text:_.preset_4_text,label:_.preset_4_label}];(0,n.useEffect)(()=>{let e=()=>y(document.documentElement.classList.contains("dark"));e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),(0,n.useEffect)(()=>{let e=localStorage.getItem("language");("en"===e||"sw"===e||"fr"===e)&&j(e);let t=e=>{var t;let r="string"==typeof e.detail?e.detail:null==(t=e.detail)?void 0:t.language;("en"===r||"sw"===r||"fr"===r)&&j(r)};return window.addEventListener("languageChange",t),()=>window.removeEventListener("languageChange",t)},[]),(0,n.useEffect)(()=>{s([{role:"assistant",content:_.greeting}])},[w]),(0,n.useEffect)(()=>{var e;null==(e=N.current)||e.scrollIntoView({behavior:"smooth"})},[r,f]);let k=async e=>{if(!e.trim()||f)return;let t=e.trim();m(""),s(e=>[...e,{role:"user",content:t}]),p(!0);try{let e=await fetch("/api/openai-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:t,category:"Kenyan civic education, constitution, and public services (eCitizen, KRA, AGPO, HELB, Youth Fund)",maxWords:250})}),r=await e.json();if(r.error)throw Error(r.error);s(e=>[...e,{role:"assistant",content:r.content}])}catch(e){console.error("HUD Assistant error:",e),s(e=>[...e,{role:"assistant",content:'<span style="color:#EF4444">'.concat(_.error_msg,"</span>")}])}finally{p(!1)}};return(0,a.jsxs)("div",{className:"fixed bottom-6 right-6 z-50 font-sans pointer-events-none",children:[(0,a.jsx)(g.N,{children:e&&(0,a.jsxs)(h.P.div,{initial:{opacity:0,y:30,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:30,scale:.95},transition:{duration:.25,ease:"easeOut"},className:"w-[360px] sm:w-[380px] max-w-[calc(100vw-1.5rem)] h-[520px] max-h-[80vh] flex flex-col rounded-card border shadow-float pointer-events-auto overflow-hidden mb-4 ".concat(v?"bg-[#1a1a17]/95 border-white/10 text-white backdrop-blur-md":"bg-white/95 border-gray-200 text-gray-900 backdrop-blur-md"),children:[(0,a.jsxs)("div",{className:"p-4 flex items-center justify-between border-b ".concat(v?"border-white/10 bg-[#111110]/50":"border-gray-100 bg-gray-50/50"),children:[(0,a.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,a.jsx)("div",{className:"w-9 h-9 rounded-xl bg-orange-500 flex items-center justify-center text-white shadow-lg shadow-orange-500/20",children:(0,a.jsx)(i.A,{size:20})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-extrabold text-sm tracking-tight",children:_.title}),(0,a.jsx)("p",{className:"text-[10px] uppercase font-bold tracking-widest text-orange-500 opacity-90",children:"Sheria ya Vijana"})]})]}),(0,a.jsx)("button",{onClick:()=>t(!1),className:"p-1.5 rounded-full transition-colors ".concat(v?"hover:bg-white/10 text-gray-400 hover:text-white":"hover:bg-gray-200 text-gray-500 hover:text-gray-900"),"aria-label":_.close_label,children:(0,a.jsx)(l.A,{size:18})})]}),(0,a.jsxs)("div",{className:"flex-1 p-4 overflow-y-auto space-y-4 custom-scrollbar",children:[r.map((e,t)=>(0,a.jsx)("div",{className:"flex ".concat("user"===e.role?"justify-end":"justify-start"),children:(0,a.jsx)("div",{className:"max-w-[85%] rounded-2xl px-4 py-2.5 text-sm leading-relaxed shadow-sm ".concat("user"===e.role?"bg-orange-500 text-white rounded-br-none":v?"bg-[#22221e] border border-white/5 text-gray-100 rounded-bl-none":"bg-gray-100 text-gray-800 rounded-bl-none"),dangerouslySetInnerHTML:{__html:e.content}})},t)),f&&(0,a.jsx)("div",{className:"flex justify-start",children:(0,a.jsxs)("div",{className:"rounded-2xl px-4 py-3 text-sm flex items-center space-x-2 ".concat(v?"bg-[#22221e] border border-white/5 text-gray-400":"bg-gray-100 text-gray-500"),children:[(0,a.jsx)(c.A,{size:16,className:"animate-spin text-orange-500"}),(0,a.jsx)("span",{className:"font-medium text-xs",children:_.consulting})]})}),(0,a.jsx)("div",{ref:N})]}),r.length<=2&&(0,a.jsxs)("div",{className:"p-4 border-t border-b ".concat(v?"border-white/5 bg-[#111110]/20":"border-gray-50 bg-gray-50/20"),children:[(0,a.jsxs)("p",{className:"text-[10px] font-black uppercase tracking-widest text-orange-500 mb-2.5 flex items-center gap-1",children:[(0,a.jsx)(d.A,{size:10}),(0,a.jsx)("span",{children:_.suggested_topics})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:E.map((e,t)=>(0,a.jsxs)("button",{onClick:()=>k(e.text),className:"text-xs px-3 py-1.5 rounded-full border font-semibold flex items-center gap-1 transition-all ".concat(v?"border-white/10 hover:border-orange-500/50 hover:bg-orange-500/5 text-gray-300 hover:text-orange-400":"border-gray-200 hover:border-orange-500/50 hover:bg-orange-50 text-gray-700 hover:text-orange-600"),children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)(u.A,{size:12,className:"opacity-70"})]},t))})]}),(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),k(o)},className:"p-4 border-t flex gap-2 items-center ".concat(v?"border-white/10 bg-[#111110]/50":"border-gray-100 bg-gray-50/50"),children:[(0,a.jsx)("input",{type:"text",value:o,onChange:e=>m(e.target.value),placeholder:_.input_placeholder,className:"flex-grow px-4 py-2 border rounded-xl text-sm outline-none transition-all ".concat(v?"bg-[#111110] border-white/10 text-white focus:border-orange-500":"bg-white border-gray-200 text-gray-900 focus:border-orange-500")}),(0,a.jsx)("button",{type:"submit",disabled:!o.trim()||f,className:"p-2 rounded-xl transition-all flex items-center justify-center shadow-md ".concat(o.trim()&&!f?"bg-orange-500 hover:bg-orange-600 text-white hover:scale-105 active:scale-95 shadow-orange-500/20":"bg-gray-300 text-gray-400 cursor-not-allowed dark:bg-white/5"),"aria-label":_.send_label,children:(0,a.jsx)(x.A,{size:16})})]})]})}),(0,a.jsxs)(h.P.button,{layout:!0,onClick:()=>
1t(!e),className:"pointer-events-auto w-14 h-14 rounded-full bg-orange-500 text-white flex items-center justify-center shadow-float hover:scale-110 active:scale-90 transition-all group relative","aria-label":_.open_label,children:[(0,a.jsx)("span",{className:"absolute inset-0 rounded-full bg-orange-500 animate-ping opacity-25 group-hover:hidden"}),(0,a.jsx)(g.N,{mode:"wait",children:e?(0,a.jsx)(h.P.div,{initial:{rotate:-90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:90,opacity:0},transition:{duration:.15},children:(0,a.jsx)(l.A,{size:24})},"close"):(0,a.jsx)(h.P.div,{initial:{rotate:90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:-90,opacity:0},transition:{duration:.15},children:(0,a.jsx)(i.A,{size:24})},"chat")})]})]})};function f(e){let{isDark:t=!1}=e,r=(0,n.useRef)(null),s=(0,n.useRef)({x:-9999,y:-9999,active:!1}),o=(0,n.useRef)([]),i=(0,n.useRef)(0),l=(0,n.useRef)(t);return(0,n.useEffect)(()=>{l.current=t},[t]),(0,n.useEffect)(()=>{let e=r.current;if(!e)return;let t=e.getContext("2d");if(!t)return;let a=()=>{e.width=e.offsetWidth,e.height=e.offsetHeight;let{width:t,height:r}=e;o.current=[];let a=Math.floor(t/32),n=Math.floor(r/32),s=(t-32*a)/2+16,i=(r-32*n)/2+16;for(let e=0;e<n;e++)for(let t=0;t<a;t++){let r=s+32*t,a=i+32*e;o.current.push({x:r,y:a,ox:r,oy:a,vx:0,vy:0})}},n=t=>{let r=e.getBoundingClientRect(),a=t.clientX-r.left,n=t.clientY-r.top;s.current={x:a,y:n,active:a>=0&&a<=r.width&&n>=0&&n<=r.height}},c=()=>{s.current={x:-9999,y:-9999,active:!1}},d=()=>{let{width:r,height:a}=e,{x:n,y:c,active:u}=s.current,x=l.current?"rgba(253,252,240,":"rgba(27,36,50,";for(let e of(t.clearRect(0,0,r,a),o.current)){let r=n-e.x,a=c-e.y,s=Math.hypot(r,a),o=0,i=0;if(u&&s<150&&s>0){let e=(1-s/150)**1.8*.1;o=r*e,i=a*e}o+=(e.ox-e.x)*.06,i+=(e.oy-e.y)*.06,e.vx=(e.vx+o)*.72,e.vy=(e.vy+i)*.72,e.x+=e.vx,e.y+=e.vy;let l=u&&s<150?(1-s/150)*.75:0;t.beginPath(),t.arc(e.x,e.y,1.5,0,2*Math.PI),t.fillStyle="".concat(x).concat(l.toFixed(2),")"),t.fill()}i.current=requestAnimationFrame(d)};return a(),window.addEventListener("mousemove",n),window.addEventListener("mouseleave",c),window.addEventListener("resize",a),i.current=requestAnimationFrame(d),()=>{cancelAnimationFrame(i.current),window.removeEventListener("mousemove",n),window.removeEventListener("mouseleave",c),window.removeEventListener("resize",a)}},[]),(0,a.jsx)("canvas",{ref:r,className:"fixed inset-0 w-full h-full pointer-events-none z-[9999]","aria-hidden":"true"})}function p(e){let{children:t,className:r="",particles:i=!1,assistant:l=!0}=e,[c,d]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let e=()=>d(document.documentElement.classList.contains("dark"));e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),(0,a.jsxs)("div",{className:"brand-page ".concat(r),children:[i&&(0,a.jsx)(f,{isDark:c}),(0,a.jsx)(s.default,{}),(0,a.jsx)("div",{className:"relative z-10 flex min-h-0 flex-1 flex-col",children:t}),(0,a.jsx)(o.default,{}),l&&(0,a.jsx)(m,{})]})}}}]);
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.