(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,84004,e=>{"use strict";e.i(10400),e.i(28127),e.i(59660),e.i(82673),e.i(22706),e.i(93998),e.i(50937),e.s([])},55436,e=>{"use strict";let s=(0,e.i(75254).default)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);e.s(["Search",()=>s],55436)},58194,e=>{"use strict";var s=e.i(43476),t=e.i(71645),a=e.i(55436);e.i(84004);var l=e.i(93998);e.i(55824);var i=e.i(22706),r=e.i(93479),c=e.i(19455),n=e.i(15288),d=e.i(9165);function x(){let[e,x]=(0,t.useState)(""),[o,m]=(0,t.useState)([]),[u,h]=(0,t.useState)(!1),[p,g]=(0,t.useState)(null),[j,f]=(0,t.useState)(""),[N,y]=(0,t.useState)([]),[v,C]=(0,t.useState)(!1),[S,b]=(0,t.useState)(null),w=(0,t.useCallback)(async()=>{let s=e.trim();if(s){h(!0),g(null);try{let e=await d.api.wiki.suggestConcept(s);m(e)}catch(e){g((0,d.getApiErrorMessage)(e))}finally{h(!1)}}},[e]),k=(0,t.useCallback)(async()=>{let e=j.trim();if(e){C(!0),b(null);try{let s=await d.api.wiki.getCrossContractMappings(e);y(s)}catch(e){b((0,d.getApiErrorMessage)(e))}finally{C(!1)}}},[j]),E=N.reduce((e,s)=>((e[s.contract_id]??=[]).push(s),e),{});return(0,s.jsxs)(l.PageContainer,{children:[(0,s.jsx)(i.PageHeader,{title:"Discovery",description:"Find relationships across contracts"}),(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.CardHeader,{children:(0,s.jsx)(n.CardTitle,{className:"text-base",children:"Concept Suggestions"})}),(0,s.jsxs)(n.CardContent,{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(a.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,s.jsx)(r.Input,{value:e,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&w(),placeholder:"Enter a field name (e.g. customer_id)...",className:"pl-10"})]}),(0,s.jsx)(c.Button,{onClick:w,disabled:!e.trim()||u,children:u?"Searching...":"Suggest"})]}),p&&(0,s.jsx)("p",{className:"text-sm text-destructive",children:p}),o.length>0&&(0,s.jsx)("div",{className:"space-y-2",children:o.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("span",{className:"font-medium text-sm",children:e.name}),e.description&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.description})]}),(0,s.jsxs)("div",{className:"w-24 flex items-center gap-2",children:[(0,s.jsx)("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:(0,s.jsx)("div",{className:"h-full bg-primary rounded-full",style:{width:`${Math.round(100*e.confidence)}%`}})}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground w-8",children:[Math.round(100*e.confidence),"%"]})]})]},e.id))}),!u&&0===o.length&&e.trim()&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No suggestions found."})]})]}),(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.CardHeader,{children:(0,s.jsx)(n.CardTitle,{className:"text-base",children:"Cross-Contract Mappings"})}),(0,s.jsxs)(n.CardContent,{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(a.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,s.jsx)(r.Input,{value:j,onChange:e=>f(e.target.value),onKeyDown:e=>"Enter"===e.key&&k(),placeholder:"Enter a concept name (e.g. Entity)...",className:"pl-10"})]}),(0,s.jsx)(c.Button,{onClick:k,disabled:!j.trim()||v,children:v?"Searching...":"Search"})]}),S&&(0,s.jsx)("p",{className:"text-sm text-destructive",children:S}),Object.keys(E).length>0&&(0,s.jsx)("div",{className:"space-y-4",children:Object.entries(E).map(([e,t])=>(0,s.jsxs)("div",{children:[(0,s.jsxs)("h4",{className:"text-sm font-medium mb-2",children:[e,(0,s.jsxs)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",t.length," fields)"]})]}),(0,s.jsx)("div",{className:"space-y-1 ml-4",children:t.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,s.jsx)("span",{children:e.name}),e.data_type&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:e.data_type})]},e.id))})]},e))}),!v&&0===N.length&&j.trim()&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No cross-contract mappings found."})]})]})]})]})}e.s(["default",()=>x])}]);