PageSourceSearch

https://incommand.ai/assets/Knowledge-DycbZ0-D.js

js incommand.ai collected 2026-10-05 15:01:28 UTC 16,767 bytes, 4 lines download raw bytes

1import{j as e}from"./vendor-radix-BnNg3BH5.js";import{r as g,d as J,L as u}from"./vendor-react-67mgcWXU.js";import{u as Z,c as F,d as ee,W as M}from"./useWikiPages-DutED1-m.js";import{C,d as U,a as A,b as $,c as se}from"./card-DpKBVi42.js";import{u as te,b as ae,a as re,D as ie,e as oe,f as ne,g as ce,h as le,w as de,x as me,y as xe,z as pe,A as V,B as y,X as ge,L as G,C as he,F as B,s as I,U as ue,V as fe,W as Y,Y as H,I as je}from"./index-Epr9psQo.js";import{B as b}from"./badge-Cl7apleB.js";import{S as Ne}from"./skeleton-CXDkv5zX.js";import{K as we,F as ve,C as Ce}from"./ContradictionScanner-CLoalyjc.js";import{u as ye}from"./index-OJZrzQMP.js";import{P as Q}from"./progress-OXAVVpg3.js";import{S as be}from"./scroll-area-OnGFamwr.js";import{C as X}from"./checkbox-CaPhqoy3.js";import{U as L}from"./upload-2-rh2XwF.js";import{F as ke}from"./folder-open-CP9JKzSm.js";import{A as Se,m as Pe}from"./vendor-motion-CSzk-Fqg.js";import{S as _e}from"./sparkles-BcySMUTB.js";import{C as q}from"./circle-alert-CFN03ksH.js";import{F as De}from"./file-spreadsheet-Q6qsWG3M.js";import{F as Te}from"./file-D62hmXlJ.js";import{P as Ue}from"./plus-DRTmwF2W.js";import{B as W}from"./book-open-CDTjHrJx.js";import{S as Ae}from"./shield-check-D18Fa-7Q.js";import{S as $e}from"./search-BnpyGpZl.js";import{C as Be}from"./clock-BYWbH6MV.js";import{S as Ee}from"./star-Bi_oSCUH.js";import{T as ze}from"./triangle-alert-C6ISfBPd.js";import{T as Ie}from"./trending-up-CXZcoU_y.js";import{P as Le}from"./package-DW7ssg6N.js";import{K as We}from"./kanban-B6qmqqtt.js";import{U as Re}from"./users-uAR6_Qvs.js";import{S as Oe}from"./settings-CFzYyjTl.js";import{f as Ke}from"./formatDistanceToNow--Gw1Xv78.js";import"./vendor-supabase-CTlrDMdV.js";import"./vendor-query-PMAhJHCS.js";import"./vendor-charts-Dck3qfzI.js";import"./AIKnowledgeGenerator-DK1KL-vt.js";import"./brain-BAvvPRM1.js";import"./target-CyHaUH9t.js";import"./shield-BI9NGrnO.js";import"./trophy-DDLL3U1f.js";import"./metric-DK0Tcl4m.js";import"./avatar-DkXZyfFy.js";import"./vendor-editor-CEJKB4cc.js";import"./FreshnessBadge-Bkkuqg1E.js";import"./circle-check-Cv8aCTuA.js";import"./refresh-ccw-Dxc3RwEl.js";import"./user-plus-Cz5haDJC.js";import"./chevron-right-DQtszqux.js";import"./alert-BbCCz1lQ.js";import"./file-warning-BppkjwTD.js";import"./constructNow-LutmP3uJ.js";import"./en-US-DJiZ5LCQ.js";import"./differenceInMonths-ODK8TVL-.js";import"./differenceInCalendarMonths-CBq9QhqA.js";import"./endOfDay-CV7hhp0x.js";import"./endOfMonth-BJH_LSY0.js";import"./differenceInMilliseconds-BS2m-4UB.js";const Me={"application/pdf":[".pdf"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"],"application/msword":[".doc"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/vnd.ms-excel":[".xls"]},Ve=["Sales & Business Development","Contracting & Legal","Service Delivery","Project Management","Talent & Team","Operations & Finance","General"],Ge=o=>o.includes("pdf")?e.jsx(B,{className:"h-5 w-5 text-destructive"}):o.includes("word")||o.includes("document")?e.jsx(B,{className:"h-5 w-5 text-info"}):o.includes("sheet")||o.includes("excel")?e.jsx(De,{className:"h-5 w-5 text-success"}):e.jsx(Te,{className:"h-5 w-5 text-muted-foreground"}),Ye=o=>o.includes("pdf")?"pdf":o.includes("word")||o.includes("document")?"docx":o.includes("sheet")||o.includes("excel")?"xlsx":o.includes("msword")?"doc":o.includes("ms-excel")?"xls":"pdf";function He({open:o,onOpenChange:d,onComplete:k}){const{toast:E}=te(),{currentTenant:h}=ae(),{user:S}=re(),[n,l]=g.useState([]),[f,P]=g.useState(!1),[x,j]=g.useState(!1),_=g.useCallback(t=>{const a=t.map(i=>({file:i,id:crypto.randomUUID(),status:"pending",progress:0,createWikiPage:x}));l(i=>[...i,...a])},[x]),{getRootProps:D,getInputProps:z,isDragActive:p}=ye({onDrop:_,accept:Me,maxSize:20*1024*1024}),N=t=>{l(a=>a.filter(i=>i.id!==t))},s=(t,a)=>{l(i=>i.map(m=>m.id===t?{...m,...a}:m))},c=async t=>{if(!(!h?.id||!S?.id))try{s(t.id,{status:"uploading",progress:20});const a=`${h.id}/${t.id}/${t.file.name}`,{error:i}=await I.storage.from("knowledge-uploads").upload(a,t.file);if(i)throw i;s(t.id,{progress:40});const{data:m,error:R}=await I.from("knowledge_documents").insert({tenant_id:h.id,file_name:t.file.name,file_path:a,file_size:t.file.size,mime_type:t.file.type,document_type:Ye(t.file.type),status:"pending",user_category:t.userCategory,create_wiki_page:t.createWikiPage,uploaded_by:S.id}).select().single();if(R)throw R;s(t.id,{documentId:m.id,progress:50,status:"processing"});const{data:O,error:K}
1=await I.functions.invoke("process-knowledge-document",{body:{document_id:m.id,tenant_id:h.id}});K&&console.error("Processing error:",K),s(t.id,{status:"completed",progress:100,suggestedCategory:O?.category,categoryConfidence:O?.confidence})}catch(a){console.error("Error processing file:",a),s(t.id,{status:"failed",error:a instanceof Error?a.message:"Upload failed"})}},r=async()=>{P(!0);for(const i of n.filter(m=>m.status==="pending"))await c(i);P(!1);const t=n.filter(i=>i.status==="completed").length,a=n.filter(i=>i.status==="failed").length;E({title:"Upload Complete",description:`${t} files processed successfully${a>0?`, ${a} failed`:""}`}),t>0&&k?.()},w=n.length>0?Math.round(n.reduce((t,a)=>t+a.progress,0)/n.length):0,v=n.filter(t=>t.status==="pending").length,T=n.filter(t=>t.status==="completed").length;return e.jsx(ie,{open:o,onOpenChange:d,children:e.jsxs(oe,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(ne,{children:[e.jsxs(ce,{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-5 w-5"}),"Bulk Upload Documents"]}),e.jsx(le,{children:"Upload Word, Excel, and PDF files to organize, categorize, and vectorize for your knowledge base."})]}),e.jsxs("div",{className:"flex-1 space-y-4 overflow-hidden",children:[e.jsxs("div",{...D(),className:`
2              border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors
3              ${p?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50"}
4            `,children:[e.jsx("input",{...z()}),e.jsx(ke,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),p?e.jsx("p",{className:"text-primary font-medium",children:"Drop files here..."}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium",children:"Drag & drop files here, or click to browse"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Supports PDF, Word (.doc, .docx), Excel (.xls, .xlsx) • Max 20MB per file"})]})]}),n.length>0&&e.jsxs("div",{className:"flex items-center gap-4 p-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{id:"global-wiki",checked:x,onCheckedChange:t=>{j(!!t),l(a=>a.map(i=>({...i,createWikiPage:!!t})))}}),e.jsx("label",{htmlFor:"global-wiki",className:"text-sm font-medium cursor-pointer",children:"Create Wiki pages for all"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs(b,{variant:"outline",children:[n.length," files"]})]}),n.length>0&&e.jsx(be,{className:"h-[300px] pr-4",children:e.jsx("div",{className:"space-y-2",children:e.jsx(Se,{mode:"popLayout",children:n.map(t=>e.jsxs(Pe.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,x:-10},className:"flex items-center gap-3 p-3 bg-card border rounded-lg",children:[Ge(t.file.type),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:t.file.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(t.file.size/1024/1024).toFixed(2)," MB"]}),t.status==="completed"&&t.suggestedCategory&&e.jsxs(b,{variant:"secondary",className:"text-xs",children:[e.jsx(_e,{className:"h-3 w-3 mr-1"}),t.suggestedCategory,t.categoryConfidence&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",Math.round(t.categoryConfidence*100),"%)"]})]}),t.status==="failed"&&e.jsxs("span",{className:"text-xs text-destructive flex items-center gap-1",children:[e.jsx(q,{className:"h-3 w-3"}),t.error]})]}),(t.status==="uploading"||t.status==="processing")&&e.jsx(Q,{value:t.progress,className:"h-1 mt-2"})]}),t.status==="pending"&&e.jsxs(de,{value:t.userCategory||"auto-detect",onValueChange:a=>s(t.id,{userCategory:a==="auto-detect"?void 0:a}),children:[e.jsx(me,{className:"w-[140px] h-8 text-xs",children:e.jsx(xe,{placeholder:"Auto-detect"})}),e.jsxs(pe,{children:[e.jsx(V,{value:"auto-detect",children:"Auto-detect"}),Ve.map(a=>e.jsx(V,{value:a,children:a},a))]})]}),t.status==="pending"&&e.jsx(X,{checked:t.createWikiPage,onCheckedChange:a=>s(t.id,{createWikiPage:!!a}),title:"Create wiki page"}),t.status==="pending"&&e.jsx(y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>N(t.id),children:e.jsx(ge,{className:"h-4 w-4"})}),(t.status==="uploading"||t.status==="processing"||t.status==="categorizing")&&e.jsx(G,{className:"h-5 w-5 animate-spin text-primary"}),t.status==="completed"&&e.jsx(he,{className:"h-5 w-5 text-success"}),t.status==="failed"&&e.jsx(q,{className:"h-5 w-5 text-destructive"})]},t.id))})})}),f&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Processing ",n.length," files..."]}),e.jsxs("span",{children:[w,"%"]})]}),e.jsx(Q,{value:w})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[T>0&&e.jsxs("span",{className:"text-success",children:[T," completed"]}),T>0&&v>0&&" • ",v>0&&e.jsxs("span",{children:[v," pending"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{variant:"outline",onClick:()=>d(!1),children:T>0?"Close":"Cancel"}),e.jsx(y,{onClick:r,disabled:v===0||f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"h-4 w-4 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),"Upload & Process (",v,")"]})})]})]})]})})}
4const Qe={sales:Ie,contracting:B,delivery:Le,"project-management":We,talent:Re,operations:Oe,general:W};function Zs(){const o=J(),[d,k]=g.useState(""),[E,h]=g.useState("browse"),[S,n]=g.useState(!1),{data:l,isLoading:f,refetch:P}=Z(),{data:x}=F(),{data:j}=ee(),_=l?.reduce((s,c)=>{const r=c.category||"general";return s[r]=(s[r]||0)+1,s},{})||{},D=(()=>{const s=new Set(M.map(r=>r.id)),c=Object.keys(_).filter(r=>!s.has(r)).map(r=>({id:r,label:r.split(/[-_]/).map(w=>w.charAt(0).toUpperCase()+w.slice(1)).join(" "),icon:"BookOpen"}));return[...M,...c]})(),z=s=>D.find(r=>r.id===s)?.label||s.split(/[-_]/).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" "),p=l?.filter(s=>{const c=s.last_reviewed_at?new Date(s.last_reviewed_at):new Date(s.updated_at);return Math.floor((Date.now()-c.getTime())/(1e3*60*60*24))>(s.review_reminder_days||90)})||[],N=d?l?.filter(s=>s.title.toLowerCase().includes(d.toLowerCase())||s.tags?.some(c=>c.toLowerCase().includes(d.toLowerCase()))):[];return e.jsxs("div",{className:"container max-w-7xl py-6 space-y-8",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4","data-tour":"knowledge-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Knowledge Hub"}),e.jsx("p",{className:"text-muted-foreground",children:"Your organization's living documentation"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>n(!0),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),"Bulk Upload"]}),e.jsxs(y,{onClick:()=>o("/knowledge/new"),children:[e.jsx(Ue,{className:"h-4 w-4 mr-2"}),"New Page"]})]})]}),e.jsx(He,{open:S,onOpenChange:n,onComplete:()=>P()}),e.jsxs(ue,{value:E,onValueChange:h,children:[e.jsxs(fe,{children:[e.jsxs(Y,{value:"browse",className:"gap-2",children:[e.jsx(W,{className:"h-4 w-4"}),"Browse"]}),e.jsxs(Y,{value:"governance",className:"gap-2",children:[e.jsx(Ae,{className:"h-4 w-4"}),"Content Governance",p.length>0&&e.jsx(b,{variant:"destructive",className:"ml-1 h-5 px-1.5 text-xs",children:p.length})]})]}),e.jsxs(H,{value:"browse",className:"mt-6 space-y-8",children:[e.jsxs("div",{className:"relative max-w-lg","data-tour":"knowledge-search",children:[e.jsx($e,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(je,{placeholder:"Search knowledge base...",value:d,onChange:s=>k(s.target.value),className:"pl-10"}),d&&N&&N.length>0&&e.jsx(C,{className:"absolute top-full left-0 right-0 mt-1 z-50",children:e.jsx(U,{className:"p-2 max-h-64 overflow-auto",children:N.map(s=>e.jsxs(u,{to:`/knowledge/${s.category}/${s.slug}`,className:"block p-2 hover:bg-accent rounded-md transition-colors",onClick:()=>k(""),children:[e.jsx("div",{className:"font-medium",children:s.title}),e.jsx("div",{className:"text-sm text-muted-foreground capitalize",children:s.category})]},s.id))})})]}),(!l||l.length<10)&&e.jsx(we,{}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(C,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs($,{className:"text-sm flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4 text-muted-foreground"}),"Recently Viewed"]})}),e.jsx(U,{className:"space-y-1",children:x&&x.length>0?x.slice(0,5).map(s=>e.jsx(u,{to:`/knowledge/${s.page?.category}/${s.page?.slug}`,className:"block text-sm hover:text-primary transition-colors truncate",children:s.page?.title},s.wiki_page_id)):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No recent pages"})})]}),e.jsxs(C,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs($,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ee,{className:"h-4 w-4 text-warning"}),"Favorites"]})}),e.jsx(U,{className:"space-y-1",children:j&&j.length>0?j.slice(0,5).map(s=>e.jsx(u,{to:`/knowledge/${s.page?.category}/${s.page?.slug}`,className:"block text-sm hover:text-primary transition-colors truncate",children:s.page?.title},s.wiki_page_id)):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No favorites yet"})})]}),e.jsxs(C,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs($,{className:"text-sm flex items-center gap-2",children:[e.jsx(ze,{className:"h-4 w-4 text-warning"}),"Needs Review"]})}),e.jsx(U,{className:"space-y-1",children:p.length>0?p.slice(0,5).map(s=>e.jsx(u,{to:`/knowledge/${s.category}/${s.slug}`,className:"block text-sm hover:text-primary transition-colors truncate",children:s.title},s.id)):e.jsx("p",{className:"text-sm text-muted-foreground",children:"All pages up to date!"})})]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Browse by Category"}),f?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[...Array(6)].map((s,c)=>e.jsx(Ne,{className:"h-32"}
4,c))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4","data-tour":"wiki-tree",children:D.map(s=>{const c=Qe[s.id]||W,r=_[s.id]||0;return e.jsx(u,{to:`/knowledge/${s.id}`,children:e.jsx(C,{className:"h-full hover:border-primary/50 hover:shadow-md transition-all cursor-pointer group",children:e.jsx(A,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10 text-primary group-hover:bg-primary group-hover:text-primary-foreground transition-colors",children:e.jsx(c,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx($,{className:"text-base",children:s.label}),e.jsxs(se,{children:[r," pages"]})]})]})})})},s.id)})})]}),l&&l.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Recent Updates"}),e.jsx("div",{className:"space-y-2",children:l.sort((s,c)=>new Date(c.updated_at).getTime()-new Date(s.updated_at).getTime()).slice(0,10).map(s=>e.jsxs(u,{to:`/knowledge/${s.category}/${s.slug}`,className:"flex items-center justify-between p-3 border rounded-lg hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(B,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(b,{variant:"outline",className:"text-xs capitalize",children:z(s.category)}),s.status==="draft"&&e.jsx(b,{variant:"secondary",className:"text-xs",children:"Draft"})]})]})]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Ke(new Date(s.updated_at),{addSuffix:!0})})]},s.id))})]})]}),e.jsx(H,{value:"governance",className:"mt-6 space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(ve,{}),e.jsx(Ce,{})]})})]})]})}export{Zs 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.