@robthepcguy/rag-vault 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +28 -9
  2. package/dist/chunker/semantic-chunker.d.ts +0 -1
  3. package/dist/chunker/semantic-chunker.d.ts.map +1 -1
  4. package/dist/chunker/semantic-chunker.js +1 -1
  5. package/dist/chunker/semantic-chunker.js.map +1 -1
  6. package/dist/embedder/index.d.ts +5 -0
  7. package/dist/embedder/index.d.ts.map +1 -1
  8. package/dist/embedder/index.js +40 -5
  9. package/dist/embedder/index.js.map +1 -1
  10. package/dist/errors/index.d.ts +1 -1
  11. package/dist/errors/index.d.ts.map +1 -1
  12. package/dist/flywheel/feedback.d.ts +1 -1
  13. package/dist/flywheel/feedback.d.ts.map +1 -1
  14. package/dist/flywheel/feedback.js +1 -1
  15. package/dist/flywheel/feedback.js.map +1 -1
  16. package/dist/parser/pdf-filter.d.ts +3 -5
  17. package/dist/parser/pdf-filter.d.ts.map +1 -1
  18. package/dist/parser/pdf-filter.js +1 -1
  19. package/dist/parser/pdf-filter.js.map +1 -1
  20. package/dist/query/parser.d.ts +2 -6
  21. package/dist/query/parser.d.ts.map +1 -1
  22. package/dist/query/parser.js +14 -22
  23. package/dist/query/parser.js.map +1 -1
  24. package/dist/server/index.d.ts.map +1 -1
  25. package/dist/server/index.js +37 -34
  26. package/dist/server/index.js.map +1 -1
  27. package/dist/server/raw-data-utils.d.ts +0 -40
  28. package/dist/server/raw-data-utils.d.ts.map +1 -1
  29. package/dist/server/raw-data-utils.js +9 -8
  30. package/dist/server/raw-data-utils.js.map +1 -1
  31. package/dist/server/remote-transport.d.ts +2 -1
  32. package/dist/server/remote-transport.d.ts.map +1 -1
  33. package/dist/server/remote-transport.js +27 -7
  34. package/dist/server/remote-transport.js.map +1 -1
  35. package/dist/server/schemas.d.ts +5 -29
  36. package/dist/server/schemas.d.ts.map +1 -1
  37. package/dist/server/schemas.js +6 -6
  38. package/dist/server/schemas.js.map +1 -1
  39. package/dist/vectordb/index.d.ts +12 -9
  40. package/dist/vectordb/index.d.ts.map +1 -1
  41. package/dist/vectordb/index.js +242 -163
  42. package/dist/vectordb/index.js.map +1 -1
  43. package/dist/web/api-routes.d.ts.map +1 -1
  44. package/dist/web/api-routes.js +23 -10
  45. package/dist/web/api-routes.js.map +1 -1
  46. package/dist/web/database-manager.d.ts.map +1 -1
  47. package/dist/web/database-manager.js +32 -25
  48. package/dist/web/database-manager.js.map +1 -1
  49. package/dist/web/http-server.d.ts +0 -5
  50. package/dist/web/http-server.d.ts.map +1 -1
  51. package/dist/web/http-server.js +4 -8
  52. package/dist/web/http-server.js.map +1 -1
  53. package/dist/web/index.js +4 -2
  54. package/dist/web/index.js.map +1 -1
  55. package/dist/web/middleware/async-handler.d.ts +2 -1
  56. package/dist/web/middleware/async-handler.d.ts.map +1 -1
  57. package/dist/web/middleware/rate-limit.d.ts +2 -1
  58. package/dist/web/middleware/rate-limit.d.ts.map +1 -1
  59. package/dist/web/middleware/request-logger.d.ts +1 -1
  60. package/dist/web/middleware/request-logger.d.ts.map +1 -1
  61. package/package.json +1 -1
  62. package/web-ui/dist/assets/{CollectionsPage-BDmEfv3V.js → CollectionsPage-CjLs8_5j.js} +1 -1
  63. package/web-ui/dist/assets/{FilesPage-pG9HmpgQ.js → FilesPage-Bw9x9aMr.js} +1 -1
  64. package/web-ui/dist/assets/ReaderPage-JPNiOF-x.js +28 -0
  65. package/web-ui/dist/assets/{ReaderSettingsContext-CkSjqsRh.js → ReaderSettingsContext-BLFJnEne.js} +1 -1
  66. package/web-ui/dist/assets/{SearchPage-DAltjnLL.js → SearchPage-D3_Vtbdw.js} +1 -1
  67. package/web-ui/dist/assets/{SettingsPage-C6J5BITP.js → SettingsPage-BAxB2264.js} +1 -1
  68. package/web-ui/dist/assets/{StatusPage-powRGmW3.js → StatusPage-CzJZW8Gs.js} +1 -1
  69. package/web-ui/dist/assets/{UploadPage-eyfSjL4u.js → UploadPage-DW8OujeJ.js} +5 -5
  70. package/web-ui/dist/assets/index-ANt8Xo4z.js +6 -0
  71. package/web-ui/dist/assets/index-DovQIIL4.css +1 -0
  72. package/web-ui/dist/assets/motion-Brxs0UET.js +9 -0
  73. package/web-ui/dist/assets/vendor-DSXQOR6A.js +10 -0
  74. package/web-ui/dist/index.html +3 -3
  75. package/web-ui/dist/assets/ReaderPage-CwMN03NU.js +0 -28
  76. package/web-ui/dist/assets/index-BpwaiuGL.css +0 -1
  77. package/web-ui/dist/assets/index-D068MV_o.js +0 -6
  78. package/web-ui/dist/assets/motion-CKwJwI3J.js +0 -9
  79. package/web-ui/dist/assets/vendor-C2QPsZ3S.js +0 -10
