PageSourceSearch

https://emunshi.ai/assets/Research-Ddti4lGb.js

js emunshi.ai collected 2026-10-05 12:34:32 UTC 17,714 bytes, 6 lines download raw bytes

1import{y as R,x as L,B,o as K,r as c,l as e,L as M,g as P,f as S}from"./index-CnQbcj9a.js";import{S as U}from"./SendToWorkspace-OiOPbGHA.js";import{P as F}from"./PageHeader-i1eWOcee.js";import{E,C as H}from"./Card-NktbqJue.js";import{B as b}from"./Button-DLSS3qle.js";import{C as O}from"./Chip-COyj_SBG.js";import{F as $}from"./Field-BGMwPsiI.js";import{M as G}from"./Modal-7OrR8bQH.js";function ie(){var x;const{id:t}=R(),n=L(),r=B(),o=K(),[s,u]=c.useState(null),[i,m]=c.useState(null),[v,y]=c.useState(!1),[N,g]=c.useState(""),[j,d]=c.useState(!1),w=c.useRef(null);async function p(){try{const a=await S.get("/research/threads");u(a.data.threads||[])}catch{u([])}}c.useEffect(()=>{p()},[]);async function C(a){if(!a){m(null);return}y(!0);try{const h=await S.get(`/research/threads/${a}`);m(h.data.thread)}catch{r.error("Could not load thread."),m(null)}finally{y(!1)}}c.useEffect(()=>{C(t)},[t]),c.useEffect(()=>{var a;(a=w.current)==null||a.scrollIntoView({behavior:"smooth"})},[(x=i==null?void 0:i.messages)==null?void 0:x.length,j]);async function A(){var h,I;const a=N.trim();if(a){d(!0),g("");try{const k=await S.post("/research/chat",{threadId:(i==null?void 0:i.id)||null,message:a});if(!i)await p(),n(`/research/${k.data.threadId}`,{replace:!0}),await C(k.data.threadId);else{const T=[...i.messages||[],{role:"user",content:a,ts:new Date().toISOString()},{role:"assistant",content:k.data.reply,toolUses:k.data.toolUses,ts:new Date().toISOString()}];m({...i,messages:T,turnCount:(i.turnCount||0)+1}),await p()}}catch(k){r.error(((I=(h=k.response)==null?void 0:h.data)==null?void 0:I.message)||"Chat failed."),g(a)}finally{d(!1)}}}async function l(a){var I,k;if(await o({title:"Delete this thread?",danger:!0,confirmLabel:"Delete"}))try{await S.delete(`/research/threads/${a}`),await p(),(i==null?void 0:i.id)===a&&(m(null),n("/research",{replace:!0}))}catch(T){r.error(((k=(I=T.response)==null?void 0:I.data)==null?void 0:k.message)||"Could not delete.")}}const f=()=>{m(null),n("/research"),g("")};return e.jsxs("div",{className:"flex flex-col h-[calc(100vh-63px)] md:h-[calc(100vh-63px)] min-h-0",children:[e.jsx(F,{className:"!static",title:"Research chat",subtitle:"Every proposition grounded in a real, verified authority — no invented citations, ever",actions:e.jsxs(e.Fragment,{children:[i&&e.jsx(Y,{threadId:i.id}),e.jsx(b,{variant:"secondary",onClick:f,children:"New thread"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsxs("aside",{className:"hidden md:block w-[250px] shrink-0 bg-surface border-r border-line overflow-y-auto px-2.5 py-3.5",children:[e.jsx(E,{muted:!0,className:"px-2 pb-2",children:"Threads"}),s?s.length===0?e.jsx("p",{className:"px-2 text-xs text-muted leading-relaxed",children:"No threads yet. Start by asking a legal-research question →"}):s.map(a=>e.jsxs(M,{to:`/research/${a.id}`,className:P("group flex items-start gap-2 px-2.5 py-2 rounded-ctl mb-0.5 no-underline hover:no-underline text-inherit",(i==null?void 0:i.id)===a.id?"bg-accent-wash":"hover:bg-[#f6f5f1]"),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-ink truncate leading-snug",children:a.title}),e.jsxs("div",{className:"mt-0.5 text-[11px] text-muted-2",children:[a.turnCount," turn",a.turnCount===1?"":"s"," · ",new Date(a.updatedAt).toLocaleDateString("en-IN",{day:"numeric",month:"short"})]})]}),e.jsx("button",{type:"button",onClick:h=>{h.preventDefault(),l(a.id)},className:"opacity-0 group-hover:opacity-100 text-xs text-muted hover:text-danger","aria-label":"Delete thread",children:"×"})]},a.id)):e.jsx("p",{className:"px-2 text-xs text-muted",children:"Loading…"})]}),e.jsxs("main",{className:"flex-1 min-w-0 flex flex-col min-h-0",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-5 md:px-[34px] py-6",children:e.jsxs("div",{className:"max-w-[860px] mx-auto flex flex-col gap-[18px]",children:[!i&&!v&&!t&&!j&&e.jsx(z,{onPickExample:a=>g(a)}),v&&e.jsx("p",{className:"text-sm text-muted",children:"Loading…"}),!i&&j&&e.jsx(D,{}),i&&(i.messages||[]).map((a,h)=>e.jsx(W,{m:a},h)),i&&j&&e.jsx(D,{}),e.jsx("div",{ref:w})]})}
1),e.jsx(q,{input:N,setInput:g,busy:j,onSend:A})]})]})]})}function z({onPickExample:t}){const n=["What's the latest SC view on Section 138 NI Act service of notice — Sundaram Finance Ltd v Lakshmi Tholasiappan and after?","Cases on quashing FIR under s.482 CrPC / s.528 BNSS for matrimonial disputes — Bhajan Lal categories applied post-Geeta Mehrotra.","Sarla Verma multiplier — is it still binding after Pranay Sethi (2017) and Magma General v Nanu Ram (2018)?","Can a Section 24 HMA interim maintenance order be passed when the husband is the applicant? Gender-neutrality post 2010 amendment.","Bail jurisprudence for economic offences — post-Satender Kumar Antil principles for s.45 PMLA."];return e.jsxs("div",{className:"py-8 max-w-2xl",children:[e.jsx("h2",{className:"m-0 font-serif text-[26px] font-semibold text-ink",children:"Ask the law"}),e.jsx("p",{className:"mt-2 text-md text-ink-3 leading-relaxed",children:"Citation-backed legal-research chat. Every answer is sourced from BNS / BNSS / BSA statutes or Indian Kanoon judgments — no invented section numbers, no hallucinated case names."}),e.jsx(E,{className:"mt-6 mb-2",children:"Try one of these"}),e.jsx("div",{className:"flex flex-col gap-2",children:n.map((r,o)=>e.jsx("button",{type:"button",onClick:()=>t(r),className:"text-left rounded-[10px] bg-surface border border-line hover:border-accent px-4 py-3 text-sm text-ink-2 leading-relaxed transition-colors",children:r},o))})]})}function q({input:t,setInput:n,busy:r,onSend:o}){function s(u){u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),o())}return e.jsx("div",{className:"shrink-0 border-t border-line bg-surface-2 px-5 md:px-[34px] pt-3.5 pb-[18px]",children:e.jsxs("div",{className:"max-w-[860px] mx-auto",children:[e.jsxs("div",{className:"flex gap-2.5 items-stretch",children:[e.jsx("textarea",{rows:2,value:t,onChange:u=>n(u.target.value),onKeyDown:s,placeholder:r?"Researching… (10–30 s)":"Ask in English, हिंदी or ਪੰਜਾਬੀ — answers cite only verified authorities…",disabled:r,className:"input flex-1 !rounded-[10px] !bg-surface !px-4 !py-3 text-md resize-none"}),e.jsx(b,{onClick:o,disabled:r||!t.trim(),size:"lg",className:"!rounded-[10px] !px-6 self-stretch",children:r?"…":"Send"})]}),e.jsx("div",{className:"mt-2 text-[11px] text-muted-2",children:"Research assistance, not legal advice. Grounded in Indian Kanoon; if no authority exists for a proposition, the answer says so instead of inventing one."})]})})}function D(){const t=["Searching Indian Kanoon…","Reviewing precedents…","Cross-checking BNS / BNSS / BSA…","Verifying citations…","Reading judgments…","Drafting the answer…","Almost there…"],[n,r]=c.useState(0);return c.useEffect(()=>{const o=setInterval(()=>r(s=>(s+1)%t.length),3500);return()=>clearInterval(o)},[]),e.jsxs("div",{className:"self-start inline-flex items-center gap-2.5 bg-surface border border-line rounded-[14px] rounded-bl-[4px] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-muted",children:t[n]}),e.jsxs("span",{className:"inline-flex gap-[3px]","aria-hidden":"true",children:[e.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-accent"}),e.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-[#e0b48a]"}),e.jsx("span",{className:"w-[5px] h-[5px] rounded-full bg-[#f0dcc4]"})]}),e.jsx("span",{className:"text-[10px] text-muted-2",children:"usually 15–40 sec"})]})}function _(t){var r,o;const n=[];for(const s of t.toolUses||[])(r=s.result)!=null&&r.verified?n.push({ok:!0,title:s.result.title,url:s.result.url}):(o=s.result)!=null&&o.error&&s.input&&(s.input.citation||s.input.query)&&n.push({ok:!1,title:s.input.citation||s.input.query,note:s.result.error});return n}function W({m:t}){var o;if(t.role==="user")return e.jsx("div",{className:"self-end max-w-[620px] bg-side text-[#f0efec] rounded-[14px] rounded-br-[4px] px-[17px] py-[13px] text-md leading-relaxed whitespace-pre-wrap",children:t.content});const n=_(t),r=n.filter(s=>s.ok).length;return e.jsxs("div",{className:"self-start max-w-[720px] min-w-0 w-full",children:[e.jsx("div",{className:"bg-surface border border-line rounded-[14px] rounded-bl-[4px] px-5 py-[17px] text-md leading-[1.75] text-ink-2 whitespace-pre-wrap",children:V(t.content)}),n.length>0&&e.jsxs(H,{flush:!0,className:"mt-2",children:[e.jsx("div",{className:"flex items-baseline gap-2 px-4 py-2.5 border-b border-line-2",children:e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[.6px] text-muted",children:"Authorities cited — verified against Indian Kanoon"})}),n.map((s,u)=>e.jsxs("div",{className:"flex items-start gap-2.5 px-4 py-2.5 border-b border-line-3 last:border-b-0",children:[e.jsxs(O,{tone:s.ok?"ok":"warn",className:"shrink-0 font-mono",children:[s.ok?"✓":"⚠"," ",u+1]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[s.url?e.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-ink hover:text-accent-link no-underline",children:s.title}):e.jsx("span",{className:"text-sm font-medium text-ink",children:s.title}),s.note&&e.jsx("div",{className:"text-xs text-muted mt-0.5",children:s.note})]}),s.url&&e.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer",className:"shrink-0 text-xs font-semibold text-accent-link",children:"Open ↗"}),e.jsx(U,{text:`${s.title}${s.note?` — ${s.note}`:""}`,source:{url:s.url||void 0,label:"Research chat · authority",verified:!!s.ok},className:"shrink-0 text-xs font-semibold text-accent-link"})]},u))]}),((o=t.toolUses)==null?void 0:o.length)>0&&e.jsxs("div",{className:"mt-2 pl-1 flex items-center gap-3.5 text-[11px] text-muted-2",children:[e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer hover:text-ink",children:[t.toolUses.length," tool call",t.toolUses.length===1?"":"s"]}),e.jsx("ul",{className:"mt-2 space-y-1.5",children:t.toolUses.map((s,u)=>{var i,m,v,y,N,g,j,d;return e.jsxs("li",{className:"border-l-2 border-line pl-2",children:[e.jsxs("div",{className:"font-mono text-[10px] text-muted",children:[s.name,"(",JSON.stringify(s.input).slice(0,100),")"]}),((m=(i=s.result)==null?void 0:i.hits)==null?void 0:m.length)>0&&e.jsxs("div",{children:["→ ",s.result.hits.length," statute hits"]}),((y=(v=s.result)==null?void 0:v.docs)==null?void 0:y.length)>0&&e.jsxs("div",{children:["→ ",s.result.docs.length," IK hits"]}),((g=(N=s.result)==null?void 0:N.chunks)==null?void 0:g.length)>0&&e.jsxs("div",{children:["→ ",s.result.chunks.length," case-file chunks"]}),((j=s.result)==null?void 0:j.verified)&&e.jsxs("div",{className:"text-ok",children:["→ verified: ",e.jsx("a",{href:s.result.url,target:"_blank",rel:"noreferrer",className:"underline",children:s.result.title})]}),((d=s.result)==null?void 0:d.error)&&e.jsxs("div",{className:"text-danger",children:["→ ",s.result.error]})]},u)})})]}),n.length>0&&e.jsxs("span",{className:"ml-auto",children:[n.length," authorit",n.length===1?"y":"ies"," · ",r," verified ✓",n.length-r>0?` · ${n.length-r} caution ⚠`:""]})]})]})}function V(t){return t?String(t).split(/(https?:\/\/[^\s)]+)/g).map((r,o)=>/^https?:\/\//.test(r)?e.jsx("a",{href:r,target:"_blank",rel:"noreferrer",className:"text-accent-link underline break-all",children:r},o):r):null}function Y({threadId:t}){const n=B(),[r,o]=c.useState(!1),[s,u]=c.useState([]),[i,m]=c.useState(""),[v,y]=c.useState(!1),[N,g]=c.useState(null);c.useEffect(()=>{!r||s.length||S.get("/cases?limit=200").then(d=>u(d.data.items||d.data||[])).catch(()=>u([]))},[r,s.length]);async function j(){var d,w;y(!0),g(null);try{const p=await S.post(`/research/threads/${t}/to-brief`,{caseId:i||null});g(p.data)}catch(p){n.error(((w=(d=p.response)==null?void 0:d.data)==null?void 0:w.message)||"Brief generation failed.")}finally{y(!1)}}return e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"secondary",onClick:()=>o(!0),children:"Send to brief →"}),r&&e.jsxs(G,{size:"lg",onClose:()=>o(!1),title:"Build a Hearing Brief from this thread",children:[!N&&e.jsxs(e.Fragment,{children:[e.jsx($,{label:"Link to case (optional)",hint:"Linking a case gives Claude the matter context (parties, stage, court) so the brief is sharper.",children:e.jsxs("select",{value:i,onChange:d=>m(d.target.value),className:"input w-full",children:[e.jsx("option",{value:"",children:"(generic brief — no case bound)"}),s.map(d=>e.jsxs("option",{value:d.id,children:[d.title,d.caseNumber?` · ${d.caseNumber}`:""]},d.id))]})}),e.jsx(b,{onClick:j,disabled:v,className:"mt-4",children:v?"Generating…":"Generate brief"})]}),N&&e.jsx(J,{brief:N,onClose:()=>o(!1),onSavedHearing:()=>{o(!1),n.success("Hearing added to diary.")}})]})]})}function J({brief:t,onClose:n,onSavedHearing:r}){var C,A;const o=B(),[s,u]=c.useState(!1),[i,m]=c.useState(!1),[v,y]=c.useState(Q()),[N,g]=c.useState(t.court||""),[j,d]=c.useState("Pre-hearing brief — generated from research thread");async function w(){var l,f;if(!t.caseId){o.error("No case is linked to this brief — re-generate with a case selected.");return}u(!0);try{const x=[`THREAD: ${t.threadTitle||""}`,"",`SUMMARY:
2${t.summary||""}`,"","ANTICIPATED ARGUMENTS:",...(t.anticipatedArguments||[]).map((a,h)=>`${h+1}. ${a.point}
3   why: ${a.why}${a.authority?`
4   authority: ${a.authority}`:""}`),"","COUNTER-ARGUMENTS:",...(t.counterArguments||[]).map((a,h)=>`${h+1}. opp: ${a.opposingPoint}
5   reply: ${a.response}`),"","KILLER POINTS:",...(t.killerPoints||[]).map((a,h)=>`${h+1}. ${a}`),"","KEY CITATIONS:",...(t.keyCitations||[]).map(a=>`  - ${a}`)].join(`
6`);await S.post("/briefs/attach-hearing",{caseId:t.caseId,date:new Date(v).toISOString(),court:N||t.court||"court",purpose:j,notes:x.slice(0,19e3)}),r()}catch(x){o.error(((f=(l=x.response)==null?void 0:l.data)==null?void 0:f.message)||"Could not attach hearing.")}finally{u(!1)}}const p=({title:l,children:f,tone:x})=>e.jsxs("section",{children:[e.jsx(E,{className:P("mb-2",x==="danger"&&"!text-danger"),children:l}),f]});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs text-muted",children:[t.caseTitle?`For: ${t.caseTitle}`:"Generic brief"," · ",((C=t.anticipatedArguments)==null?void 0:C.length)||0," arguments · ",((A=t.citations)==null?void 0:A.length)||0," citations · ",t.tokensUsed," tokens"]}),e.jsx(p,{title:"Summary",children:e.jsx("p",{className:"m-0 text-md text-ink-2 leading-relaxed",children:t.summary})}),(t.anticipatedArguments||[]).length>0&&e.jsx(p,{title:"Anticipated arguments",children:e.jsx("ol",{className:"text-md space-y-2 list-decimal list-inside text-ink",children:t.anticipatedArguments.map((l,f)=>e.jsxs("li",{children:[e.jsx("span",{className:"font-medium",children:l.point}),l.why&&e.jsxs("div",{className:"text-ink-3 text-xs mt-0.5 ml-5",children:["why: ",l.why]}),l.authority&&e.jsx("div",{className:"text-xs text-accent-ink mt-0.5 ml-5 font-mono",children:l.authority})]},f))})}),(t.counterArguments||[]).length>0&&e.jsx(p,{title:"Counter-arguments",children:e.jsx("ul",{className:"text-md space-y-2",children:t.counterArguments.map((l,f)=>e.jsxs("li",{className:"border-l-2 border-line pl-3",children:[e.jsxs("div",{className:"text-ink-3",children:["Opposing: ",l.opposingPoint]}
6),e.jsxs("div",{className:"font-medium mt-0.5 text-ink",children:["Reply: ",l.response]}),l.authority&&e.jsx("div",{className:"text-xs text-accent-ink mt-0.5 font-mono",children:l.authority})]},f))})}),(t.killerPoints||[]).length>0&&e.jsx(p,{title:"Killer points",tone:"danger",children:e.jsx("ol",{className:"text-md space-y-1 list-decimal list-inside font-medium text-ink",children:t.killerPoints.map((l,f)=>e.jsx("li",{children:l},f))})}),(t.keyCitations||[]).length>0&&e.jsx(p,{title:"Key citations",children:e.jsx("ul",{className:"text-xs font-mono space-y-1",children:t.keyCitations.map((l,f)=>{const x=(t.citations||[]).find(a=>a.query===l);return e.jsxs("li",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"flex-1",children:l}),(x==null?void 0:x.verified)&&e.jsx("a",{href:x.url,target:"_blank",rel:"noreferrer",className:"text-ok",children:"✓ IK ↗"}),x&&!x.verified&&e.jsx("span",{className:"text-danger",children:"⚠ not found"})]},f)})})}),t.caseId&&e.jsx("section",{className:"border-t border-line-2 pt-3",children:i?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-semibold",children:"Add hearing"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[e.jsx($,{label:"When",children:e.jsx("input",{type:"datetime-local",value:v,onChange:l=>y(l.target.value),className:"input w-full"})}),e.jsx($,{label:"Court",children:e.jsx("input",{value:N,onChange:l=>g(l.target.value),className:"input w-full"})}),e.jsx($,{label:"Purpose",children:e.jsx("input",{value:j,onChange:l=>d(l.target.value),className:"input w-full"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{size:"sm",onClick:w,disabled:s,children:s?"Saving…":"Save hearing"}),e.jsx(b,{size:"sm",variant:"secondary",onClick:()=>m(!1),children:"Cancel"})]})]}):e.jsxs(b,{variant:"secondary",size:"sm",onClick:()=>m(!0),children:["+ Add as hearing in ",t.caseTitle]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-line-2",children:[e.jsx(b,{variant:"secondary",size:"sm",onClick:()=>window.print(),children:"🖨 Print"}),e.jsx(b,{size:"sm",onClick:n,children:"Done"})]})]})}function Q(){const t=new Date;t.setDate(t.getDate()+1),t.setHours(10,30,0,0);const n=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}export{ie 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.