PageSourceSearch

https://newtral.ai/_next/static/chunks/8124.5104a0879b8dc010.js

js newtral.ai collected 2026-10-05 14:24:54 UTC 46,059 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8124],{88015:function(e,t,r){r.d(t,{F3:function(){return i},Ic:function(){return a},J_:function(){return d},aZ:function(){return l},c9:function(){return o},g1:function(){return c},sI:function(){return s}}),r(83079);var n=r(12119),i=(0,n.$)("0ad751d73fbee4e732b8cf2955b98610d5b1ac57"),a=(0,n.$)("acbc821bf37618574689e9c2f132ed455872951f"),s=(0,n.$)("aa6192c00bd7244f908cc0b8452651eda531df3d"),l=(0,n.$)("c17a9b95758b4b4135901135019e56f88692cea2"),o=(0,n.$)("10fd33e016d8cdbf645f769258df4da7060770f5"),d=(0,n.$)("97a0e1cab45d6a82b40471b5f3bbec6f2c1130e4"),c=(0,n.$)("b65e33097ef680735797532547538800eb2c7219")},98124:function(e,t,r){r.r(t),r.d(t,{PeerExtractClient:function(){return T}});var n=r(57437),i=r(2265),a=r(23738),s=r(1192),l=r(72643),o=r(38208),d=r(55400),c=r(91746);let u=(0,r(95480).Z)("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]]);var p=r(33922),x=r(40677),g=r(28875),v=r(45466),f=r(19150),h=r(24754),y=r(54891),b=r(55972),m=r(41119),j=r(10887),w=r(71917),S=r(6144),k=r(5567),I=r(63853),z=r(88015),C=r(39469);let R={Environment:"var(--success)",Social:"var(--accent)",Governance:"var(--warning)",Compliance:"var(--error)",CSR:"var(--cat-12)",Economical:"var(--cat-11)"};function T(e){let{projectInstanceId:t,peers:r,metrics:a,files:s,vaultPool:l,existingTargets:o,initialAutoAcceptThreshold:d}=e,[c,u]=(0,i.useState)(0===s.length?"files":"extract"),[p,x]=(0,i.useState)(new Map),[g,v]=(0,i.useState)(!1),[f,h]=(0,i.useState)({done:0,total:0}),[y,b]=(0,i.useState)(d),m=(0,i.useRef)(null),j=0===r.length;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[(0,n.jsx)(E,{subTab:c,setSubTab:u,peerCount:r.length,fileCount:s.length,pendingReview:Array.from(p.values()).filter(e=>"pending-review"===e.reviewState).length}),j&&(0,n.jsx)(M,{noPeers:j}),"files"===c&&(0,n.jsx)(P,{peers:r,files:s,vaultPool:l,projectInstanceId:t}),"extract"===c&&(0,n.jsx)(B,{peers:r,metrics:a,files:s,existingTargets:o,rows:p,setRows:x,streaming:g,setStreaming:v,streamProgress:f,setStreamProgress:h,abortRef:m,autoAcceptThreshold:y,setAutoAcceptThreshold:b}),"review"===c&&(0,n.jsx)(J,{peers:r,rows:p,setRows:x,existingTargets:o})]})}function E(e){let{subTab:t,setSubTab:r,peerCount:i,fileCount:a,pendingReview:c}=e;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[(0,n.jsxs)("div",{style:{padding:"14px 18px",background:"var(--accent-subtle)",border:"1px solid color-mix(in srgb, var(--accent) 40%, transparent)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"flex-start",gap:12},children:[(0,n.jsx)("span",{style:{width:28,height:28,borderRadius:7,background:"var(--accent)",color:"white",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontSize:13},children:(0,n.jsx)(s.Z,{size:14})}),(0,n.jsxs)("div",{style:{flex:1},children:[(0,n.jsx)(j.Caps,{size:10,children:"EXTRACT METRICS FROM PEER REPORTS"}),(0,n.jsx)("div",{style:{fontSize:13,color:"var(--text-primary)",marginTop:2,lineHeight:1.5},children:"Upload (or attach) a peer's annual / sustainability report. Cortex converts it to markdown; Claude reads it one metric at a time. High-confidence answers flow straight into Benchmark; everything else queues for one-click review."})]})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:0,background:"var(--bg-elevated)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",padding:3,alignSelf:"flex-start"},children:[(0,n.jsxs)(_,{active:"files"===t,onClick:()=>r("files"),children:[(0,n.jsx)(l.Z,{size:12})," Files",(0,n.jsx)("span",{style:A,children:a})]}),(0,n.jsxs)(_,{active:"extract"===t,onClick:()=>r("extract"),children:[(0,n.jsx)(o.Z,{size:12})," Extract",(0,n.jsx)("span",{style:A,children:i})]}),(0,n.jsxs)(_,{active:"review"===t,onClick:()=>r("review"),children:[(0,n.jsx)(d.Z,{size:12})," Review",c>0&&(0,n.jsx)("span",{style:{...A,background:"var(--warning)",color:"var(--fg-on-solid)"},children:c})]})]})]})}function _(e){let{active:t,onClick:r,children:i}=e;return(0,n.jsx)("button",{onClick:r,style:{padding:"6px 14px",borderRadius:"var(--radius-sm)",background:t?"var(--bg-base)":"transparent",color:t?"var(--accent)":"var(--text-secondary)",border:t?"1px solid var(--border-subtle)":"1px solid transparent",fontSize:12.5,fontWeight:t?600:500,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:i})}let A={fontFamily:"var(--font-mono)",fontSize:10,padding:"1px 6px",borderRadius:999,background:"var(--bg-sunken)",color:"var(--text-tertiary)",marginLeft:2};function M(e){let{noPeers:t}=e;return(0,n.jsxs)("div",{style:{padding:"10px 14px",background:"var(--warning-bg)",border:"1px solid var(--warning)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:8,fontSize:12.5,color:"var(--warning)"},children:[(0,n.jsx)(c.Z,{size:14}),(0,n.jsx)("span",{children:t&&"No active peers picked yet - head to Peer Setup and pick up to 5 companies before extracting."})]})}function P(e){let{peers:t,files:r,vaultPool:a,projectInstanceId:s}=e,[l,o]=(0,i.useState)(!1),[d,c]=(0,i.useState)(!1),x=r.filter(e=>e.peerId).length,g=r.filter(e=>"ready"===e.status&&e.md).length;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10}
1,children:[(0,n.jsx)(K,{label:"ATTACHED",value:String(r.length),sub:"files in this project"}),(0,n.jsx)(K,{label:"TAGGED TO PEER",value:"".concat(x,"/").concat(r.length),sub:"bucketed for extraction"}),(0,n.jsx)(K,{label:"READY",value:String(g),sub:"MD available \xb7 Cortex done"}),(0,n.jsx)(K,{label:"VAULT POOL",value:String(a.length),sub:"files you can attach"})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,n.jsxs)("button",{onClick:()=>o(!0),disabled:0===a.length,style:ec(0===a.length),children:[(0,n.jsx)(u,{size:12,style:{marginRight:4}})," Attach from Vault"]}),(0,n.jsxs)("button",{onClick:()=>c(!0),style:ed(!1),children:[(0,n.jsx)(p.Z,{size:12,style:{marginRight:4}})," Upload report"]})]}),(0,n.jsx)("div",{style:{background:"var(--bg-elevated)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:(0,n.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{style:{background:"var(--bg-base)"},children:[(0,n.jsx)(Y,{width:32}),(0,n.jsx)(Y,{children:"FILE"}),(0,n.jsx)(Y,{width:170,children:"TAGGED PEER"}),(0,n.jsx)(Y,{width:140,children:"PIPELINE"}),(0,n.jsx)(Y,{width:90,align:"right",children:"SIZE"}),(0,n.jsx)(Y,{width:100,children:"UPLOADED"})]})}),(0,n.jsxs)("tbody",{children:[0===r.length&&(0,n.jsx)("tr",{children:(0,n.jsxs)("td",{colSpan:6,style:{padding:40,textAlign:"center"},children:[(0,n.jsx)("div",{style:{fontSize:13,color:"var(--text-secondary)",marginBottom:6},children:"No files attached to Peer Intel yet."}),(0,n.jsxs)("div",{style:{fontSize:11.5,color:"var(--text-tertiary)"},children:["Click ",(0,n.jsx)("strong",{children:"Upload report"})," for a new PDF, or ",(0,n.jsx)("strong",{children:"Attach from Vault"})," to pull an existing one in."]})]})}),r.map(e=>(0,n.jsx)(F,{file:e,peers:t},e.id))]})]})}),l&&(0,n.jsx)(Z,{peers:t,vaultPool:a,onClose:()=>o(!1)}),d&&(0,n.jsx)(L,{peers:t,projectInstanceId:s,onClose:()=>c(!1)})]})}function F(e){let{file:t,peers:r}=e,s=(0,a.t)(),l=(0,w.p)(),[o,d]=(0,i.useTransition)();return(0,n.jsxs)("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[(0,n.jsx)(ee,{children:(0,n.jsx)(er,{mime:t.mimeType})}),(0,n.jsxs)(ee,{children:[(0,n.jsx)("div",{style:{fontSize:12.5,fontWeight:500,color:"var(--text-primary)"},children:t.originalFilename}),(0,n.jsx)(j.NumMono,{size:10.5,color:"var(--text-tertiary)",children:t.mimeType})]}),(0,n.jsx)(ee,{children:(0,n.jsx)(N,{peers:r,currentPeerId:t.peerId,currentRelation:t.peerRelation,disabled:o,onChange:e=>{d(async()=>{var n,i;let a="peerId"in e?{sourceFileId:t.id,peerId:e.peerId}:"unrelated"in e?{sourceFileId:t.id,peerId:null,markUnrelated:!0}:{sourceFileId:t.id,peerId:null},o=await (0,z.Ic)(a);if(!o.ok){l.show({title:"Tag failed",body:o.error,tone:"error"});return}l.show({title:"peerId"in e?"Tagged to peer":"unrelated"in e?"Marked as not a peer report":"Tag cleared",body:"peerId"in e?"Now attributed to ".concat(null!==(i=null===(n=r.find(t=>t.id===e.peerId))||void 0===n?void 0:n.name)&&void 0!==i?i:"peer"):"unrelated"in e?"Will be skipped during extraction.":"",tone:"success"}),s.refresh()})}})}),(0,n.jsx)(ee,{children:(0,n.jsx)(U,{file:t})}),(0,n.jsx)(ee,{align:"right",children:(0,n.jsx)(j.NumMono,{size:11.5,color:"var(--text-secondary)",children:ex(t.sizeBytes)})}),(0,n.jsx)(ee,{children:(0,n.jsx)(j.NumMono,{size:11,color:"var(--text-tertiary)",children:new Date(t.createdAt).toLocaleDateString("en-IN",{day:"2-digit",month:"short"})})})]})}let D="__unrelated__";function N(e){let{peers:t,currentPeerId:r,currentRelation:i,disabled:a,onChange:s}=e,l="unrelated"===i,o=null!=r?r:l?D:"",d=r?{bg:"var(--accent-subtle)",fg:"var(--accent)",border:"color-mix(in srgb, var(--accent) 30%, transparent)"}:l?{bg:"color-mix(in srgb, var(--text-tertiary) 12%, transparent)",fg:"var(--text-secondary)",border:"var(--border-subtle)"}:{bg:"var(--bg-sunken)",fg:"var(--text-tertiary)",border:"var(--border-subtle)"};return(0,n.jsx)(S.D,{value:o,onChange:e=>{e===D?s({unrelated:!0}):""===e?s({clear:!0}):s({peerId:e})},disabled:a,placeholder:"- Untagged -",options:[...t.map(e=>({value:e.id,label:e.name})),{value:D,label:"- Not a peer report -"}],style:{padding:"4px 8px",fontSize:11.5,background:d.bg,color:d.fg,border:"1px solid ".concat(d.border),borderRadius:"var(--radius-sm)",width:"100%",fontWeight:500}})}function U(e){var t,r,i,a;let{file:s}=e,l="ready"===s.status&&null!=s.md,o="converting"===s.status||(null===(t=s.cortex)||void 0===t?void 0:t.status)==="in_progress",d="failed"===s.status||(null===(r=s.cortex)||void 0===r?void 0:r.status)==="failed",u=l&&null!=s.peerId,p="unrelated"===s.peerRelation,f=[{name:"Uploaded",done:!0,failed:!1,active:!1},{name:l?"Converted \xb7 ".concat(null!==(a=null===(i=s.cortex)||void 0===i?void 0:i.pagesProcessed)&&void 0!==a?a:"?","p"):o?"Convert
1ing…":d?"Failed":"Queued",done:l,failed:d,active:o},{name:u?"Ready":p?"Not a peer report":"Needs peer tag",done:u,failed:!1,active:p}];return(0,n.jsx)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:f.map((e,t)=>{let r=e.failed?"var(--error)":e.done?"var(--success)":e.active?"var(--accent)":"var(--text-tertiary)",i=e.failed?c.Z:e.done?x.Z:e.active?g.Z:v.Z;return(0,n.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,color:r,fontSize:10.5,fontFamily:"var(--font-mono)"},title:e.name,children:[(0,n.jsx)(i,{size:11}),1===t&&(0,n.jsx)("span",{style:{whiteSpace:"nowrap"},children:e.name})]},t)})})}function Z(e){let{peers:t,vaultPool:r,onClose:s}=e,l=(0,a.t)(),o=(0,w.p)(),[d,c]=(0,i.useState)(new Set),[u,p]=(0,i.useState)(""),[x,g]=(0,i.useState)(""),[v,y]=(0,i.useTransition)(),b=(0,i.useMemo)(()=>{let e=u.trim().toLowerCase();return e?r.filter(t=>t.filename.toLowerCase().includes(e)):r},[r,u]),m=e=>{c(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})};return(0,n.jsxs)(ei,{onClose:s,title:"Attach from org vault",subtitle:"Pick existing files. Optionally tag them all to one peer in this step (or leave untagged and tag in the table later).",width:720,children:[(0,n.jsxs)("div",{style:{padding:"12px 20px",borderBottom:"1px solid var(--border-subtle)",display:"flex",gap:10},children:[(0,n.jsxs)("div",{style:es,children:[(0,n.jsx)(f.Z,{size:13,color:"var(--text-tertiary)"}),(0,n.jsx)("input",{value:u,onChange:e=>p(e.target.value),placeholder:"Search filenames…",style:el})]}),(0,n.jsx)(S.D,{value:x,onChange:g,placeholder:"Tag to peer (optional)…",options:t.map(e=>({value:e.id,label:e.name})),style:{padding:"6px 10px",fontSize:12.5,border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",background:"var(--bg-base)",minWidth:200}})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"6px 8px",minHeight:200},children:0===b.length?(0,n.jsx)("div",{style:{padding:32,textAlign:"center",fontSize:12.5,color:"var(--text-tertiary)"},children:0===r.length?"No more org files left to attach.":"No files match your search."}):b.map(e=>{let t=d.has(e.id);return(0,n.jsxs)("button",{onClick:()=>m(e.id),style:{display:"grid",gridTemplateColumns:"18px 1fr 80px 80px",gap:10,alignItems:"center",width:"100%",textAlign:"left",padding:"8px 12px",borderRadius:"var(--radius-sm)",background:t?"color-mix(in srgb, var(--accent) 8%, transparent)":"transparent",border:"1px solid ".concat(t?"color-mix(in srgb, var(--accent) 30%, transparent)":"transparent"),cursor:"pointer",margin:"2px 0"},children:[(0,n.jsx)("div",{style:{width:16,height:16,borderRadius:3,border:"1.5px solid ".concat(t?"var(--accent)":"var(--border-default)"),background:t?"var(--accent)":"transparent",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:t&&(0,n.jsx)(h.Z,{size:11,color:"var(--fg-on-solid)"})}),(0,n.jsx)("span",{style:{fontSize:12.5,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.filename}),(0,n.jsx)(j.Caps,{size:10,children:e.status.toUpperCase()}),(0,n.jsx)(j.NumMono,{size:11,color:"var(--text-tertiary)",children:ex(e.sizeBytes)})]},e.id)})}),(0,n.jsx)(ea,{leftText:"".concat(d.size," SELECTED"),onCancel:s,onConfirm:()=>{if(0===d.size){s();return}y(async()=>{var e;let r=await (0,z.sI)({sourceFileIds:Array.from(d),peerId:x||null});if(!r.ok){o.show({title:"Attach failed",body:r.error,tone:"error"});return}o.show({title:"".concat(r.attached," file").concat(1===r.attached?"":"s"," attached"),body:x?"Tagged to ".concat(null===(e=t.find(e=>e.id===x))||void 0===e?void 0:e.name):"Tag them to a peer to start extracting",tone:"success"}),l.refresh(),s()})},confirmLabel:v?"Attaching…":"Attach ".concat(d.size||"").trim(),pending:v,disabled:0===d.size})]})}function L(e){let{peers:t,projectInstanceId:r,onClose:s}=e,l=(0,a.t)(),o=(0,w.p)(),d=(0,i.useRef)(null),[c,u]=(0,i.useState)(null),[p,x]=(0,i.useState)(""),[g,v]=(0,i.useState)(!1),[f,h]=(0,i.useState)(0),[y,b]=(0,i.useState)(null),m=async()=>{if(!c){b("Pick a PDF first.");return}if(!p){b("Tag this report to one of your peer buckets.");return}b(null),v(!0);try{let e;let t=await (0,I.O)(c).catch(()=>void 0),n=await (0,k.X7)({filename:c.name,size_bytes:c.size,mime_type:c.type||void 0,kind:"Report",project_instance_ids:[r],sha256:t});if(!n.ok)throw Error(n.error);if(n.reused)e=n.source_file_id;else{await new Promise((e,t)=>
1{let r=new XMLHttpRequest;r.upload.addEventListener("progress",e=>{e.lengthComputable&&h(Math.round(e.loaded/e.total*100))}),r.addEventListener("load",()=>{r.status>=200&&r.status<300?e():t(Error("Upload failed: HTTP ".concat(r.status)))}),r.addEventListener("error",()=>t(Error("Network error during upload"))),r.open("PUT",n.signed_url),c.type&&r.setRequestHeader("Content-Type",c.type),r.send(c)}).catch(async e=>{try{await (0,k.wq)({source_file_id:n.source_file_id})}catch(e){}throw e}),h(100);let t=await (0,k.x7)({source_file_id:n.source_file_id});if(!t.ok)throw Error(t.error);e=t.source_file_id}let i=await (0,z.Ic)({sourceFileId:e,peerId:p});i.ok||o.show({title:"Uploaded, but tagging failed",body:i.error,tone:"error"}),o.show({title:"Report uploaded",body:n.reused?"Ready now.":'Cortex is converting it now. Refresh in a minute to see "Ready".',tone:"success"}),l.refresh(),s()}catch(e){b(e instanceof Error?e.message:"Upload failed.")}finally{v(!1)}};return(0,n.jsxs)(ei,{onClose:s,title:"Upload report",subtitle:"Pick a PDF (annual / sustainability report) and which peer bucket it belongs to. We hand it to Cortex for conversion and you'll be able to extract metrics within a minute or two.",width:560,children:[(0,n.jsxs)("div",{style:{padding:"14px 20px",display:"flex",flexDirection:"column",gap:14},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(j.Caps,{size:10,style:{display:"block",marginBottom:6},children:"PEER BUCKET"}),(0,n.jsx)(S.D,{value:p,onChange:x,disabled:g,placeholder:"- Select peer -",options:t.map(e=>({value:e.id,label:e.name})),style:{padding:"8px 10px",fontSize:13,border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",background:"var(--bg-base)",width:"100%"}})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(j.Caps,{size:10,style:{display:"block",marginBottom:6},children:"FILE"}),(0,n.jsx)("input",{ref:d,type:"file",accept:".pdf,.docx,.pptx,.html,.htm,.md",disabled:g,onChange:e=>{var t,r;return u(null!==(r=null===(t=e.target.files)||void 0===t?void 0:t[0])&&void 0!==r?r:null)},style:{fontSize:12.5,width:"100%"}}),c&&(0,n.jsxs)("div",{style:{marginTop:6,fontSize:11.5,color:"var(--text-tertiary)"},children:[c.name," \xb7 ",ex(c.size)]})]}),g&&c&&(0,n.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-secondary)"},children:[f<100?(0,n.jsx)(C.eP,{value:f,px:14,label:"Uploading ".concat(c.name)}):(0,n.jsx)(C.bw,{size:"xs",tone:"current",px:14}),(0,n.jsx)("span",{style:{fontVariantNumeric:"tabular-nums"},children:f<100?"Uploading ".concat(c.name," \xb7 ").concat(f,"%"):"Converting the document…"})]}),y&&(0,n.jsx)(en,{text:y})]}),(0,n.jsx)(ea,{onCancel:s,onConfirm:m,confirmLabel:g?f<100?"Uploading…":"Finalising…":"Upload & convert",pending:g,disabled:!c||!p})]})}function B(e){var t,r,a,s,l,d,c,u;let{peers:p,metrics:x,files:g,existingTargets:v,rows:f,setRows:h,streaming:b,setStreaming:m,streamProgress:j,setStreamProgress:k,abortRef:I,autoAcceptThreshold:T,setAutoAcceptThreshold:E}=e,_=(0,w.p)(),A=(0,i.useMemo)(()=>new Set(p.map(e=>e.id)),[p]),M=(0,i.useMemo)(()=>g.filter(e=>"ready"===e.status&&e.md&&e.peerId&&A.has(e.peerId)),[g,A]),[P,F]=(0,i.useState)(null!==(l=null===(t=M[0])||void 0===t?void 0:t.id)&&void 0!==l?l:null),D=null!==(d=M.find(e=>e.id===P))&&void 0!==d?d:null,N=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(!D||N.current===D.id)return;N.current=D.id;let e=D.priorResults,t=Object.keys(e);0!==t.length&&h(r=>{let n=new Map(r);for(let r of t){if(n.has(r))continue;let t=x.find(e=>e.id===r);if(!t)continue;let i=e[r],a=i.result,s=v.some(e=>e.peerId===D.peerId&&e.universalMetricId===r);n.set(r,{metric:t,status:"done",result:a,error:null,reviewState:s?"agent"===v.find(e=>e.peerId===D.peerId&&e.universalMetricId===r).capturedByActorType?"auto-accepted":"accepted":a.not_found?"rejected":"pending-review",targetId:null,arrivedAt:new Date(i.finishedAt||Date.now()).getTime()})}return n})},[D,x,v,h]);let U=(0,i.useMemo)(()=>{let e=new Set;for(let t of x)t.category&&e.add(t.category);return Array.from(e).sort()},[x]),[Z,L]=(0,i.useState)(new Set),B=e=>{L(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},W=(0,i.useMemo)(()=>0===Z.size?[]:x.filter(e=>e.category&&Z.has(e.category)),[x,Z]),H=(0,i.useMemo)(()=>{let e=new Map;if(!D)return e;for(let t of v)t.peerId===D.peerId&&e.set(t.universalMetricId,t);return e},[v,D]),q=(0,i.useCallback)(async e=>{if(!D||!D.peerId||!D.md){_.show({title:"Pick a ready, peer-tagged file",body:"",tone:"error"});return}let t=null!=e?e:W.map(e=>e.id);if(0===t.length){_.show({title:"Pick at least one category",body:"",tone:"error"});return}h(e=>{let r=new Map(e);for(let a of t){var n,i;let t=x.find(e=>e.id===a);t&&r.set(a,{metric:t,status:"queued",result:null,error:null,reviewState:null,targetId:null,arrivedAt:null!==(i=null===(n=e.get(a))||void 0===n?void 0:n.arrivedAt)&&void 0!==i?i:Date.now()})}return r}),k({done:0,total:t.length}),m(!0);let r=new AbortController;I.current=r;
1try{let e=await fetch("/api/peer-extract/stream",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({source_file_id:D.id,peer_id:D.peerId,uml_ids:t}),signal:r.signal});if(!e.ok||!e.body){let t=await e.text().catch(()=>""),r=null;try{let e=JSON.parse(t);e&&"string"==typeof e.error&&(r=e.error)}catch(e){}throw Error(null!=r?r:"Extraction failed (HTTP ".concat(e.status,"). ").concat(t.slice(0,200)))}let n=e.body.getReader(),i=new TextDecoder,a="",s=0;for(;;){let e;let{done:r,value:l}=await n.read();if(r)break;for(a+=i.decode(l,{stream:!0});(e=a.indexOf("\n\n"))>=0;){let r;let n=a.slice(0,e);a=a.slice(e+2);let i=n.split("\n").find(e=>e.startsWith("data:"));if(!i)continue;let l=i.slice(5).trim();if(!l)continue;try{r=JSON.parse(l)}catch(e){continue}let o=r;if("metric_started"===o.type&&"string"==typeof o.metric_id){let e=o.metric_id;h(t=>{let r=new Map(t),n=r.get(e);return n&&r.set(e,{...n,status:"streaming"}),r})}else if("metric_done"===o.type){let e=o.result,r=o.metric_id;if(!x.find(e=>e.id===r))continue;s++,k({done:s,total:t.length});let n="never"!==T&&("medium"===T?"high"===e.confidence||"medium"===e.confidence:"high"===e.confidence)&&!e.not_found&&"number"==typeof e.value&&Number.isFinite(e.value);h(t=>{let i=new Map(t),a=i.get(r);return a&&i.set(r,{...a,status:"done",result:e,error:null,reviewState:n?"auto-accepted":e.not_found?"rejected":"pending-review"}),i}),n&&D.peerId&&D.md&&(0,z.aZ)({peerId:D.peerId,universalMetricId:r,sourceFileId:D.id,mdRevisionId:D.md.revisionId,value:e.value,unit:e.unit,originalValue:e.original_value,originalUnit:e.original_unit,converted:e.converted,periodLabel:e.period,quote:e.quote,pageRefs:e.page_refs,confidence:e.confidence,reasoning:e.reasoning,rawResponse:""}).then(e=>{e.ok&&h(t=>{let n=new Map(t),i=n.get(r);return i&&n.set(r,{...i,targetId:e.targetId}),n})}).catch(()=>{})}else if("metric_error"===o.type){let e=o.metric_id;s++,k({done:s,total:t.length}),h(t=>{var r;let n=new Map(t),i=n.get(e);return i&&n.set(e,{...i,status:"error",error:String(null!==(r=o.message)&&void 0!==r?r:"extraction error")}),n})}else o.type}}}catch(e){if(r.signal.aborted)_.show({title:"Extraction stopped",body:"",tone:"info"});else{let t=e instanceof Error?e.message:String(e),r=t.length<160&&/[.!?]$/.test(t)&&!t.startsWith("Extraction failed (HTTP");_.show({title:r?t:"Extraction failed",body:r?"":t,tone:"error"})}}finally{m(!1),I.current=null}},[D,W,x,h,m,k,I,_,T]),G=(0,i.useMemo)(()=>{let e=Array.from(f.values());return e.sort((e,t)=>e.arrivedAt-t.arrivedAt),e},[f]);return 0===M.length?(0,n.jsxs)("div",{style:{padding:32,textAlign:"center",background:"var(--bg-elevated)",border:"1px dashed var(--border-strong)",borderRadius:"var(--radius-lg)",color:"var(--text-secondary)",fontSize:13},children:[(0,n.jsx)("div",{style:{marginBottom:6},children:"No files are ready to extract from yet."}),(0,n.jsxs)("div",{style:{fontSize:11.5,color:"var(--text-tertiary)"},children:['A file is "ready" once Cortex has finished converting it to markdown ',(0,n.jsx)("strong",{children:"and"})," it's tagged to one of your peer buckets. Use the ",(0,n.jsx)("strong",{children:"Files"})," tab to upload or attach a report."]})]}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,n.jsxs)(Q,{title:"SOURCE",children:[(0,n.jsx)(S.D,{value:null!=P?P:"",onChange:e=>F(e||null),disabled:b,options:M.map(e=>{var t,r;let n=null!==(r=null===(t=p.find(t=>t.id===e.peerId))||void 0===t?void 0:t.name)&&void 0!==r?r:"?";return{value:e.id,label:"".concat(e.originalFilename," → ").concat(n)}}),style:{padding:"8px 10px",fontSize:12.5,border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",background:"var(--bg-base)",width:"100%"}}),D&&(0,n.jsxs)("div",{style:{marginTop:8,fontSize:11.5,color:"var(--text-tertiary)"},children:["Peer: ",(0,n.jsx)("strong",{style:{color:"var(--text-secondary)"},children:null===(r=p.find(e=>e.id===D.peerId))||void 0===r?void 0:r.name})," \xb7 ","MD size: ",ex(null!==(c=null===(a=D.md)||void 0===a?void 0:a.sizeBytes)&&void 0!==c?c:0)," \xb7 ","Pages: ",null!==(u=null===(s=D.cortex)||void 0===s?void 0:s.pagesProcessed)&&void 0!==u?u:"?"]})]}),(0,n.jsx)(Q,{title:"CATEGORIES",children:(0,n.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:U.map(e=>{var t;let r=Z.has(e),i=null!==(t=R[e])&&void 0!==t?t:"var(--text-tertiary)",a=x.filter(t=>t.category===e).length;return(0,n.jsxs)("button",{onClick:()=>B(e),disabled:b,style:{padding:"5px 11px",borderRadius:999,fontSize:11.5,fontWeight:500,background:r?"color-mix(in srgb, ".concat(i," 15%, transparent)"):"var(--bg-base)",color:r?i:"var(--text-secondary)",border:"1px solid ".concat(r?"color-mix(in srgb, ".concat(i," 35%, transparent)"):"var(--border-subtle)"),cursor:b?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:i}}),e,(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,opacity:.7},children:a})]},e)})})})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",padding:"10px 14px",background:"var(--bg-elevated)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)"},children:[(0,n.jsx)("div",{style:{flex:1,fontSize:12.5,color:"var(--text-secondary)"},children:b?(0,n.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,n.jsx)(C.bw,{size:"xs",tone:"noa"}),"Extracting ",(0,n.jsx)("strong",{children:j.done})," / ",(0,n.jsx)("strong",{children:j.total})," metrics"," ","- auto-accepting ",(0,n.jsx)("strong",{children:"high"===T?"HIGH-confidence only":"medium"===T?"HIGH and MEDIUM":"nothing (review all)"}),"."]}):W.length>0?(0,n.jsxs)("span",{children:["Ready to extract ",(0,n.jsx)("strong",{children:W.length})," metrics from the chosen report."]}):(0,n.jsx)("span",{style:{color:"var(--text-tertiary)"},children:"Pick one or more categories above to define the run."})}),(0,n.jsx)($,{value:T,disabled:b,onChange:E}),b?(0,n.jsxs)("button",{onClick:()=>{var e;null===(e=I.current)||void 0===e||e.abort()},style:ec(!1),children:[(0,n.jsx)(y.Z,{size:12,style:{marginRight:4}})," Stop"]}):(0,n.jsxs)("button",{onClick:()=>q(),disabled:0===W.length,style:ed(0===W.length),children:[(0,n.jsx)(o.Z,{size:12,style:{marginRight:4}})," Extract ",W.length||""]})]}),(0,n.jsx)(O,{rows:G,selectedFile:D,existingByMetric:H,streaming:b,setRows:h,onRerun:e=>q([e])})]})}function O(e){let{rows:t,selectedFile:r,existingByMetric:i,streaming:a,setRows:s,onRerun:l}=e;return 0===t.length?(0,n.jsxs)("div",{style:{padding:36,textAlign:"center",background:"var(--bg-elevated)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",color:"var(--text-tertiary)",fontSize:12.5},children:["Click ",(0,n.jsx)("strong",{children:"Extract"})," above to start. Results stream in here, one metric at a time."]}):(0,n.jsx)("div",{style:{background:"var(--bg-elevated)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:(0,n.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{style:{background:"var(--bg-base)"},children:[(0,n.jsx)(Y,{width:28}),(0,n.jsx)(Y,{children:"METRIC"}),(0,n.jsx)(Y,{children:"LLM RESPONSE"}),(0,n.jsx)(Y,{width:220,children:"ACTIONS"})]})}),(0,n.jsx)("tbody",{children:t.map(e=>{var t;return(0,n.jsx)(W,{row:e,selectedFile:r,existingTarget:null!==(t=i.get(e.metric.id
1))&&void 0!==t?t:null,streaming:a,setRows:s,onRerun:()=>l(e.metric.id)},e.metric.id)})})]})})}function W(e){var t,r,a;let{row:s,selectedFile:l,existingTarget:o,streaming:d,setRows:c,onRerun:u}=e,p=(0,w.p)(),[x,g]=(0,i.useState)(!1),v=e=>{c(t=>{let r=new Map(t),n=r.get(s.metric.id);return n&&r.set(s.metric.id,{...n,...e}),r})},f=async()=>{if(!s.result||!l||!l.peerId||!l.md)return;if(s.result.not_found||"number"!=typeof s.result.value){p.show({title:"Nothing to accept",body:"Result has no numeric value.",tone:"error"});return}g(!0);let e=await (0,z.aZ)({peerId:l.peerId,universalMetricId:s.metric.id,sourceFileId:l.id,mdRevisionId:l.md.revisionId,value:s.result.value,unit:s.result.unit,originalValue:s.result.original_value,originalUnit:s.result.original_unit,converted:s.result.converted,periodLabel:s.result.period,quote:s.result.quote,pageRefs:s.result.page_refs,confidence:s.result.confidence,reasoning:s.result.reasoning,rawResponse:""});if(g(!1),!e.ok){p.show({title:"Accept failed",body:e.error,tone:"error"});return}v({reviewState:"accepted",targetId:e.targetId}),p.show({title:"Saved to Benchmark",body:"".concat(s.metric.name," now visible in Peer Intel"),tone:"success"})},h=async()=>{var e;if(!l)return;g(!0);let t="accepted"===s.reviewState||"auto-accepted"===s.reviewState,r=await (0,z.c9)({sourceFileId:l.id,universalMetricId:s.metric.id,peerId:t&&null!==(e=l.peerId)&&void 0!==e?e:void 0,reason:"manual"});if(g(!1),!r.ok){p.show({title:"Reject failed",body:r.error,tone:"error"});return}v({reviewState:"rejected",targetId:null}),t&&r.removedTarget&&p.show({title:"Removed from peer targets",body:"".concat(s.metric.name," no longer in Benchmark"),tone:"success"})},y=s.metric.category&&null!==(t=R[s.metric.category])&&void 0!==t?t:"var(--text-tertiary)";return(0,n.jsxs)("tr",{style:{borderTop:"1px solid var(--border-subtle)",background:"accepted"===s.reviewState||"auto-accepted"===s.reviewState?"color-mix(in srgb, var(--success) 4%, transparent)":"rejected"===s.reviewState?"color-mix(in srgb, var(--text-tertiary) 4%, transparent)":"transparent",opacity:"rejected"===s.reviewState?.6:1},children:[(0,n.jsx)(ee,{children:(0,n.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:y,display:"inline-block"}})}),(0,n.jsxs)(ee,{children:[(0,n.jsx)("div",{style:{fontSize:12.5,fontWeight:500,color:"var(--text-primary)"},children:s.metric.name}),(0,n.jsxs)("div",{style:{display:"flex",gap:6,marginTop:3,fontSize:10.5,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:[(0,n.jsx)("span",{children:s.metric.code}),s.metric.category&&(0,n.jsxs)("span",{children:["\xb7 ",s.metric.category]}),s.metric.outputUnit&&(0,n.jsxs)("span",{children:["\xb7 ",s.metric.outputUnit]})]}),o&&null==s.reviewState&&(0,n.jsxs)("div",{style:{fontSize:10.5,color:"var(--text-tertiary)",marginTop:3},children:["Existing value: ",o.valueNumeric," ",null!==(r=o.unit)&&void 0!==r?r:""]})]}),(0,n.jsx)(ee,{children:(0,n.jsx)(H,{row:s,sourceFileId:null!==(a=null==l?void 0:l.id)&&void 0!==a?a:null})}),(0,n.jsx)(ee,{children:(0,n.jsx)(G,{row:s,busy:x||d,onAccept:f,onReject:h,onRerun:u})})]})}function H(e){var t;let{row:r,sourceFileId:i}=e;if("queued"===r.status)return(0,n.jsx)(et,{children:"Queued…"});if("streaming"===r.status)return(0,n.jsxs)(et,{children:[(0,n.jsx)(C.bw,{size:"xs",tone:"noa",px:11,style:{display:"inline-flex",marginRight:4,verticalAlign:"middle"}})," Reading the report…"]});if("error"===r.status)return(0,n.jsx)("span",{style:{color:"var(--error)",fontSize:12},children:null!==(t=r.error)&&void 0!==t?t:"Extraction error"});if(!r.result)return(0,n.jsx)(et,{children:"-"});let a=r.result;return a.not_found?(0,n.jsxs)("div",{style:{fontSize:12},children:[(0,n.jsx)("span",{style:{color:"var(--text-tertiary)"},children:"Not reported in this document"}),a.reasoning&&(0,n.jsx)("div",{style:{fontSize:10.5,color:"var(--text-tertiary)",marginTop:3,fontStyle:"italic"},children:a.reasoning})]}):(0,n.jsxs)("div",{style:{fontSize:12.5},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6,flexWrap:"wrap"},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-display)",fontSize:16,fontWeight:500,color:"var(--text-primary)"}
1,children:"number"==typeof a.value?a.value.toLocaleString():"-"}),a.unit&&(0,n.jsx)("span",{style:{fontSize:11.5,color:"var(--text-secondary)"},children:a.unit}),a.period&&(0,n.jsx)(j.Caps,{size:10,children:a.period}),(0,n.jsx)(V,{confidence:a.confidence})]}),a.converted&&"number"==typeof a.original_value&&a.original_unit&&(0,n.jsxs)("div",{title:"LLM converted the report's verbatim value into the metric's canonical unit. The original is preserved in the audit metadata.",style:{marginTop:3,fontSize:10.5,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",display:"inline-flex",alignItems:"center",gap:4},children:[(0,n.jsx)("span",{children:"↺"}),"original: ",a.original_value.toLocaleString()," ",a.original_unit]}),a.quote&&(0,n.jsxs)("div",{style:{marginTop:4,fontSize:11,color:"var(--text-tertiary)",fontStyle:"italic",lineHeight:1.4},children:["“",a.quote.length>200?a.quote.slice(0,200)+"…":a.quote,"”",a.page_refs.length>0&&(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",marginLeft:6},children:a.page_refs.map((e,t)=>(0,n.jsx)(q,{sourceFileId:i,page:e,prefix:0===t?"p.":null},"".concat(e,"-").concat(t)))})]})]})}function q(e){let{sourceFileId:t,page:r,prefix:a}=e,s=(0,w.p)(),[l,o]=(0,i.useState)(!1);if(!t)return(0,n.jsxs)("span",{style:{opacity:.7},children:[null!=a?a:", ",r]});let d=async()=>{if(!l){o(!0);try{let e=await (0,z.F3)({sourceFileId:t,page:r});if(!e.ok){s.show({title:"Could not open source",body:e.error,tone:"error"});return}window.open(e.signedUrl,"_blank","noopener,noreferrer")}finally{o(!1)}}};return(0,n.jsxs)("button",{onClick:d,disabled:l,title:"Open source PDF at page ".concat(r),style:{background:"transparent",border:"none",padding:0,margin:0,color:"var(--accent)",cursor:l?"wait":"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:[null!=a?a:", ",r]})}function G(e){let{row:t,busy:r,onAccept:i,onReject:a,onRerun:s}=e;if("queued"===t.status||"streaming"===t.status)return(0,n.jsx)(et,{children:"-"});if("auto-accepted"===t.reviewState||"accepted"===t.reviewState){let e="auto-accepted"===t.reviewState;return(0,n.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,n.jsxs)("span",{style:ep("success"),children:[e?(0,n.jsx)(x.Z,{size:11}):(0,n.jsx)(h.Z,{size:11}),e?"Auto-saved":"Saved"]}),(0,n.jsxs)("button",{onClick:a,disabled:r,title:"Un-save and remove from Benchmark",style:eu("var(--error)",!1),children:[(0,n.jsx)(y.Z,{size:11})," Un-save"]}),(0,n.jsx)("button",{onClick:s,disabled:r,title:"Re-run",style:eo,children:(0,n.jsx)(b.Z,{size:11})})]})}if("rejected"===t.reviewState)return(0,n.jsxs)("span",{style:ep("muted"),children:["Rejected",(0,n.jsx)("button",{onClick:s,disabled:r,title:"Re-run",style:eo,children:(0,n.jsx)(b.Z,{size:11})})]});let l=t.result&&!t.result.not_found&&"number"==typeof t.result.value;return(0,n.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,n.jsxs)("button",{onClick:i,disabled:r||!l,style:eu("var(--success)",!l),children:[(0,n.jsx)(h.Z,{size:11})," Accept"]}),(0,n.jsxs)("button",{onClick:a,disabled:r,style:eu("var(--text-tertiary)",!1),children:[(0,n.jsx)(y.Z,{size:11})," Reject"]}),(0,n.jsx)("button",{onClick:s,disabled:r,title:"Re-run extraction",style:eo,children:(0,n.jsx)(b.Z,{size:11})})]})}function V(e){let{confidence:t}=e;return(0,n.jsx)("span",{style:ep("high"===t?"success":"medium"===t?"warning":"muted"),children:t.toUpperCase()})}function $(e){let{value:t,disabled:r,onChange:i}=e,a=(0,w.p)(),s=e=>{e===t||r||(i(e),(0,z.J_)({threshold:e}).then(e=>{e.ok||(a.show({title:"Could not save threshold",body:e.error,tone:"error"}),i(t))}).catch(()=>i(t)))};return(0,n.jsxs)("div",{title:"Confidence threshold for auto-accept. HIGH = only labelled table rows auto-save. MEDIUM = also save near-synonyms. NEVER = nothing auto-saves; every row goes to Review.",style:{display:"inline-flex",alignItems:"center",background:"var(--bg-sunken)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",padding:2,opacity:r?.55:1},children:[(0,n.jsx)("span",{style:{padding:"0 8px 0 10px",fontSize:9.5,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",letterSpacing:"0.06em"},children:"AUTO-ACCEPT"}),["high","medium","never"].map(e=>{let i=e===t;return(0,n.jsx)("button",{onClick:()=>s(e),disabled:r,style:{padding:"3px 9px",background:i?"var(--bg-elevated)":"transparent",color:i?"var(--accent)":"var(--text-secondary)",border:"none",borderRadius:"var(--radius-sm)",margin:1,fontSize:11,fontWeight:i?600:500,fontFamily:"var(--font-mono)",letterSpacing:"0.04em",textTransform:"uppercase",cursor:r?"not-allowed":"pointer"},children:e},e)})]})}function J(e){let{peers:t,rows:r,setRows:i,existingTargets:a}=e,s=Array.from(r.values()).filter(e=>"pending-review"===e.reviewState),l=Array.from(r.values()).filter(e=>"auto-accepted"===e.reviewState||"accepted"===e.reviewState);return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[(0,n.jsx)(Q,{title:"PENDING REVIEW \xb7 ".concat(s.length),accent:"warning",children:0===s.length?(0,n.jsx)(et,{children:"Nothing waiting - high-confidence answers auto-saved, low-confidence ones get queued here."}):(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:s.map(e=>(0,n.jsx)(X,{row:e,setRows:i}
1,e.metric.id))})}),(0,n.jsx)(Q,{title:"AUTO-SAVED THIS SESSION \xb7 ".concat(l.length),accent:"success",children:0===l.length?(0,n.jsx)(et,{children:"No values saved in this session yet. Start an extraction in the Extract tab."}):(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:6},children:l.map(e=>{var t,r,i,a,s;return(0,n.jsxs)("div",{style:{padding:"8px 12px",borderRadius:"var(--radius-sm)",background:"color-mix(in srgb, var(--success) 6%, transparent)",fontSize:12.5,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,n.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.metric.name}),(0,n.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:[null!==(a=null===(r=e.result)||void 0===r?void 0:null===(t=r.value)||void 0===t?void 0:t.toLocaleString())&&void 0!==a?a:"-"," ",null!==(s=null===(i=e.result)||void 0===i?void 0:i.unit)&&void 0!==s?s:""]})]},e.metric.id)})})}),(0,n.jsx)(Q,{title:"PEER TARGETS IN DATABASE \xb7 ".concat(a.length),accent:"accent",children:(0,n.jsxs)(et,{children:["These are persisted values powering Coverage / Benchmark / Score / Insights. ",a.length," active rows across ",t.length," peer",1===t.length?"":"s","."]})})]})}function X(e){var t,r,i,a,s,l,o,d;let{row:c,setRows:u}=e,p=e=>{u(t=>{let r=new Map(t),n=r.get(c.metric.id);return n&&r.set(c.metric.id,{...n,...e}),r})};return(0,n.jsxs)("div",{style:{padding:"10px 12px",borderRadius:"var(--radius-sm)",background:"color-mix(in srgb, var(--warning) 6%, transparent)",border:"1px solid color-mix(in srgb, var(--warning) 20%, transparent)",display:"grid",gridTemplateColumns:"1fr auto",gap:10,alignItems:"center"},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12.5,fontWeight:500},children:c.metric.name}),(0,n.jsxs)("div",{style:{fontSize:11.5,color:"var(--text-secondary)",marginTop:2},children:[null!==(o=null===(r=c.result)||void 0===r?void 0:null===(t=r.value)||void 0===t?void 0:t.toLocaleString())&&void 0!==o?o:"-"," ",null!==(d=null===(i=c.result)||void 0===i?void 0:i.unit)&&void 0!==d?d:"",(null===(a=c.result)||void 0===a?void 0:a.period)?" \xb7 ".concat(c.result.period):"",(null===(s=c.result)||void 0===s?void 0:s.confidence)?(0,n.jsx)("span",{style:{marginLeft:8},children:(0,n.jsx)(V,{confidence:c.result.confidence})}):null]}),(null===(l=c.result)||void 0===l?void 0:l.quote)&&(0,n.jsxs)("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontStyle:"italic",marginTop:4},children:["“",c.result.quote.length>160?c.result.quote.slice(0,160)+"…":c.result.quote,"”"]})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,n.jsxs)("button",{onClick:()=>p({reviewState:"rejected"}),style:eu("var(--text-tertiary)",!1),children:[(0,n.jsx)(y.Z,{size:11})," Skip"]}),(0,n.jsxs)("button",{onClick:()=>p({reviewState:"accepted"}),style:eu("var(--success)",!1),children:[(0,n.jsx)(m.Z,{size:11})," Go to Extract"]})]})]})}function K(e){let{label:t,value:r,sub:i}=e;return(0,n.jsxs)("div",{style:{padding:14,background:"var(--bg-elevated)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)"},children:[(0,n.jsx)(j.Caps,{size:10,style:{display:"block",marginBottom:4},children:t}),(0,n.jsx)("div",{style:{fontSize:22,fontWeight:500,fontFamily:"var(--font-display)",letterSpacing:"-0.02em",lineHeight:1,marginTop:4},children:r}),(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:4},children:i})]})}function Q(e){let{title:t,children:r,accent:i}=e;return(0,n.jsxs)("div",{style:{background:"var(--bg-elevated)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:14},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:10},children:[(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"success"===i?"var(--success)":"warning"===i?"var(--warning)":"accent"===i?"var(--accent)":"var(--text-tertiary)"}}),(0,n.jsx)(j.Caps,{size:10,children:t})]}),r]})}function Y(e){let{children:t,width:r,align:i="left"}=e;return(0,n.jsx)("th",{style:{padding:"8px 14px",textAlign:i,borderBottom:"1px solid var(--border-subtle)",whiteSpace:"nowrap",width:r},children:(0,n.jsx)(j.Caps,{children:t})})}function ee(e){let{children:t,align:r="left"}=e;return(0,n.jsx)("td",{style:{padding:"10px 14px",textAlign:r,verticalAlign:"top",fontSize:12.5},children:t})}function et(e){let{children:t}=e;return(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-tertiary)"},children:t})}function er(e){let{mime:t}=e,r=t.toLowerCase().includes("pdf");return(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:"var(--radius-sm)",background:r?"color-mix(in srgb, var(--error) 10%, transparent)":"var(--bg-sunken)",color:r?"var(--error)":"var(--text-tertiary)"},children:(0,n.jsx)(l.Z,{size:13})})}function en(e){let{text:t}=e;return(0,n.jsxs)("div",{style:{padding:"8px 12px",fontSize:12,color:"var(--error)",background:"color-mix(in srgb, var(--error) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--error) 30%, transparent)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)(c.Z,{size:13}),t]})}function ei(e){let{onClose:t,title:r,subtitle:i,children:a,width:s=640}=e;return(0,n.jsx)("div",{onClick:t,style:{position:"fixed",inset:0,background:"var(--scrim)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:90},children:(0,n.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{width:s,maxHeight:"85%",background:"var(--bg-elevated)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-lg)",boxShadow:"0 20px 50px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column"},children:[(0,n.jsxs)("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border-subtle)",display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{style:{fontSize:15,fontWeight:500,margin:0},children:r}),i&&(0,n.jsx)("p",{style:{fontSize:12,color:"var(--text-secondary)",margin:"4px 0 0",lineHeight:1.5},children:i})]}),(0,n.jsx)("button",{onClick:t,style:{background:"transparent",border:"none",cursor:"pointer",padding:4,color:"var(--text-tertiary)"},children:(0,n.jsx)(y.Z,{size:16})})]}),a]})})}function ea(e){let{leftText:t,onCancel:r,onConfirm:i,confirmLabel:a,pending:s,disabled:l}=e;return(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 20px",borderTop:"1px solid var(--border-subtle)"},children:[(0,n.jsx)(j.Caps,{children:t}),(0,n.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,n.jsx)("button",{onClick:r,disabled:s,style:ec(s),children:"Cancel"}),(0,n.jsx)("button",{onClick:i,disabled:s||l,style:ed(s||l),children:a})]})]})}let es={display:"flex",alignItems:"center",gap:6,flex:1,padding:"6px 10px",background:"var(--bg-base)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)"},el={flex:1,border:"none",outline:"none",background:"transparent",fontSize:12.5,color:"var(--text-primary)"},eo={padding:3,background:"transparent",border:"none",color:"var(--text-tertiary)",cursor:"pointer",display:"inline-flex",alignItems:"center",marginLeft:4};function ed(e){return{padding:"7px 14px",borderRadius:"var(--radius-sm)",fontSize:12.5,fontWeight:500,background:"var(--accent)",color:"var(--fg-on-solid)",border:"1px solid var(--accent)",cursor:e?"not-allowed":"pointer",opacity:e?.55:1,display:"inline-flex",alignItems:"center"}}function ec(e){return{padding:"7px 14px",borderRadius:"var(--radius-sm)",fontSize:12.5,background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",cursor:e?"not-allowed":"pointer",opacity:e?.55:1,display:"inline-flex",alignItems:"center"}}function eu(e,t){return{padding:"4px 9px",borderRadius:"var(--radius-sm)",fontSize:11.5,fontWeight:500,background:"transparent",color:e,border:"1px solid color-mix(in srgb, ".concat(e," 30%, transparent)"),cursor:t?"not-allowed":"pointer",opacity:t?.55:1,display:"inline-flex",alignItems:"center",gap:3}}function ep(e){let t={success:{fg:"var(--success)",bg:"color-mix(in srgb, var(--success) 10%, transparent)"},warning:{fg:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 10%, transparent)"},error:{fg:"var(--error)",bg:"color-mix(in srgb, var(--error) 10%, transparent)"},accent:{fg:"var(--accent)",bg:"var(--accent-subtle)"},muted:{fg:"var(--text-tertiary)",bg:"var(--bg-sunken)"}}[e];return{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 7px",borderRadius:999,background:t.bg,color:t.fg,fontSize:10.5,fontFamily:"var(--font-mono)",fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"}}function ex(e){return e?e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):e<1073741824?"".concat((e/1048576).toFixed(1)," MB"):"".concat((e/1073741824).toFixed(1)," GB"):"0 B"}}}]);

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.