1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[49581],{49581:(e,t,s)=>{s.r(t),s.d(t,{default:()=>i});var a=s(95155),l=s(12115),r=s(50910),n=s(40993);function i({query:e,results:t,onClose:s}){let c=(0,r.c)("search"),[d,x]=(0,l.useState)([]),[m,o]=(0,l.useState)(""),[p,h]=(0,l.useState)([]),[u,j]=(0,l.useState)(!1),[f,N]=(0,l.useState)("");(0,l.useEffect)(()=>{fetch("/v1/models").then(e=>e.json()).then(e=>{let t=(e?.data||[]).filter(e=>e.id.toLowerCase().includes("rerank")).map(e=>({value:e.id,label:e.id}));x(t),t.length>0&&o(t[0].value)}).catch(()=>{})},[]);let b=async()=>{j(!0),N("");try{let s=await fetch("/api/v1/rerank",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:m,query:e,documents:t.map(e=>e.snippet),top_n:t.length})}),a=await s.json();if(!s.ok)return void N(a.error?.message||a.error||`Error ${s.status}`);let l=(a.results||[]).map((e,s)=>{let a=e.index;return{index:s,originalIndex:a,title:t[a]?.title||"",snippet:t[a]?.snippet||"",score:e.relevance_score,delta:a-s}});h(l)}catch(e){N(e.message||"Rerank failed")}finally{j(!1)}},v=0===d.length;return(0,a.jsxs)("div",{className:"bg-surface border border-border rounded-lg overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center px-4 py-2.5 border-b border-border",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-main flex items-center gap-1.5",children:["â
",c("rerankResults")]}),(0,a.jsx)("button",{onClick:s,className:"text-text-muted text-xs hover:text-text-main",children:"â"})]}),(0,a.jsx)("div",{className:"p-4",children:v?(0,a.jsx)("p",{className:"text-xs text-text-muted",children:c("noRerankModels")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex gap-2 items-end mb-3",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("label",{className:"block text-[10px] text-text-muted uppercase tracking-wider mb-1",children:c("rerankModel")}),(0,a.jsx)(n.l6,{value:m,onChange:e=>o(e.target.value),options:d,className:"w-full"})]}),(0,a.jsx)(n.$n,{variant:"primary",onClick:b,disabled:u||!m,children:u?"Reranking...":c("rerank")})]}),f&&(0,a.jsx)("p",{className:"text-xs text-error mb-2",children:f}),p.length>0&&(0,a.jsx)("div",{className:"space-y-2",children:p.map(e=>{var t;return(0,a.jsxs)("div",{className:"flex items-start gap-3 p-2 bg-bg-alt rounded-lg",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center min-w-[32px]",children:[(0,a.jsxs)("span",{className:"text-xs font-medium text-text-main",children:["#",e.index+1]}),(0,a.jsx)("span",{className:"text-[10px]",children:(t=e.delta)>0?(0,a.jsxs)("span",{className:"text-success",children:["â",t]}):t<0?(0,a.jsxs)("span",{className:"text-error",children:["â",Math.abs(t)]}):(0,a.jsx)("span",{className:"text-text-muted",children:"="})})]}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-text-main",children:e.title}),(0,a.jsx)("div",{className:"text-[10px] text-text-muted mt-0.5 line-clamp-2",children:e.snippet})]}),(0,a.jsx)("span",{className:"text-[10px] text-accent whitespace-nowrap",children:e.score.toFixed(4)})]},e.index)})})]})})]})}}}]);
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.