@@ -1 +1 @@
1
- import{a as x,j as e}from"./query-DPt-uCb6.js";import{o as $,p as q,S as C,q as Y,r as Q,t as X,v as Z,u as ee,b as se,k as te,l as re,w as ae,x as ne,a as oe,y as le,z as ie,A as ce,B as de,D as xe,E as me,F as ue,G as he,H as pe,W as be}from"./index-D068MV_o.js";import{b as ve}from"./format-DOJ3IkRX.js";import{m as D}from"./motion-CKwJwI3J.js";import"./vendor-C2QPsZ3S.js";function V({isOpen:s,onClose:a,onSelect:d,initialPath:o,title:n="Select Folder"}){const{preferences:r,setLastBrowsedPath:h,setShowHiddenFiles:m}=$(),[l,y]=x.useState(o||r.lastBrowsedPath||"/"),{browse:f,isLoading:k,data:p,error:w}=q();x.useEffect(()=>{if(s){const g=o||r.lastBrowsedPath||"/";y(g),f(g,r.showHiddenFiles)}},[s,o,r.lastBrowsedPath,r.showHiddenFiles,f]);const N=g=>{y(g),h(g),f(g,r.showHiddenFiles)},i=()=>{const g=l.split("/").slice(0,-1).join("/")||"/";N(g)},b=()=>{h(l),d(l),a()},t=()=>{const g=!r.showHiddenFiles;m(g),f(l,g)};if(!s)return null;const R=l.split("/").filter(Boolean);return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col",style:{background:"var(--ws-surface-raised)"},children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:"var(--ws-border)"},children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--ws-text)"},children:n}),e.jsx("button",{type:"button",onClick:a,className:"p-1 transition-colors",style:{color:"var(--ws-text-muted)"},children:e.jsx(ge,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex items-center gap-1 px-4 py-2 border-b overflow-x-auto",style:{background:"var(--ws-surface-1)",borderColor:"var(--ws-border)"},children:[e.jsx("button",{type:"button",onClick:()=>N("/"),className:"px-2 py-1 text-sm rounded",style:{color:"var(--ws-text-secondary)"},children:"/"}),R.map((g,B)=>{const M=`/${R.slice(0,B+1).join("/")}`;return e.jsxs("span",{className:"flex items-center",children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"/"}),e.jsx("button",{type:"button",onClick:()=>N(M),className:"px-2 py-1 text-sm rounded truncate max-w-32",style:{color:"var(--ws-text-secondary)"},children:g})]},M)})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-50 dark:bg-amber-900/20 border-b border-amber-100 dark:border-amber-800/30",children:[e.jsx("span",{className:"text-sm text-amber-800 dark:text-amber-200 font-mono truncate flex-1",children:l}),e.jsxs("label",{className:"flex items-center gap-2 ml-4 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:r.showHiddenFiles,onChange:t,className:"w-4 h-4 rounded text-amber-600 focus:ring-amber-500",style:{borderColor:"var(--ws-border)"}}),e.jsx("span",{className:"text-xs text-amber-700 dark:text-amber-300 whitespace-nowrap",children:"Show hidden"})]})]}),e.jsx("div",{className:"flex-1 overflow-auto p-2 min-h-[300px]",style:{background:"var(--ws-surface-raised)"},children:k?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(C,{style:{color:"var(--ws-text-muted)"}}),e.jsx("span",{className:"ml-3",style:{color:"var(--ws-text-muted)"},children:"Loading..."})]}):w?e.jsxs("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-300 rounded-lg",children:[e.jsx("p",{className:"font-medium",children:"Error"}),e.jsx("p",{className:"text-sm",children:w.message})]}):e.jsxs("div",{className:"space-y-1",children:[l!=="/"&&e.jsxs("button",{type:"button",onClick:i,className:"w-full flex items-center gap-3 px-3 py-2 text-left rounded-lg transition-colors",children:[e.jsx(ye,{className:"w-5 h-5",style:{color:"var(--ws-text-muted)"}}),e.jsx("span",{style:{color:"var(--ws-text-secondary)"},children:".."})]}),p?.entries.map(g=>e.jsx(fe,{entry:g,onNavigate:N},g.path)),p?.entries.length===0&&e.jsx("p",{className:"text-center py-8",style:{color:"var(--ws-text-muted)"},children:"This directory is empty"})]})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t",style:{borderColor:"var(--ws-border)",background:"var(--ws-surface-1)"},children:[e.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 text-sm font-medium border rounded-lg transition-colors",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:b,className:"px-4 py-2 text-sm font-medium text-white bg-amber-600 rounded-lg hover:bg-amber-700 transition-colors",children:"Select This Folder"})]})]})})}function fe({entry:s,onNavigate:a}){const d=s.name.startsWith(".");return s.isDirectory?e.jsxs("button",{type:"button",onClick:()=>a(s.path),className:`w-full flex items-center gap-3 px-3 py-2 text-left rounded-lg transition-colors ${d?"opacity-60":""}`,children:[e.jsx(je,{className:"w-5 h-5 text-amber-500"}),e.jsx("span",{className:"truncate",style:{color:"var(--ws-text)"},children:s.name})]}):e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 ${d?"opacity-50":""}`,style:{color:"var(--ws-text-muted)"},children:[e.jsx(we,{className:"w-5 h-5"}),e.jsx("span",{className:"truncate",children:s.name})]})}function ge({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}function je({className:s}){return e.jsx("svg",{className:s,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}function ye({className:s,style:a}){return e.jsx("svg",{className:s,style:a,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2zM12 11v6m0-6l-3 3m3-3l3 3"})})}function we({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})}function Ne({data:s,isLoading:a,onAdd:d,onRemove:o,isAdding:n,isRemoving:r}){const[h,m]=x.useState(!1),[l,y]=x.useState(null),f=t=>{y(t),o(t)},k=t=>{d(t)},p=t=>s?.userRoots.includes(t)??!1,w=t=>s?.envRoots.includes(t)??!1,N=t=>t===s?.baseDir,i=t=>N(t)?"Base Dir":w(t)?"Env":p(t)?"Custom":"",b=t=>N(t)?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":w(t)?"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300":p(t)?"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300":"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300";return e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-purple-50 dark:bg-purple-900/30 rounded-lg",children:e.jsx(ke,{className:"w-6 h-6 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Allowed Scan Roots"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Directories where database scanning is permitted"})]})]}),e.jsx("button",{type:"button",onClick:()=>m(!0),disabled:n,className:"px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-2",children:n?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm"}),"Adding..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ce,{className:"w-4 h-4"}),"Add Root"]})})]}),a?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(C,{style:{color:"var(--ws-text-muted)"}}),e.jsx("span",{className:"ml-3",style:{color:"var(--ws-text-muted)"},children:"Loading allowed roots..."})]}):e.jsxs("div",{className:"space-y-2",children:[s?.roots.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg",style:{background:"var(--ws-surface-1)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx(Se,{className:"w-5 h-5 flex-shrink-0",style:{color:"var(--ws-text-muted)"}}),e.jsx("span",{className:"font-mono text-sm truncate",style:{color:"var(--ws-text-secondary)"},title:t,children:t}),e.jsx("span",{className:`px-2 py-0.5 text-xs font-medium rounded-full flex-shrink-0 ${b(t)}`,children:i(t)})]}),p(t)&&e.jsx("button",{type:"button",onClick:()=>f(t),disabled:r,className:"ml-4 p-1 text-red-500 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-900/30 rounded disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Remove this root",children:r&&l===t?e.jsx(C,{size:"sm"}):e.jsx(Le,{className:"w-4 h-4"})})]},t)),s?.roots.length===0&&e.jsx("p",{className:"text-center py-4",style:{color:"var(--ws-text-muted)"},children:"No allowed roots configured"})]}),e.jsxs("div",{className:"mt-4 text-xs space-y-1",style:{color:"var(--ws-text-muted)"},children:[e.jsxs("p",{children:[e.jsx("strong",{style:{color:"var(--ws-text-secondary)"},children:"Base Dir:"})," Current database directory (always allowed)"]}),e.jsxs("p",{children:[e.jsx("strong",{style:{color:"var(--ws-text-secondary)"},children:"Env:"})," Set via ALLOWED_SCAN_ROOTS environment variable"]}),e.jsxs("p",{children:[e.jsx("strong",{style:{color:"var(--ws-text-secondary)"},children:"Custom:"})," User-added roots (can be removed)"]})]}),e.jsx(V,{isOpen:h,onClose:()=>m(!1),onSelect:k,title:"Add Allowed Root"})]})}function ke({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}function Ce({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function Se({className:s,style:a}){return e.jsx("svg",{className:s,style:a,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}function Le({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function De({models:s,value:a,onChange:d,isLoading:o=!1,disabled:n=!1,label:r="Embedding Model",id:h="model-selector"}){const m=s.find(l=>l.id===a)||s.find(l=>l.isDefault);return e.jsxs("div",{children:[r&&e.jsx("label",{htmlFor:h,className:"block text-sm font-medium mb-1",style:{color:"var(--ws-text-secondary)"},children:r}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{id:h,value:a||m?.id||"",onChange:l=>d(l.target.value),disabled:n||o,className:"w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-amber-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed appearance-none pr-10",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)",color:"var(--ws-text)"},children:o?e.jsx("option",{children:"Loading models..."}):s.map(l=>e.jsxs("option",{value:l.id,children:[l.name," ",l.isDefault?"(default)":""]},l.id))}),e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none",children:o?e.jsx(C,{size:"sm",style:{color:"var(--ws-text-muted)"}}):e.jsx(Ie,{className:"w-4 h-4",style:{color:"var(--ws-text-muted)"}})})]}),m&&e.jsx("p",{className:"mt-1 text-xs",style:{color:"var(--ws-text-muted)"},children:m.description})]})}function Ie({className:s,style:a}){return e.jsx("svg",{className:s,style:a,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}function Re({onCreate:s,isLoading:a,error:d}){const[o,n]=x.useState(""),[r,h]=x.useState(""),[m,l]=x.useState(!1),[y,f]=x.useState(!1),{models:k,isLoading:p}=Y(),w=k.find(b=>b.isDefault)?.id||"",N=b=>{b.preventDefault(),o.trim()&&(s(o.trim(),void 0,r||w),n(""),h(""),l(!1))},i=b=>{n(b)};return e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-purple-50 dark:bg-purple-900/30 rounded-lg",children:e.jsx(Be,{className:"w-6 h-6 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Create Database"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Create a new RAG database"})]})]}),m?e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"dbPath",className:"block text-sm font-medium mb-1",style:{color:"var(--ws-text-secondary)"},children:"Database Path"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",id:"dbPath",value:o,onChange:b=>n(b.target.value),placeholder:"/path/to/new-database",className:"flex-1 px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)",color:"var(--ws-text)"},disabled:a}),e.jsx("button",{type:"button",onClick:()=>f(!0),disabled:a,className:"px-3 py-2 text-sm font-medium border rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition-colors",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},title:"Browse folders",children:e.jsx(Ae,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"mt-1 text-xs",style:{color:"var(--ws-text-muted)"},children:"Enter the full path where you want to create the database"})]}),e.jsx(De,{models:k,value:r||w,onChange:h,isLoading:p,disabled:a}),d&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-700 dark:text-red-300",children:d.message}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{type:"submit",disabled:a||!o.trim(),className:"flex-1 px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:a?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx(C,{size:"sm"}),"Creating..."]}):"Create Database"}),e.jsx("button",{type:"button",onClick:()=>{l(!1),n(""),h("")},disabled:a,className:"px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-50 transition-colors",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-1)"},children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>l(!0),className:"w-full px-4 py-3 text-sm font-medium text-purple-700 dark:text-purple-300 bg-purple-50 dark:bg-purple-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:bg-purple-100 dark:hover:bg-purple-900/50 transition-colors",children:"+ Create New Database"}),e.jsx(V,{isOpen:y,onClose:()=>f(!1),onSelect:i,title:"Select Database Location"})]})}function Be({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function Ae({className:s}){return e.jsx("svg",{className:s,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}const Me=[{value:0,label:"Off"},{value:3e4,label:"30s"},{value:6e4,label:"1m"},{value:3e5,label:"5m"}];function Ee({config:s,onRefresh:a,isFetching:d}){const{preferences:o,setStatsRefreshInterval:n}=$();return e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-green-50 dark:bg-green-900/30 rounded-lg",children:e.jsx(Fe,{className:"w-6 h-6 text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Current Database"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Active RAG database"})]})]}),a&&e.jsx("button",{type:"button",onClick:a,disabled:d,className:"p-2 rounded-lg transition-colors disabled:opacity-50",style:{color:"var(--ws-text-muted)"},title:"Refresh stats",children:d?e.jsx(C,{size:"sm"}):e.jsx(Pe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",style:{borderColor:"var(--ws-border-subtle)"},children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Name"}),e.jsx("span",{className:"font-medium",style:{color:"var(--ws-text)"},children:s.name})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",style:{borderColor:"var(--ws-border-subtle)"},children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Path"}),e.jsx("span",{className:"font-mono text-sm max-w-xs truncate",style:{color:"var(--ws-text)"},title:s.dbPath,children:s.dbPath})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",style:{borderColor:"var(--ws-border-subtle)"},children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Model"}),e.jsx("span",{className:"font-mono text-sm",style:{color:"var(--ws-text)"},children:s.modelName})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",style:{borderColor:"var(--ws-border-subtle)"},children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Documents"}),e.jsx("span",{className:"font-medium",style:{color:"var(--ws-text)"},children:s.documentCount})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",style:{borderColor:"var(--ws-border-subtle)"},children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Chunks"}),e.jsx("span",{className:"font-medium",style:{color:"var(--ws-text)"},children:s.chunkCount})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Auto-refresh"}),e.jsx("div",{className:"flex items-center gap-1 p-0.5 rounded-lg",style:{background:"var(--ws-surface-1)"},children:Me.map(({value:r,label:h})=>e.jsx("button",{type:"button",onClick:()=>n(r),className:`px-2 py-1 text-xs font-medium rounded transition-all ${o.statsRefreshInterval===r?"shadow-sm":""}`,style:o.statsRefreshInterval===r?{background:"var(--ws-surface-raised)",color:"var(--ws-text)"}:{color:"var(--ws-text-muted)"},children:h},r))})]})]})]})}function Fe({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"})})}function Pe({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function ze({databases:s,currentDbPath:a,onSwitch:d,onDelete:o,isLoading:n}){const[r,h]=x.useState(null),[m,l]=x.useState(null),[y,f]=x.useState(null),k=i=>{h(i),d(i)},p=i=>{f({path:i.path,name:i.name})},w=async i=>{if(y){l(y.path);try{await o(y.path,i)}finally{l(null),f(null)}}},N=s.filter(i=>i.path!==a);return N.length===0?e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg",style:{background:"var(--ws-accent-subtle)"},children:e.jsx(U,{className:"w-6 h-6",style:{color:"var(--ws-accent)"}})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Recent Databases"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Switch between databases"})]})]}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"No other databases available. Create a new database or scan for existing ones."})]}):e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg",style:{background:"var(--ws-accent-subtle)"},children:e.jsx(U,{className:"w-6 h-6",style:{color:"var(--ws-accent)"}})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Recent Databases"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Switch between databases"})]})]}),e.jsx("div",{className:"space-y-2",children:N.map(i=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg",style:{background:"var(--ws-surface-1)"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",style:{color:"var(--ws-text)"},children:i.name}),e.jsx("p",{className:"text-sm font-mono truncate max-w-xs",style:{color:"var(--ws-text-muted)"},title:i.path,children:i.path}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"var(--ws-text-muted)"},children:[e.jsxs("span",{children:["Last used: ",ve(i.lastAccessed)]}),i.modelName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{className:"font-mono",children:i.modelName.split("/").pop()})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx("button",{type:"button",onClick:()=>k(i.path),disabled:n,className:"px-4 py-2 text-sm font-medium text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-700 rounded-lg hover:bg-blue-100 dark:hover:bg-blue-900/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:n&&r===i.path?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm"}),"Switching..."]}):"Switch"}),e.jsx("button",{type:"button",onClick:()=>p(i),disabled:n||m===i.path,className:"p-2 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition-colors",style:{color:"var(--ws-text-muted)"},title:"Remove database",children:m===i.path?e.jsx(C,{size:"sm"}):e.jsx(We,{className:"w-5 h-5"})})]})]},i.path))}),y&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"rounded-lg p-6 max-w-md mx-4 shadow-xl",style:{background:"var(--ws-surface-raised)"},children:[e.jsx("h3",{className:"text-lg font-medium mb-2",style:{color:"var(--ws-text)"},children:"Remove Database"}),e.jsxs("p",{className:"mb-4",style:{color:"var(--ws-text-secondary)"},children:["Remove ",e.jsx("span",{className:"font-medium",children:y.name})," from your recent databases?"]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",onClick:()=>w(!1),disabled:n,className:"w-full px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-50 transition-colors",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-1)"},children:"Remove from list only"}),e.jsx("button",{type:"button",onClick:()=>w(!0),disabled:n,className:"w-full px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-700 disabled:opacity-50 transition-colors",children:"Delete files permanently"}),e.jsx("button",{type:"button",onClick:()=>f(null),disabled:n,className:"w-full px-4 py-2 text-sm font-medium transition-colors",style:{color:"var(--ws-text-muted)"},children:"Cancel"})]})]})})]})}function U({className:s,style:a}){return e.jsx("svg",{className:s,style:a,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}function We({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function He(){const s=x.useRef(null),{exportConfigAsync:a,isLoading:d}=Q(),{importConfig:o,isLoading:n}=X(),{addToast:r}=Z(),{exportLinks:h,importLinks:m}=ee(),{exportAnnotations:l,importAnnotations:y}=se(),{exportCollections:f,importCollections:k}=te(),{exportTags:p,importTags:w}=re(),[N,i]=x.useState(!1),[b,t]=x.useState({includeLinks:!0,includeAnnotations:!0,includeCollections:!0,includeTags:!0,includeServerConfig:!0}),[R,g]=x.useState(!1),[B,M]=x.useState("merge"),[L,F]=x.useState(null),[I,E]=x.useState(!1),W=x.useCallback(async()=>{E(!0);try{const c={version:1,exportedAt:new Date().toISOString(),vaultId:"default",data:{}};if(b.includeLinks&&(c.data.links=JSON.parse(h())),b.includeAnnotations&&(c.data.annotations=JSON.parse(l())),b.includeCollections&&(c.data.collections=JSON.parse(f())),b.includeTags&&(c.data.tags=JSON.parse(p())),b.includeServerConfig)try{c.data.serverConfig=await a()}catch{}const j=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),v=URL.createObjectURL(j),u=document.createElement("a");u.href=v,u.download=`rag-vault-backup-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(v),r({type:"success",title:"Export complete",message:"Your vault data has been exported"}),i(!1)}catch(c){r({type:"error",title:"Export failed",message:c instanceof Error?c.message:"Unknown error"})}finally{E(!1)}},[b,h,l,f,p,a,r]),H=x.useCallback(async c=>{const j=c.target.files?.[0];if(j){try{const v=await j.text(),u=JSON.parse(v);if(u.version===1&&u.data)F(u),g(!0);else if(u.version&&u.allowedRoots)o(u),r({type:"success",title:"Config imported",message:"Server configuration has been restored"});else throw new Error("Unrecognized file format")}catch(v){r({type:"error",title:"Failed to import",message:v instanceof Error?v.message:"Invalid file format"})}s.current&&(s.current.value="")}},[o,r]),z=x.useCallback(async()=>{if(!L)return;E(!0);const c=[];let j=0;try{const{data:v}=L;if(v.links){const{imported:u,errors:S}=m(JSON.stringify(v.links));j+=u,S.length>0&&c.push(`Links: ${S.join(", ")}`)}if(v.annotations){const{imported:u,errors:S}=y(JSON.stringify(v.annotations));j+=u,S.length>0&&c.push(`Annotations: ${S.join(", ")}`)}if(v.collections){const{imported:u,errors:S}=k(JSON.stringify(v.collections));j+=u,S.length>0&&c.push(`Collections: ${S.join(", ")}`)}if(v.tags){const{imported:u,errors:S}=w(JSON.stringify(v.tags));j+=u,S.length>0&&c.push(`Tags: ${S.join(", ")}`)}if(v.serverConfig)try{o(v.serverConfig),c.push("Server config restored")}catch{c.push("Server config: import failed")}r({type:"success",title:"Import complete",message:`Imported ${j} items`})}catch(v){r({type:"error",title:"Import failed",message:v instanceof Error?v.message:"Unknown error"})}finally{E(!1),g(!1),F(null)}},[L,B,m,y,k,w,o,r]);return e.jsxs("div",{className:"ws-card","data-padding":"lg",children:[e.jsx("div",{className:"ws-card-header",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg",style:{background:"var(--ws-accent-muted)"},children:e.jsx(Oe,{className:"w-6 h-6",style:{color:"var(--ws-accent)"}})}),e.jsxs("div",{children:[e.jsx("div",{className:"ws-card-title",children:"Export / Import"}),e.jsx("div",{className:"ws-card-subtitle",children:"Backup and restore your vault data"})]})]})}),e.jsxs("div",{className:"ws-card-body",children:[N&&e.jsxs("div",{className:"mb-4 p-4 rounded-lg",style:{background:"var(--ws-surface-1)",border:"1px solid var(--ws-border)"},children:[e.jsx("h3",{className:"text-sm font-medium mb-3",style:{color:"var(--ws-text-secondary)"},children:"Select data to export"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{checked:b.includeLinks,onChange:c=>t(j=>({...j,includeLinks:c})),label:"Links, trails & bookmarks"}),e.jsx(P,{checked:b.includeAnnotations,onChange:c=>t(j=>({...j,includeAnnotations:c})),label:"Highlights & annotations"}),e.jsx(P,{checked:b.includeCollections,onChange:c=>t(j=>({...j,includeCollections:c})),label:"Collections"}),e.jsx(P,{checked:b.includeTags,onChange:c=>t(j=>({...j,includeTags:c})),label:"Tags"}),e.jsx(P,{checked:b.includeServerConfig,onChange:c=>t(j=>({...j,includeServerConfig:c})),label:"Server config"})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsxs("button",{type:"button",onClick:W,disabled:I,className:"ws-button flex-1","data-variant":"primary","data-size":"md",children:[I?e.jsx(C,{size:"sm"}):e.jsx(J,{className:"w-4 h-4"}),"Export"]}),e.jsx("button",{type:"button",onClick:()=>i(!1),className:"ws-button","data-variant":"ghost","data-size":"md",children:"Cancel"})]})]}),R&&L&&e.jsxs("div",{className:"mb-4 p-4 rounded-lg",style:{background:"var(--ws-surface-1)",border:"1px solid var(--ws-border)"},children:[e.jsx("h3",{className:"text-sm font-medium mb-3",style:{color:"var(--ws-text-secondary)"},children:"Import vault backup"}),e.jsxs("p",{className:"text-xs mb-3",style:{color:"var(--ws-text-muted)"},children:["From: ",new Date(L.exportedAt).toLocaleDateString()]}),e.jsxs("div",{className:"mb-3 text-xs",style:{color:"var(--ws-text-secondary)"},children:[e.jsx("p",{className:"font-medium mb-1",children:"Contains:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[L.data.links&&e.jsx("li",{children:"Links, trails & bookmarks"}),L.data.annotations&&e.jsx("li",{children:"Highlights & annotations"}),L.data.collections&&e.jsx("li",{children:"Collections"}),L.data.tags&&e.jsx("li",{children:"Tags"}),L.data.serverConfig&&e.jsx("li",{children:"Server config"})]})]}),e.jsx("div",{className:"mb-3",children:e.jsxs("label",{className:"block text-xs font-medium mb-1",style:{color:"var(--ws-text-muted)"},children:["Import strategy",e.jsxs("select",{value:B,onChange:c=>M(c.target.value),className:"ws-select mt-1 w-full",children:[e.jsx("option",{value:"merge",children:"Merge (skip duplicates)"}),e.jsx("option",{value:"overwrite",children:"Add all (may create duplicates)"})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:z,disabled:I,className:"ws-button flex-1","data-variant":"primary","data-size":"md",children:[I?e.jsx(C,{size:"sm"}):e.jsx(G,{className:"w-4 h-4"}),"Import"]}),e.jsx("button",{type:"button",onClick:()=>{g(!1),F(null)},className:"ws-button","data-variant":"ghost","data-size":"md",children:"Cancel"})]})]}),!N&&!R&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("button",{type:"button",onClick:()=>i(!0),disabled:d||I,className:"ws-button flex-1","data-variant":"primary","data-size":"lg",children:d?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm"}),"Exporting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4"}),"Export Vault"]})}),e.jsx("button",{type:"button",onClick:()=>s.current?.click(),disabled:n||I,className:"ws-button flex-1","data-variant":"default","data-size":"lg",children:n?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-4 h-4"}),"Import Backup"]})}),e.jsx("input",{ref:s,type:"file",accept:".json",onChange:H,className:"hidden"})]}),e.jsx("p",{className:"mt-4 text-xs",style:{color:"var(--ws-text-muted)"},children:"Export saves all your vault data including links, annotations, collections, and tags. Import restores from a previously exported backup."})]})]})}function P({checked:s,onChange:a,label:d}){return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:o=>a(o.target.checked),className:"w-4 h-4 rounded",style:{accentColor:"var(--ws-accent)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--ws-text-secondary)"},children:d})]})}function Oe({className:s,style:a}){return e.jsxs("svg",{className:s,style:a,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function J({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})})}function G({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}function Te(){const{weight:s,isLoading:a}=ae(),{setWeight:d,isLoading:o}=ne(),[n,r]=x.useState(s),[h,m]=x.useState(!1);x.useEffect(()=>{h||r(s)},[s,h]);const l=x.useCallback(p=>{const w=parseFloat(p.target.value);r(w),m(!0)},[]),y=x.useCallback(()=>{d(n),m(!1)},[n,d]),f=x.useCallback(()=>{r(s),m(!1)},[s]),k=p=>p===0?"Vector-only search (pure semantic similarity)":p<.3?"Minimal keyword boost, semantic-focused":p<.5?"Balanced toward semantic meaning":p<.7?"Balanced hybrid search (recommended)":p<.9?"Balanced toward keyword matching":p<1?"Strong keyword boost, keyword-focused":"Maximum keyword influence";return e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-cyan-50 dark:bg-cyan-900/30 rounded-lg",children:e.jsx($e,{className:"w-6 h-6 text-cyan-600 dark:text-cyan-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Hybrid Search Weight"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Balance between semantic and keyword matching"})]})]}),a?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(C,{style:{color:"var(--ws-text-muted)"}}),e.jsx("span",{className:"ml-3",style:{color:"var(--ws-text-muted)"},children:"Loading settings..."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",style:{color:"var(--ws-text-secondary)"},children:"Semantic"}),e.jsx("span",{className:"text-sm font-mono",style:{color:"var(--ws-text)"},children:n.toFixed(2)}),e.jsx("span",{className:"text-sm",style:{color:"var(--ws-text-secondary)"},children:"Keyword"})]}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.05",value:n,onChange:l,className:"w-full h-2 rounded-lg appearance-none cursor-pointer accent-cyan-600",style:{background:"var(--ws-surface-2)"}}),e.jsx("p",{className:"text-sm text-center",style:{color:"var(--ws-text-secondary)"},children:k(n)})]}),h&&e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx("button",{type:"button",onClick:y,disabled:o,className:"flex-1 flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium text-white bg-cyan-600 rounded-lg hover:bg-cyan-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:o?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm"}),"Saving..."]}):"Apply"}),e.jsx("button",{type:"button",onClick:f,disabled:o,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:"var(--ws-text-secondary)"},children:"Reset"})]})]}),e.jsx("div",{className:"mt-4 p-3 rounded-lg",style:{background:"var(--ws-surface-1)"},children:e.jsxs("p",{className:"text-xs space-y-1",style:{color:"var(--ws-text-secondary)"},children:[e.jsxs("span",{className:"block",children:[e.jsx("strong",{style:{color:"var(--ws-text-secondary)"},children:"Lower values (0.0-0.4):"})," ","Better for conceptual questions, finding related ideas"]}),e.jsxs("span",{className:"block",children:[e.jsx("strong",{style:{color:"var(--ws-text-secondary)"},children:"Higher values (0.6-1.0):"})," ","Better for exact terms, code, error messages"]})]})})]})}function $e({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function Ve({onScan:s,onSwitch:a,isScanning:d,isSwitching:o,scanResults:n,error:r,onReset:h}){const[m,l]=x.useState(""),[y,f]=x.useState(null),[k,p]=x.useState(!1),w=t=>{t.preventDefault(),m.trim()&&s(m.trim())},N=t=>{f(t),a(t)},i=()=>{l(""),h()},b=t=>{l(t)};return e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-amber-50 dark:bg-amber-900/30 rounded-lg",children:e.jsx(Ue,{className:"w-6 h-6 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Scan for Databases"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Find existing RAG databases"})]})]}),e.jsx("form",{onSubmit:w,className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("label",{htmlFor:"scanPath",className:"block text-sm font-medium mb-1",style:{color:"var(--ws-text-secondary)"},children:"Directory to Scan"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",id:"scanPath",value:m,onChange:t=>l(t.target.value),placeholder:"/path/to/scan",className:"flex-1 px-3 py-2 border rounded-lg focus:ring-2 focus:ring-amber-500 focus:border-transparent",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)",color:"var(--ws-text)"},disabled:d}),e.jsx("button",{type:"button",onClick:()=>p(!0),disabled:d,className:"px-3 py-2 text-sm font-medium border rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition-colors",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},title:"Browse folders",children:e.jsx(Je,{className:"w-5 h-5"})}),e.jsx("button",{type:"submit",disabled:d||!m.trim(),className:"px-4 py-2 text-sm font-medium text-white bg-amber-600 rounded-lg hover:bg-amber-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm"}),"Scanning..."]}):"Scan"})]}),e.jsx("p",{className:"mt-1 text-xs",style:{color:"var(--ws-text-muted)"},children:"Searches the directory and up to 2 levels of subdirectories"})]})}),r&&e.jsx("div",{className:"mt-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-700 dark:text-red-300",children:r.message}),n&&e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-sm font-medium",style:{color:"var(--ws-text-secondary)"},children:["Found ",n.length," database",n.length!==1?"s":""]}),e.jsx("button",{type:"button",onClick:i,className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Clear results"})]}),n.length===0?e.jsx("p",{className:"text-sm py-2",style:{color:"var(--ws-text-muted)"},children:"No databases found in this directory."}):e.jsx("div",{className:"space-y-2",children:n.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg",style:{background:"var(--ws-surface-1)"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",style:{color:"var(--ws-text)"},children:t.name}),t.isKnown&&e.jsx("span",{className:"px-2 py-0.5 text-xs font-medium text-green-700 dark:text-green-300 bg-green-100 dark:bg-green-900/30 rounded-full",children:"Known"})]}),e.jsx("p",{className:"text-sm font-mono truncate max-w-xs",style:{color:"var(--ws-text-muted)"},title:t.path,children:t.path})]}),e.jsx("button",{type:"button",onClick:()=>N(t.path),disabled:o,className:"ml-4 px-4 py-2 text-sm font-medium text-amber-700 dark:text-amber-300 bg-amber-50 dark:bg-amber-900/30 border border-amber-200 dark:border-amber-700 rounded-lg hover:bg-amber-100 dark:hover:bg-amber-900/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:o&&y===t.path?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm"}),"Switching..."]}):"Use"})]},t.path))})]}),e.jsx(V,{isOpen:k,onClose:()=>p(!1),onSelect:b,title:"Select Directory to Scan"})]})}function Ue({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function Je({className:s}){return e.jsx("svg",{className:s,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}const T={hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.1}}},A={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.3,ease:[.25,.1,.25,1]}}},Ge=[{id:"database",label:"Database"},{id:"search",label:"Search"},{id:"data",label:"Data"}];function Xe(){const[s,a]=oe("settings-active-tab","database"),{preferences:d}=$(),{config:o,isLoading:n,error:r,refetch:h,isFetching:m}=le(d.statsRefreshInterval),{databases:l,isLoading:y}=ie(),{switchDatabase:f,isLoading:k}=ce(),{deleteDatabase:p,isLoading:w}=de(),{createDatabase:N,isLoading:i,error:b}=xe(),{scan:t,isLoading:R,data:g,error:B,reset:M}=me(),{data:L,isLoading:F}=ue(),{addRoot:I,isLoading:E}=he(),{removeRoot:W,isLoading:H}=pe(),z=u=>{f(u)},c=async(u,S)=>{await new Promise((O,K)=>{p({dbPath:u,deleteFiles:S},{onSuccess:()=>O(),onError:_=>K(_)})})},j=(u,S,O)=>{N({dbPath:u,modelName:O})},v=u=>{t(u)};return e.jsxs("div",{className:"ws-page max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"ws-page-title text-2xl font-bold mb-2",children:"Settings"}),e.jsx("p",{style:{color:"var(--ws-text-secondary)"},children:"Manage your RAG database configuration."})]}),e.jsx("button",{type:"button",onClick:()=>h(),disabled:n||m,className:"ws-button px-4 py-2 text-sm rounded-lg transition-colors","data-variant":"default",children:n||m?"Refreshing...":"Refresh"})]}),n&&!o?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx("span",{style:{color:"var(--ws-text-faint)"},children:e.jsx(C,{})}),e.jsx("span",{className:"ml-3",style:{color:"var(--ws-text-muted)"},children:"Loading configuration..."})]}):r?e.jsxs("div",{className:"ws-error-box rounded-lg",children:[e.jsx("p",{className:"font-medium",children:"Error loading configuration"}),e.jsx("p",{className:"text-sm",children:r.message})]}):e.jsxs(e.Fragment,{children:[e.jsx(be,{tabs:Ge,activeId:s,onSelect:a,variant:"underline",className:"mb-6"}),s==="database"&&e.jsxs(D.div,{className:"space-y-6",variants:T,initial:"hidden",animate:"visible",children:[o&&e.jsx(D.div,{variants:A,children:e.jsx(Ee,{config:o,onRefresh:()=>h(),isFetching:m})}),!y&&e.jsx(D.div,{variants:A,children:e.jsx(ze,{databases:l,currentDbPath:o?.dbPath,onSwitch:z,onDelete:c,isLoading:k||w})}),e.jsx(D.div,{variants:A,children:e.jsx(Re,{onCreate:j,isLoading:i,error:b})}),e.jsx(D.div,{variants:A,children:e.jsx(Ve,{onScan:v,onSwitch:z,isScanning:R,isSwitching:k,scanResults:g,error:B,onReset:M})})]}),s==="search"&&e.jsxs(D.div,{className:"space-y-6",variants:T,initial:"hidden",animate:"visible",children:[e.jsx(D.div,{variants:A,children:e.jsx(Ne,{data:L,isLoading:F,onAdd:I,onRemove:W,isAdding:E,isRemoving:H})}),e.jsx(D.div,{variants:A,children:e.jsx(Te,{})})]}),s==="data"&&e.jsx(D.div,{className:"space-y-6",variants:T,initial:"hidden",animate:"visible",children:e.jsx(D.div,{variants:A,children:e.jsx(He,{})})})]})]})}export{Xe as SettingsPage};
1
+ import{a as x,j as e}from"./query-DPt-uCb6.js";import{o as $,p as q,S as C,q as Y,r as Q,t as X,v as Z,u as ee,b as se,k as te,l as re,w as ae,x as ne,a as oe,y as le,z as ie,A as ce,B as de,D as xe,E as me,F as ue,G as he,H as pe,W as be}from"./index-ANt8Xo4z.js";import{b as ve}from"./format-DOJ3IkRX.js";import{m as D}from"./motion-Brxs0UET.js";import"./vendor-DSXQOR6A.js";function V({isOpen:s,onClose:a,onSelect:d,initialPath:o,title:n="Select Folder"}){const{preferences:r,setLastBrowsedPath:h,setShowHiddenFiles:m}=$(),[l,y]=x.useState(o||r.lastBrowsedPath||"/"),{browse:f,isLoading:k,data:p,error:w}=q();x.useEffect(()=>{if(s){const g=o||r.lastBrowsedPath||"/";y(g),f(g,r.showHiddenFiles)}},[s,o,r.lastBrowsedPath,r.showHiddenFiles,f]);const N=g=>{y(g),h(g),f(g,r.showHiddenFiles)},i=()=>{const g=l.split("/").slice(0,-1).join("/")||"/";N(g)},b=()=>{h(l),d(l),a()},t=()=>{const g=!r.showHiddenFiles;m(g),f(l,g)};if(!s)return null;const R=l.split("/").filter(Boolean);return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col",style:{background:"var(--ws-surface-raised)"},children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:"var(--ws-border)"},children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--ws-text)"},children:n}),e.jsx("button",{type:"button",onClick:a,className:"p-1 transition-colors",style:{color:"var(--ws-text-muted)"},children:e.jsx(ge,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex items-center gap-1 px-4 py-2 border-b overflow-x-auto",style:{background:"var(--ws-surface-1)",borderColor:"var(--ws-border)"},children:[e.jsx("button",{type:"button",onClick:()=>N("/"),className:"px-2 py-1 text-sm rounded",style:{color:"var(--ws-text-secondary)"},children:"/"}),R.map((g,B)=>{const M=`/${R.slice(0,B+1).join("/")}`;return e.jsxs("span",{className:"flex items-center",children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"/"}),e.jsx("button",{type:"button",onClick:()=>N(M),className:"px-2 py-1 text-sm rounded truncate max-w-32",style:{color:"var(--ws-text-secondary)"},children:g})]},M)})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-50 dark:bg-amber-900/20 border-b border-amber-100 dark:border-amber-800/30",children:[e.jsx("span",{className:"text-sm text-amber-800 dark:text-amber-200 font-mono truncate flex-1",children:l}),e.jsxs("label",{className:"flex items-center gap-2 ml-4 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:r.showHiddenFiles,onChange:t,className:"w-4 h-4 rounded text-amber-600 focus:ring-amber-500",style:{borderColor:"var(--ws-border)"}}),e.jsx("span",{className:"text-xs text-amber-700 dark:text-amber-300 whitespace-nowrap",children:"Show hidden"})]})]}),e.jsx("div",{className:"flex-1 overflow-auto p-2 min-h-[300px]",style:{background:"var(--ws-surface-raised)"},children:k?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(C,{style:{color:"var(--ws-text-muted)"}}),e.jsx("span",{className:"ml-3",style:{color:"var(--ws-text-muted)"},children:"Loading..."})]}):w?e.jsxs("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-300 rounded-lg",children:[e.jsx("p",{className:"font-medium",children:"Error"}),e.jsx("p",{className:"text-sm",children:w.message})]}):e.jsxs("div",{className:"space-y-1",children:[l!=="/"&&e.jsxs("button",{type:"button",onClick:i,className:"w-full flex items-center gap-3 px-3 py-2 text-left rounded-lg transition-colors",children:[e.jsx(ye,{className:"w-5 h-5",style:{color:"var(--ws-text-muted)"}}),e.jsx("span",{style:{color:"var(--ws-text-secondary)"},children:".."})]}),p?.entries.map(g=>e.jsx(fe,{entry:g,onNavigate:N},g.path)),p?.entries.length===0&&e.jsx("p",{className:"text-center py-8",style:{color:"var(--ws-text-muted)"},children:"This directory is empty"})]})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t",style:{borderColor:"var(--ws-border)",background:"var(--ws-surface-1)"},children:[e.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 text-sm font-medium border rounded-lg transition-colors",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:b,className:"px-4 py-2 text-sm font-medium text-white bg-amber-600 rounded-lg hover:bg-amber-700 transition-colors",children:"Select This Folder"})]})]})})}function fe({entry:s,onNavigate:a}){const d=s.name.startsWith(".");return s.isDirectory?e.jsxs("button",{type:"button",onClick:()=>a(s.path),className:`w-full flex items-center gap-3 px-3 py-2 text-left rounded-lg transition-colors ${d?"opacity-60":""}`,children:[e.jsx(je,{className:"w-5 h-5 text-amber-500"}),e.jsx("span",{className:"truncate",style:{color:"var(--ws-text)"},children:s.name})]}):e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 ${d?"opacity-50":""}`,style:{color:"var(--ws-text-muted)"},children:[e.jsx(we,{className:"w-5 h-5"}),e.jsx("span",{className:"truncate",children:s.name})]})}function ge({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}function je({className:s}){return e.jsx("svg",{className:s,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}function ye({className:s,style:a}){return e.jsx("svg",{className:s,style:a,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2zM12 11v6m0-6l-3 3m3-3l3 3"})})}function we({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})}function Ne({data:s,isLoading:a,onAdd:d,onRemove:o,isAdding:n,isRemoving:r}){const[h,m]=x.useState(!1),[l,y]=x.useState(null),f=t=>{y(t),o(t)},k=t=>{d(t)},p=t=>s?.userRoots.includes(t)??!1,w=t=>s?.envRoots.includes(t)??!1,N=t=>t===s?.baseDir,i=t=>N(t)?"Base Dir":w(t)?"Env":p(t)?"Custom":"",b=t=>N(t)?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":w(t)?"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300":p(t)?"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300":"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300";return e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-purple-50 dark:bg-purple-900/30 rounded-lg",children:e.jsx(ke,{className:"w-6 h-6 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Allowed Scan Roots"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Directories where database scanning is permitted"})]})]}),e.jsx("button",{type:"button",onClick:()=>m(!0),disabled:n,className:"px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-2",children:n?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm"}),"Adding..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ce,{className:"w-4 h-4"}),"Add Root"]})})]}),a?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(C,{style:{color:"var(--ws-text-muted)"}}),e.jsx("span",{className:"ml-3",style:{color:"var(--ws-text-muted)"},children:"Loading allowed roots..."})]}):e.jsxs("div",{className:"space-y-2",children:[s?.roots.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg",style:{background:"var(--ws-surface-1)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx(Se,{className:"w-5 h-5 flex-shrink-0",style:{color:"var(--ws-text-muted)"}}),e.jsx("span",{className:"font-mono text-sm truncate",style:{color:"var(--ws-text-secondary)"},title:t,children:t}),e.jsx("span",{className:`px-2 py-0.5 text-xs font-medium rounded-full flex-shrink-0 ${b(t)}`,children:i(t)})]}),p(t)&&e.jsx("button",{type:"button",onClick:()=>f(t),disabled:r,className:"ml-4 p-1 text-red-500 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-900/30 rounded disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Remove this root",children:r&&l===t?e.jsx(C,{size:"sm"}):e.jsx(Le,{className:"w-4 h-4"})})]},t)),s?.roots.length===0&&e.jsx("p",{className:"text-center py-4",style:{color:"var(--ws-text-muted)"},children:"No allowed roots configured"})]}),e.jsxs("div",{className:"mt-4 text-xs space-y-1",style:{color:"var(--ws-text-muted)"},children:[e.jsxs("p",{children:[e.jsx("strong",{style:{color:"var(--ws-text-secondary)"},children:"Base Dir:"})," Current database directory (always allowed)"]}),e.jsxs("p",{children:[e.jsx("strong",{style:{color:"var(--ws-text-secondary)"},children:"Env:"})," Set via ALLOWED_SCAN_ROOTS environment variable"]}),e.jsxs("p",{children:[e.jsx("strong",{style:{color:"var(--ws-text-secondary)"},children:"Custom:"})," User-added roots (can be removed)"]})]}),e.jsx(V,{isOpen:h,onClose:()=>m(!1),onSelect:k,title:"Add Allowed Root"})]})}function ke({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}function Ce({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function Se({className:s,style:a}){return e.jsx("svg",{className:s,style:a,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}function Le({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function De({models:s,value:a,onChange:d,isLoading:o=!1,disabled:n=!1,label:r="Embedding Model",id:h="model-selector"}){const m=s.find(l=>l.id===a)||s.find(l=>l.isDefault);return e.jsxs("div",{children:[r&&e.jsx("label",{htmlFor:h,className:"block text-sm font-medium mb-1",style:{color:"var(--ws-text-secondary)"},children:r}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{id:h,value:a||m?.id||"",onChange:l=>d(l.target.value),disabled:n||o,className:"w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-amber-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed appearance-none pr-10",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)",color:"var(--ws-text)"},children:o?e.jsx("option",{children:"Loading models..."}):s.map(l=>e.jsxs("option",{value:l.id,children:[l.name," ",l.isDefault?"(default)":""]},l.id))}),e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none",children:o?e.jsx(C,{size:"sm",style:{color:"var(--ws-text-muted)"}}):e.jsx(Ie,{className:"w-4 h-4",style:{color:"var(--ws-text-muted)"}})})]}),m&&e.jsx("p",{className:"mt-1 text-xs",style:{color:"var(--ws-text-muted)"},children:m.description})]})}function Ie({className:s,style:a}){return e.jsx("svg",{className:s,style:a,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}function Re({onCreate:s,isLoading:a,error:d}){const[o,n]=x.useState(""),[r,h]=x.useState(""),[m,l]=x.useState(!1),[y,f]=x.useState(!1),{models:k,isLoading:p}=Y(),w=k.find(b=>b.isDefault)?.id||"",N=b=>{b.preventDefault(),o.trim()&&(s(o.trim(),void 0,r||w),n(""),h(""),l(!1))},i=b=>{n(b)};return e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-purple-50 dark:bg-purple-900/30 rounded-lg",children:e.jsx(Be,{className:"w-6 h-6 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Create Database"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Create a new RAG database"})]})]}),m?e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"dbPath",className:"block text-sm font-medium mb-1",style:{color:"var(--ws-text-secondary)"},children:"Database Path"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",id:"dbPath",value:o,onChange:b=>n(b.target.value),placeholder:"/path/to/new-database",className:"flex-1 px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)",color:"var(--ws-text)"},disabled:a}),e.jsx("button",{type:"button",onClick:()=>f(!0),disabled:a,className:"px-3 py-2 text-sm font-medium border rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition-colors",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},title:"Browse folders",children:e.jsx(Ae,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"mt-1 text-xs",style:{color:"var(--ws-text-muted)"},children:"Enter the full path where you want to create the database"})]}),e.jsx(De,{models:k,value:r||w,onChange:h,isLoading:p,disabled:a}),d&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-700 dark:text-red-300",children:d.message}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{type:"submit",disabled:a||!o.trim(),className:"flex-1 px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:a?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx(C,{size:"sm"}),"Creating..."]}):"Create Database"}),e.jsx("button",{type:"button",onClick:()=>{l(!1),n(""),h("")},disabled:a,className:"px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-50 transition-colors",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-1)"},children:"Cancel"})]})]}):e.jsx("button",{type:"button",onClick:()=>l(!0),className:"w-full px-4 py-3 text-sm font-medium text-purple-700 dark:text-purple-300 bg-purple-50 dark:bg-purple-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:bg-purple-100 dark:hover:bg-purple-900/50 transition-colors",children:"+ Create New Database"}),e.jsx(V,{isOpen:y,onClose:()=>f(!1),onSelect:i,title:"Select Database Location"})]})}function Be({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function Ae({className:s}){return e.jsx("svg",{className:s,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}const Me=[{value:0,label:"Off"},{value:3e4,label:"30s"},{value:6e4,label:"1m"},{value:3e5,label:"5m"}];function Ee({config:s,onRefresh:a,isFetching:d}){const{preferences:o,setStatsRefreshInterval:n}=$();return e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-green-50 dark:bg-green-900/30 rounded-lg",children:e.jsx(Fe,{className:"w-6 h-6 text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Current Database"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Active RAG database"})]})]}),a&&e.jsx("button",{type:"button",onClick:a,disabled:d,className:"p-2 rounded-lg transition-colors disabled:opacity-50",style:{color:"var(--ws-text-muted)"},title:"Refresh stats",children:d?e.jsx(C,{size:"sm"}):e.jsx(Pe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",style:{borderColor:"var(--ws-border-subtle)"},children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Name"}),e.jsx("span",{className:"font-medium",style:{color:"var(--ws-text)"},children:s.name})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",style:{borderColor:"var(--ws-border-subtle)"},children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Path"}),e.jsx("span",{className:"font-mono text-sm max-w-xs truncate",style:{color:"var(--ws-text)"},title:s.dbPath,children:s.dbPath})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",style:{borderColor:"var(--ws-border-subtle)"},children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Model"}),e.jsx("span",{className:"font-mono text-sm",style:{color:"var(--ws-text)"},children:s.modelName})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",style:{borderColor:"var(--ws-border-subtle)"},children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Documents"}),e.jsx("span",{className:"font-medium",style:{color:"var(--ws-text)"},children:s.documentCount})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",style:{borderColor:"var(--ws-border-subtle)"},children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Chunks"}),e.jsx("span",{className:"font-medium",style:{color:"var(--ws-text)"},children:s.chunkCount})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{style:{color:"var(--ws-text-muted)"},children:"Auto-refresh"}),e.jsx("div",{className:"flex items-center gap-1 p-0.5 rounded-lg",style:{background:"var(--ws-surface-1)"},children:Me.map(({value:r,label:h})=>e.jsx("button",{type:"button",onClick:()=>n(r),className:`px-2 py-1 text-xs font-medium rounded transition-all ${o.statsRefreshInterval===r?"shadow-sm":""}`,style:o.statsRefreshInterval===r?{background:"var(--ws-surface-raised)",color:"var(--ws-text)"}:{color:"var(--ws-text-muted)"},children:h},r))})]})]})]})}function Fe({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"})})}function Pe({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function ze({databases:s,currentDbPath:a,onSwitch:d,onDelete:o,isLoading:n}){const[r,h]=x.useState(null),[m,l]=x.useState(null),[y,f]=x.useState(null),k=i=>{h(i),d(i)},p=i=>{f({path:i.path,name:i.name})},w=async i=>{if(y){l(y.path);try{await o(y.path,i)}finally{l(null),f(null)}}},N=s.filter(i=>i.path!==a);return N.length===0?e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg",style:{background:"var(--ws-accent-subtle)"},children:e.jsx(U,{className:"w-6 h-6",style:{color:"var(--ws-accent)"}})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Recent Databases"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Switch between databases"})]})]}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"No other databases available. Create a new database or scan for existing ones."})]}):e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg",style:{background:"var(--ws-accent-subtle)"},children:e.jsx(U,{className:"w-6 h-6",style:{color:"var(--ws-accent)"}})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Recent Databases"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Switch between databases"})]})]}),e.jsx("div",{className:"space-y-2",children:N.map(i=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg",style:{background:"var(--ws-surface-1)"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",style:{color:"var(--ws-text)"},children:i.name}),e.jsx("p",{className:"text-sm font-mono truncate max-w-xs",style:{color:"var(--ws-text-muted)"},title:i.path,children:i.path}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"var(--ws-text-muted)"},children:[e.jsxs("span",{children:["Last used: ",ve(i.lastAccessed)]}),i.modelName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{className:"font-mono",children:i.modelName.split("/").pop()})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx("button",{type:"button",onClick:()=>k(i.path),disabled:n,className:"px-4 py-2 text-sm font-medium text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-700 rounded-lg hover:bg-blue-100 dark:hover:bg-blue-900/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:n&&r===i.path?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm"}),"Switching..."]}):"Switch"}),e.jsx("button",{type:"button",onClick:()=>p(i),disabled:n||m===i.path,className:"p-2 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition-colors",style:{color:"var(--ws-text-muted)"},title:"Remove database",children:m===i.path?e.jsx(C,{size:"sm"}):e.jsx(We,{className:"w-5 h-5"})})]})]},i.path))}),y&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"rounded-lg p-6 max-w-md mx-4 shadow-xl",style:{background:"var(--ws-surface-raised)"},children:[e.jsx("h3",{className:"text-lg font-medium mb-2",style:{color:"var(--ws-text)"},children:"Remove Database"}),e.jsxs("p",{className:"mb-4",style:{color:"var(--ws-text-secondary)"},children:["Remove ",e.jsx("span",{className:"font-medium",children:y.name})," from your recent databases?"]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",onClick:()=>w(!1),disabled:n,className:"w-full px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-50 transition-colors",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-1)"},children:"Remove from list only"}),e.jsx("button",{type:"button",onClick:()=>w(!0),disabled:n,className:"w-full px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-700 disabled:opacity-50 transition-colors",children:"Delete files permanently"}),e.jsx("button",{type:"button",onClick:()=>f(null),disabled:n,className:"w-full px-4 py-2 text-sm font-medium transition-colors",style:{color:"var(--ws-text-muted)"},children:"Cancel"})]})]})})]})}function U({className:s,style:a}){return e.jsx("svg",{className:s,style:a,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}function We({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function He(){const s=x.useRef(null),{exportConfigAsync:a,isLoading:d}=Q(),{importConfig:o,isLoading:n}=X(),{addToast:r}=Z(),{exportLinks:h,importLinks:m}=ee(),{exportAnnotations:l,importAnnotations:y}=se(),{exportCollections:f,importCollections:k}=te(),{exportTags:p,importTags:w}=re(),[N,i]=x.useState(!1),[b,t]=x.useState({includeLinks:!0,includeAnnotations:!0,includeCollections:!0,includeTags:!0,includeServerConfig:!0}),[R,g]=x.useState(!1),[B,M]=x.useState("merge"),[L,F]=x.useState(null),[I,E]=x.useState(!1),W=x.useCallback(async()=>{E(!0);try{const c={version:1,exportedAt:new Date().toISOString(),vaultId:"default",data:{}};if(b.includeLinks&&(c.data.links=JSON.parse(h())),b.includeAnnotations&&(c.data.annotations=JSON.parse(l())),b.includeCollections&&(c.data.collections=JSON.parse(f())),b.includeTags&&(c.data.tags=JSON.parse(p())),b.includeServerConfig)try{c.data.serverConfig=await a()}catch{}const j=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),v=URL.createObjectURL(j),u=document.createElement("a");u.href=v,u.download=`rag-vault-backup-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(v),r({type:"success",title:"Export complete",message:"Your vault data has been exported"}),i(!1)}catch(c){r({type:"error",title:"Export failed",message:c instanceof Error?c.message:"Unknown error"})}finally{E(!1)}},[b,h,l,f,p,a,r]),H=x.useCallback(async c=>{const j=c.target.files?.[0];if(j){try{const v=await j.text(),u=JSON.parse(v);if(u.version===1&&u.data)F(u),g(!0);else if(u.version&&u.allowedRoots)o(u),r({type:"success",title:"Config imported",message:"Server configuration has been restored"});else throw new Error("Unrecognized file format")}catch(v){r({type:"error",title:"Failed to import",message:v instanceof Error?v.message:"Invalid file format"})}s.current&&(s.current.value="")}},[o,r]),z=x.useCallback(async()=>{if(!L)return;E(!0);const c=[];let j=0;try{const{data:v}=L;if(v.links){const{imported:u,errors:S}=m(JSON.stringify(v.links));j+=u,S.length>0&&c.push(`Links: ${S.join(", ")}`)}if(v.annotations){const{imported:u,errors:S}=y(JSON.stringify(v.annotations));j+=u,S.length>0&&c.push(`Annotations: ${S.join(", ")}`)}if(v.collections){const{imported:u,errors:S}=k(JSON.stringify(v.collections));j+=u,S.length>0&&c.push(`Collections: ${S.join(", ")}`)}if(v.tags){const{imported:u,errors:S}=w(JSON.stringify(v.tags));j+=u,S.length>0&&c.push(`Tags: ${S.join(", ")}`)}if(v.serverConfig)try{o(v.serverConfig),c.push("Server config restored")}catch{c.push("Server config: import failed")}r({type:"success",title:"Import complete",message:`Imported ${j} items`})}catch(v){r({type:"error",title:"Import failed",message:v instanceof Error?v.message:"Unknown error"})}finally{E(!1),g(!1),F(null)}},[L,B,m,y,k,w,o,r]);return e.jsxs("div",{className:"ws-card","data-padding":"lg",children:[e.jsx("div",{className:"ws-card-header",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg",style:{background:"var(--ws-accent-muted)"},children:e.jsx(Oe,{className:"w-6 h-6",style:{color:"var(--ws-accent)"}})}),e.jsxs("div",{children:[e.jsx("div",{className:"ws-card-title",children:"Export / Import"}),e.jsx("div",{className:"ws-card-subtitle",children:"Backup and restore your vault data"})]})]})}),e.jsxs("div",{className:"ws-card-body",children:[N&&e.jsxs("div",{className:"mb-4 p-4 rounded-lg",style:{background:"var(--ws-surface-1)",border:"1px solid var(--ws-border)"},children:[e.jsx("h3",{className:"text-sm font-medium mb-3",style:{color:"var(--ws-text-secondary)"},children:"Select data to export"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{checked:b.includeLinks,onChange:c=>t(j=>({...j,includeLinks:c})),label:"Links, trails & bookmarks"}),e.jsx(P,{checked:b.includeAnnotations,onChange:c=>t(j=>({...j,includeAnnotations:c})),label:"Highlights & annotations"}),e.jsx(P,{checked:b.includeCollections,onChange:c=>t(j=>({...j,includeCollections:c})),label:"Collections"}),e.jsx(P,{checked:b.includeTags,onChange:c=>t(j=>({...j,includeTags:c})),label:"Tags"}),e.jsx(P,{checked:b.includeServerConfig,onChange:c=>t(j=>({...j,includeServerConfig:c})),label:"Server config"})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsxs("button",{type:"button",onClick:W,disabled:I,className:"ws-button flex-1","data-variant":"primary","data-size":"md",children:[I?e.jsx(C,{size:"sm"}):e.jsx(J,{className:"w-4 h-4"}),"Export"]}),e.jsx("button",{type:"button",onClick:()=>i(!1),className:"ws-button","data-variant":"ghost","data-size":"md",children:"Cancel"})]})]}),R&&L&&e.jsxs("div",{className:"mb-4 p-4 rounded-lg",style:{background:"var(--ws-surface-1)",border:"1px solid var(--ws-border)"},children:[e.jsx("h3",{className:"text-sm font-medium mb-3",style:{color:"var(--ws-text-secondary)"},children:"Import vault backup"}),e.jsxs("p",{className:"text-xs mb-3",style:{color:"var(--ws-text-muted)"},children:["From: ",new Date(L.exportedAt).toLocaleDateString()]}),e.jsxs("div",{className:"mb-3 text-xs",style:{color:"var(--ws-text-secondary)"},children:[e.jsx("p",{className:"font-medium mb-1",children:"Contains:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[L.data.links&&e.jsx("li",{children:"Links, trails & bookmarks"}),L.data.annotations&&e.jsx("li",{children:"Highlights & annotations"}),L.data.collections&&e.jsx("li",{children:"Collections"}),L.data.tags&&e.jsx("li",{children:"Tags"}),L.data.serverConfig&&e.jsx("li",{children:"Server config"})]})]}),e.jsx("div",{className:"mb-3",children:e.jsxs("label",{className:"block text-xs font-medium mb-1",style:{color:"var(--ws-text-muted)"},children:["Import strategy",e.jsxs("select",{value:B,onChange:c=>M(c.target.value),className:"ws-select mt-1 w-full",children:[e.jsx("option",{value:"merge",children:"Merge (skip duplicates)"}),e.jsx("option",{value:"overwrite",children:"Add all (may create duplicates)"})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:z,disabled:I,className:"ws-button flex-1","data-variant":"primary","data-size":"md",children:[I?e.jsx(C,{size:"sm"}):e.jsx(G,{className:"w-4 h-4"}),"Import"]}),e.jsx("button",{type:"button",onClick:()=>{g(!1),F(null)},className:"ws-button","data-variant":"ghost","data-size":"md",children:"Cancel"})]})]}),!N&&!R&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("button",{type:"button",onClick:()=>i(!0),disabled:d||I,className:"ws-button flex-1","data-variant":"primary","data-size":"lg",children:d?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm"}),"Exporting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4"}),"Export Vault"]})}),e.jsx("button",{type:"button",onClick:()=>s.current?.click(),disabled:n||I,className:"ws-button flex-1","data-variant":"default","data-size":"lg",children:n?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-4 h-4"}),"Import Backup"]})}),e.jsx("input",{ref:s,type:"file",accept:".json",onChange:H,className:"hidden"})]}),e.jsx("p",{className:"mt-4 text-xs",style:{color:"var(--ws-text-muted)"},children:"Export saves all your vault data including links, annotations, collections, and tags. Import restores from a previously exported backup."})]})]})}function P({checked:s,onChange:a,label:d}){return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:o=>a(o.target.checked),className:"w-4 h-4 rounded",style:{accentColor:"var(--ws-accent)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--ws-text-secondary)"},children:d})]})}function Oe({className:s,style:a}){return e.jsxs("svg",{className:s,style:a,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function J({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})})}function G({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}function Te(){const{weight:s,isLoading:a}=ae(),{setWeight:d,isLoading:o}=ne(),[n,r]=x.useState(s),[h,m]=x.useState(!1);x.useEffect(()=>{h||r(s)},[s,h]);const l=x.useCallback(p=>{const w=parseFloat(p.target.value);r(w),m(!0)},[]),y=x.useCallback(()=>{d(n),m(!1)},[n,d]),f=x.useCallback(()=>{r(s),m(!1)},[s]),k=p=>p===0?"Vector-only search (pure semantic similarity)":p<.3?"Minimal keyword boost, semantic-focused":p<.5?"Balanced toward semantic meaning":p<.7?"Balanced hybrid search (recommended)":p<.9?"Balanced toward keyword matching":p<1?"Strong keyword boost, keyword-focused":"Maximum keyword influence";return e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-cyan-50 dark:bg-cyan-900/30 rounded-lg",children:e.jsx($e,{className:"w-6 h-6 text-cyan-600 dark:text-cyan-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Hybrid Search Weight"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Balance between semantic and keyword matching"})]})]}),a?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(C,{style:{color:"var(--ws-text-muted)"}}),e.jsx("span",{className:"ml-3",style:{color:"var(--ws-text-muted)"},children:"Loading settings..."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",style:{color:"var(--ws-text-secondary)"},children:"Semantic"}),e.jsx("span",{className:"text-sm font-mono",style:{color:"var(--ws-text)"},children:n.toFixed(2)}),e.jsx("span",{className:"text-sm",style:{color:"var(--ws-text-secondary)"},children:"Keyword"})]}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.05",value:n,onChange:l,className:"w-full h-2 rounded-lg appearance-none cursor-pointer accent-cyan-600",style:{background:"var(--ws-surface-2)"}}),e.jsx("p",{className:"text-sm text-center",style:{color:"var(--ws-text-secondary)"},children:k(n)})]}),h&&e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx("button",{type:"button",onClick:y,disabled:o,className:"flex-1 flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium text-white bg-cyan-600 rounded-lg hover:bg-cyan-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:o?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm"}),"Saving..."]}):"Apply"}),e.jsx("button",{type:"button",onClick:f,disabled:o,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:"var(--ws-text-secondary)"},children:"Reset"})]})]}),e.jsx("div",{className:"mt-4 p-3 rounded-lg",style:{background:"var(--ws-surface-1)"},children:e.jsxs("p",{className:"text-xs space-y-1",style:{color:"var(--ws-text-secondary)"},children:[e.jsxs("span",{className:"block",children:[e.jsx("strong",{style:{color:"var(--ws-text-secondary)"},children:"Lower values (0.0-0.4):"})," ","Better for conceptual questions, finding related ideas"]}),e.jsxs("span",{className:"block",children:[e.jsx("strong",{style:{color:"var(--ws-text-secondary)"},children:"Higher values (0.6-1.0):"})," ","Better for exact terms, code, error messages"]})]})})]})}function $e({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function Ve({onScan:s,onSwitch:a,isScanning:d,isSwitching:o,scanResults:n,error:r,onReset:h}){const[m,l]=x.useState(""),[y,f]=x.useState(null),[k,p]=x.useState(!1),w=t=>{t.preventDefault(),m.trim()&&s(m.trim())},N=t=>{f(t),a(t)},i=()=>{l(""),h()},b=t=>{l(t)};return e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-amber-50 dark:bg-amber-900/30 rounded-lg",children:e.jsx(Ue,{className:"w-6 h-6 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",style:{color:"var(--ws-text)"},children:"Scan for Databases"}),e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Find existing RAG databases"})]})]}),e.jsx("form",{onSubmit:w,className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("label",{htmlFor:"scanPath",className:"block text-sm font-medium mb-1",style:{color:"var(--ws-text-secondary)"},children:"Directory to Scan"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",id:"scanPath",value:m,onChange:t=>l(t.target.value),placeholder:"/path/to/scan",className:"flex-1 px-3 py-2 border rounded-lg focus:ring-2 focus:ring-amber-500 focus:border-transparent",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)",color:"var(--ws-text)"},disabled:d}),e.jsx("button",{type:"button",onClick:()=>p(!0),disabled:d,className:"px-3 py-2 text-sm font-medium border rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition-colors",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},title:"Browse folders",children:e.jsx(Je,{className:"w-5 h-5"})}),e.jsx("button",{type:"submit",disabled:d||!m.trim(),className:"px-4 py-2 text-sm font-medium text-white bg-amber-600 rounded-lg hover:bg-amber-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm"}),"Scanning..."]}):"Scan"})]}),e.jsx("p",{className:"mt-1 text-xs",style:{color:"var(--ws-text-muted)"},children:"Searches the directory and up to 2 levels of subdirectories"})]})}),r&&e.jsx("div",{className:"mt-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-700 dark:text-red-300",children:r.message}),n&&e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-sm font-medium",style:{color:"var(--ws-text-secondary)"},children:["Found ",n.length," database",n.length!==1?"s":""]}),e.jsx("button",{type:"button",onClick:i,className:"text-sm",style:{color:"var(--ws-text-muted)"},children:"Clear results"})]}),n.length===0?e.jsx("p",{className:"text-sm py-2",style:{color:"var(--ws-text-muted)"},children:"No databases found in this directory."}):e.jsx("div",{className:"space-y-2",children:n.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg",style:{background:"var(--ws-surface-1)"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",style:{color:"var(--ws-text)"},children:t.name}),t.isKnown&&e.jsx("span",{className:"px-2 py-0.5 text-xs font-medium text-green-700 dark:text-green-300 bg-green-100 dark:bg-green-900/30 rounded-full",children:"Known"})]}),e.jsx("p",{className:"text-sm font-mono truncate max-w-xs",style:{color:"var(--ws-text-muted)"},title:t.path,children:t.path})]}),e.jsx("button",{type:"button",onClick:()=>N(t.path),disabled:o,className:"ml-4 px-4 py-2 text-sm font-medium text-amber-700 dark:text-amber-300 bg-amber-50 dark:bg-amber-900/30 border border-amber-200 dark:border-amber-700 rounded-lg hover:bg-amber-100 dark:hover:bg-amber-900/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:o&&y===t.path?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm"}),"Switching..."]}):"Use"})]},t.path))})]}),e.jsx(V,{isOpen:k,onClose:()=>p(!1),onSelect:b,title:"Select Directory to Scan"})]})}function Ue({className:s}){return e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function Je({className:s}){return e.jsx("svg",{className:s,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}const T={hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.1}}},A={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.3,ease:[.25,.1,.25,1]}}},Ge=[{id:"database",label:"Database"},{id:"search",label:"Search"},{id:"data",label:"Data"}];function Xe(){const[s,a]=oe("settings-active-tab","database"),{preferences:d}=$(),{config:o,isLoading:n,error:r,refetch:h,isFetching:m}=le(d.statsRefreshInterval),{databases:l,isLoading:y}=ie(),{switchDatabase:f,isLoading:k}=ce(),{deleteDatabase:p,isLoading:w}=de(),{createDatabase:N,isLoading:i,error:b}=xe(),{scan:t,isLoading:R,data:g,error:B,reset:M}=me(),{data:L,isLoading:F}=ue(),{addRoot:I,isLoading:E}=he(),{removeRoot:W,isLoading:H}=pe(),z=u=>{f(u)},c=async(u,S)=>{await new Promise((O,K)=>{p({dbPath:u,deleteFiles:S},{onSuccess:()=>O(),onError:_=>K(_)})})},j=(u,S,O)=>{N({dbPath:u,modelName:O})},v=u=>{t(u)};return e.jsxs("div",{className:"ws-page max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"ws-page-title text-2xl font-bold mb-2",children:"Settings"}),e.jsx("p",{style:{color:"var(--ws-text-secondary)"},children:"Manage your RAG database configuration."})]}),e.jsx("button",{type:"button",onClick:()=>h(),disabled:n||m,className:"ws-button px-4 py-2 text-sm rounded-lg transition-colors","data-variant":"default",children:n||m?"Refreshing...":"Refresh"})]}),n&&!o?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx("span",{style:{color:"var(--ws-text-faint)"},children:e.jsx(C,{})}),e.jsx("span",{className:"ml-3",style:{color:"var(--ws-text-muted)"},children:"Loading configuration..."})]}):r?e.jsxs("div",{className:"ws-error-box rounded-lg",children:[e.jsx("p",{className:"font-medium",children:"Error loading configuration"}),e.jsx("p",{className:"text-sm",children:r.message})]}):e.jsxs(e.Fragment,{children:[e.jsx(be,{tabs:Ge,activeId:s,onSelect:a,variant:"underline",className:"mb-6"}),s==="database"&&e.jsxs(D.div,{className:"space-y-6",variants:T,initial:"hidden",animate:"visible",children:[o&&e.jsx(D.div,{variants:A,children:e.jsx(Ee,{config:o,onRefresh:()=>h(),isFetching:m})}),!y&&e.jsx(D.div,{variants:A,children:e.jsx(ze,{databases:l,currentDbPath:o?.dbPath,onSwitch:z,onDelete:c,isLoading:k||w})}),e.jsx(D.div,{variants:A,children:e.jsx(Re,{onCreate:j,isLoading:i,error:b})}),e.jsx(D.div,{variants:A,children:e.jsx(Ve,{onScan:v,onSwitch:z,isScanning:R,isSwitching:k,scanResults:g,error:B,onReset:M})})]}),s==="search"&&e.jsxs(D.div,{className:"space-y-6",variants:T,initial:"hidden",animate:"visible",children:[e.jsx(D.div,{variants:A,children:e.jsx(Ne,{data:L,isLoading:F,onAdd:I,onRemove:W,isAdding:E,isRemoving:H})}),e.jsx(D.div,{variants:A,children:e.jsx(Te,{})})]}),s==="data"&&e.jsx(D.div,{className:"space-y-6",variants:T,initial:"hidden",animate:"visible",children:e.jsx(D.div,{variants:A,children:e.jsx(He,{})})})]})]})}export{Xe as SettingsPage};
@@ -1 +1 @@
1
- import{b as n,j as e}from"./query-DPt-uCb6.js";import{f as o,a as l}from"./format-DOJ3IkRX.js";import{n as c,S as d}from"./index-D068MV_o.js";import"./vendor-C2QPsZ3S.js";function i(){const{data:s,isLoading:t,error:r,refetch:a}=n({queryKey:["status"],queryFn:c,refetchInterval:3e4});return{status:s,isLoading:t,error:r,refetch:a}}function x({status:s}){const t=[{label:"Documents",value:s.documentCount.toString(),icon:m},{label:"Chunks",value:s.chunkCount.toString(),icon:u},{label:"Memory Usage",value:o(s.memoryUsage*1024*1024),icon:h}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:t.map(r=>e.jsx("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg",style:{background:"var(--ws-accent-subtle)"},children:e.jsx(r.icon,{className:"w-6 h-6",style:{color:"var(--ws-accent)"}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:r.label}),e.jsx("p",{className:"text-2xl font-semibold",style:{color:"var(--ws-text)"},children:r.value})]})]})},r.label))}),e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsx("h2",{className:"text-lg font-medium mb-4",style:{color:"var(--ws-text)"},children:"System Info"}),e.jsxs("dl",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{style:{color:"var(--ws-text-muted)"},children:"Search Mode"}),e.jsx("dd",{className:"font-mono text-sm",style:{color:"var(--ws-text)"},children:s.searchMode})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{style:{color:"var(--ws-text-muted)"},children:"FTS Index"}),e.jsx("dd",{className:"font-mono text-sm",style:{color:"var(--ws-text)"},children:s.ftsIndexEnabled?"Enabled":"Disabled"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{style:{color:"var(--ws-text-muted)"},children:"Uptime"}),e.jsx("dd",{className:"font-mono text-sm",style:{color:"var(--ws-text)"},children:l(s.uptime)})]})]})]})]})}function m({className:s,style:t}){return e.jsx("svg",{className:s,style:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}function u({className:s,style:t}){return e.jsx("svg",{className:s,style:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 10h16M4 14h16M4 18h16"})})}function h({className:s,style:t}){return e.jsx("svg",{className:s,style:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"})})}function p(){const{status:s,isLoading:t,error:r,refetch:a}=i();return e.jsxs("div",{className:"ws-page max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"ws-page-title text-2xl font-bold mb-2",children:"System Status"}),e.jsx("p",{style:{color:"var(--ws-text-secondary)"},children:"Monitor your RAG system metrics and configuration."})]}),e.jsx("button",{type:"button",onClick:()=>a(),disabled:t,className:"ws-button px-4 py-2 text-sm rounded-lg transition-colors","data-variant":"default",children:t?"Refreshing...":"Refresh"})]}),t&&!s?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx("span",{style:{color:"var(--ws-text-faint)"},children:e.jsx(d,{})}),e.jsx("span",{className:"ml-3",style:{color:"var(--ws-text-muted)"},children:"Loading status..."})]}):r?e.jsxs("div",{className:"ws-error-box rounded-lg",children:[e.jsx("p",{className:"font-medium",children:"Error loading status"}),e.jsx("p",{className:"text-sm",children:r.message})]}):s?e.jsx(x,{status:s}):null]})}export{p as StatusPage};
1
+ import{b as n,j as e}from"./query-DPt-uCb6.js";import{f as o,a as l}from"./format-DOJ3IkRX.js";import{n as c,S as d}from"./index-ANt8Xo4z.js";import"./vendor-DSXQOR6A.js";function i(){const{data:s,isLoading:t,error:r,refetch:a}=n({queryKey:["status"],queryFn:c,refetchInterval:3e4});return{status:s,isLoading:t,error:r,refetch:a}}function x({status:s}){const t=[{label:"Documents",value:s.documentCount.toString(),icon:m},{label:"Chunks",value:s.chunkCount.toString(),icon:u},{label:"Memory Usage",value:o(s.memoryUsage*1024*1024),icon:h}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:t.map(r=>e.jsx("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg",style:{background:"var(--ws-accent-subtle)"},children:e.jsx(r.icon,{className:"w-6 h-6",style:{color:"var(--ws-accent)"}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",style:{color:"var(--ws-text-muted)"},children:r.label}),e.jsx("p",{className:"text-2xl font-semibold",style:{color:"var(--ws-text)"},children:r.value})]})]})},r.label))}),e.jsxs("div",{className:"border rounded-lg p-6",style:{background:"var(--ws-surface-raised)",borderColor:"var(--ws-border)"},children:[e.jsx("h2",{className:"text-lg font-medium mb-4",style:{color:"var(--ws-text)"},children:"System Info"}),e.jsxs("dl",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{style:{color:"var(--ws-text-muted)"},children:"Search Mode"}),e.jsx("dd",{className:"font-mono text-sm",style:{color:"var(--ws-text)"},children:s.searchMode})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{style:{color:"var(--ws-text-muted)"},children:"FTS Index"}),e.jsx("dd",{className:"font-mono text-sm",style:{color:"var(--ws-text)"},children:s.ftsIndexEnabled?"Enabled":"Disabled"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{style:{color:"var(--ws-text-muted)"},children:"Uptime"}),e.jsx("dd",{className:"font-mono text-sm",style:{color:"var(--ws-text)"},children:l(s.uptime)})]})]})]})]})}function m({className:s,style:t}){return e.jsx("svg",{className:s,style:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}function u({className:s,style:t}){return e.jsx("svg",{className:s,style:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 10h16M4 14h16M4 18h16"})})}function h({className:s,style:t}){return e.jsx("svg",{className:s,style:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"})})}function p(){const{status:s,isLoading:t,error:r,refetch:a}=i();return e.jsxs("div",{className:"ws-page max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"ws-page-title text-2xl font-bold mb-2",children:"System Status"}),e.jsx("p",{style:{color:"var(--ws-text-secondary)"},children:"Monitor your RAG system metrics and configuration."})]}),e.jsx("button",{type:"button",onClick:()=>a(),disabled:t,className:"ws-button px-4 py-2 text-sm rounded-lg transition-colors","data-variant":"default",children:t?"Refreshing...":"Refresh"})]}),t&&!s?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx("span",{style:{color:"var(--ws-text-faint)"},children:e.jsx(d,{})}),e.jsx("span",{className:"ml-3",style:{color:"var(--ws-text-muted)"},children:"Loading status..."})]}):r?e.jsxs("div",{className:"ws-error-box rounded-lg",children:[e.jsx("p",{className:"font-medium",children:"Error loading status"}),e.jsx("p",{className:"text-sm",children:r.message})]}):s?e.jsx(x,{status:s}):null]})}export{p as StatusPage};