https://www.intelital.com/_next/static/chunks/pages/admin/training-data/cleaning-256f81626b31ebbf.js
1!function(){try{var e="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="85043439-f28d-40f3-943f-226e2d411151",e._sentryDebugIdIdentifier="sentry-dbid-85043439-f28d-40f3-943f-226e2d411151")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8835],{8021:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(77161).A)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]])},54114:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var a=r(37876);function s({children:e}){return(0,a.jsx)("div",{className:"w-full h-full flex flex-row bg-surface overflow-hidden",children:(0,a.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:e})})}r(14232)},61081:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});var a=r(37876),s=r(14232),n=r(4033),l=r(56572);let i=(0,r(77161).A)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);var o=r(5164),d=r(98477);function c({onOrgSelect:e,selectedOrgId:t}){let[r,c]=(0,s.useState)([]),[u,m]=(0,s.useState)(!0),[x,p]=(0,s.use
1State)(null),[b,h]=(0,s.useState)(!1),[f,y]=(0,s.useState)(null),[g,j]=(0,s.useState)(!1),N=(0,s.useRef)(null),v=(0,s.useRef)(null),[_,w]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=!0;(async()=>{try{let{data:t}=await n.N.auth.getSession();if(!e)return;y(t.session?.access_token||null)}catch{if(!e)return;y(null)}})();let{data:t}=n.N.auth.onAuthStateChange((t,r)=>{e&&y(r?.access_token||null)});return()=>{e=!1,t.subscription.unsubscribe()}},[]),(0,s.useEffect)(()=>{(async()=>{if(f)try{m(!0),p(null);let r=await fetch(`/api/admin/list-orgs?_t=${Date.now()}`,{headers:{Authorization:`Bearer ${f}`},cache:"no-store"}).catch(e=>{throw console.error("Fetch error:",e),Error(`Network error: ${e?.message||"Failed to reach server"}`)});if(412===r.status){c([]),j(!0);return}if(401===r.status||403===r.status){y(null),c([]),p("Not authorized");return}let a=await r.json().catch(()=>({}));if(!r.ok){let e=String(a?.error||"");if(412===r.status||a?.mfaRequired||e.toLowerCase().includes("mfa required")){c([]),j(!0);return}throw Error(e||`Server error (${r.status})`)}let s=(a.orgs||[]).filter(e=>{let t=String(e.classification||"").toLowerCase().trim();return!!t&&!["innactive"].includes(t)});if(c(s),!t&&s&&s.length>0){let t=s.find(e=>"intelital"===String(e?.name||"").trim().toLowerCase());e((t||s[0]).id)}}catch(e){console.error("Error loading orgs:",e),p(e.message||"Failed to load organizations")}finally{m(!1)}})()},[f,e,t]);let S=r.find(e=>e.id===t);(0,s.useEffect)(()=>{if(b&&N.current){let e=N.current.getBoundingClientRect();w({top:e.bottom+8,left:e.left})}},[b]),(0,s.useEffect)(()=>{if(!b)return;let e=e=>{let t=e.target;N.current?.contains(t)||v.current?.contains(t)||h(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[b]);let k=u?(0,a.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 bg-surface-alt rounded-lg border border-border/50",children:[(0,a.jsx)(i,{className:"h-4 w-4 animate-spin text-fg-secondary"}),(0,a.jsx)("span",{className:"text-sm text-fg-secondary",children:"Loading organizations..."})]}):x?(0,a.jsx)("div",{className:"px-4 py-2 bg-red-500/10 rounded-lg border border-red-500/30 text-sm text-red-500",children:x}):0===r.length?(0,a.jsx)("div",{className:"px-4 py-2 bg-surface-alt rounded-lg border border-border/50 text-sm text-fg-secondary",children:"No organizations found"}):(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{ref:N,onClick:()=>h(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-md border border-transparent text-sm bg-brand text-fg-onBrand shadow-sm transition-colors hover:bg-brand-dark",children:[(0,a.jsx)("span",{className:"font-medium",children:S?.name||"Select org"}),(0,a.jsx)(o.A,{className:`h-4 w-4 transition-transform ${b?"rotate-180":""}`})]}),b&&_&&(0,d.createPortal)((0,a.jsx)("div",{ref:v,className:"fixed w-64 bg-surface-alt rounded-lg border border-border/50 shadow-xl z-[9999] max-h-96 overflow-y-auto",style:{to
1p:_.top,left:_.left},children:r.map(r=>(0,a.jsxs)("button",{onClick:()=>{e(r.id),h(!1)},className:`w-full text-left px-4 py-3 text-sm transition-colors ${t===r.id?"bg-brand/10 text-brand font-medium":"text-text hover:bg-surface/50"}`,children:[(0,a.jsx)("div",{className:"font-medium",children:r.name}),r.domain&&(0,a.jsx)("div",{className:"text-xs text-fg-secondary",children:r.domain})]},r.id))}),document.body)]});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.H,{isOpen:g,onClose:()=>{j(!1)},onSuccess:()=>{j(!1)}}),k]})}},73295:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(77161).A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},74015:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(77161).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])},76028:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(77161).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},79674:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>h});var a=r(37876),s=r(14232),n=r(89099),l=r(76028),i=r(73295),o=r(8021),d=r(74015),c=r(5002),u=r(99584),m=r(75304),x=r(61081),p=r(54114);function b(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function h(){let{user:e,loading:t}=(0,u.A)(),r=(0,n.useRouter)(),{accessToken:h,adminAllowed:f,adminChecked:y,mfaRequired:g}=(0,m.v)();(0,s.useEffect)(()=>{t||e||r.replace(`/login?redirectedFrom=${encodeURIComponent(r.asPath||"/admin/training-data/cleaning")}`)},[t,r,e]);let j="string"==typeof r.query.orgId?r.query.orgId:"",[N,v]=(0,s.useState)(j);(0,s.useEffect)(()=>{!N&&j&&v(j)},[j,N]);let[_,w]=(0,s.useState)(!1),[S,k]=(0,s.useState)(""),[C,A]=(0,s.useState)(null),[z,E]=(0,s.useState)([]),[I,M]=(0,s.useState)(!1),[$,L]=(0,s.useState)(null),[O,R]=(0,s.use
1State)(500),[D,F]=(0,s.useState)(0),[P,T]=(0,s.useState)(0),[q,B]=(0,s.useState)([]),[V,U]=(0,s.useState)(null),[H,J]=(0,s.useState)({}),[Y,W]=(0,s.useState)({}),[X,G]=(0,s.useState)({}),[K,Q]=(0,s.useState)({}),[Z,ee]=(0,s.useState)(!1),[et,er]=(0,s.useState)(!1),[ea,es]=(0,s.useState)(null),[en,el]=(0,s.useState)("onlyEmpty"),[ei,eo]=(0,s.useState)(""),[ed,ec]=(0,s.useState)(null),[eu,em]=(0,s.useState)(null),[ex,ep]=(0,s.useState)(()=>new Set);(0,s.useRef)(0);let eb=(0,s.useRef)(0),eh=!t&&e&&y,ef=async(e,t)=>{if(!h||!e)return;let r=++eb.current;M(!0),L(null);try{let a="number"==typeof t?.offset&&Number.isFinite(t.offset)?Math.max(0,Math.trunc(t.offset)):D,s=new URLSearchParams({orgId:e,limit:String(O),offset:String(a),_t:String(Date.now())}),n=await fetch(`/api/admin/training-data/training-leads?${s}`,{headers:{Authorization:`Bearer ${h}`},cache:"no-store"}),l=await n.json().catch(()=>({}));if(r!==eb.current)return;if(!n.ok)throw Error(l?.error||"Failed to load training table");E(Array.isArray(l.rows)?l.rows:[]),l?.paging?(F(l.paging.offset??a),T(l.paging.total??0)):(F(a),T(Array.isArray(l.rows)?l.rows.length:0))}catch(e){L(e?.message||"Failed to load training table")}finally{M(!1)}},ey=async()=>{if(h&&N&&z.length){ee(!0),A(null);try{let e=z.filter(e=>!!Y[e.id]),t=0,r=Array(Math.min(5,e.length)).fill(null).map(async()=>{for(;;){let r=t;if(t+=1,r>=e.length)return;await eS(e[r])}});await Promise.all(r)}finally{ee(!1)}}},eg=async e=>{if(h&&e){U(null);try{let t=new URLSearchParams({orgId:e,_t:String(Date.now())}),r=await fetch(`/api/admin/training-data/status-options?${t}`,{headers:{Authorization:`Bearer ${h}`},cache:"no-store"}),a=await r.json().catch(()=>({}));if(!r.ok)throw Error(a?.error||"Failed to load status options");B(Array.isArray(a.statuses)?a.statuses:[])}catch(e){B([]),U(e?.message||"Failed to load status options")}}},ej=e=>{let t=e.features||{};return{company_name:b(t.company_name),company_domain:b(t.company_domain),company_industry:b(t.company_industry),company_size:b(t.company_size),lead_title:b(t.lead_title),current_status:String(e.current_status||""),target_seller_likes_lead:b(e.target_seller_likes_lead),target_call_booked:b(e.target_call_booked),target_deal_won:b(e.target_deal_won),target_days_to_call:b(e.target_days_to_call)}},eN=(0,s.useMemo)(()=>({company_name:{label:"Company name",column:"company.name",prompt:"Normalize the company name (remove suffixes like Inc/LLC, fix capitalization, remove extra whitespace). Output ONLY the cleaned company name."},company_domain:{label:"Company domain",column:"company.domain",prompt:"Return the company's primary website domain only (no protocol, no path). Example: acme.com. Output ONLY the domain."},company_industry:{label:"Company industry",column:"company.industry",prompt:"Infer the company industry from the row context and output a short industry label (2-4 words). Output ONLY the industry."},company_size:{label:"Company size",column:"company.size",prompt:"Infer the approximate employee count as a single integer (no ranges, no text). If unknown, return empty string."},lead_title:{label:"Lead title",column:"lead.title",prompt:"Normalize the job title (fix casing, remove extra whitespace). Output ONLY the title."}}),[]),ev=e=>{es(e),er(!0),el("onlyEmpty"),eo(eN[e].prompt),em(null)},e_=async()=>{if(!h||!N||!ea||!z.length)return;let e=eN[ea],t=String(ei||"").trim();if(t){ec(ea),em(null),er(!1);try{let r=z.map((e,t)=>{let r=H[e.id]||ej(e);return{idx:t,rowId:e.id,currentValue:String(r[ea]||""),context:{company_name:r.company_name,company_domain:r.company_domain,company_industry:r.company_industry,company_size:r.company_size,lead_title:r.lead_title,current_status:r.current_status}}}),a="onlyEmpty"===en?r.filter(e=>!String(e.currentValue||"").trim()):r;if(!a.length)return;let s=Array.from(new Set(r.map(e=>String(e.currentValue||"").trim()).filter(e=>e))).slice(0,10);for(let r=0;r<a.length;r+=10){let n=a.slice(r,r+10);ep(e=>{let t=new Set(e);for(let e of n)t.add(`${e.idx}:${ea}`);return t}),await Promise.all(n.map(async r=>{try{let a=await fetch("/api/admin/ai-fill-cell-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},body:JSON.stringify({column:e.column,rowContext:r.context,userPrompt:t,columnExamples:s}
1)}),n=await a.json().catch(()=>({}));if(!a.ok)return;let l=String(n?.value??"");J(e=>{let t={...e||{}},a=t[r.rowId]||ej(z[r.idx]),s=String(a[ea]||"");return"onlyEmpty"===en&&s.trim()||s.trim()&&!l.trim()?e:(t[r.rowId]={...a,[ea]:l},t)}),W(e=>({...e||{},[r.rowId]:!0}))}catch{return}finally{ep(e=>{let t=new Set(e);return t.delete(`${r.idx}:${ea}`),t})}}))}}catch(e){em(e?.message||"AI column clean failed")}finally{ec(null),es(null),eo("")}}};(0,s.useEffect)(()=>{z.length&&J(e=>{let t={...e};for(let e of z)t[e.id]||(t[e.id]=ej(e));return t})},[z]),(0,s.useEffect)(()=>{let e=String(r.query.orgId||"").trim();e&&v(e)},[r.query.orgId]),(0,s.useEffect)(()=>{N&&h&&f&&(ef(N,{offset:0}),eg(N))},[N,h,f]),(0,s.useEffect)(()=>{N&&h&&f&&ef(N)},[O]);let ew=(e,t,r)=>{J(a=>({...a,[e]:{...a[e]||{},[t]:r}})),W(t=>({...t,[e]:!0}))},eS=async e=>{if(!h||!N)return;let t=e.id,r=H[t]||ej(e);G(e=>({...e,[t]:!0})),A(null);try{let e={current_status:r.current_status||null,target_seller_likes_lead:""===r.target_seller_likes_lead?null:Number(r.target_seller_likes_lead),target_call_booked:""===r.target_call_booked?null:Number(r.target_call_booked),target_deal_won:""===r.target_deal_won?null:Number(r.target_deal_won),target_days_to_call:""===r.target_days_to_call?null:Number(r.target_days_to_call),features:{company_name:r.company_name||null,company_domain:r.company_domain||null,company_industry:r.company_industry||null,company_size:""===r.company_size?null:Number(r.company_size),lead_title:r.lead_title||null}},a=await fetch("/api/admin/training-data/training-leads-mutate",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},body:JSON.stringify({orgId:N,id:t,patch:e})}),s=await a.json().catch(()=>({}));if(!a.ok)throw Error(s?.error||"Failed to save row");let n=s?.row;n&&n.id&&(E(e=>e.map(e=>e.id===t?n:e)),J(e=>({...e,[t]:ej(n)}))),W(e=>({...e,[t]:!1}))}catch(e){A(e?.message||"Save failed")}finally{G(e=>({...e,[t]:!1}))}},ek=async e=>{if(!h||!N)return;let t=e.id;Q(e=>({...e,[t]:!0})),A(null);try{let e=await fetch("/api/admin/training-data/training-leads-mutate",{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},body:JSON.stringify({orgId:N,id:t})}),r=await e.json().catch(()=>({}));if(!e.ok)throw Error(r?.error||"Failed to delete row");E(e=>e.filter(e=>e.id!==t)),J(e=>{let r={...e};return delete r[t],r}),W(e=>{let r={...e};return delete r[t],r})}catch(e){A(e?.message||"Delete failed")}finally{Q(e=>({...e,[t]:!1}))}};return eh?f?g?(0,a.jsx)(p.A,{children:(0,a.jsx)("div",{className:"p-6",children:(0,a.jsx)("div",{className:"rounded-lg border border-border/60 bg-surface-alt p-4",children:(0,a.jsx)("div",{className:"text-sm text-fg-secondary",children:"MFA required"})})})}):(0,a.jsx)(p.A,{children:(0,a.jsx)("div",{className:"w-full h-full overflow-auto",children:(0,a.jsxs)("div",{className:"p-6 max-w-none mx-auto",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-2xl font-semibold text-text",children:"Training Data \xb7 Cleaning"}),(0,a.jsx)("div",{className:"text-sm text-fg-secondary",children:"Deterministic cleanup for dates/interactions. LLM cleaning is optional for filling missing values + sanity checks."})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(x.A,{selectedOrgId:N,onOrgSelect:v}),(0,a.jsxs)("div",{className:"flex items-center gap-1 rounded-md border border-border/60 bg-surface-alt p-1",children:[(0,a.jsx)("button",{className:"px-2.5 py-1 rounded text-xs text-fg-secondary hover:text-text",onClick:()=>{let e=N?`?orgId=${encodeURIComponent(N)}`:"";r.push(`/admin/training-data${e}`)},children:"1. Sync & view"}),(0,a.jsx)("button",{className:"px-2.5 py-1 rounded text-xs font-medium",style:{background:"#1F5B69",color:"#fff"},onClick:()=>{let e=N?`?orgId=${encodeURIComponent(N)}`:"";r.push(`/admin/training-data/cleaning${e}`)},children:"2. Clean"})]}),(0,a.jsxs)("button",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-md border border-border/60 bg-surface-alt text-xs text-text hover:bg-surface disabled:opacity-50",onClick:()=>void ey(),disabled:!N||Z||_,title:"Persist all dirty rows to the training_leads table",children:[Z?(0,a.jsx)(l.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(i.A,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),C&&(0,a.jsx)("div",{className:"mt-4 rounded-lg border border-red-500/30 bg-red-500/10 p-4 text-sm text-red-500",children:C}),_?(0,a.jsx)("div",{className:"mt-4 rounded-lg border border-brand/25 bg-brand/5 p-3 text-sm text-fg-secondary",children:S||"Running..."}):null,eu?(0,a.jsx)("div",{className:"mt-4 rounded-lg border border-red-500/30 bg-red-500/10 p-4 text-sm text-red-500",children:eu}):null,(0,a.jsxs)("div",{className:"mt-6 rounded-lg border border-border/60 bg-surface-alt p-4",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-text",children:"Training table (sample)"}),$?(0,a.jsx)("div",{className:"mt-2 text-sm text-red-500",children:$}):null,V?(0,a.jsx)("div",{className:"mt-2 text-sm text-red-500",children:V}):null,(0,a.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-3 flex-wrap",children:[(0,a.jsx)("div",{className:"text-xs text-fg-secondary",children:P>0?(0,a.jsxs)("span",{children:["Showing ",(0,a.jsx)("strong",{children:D+1}),"â",(0,a.jsx)("strong",{children:D+z.length})," of"," ",(0,a.jsx)("strong",{children:P})]}):(0,a.jsx)("span",{children:"Showing 0 rows"})}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("select",{value:String(O),onChange:e=>{let t=Number(e.target.value),r=Number.isFinite(t)?Math.max(50,Math.min(2e3,t)):500;F(0),R(r)},className:"text-xs px-2 py-1 rounded-md border border-border/60 bg-surface text-fg-secondary",children:[100,250,500,1e3,2e3].map(e=>(0,a.jsxs)("option",{value:String(e),children:[e," / page"]},e))}),(0,a.jsx)("button",{className:"text-xs px-3 py-1 rounded-md border border-border/60 bg-surface-alt text-text hover:bg-surface disabled:opacity-50",disabled:!N||I||D<=0,onClick:()=>
1{if(!N)return;let e=Math.max(0,D-O);F(e),ef(N,{offset:e})},children:"Prev"}),(0,a.jsx)("button",{className:"text-xs px-3 py-1 rounded-md border border-border/60 bg-surface-alt text-text hover:bg-surface disabled:opacity-50",disabled:!N||I||D+z.length>=P,onClick:()=>{if(!N)return;let e=D+O;F(e),ef(N,{offset:e})},children:"Next"})]})]}),(0,a.jsx)("div",{className:"mt-3 overflow-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm border-separate border-spacing-0",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"text-xs text-fg-secondary",children:[(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-border/30 min-w-[220px]",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{children:"Company name"}),(0,a.jsx)("button",{type:"button",className:"inline-flex items-center justify-center rounded-md border border-border/60 bg-surface px-1.5 py-1 text-text hover:bg-surface-alt disabled:opacity-50",onClick:()=>ev("company_name"),disabled:_||I||!!ed,title:"Clean this column with AI",children:"company_name"===ed?(0,a.jsx)(l.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(o.A,{className:"h-3.5 w-3.5"})})]})}),(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-border/30 min-w-[200px]",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{children:"Company domain"}),(0,a.jsx)("button",{type:"button",className:"inline-flex items-center justify-center rounded-md border border-border/60 bg-surface px-1.5 py-1 text-text hover:bg-surface-alt disabled:opacity-50",onClick:()=>ev("company_domain"),disabled:_||I||!!ed,title:"Clean this column with AI",children:"company_domain"===ed?(0,a.jsx)(l.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(o.A,{className:"h-3.5 w-3.5"})})]})}),(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-border/30 min-w-[220px]",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{children:"Company industry"}),(0,a.jsx)("button",{type:"button",className:"inline-flex items-center justify-center rounded-md border border-border/60 bg-surface px-1.5 py-1 text-text hover:bg-surface-alt disabled:opacity-50",onClick:()=>ev("company_industry"),disabled:_||I||!!ed,title:"Clean this column with AI",children:"company_industry"===ed?(0,a.jsx)(l.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(o.A,{className:"h-3.5 w-3.5"})})]})}),(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-border/30 min-w-[150px]",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{children:"Company size"}),(0,a.jsx)("button",{type:"button",className:"inline-flex items-center justify-center rounded-md border border-border/60 bg-surface px-1.5 py-1 text-text hover:bg-surface-alt disabled:opacity-50",onClick:()=>ev("company_size"),disabled:_||I||!!ed,title:"Clean this column with AI",children:"company_size"===ed?(0,a.jsx)(l.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(o.A,{className:"h-3.5 w-3.5"})})]})}),(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-border/30 min-w-[220px]",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{children:"Lead title"}),(0,a.jsx)("button",{type:"button",className:"inline-flex items-center justify-center rounded-md border border-border/60 bg-surface px-1.5 py-1 text-text hover:bg-surface-alt disabled:opacity-50",onClick:()=>ev("lead_title"),disabled:_||I||!!ed,title:"Clean this column with AI",children:"lead_title"===ed?(0,a.jsx)(l.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(o.A,{className:"h-3.5 w-3.5"})})]})}),(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-border/30",children:"Status"}),(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-gray-200",children:"Like"}),(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-gray-200",children:"Call"}),(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-gray-200",children:"Won"}),(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-gray-200",children:"Days to call"}),(0,a.jsx)("th",{className:"text-left font-medium px-3 py-2 border-b border-gray-200",children:"Actions"})]})}),(0,a.jsx)("tbody",{children:I&&0===z.length?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:11,className:"px-3 py-6 text-fg-secondary",children:"Loading..."})}):0===z.length?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:11,className:"px-3 py-6 text-fg-secondary",children:_?"running...":"No training rows yet."})}):z.map((e,t)=>{let r=H[e.id]||ej(e),s=!!Y[e.id],n=!!X[e.id],o=!!K[e.id],c=_||n||o,u=e=>ex.has(`${t}:${e}`);return(0,a.jsxs)("tr",{className:"hover:bg-surface/40",children:[(0,a.jsx)("td",{className:"px-3 py-2 border-b border-border/20",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{className:"w-full text-xs px-2 py-1 rounded-md border border-border/30 bg-transparent text-text focus:bg-surface focus:border-border/60 focus:outline-none",value:r.company_name,onChange:t=>ew(e.id,"company_name",t.target.value),disabled:c}),u("company_name")&&(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-end pr-2 text-[11px] text-fg-secondary",children:"Running..."})]})}),(0,a.jsx)("td",{className:"px-3 py-2 border-b border-border/20",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{className:"w-full text-xs px-2 py-1 rounded-md border border-border/30 bg-transparent text-text focus:bg-surface focus:border-border/60 focus:outline-none",value:r.company_domain,onChange:t=>ew(e.id,"company_domain",t.target.value),disabled:c}),u("company_domain")&&(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-end pr-2 text-[11px] text-fg-secondary",children:"Running..."})]})}),(0,a.jsx)("td",{className:"px-3 py-2 border-b border-border/20",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{className:"w-full text-xs px-2 py-1 rounded-md border border-border/30 bg-transparent text-text focus:bg-surface focus:border-border/60 focus:outline-none",value:r.company_industry,onChange:t=>ew(e.id,"company_industry",t.target.value),disabled:c}),u("company_industry")&&(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-end pr-2 text-[11px] text-fg-secondary",children:"Running..."})]})}),(0,a.jsx)("td",{className:"px-3 py-2 border-b border-border/20",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{className:"w-full text-xs px-2 py-1 rounded-md border border-border/30 bg-transparent text-text focus:bg-surface focus:border-border/60 focus:outline-none",value:r.company_
1size,onChange:t=>ew(e.id,"company_size",t.target.value),disabled:c,inputMode:"numeric"}),u("company_size")&&(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-end pr-2 text-[11px] text-fg-secondary",children:"Running..."})]})}),(0,a.jsx)("td",{className:"px-3 py-2 border-b border-border/20",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{className:"w-full text-xs px-2 py-1 rounded-md border border-border/30 bg-transparent text-text focus:bg-surface focus:border-border/60 focus:outline-none",value:r.lead_title,onChange:t=>ew(e.id,"lead_title",t.target.value),disabled:c}),u("lead_title")&&(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-end pr-2 text-[11px] text-fg-secondary",children:"Running..."})]})}),(0,a.jsx)("td",{className:"px-3 py-2 border-b border-gray-100",children:(0,a.jsxs)("select",{className:"w-full text-xs px-2 py-1 rounded-md border border-gray-200 bg-transparent text-text focus:bg-surface focus:border-gray-300 focus:outline-none",value:r.current_status||"",onChange:t=>ew(e.id,"current_status",t.target.value),disabled:c,children:[(0,a.jsx)("option",{value:"",children:"(none)"}),q.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})}),(0,a.jsx)("td",{className:"px-3 py-2 border-b border-gray-100",children:(0,a.jsx)("input",{className:"w-16 text-xs px-2 py-1 rounded-md border border-gray-200 bg-transparent text-text focus:bg-surface focus:border-gray-300 focus:outline-none",value:r.target_seller_likes_lead,onChange:t=>ew(e.id,"target_seller_likes_lead",t.target.value),disabled:c,inputMode:"numeric"})}),(0,a.jsx)("td",{className:"px-3 py-2 border-b border-gray-100",children:(0,a.jsx)("input",{className:"w-16 text-xs px-2 py-1 rounded-md border border-gray-200 bg-transparent text-text focus:bg-surface focus:border-gray-300 focus:outline-none",value:r.target_call_booked,onChange:t=>ew(e.id,"target_call_booked",t.target.value),disabled:c,inputMode:"numeric"})}),(0,a.jsx)("td",{className:"px-3 py-2 border-b border-gray-100",children:(0,a.jsx)("input",{className:"w-16 text-xs px-2 py-1 rounded-md border border-gray-200 bg-transparent text-text focus:bg-surface focus:border-gray-300 focus:outline-none",value:r.target_deal_won,onChange:t=>ew(e.id,"target_deal_won",t.target.value),disabled:c,inputMode:"numeric"})}),(0,a.jsx)("td",{className:"px-3 py-2 border-b border-gray-100",children:(0,a.jsx)("input",{className:"w-20 text-xs px-2 py-1 rounded-md border border-gray-200 bg-transparent text-text focus:bg-surface focus:border-gray-300 focus:outline-none",value:r.target_days_to_call,onChange:t=>ew(e.id,"target_days_to_call",t.target.value),disabled:c,inputMode:"numeric"})}),(0,a.jsx)("td",{className:"px-3 py-2 border-b border-gray-100",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("button",{className:"inline-flex items-center justify-center h-8 w-8 rounded-md border border-gray-200 bg-transparent text-fg-secondary hover:bg-surface focus:outline-none disabled:opacity-50",onClick:()=>eS(e),disabled:c||!s,"aria-label":"Save",title:n?"Saving...":"Save",children:n?(0,a.jsx)(l.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(i.A,{className:"h-4 w-4"})}),(0,a.jsx)("button",{className:"inline-flex items-center justify-center h-8 w-8 rounded-md border border-gray-200 bg-transparent text-red-500 hover:bg-red-500/10 focus:outline-none disabled:opacity-50",onClick:()=>ek(e),disabled:c,"aria-label":"Delete",title:o?"Deleting...":"Delete",children:o?(0,a.jsx)(l.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(d.A,{className:"h-4 w-4"})})]})})]},e.id)})})]})})]}),et&&ea&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:(0,a.jsxs)("div",{className:"bg-white rounded-lg shadow-lg p-6 max-w-xl w-full mx-4 max-h-[90vh] overflow-y-auto",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h3",{className:"text-lg font-semibold text-gray-900",children:['Clean "',eN[ea].label,'" with AI']}),(0,a.jsx)("button",{type:"button",onClick:()=>{er(!1),es(null),eo("")},className:"text-gray-400 hover:text-gray-600",children:(0,a.jsx)(c.A,{size:20})})]}),(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-900 mb-2",children:"What to clean"}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"radio",name:"fillScope",checked:"onlyEmpty"===en,onChange:()=>el("onlyEmpty"),className:"text-brand"}),(0,a.jsx)("span",{className:"text-sm text-gray-900",children:"Only empty cells"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 ml-6",children:"Skip rows where this column already has a value."}),(0,a.jsxs)("label",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"radio",name:"fillScope",checked:"allCells"===en,onChange:()=>el("allCells"),className:"text-brand"}),(0,a.jsx)("span",{className:"text-sm text-gray-900",children:"All cells in this column"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 ml-6",children:"Overwrite existing values too."}),(0,a.jsxs)("label",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"radio",name:"fillScope",checked:"completeColumn"===en,onChange:()=>el("completeColumn"),className:"text-brand"}),(0,a.jsx)("span",{className:"text-sm text-gray-900",children:"Complete column (clean + f
1ill)"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 ml-6",children:"Normalize existing values and fill missing ones. Won't blank out non-empty cells."})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-900 mb-2",children:"Instructions"}),(0,a.jsx)("textarea",{value:ei,onChange:e=>eo(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",rows:4}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mt-2",children:"The AI uses the row context to normalize this column."})]})]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-end mt-6",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{er(!1),es(null),eo("")},className:"px-4 py-2 text-sm font-medium text-gray-700 border border-gray-300 rounded-md hover:bg-gray-50",children:"Cancel"}),(0,a.jsxs)("button",{type:"button",onClick:()=>void e_(),className:"px-4 py-2 text-sm font-medium text-white bg-brand rounded-md hover:bg-brand-dark disabled:opacity-50 inline-flex items-center gap-2",disabled:!!ed||!String(ei||"").trim(),children:[(0,a.jsx)(o.A,{className:"h-4 w-4"}),"Clean column"]})]})]})})]})})}):(0,a.jsx)(p.A,{children:(0,a.jsx)("div",{className:"p-6",children:(0,a.jsx)("div",{className:"rounded-lg border border-border/60 bg-surface-alt p-4",children:(0,a.jsx)("div",{className:"text-sm text-fg-secondary",children:"Not authorized"})})})}):null}},99286:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/training-data/cleaning",function(){return r(79674)}])}},e=>{e.O(0,[636,6593,8792],()=>e(e.s=99286)),_N_E=e.O()}]);
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.