totem-llm 0.2.0 → 0.3.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 (90) hide show
  1. package/README.md +12 -0
  2. package/package.json +1 -1
  3. package/server/models/systemSettings.js +1 -1
  4. package/server/models/workspace.js +2 -2
  5. package/server/public/assets/{404-b5c6b0dc.js → 404-56d107aa.js} +1 -1
  6. package/server/public/assets/RunDetailPage-da6aa377.js +1 -0
  7. package/server/public/assets/RunHistoryPage-2fcb4325.js +1 -0
  8. package/server/public/assets/{Trans-ca8f9cfe.js → Trans-820f1dad.js} +1 -1
  9. package/server/public/assets/{cron-1f15870f.js → cron-307d3fc6.js} +1 -1
  10. package/server/public/assets/{files-e19b0187.js → files-676613ed.js} +1 -1
  11. package/server/public/assets/index-01932fa1.js +1 -0
  12. package/server/public/assets/{index-a6e642d7.js → index-0bf4fb6b.js} +1 -1
  13. package/server/public/assets/index-166e238c.js +1 -0
  14. package/server/public/assets/{index-f86e167c.js → index-1c653bbf.js} +2 -2
  15. package/server/public/assets/index-1fe43260.js +1 -0
  16. package/server/public/assets/index-27cc497c.js +1 -0
  17. package/server/public/assets/{index-9cc77cb6.js → index-2aac91d0.js} +3 -3
  18. package/server/public/assets/index-2d84e5fe.js +1 -0
  19. package/server/public/assets/index-33ded078.js +1 -0
  20. package/server/public/assets/{index-2f526c2a.js → index-3cb59d82.js} +1 -1
  21. package/server/public/assets/{index-92d3b7bc.js → index-4277cf52.js} +1 -1
  22. package/server/public/assets/index-44ab5f11.js +1 -0
  23. package/server/public/assets/index-4750915e.js +1 -0
  24. package/server/public/assets/{index-ab72b353.js → index-574ed823.js} +2 -2
  25. package/server/public/assets/{index-3a2c5fd7.js → index-631fc042.js} +1 -1
  26. package/server/public/assets/index-65184421.js +1 -0
  27. package/server/public/assets/index-6679334a.js +1 -0
  28. package/server/public/assets/{index-6cdecde9.js → index-6bd7928a.js} +9 -9
  29. package/server/public/assets/index-6d56c896.js +18 -0
  30. package/server/public/assets/{index-925792fe.js → index-72544df5.js} +1 -1
  31. package/server/public/assets/index-80edec8f.js +1 -0
  32. package/server/public/assets/index-83825216.js +1 -0
  33. package/server/public/assets/index-841db586.js +1 -0
  34. package/server/public/assets/index-882e468e.js +1 -0
  35. package/server/public/assets/{index-ab35fb74.js → index-8c2371f5.js} +1 -1
  36. package/server/public/assets/{index-8eb228e2.js → index-9ab52cfb.js} +3 -3
  37. package/server/public/assets/{index-ad8e77d2.js → index-a2978aa0.js} +2 -2
  38. package/server/public/assets/index-a29a8c19.js +3 -0
  39. package/server/public/assets/{index-62fee0f9.js → index-ae4f557d.js} +2 -2
  40. package/server/public/assets/{index-8132c765.js → index-b49f94f1.js} +1 -1
  41. package/server/public/assets/{index-52850dde.js → index-c453ccc8.js} +1 -1
  42. package/server/public/assets/index-cd6bc090.js +1 -0
  43. package/server/public/assets/{index-c391a2fa.js → index-d1d3d69a.js} +1 -1
  44. package/server/public/assets/index-d29fdeda.js +1 -0
  45. package/server/public/assets/index-d54b0575.js +1 -0
  46. package/server/public/assets/index-dcc00e8c.js +3 -0
  47. package/server/public/assets/index-e58bf860.js +1 -0
  48. package/server/public/assets/index-ec3efa1e.js +1 -0
  49. package/server/public/assets/index-ed9034ac.js +1 -0
  50. package/server/public/assets/{index-92574f3a.js → index-efee6d1f.js} +1 -1
  51. package/server/public/assets/index-f9305828.js +1 -0
  52. package/server/public/assets/index-fce187ac.js +1 -0
  53. package/server/public/assets/{main-8ad4162f.js → main-0b9e408b.js} +1 -1
  54. package/server/public/assets/{mcpServers-a175e8cf.js → mcpServers-1686e782.js} +1 -1
  55. package/server/public/assets/{moment-8a59df1b.js → moment-75486807.js} +1 -1
  56. package/server/public/assets/{purify-fbc9e8e2.js → purify-eb750cf4.js} +1 -1
  57. package/server/public/assets/{react-beautiful-dnd.esm-45ea8487.js → react-beautiful-dnd.esm-bb85eef1.js} +1 -1
  58. package/server/public/assets/{truncate-352eb33b.js → truncate-06273256.js} +1 -1
  59. package/server/public/index.js +27 -27
  60. package/server/utils/AiProviders/ollama/index.js +2 -0
  61. package/server/utils/chats/agents.js +7 -1
  62. package/server/utils/telegramBot/utils/verification.js +1 -1
  63. package/totem.features.cjs +5 -108
  64. package/server/public/assets/RunDetailPage-74b1e63a.js +0 -1
  65. package/server/public/assets/RunHistoryPage-9609436a.js +0 -1
  66. package/server/public/assets/index-25b2660c.js +0 -1
  67. package/server/public/assets/index-2a7c0b04.js +0 -1
  68. package/server/public/assets/index-35b0a39b.js +0 -3
  69. package/server/public/assets/index-3643e990.js +0 -1
  70. package/server/public/assets/index-39899779.js +0 -1
  71. package/server/public/assets/index-51f23c79.js +0 -1
  72. package/server/public/assets/index-56bb11a0.js +0 -1
  73. package/server/public/assets/index-65801ac6.js +0 -1
  74. package/server/public/assets/index-6710499a.js +0 -1
  75. package/server/public/assets/index-73aba4c6.js +0 -3
  76. package/server/public/assets/index-837868b3.js +0 -1
  77. package/server/public/assets/index-86e8a6b4.js +0 -1
  78. package/server/public/assets/index-8e43159f.js +0 -1
  79. package/server/public/assets/index-994c849a.js +0 -1
  80. package/server/public/assets/index-9f71774b.js +0 -1
  81. package/server/public/assets/index-9f7dabd6.js +0 -1
  82. package/server/public/assets/index-a0e2be61.js +0 -1
  83. package/server/public/assets/index-ac4d4b42.js +0 -1
  84. package/server/public/assets/index-c9b59c35.js +0 -1
  85. package/server/public/assets/index-dad0fb8d.js +0 -18
  86. package/server/public/assets/index-dd210692.js +0 -1
  87. package/server/public/assets/index-e28b0ead.js +0 -1
  88. package/server/public/assets/index-e6c540e1.js +0 -1
  89. package/server/public/assets/index-f984ef26.js +0 -1
  90. package/server/public/assets/index-fb26b60a.js +0 -1
@@ -0,0 +1,18 @@
1
+ import{R as l,r as i,g as L,A as y,m as v,j as e,k as S,aF as xe,W as ue,s as _,c as g,aM as pe,q as N,p as U,aN as be,M,u as Y,S as Q,C as fe,ab as G,aL as ge,t as we,aO as je,i as $,aJ as ye,a1 as ve,aE as Ne}from"../index.js";import{q as Me}from"./index-4fb4d421.js";import{H,D as Ee,M as Ae}from"./purify-eb750cf4.js";/* empty css */import{h as C}from"./moment-75486807.js";import{t as O}from"./truncate-06273256.js";import{I as ke}from"./github-dark-57c241de.js";const _e=new Map([["bold",l.createElement(l.Fragment,null,l.createElement("path",{d:"M51.51,104.49l-32-32a12,12,0,0,1,0-17l32-32a12,12,0,1,1,17,17L45,64,68.49,87.51a12,12,0,0,1-17,17Zm48,0a12,12,0,0,0,17,0l32-32a12,12,0,0,0,0-17l-32-32a12,12,0,1,0-17,17L123,64,99.51,87.51A12,12,0,0,0,99.51,104.49ZM200,36H180a12,12,0,0,0,0,24h16V196H60V140a12,12,0,0,0-24,0v60a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Z"}))],["duotone",l.createElement(l.Fragment,null,l.createElement("path",{d:"M152,32V96a16,16,0,0,1-16,16H32A16,16,0,0,1,16,96V32A16,16,0,0,1,32,16H136A16,16,0,0,1,152,32Z",opacity:"0.2"}),l.createElement("path",{d:"M58.34,101.66l-32-32a8,8,0,0,1,0-11.32l32-32A8,8,0,0,1,69.66,37.66L43.31,64,69.66,90.34a8,8,0,0,1-11.32,11.32Zm40,0a8,8,0,0,0,11.32,0l32-32a8,8,0,0,0,0-11.32l-32-32A8,8,0,0,0,98.34,37.66L124.69,64,98.34,90.34A8,8,0,0,0,98.34,101.66ZM200,40H176a8,8,0,0,0,0,16h24V200H56V136a8,8,0,0,0-16,0v64a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Z"}))],["fill",l.createElement(l.Fragment,null,l.createElement("path",{d:"M200,40H168a16,16,0,0,0-16-16H32A16,16,0,0,0,16,40v80a16,16,0,0,0,16,16h8v64a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40ZM106.34,61.66a8,8,0,0,1,11.32-11.32l24,24a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32-11.32L124.69,80Zm-64,24a8,8,0,0,1,0-11.32l24-24A8,8,0,0,1,77.66,61.66L59.31,80,77.66,98.34a8,8,0,0,1-11.32,11.32ZM200,200H56V136h96a16,16,0,0,0,16-16V56h32Z"}))],["light",l.createElement(l.Fragment,null,l.createElement("path",{d:"M59.76,100.24l-32-32a6,6,0,0,1,0-8.48l32-32a6,6,0,1,1,8.48,8.48L40.49,64,68.24,91.76a6,6,0,1,1-8.48,8.48Zm40,0a6,6,0,0,0,8.48,0l32-32a6,6,0,0,0,0-8.48l-32-32a6,6,0,1,0-8.48,8.48L127.51,64,99.76,91.76A6,6,0,0,0,99.76,100.24ZM200,42H176a6,6,0,0,0,0,12h24a2,2,0,0,1,2,2V200a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V136a6,6,0,0,0-12,0v64a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Z"}))],["regular",l.createElement(l.Fragment,null,l.createElement("path",{d:"M58.34,101.66l-32-32a8,8,0,0,1,0-11.32l32-32A8,8,0,0,1,69.66,37.66L43.31,64,69.66,90.34a8,8,0,0,1-11.32,11.32Zm40,0a8,8,0,0,0,11.32,0l32-32a8,8,0,0,0,0-11.32l-32-32A8,8,0,0,0,98.34,37.66L124.69,64,98.34,90.34A8,8,0,0,0,98.34,101.66ZM200,40H176a8,8,0,0,0,0,16h24V200H56V136a8,8,0,0,0-16,0v64a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Z"}))],["thin",l.createElement(l.Fragment,null,l.createElement("path",{d:"M61.17,98.83l-32-32a4,4,0,0,1,0-5.66l32-32a4,4,0,0,1,5.66,5.66L37.66,64,66.83,93.17a4,4,0,0,1-5.66,5.66Zm40,0a4,4,0,0,0,5.66,0l32-32a4,4,0,0,0,0-5.66l-32-32a4,4,0,0,0-5.66,5.66L130.34,64,101.17,93.17A4,4,0,0,0,101.17,98.83ZM200,44H176a4,4,0,0,0,0,8h24a4,4,0,0,1,4,4V200a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V136a4,4,0,0,0-8,0v64a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Z"}))]]);var Ze=Object.defineProperty,Ce=Object.defineProperties,Se=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,F=(s,t,a)=>t in s?Ze(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a,He=(s,t)=>{for(var a in t||(t={}))Oe.call(t,a)&&F(s,a,t[a]);if(D)for(var a of D(t))Ve.call(t,a)&&F(s,a,t[a]);return s},Le=(s,t)=>Ce(s,Se(t));const K=i.forwardRef((s,t)=>l.createElement(L,Le(He({ref:t},s),{weights:_e})));K.displayName="CodeBlock";const $e=new Map([["bold",l.createElement(l.Fragment,null,l.createElement("path",{d:"M180,64H40A12,12,0,0,0,28,76V216a12,12,0,0,0,12,12H180a12,12,0,0,0,12-12V76A12,12,0,0,0,180,64ZM168,204H52V88H168ZM228,40V180a12,12,0,0,1-24,0V52H76a12,12,0,0,1,0-24H216A12,12,0,0,1,228,40Z"}))],["duotone",l.createElement(l.Fragment,null,l.createElement("path",{d:"M184,72V216H40V72Z",opacity:"0.2"}),l.createElement("path",{d:"M184,64H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H184a8,8,0,0,0,8-8V72A8,8,0,0,0,184,64Zm-8,144H48V80H176ZM224,40V184a8,8,0,0,1-16,0V48H72a8,8,0,0,1,0-16H216A8,8,0,0,1,224,40Z"}))],["fill",l.createElement(l.Fragment,null,l.createElement("path",{d:"M192,72V216a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V72a8,8,0,0,1,8-8H184A8,8,0,0,1,192,72Zm24-40H72a8,8,0,0,0,0,16H208V184a8,8,0,0,0,16,0V40A8,8,0,0,0,216,32Z"}))],["light",l.createElement(l.Fragment,null,l.createElement("path",{d:"M184,66H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H184a6,6,0,0,0,6-6V72A6,6,0,0,0,184,66Zm-6,144H46V78H178ZM222,40V184a6,6,0,0,1-12,0V46H72a6,6,0,0,1,0-12H216A6,6,0,0,1,222,40Z"}))],["regular",l.createElement(l.Fragment,null,l.createElement("path",{d:"M184,64H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H184a8,8,0,0,0,8-8V72A8,8,0,0,0,184,64Zm-8,144H48V80H176ZM224,40V184a8,8,0,0,1-16,0V48H72a8,8,0,0,1,0-16H216A8,8,0,0,1,224,40Z"}))],["thin",l.createElement(l.Fragment,null,l.createElement("path",{d:"M184,68H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H184a4,4,0,0,0,4-4V72A4,4,0,0,0,184,68Zm-4,144H44V76H180ZM220,40V184a4,4,0,0,1-8,0V44H72a4,4,0,0,1,0-8H216A4,4,0,0,1,220,40Z"}))]]);var De=Object.defineProperty,Fe=Object.defineProperties,Pe=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,Te=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,T=(s,t,a)=>t in s?De(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a,Re=(s,t)=>{for(var a in t||(t={}))Te.call(t,a)&&T(s,a,t[a]);if(P)for(var a of P(t))ze.call(t,a)&&T(s,a,t[a]);return s},Ie=(s,t)=>Fe(s,Pe(t));const X=i.forwardRef((s,t)=>l.createElement(L,Ie(Re({ref:t},s),{weights:$e})));X.displayName="CopySimple";const qe=new Map([["bold",l.createElement(l.Fragment,null,l.createElement("path",{d:"M128,96a32,32,0,1,0,32,32A32,32,0,0,0,128,96Zm0,40a8,8,0,1,1,8-8A8,8,0,0,1,128,136Zm80-40a32,32,0,1,0,32,32A32,32,0,0,0,208,96Zm0,40a8,8,0,1,1,8-8A8,8,0,0,1,208,136ZM48,96a32,32,0,1,0,32,32A32,32,0,0,0,48,96Zm0,40a8,8,0,1,1,8-8A8,8,0,0,1,48,136Z"}))],["duotone",l.createElement(l.Fragment,null,l.createElement("path",{d:"M152,128a24,24,0,1,1-24-24A24,24,0,0,1,152,128ZM48,104a24,24,0,1,0,24,24A24,24,0,0,0,48,104Zm160,0a24,24,0,1,0,24,24A24,24,0,0,0,208,104Z",opacity:"0.2"}),l.createElement("path",{d:"M128,96a32,32,0,1,0,32,32A32,32,0,0,0,128,96Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,128,144ZM48,96a32,32,0,1,0,32,32A32,32,0,0,0,48,96Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,48,144ZM208,96a32,32,0,1,0,32,32A32,32,0,0,0,208,96Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,208,144Z"}))],["fill",l.createElement(l.Fragment,null,l.createElement("path",{d:"M156,128a28,28,0,1,1-28-28A28,28,0,0,1,156,128ZM48,100a28,28,0,1,0,28,28A28,28,0,0,0,48,100Zm160,0a28,28,0,1,0,28,28A28,28,0,0,0,208,100Z"}))],["light",l.createElement(l.Fragment,null,l.createElement("path",{d:"M128,98a30,30,0,1,0,30,30A30,30,0,0,0,128,98Zm0,48a18,18,0,1,1,18-18A18,18,0,0,1,128,146ZM48,98a30,30,0,1,0,30,30A30,30,0,0,0,48,98Zm0,48a18,18,0,1,1,18-18A18,18,0,0,1,48,146ZM208,98a30,30,0,1,0,30,30A30,30,0,0,0,208,98Zm0,48a18,18,0,1,1,18-18A18,18,0,0,1,208,146Z"}))],["regular",l.createElement(l.Fragment,null,l.createElement("path",{d:"M128,96a32,32,0,1,0,32,32A32,32,0,0,0,128,96Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,128,144ZM48,96a32,32,0,1,0,32,32A32,32,0,0,0,48,96Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,48,144ZM208,96a32,32,0,1,0,32,32A32,32,0,0,0,208,96Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,208,144Z"}))],["thin",l.createElement(l.Fragment,null,l.createElement("path",{d:"M128,100a28,28,0,1,0,28,28A28,28,0,0,0,128,100Zm0,48a20,20,0,1,1,20-20A20,20,0,0,1,128,148ZM48,100a28,28,0,1,0,28,28A28,28,0,0,0,48,100Zm0,48a20,20,0,1,1,20-20A20,20,0,0,1,48,148Zm160-48a28,28,0,1,0,28,28A28,28,0,0,0,208,100Zm0,48a20,20,0,1,1,20-20A20,20,0,0,1,208,148Z"}))]]);var We=Object.defineProperty,Je=Object.defineProperties,Be=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable,R=(s,t,a)=>t in s?We(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a,Qe=(s,t)=>{for(var a in t||(t={}))Ue.call(t,a)&&R(s,a,t[a]);if(z)for(var a of z(t))Ye.call(t,a)&&R(s,a,t[a]);return s},Ge=(s,t)=>Je(s,Be(t));const ee=i.forwardRef((s,t)=>l.createElement(L,Ge(Qe({ref:t},s),{weights:qe})));ee.displayName="DotsThreeOutline";const w={embeds:async()=>await fetch(`${y}/embeds`,{method:"GET",headers:v()}).then(s=>s.json()).then(s=>(s==null?void 0:s.embeds)||[]).catch(s=>(console.error(s),[])),newEmbed:async s=>await fetch(`${y}/embeds/new`,{method:"POST",headers:v(),body:JSON.stringify(s)}).then(t=>t.json()).catch(t=>(console.error(t),{embed:null,error:t.message})),updateEmbed:async(s,t)=>await fetch(`${y}/embed/update/${s}`,{method:"POST",headers:v(),body:JSON.stringify(t)}).then(a=>a.json()).catch(a=>(console.error(a),{success:!1,error:a.message})),deleteEmbed:async s=>await fetch(`${y}/embed/${s}`,{method:"DELETE",headers:v()}).then(t=>{if(t.ok)return{success:!0,error:null};throw new Error(t.statusText)}).catch(t=>(console.error(t),{success:!0,error:t.message})),chats:async(s=0)=>await fetch(`${y}/embed/chats`,{method:"POST",headers:v(),body:JSON.stringify({offset:s})}).then(t=>t.json()).catch(t=>(console.error(t),[])),deleteChat:async s=>await fetch(`${y}/embed/chats/${s}`,{method:"DELETE",headers:v()}).then(t=>t.json()).catch(t=>(console.error(t),{success:!1,error:t.message}))};function te(s){const t={};for(var[a,r]of s.entries())!r||r===null||(t[a]=r,r==="on"&&(t[a]=!0));return t.hasOwnProperty("allowlist_domains")||(t.allowlist_domains=null),t.hasOwnProperty("allow_model_override")||(t.allow_model_override=!1),t.hasOwnProperty("allow_temperature_override")||(t.allow_temperature_override=!1),t.hasOwnProperty("allow_prompt_override")||(t.allow_prompt_override=!1),t.hasOwnProperty("message_limit")||(t.message_limit=20),t}function Ke({closeModal:s}){const[t,a]=i.useState(null),r=async n=>{a(null),n.preventDefault();const o=new FormData(n.target),d=te(o),{embed:m,error:c}=await w.newEmbed(d);m&&window.location.reload(),a(c)};return e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsx("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:"Create new embed for workspace"})}),e.jsx("button",{onClick:s,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(S,{size:24,weight:"bold",className:"text-white"})})]}),e.jsx("div",{className:"px-7 py-6",children:e.jsxs("form",{onSubmit:r,children:[e.jsxs("div",{className:"space-y-6 max-h-[60vh] overflow-y-auto pr-2",children:[e.jsx(se,{}),e.jsx(ae,{}),e.jsx(re,{}),e.jsx(E,{name:"max_chats_per_day",title:"Max chats per day",hint:"Limit the amount of chats this embedded chat can process in a 24 hour period. Zero is unlimited."}),e.jsx(E,{name:"max_chats_per_session",title:"Max chats per session",hint:"Limit the amount of chats a session user can send with this embed in a 24 hour period. Zero is unlimited."}),e.jsx(E,{name:"message_limit",title:"Message History Limit",hint:"The number of previous messages to include in the chat context. Default is 20.",defaultValue:20}),e.jsx(A,{name:"allow_model_override",title:"Enable dynamic model use",hint:"Allow setting of the preferred LLM model to override the workspace default."}),e.jsx(A,{name:"allow_temperature_override",title:"Enable dynamic LLM temperature",hint:"Allow setting of the LLM temperature to override the workspace default."}),e.jsx(A,{name:"allow_prompt_override",title:"Enable Prompt Override",hint:"Allow setting of the system prompt to override the workspace default."}),t&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",t]}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs md:text-sm",children:["After creating an embed you will be provided a link that you can publish on your website with a simple",e.jsx("code",{className:"light:bg-stone-300 bg-stone-900 text-white mx-1 px-1 rounded-sm",children:"<script>"})," ","tag."]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:s,type:"button",className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Create embed"})]})]})})]})})}const se=({defaultValue:s=null})=>{const[t,a]=i.useState([]);return i.useEffect(()=>{async function r(){const n=await ue.all();a(n)}r()},[]),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col mb-2",children:[e.jsx("label",{htmlFor:"workspace_id",className:"block text-sm font-medium text-white",children:"Workspace"}),e.jsx("p",{className:"text-theme-text-secondary text-xs",children:"This is the workspace your chat window will be based on. All defaults will be inherited from the workspace unless overridden by this config."})]}),e.jsx("select",{name:"workspace_id",required:!0,defaultValue:s,className:"min-w-[15rem] rounded-lg bg-theme-settings-input-bg px-4 py-2 text-sm text-white focus:ring-blue-500 focus:border-blue-500",children:t.map(r=>e.jsx("option",{selected:s===r.id,value:r.id,children:r.name},r.id))})]})},ae=({defaultValue:s=null})=>{const[t,a]=i.useState(s??"query");return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-white",htmlFor:"chat_mode",children:"Allowed chat method"}),e.jsxs("p",{className:"text-theme-text-secondary text-xs",children:["Set how your chatbot should operate. Query means it will only respond if a document helps answer the query.",e.jsx("br",{}),"Chat opens the chat to even general questions and can answer totally unrelated queries to your workspace."]})]}),e.jsxs("div",{className:"mt-2 gap-y-3 flex flex-col",children:[e.jsxs("label",{className:`transition-all duration-300 w-full h-11 p-2.5 rounded-lg flex justify-start items-center gap-2.5 cursor-pointer border ${t==="chat"?"border-theme-sidebar-item-workspace-active bg-theme-bg-secondary":"border-theme-sidebar-border hover:border-theme-sidebar-border hover:bg-theme-bg-secondary"} `,children:[e.jsx("input",{type:"radio",name:"chat_mode",value:"chat",checked:t==="chat",onChange:r=>a(r.target.value),className:"hidden"}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 border-theme-sidebar-border mr-2 ${t==="chat"?"bg-[var(--theme-sidebar-item-workspace-active)]":""}`}),e.jsx("div",{className:"text-theme-text-primary text-sm font-medium font-['Plus Jakarta Sans'] leading-tight",children:"Chat: Respond to all questions regardless of context"})]}),e.jsxs("label",{className:`transition-all duration-300 w-full h-11 p-2.5 rounded-lg flex justify-start items-center gap-2.5 cursor-pointer border ${t==="query"?"border-theme-sidebar-item-workspace-active bg-theme-bg-secondary":"border-theme-sidebar-border hover:border-theme-sidebar-border hover:bg-theme-bg-secondary"} `,children:[e.jsx("input",{type:"radio",name:"chat_mode",value:"query",checked:t==="query",onChange:r=>a(r.target.value),className:"hidden"}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 border-theme-sidebar-border mr-2 ${t==="query"?"bg-[var(--theme-sidebar-item-workspace-active)]":""}`}),e.jsx("div",{className:"text-theme-text-primary text-sm font-medium font-['Plus Jakarta Sans'] leading-tight",children:"Query: Only respond to chats related to documents in workspace"})]})]})]})},re=({defaultValue:s=[]})=>{const[t,a]=i.useState(s),r=o=>{const d=o.map(m=>{let c=m;!c.includes("http://")&&!c.includes("https://")&&(c=`https://${c}`);try{return new URL(c),c}catch{return null}}).filter(m=>!!m);a(d)},n=o=>{const d=o.target.value;if(!d)return;const m=[...t,d].map(c=>{let h=c;!h.includes("http://")&&!h.includes("https://")&&(h=`https://${h}`);try{return new URL(h),h}catch{return null}});o.target.value="",a(m)};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col mb-2",children:[e.jsx("label",{htmlFor:"allowlist_domains",className:"block text-sm font-medium text-white",children:"Restrict requests from domains"}),e.jsxs("p",{className:"text-theme-text-secondary text-xs",children:["This filter will block any requests that come from a domain other than the list below.",e.jsx("br",{}),"Leaving this empty means anyone can use your embed on any site."]})]}),e.jsx("input",{type:"hidden",name:"allowlist_domains",value:t.join(",")}),e.jsx(Me,{value:t,onChange:r,onBlur:n,placeholder:"https://mysite.com, https://anythingllm.com",classNames:{tag:"bg-theme-settings-input-bg light:bg-black/10 bg-blue-300/10 text-zinc-800",input:"flex p-1 !bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none"}})]})},E=({name:s,title:t,hint:a,defaultValue:r=0})=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col mb-2",children:[e.jsx("label",{htmlFor:s,className:"block text-sm font-medium text-white",children:t}),e.jsx("p",{className:"text-theme-text-secondary text-xs",children:a})]}),e.jsx("input",{type:"number",name:s,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-[15rem] p-2.5",min:0,defaultValue:r,onScroll:n=>n.target.blur()})]}),A=({name:s,title:t,hint:a,defaultValue:r=null})=>{const[n,o]=i.useState(r??!1);return e.jsx(xe,{name:s,size:"md",variant:"horizontal",label:t,description:a,enabled:n,onChange:d=>o(d)})};function Xe({embed:s,closeModal:t}){const[a,r]=i.useState(null),n=async o=>{r(null),o.preventDefault();const d=new FormData(o.target),m=te(d),{success:c,error:h}=await w.updateEmbed(s.id,m);c&&(g("Embed updated successfully.","success",{clear:!0}),setTimeout(()=>{window.location.reload()},800)),r(h)};return e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsxs("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:["Update embed #",s.id]})}),e.jsx("button",{onClick:t,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(S,{size:24,weight:"bold",className:"text-white"})})]}),e.jsx("div",{className:"px-7 py-6",children:e.jsxs("form",{onSubmit:n,children:[e.jsxs("div",{className:"space-y-6 max-h-[60vh] overflow-y-auto pr-2",children:[e.jsx(se,{defaultValue:s.workspace.id}),e.jsx(ae,{defaultValue:s.chat_mode}),e.jsx(re,{defaultValue:_(s.allowlist_domains,null)||[]}),e.jsx(E,{name:"max_chats_per_day",title:"Max chats per day",hint:"Limit the amount of chats this embedded chat can process in a 24 hour period. Zero is unlimited.",defaultValue:s.max_chats_per_day}),e.jsx(E,{name:"max_chats_per_session",title:"Max chats per session",hint:"Limit the amount of chats a session user can send with this embed in a 24 hour period. Zero is unlimited.",defaultValue:s.max_chats_per_session}),e.jsx(E,{name:"message_limit",title:"Message History Limit",hint:"The number of previous messages to include in the chat context. Default is 20.",defaultValue:s.message_limit}),e.jsx(A,{name:"allow_model_override",title:"Enable dynamic model use",hint:"Allow setting of the preferred LLM model to override the workspace default.",defaultValue:s.allow_model_override}),e.jsx(A,{name:"allow_temperature_override",title:"Enable dynamic LLM temperature",hint:"Allow setting of the LLM temperature to override the workspace default.",defaultValue:s.allow_temperature_override}),e.jsx(A,{name:"allow_prompt_override",title:"Enable Prompt Override",hint:"Allow setting of the system prompt to override the workspace default.",defaultValue:s.allow_prompt_override}),a&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",a]}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs md:text-sm",children:["After creating an embed you will be provided a link that you can publish on your website with a simple",e.jsx("code",{className:"border-none bg-theme-settings-input-bg text-white mx-1 px-1 rounded-sm",children:"<script>"})," ","tag."]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:t,type:"button",className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Update embed"})]})]})})]})})}function et({embed:s,closeModal:t}){return e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsx("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:"Copy your embed code"})}),e.jsx("button",{onClick:t,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(S,{size:24,weight:"bold",className:"text-white"})})]}),e.jsxs("div",{className:"px-7 py-6",children:[e.jsx("div",{className:"space-y-6 max-h-[60vh] overflow-y-auto pr-2",children:e.jsx(st,{embed:s})}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:t,type:"button",className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Close"}),e.jsx("div",{hidden:!0})]})]})]})})}function tt(s,t,a){return`<!--
2
+ Paste this script at the bottom of your HTML before the </body> tag.
3
+ See more style and config options on our docs
4
+ https://github.com/Mintplex-Labs/anythingllm-embed/blob/main/README.md
5
+ -->
6
+ <script
7
+ data-embed-id="${s.uuid}"
8
+ data-base-api-url="${a}/api/embed"
9
+ src="${t}/embed/anythingllm-chat-widget.min.js">
10
+ <\/script>
11
+ <!-- AnythingLLM (https://anythingllm.com) -->
12
+ `}const st=({embed:s})=>{const[t,a]=i.useState(!1),r=window.location.origin,n=window.location.origin,o=tt(s,r,n),d=window.localStorage.getItem("theme")==="light"?"github":"github-dark",m=()=>{window.navigator.clipboard.writeText(o),a(!0),setTimeout(()=>{a(!1)},2500),g("Snippet copied to clipboard!","success",{clear:!0})};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-white",children:"HTML Script Tag Embed Code"}),e.jsx("p",{className:"text-theme-text-secondary text-xs",children:"Have your workspace chat embed function like a help desk chat bottom in the corner of your website."}),e.jsx("a",{href:"https://github.com/Mintplex-Labs/anythingllm-embed/blob/main/README.md",target:"_blank",rel:"noreferrer",className:"text-blue-300 light:text-blue-500 hover:underline",children:"View all style and configuration options →"})]}),e.jsxs("button",{disabled:t,onClick:m,className:`disabled:border disabled:border-green-300 disabled:light:border-green-600 border border-transparent relative w-full font-mono flex hljs ${d} light:border light:border-gray-700 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5 m-1`,children:[e.jsx("div",{className:"flex w-full text-left flex-col gap-y-1 pr-6 pl-4 whitespace-pre-line",dangerouslySetInnerHTML:{__html:H.highlight(o,{language:"html",ignoreIllegals:!0}).value}}),t?e.jsx(pe,{size:14,className:"text-green-300 light:text-green-600 absolute top-2 right-2"}):e.jsx(X,{size:14,className:"absolute top-2 right-2"})]})]})};function at({embed:s}){const t=i.useRef(null),[a,r]=i.useState(Number(s.enabled)===1),{isOpen:n,openModal:o,closeModal:d}=N(),{isOpen:m,openModal:c,closeModal:h}=N(),p=async()=>{if(!window.confirm(`Are you sure you want to disabled this embed?
13
+ Once disabled the embed will no longer respond to any chat requests.`))return!1;const{success:u,error:f}=await w.updateEmbed(s.id,{enabled:!a});u||g(f,"error",{clear:!0}),u&&(g(`Embed ${a?"has been disabled":"is active"}.`,"success",{clear:!0}),r(!a))},j=async()=>{var Z;if(!window.confirm(`Are you sure you want to delete this embed?
14
+ Once deleted this embed will no longer respond to chats or be active.
15
+
16
+ This action is irreversible.`))return!1;const{success:u,error:f}=await w.deleteEmbed(s.id);u||g(f,"error",{clear:!0}),u&&((Z=t==null?void 0:t.current)==null||Z.remove(),g("Embed deleted from system.","success",{clear:!0}))};return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{ref:t,className:"bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10",children:[e.jsx("th",{scope:"row",className:"px-6 whitespace-nowrap flex item-center gap-x-1",children:e.jsx("a",{href:U.workspace.chat(s.workspace.slug),target:"_blank",rel:"noreferrer",className:"text-white flex items-center hover:underline",children:s.workspace.name})}),e.jsx("th",{scope:"row",className:"px-6 whitespace-nowrap",children:be(s._count.embed_chats)}),e.jsx("th",{scope:"row",className:"px-6 whitespace-nowrap",children:e.jsx(rt,{domainList:s.allowlist_domains})}),e.jsx("th",{scope:"row",className:"px-6 whitespace-nowrap text-theme-text-secondary !font-normal",children:C(s.createdAt).diff(C(),"days")>0?C(s.createdAt).format("MMM D, YYYY"):C(s.createdAt).fromNow()}),e.jsxs("td",{className:"px-6 flex items-center gap-x-6 h-full mt-1",children:[e.jsx("button",{onClick:c,className:"group text-xs font-medium text-theme-text-secondary px-2 py-1 rounded-lg hover:bg-theme-button-code-hover-bg",children:e.jsx("span",{className:"group-hover:text-theme-button-code-hover-text",children:"Code"})}),e.jsx("button",{onClick:p,className:"group text-xs font-medium text-theme-text-secondary px-2 py-1 rounded-lg hover:bg-theme-button-disable-hover-bg",children:e.jsx("span",{className:"group-hover:text-theme-button-disable-hover-text",children:a?"Disable":"Enable"})}),e.jsx("button",{onClick:j,className:"group text-xs font-medium text-theme-text-secondary px-2 py-1 rounded-lg hover:bg-theme-button-delete-hover-bg",children:e.jsx("span",{className:"group-hover:text-theme-button-delete-hover-text",children:"Delete"})}),e.jsx("button",{onClick:o,className:"text-xs font-medium text-theme-button-text hover:text-theme-text-secondary hover:bg-theme-hover px-2 py-1 rounded-lg",children:e.jsx(ee,{weight:"fill",className:"h-5 w-5"})})]})]}),e.jsx(M,{isOpen:n,children:e.jsx(Xe,{embed:s,closeModal:d})}),e.jsx(M,{isOpen:m,children:e.jsx(et,{embed:s,closeModal:h})})]})}function rt({domainList:s}){const t=_(s,[]);return t.length===0?e.jsx("p",{children:"all"}):e.jsx("div",{className:"flex flex-col gap-y-2",children:t.map((a,r)=>e.jsx("p",{className:"font-mono !font-normal",children:a},r))})}function I(){const{isOpen:s,openModal:t,closeModal:a}=N(),{t:r}=Y(),[n,o]=i.useState(!0),[d,m]=i.useState([]);return i.useEffect(()=>{async function c(){const h=await w.embeds();m(h),o(!1)}c()},[]),n?e.jsx(Q,{height:"80vh",width:"100%",highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",count:1,className:"w-full p-4 rounded-b-2xl rounded-tr-2xl rounded-tl-sm",containerClassName:"flex w-full"}):e.jsxs("div",{className:"flex flex-col w-full p-4",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6",children:[e.jsx("div",{className:"items-center flex gap-x-4",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:r("embeddable.title")})}),e.jsxs("div",{className:"flex gap-x-10 mr-8",children:[e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary mt-2",children:r("embeddable.description")}),e.jsx("div",{children:e.jsxs(fe,{onClick:t,className:"text-theme-bg-chat",children:[e.jsx(K,{className:"h-4 w-4",weight:"bold"})," ",r("embeddable.create")]})})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3",children:r("embeddable.table.workspace")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:r("embeddable.table.chats")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:r("embeddable.table.active")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:r("embeddable.table.created")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:" "})]})}),e.jsx("tbody",{children:d.map(c=>e.jsx(at,{embed:c},c.id))})]})}),e.jsx(M,{isOpen:s,children:e.jsx(Ke,{closeModal:a})})]})}const lt=new Ae({html:!0,breaks:!0,highlight:function(s,t){if(t&&H.getLanguage(t))try{return H.highlight(s,{language:t}).value}catch{}return""}}),nt=({thought:s})=>{const[t,a]=i.useState(!1);if(!s)return null;const r=s.replace(/<\/?think>/g,"").trim();return r?e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{onClick:()=>a(!t),className:"cursor-pointer flex items-center gap-x-2 text-theme-text-secondary hover:text-theme-text-primary transition-colors mb-2",children:[e.jsx(G,{size:14,weight:"bold",className:`transition-transform ${t?"rotate-180":""}`}),e.jsx("span",{className:"text-xs font-medium",children:"View thoughts"})]}),t&&e.jsx("div",{className:"bg-theme-bg-chat-input rounded-md p-3 border-l-2 border-theme-text-secondary/30",children:e.jsx("div",{className:"text-xs text-theme-text-secondary font-mono whitespace-pre-wrap",children:r})})]}):null};function ot(s){const t=[];let a=0;return s.replace(/<think>([^]*?)<\/think>/g,(r,n,o)=>{o>a&&t.push({type:"normal",text:s.slice(a,o)}),t.push({type:"think",text:n}),a=o+r.length}),a<s.length&&t.push({type:"normal",text:s.slice(a)}),t}function it({content:s}){if(!s)return null;const t=ot(s);return e.jsx("div",{className:"whitespace-normal",children:t.map((a,r)=>{const n=lt.render(a.text);return a.type==="think"?e.jsx(nt,{thought:a.text},r):e.jsx("div",{dangerouslySetInnerHTML:{__html:Ee.sanitize(n)}},r)})})}function ct({chat:s,onDelete:t}){var u,f;const{isOpen:a,openModal:r,closeModal:n}=N(),{isOpen:o,openModal:d,closeModal:m}=N(),{isOpen:c,openModal:h,closeModal:p}=N(),j=async()=>{if(!window.confirm(`Are you sure you want to delete this chat?
17
+
18
+ This action is irreversible.`))return!1;await w.deleteChat(s.id),t(s.id)};return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10",children:[e.jsx("td",{className:"px-6 font-medium whitespace-nowrap text-white",children:e.jsx("a",{href:U.settings.embedChatWidgets(),target:"_blank",rel:"noreferrer",className:"text-white flex items-center hover:underline",children:s.embed_config.workspace.name})}),e.jsx("td",{onClick:h,className:"px-6 cursor-pointer hover:shadow-lg",children:e.jsx("div",{className:"flex flex-col",children:e.jsx("p",{children:O(s.session_id,20)})})}),e.jsx("td",{onClick:r,className:"px-6 border-transparent cursor-pointer hover:shadow-lg",children:O(s.prompt,40)}),e.jsx("td",{onClick:d,className:"px-6 cursor-pointer hover:shadow-lg",children:O((u=_(s.response,{}))==null?void 0:u.text,40)}),e.jsx("td",{className:"px-6",children:s.createdAt}),e.jsx("td",{className:"px-6 flex items-center gap-x-6 h-full mt-1",children:e.jsx("button",{onClick:j,className:"group text-xs font-medium text-theme-text-secondary px-2 py-1 rounded-lg hover:bg-theme-button-delete-hover-bg",children:e.jsx("span",{className:"group-hover:text-theme-button-delete-hover-text",children:"Delete"})})})]}),e.jsx(M,{isOpen:a,children:e.jsx(V,{text:s.prompt,closeModal:n})}),e.jsx(M,{isOpen:o,children:e.jsx(V,{text:e.jsx(it,{content:(f=_(s.response,{}))==null?void 0:f.text}),closeModal:m})}),e.jsx(M,{isOpen:c,children:e.jsx(V,{text:e.jsx(dt,{sessionId:s.session_id,verbose:!0,connection_information:s.connection_information}),closeModal:p})})]})}const V=({text:s,closeModal:t})=>e.jsx("div",{className:"relative w-full md:max-w-2xl max-h-full",children:e.jsxs("div",{className:"w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("h3",{className:"text-xl font-semibold text-white",children:"Viewing Text"}),e.jsx("button",{onClick:t,type:"button",className:"bg-transparent rounded-lg text-sm p-1.5 ml-auto inline-flex items-center bg-sidebar-button hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(S,{className:"text-white text-lg"})})]}),e.jsx("div",{className:"w-full p-6",children:e.jsx("div",{className:"w-full h-[60vh] py-2 px-4 whitespace-pre-line overflow-auto rounded-lg bg-zinc-900 light:bg-theme-bg-secondary border border-gray-500 text-white text-sm",children:s})})]})}),dt=({sessionId:s,verbose:t=!1,connection_information:a})=>{const r=_(a,{});return Object.keys(r).length===0?null:t?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-xs text-theme-text-secondary",children:["sessionID: ",s]}),r.username&&e.jsxs("p",{className:"text-xs text-theme-text-secondary",children:["username: ",r.username]}),r.ip&&e.jsxs("p",{className:"text-xs text-theme-text-secondary",children:["client ip address: ",r.ip]}),r.host&&e.jsxs("p",{className:"text-xs text-theme-text-secondary",children:["client host URL: ",r.host]})]}):e.jsxs(e.Fragment,{children:[r.username&&e.jsx("p",{className:"text-xs text-theme-text-secondary",children:r.username}),r.ip&&e.jsx("p",{className:"text-xs text-theme-text-secondary",children:r.ip}),r.host&&e.jsx("p",{className:"text-xs text-theme-text-secondary",children:r.host})]})},q={csv:{name:"CSV",mimeType:"text/csv",fileExtension:"csv",filenameFunc:()=>`anythingllm-embed-chats-${new Date().toLocaleDateString()}`},json:{name:"JSON",mimeType:"application/json",fileExtension:"json",filenameFunc:()=>`anythingllm-embed-chats-${new Date().toLocaleDateString()}`},jsonl:{name:"JSONL",mimeType:"application/jsonl",fileExtension:"jsonl",filenameFunc:()=>`anythingllm-embed-chats-${new Date().toLocaleDateString()}-lines`},jsonAlpaca:{name:"JSON (Alpaca)",mimeType:"application/json",fileExtension:"json",filenameFunc:()=>`anythingllm-embed-chats-${new Date().toLocaleDateString()}-alpaca`}};function W(){const{t:s}=Y(),t=i.useRef(),a=ge(),r=i.useRef(),[n,o]=i.useState(!1),[d,m]=i.useState(!0),[c,h]=i.useState([]),[p,j]=i.useState(Number(a.get("offset")||0)),[u,f]=i.useState(!1),Z=async x=>{const b=await we.exportChats(x,"embed");if(b){const{name:k,mimeType:ce,fileExtension:de,filenameFunc:me}=q[x],he=new Blob([b],{type:ce});je.saveAs(he,`${me()}.${de}`),g(`Embed chats exported successfully as ${k}.`,"success")}else g("Failed to export embed chats.","error")},le=()=>{o(!n)};i.useEffect(()=>{function x(b){t.current&&!t.current.contains(b.target)&&!r.current.contains(b.target)&&o(!1)}return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]),i.useEffect(()=>{async function x(){m(!0),await w.chats(p).then(({chats:b,hasPages:k=!1})=>{h(b),f(k)}).finally(()=>{m(!1)})}x()},[p]);const ne=()=>{j(Math.max(p-1,0))},oe=()=>{j(p+1)},ie=x=>{h(b=>b.filter(k=>k.id!==x))};return d?e.jsx(Q,{height:"80vh",width:"100%",highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",count:1,className:"w-full p-4 rounded-b-2xl rounded-tr-2xl rounded-tl-sm",containerClassName:"flex w-full"}):e.jsxs("div",{className:"flex flex-col w-full p-4 overflow-none",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:s("embed-chats.title")}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:r,onClick:le,className:"flex items-center gap-x-2 px-4 py-1 rounded-lg text-theme-bg-chat bg-primary-button hover:bg-secondary hover:text-white text-xs font-semibold h-[34px] w-fit",children:[e.jsx(ke,{size:18,weight:"bold"}),s("embed-chats.export"),e.jsx(G,{size:18,weight:"bold"})]}),e.jsx("div",{ref:t,className:`${n?"slide-down":"slide-up hidden"} z-20 w-fit rounded-lg absolute top-full right-0 bg-secondary light:bg-theme-bg-secondary mt-2 shadow-md`,children:e.jsx("div",{className:"py-2",children:Object.entries(q).map(([x,b])=>e.jsx("button",{onClick:()=>{Z(x),o(!1)},className:"w-full text-left px-4 py-2 text-white text-sm hover:bg-[#3D4147] light:hover:bg-theme-sidebar-item-hover",children:b.name},x))})})]})]}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary mt-2",children:s("embed-chats.description")})]}),e.jsxs("div",{className:"overflow-x-auto mt-6",children:[e.jsxs("table",{className:"w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tl-lg",children:s("embed-chats.table.embed")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:s("embed-chats.table.sender")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:s("embed-chats.table.message")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:s("embed-chats.table.response")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:s("embed-chats.table.at")}),e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tr-lg",children:" "})]})}),e.jsx("tbody",{children:c.map(x=>e.jsx(ct,{chat:x,onDelete:ie},x.id))})]}),(p>0||u)&&e.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4 pb-6",children:[e.jsx("button",{onClick:ne,disabled:p===0,className:`px-4 py-2 text-sm rounded-lg ${p===0?"bg-theme-bg-secondary text-theme-text-disabled cursor-not-allowed":"bg-theme-bg-secondary text-theme-text-primary hover:bg-theme-hover"}`,children:s("common.previous")}),e.jsx("button",{onClick:oe,disabled:!u,className:`px-4 py-2 text-sm rounded-lg ${u?"bg-theme-bg-secondary text-theme-text-primary hover:bg-theme-hover":"bg-theme-bg-secondary text-theme-text-disabled cursor-not-allowed"}`,children:s("common.next")})]})]})]})}function gt(){const[s,t]=i.useState("configs"),[a,r]=i.useState(!1);return $?e.jsx(J,{children:e.jsxs("div",{className:"flex flex-col w-full p-4 mt-10",children:[e.jsxs("div",{hidden:a,className:"flex flex-col gap-y-[18px] overflow-y-scroll no-scroll",children:[e.jsx("div",{className:"text-theme-text-primary flex items-center gap-x-2",children:e.jsx("p",{className:"text-lg font-medium",children:"Chat Embed"})}),e.jsx(B,{selectedView:s,handleClick:n=>{t(n),r(!0)}})]}),a&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-sidebar z-30",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex items-center p-4",children:e.jsx("button",{type:"button",onClick:()=>{r(!1),t("")},className:"text-white/60 hover:text-white transition-colors duration-200",children:e.jsxs("div",{className:"flex items-center text-sky-400",children:[e.jsx(ye,{size:24}),e.jsx("div",{children:"Back"})]})})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.jsx("div",{className:"bg-theme-bg-secondary text-white rounded-xl p-4 overflow-y-scroll no-scroll",children:s==="configs"?e.jsx(I,{}):e.jsx(W,{})})})]})})]})}):e.jsx(J,{children:e.jsxs("div",{className:"flex-1 flex gap-x-6 p-4 mt-10",children:[e.jsxs("div",{className:"flex flex-col min-w-[360px] h-[calc(100vh-90px)]",children:[e.jsx("div",{className:"flex-none mb-4",children:e.jsx("div",{className:"text-theme-text-primary flex items-center gap-x-2",children:e.jsx("p",{className:"text-lg font-medium",children:"Chat Embed"})})}),e.jsx("div",{className:"flex-1 overflow-y-auto pr-2 pb-4",children:e.jsx("div",{className:"space-y-4",children:e.jsx(B,{selectedView:s,handleClick:t})})})]}),e.jsx("div",{className:"flex-[2] flex flex-col gap-y-[18px] mt-10",children:e.jsx("div",{className:"bg-theme-bg-secondary text-white rounded-xl flex-1 p-4 overflow-y-scroll no-scroll",children:s==="configs"?e.jsx(I,{}):e.jsx(W,{})})})]})})}function J({children:s}){return e.jsxs("div",{id:"workspace-widget-settings-container",className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex md:mt-0 mt-6",children:[e.jsx(ve,{}),e.jsx("div",{style:{height:$?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] w-full h-full flex",children:s})]})}function B({selectedView:s,handleClick:t}){const a={configs:{title:"Widgets"},chats:{title:"History"}};return e.jsx("div",{className:`bg-theme-bg-secondary text-white rounded-xl ${$?"w-full":"min-w-[360px] w-fit"}`,children:Object.entries(a).map(([r,n],o)=>e.jsxs("div",{className:`py-3 px-4 flex items-center justify-between ${o===0?"rounded-t-xl":""} ${o===Object.keys(a).length-1?"rounded-b-xl":"border-b border-white/10"} cursor-pointer transition-all duration-300 hover:bg-theme-bg-primary ${s===r?"bg-white/10 light:bg-theme-bg-sidebar":""}`,onClick:()=>t==null?void 0:t(r),children:[e.jsx("div",{className:"text-sm font-light",children:n.title}),e.jsx(Ne,{size:14,weight:"bold",className:"text-theme-text-secondary"})]},r))})}export{gt as default};
@@ -1,2 +1,2 @@
1
- import{r as m,j as e,k as b,t as x,c as u,q as f,O as y,aU as w,M as g,$ as j,i as v,C as N,I as k,S as C}from"../index.js";import{t as h}from"./truncate-352eb33b.js";function V({variable:t,closeModal:l,onRefresh:s}){const[a,i]=m.useState(null),d=async c=>{if(!t.id)return;c.preventDefault(),i(null);const o=new FormData(c.target),r={};for(const[n,p]of o.entries())r[n]=p.trim();if(!r.key||!r.value){i("Key and value are required");return}try{await x.promptVariables.update(t.id,r),u("Variable updated successfully","success",{clear:!0}),s&&s(),l()}catch(n){console.error("Error updating variable:",n),i("Failed to update variable")}};return e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsxs("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:["Edit ",t.key]})}),e.jsx("button",{onClick:l,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(b,{size:24,weight:"bold",className:"text-white"})})]}),e.jsx("div",{className:"p-6",children:e.jsxs("form",{onSubmit:d,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"key",className:"block mb-2 text-sm font-medium text-white",children:"Key"}),e.jsx("input",{name:"key",minLength:3,maxLength:255,type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"e.g., company_name",defaultValue:t.key,required:!0,autoComplete:"off",pattern:"^[a-zA-Z0-9_]+$"}),e.jsxs("p",{className:"mt-2 text-xs text-white/60",children:["Key must be unique and will be used in prompts as ","{key}",". Only letters, numbers and underscores are allowed."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"value",className:"block mb-2 text-sm font-medium text-white",children:"Value"}),e.jsx("input",{name:"value",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"e.g., Acme Corp",defaultValue:t.value,required:!0,autoComplete:"off"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block mb-2 text-sm font-medium text-white",children:"Description"}),e.jsx("input",{name:"description",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"Optional description",defaultValue:t.description,autoComplete:"off"})]}),a&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",a]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:l,type:"button",className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Update variable"})]})]})})]})})}function E({variable:t,onRefresh:l}){const s=m.useRef(null),{isOpen:a,openModal:i,closeModal:d}=f(),c=async()=>{var n;if(t.id){if(!window.confirm(`Are you sure you want to delete the variable "${t.key}"?
1
+ import{r as m,j as e,k as b,t as x,c as u,q as f,Q as y,aW as w,M as g,a1 as j,i as v,C as N,I as k,S as C}from"../index.js";import{t as h}from"./truncate-06273256.js";function V({variable:t,closeModal:l,onRefresh:s}){const[a,i]=m.useState(null),d=async c=>{if(!t.id)return;c.preventDefault(),i(null);const o=new FormData(c.target),r={};for(const[n,p]of o.entries())r[n]=p.trim();if(!r.key||!r.value){i("Key and value are required");return}try{await x.promptVariables.update(t.id,r),u("Variable updated successfully","success",{clear:!0}),s&&s(),l()}catch(n){console.error("Error updating variable:",n),i("Failed to update variable")}};return e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsxs("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:["Edit ",t.key]})}),e.jsx("button",{onClick:l,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(b,{size:24,weight:"bold",className:"text-white"})})]}),e.jsx("div",{className:"p-6",children:e.jsxs("form",{onSubmit:d,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"key",className:"block mb-2 text-sm font-medium text-white",children:"Key"}),e.jsx("input",{name:"key",minLength:3,maxLength:255,type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"e.g., company_name",defaultValue:t.key,required:!0,autoComplete:"off",pattern:"^[a-zA-Z0-9_]+$"}),e.jsxs("p",{className:"mt-2 text-xs text-white/60",children:["Key must be unique and will be used in prompts as ","{key}",". Only letters, numbers and underscores are allowed."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"value",className:"block mb-2 text-sm font-medium text-white",children:"Value"}),e.jsx("input",{name:"value",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"e.g., Acme Corp",defaultValue:t.value,required:!0,autoComplete:"off"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block mb-2 text-sm font-medium text-white",children:"Description"}),e.jsx("input",{name:"description",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"Optional description",defaultValue:t.description,autoComplete:"off"})]}),a&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",a]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:l,type:"button",className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Update variable"})]})]})})]})})}function E({variable:t,onRefresh:l}){const s=m.useRef(null),{isOpen:a,openModal:i,closeModal:d}=f(),c=async()=>{var n;if(t.id){if(!window.confirm(`Are you sure you want to delete the variable "${t.key}"?
2
2
  This action is irreversible.`))return!1;try{await x.promptVariables.delete(t.id),(n=s==null?void 0:s.current)==null||n.remove(),u("Variable deleted successfully","success",{clear:!0}),l&&l()}catch(p){console.error("Error deleting variable:",p),u("Failed to delete variable","error",{clear:!0})}}},r=(n=>{switch(n){case"system":return{bg:"bg-blue-600/20",text:"text-blue-400 light:text-blue-800"};case"user":return{bg:"bg-green-600/20",text:"text-green-400 light:text-green-800"};case"workspace":return{bg:"bg-cyan-600/20",text:"text-cyan-400 light:text-cyan-800"};default:return{bg:"bg-yellow-600/20",text:"text-yellow-400 light:text-yellow-800"}}})(t.type);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{ref:s,className:"bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10",children:[e.jsx("th",{scope:"row",className:"px-4 py-2 whitespace-nowrap",children:t.key}),e.jsx("td",{className:"px-4 py-2",children:typeof t.value=="function"?t.value():h(t.value,50)}),e.jsx("td",{className:"px-4 py-2",children:h(t.description||"-",50)}),e.jsx("td",{className:"px-4 py-2",children:e.jsx("span",{className:`rounded-full ${r.bg} px-2 py-0.5 text-xs leading-5 font-semibold ${r.text} shadow-sm`,children:y((t==null?void 0:t.type)??"static")})}),e.jsx("td",{className:"px-4 py-2 flex items-center justify-end gap-x-4",children:t.type==="static"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:i,className:"text-xs font-medium text-white/80 light:text-black/80 rounded-lg hover:text-white hover:light:text-gray-500 px-2 py-1 hover:bg-white hover:bg-opacity-10",children:"Edit"}),e.jsx("button",{onClick:c,className:"text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10",children:e.jsx(w,{className:"h-4 w-4"})})]})})]}),e.jsx(g,{isOpen:a,children:e.jsx(V,{variable:t,closeModal:d,onRefresh:l})})]})}function S({closeModal:t,onRefresh:l}){const[s,a]=m.useState(null),i=async d=>{d.preventDefault(),a(null);const c=new FormData(d.target),o={};for(const[r,n]of c.entries())o[r]=n.trim();if(!o.key||!o.value){a("Key and value are required");return}try{await x.promptVariables.create(o),u("Variable created successfully","success",{clear:!0}),l&&l(),t()}catch(r){console.error("Error creating variable:",r),a("Failed to create variable")}};return e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsx("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:"Add New Variable"})}),e.jsx("button",{onClick:t,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(b,{size:24,weight:"bold",className:"text-white"})})]}),e.jsx("div",{className:"p-6",children:e.jsxs("form",{onSubmit:i,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"key",className:"block mb-2 text-sm font-medium text-white",children:"Key"}),e.jsx("input",{name:"key",type:"text",minLength:3,maxLength:255,className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"e.g., company_name",required:!0,autoComplete:"off",pattern:"^[a-zA-Z0-9_]+$"}),e.jsxs("p",{className:"mt-2 text-xs text-white/60",children:["Key must be unique and will be used in prompts as ","{key}",". Only letters, numbers and underscores are allowed."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"value",className:"block mb-2 text-sm font-medium text-white",children:"Value"}),e.jsx("input",{name:"value",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"e.g., Acme Corp",required:!0,autoComplete:"off"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block mb-2 text-sm font-medium text-white",children:"Description"}),e.jsx("input",{name:"description",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"Optional description",autoComplete:"off"})]}),s&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",s]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:t,type:"button",className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Create variable"})]})]})})]})})}function D(){const[t,l]=m.useState([]),[s,a]=m.useState(!0),{isOpen:i,openModal:d,closeModal:c}=f();m.useEffect(()=>{o()},[]);const o=async()=>{a(!0);try{const{variables:r}=await x.promptVariables.getAll();l(r||[])}catch(r){console.error("Error fetching variables:",r),u("No variables found","error")}finally{a(!1)}};return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(j,{}),e.jsx("div",{style:{height:v?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2",children:[e.jsx("div",{className:"items-center flex gap-x-4",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:"System Prompt Variables"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary",children:"System prompt variables are used to store configuration values that can be referenced in your system prompt to enable dynamic content in your prompts."})]}),e.jsx("div",{className:"w-full justify-end flex",children:e.jsxs(N,{onClick:d,className:"mt-3 mr-0 mb-4 md:-mb-6 z-10",children:[e.jsx(k,{className:"h-4 w-4",weight:"bold"})," Add Variable"]})}),e.jsx("div",{className:"overflow-x-auto",children:s?e.jsx(C,{height:"80vh",width:"100%",highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",count:1,className:"w-full p-4 rounded-b-2xl rounded-tr-2xl rounded-tl-sm mt-8",containerClassName:"flex w-full"}):t.length===0?e.jsx("div",{className:"text-center py-4 text-theme-text-secondary",children:"No variables found"}):e.jsxs("table",{className:"w-full text-sm text-left rounded-lg min-w-[640px] border-spacing-0",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-4 py-2 rounded-tl-lg",children:"Key"}),e.jsx("th",{scope:"col",className:"px-4 py-2",children:"Value"}),e.jsx("th",{scope:"col",className:"px-4 py-2",children:"Description"}),e.jsx("th",{scope:"col",className:"px-4 py-2",children:"Type"})]})}),e.jsx("tbody",{children:t.map(r=>e.jsx(E,{variable:r,onRefresh:o},r.id))})]})})]})}),e.jsx(g,{isOpen:i,children:e.jsx(S,{closeModal:c,onRefresh:o})})]})}export{D as default};
@@ -0,0 +1 @@
1
+ import{r,q as N,u as j,j as e,a1 as k,i as d,h as z,C as S,at as C,M as T,c as i}from"../index.js";import{A as u}from"./admin-04b020fe.js";import{C as M}from"./index-4277cf52.js";function n(t){return t===null?!0:isNaN(t)}function F(){const[t,p]=r.useState({}),[h,f]=r.useState(!0),[g,o]=r.useState(!1),[b,c]=r.useState(!1),{isOpen:_,openModal:v,closeModal:m}=N(),{t:l}=j(),y=async s=>{s.preventDefault();const a=new FormData(s.target);if(Number(a.get("text_splitter_chunk_overlap"))>=Number(a.get("text_splitter_chunk_size"))){i("Chunk overlap cannot be larger or equal to chunk size.","error");return}v()},w=async()=>{o(!0);try{const s=new FormData(document.getElementById("text-splitter-chunking-form"));await u.updateSystemPreferences({text_splitter_chunk_size:n(s.get("text_splitter_chunk_size"))?1e3:Number(s.get("text_splitter_chunk_size")),text_splitter_chunk_overlap:n(s.get("text_splitter_chunk_overlap"))?1e3:Number(s.get("text_splitter_chunk_overlap"))}),c(!1),m(),i("Text chunking strategy settings saved.","success")}catch{i("Failed to save text chunking strategy settings.","error")}finally{o(!1)}};return r.useEffect(()=>{async function s(){var x;const a=(x=await u.systemPreferencesByFields(["text_splitter_chunk_size","text_splitter_chunk_overlap","max_embed_chunk_size"]))==null?void 0:x.settings;p(a??{}),f(!1)}s()},[]),e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(k,{}),h?e.jsx("div",{style:{height:d?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsx("div",{className:"w-full h-full flex justify-center items-center",children:e.jsx(z,{})})}):e.jsx("div",{style:{height:d?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsx("form",{onSubmit:y,onChange:()=>c(!0),className:"flex w-full",id:"text-splitter-chunking-form",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-4 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10",children:[e.jsx("div",{className:"flex gap-x-4 items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:l("text.title")})}),e.jsxs("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:[l("text.desc-start")," ",e.jsx("br",{}),l("text.desc-end")]})]}),e.jsx("div",{className:"w-full justify-end flex",children:b&&e.jsx(S,{className:"mt-3 mr-0 -mb-14 z-10",children:l(g?"common.saving":"common.save")})}),e.jsx("div",{className:"flex flex-col gap-y-4 mt-8",children:e.jsxs("div",{className:"flex flex-col max-w-[300px]",children:[e.jsxs("div",{className:"flex flex-col gap-y-2 mb-4",children:[e.jsx("label",{className:"text-white text-sm font-semibold block",children:l("text.size.title")}),e.jsx("p",{className:"text-xs text-white/60",children:l("text.size.description")})]}),e.jsx("input",{type:"number",name:"text_splitter_chunk_size",min:1,max:(t==null?void 0:t.max_embed_chunk_size)||1e3,onWheel:s=>{var a;return(a=s==null?void 0:s.currentTarget)==null?void 0:a.blur()},className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"maximum length of vectorized text",defaultValue:n(t==null?void 0:t.text_splitter_chunk_size)?1e3:Number(t==null?void 0:t.text_splitter_chunk_size),required:!0,autoComplete:"off"}),e.jsxs("p",{className:"text-xs text-white/40 mt-2",children:[l("text.size.recommend")," ",C((t==null?void 0:t.max_embed_chunk_size)||1e3),"."]})]})}),e.jsx("div",{className:"flex flex-col gap-y-4 mt-8",children:e.jsxs("div",{className:"flex flex-col max-w-[300px]",children:[e.jsxs("div",{className:"flex flex-col gap-y-2 mb-4",children:[e.jsx("label",{className:"text-white text-sm font-semibold block",children:l("text.overlap.title")}),e.jsx("p",{className:"text-xs text-white/60",children:l("text.overlap.description")})]}),e.jsx("input",{type:"number",name:"text_splitter_chunk_overlap",min:0,onWheel:s=>{var a;return(a=s==null?void 0:s.currentTarget)==null?void 0:a.blur()},className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"maximum length of vectorized text",defaultValue:n(t==null?void 0:t.text_splitter_chunk_overlap)?20:Number(t==null?void 0:t.text_splitter_chunk_overlap),required:!0,autoComplete:"off"})]})})]})})}),e.jsx(T,{isOpen:_,children:e.jsx(M,{warningText:"Changing text splitter settings will clear any previously cached documents.\\n\\nThese new settings will be applied to all documents when embedding them into a workspace.",onClose:m,onConfirm:w})})]})}export{F as default};
@@ -0,0 +1 @@
1
+ import{r as l,j as e,u as p,a1 as T,i as k,h as B,C as V,K as X,k as F,a2 as $,N as Q,a3 as q,J as G,t as C,c as A}from"../index.js";import{w as P}from"./Gauge-e6762f4d.js";function H({settings:t}){const[n,i]=l.useState(t==null?void 0:t.OpenAiKey),[o,r]=l.useState(t==null?void 0:t.OpenAiKey);return e.jsxs("div",{className:"flex gap-x-7 gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"API Key"}),e.jsx("input",{type:"password",name:"OpenAiKey",className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"OpenAI API Key",defaultValue:t!=null&&t.OpenAiKey?"*".repeat(20):"",required:!0,autoComplete:"off",spellCheck:!1,onChange:d=>i(d.target.value),onBlur:()=>r(n)})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Whisper Model"}),e.jsx("select",{disabled:!0,className:"border-none flex-shrink-0 bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:e.jsx("option",{disabled:!0,selected:!0,children:"Whisper Large"})})]})]})}function J({settings:t}){const{t:n}=p(),[i,o]=l.useState(t==null?void 0:t.WhisperModelPref);return e.jsxs("div",{className:"w-full flex flex-col gap-y-4",children:[e.jsx(_,{model:i}),e.jsx("div",{className:"w-full flex items-center gap-4",children:e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:n("common.selection")}),e.jsx("select",{name:"WhisperModelPref",defaultValue:i,onChange:r=>o(r.target.value),className:"border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:["Xenova/whisper-small","Xenova/whisper-large"].map((r,d)=>e.jsx("option",{value:r,children:r},d))})]})})]})}function _({model:t}){switch(t){case"Xenova/whisper-small":return e.jsx(O,{});case"Xenova/whisper-large":return e.jsx(U,{});default:return e.jsx(O,{})}}function O(){const{t}=p();return e.jsx("div",{className:"flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-4 bg-blue-800/30 w-fit rounded-lg px-4 py-2",children:e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(P,{size:25}),e.jsxs("p",{className:"text-sm",children:[t("transcription.warn-start"),e.jsx("br",{}),t("transcription.warn-recommend"),e.jsx("br",{}),e.jsx("br",{}),e.jsxs("i",{children:[t("transcription.warn-end")," (250mb)"]})]})]})})}function U(){const{t}=p();return e.jsx("div",{className:"flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-4 bg-blue-800/30 w-fit rounded-lg px-4 py-2",children:e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(P,{size:25}),e.jsxs("p",{className:"text-sm",children:[t("transcription.warn-start"),e.jsx("br",{}),t("transcription.warn-recommend"),e.jsx("br",{}),e.jsx("br",{}),e.jsxs("i",{children:[t("transcription.warn-end")," (1.56GB)"]})]})]})})}const w=[{name:"OpenAI",value:"openai",logo:q,options:t=>e.jsx(H,{settings:t}),description:"Leverage the OpenAI Whisper-large model using your API key."},{name:"AnythingLLM Built-In",value:"local",logo:G,options:t=>e.jsx(J,{settings:t}),description:"Run a built-in whisper model on this instance privately."}];function ee(){var N;const[t,n]=l.useState(!1),[i,o]=l.useState(!1),[r,d]=l.useState(null),[L,I]=l.useState(!0),[u,h]=l.useState(""),[z,K]=l.useState([]),[c,v]=l.useState(null),[f,x]=l.useState(!1),b=l.useRef(null),{t:g}=p(),y=async s=>{s.preventDefault();const a=s.target,S={WhisperProvider:c},D=new FormData(a);for(var[R,E]of D.entries())S[R]=E;const{error:j}=await C.updateSystem(S);n(!0),j?A(`Failed to save preferences: ${j}`,"error"):A("Transcription preferences saved successfully.","success"),n(!1),o(!!j)},M=s=>{h(""),v(s),x(!1),o(!0)},W=()=>{u.length>0?(h(""),b.current&&(b.current.value="")):x(!f)};l.useEffect(()=>{async function s(){const a=await C.keys();d(a),v((a==null?void 0:a.WhisperProvider)||"local"),I(!1)}s()},[]),l.useEffect(()=>{const s=w.filter(a=>a.name.toLowerCase().includes(u.toLowerCase()));K(s)},[u,c]);const m=w.find(s=>s.value===c);return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(T,{}),L?e.jsx("div",{style:{height:k?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsx("div",{className:"w-full h-full flex justify-center items-center",children:e.jsx(B,{})})}):e.jsx("div",{style:{height:k?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsx("form",{onSubmit:y,className:"flex w-full",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] py-16 md:py-6",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10",children:[e.jsx("div",{className:"flex gap-x-4 items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:g("transcription.title")})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:g("transcription.description")})]}),e.jsx("div",{className:"w-full justify-end flex",children:i&&e.jsx(V,{onClick:()=>y(),className:"mt-3 mr-0 -mb-14 z-10",children:t?"Saving...":"Save changes"})}),e.jsx("div",{className:"text-base font-bold text-white mt-6 mb-4",children:g("transcription.provider")}),e.jsxs("div",{className:"relative",children:[f&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>x(!1)}),f?e.jsx("div",{className:"absolute top-0 left-0 w-full max-w-[640px] max-h-[310px] min-h-[64px] bg-theme-settings-input-bg rounded-lg flex flex-col justify-between cursor-pointer border-2 border-primary-button z-20",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-1",children:[e.jsxs("div",{className:"flex items-center sticky top-0 z-10 border-b border-[#9CA3AF] mx-4 bg-theme-settings-input-bg",children:[e.jsx(X,{size:20,weight:"bold",className:"absolute left-4 z-30 text-theme-text-primary -ml-4 my-2"}),e.jsx("input",{type:"text",name:"provider-search",autoComplete:"off",placeholder:"Search audio transcription providers",className:"border-none -ml-4 my-2 bg-transparent z-20 pl-12 h-[38px] w-full px-4 py-1 text-sm outline-none focus:outline-primary-button active:outline-primary-button outline-none text-theme-text-primary placeholder:text-theme-text-primary placeholder:font-medium",onChange:s=>h(s.target.value),ref:b,onKeyDown:s=>{s.key==="Enter"&&s.preventDefault()}}),e.jsx(F,{size:20,weight:"bold",className:"cursor-pointer text-white hover:text-x-button",onClick:W})]}),e.jsx("div",{className:"flex-1 pl-4 pr-2 flex flex-col gap-y-1 overflow-y-auto white-scrollbar pb-4 max-h-[245px]",children:z.map(s=>e.jsx($,{name:s.name,value:s.value,image:s.logo,description:s.description,checked:c===s.value,onClick:()=>M(s.value)},s.name))})]})}):e.jsxs("button",{className:"w-full max-w-[640px] h-[64px] bg-theme-settings-input-bg rounded-lg flex items-center p-[14px] justify-between cursor-pointer border-2 border-transparent hover:border-primary-button transition-all duration-300",type:"button",onClick:()=>x(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:m.logo,alt:`${m.name} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:m.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:m.description})]})]}),e.jsx(Q,{size:24,weight:"bold",className:"text-white"})]})]}),e.jsx("div",{onChange:()=>o(!0),className:"mt-4 flex flex-col gap-y-1",children:c&&((N=w.find(s=>s.value===c))==null?void 0:N.options(r))})]})})})]})}export{ee as default};
@@ -0,0 +1 @@
1
+ import{r as i,u,j as e,aF as p,aT as c,a1 as h,i as m}from"../index.js";function g(){const[n,r]=i.useState(!1),[l,o]=i.useState(!0),{t:a}=u(),d=async t=>{o(t),r(!0);try{c.updateSettings({autoSubmitSttInput:t})}catch(s){console.error("Failed to update appearance settings:",s),o(!t)}r(!1)};return i.useEffect(()=>{function t(){const s=c.getSettings();o(s.autoSubmitSttInput??!0)}t()},[]),e.jsx("div",{className:"my-4",children:e.jsx(p,{size:"md",variant:"horizontal",enabled:l,onChange:d,disabled:n,label:a("customization.chat.auto_submit.title"),description:a("customization.chat.auto_submit.description")})})}function S(){const[n,r]=i.useState(!1),[l,o]=i.useState(!1),{t:a}=u(),d=async t=>{o(t),r(!0);try{c.updateSettings({autoPlayAssistantTtsResponse:t})}catch(s){console.error("Failed to update appearance settings:",s),o(!t)}r(!1)};return i.useEffect(()=>{function t(){const s=c.getSettings();o(s.autoPlayAssistantTtsResponse??!1)}t()},[]),e.jsx("div",{className:"my-4",children:e.jsx(p,{size:"md",variant:"horizontal",enabled:l,onChange:d,disabled:n,label:a("customization.chat.auto_speak.title"),description:a("customization.chat.auto_speak.description")})})}function f(){const{t:n}=u(),[r,l]=i.useState(!1),[o,a]=i.useState(c.get("enableSpellCheck")),d=async t=>{a(t),l(!0);try{c.set("enableSpellCheck",t)}catch(s){console.error("Failed to update appearance settings:",s),a(!t)}l(!1)};return e.jsx("div",{className:"my-4",children:e.jsx(p,{size:"md",variant:"horizontal",enabled:o,onChange:d,disabled:r,label:n("customization.chat.spellcheck.title"),description:n("customization.chat.spellcheck.description")})})}function b(){const{t:n}=u(),[r,l]=i.useState(!1),[o,a]=i.useState(!1),d=async t=>{a(t),l(!0);try{c.updateSettings({showScrollbar:t})}catch(s){console.error("Failed to update appearance settings:",s),a(!t)}l(!1)};return i.useEffect(()=>{function t(){const s=c.getSettings();a(s.showScrollbar)}t()},[]),e.jsx("div",{className:"my-4",children:e.jsx(p,{size:"md",variant:"horizontal",enabled:o,onChange:d,disabled:r,label:n("customization.items.show-scrollbar.title"),description:n("customization.items.show-scrollbar.description")})})}function x(){const{t:n}=u(),[r,l]=i.useState(!1),[o,a]=i.useState(!1),d=async t=>{a(t),l(!0);try{c.updateSettings({renderHTML:t})}catch(s){console.error("Failed to update appearance settings:",s),a(!t)}l(!1)};return i.useEffect(()=>{function t(){const s=c.getSettings();a(s.renderHTML)}t()},[]),e.jsx("div",{className:"my-4",children:e.jsx(p,{size:"md",variant:"horizontal",enabled:o,onChange:d,disabled:r,label:n("customization.items.render-html.title"),description:n("customization.items.render-html.description")})})}function y(){const{t:n}=u();return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(h,{}),e.jsx("div",{style:{height:m?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10",children:[e.jsx("div",{className:"items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:n("customization.chat.title")})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:n("customization.chat.description")})]}),e.jsx(g,{}),e.jsx(S,{}),e.jsx(f,{}),e.jsx(b,{}),e.jsx(x,{})]})})]})}export{y as default};
@@ -0,0 +1 @@
1
+ import{R as i,r as o,g as oe,j as e,aD as st,aE as de,aF as te,t as C,c as w,y as me,b as gt,p as re,u as _,aG as ft,a7 as lt,ae as nt,Q as at,aH as pt,ab as bt,aI as xe,a4 as rt,q as jt,M as yt,k as vt,i as L,e as wt,aJ as Nt,v as Re,a1 as St}from"../index.js";import{A as G}from"./admin-04b020fe.js";import{M as J,H as kt,g as At,a as Mt,b as Ct,D as Et}from"./mcpServers-1686e782.js";import{I as De}from"./Hammer-05b5ccc7.js";import{w as ie}from"./Plug-7d951c7d.js";import{w as Y,c as _t}from"./types-e90e1137.js";import{C as Ft}from"./index-efee6d1f.js";import{A as ue}from"./agentFlows-e4124dd3.js";import{T as Zt}from"./Trans-820f1dad.js";import"./Database-f1a76329.js";import"./Copy-d323e545.js";import"./File-b92df2f3.js";import"./XCircle-edfe554c.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";const Ht=new Map([["bold",i.createElement(i.Fragment,null,i.createElement("path",{d:"M232,44H160a43.86,43.86,0,0,0-32,13.85A43.86,43.86,0,0,0,96,44H24A12,12,0,0,0,12,56V200a12,12,0,0,0,12,12H96a20,20,0,0,1,20,20,12,12,0,0,0,24,0,20,20,0,0,1,20-20h72a12,12,0,0,0,12-12V56A12,12,0,0,0,232,44ZM96,188H36V68H96a20,20,0,0,1,20,20V192.81A43.79,43.79,0,0,0,96,188Zm124,0H160a43.71,43.71,0,0,0-20,4.83V88a20,20,0,0,1,20-20h60ZM164,96h32a12,12,0,0,1,0,24H164a12,12,0,0,1,0-24Zm44,52a12,12,0,0,1-12,12H164a12,12,0,0,1,0-24h32A12,12,0,0,1,208,148Z"}))],["duotone",i.createElement(i.Fragment,null,i.createElement("path",{d:"M232,56V200H160a32,32,0,0,0-32,32V88a32,32,0,0,1,32-32Z",opacity:"0.2"}),i.createElement("path",{d:"M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64ZM160,88h40a8,8,0,0,1,0,16H160a8,8,0,0,1,0-16Zm48,40a8,8,0,0,1-8,8H160a8,8,0,0,1,0-16h40A8,8,0,0,1,208,128Zm0,32a8,8,0,0,1-8,8H160a8,8,0,0,1,0-16h40A8,8,0,0,1,208,160Z"}))],["fill",i.createElement(i.Fragment,null,i.createElement("path",{d:"M232,48H168a32,32,0,0,0-32,32v87.73a8.17,8.17,0,0,1-7.47,8.25,8,8,0,0,1-8.53-8V80A32,32,0,0,0,88,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,23.94,7.9,7.9,0,0,0,5.12,7.55A8,8,0,0,0,136,232a24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM208,168H168.27a8.17,8.17,0,0,1-8.25-7.47,8,8,0,0,1,8-8.53h39.73a8.17,8.17,0,0,1,8.25,7.47A8,8,0,0,1,208,168Zm0-32H168.27a8.17,8.17,0,0,1-8.25-7.47,8,8,0,0,1,8-8.53h39.73a8.17,8.17,0,0,1,8.25,7.47A8,8,0,0,1,208,136Zm0-32H168.27A8.17,8.17,0,0,1,160,96.53,8,8,0,0,1,168,88h39.73A8.17,8.17,0,0,1,216,95.47,8,8,0,0,1,208,104Z"}))],["light",i.createElement(i.Fragment,null,i.createElement("path",{d:"M232,50H160a38,38,0,0,0-32,17.55A38,38,0,0,0,96,50H24a6,6,0,0,0-6,6V200a6,6,0,0,0,6,6H96a26,26,0,0,1,26,26,6,6,0,0,0,12,0,26,26,0,0,1,26-26h72a6,6,0,0,0,6-6V56A6,6,0,0,0,232,50ZM96,194H30V62H96a26,26,0,0,1,26,26V204.31A37.86,37.86,0,0,0,96,194Zm130,0H160a37.87,37.87,0,0,0-26,10.32V88a26,26,0,0,1,26-26h66ZM160,90h40a6,6,0,0,1,0,12H160a6,6,0,0,1,0-12Zm46,38a6,6,0,0,1-6,6H160a6,6,0,0,1,0-12h40A6,6,0,0,1,206,128Zm0,32a6,6,0,0,1-6,6H160a6,6,0,0,1,0-12h40A6,6,0,0,1,206,160Z"}))],["regular",i.createElement(i.Fragment,null,i.createElement("path",{d:"M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64ZM160,88h40a8,8,0,0,1,0,16H160a8,8,0,0,1,0-16Zm48,40a8,8,0,0,1-8,8H160a8,8,0,0,1,0-16h40A8,8,0,0,1,208,128Zm0,32a8,8,0,0,1-8,8H160a8,8,0,0,1,0-16h40A8,8,0,0,1,208,160Z"}))],["thin",i.createElement(i.Fragment,null,i.createElement("path",{d:"M232,52H160a36,36,0,0,0-32,19.54A36,36,0,0,0,96,52H24a4,4,0,0,0-4,4V200a4,4,0,0,0,4,4H96a28,28,0,0,1,28,28,4,4,0,0,0,8,0,28,28,0,0,1,28-28h72a4,4,0,0,0,4-4V56A4,4,0,0,0,232,52ZM96,196H28V60H96a28,28,0,0,1,28,28V209.4A35.94,35.94,0,0,0,96,196Zm132,0H160a35.94,35.94,0,0,0-28,13.41V88a28,28,0,0,1,28-28h68ZM160,92h40a4,4,0,0,1,0,8H160a4,4,0,0,1,0-8Zm44,36a4,4,0,0,1-4,4H160a4,4,0,0,1,0-8h40A4,4,0,0,1,204,128Zm0,32a4,4,0,0,1-4,4H160a4,4,0,0,1,0-8h40A4,4,0,0,1,204,160Z"}))]]);var Ot=Object.defineProperty,Pt=Object.defineProperties,Vt=Object.getOwnPropertyDescriptors,qe=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,Be=(t,s,l)=>s in t?Ot(t,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[s]=l,$t=(t,s)=>{for(var l in s||(s={}))Lt.call(s,l)&&Be(t,l,s[l]);if(qe)for(var l of qe(s))Tt.call(s,l)&&Be(t,l,s[l]);return t},It=(t,s)=>Pt(t,Vt(s));const it=o.forwardRef((t,s)=>i.createElement(oe,It($t({ref:s},t),{weights:Ht})));it.displayName="BookOpenText";const zt=new Map([["bold",i.createElement(i.Fragment,null,i.createElement("path",{d:"M248.49,71.51l-32-32a12,12,0,0,0-17,17L211,68h-3c-52,0-64.8,30.71-75.08,55.38-8.82,21.17-15.45,37.05-42.75,40.09a44,44,0,1,0,.28,24.08c43.34-3.87,55.07-32,64.63-54.93C164.9,109,172,92,208,92h3l-11.52,11.51a12,12,0,0,0,17,17l32-32A12,12,0,0,0,248.49,71.51ZM48,196a20,20,0,1,1,20-20A20,20,0,0,1,48,196Z"}))],["duotone",i.createElement(i.Fragment,null,i.createElement("path",{d:"M80,176a32,32,0,1,1-32-32A32,32,0,0,1,80,176Z",opacity:"0.2"}),i.createElement("path",{d:"M245.66,74.34l-32-32a8,8,0,0,0-11.32,11.32L220.69,72H208c-49.33,0-61.05,28.12-71.38,52.92-9.38,22.51-16.92,40.59-49.48,42.84a40,40,0,1,0,.1,16c43.26-2.65,54.34-29.15,64.14-52.69C161.41,107,169.33,88,208,88h12.69l-18.35,18.34a8,8,0,0,0,11.32,11.32l32-32A8,8,0,0,0,245.66,74.34ZM48,200a24,24,0,1,1,24-24A24,24,0,0,1,48,200Z"}))],["fill",i.createElement(i.Fragment,null,i.createElement("path",{d:"M245.66,85.66l-32,32a8,8,0,0,1-11.32-11.32L220.69,88H208c-38.67,0-46.59,19-56.62,43.08C141.05,155.88,129.33,184,80,184H79a32,32,0,1,1,0-16h1c38.67,0,46.59-19,56.62-43.08C147,100.12,158.67,72,208,72h12.69L202.34,53.66a8,8,0,0,1,11.32-11.32l32,32A8,8,0,0,1,245.66,85.66Z"}))],["light",i.createElement(i.Fragment,null,i.createElement("path",{d:"M244.24,75.76l-32-32a6,6,0,0,0-8.48,8.48L225.51,74H208c-48,0-59.44,27.46-69.54,51.69-9.43,22.64-17.66,42.33-53,44.16a38,38,0,1,0,.06,12c43.34-2.06,54.29-28.29,64-51.55C159.44,106.53,168,86,208,86h17.51l-21.75,21.76a6,6,0,1,0,8.48,8.48l32-32A6,6,0,0,0,244.24,75.76ZM48,202a26,26,0,1,1,26-26A26,26,0,0,1,48,202Z"}))],["regular",i.createElement(i.Fragment,null,i.createElement("path",{d:"M245.66,74.34l-32-32a8,8,0,0,0-11.32,11.32L220.69,72H208c-49.33,0-61.05,28.12-71.38,52.92-9.38,22.51-16.92,40.59-49.48,42.84a40,40,0,1,0,.1,16c43.26-2.65,54.34-29.15,64.14-52.69C161.41,107,169.33,88,208,88h12.69l-18.35,18.34a8,8,0,0,0,11.32,11.32l32-32A8,8,0,0,0,245.66,74.34ZM48,200a24,24,0,1,1,24-24A24,24,0,0,1,48,200Z"}))],["thin",i.createElement(i.Fragment,null,i.createElement("path",{d:"M242.83,77.17l-32-32a4,4,0,0,0-5.66,5.66L230.34,76H208c-46.67,0-57.84,26.81-67.69,50.46-9.46,22.69-18.4,44.16-56.55,45.48a36,36,0,1,0,0,8c43.49-1.42,54.33-27.39,63.91-50.39C157.45,106.12,166.67,84,208,84h22.34l-25.17,25.17a4,4,0,0,0,5.66,5.66l32-32A4,4,0,0,0,242.83,77.17ZM48,204a28,28,0,1,1,28-28A28,28,0,0,1,48,204Z"}))]]);var Rt=Object.defineProperty,Dt=Object.defineProperties,qt=Object.getOwnPropertyDescriptors,Qe=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable,Ue=(t,s,l)=>s in t?Rt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[s]=l,Ut=(t,s)=>{for(var l in s||(s={}))Bt.call(s,l)&&Ue(t,l,s[l]);if(Qe)for(var l of Qe(s))Qt.call(s,l)&&Ue(t,l,s[l]);return t},Wt=(t,s)=>Dt(t,qt(s));const ee=o.forwardRef((t,s)=>i.createElement(oe,Wt(Ut({ref:s},t),{weights:zt})));ee.displayName="FlowArrow";const Gt=new Map([["bold",i.createElement(i.Fragment,null,i.createElement("path",{d:"M225.6,62.64l-88-48.17a19.91,19.91,0,0,0-19.2,0l-88,48.17A20,20,0,0,0,20,80.19v95.62a20,20,0,0,0,10.4,17.55l88,48.17a19.89,19.89,0,0,0,19.2,0l88-48.17A20,20,0,0,0,236,175.81V80.19A20,20,0,0,0,225.6,62.64ZM128,36.57,200,76,178.57,87.73l-72-39.42Zm0,78.83L56,76,81.56,62l72,39.41ZM44,96.79l72,39.4v76.67L44,173.44Zm96,116.07V136.19l24-13.13V152a12,12,0,0,0,24,0V109.92l24-13.13v76.65Z"}))],["duotone",i.createElement(i.Fragment,null,i.createElement("path",{d:"M128,129.09V232a8,8,0,0,1-3.84-1l-88-48.18a8,8,0,0,1-4.16-7V80.18a8,8,0,0,1,.7-3.25Z",opacity:"0.2"}),i.createElement("path",{d:"M223.68,66.15,135.68,18a15.88,15.88,0,0,0-15.36,0l-88,48.17a16,16,0,0,0-8.32,14v95.64a16,16,0,0,0,8.32,14l88,48.17a15.88,15.88,0,0,0,15.36,0l88-48.17a16,16,0,0,0,8.32-14V80.18A16,16,0,0,0,223.68,66.15ZM128,32l80.34,44-29.77,16.3-80.35-44ZM128,120,47.66,76l33.9-18.56,80.34,44ZM40,90l80,43.78v85.79L40,175.82Zm176,85.78h0l-80,43.79V133.82l32-17.51V152a8,8,0,0,0,16,0V107.55L216,90v85.77Z"}))],["fill",i.createElement(i.Fragment,null,i.createElement("path",{d:"M223.68,66.15,135.68,18a15.88,15.88,0,0,0-15.36,0l-88,48.17a16,16,0,0,0-8.32,14v95.64a16,16,0,0,0,8.32,14l88,48.17a15.88,15.88,0,0,0,15.36,0l88-48.17a16,16,0,0,0,8.32-14V80.18A16,16,0,0,0,223.68,66.15ZM128,32l80.35,44L178.57,92.29l-80.35-44Zm0,88L47.65,76,81.56,57.43l80.35,44Zm88,55.85h0l-80,43.79V133.83l32-17.51V152a8,8,0,0,0,16,0V107.56l32-17.51v85.76Z"}))],["light",i.createElement(i.Fragment,null,i.createElement("path",{d:"M222.72,67.91l-88-48.18a13.9,13.9,0,0,0-13.44,0l-88,48.18A14,14,0,0,0,26,80.18v95.64a14,14,0,0,0,7.28,12.27l88,48.18a13.92,13.92,0,0,0,13.44,0l88-48.18A14,14,0,0,0,230,175.82V80.18A14,14,0,0,0,222.72,67.91ZM127,30.25a2,2,0,0,1,1.92,0L212.51,76,178.57,94.57,94.05,48.31ZM122,223,39,177.57a2,2,0,0,1-1-1.75V86.66l84,46ZM43.49,76,81.56,55.15l84.51,46.26L128,122.24ZM218,175.82a2,2,0,0,1-1,1.75h0L134,223V132.64l36-19.71V152a6,6,0,0,0,12,0V106.37l36-19.71Z"}))],["regular",i.createElement(i.Fragment,null,i.createElement("path",{d:"M223.68,66.15,135.68,18a15.88,15.88,0,0,0-15.36,0l-88,48.17a16,16,0,0,0-8.32,14v95.64a16,16,0,0,0,8.32,14l88,48.17a15.88,15.88,0,0,0,15.36,0l88-48.17a16,16,0,0,0,8.32-14V80.18A16,16,0,0,0,223.68,66.15ZM128,32l80.34,44-29.77,16.3-80.35-44ZM128,120,47.66,76l33.9-18.56,80.34,44ZM40,90l80,43.78v85.79L40,175.82Zm176,85.78h0l-80,43.79V133.82l32-17.51V152a8,8,0,0,0,16,0V107.55L216,90v85.77Z"}))],["thin",i.createElement(i.Fragment,null,i.createElement("path",{d:"M221.76,69.66l-88-48.18a12,12,0,0,0-11.52,0l-88,48.18A12,12,0,0,0,28,80.18v95.64a12,12,0,0,0,6.24,10.52l88,48.18a11.95,11.95,0,0,0,11.52,0l88-48.18A12,12,0,0,0,228,175.82V80.18A12,12,0,0,0,221.76,69.66ZM126.08,28.5a3.94,3.94,0,0,1,3.84,0L216.67,76,178.5,96.89a4,4,0,0,0-.58-.4l-88-48.18Zm1.92,96L39.33,76,81.56,52.87l88.67,48.54Zm-89.92,54.8a4,4,0,0,1-2.08-3.5V83.29l88,48.16v94.91Zm179.84,0h0l-85.92,47V131.45l40-21.89V152a4,4,0,0,0,8,0V105.18l40-21.89v92.53A4,4,0,0,1,217.92,179.32Z"}))]]);var Jt=Object.defineProperty,Kt=Object.defineProperties,Xt=Object.getOwnPropertyDescriptors,We=Object.getOwnPropertySymbols,Yt=Object.prototype.hasOwnProperty,es=Object.prototype.propertyIsEnumerable,Ge=(t,s,l)=>s in t?Jt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[s]=l,ts=(t,s)=>{for(var l in s||(s={}))Yt.call(s,l)&&Ge(t,l,s[l]);if(We)for(var l of We(s))es.call(s,l)&&Ge(t,l,s[l]);return t},ss=(t,s)=>Kt(t,Xt(s));const ce=o.forwardRef((t,s)=>i.createElement(oe,ss(ts({ref:s},t),{weights:Gt})));ce.displayName="Package";function Je({skills:t=[],selectedSkill:s=null,handleClick:l=null}){return t.length===0?e.jsxs("div",{className:"text-theme-text-secondary text-center text-xs flex flex-col gap-y-2",children:[e.jsx("p",{children:"No imported skills found"}),e.jsxs("p",{children:["Learn about agent skills in the"," ",e.jsx("a",{href:"https://docs.anythingllm.com/agent/custom/developer-guide",target:"_blank",className:"text-theme-text-secondary underline hover:text-cta-button",rel:"noreferrer",children:"AnythingLLM Agent Docs"}),"."]})]}):e.jsx("div",{className:"bg-theme-bg-secondary text-white rounded-xl w-full md:min-w-[360px]",children:t.map((a,r)=>e.jsxs("div",{className:`py-3 px-4 flex items-center justify-between ${r===0?"rounded-t-xl":""} ${r===Object.keys(t).length-1?"rounded-b-xl":"border-b border-white/10"} cursor-pointer transition-all duration-300 hover:bg-theme-bg-primary ${s===a.hubId?"bg-theme-bg-primary":""}`,onClick:()=>l==null?void 0:l({...a,imported:!0}),children:[e.jsx("div",{className:"text-sm font-light",children:st(a.name)}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("div",{className:"text-sm text-theme-text-secondary font-medium",children:a.active?"On":"Off"}),e.jsx(de,{size:14,weight:"bold",className:"text-theme-text-secondary"})]})]},a.hubId))})}function Ke(t){var s,l;return!t||((l=(s=t.constructor)==null?void 0:s.call)==null?void 0:l.call(s).toString())!=="[object Object]"?{}:Object.entries(t).reduce((a,[r,c])=>{var n;return{...a,[r]:c.hasOwnProperty("value")?c.value:((n=c==null?void 0:c.input)==null?void 0:n.default)||""}},{})}function le({selectedSkill:t,setImportedSkills:s}){const[l,a]=o.useState(t),[r,c]=o.useState(!1),[n,m]=o.useState(Ke(t==null?void 0:t.setup_args)),g=(t==null?void 0:t.setup_args)&&Object.keys(t.setup_args).length>0;async function u(){const f={...t,active:!l.active};await C.experimentalFeatures.agentPlugins.updatePluginConfig(l.hubId,{active:!l.active}),s(x=>x.map(b=>b.hubId===l.hubId?f:b)),a(f),w(`Skill ${f.active?"activated":"deactivated"}.`,"success",{clear:!0})}async function F(f){f.preventDefault();const x=[],b={...l};for(const[N,S]of Object.entries(n)){const E=l.setup_args[N];if(E.required&&!S){x.push(`${N} is required to have a value.`);continue}if(typeof S!==E.type){x.push(`${N} must be of type ${E.type}.`);continue}b.setup_args[N].value=S}if(x.length>0){x.forEach(N=>w(N,"error"));return}await C.experimentalFeatures.agentPlugins.updatePluginConfig(l.hubId,b),a(b),s(N=>N.map(S=>S.hubId===l.hubId?b:S)),w("Skill config updated successfully.","success"),c(!1)}return o.useEffect(()=>{c(JSON.stringify(n)!==JSON.stringify(Ke(t.setup_args)))},[n]),e.jsx(e.Fragment,{children:e.jsx("div",{className:"p-2",children:e.jsxs("div",{className:"flex flex-col gap-y-[18px] max-w-[500px]",children:[e.jsxs("div",{className:"flex w-full justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(ie,{size:24,weight:"bold",className:"text-white"}),e.jsx("label",{htmlFor:"name",className:"text-white text-md font-bold",children:st(l.name)})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(te,{size:"lg",enabled:l.active,onChange:u}),e.jsx(ls,{config:l,setImportedSkills:s})]})]}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:[l.description," by"," ",e.jsx("a",{href:l.author_url,target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline",children:l.author})]}),g?e.jsxs("div",{className:"flex flex-col gap-y-2",children:[Object.entries(l.setup_args).map(([f,x])=>{var b,N,S,E,I;return e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsx("label",{htmlFor:f,className:"text-white text-sm font-bold",children:f}),e.jsx("input",{type:((b=x==null?void 0:x.input)==null?void 0:b.type)||"text",required:(N=x==null?void 0:x.input)==null?void 0:N.required,defaultValue:x.hasOwnProperty("value")?x.value:((S=x==null?void 0:x.input)==null?void 0:S.default)||"",onChange:Q=>m({...n,[f]:Q.target.value}),placeholder:((E=x==null?void 0:x.input)==null?void 0:E.placeholder)||"",className:"border-solid bg-transparent border border-white light:border-black rounded-md p-2 text-white text-sm"}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:(I=x==null?void 0:x.input)==null?void 0:I.hint})]},f)}),r&&e.jsx("button",{onClick:F,type:"button",className:"bg-blue-500 text-white light:text-white rounded-md p-2",children:"Save"})]}):e.jsx("p",{className:"text-white text-opacity-60 text-sm font-medium py-1.5",children:"There are no options to modify for this skill."})]})})})}function ls({config:t,setImportedSkills:s}){const[l,a]=o.useState(!1),r=o.useRef(null);async function c(){if(!window.confirm("Are you sure you want to delete this skill? This action cannot be undone."))return;await C.experimentalFeatures.agentPlugins.deletePlugin(t.hubId)?(s(m=>m.filter(g=>g.hubId!==t.hubId)),w("Skill deleted successfully.","success"),a(!1)):w("Failed to delete skill.","error")}return o.useEffect(()=>{const n=m=>{r.current&&!r.current.contains(m.target)&&a(!1)};return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[]),t.hubId?e.jsxs("div",{className:"relative",ref:r,children:[e.jsx("button",{type:"button",onClick:()=>a(!l),className:"p-1.5 rounded-lg text-white hover:bg-theme-action-menu-item-hover transition-colors duration-300",children:e.jsx(me,{className:"h-5 w-5",weight:"bold"})}),l&&e.jsx("div",{className:"absolute w-[100px] -top-1 left-7 mt-1 border-[1.5px] border-white/40 rounded-lg bg-theme-action-menu-bg flex flex-col shadow-[0_4px_14px_rgba(0,0,0,0.25)] text-white z-99 md:z-10",children:e.jsx("button",{type:"button",onClick:c,className:"border-none flex items-center rounded-lg gap-x-2 hover:bg-theme-action-menu-item-hover py-1.5 px-2 transition-colors duration-200 w-full text-left",children:e.jsx("span",{className:"text-sm",children:"Delete Skill"})})})]}):null}function Xe({flows:t=[],selectedFlow:s,handleClick:l,activeFlowIds:a=[]}){return t.length===0?e.jsxs("div",{className:"text-theme-text-secondary text-center text-xs flex flex-col gap-y-2",children:[e.jsx("p",{children:"No agent flows found"}),e.jsx("a",{href:"https://docs.anythingllm.com/agent-flows/getting-started",target:"_blank",className:"text-theme-text-secondary underline hover:text-cta-button",rel:"noreferrer",children:"Learn more about Agent Flows."})]}):e.jsx("div",{className:"bg-theme-bg-secondary text-white rounded-xl w-full md:min-w-[360px]",children:t.map((r,c)=>e.jsxs("div",{className:`py-3 px-4 flex items-center justify-between ${c===0?"rounded-t-xl":""} ${c===t.length-1?"rounded-b-xl":"border-b border-white/10"} cursor-pointer transition-all duration-300 hover:bg-theme-bg-primary ${(s==null?void 0:s.uuid)===r.uuid?"bg-white/10 light:bg-theme-bg-sidebar":""}`,onClick:()=>l==null?void 0:l(r),children:[e.jsx("div",{className:"text-sm font-light",children:r.name}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("div",{className:"text-sm text-theme-text-secondary font-medium",children:a.includes(r.uuid)?"On":"Off"}),e.jsx(de,{size:14,weight:"bold",className:"text-theme-text-secondary"})]})]},r.uuid))})}function ns({flow:t,onDelete:s}){const[l,a]=o.useState(!1),r=o.useRef(null),c=gt();async function n(){if(a(!1),!window.confirm("Are you sure you want to delete this flow? This action cannot be undone."))return;const{success:m,error:g}=await ue.deleteFlow(t.uuid);m?(w("Flow deleted successfully.","success"),s(t.uuid)):w(g||"Failed to delete flow.","error")}return o.useEffect(()=>{if(!l)return;const m=g=>{r.current&&!r.current.contains(g.target)&&a(!1)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[l]),e.jsxs("div",{className:"relative",ref:r,children:[e.jsx("button",{type:"button",onClick:()=>a(!l),className:"p-1.5 rounded-lg text-white hover:bg-theme-action-menu-item-hover transition-colors duration-300",children:e.jsx(me,{className:"h-5 w-5",weight:"bold"})}),l&&e.jsxs("div",{className:"absolute min-w-[140px] top-full right-0 mt-1 border-[1.5px] border-white/40 rounded-lg bg-theme-action-menu-bg flex flex-col shadow-[0_4px_14px_rgba(0,0,0,0.25)] text-white z-99 md:z-10",children:[e.jsx("button",{type:"button",onClick:()=>c(re.agents.editAgent(t.uuid)),className:"border-none flex items-center rounded-lg gap-x-2 hover:bg-theme-action-menu-item-hover py-1.5 px-2 transition-colors duration-200 w-full text-left",children:e.jsx("span",{className:"text-sm whitespace-nowrap",children:"Edit Flow"})}),e.jsx("button",{type:"button",onClick:n,className:"border-none flex items-center rounded-lg gap-x-2 hover:bg-theme-action-menu-item-hover py-1.5 px-2 transition-colors duration-200 w-full text-left",children:e.jsx("span",{className:"text-sm whitespace-nowrap",children:"Delete Flow"})})]})]})}function ne({flow:t,toggleFlow:s,enabled:l,onDelete:a}){const r=async()=>{try{const{success:c,error:n}=await ue.toggleFlow(t.uuid,!l);if(!c)throw new Error(n);s(t.uuid)}catch(c){console.error("Failed to toggle flow:",c),w("Failed to toggle flow","error",{clear:!0})}};return e.jsx(e.Fragment,{children:e.jsx("div",{className:"p-2",children:e.jsxs("div",{className:"flex flex-col gap-y-[18px] max-w-[500px]",children:[e.jsxs("div",{className:"flex w-full justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(ee,{size:24,weight:"bold",className:"text-white"}),e.jsx("label",{htmlFor:"name",className:"text-white text-md font-bold",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(te,{size:"lg",enabled:l,onChange:r}),e.jsx(ns,{flow:t,onDelete:a})]})]}),e.jsx("p",{className:"whitespace-pre-wrap text-white text-opacity-60 text-xs font-medium py-1.5",children:t.description||"No description provided"})]})})})}const ct="/mcp-logo.svg";function Ye({setMcpServers:t,setSelectedMcpServer:s,children:l}){const{t:a}=_(),[r,c]=o.useState(!1);o.useEffect(()=>{async function m(){c(!0);const{servers:g=[]}=await J.listServers();t(g),c(!1)}m()},[]);const n=()=>{window.confirm("Are you sure you want to refresh the list of MCP servers? This will restart all MCP servers and reload their tools.")&&(c(!0),J.forceReload().then(({servers:m=[]})=>{s(null),t(m)}).catch(m=>{console.error(m),w("Failed to refresh MCP servers.","error",{clear:!0})}).finally(()=>{c(!1)}))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-theme-text-primary flex items-center justify-between gap-x-2 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("img",{src:ct,className:"w-6 h-6 light:invert",alt:"MCP Logo"}),e.jsx("p",{className:"text-lg font-medium",children:a("agent.mcp.title")})]}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("a",{href:"https://docs.anythingllm.com/mcp-compatibility/overview",target:"_blank",rel:"noopener noreferrer",className:"border-none text-theme-text-secondary hover:text-cta-button",children:e.jsx(it,{size:16})}),e.jsxs("button",{type:"button",onClick:n,disabled:r,className:"border-none text-theme-text-secondary hover:text-cta-button flex items-center gap-x-1",children:[e.jsx(ft,{size:16,className:r?"animate-spin":""}),e.jsx("p",{className:"text-sm",children:r?`${a("common.loading")}...`:a("common.refresh")})]})]})]}),l({loadingMcpServers:r})]})}function et({isLoading:t=!1,servers:s=[],selectedServer:l,handleClick:a}){const{t:r}=_();return t?e.jsxs("div",{className:"text-theme-text-secondary text-center text-xs flex flex-col gap-y-2",children:[e.jsxs("p",{children:[r("agent.mcp.loading-from-config"),"..."]}),e.jsx("a",{href:"https://docs.anythingllm.com/mcp-compatibility/overview",target:"_blank",rel:"noopener noreferrer",className:"text-theme-text-secondary underline hover:text-cta-button",children:r("agent.mcp.learn-more")})]}):s.length===0?e.jsxs("div",{className:"text-theme-text-secondary text-center text-xs flex flex-col gap-y-2",children:[e.jsx("p",{children:r("agent.mcp.no-servers-found")}),e.jsx("a",{href:"https://docs.anythingllm.com/mcp-compatibility/overview",target:"_blank",rel:"noopener noreferrer",className:"text-theme-text-secondary underline hover:text-cta-button",children:r("agent.mcp.learn-more")})]}):e.jsxs("div",{className:"bg-theme-bg-secondary text-white rounded-xl w-full md:min-w-[360px]",children:[s.map((c,n)=>e.jsx(as,{server:c,isFirst:n===0,isLast:n===s.length-1,isSelected:(l==null?void 0:l.name)===c.name,handleClick:()=>a==null?void 0:a(c)},c.name)),e.jsx(lt,{id:"mcp-server-warning",place:"bottom",delayShow:300,className:"tooltip !text-xs",content:r("agent.mcp.tool-warning")})]})}function as({server:t,isFirst:s,isLast:l,isSelected:a,handleClick:r}){var F,f;const{t:c}=_(),n=((f=(F=t.config)==null?void 0:F.anythingllm)==null?void 0:f.suppressedTools)||[],g=t.tools.length-n.length>10,u=t.running;return e.jsxs("div",{className:`py-3 px-4 flex items-center justify-between ${s?"rounded-t-xl":""} ${l?"rounded-b-xl":"border-b border-white/10"} cursor-pointer transition-all duration-300 hover:bg-theme-bg-primary ${a?"bg-white/10 light:bg-theme-bg-sidebar":""}`,onClick:r,children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-sm font-light",children:[g&&e.jsx(nt,{"data-tooltip-id":"mcp-server-warning",className:"h-4 w-4 text-yellow-500"}),at(t.name.replace(/[_-]/g," "))]}),e.jsx("div",{className:"flex items-center gap-x-2",children:e.jsx("div",{className:`text-sm text-theme-text-secondary font-medium ${u?"text-green-500":"text-red-500"}`,children:c(u?"common.on":"common.stopped")})})]})}function rs({server:t,toggleServer:s,onDelete:l}){const{t:a}=_(),[r,c]=o.useState(!1),[n,m]=o.useState(t.running),g=o.useRef(null);async function u(){if(!window.confirm("Are you sure you want to delete this MCP server? It will be removed from your config file and you will need to add it back manually."))return;const{success:f,error:x}=await J.deleteServer(t.name);f?(w("MCP server deleted successfully.","success"),l(t.name)):w(x||"Failed to delete MCP server.","error")}async function F(){if(!window.confirm(n?"Are you sure you want to stop this MCP server? It will be started automatically when you next start the server.":"Are you sure you want to start this MCP server? It will be started automatically when you next start the server."))return;const{success:f,error:x}=await J.toggleServer(t.name);if(f){const b=!n;m(b),s(t.name),w(`MCP server ${t.name} ${b?"started":"stopped"} successfully.`,"success",{clear:!0})}else w(x||"Failed to toggle MCP server.","error",{clear:!0})}return o.useEffect(()=>{const f=x=>{g.current&&!g.current.contains(x.target)&&c(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs("div",{className:"relative",ref:g,children:[e.jsx("button",{type:"button",onClick:()=>c(!r),className:"p-1.5 rounded-lg text-white hover:bg-theme-action-menu-item-hover transition-colors duration-300",children:e.jsx(me,{className:"h-5 w-5",weight:"bold"})}),r&&e.jsxs("div",{className:"absolute w-[150px] top-1 left-7 mt-1 border-[1.5px] border-white/40 rounded-lg bg-theme-action-menu-bg flex flex-col shadow-[0_4px_14px_rgba(0,0,0,0.25)] text-white z-99 md:z-10",children:[e.jsx("button",{type:"button",onClick:F,className:"border-none flex items-center rounded-lg gap-x-2 hover:bg-theme-action-menu-item-hover py-1.5 px-2 transition-colors duration-200 w-full text-left",children:e.jsx("span",{className:"text-sm",children:a(n?"agent.mcp.stop-server":"agent.mcp.start-server")})}),e.jsx("button",{type:"button",onClick:u,className:"border-none flex items-center rounded-lg gap-x-2 hover:bg-theme-action-menu-item-hover py-1.5 px-2 transition-colors duration-200 w-full text-left",children:e.jsx("span",{className:"text-sm",children:a("agent.mcp.delete-server")})})]})]})}function ae({server:t,toggleServer:s,onDelete:l,onToggleTool:a}){var m,g;const{t:r}=_(),c=((g=(m=t.config)==null?void 0:m.anythingllm)==null?void 0:g.suppressedTools)||[],n=t.tools.filter(u=>!c.includes(u.name)).length;return e.jsx(e.Fragment,{children:e.jsx("div",{className:"p-2",children:e.jsxs("div",{className:"flex flex-col gap-y-[18px] max-w-[800px]",children:[e.jsx(is,{server:t,enabledToolCount:n}),e.jsxs("div",{className:"flex w-full justify-between",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("img",{src:ct,className:"w-6 h-6 light:invert"}),e.jsx("label",{htmlFor:"name",className:"text-white text-md font-bold",children:at(t.name.replace(/[_-]/g," "))}),t.tools.length>0&&e.jsxs("p",{className:"text-theme-text-secondary text-sm",children:[n,"/",t.tools.length," ",r("agent.mcp.tools-enabled")]})]}),e.jsx(rs,{server:t,toggleServer:s,onDelete:l},t.name)]}),e.jsx(cs,{config:t.config}),e.jsx(os,{server:t}),e.jsx(ds,{serverName:t.name,tools:t.tools,suppressedTools:c,onToggleTool:a})]})})})}function is({server:t,enabledToolCount:s}){return t.tools.length<=10||s<=10?null:e.jsxs("div",{className:"flex items-center gap-x-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[e.jsx(nt,{className:"h-5 w-5 text-yellow-500 shrink-0",weight:"fill"}),e.jsx("p",{className:"text-yellow-500 text-sm",children:e.jsx(Zt,{i18nKey:"agent.mcp.tool-count-warning",values:{count:s},components:{b:e.jsx("b",{}),br:e.jsx("br",{})}})})]})}function cs({config:t=null}){const{t:s}=_();return t?e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"text-theme-text-primary text-sm",children:s("agent.mcp.startup-command")}),e.jsxs("div",{className:"bg-theme-bg-primary rounded-lg p-4",children:[e.jsxs("p",{className:"text-theme-text-secondary text-sm text-left",children:[e.jsxs("span",{className:"font-bold",children:[s("agent.mcp.command"),":"]})," ",t.command]}),e.jsxs("p",{className:"text-theme-text-secondary text-sm text-left",children:[e.jsxs("span",{className:"font-bold",children:[s("agent.mcp.arguments"),":"]})," ",t.args?t.args.join(" "):s("common.none")]})]})]}):null}function os({server:t}){const{t:s}=_();return t.running||!t.error?null:e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"text-theme-text-primary text-sm",children:s("agent.mcp.not-running-warning")}),e.jsx("div",{className:"bg-theme-bg-primary rounded-lg p-4",children:e.jsx("p",{className:"text-red-500 text-sm font-mono",children:t.error})})]})}function ds({serverName:t,tools:s=[],suppressedTools:l=[],onToggleTool:a}){return s.length===0?null:e.jsx("div",{className:"flex flex-col gap-y-2",children:e.jsx("div",{className:"flex flex-col gap-y-2",children:s.map(r=>e.jsx(ms,{serverName:t,tool:r,enabled:!l.includes(r.name),onToggle:a},r.name))})})}function ms({serverName:t,tool:s,enabled:l,onToggle:a}){var m;const{t:r}=_(),[c,n]=o.useState(!1);return e.jsxs("button",{type:"button",onClick:()=>n(!c),className:`flex flex-col gap-y-2 px-4 py-2 rounded-lg border ${l?"border-theme-text-secondary":"border-theme-text-secondary/50 opacity-60"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-x-2 min-w-0 flex-1",children:[e.jsx(pt,{size:"md",enabled:l,onChange:g=>a==null?void 0:a(t,s.name,g)}),e.jsx("p",{className:"text-theme-text-primary font-mono font-bold text-sm shrink-0",children:s.name}),!c&&e.jsx("p",{className:"text-theme-text-secondary text-sm truncate",children:s.description})]}),e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx("div",{className:`border-none text-theme-text-secondary hover:text-cta-button transition-transform duration-200 ${c?"rotate-180":""}`,children:e.jsx(bt,{size:16})})})]}),c&&e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("div",{className:"flex flex-col gap-y-2",children:e.jsx("p",{className:"text-theme-text-secondary text-sm text-left",children:s.description})}),e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"text-theme-text-primary text-sm text-left",children:r("agent.mcp.tool-call-arguments")}),e.jsx("div",{className:"flex flex-col gap-y-2",children:Object.entries(((m=s.inputSchema)==null?void 0:m.properties)||{}).map(([g,u])=>{var F,f;return e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsxs("p",{className:"text-theme-text-secondary text-sm text-left font-bold",children:[g,((f=(F=s.inputSchema)==null?void 0:F.required)==null?void 0:f.includes(g))&&e.jsx("sup",{className:"text-red-500",children:"*"})]}),e.jsx("p",{className:"text-theme-text-secondary text-sm text-left",children:u.type})]},g)})})]})]})]})}function xs(){const{t}=_(),[s,l]=o.useState(10),[a,r]=o.useState(!0),c=o.useMemo(()=>xe(async n=>{await C.updateSystem({AgentSkillMaxToolCalls:n.toString()})},800),[]);return o.useEffect(()=>{C.keys().then(n=>{l(parseInt(n.AgentSkillMaxToolCalls))}).finally(()=>{r(!1)})},[]),o.useEffect(()=>()=>c.cancel(),[c]),e.jsx("div",{className:"flex flex-col gap-y-2 mt-4",children:e.jsxs("div",{className:"flex items-center gap-x-4 mt-2",children:[e.jsxs("div",{className:"flex flex-col gap-y-1 flex-1",children:[e.jsx("label",{className:"block text-md font-medium text-white",children:t("agent.settings.max-tool-calls.title")}),e.jsx("p",{className:"text-xs text-white/60",children:t("agent.settings.max-tool-calls.description")})]}),e.jsx("input",{type:"number",name:"agentSkillMaxToolCalls",min:1,value:s,disabled:a,onChange:n=>{n.target.value<1||(c(n.target.value),l(parseInt(n.target.value)))},onWheel:n=>n.target.blur(),className:"border border-white/10 bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-[80px] p-2.5 text-center",placeholder:"10",autoComplete:"off"})]})})}function us(){const{t}=_(),[s,l]=o.useState(!1),[a,r]=o.useState(3),[c,n]=o.useState(!0),m=o.useMemo(()=>xe(async u=>{await G.updateSystemPreferences({agent_clarifying_questions_max_per_turn:String(u)})},800),[]);o.useEffect(()=>{C.keys().then(u=>{l(!!u.AgentClarifyingQuestionsEnabled),r(parseInt(u.AgentClarifyingQuestionsMaxPerTurn)||3)}).finally(()=>n(!1))},[]),o.useEffect(()=>()=>{m.cancel()},[m]);async function g(u){l(u),await G.updateSystemPreferences({agent_clarifying_questions_enabled:String(u)})}return e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsx("div",{className:"flex items-center gap-x-1",children:e.jsxs("label",{className:"block text-md font-medium text-white flex items-center gap-x-1",children:[t("agent.settings.clarifying-questions.title")," ",e.jsx("i",{className:"ml-1 text-xs text-white pl-2 bg-blue-500/40 rounded-md px-2 py-0.5",children:t("agent.settings.clarifying-questions.beta-badge")})]})}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx("p",{className:"text-xs text-white/60",children:t("agent.settings.clarifying-questions.description")}),c?e.jsx(rt,{size:16,className:"shrink-0 animate-spin text-theme-text-primary"}):e.jsx(te,{size:"lg",name:"agentClarifyingQuestionsEnabled",enabled:s,onChange:g})]}),s&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1 flex-1",children:[e.jsx("label",{className:"block text-md font-medium text-white",children:t("agent.settings.clarifying-questions.max-per-turn.title")}),e.jsx("p",{className:"text-xs text-white/60",children:t("agent.settings.clarifying-questions.max-per-turn.description")})]}),e.jsx("input",{type:"number",name:"agentClarifyingQuestionsMaxPerTurn",min:1,value:a,onChange:u=>{u.target.value<1||(m(u.target.value),r(parseInt(u.target.value)))},onWheel:u=>u.target.blur(),className:"border border-white/10 bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-[80px] p-2.5 text-center",placeholder:"3",autoComplete:"off"})]})})]})}function hs(){const{t}=_(),[s,l]=o.useState(!1),[a,r]=o.useState(15),[c,n]=o.useState(!0),m=o.useMemo(()=>xe(async u=>{await C.updateSystem({AgentSkillRerankerTopN:u.toString()})},800),[]);o.useEffect(()=>{C.keys().then(u=>{l(u.AgentSkillRerankerEnabled),r(parseInt(u.AgentSkillRerankerTopN))}).finally(()=>{n(!1)})},[]),o.useEffect(()=>()=>m.cancel(),[m]);async function g(u){l(u),await C.updateSystem({AgentSkillRerankerEnabled:String(u)})}return e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsx("div",{className:"flex items-center gap-x-1",children:e.jsxs("label",{className:"block text-md font-medium text-white flex items-center gap-x-1",children:[t("agent.settings.intelligent-skill-selection.title")," ",e.jsx("i",{className:"ml-1 text-xs text-white pl-2 bg-blue-500/40 rounded-md px-2 py-0.5",children:t("agent.settings.intelligent-skill-selection.beta-badge")})]})}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx("p",{className:"text-xs text-white/60",children:t("agent.settings.intelligent-skill-selection.description")}),c?e.jsx(rt,{size:16,className:"shrink-0 animate-spin text-theme-text-primary"}):e.jsx(te,{size:"lg",name:"agentSkillRerankerEnabled",enabled:s,onChange:g})]}),s&&e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1 flex-1",children:[e.jsx("label",{className:"block text-md font-medium text-white",children:t("agent.settings.intelligent-skill-selection.max-tools.title")}),e.jsx("p",{className:"text-xs text-white/60",children:t("agent.settings.intelligent-skill-selection.max-tools.description")})]}),e.jsx("input",{type:"number",name:"agentSkillRerankerTopN",min:10,value:a,onChange:u=>{u.target.value<10||(m(u.target.value),r(parseInt(u.target.value)))},onWheel:u=>u.target.blur(),className:"border border-white/10 bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-[80px] p-2.5 text-center",placeholder:"15",autoComplete:"off"})]})]})}function gs(){const{isOpen:t,openModal:s,closeModal:l}=jt();return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:s,className:"w-10 h-10 flex items-center justify-center light:border-black/10 light:border-solid border-none light:!border rounded-lg transition-colors outline-none bg-transparent hover:bg-theme-bg-secondary",children:e.jsx(kt,{size:24,className:"text-theme-text-secondary"})}),e.jsx(fs,{isOpen:t,closeModal:l})]})}function fs({isOpen:t,closeModal:s}){const{t:l}=_();return t?e.jsx(yt,{isOpen:t,children:e.jsxs("div",{className:"w-[500px] bg-theme-bg-sidebar px-6 py-4 rounded-lg flex flex-col items-center justify-between relative shadow-lg border border-white/10",children:[e.jsxs("div",{className:"w-full flex items-center justify-between",children:[e.jsx("div",{className:"text-white text-left font-medium text-lg",children:l("agent.settings.title")}),e.jsx("button",{onClick:s,className:"text-white opacity-60 hover:text-white hover:opacity-100 border-none outline-none",children:e.jsx(vt,{size:20})})]}),e.jsx("div",{className:"flex flex-col w-full",children:e.jsxs("div",{className:"flex flex-col gap-y-5 w-full",children:[e.jsx(xs,{}),e.jsx("div",{className:"border-b border-white/10 h-[1px] w-full"}),e.jsx(hs,{}),e.jsx("div",{className:"border-b border-white/10 h-[1px] w-full"}),e.jsx(us,{})]})})]})}):null}const ps=["agentSkillRerankerEnabled","agentSkillRerankerTopN","agentSkillMaxToolCalls","agentClarifyingQuestionsEnabled","agentClarifyingQuestionsMaxPerTurn"];function Hs(){var Me,Ce,Ee,_e,Fe,Ze,He,Oe,Pe,Ve,Le,Te,$e,Ie,ze;const{t}=_(),s=o.useRef(null),[l,a]=o.useState(!1),[r,c]=o.useState({}),[n,m]=o.useState(""),[g,u]=o.useState(!0),[F,f]=o.useState(!1),[x,b]=o.useState([]),[N,S]=o.useState([]),[E,I]=o.useState([]),[Q,he]=o.useState([]),[H,U]=o.useState(null),[z,se]=o.useState([]),[ge,W]=o.useState([]),[T,P]=o.useState(null),[ot,dt]=o.useState(!1),[mt,xt]=o.useState(!1),j=At(t),ut=Mt(t,{fileSystemAgentAvailable:ot,createFilesAgentAvailable:mt}),ht=Ct(t),fe=(r==null?void 0:r.MultiUserMode)??!1,pe=([d,h])=>h.mode?!(h.mode.includes("singleUserOnly")&&fe||h.mode.includes("multiUserOnly")&&!fe):!0,y=Object.fromEntries(Object.entries(ut).filter(pe)),O=Object.fromEntries(Object.entries(ht).filter(pe));o.useEffect(()=>{const d=h=>{l&&(h.preventDefault(),h.returnValue="")};return window.addEventListener("beforeunload",d),()=>{window.removeEventListener("beforeunload",d)}},[l]),o.useEffect(()=>{async function d(){var M,V,q;const[h,p,v,$,D]=await Promise.all([C.keys(),G.systemPreferencesByFields(["disabled_agent_skills","default_agent_skills","imported_agent_skills","active_agent_flows"]),ue.listFlows(),C.isFileSystemAgentAvailable(),C.isCreateFilesAgentAvailable()]),{flows:A=[]}=v;c({...h,preferences:p.settings}),b(((M=p.settings)==null?void 0:M.default_agent_skills)??[]),I(((V=p.settings)==null?void 0:V.disabled_agent_skills)??[]),S(((q=p.settings)==null?void 0:q.imported_agent_skills)??[]),se(A.filter(Z=>Z.active).map(Z=>Z.uuid)),he(A),dt($),xt(D),u(!1)}d()},[]);const be=d=>{I(h=>{const p=h.includes(d)?h.filter(v=>v!==d):[...h,d];return a(!0),p})},K=d=>{b(h=>{const p=h.includes(d)?h.filter(v=>v!==d):[...h,d];return a(!0),p})},je=d=>{se(h=>h.includes(d)?h.filter(v=>v!==d):[...h,d])},ye=d=>{W(h=>h.map(p=>p.name!==d?p:{...p,running:!p.running}))},X=async d=>{var A,M,V;d.preventDefault();const h={workspace:{},system:{},env:{}},p=new FormData(s.current);for(var[v,$]of p.entries()){if(v.startsWith("system::")){const[q,Z]=v.split("system::");h.system[Z]=String($);continue}if(v.startsWith("env::")){const[q,Z]=v.split("env::");h.env[Z]=String($);continue}h.workspace[v]=_t(v,$)}const{success:D}=await G.updateSystemPreferences(h.system);if(await C.updateSystem(h.env),D){const q=await C.keys(),Z=await G.systemPreferencesByFields(["disabled_agent_skills","default_agent_skills","imported_agent_skills"]);c({...q,preferences:Z.settings}),b(((A=Z.settings)==null?void 0:A.default_agent_skills)??[]),I(((M=Z.settings)==null?void 0:M.disabled_agent_skills)??[]),S(((V=Z.settings)==null?void 0:V.imported_agent_skills)??[]),w("Agent preferences saved successfully.","success",{clear:!0})}else w("Agent preferences failed to save.","error",{clear:!0});a(!1)};let k=null;H?k=ne:T?k=ae:n!=null&&n.imported?k=le:y[n]?k=(Me=y[n])==null?void 0:Me.component:O[n]?k=(Ce=O[n])==null?void 0:Ce.component:k=(Ee=j[n])==null?void 0:Ee.component;const ve=d=>{U(null),P(null),m(d),L&&f(!0)},R=d=>{U(null),P(null),m(d),L&&f(!0)},we=d=>{m(null),P(null),U(d),L&&f(!0)},Ne=d=>{m(null),U(null),P(d),L&&f(!0)},Se=d=>{U(null),se(h=>h.filter(p=>p!==d)),he(h=>h.filter(p=>p.uuid!==d))},ke=d=>{P(null),W(h=>h.filter(p=>p.name!==d))},Ae=async(d,h,p)=>{const{success:v,error:$,suppressedTools:D}=await J.toggleTool(d,h,p);if(!v){w($||"Failed to toggle tool.","error",{clear:!0});return}W(A=>A.map(M=>{var V;return M.name!==d?M:{...M,config:{...M.config,anythingllm:{...(V=M.config)==null?void 0:V.anythingllm,suppressedTools:D}}}})),P(A=>{var M;return!A||A.name!==d?A:{...A,config:{...A.config,anythingllm:{...(M=A.config)==null?void 0:M.anythingllm,suppressedTools:D}}}})};return g?e.jsx("div",{style:{height:L?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] w-full h-full flex justify-center items-center",children:e.jsx(wt,{})}):L?e.jsx(tt,{hasChanges:l,handleCancel:()=>a(!1),handleSubmit:X,children:e.jsxs("form",{onSubmit:X,onChange:()=>!H&&a(!0),ref:s,className:"flex flex-col w-full p-4 mt-10",children:[e.jsx("input",{name:"system::default_agent_skills",type:"hidden",value:x.join(",")}),e.jsx("input",{name:"system::disabled_agent_skills",type:"hidden",value:E.join(",")}),e.jsxs("div",{hidden:F,className:"flex flex-col gap-y-[18px] overflow-y-scroll no-scroll",children:[e.jsxs("div",{className:"text-theme-text-primary flex items-center gap-x-2",children:[e.jsx(Y,{size:24}),e.jsx("p",{className:"text-lg font-medium",children:"Agent Skills"})]}),e.jsx(B,{skills:j,selectedSkill:n,handleClick:ve,activeSkills:Object.keys(j).filter(d=>!E.includes(d))}),e.jsx(B,{skills:y,selectedSkill:n,handleClick:ve,activeSkills:x}),e.jsxs("div",{className:"text-theme-text-primary flex items-center gap-x-2 mt-6",children:[e.jsx(ce,{size:24}),e.jsx("p",{className:"text-lg font-medium",children:"App Integrations"})]}),e.jsx(B,{skills:O,selectedSkill:n,handleClick:R,activeSkills:x}),e.jsxs("div",{className:"text-theme-text-primary flex items-center gap-x-2",children:[e.jsx(ie,{size:24}),e.jsx("p",{className:"text-lg font-medium",children:"Custom Skills"})]}),e.jsx(Je,{skills:N,selectedSkill:n,handleClick:R}),e.jsxs("div",{className:"text-theme-text-primary flex items-center gap-x-2 mt-6",children:[e.jsx(ee,{size:24}),e.jsx("p",{className:"text-lg font-medium",children:"Agent Flows"})]}),e.jsx(Xe,{flows:Q,selectedFlow:H,handleClick:we,activeFlowIds:z}),e.jsx("input",{type:"hidden",name:"system::active_agent_flows",id:"active_agent_flows",value:z.join(",")}),e.jsx(Ye,{setMcpServers:W,setSelectedMcpServer:P,children:({loadingMcpServers:d})=>e.jsx(et,{isLoading:d,servers:ge,selectedServer:T,handleClick:Ne})})]}),F&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-sidebar z-30",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex items-center p-4",children:e.jsx("button",{type:"button",onClick:()=>{f(!1),m("")},className:"text-white/60 hover:text-white transition-colors duration-200",children:e.jsxs("div",{className:"flex items-center text-sky-400",children:[e.jsx(Nt,{size:24}),e.jsx("div",{children:"Back"})]})})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.jsx("div",{className:" bg-theme-bg-secondary text-white rounded-xl p-4 overflow-y-scroll overflow-x-visible no-scroll",children:k?e.jsx(e.Fragment,{children:T?e.jsx(ae,{server:T,toggleServer:ye,onDelete:ke,onToggleTool:Ae}):H?e.jsx(ne,{flow:H,toggleFlow:je,enabled:z.includes(H.uuid),onDelete:Se}):n.imported?e.jsx(le,{selectedSkill:n,setImportedSkills:S},n.hubId):e.jsx(e.Fragment,{children:j!=null&&j[n]?e.jsx(k,{skill:(_e=j[n])==null?void 0:_e.skill,settings:r,toggleSkill:be,enabled:!E.includes((Fe=j[n])==null?void 0:Fe.skill),setHasChanges:a,...j[n]}):y!=null&&y[n]?e.jsx(k,{skill:(Ze=y[n])==null?void 0:Ze.skill,settings:r,toggleSkill:K,enabled:x.includes((He=y[n])==null?void 0:He.skill),setHasChanges:a,hasChanges:l,...y[n]}):e.jsx(k,{skill:(Oe=O[n])==null?void 0:Oe.skill,settings:r,toggleSkill:K,enabled:x.includes((Pe=O[n])==null?void 0:Pe.skill),setHasChanges:a,hasChanges:l,...O[n]})})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-theme-text-secondary",children:[e.jsx(Y,{size:40}),e.jsx("p",{className:"font-medium",children:"Select an Agent Skill, Agent Flow, or MCP Server"})]})})})]})})]})}):e.jsx(tt,{hasChanges:l,handleCancel:()=>a(!1),handleSubmit:X,children:e.jsxs("form",{onSubmit:X,onChange:d=>{ps.includes(d.target.name)||!(n!=null&&n.imported)&&!H&&a(!0)},ref:s,className:"flex-1 flex gap-x-6 p-4 mt-10",children:[e.jsx("input",{name:"system::default_agent_skills",type:"hidden",value:x.join(",")}),e.jsx("input",{name:"system::disabled_agent_skills",type:"hidden",value:E.join(",")}),e.jsx("input",{type:"hidden",name:"system::active_agent_flows",id:"active_agent_flows",value:z.join(",")}),e.jsxs("div",{className:"flex flex-col min-w-[360px] h-[calc(100vh-90px)]",children:[e.jsxs("div",{className:"flex-none flex justify-between items-center mb-4",children:[e.jsxs("div",{className:"text-theme-text-primary flex items-center gap-x-2",children:[e.jsx(Y,{size:24}),e.jsx("p",{className:"text-lg font-medium",children:"Agent Skills"})]}),e.jsx(gs,{})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pr-2 pb-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(B,{skills:j,selectedSkill:n,handleClick:R,activeSkills:Object.keys(j).filter(d=>!E.includes(d))}),e.jsx(B,{skills:y,selectedSkill:n,handleClick:R,activeSkills:x}),e.jsxs("div",{className:"text-theme-text-primary flex items-center gap-x-2 mt-6",children:[e.jsx(ce,{size:24}),e.jsx("p",{className:"text-lg font-medium",children:"App Integrations"})]}),e.jsx(B,{skills:O,selectedSkill:n,handleClick:R,activeSkills:x}),e.jsxs("div",{className:"text-theme-text-primary flex items-center gap-x-2 mt-4",children:[e.jsx(ie,{size:24}),e.jsx("p",{className:"text-lg font-medium",children:"Custom Skills"})]}),e.jsx(Je,{skills:N,selectedSkill:n,handleClick:R}),e.jsxs("div",{className:"text-theme-text-primary flex items-center justify-between gap-x-2 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(ee,{size:24}),e.jsx("p",{className:"text-lg font-medium",children:"Agent Flows"})]}),Q.length===0?e.jsxs(Re,{to:re.agents.builder(),className:"text-cta-button flex items-center gap-x-1 hover:underline",children:[e.jsx(De,{size:16}),e.jsx("p",{className:"text-sm",children:"Create Flow"})]}):e.jsxs(Re,{to:re.agents.builder(),className:"text-theme-text-secondary hover:text-cta-button flex items-center gap-x-1",children:[e.jsx(De,{size:16}),e.jsx("p",{className:"text-sm",children:"Open Builder"})]})]}),e.jsx(Xe,{flows:Q,selectedFlow:H,handleClick:we,activeFlowIds:z}),e.jsx(Ye,{setMcpServers:W,setSelectedMcpServer:P,children:({loadingMcpServers:d})=>e.jsx(et,{isLoading:d,servers:ge,selectedServer:T,handleClick:Ne})})]})})]}),e.jsx("div",{className:"flex-[2] flex flex-col gap-y-[18px] mt-10",children:e.jsx("div",{className:"bg-theme-bg-secondary text-white rounded-xl flex-1 p-4 overflow-y-scroll overflow-x-visible no-scroll",children:k?e.jsx(e.Fragment,{children:T?e.jsx(ae,{server:T,toggleServer:ye,onDelete:ke,onToggleTool:Ae}):H?e.jsx(ne,{flow:H,toggleFlow:je,enabled:z.includes(H.uuid),onDelete:Se}):n.imported?e.jsx(le,{selectedSkill:n,setImportedSkills:S},n.hubId):e.jsx(e.Fragment,{children:j!=null&&j[n]?e.jsx(k,{skill:(Ve=j[n])==null?void 0:Ve.skill,settings:r,toggleSkill:be,enabled:!E.includes((Le=j[n])==null?void 0:Le.skill),setHasChanges:a,...j[n]}):y!=null&&y[n]?e.jsx(k,{skill:(Te=y[n])==null?void 0:Te.skill,settings:r,toggleSkill:K,enabled:x.includes(($e=y[n])==null?void 0:$e.skill),setHasChanges:a,hasChanges:l,...y[n]}):e.jsx(k,{skill:(Ie=O[n])==null?void 0:Ie.skill,settings:r,toggleSkill:K,enabled:x.includes((ze=O[n])==null?void 0:ze.skill),setHasChanges:a,hasChanges:l,...O[n]})})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-theme-text-secondary",children:[e.jsx(Y,{size:40}),e.jsx("p",{className:"font-medium",children:"Select an Agent Skill, Agent Flow, or MCP Server"})]})})})]})})}function tt({children:t,hasChanges:s,handleSubmit:l,handleCancel:a}){return e.jsxs("div",{id:"workspace-agent-settings-container",className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex md:mt-0 mt-6",children:[e.jsx(St,{}),e.jsxs("div",{style:{height:L?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] w-full h-full flex",children:[t,e.jsx(Ft,{showing:s,onSave:l,onCancel:a})]})]})}function B({isDefault:t=!1,skills:s=[],selectedSkill:l=null,handleClick:a=null,activeSkills:r=[],Icon:c=null}){return s.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`bg-theme-bg-secondary text-white rounded-xl ${L?"w-full":"min-w-[360px] w-fit"}`,children:Object.entries(s).map(([n,m],g)=>e.jsxs("div",{className:`py-3 px-4 flex items-center justify-between ${g===0?"rounded-t-xl":""} ${g===Object.keys(s).length-1?"rounded-b-xl":"border-b border-white/10"} cursor-pointer transition-all duration-300 hover:bg-theme-bg-primary ${l===n?"bg-white/10 light:bg-theme-bg-sidebar":""}`,onClick:()=>a==null?void 0:a(n),children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[m.Icon?e.jsx(m.Icon,{size:16}):c&&e.jsx(c,{size:16}),e.jsx("div",{className:"text-sm font-light",children:m.title})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[t?e.jsx(Et,{title:n}):e.jsx("div",{className:"text-sm text-theme-text-secondary font-medium",children:r.includes(n)?"On":"Off"}),e.jsx(de,{size:14,weight:"bold",className:"text-theme-text-secondary"})]})]},n))}),t&&e.jsx(lt,{id:"default-skill",place:"bottom",delayShow:300,className:"tooltip light:invert-0 !text-xs"})]})}export{Hs as default};
@@ -1 +1 @@
1
- import{u as C,r as o,q as V,G as O,j as e,t as m,c as T,M as $,k as B}from"../index.js";const G=["anythingllm-router"];function X({providerFieldName:g="fallback_provider",modelFieldName:i="fallback_model",label:b="Provider & Model",description:p="",defaultProvider:n="",defaultModel:l=""}){const{t:a}=C(),[s,f]=o.useState(n),[v,u]=o.useState(l),[y,j]=o.useState([]),[E,N]=o.useState(!1),[h,S]=o.useState(null),{isOpen:L,openModal:z,closeModal:M}=V();o.useEffect(()=>{n&&!s&&f(n)},[n]),o.useEffect(()=>{l&&!v&&u(l)},[l]);const w=O.filter(t=>!G.includes(t.value));o.useEffect(()=>{async function t(){const r=await m.keys();S(r??{})}t()},[]);function x(t){if(!h)return!0;const r=w.find(d=>d.value===t),c=(r==null?void 0:r.connectionConfig)||(r==null?void 0:r.requiredConfig);return c!=null&&c.length?c.every(d=>!!h[d]):!0}o.useEffect(()=>{if(!s||!h){j([]);return}if(!x(s))return;async function t(){N(!0);const{models:r=[]}=await m.customModels(s);j(r),N(!1)}t()},[s,h]);function P(t){const r=t.target.value;f(r),u(""),j([]),r&&!x(r)&&z()}function _(){M(),x(s)||(f(n||""),u(l||""))}async function q(t){t.preventDefault(),t.stopPropagation();const r={},c=new FormData(t.target);for(const[A,I]of c.entries())r[A]=I;const{error:d}=await m.updateSystem(r);if(d){T(a("model-router.provider-picker.toast-save-failed",{error:d}),"error");return}const R=await m.keys();S(R??{}),M()}const k=w.find(t=>t.value===s),D=s&&k&&!x(s);return e.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium leading-5 text-white light:text-slate-950",children:b}),p&&e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600",children:p}),e.jsxs("div",{className:"flex gap-x-3",children:[e.jsx("div",{className:"flex-1",children:e.jsxs("select",{name:g,value:s,onChange:P,className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5",required:!0,children:[e.jsx("option",{value:"",children:a("model-router.provider-picker.select-provider")}),w.map(t=>e.jsxs("option",{value:t.value,children:[t.name,x(t.value)?"":` ${a("model-router.provider-picker.setup-required")}`]},t.value))]})}),e.jsx("div",{className:"flex-1",children:D?e.jsx("button",{type:"button",onClick:z,className:"border-none bg-zinc-800 light:bg-white light:border light:border-slate-300 text-blue-400 light:text-blue-500 text-sm rounded-[8px] block w-full h-8 px-3.5 text-left hover:text-blue-300 light:hover:text-blue-600 transition-colors",children:a("model-router.provider-picker.configure-to-continue",{name:k.name})}):E?e.jsx("div",{className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-zinc-400 light:text-slate-500 text-sm rounded-[8px] h-8 px-3.5 flex items-center",children:a("model-router.provider-picker.loading-models")}):y.length>0?e.jsxs("select",{name:i,value:v,onChange:t=>u(t.target.value),className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5",required:!0,children:[e.jsx("option",{value:"",children:a("model-router.provider-picker.select-model")}),y.map(t=>e.jsx("option",{value:t.id,children:t.id},t.id))]}):e.jsx("input",{type:"text",name:i,value:v,onChange:t=>u(t.target.value),placeholder:a(s?"model-router.provider-picker.enter-model":"model-router.provider-picker.select-provider-first"),disabled:!s,className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 placeholder:text-zinc-400 light:placeholder:text-slate-400 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5 disabled:opacity-50",required:!0})})]}),e.jsx(U,{isOpen:L,provider:k,settings:h,onSave:q,onClose:_})]})}function U({isOpen:g,provider:i,settings:b,onSave:p,onClose:n}){const{t:l}=C();return!g||!i?null:e.jsx($,{isOpen:g,children:e.jsxs("div",{className:"w-full max-w-2xl bg-zinc-900 light:bg-white rounded-[8px] shadow-lg border border-zinc-700 light:border-slate-300",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-zinc-700 light:border-slate-300",children:[e.jsxs("div",{className:"flex items-center gap-x-3",children:[i.logo&&e.jsx("img",{src:i.logo,alt:`${i.name} logo`,className:"w-8 h-8 rounded-md"}),e.jsx("h3",{className:"text-base font-semibold leading-6 text-white light:text-slate-950",children:l("model-router.provider-picker.configure-provider",{name:i.name})})]}),e.jsx("button",{onClick:n,type:"button",className:"border-none p-1 rounded-lg text-zinc-400 light:text-slate-500 hover:text-white light:hover:text-slate-900 hover:bg-zinc-800 light:hover:bg-slate-100 transition-colors",children:e.jsx(B,{size:16,weight:"bold"})})]}),e.jsxs("form",{id:"provider-setup-form",onSubmit:p,children:[e.jsxs("div",{className:"px-6 py-5",children:[e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600 mb-4",children:l("model-router.provider-picker.setup-credentials",{name:i.name})}),e.jsx("div",{className:"space-y-4",children:i.options(b??{})})]}),e.jsxs("div",{className:"flex justify-between gap-x-3 px-6 py-4 border-t border-zinc-700 light:border-slate-300",children:[e.jsx("button",{type:"button",onClick:n,className:"border border-zinc-600 light:border-slate-600 text-white light:text-slate-900 text-sm font-medium leading-5 rounded-[8px] h-[34px] px-3.5 hover:opacity-90 transition-opacity",children:l("model-router.provider-picker.cancel")}),e.jsx("button",{type:"submit",form:"provider-setup-form",className:"border-none text-sm font-medium leading-5 bg-zinc-50 light:bg-slate-900 text-zinc-900 light:text-white rounded-[8px] h-[34px] px-3.5 hover:opacity-90 transition-opacity",children:l("model-router.provider-picker.save-settings")})]})]})]})})}export{X as L};
1
+ import{u as C,r as o,q as V,H as O,j as e,t as m,c as T,M as $,k as B}from"../index.js";const H=["anythingllm-router"];function X({providerFieldName:g="fallback_provider",modelFieldName:i="fallback_model",label:b="Provider & Model",description:p="",defaultProvider:n="",defaultModel:l=""}){const{t:a}=C(),[s,f]=o.useState(n),[v,u]=o.useState(l),[y,j]=o.useState([]),[E,N]=o.useState(!1),[h,S]=o.useState(null),{isOpen:L,openModal:z,closeModal:M}=V();o.useEffect(()=>{n&&!s&&f(n)},[n]),o.useEffect(()=>{l&&!v&&u(l)},[l]);const w=O.filter(t=>!H.includes(t.value));o.useEffect(()=>{async function t(){const r=await m.keys();S(r??{})}t()},[]);function x(t){if(!h)return!0;const r=w.find(d=>d.value===t),c=(r==null?void 0:r.connectionConfig)||(r==null?void 0:r.requiredConfig);return c!=null&&c.length?c.every(d=>!!h[d]):!0}o.useEffect(()=>{if(!s||!h){j([]);return}if(!x(s))return;async function t(){N(!0);const{models:r=[]}=await m.customModels(s);j(r),N(!1)}t()},[s,h]);function P(t){const r=t.target.value;f(r),u(""),j([]),r&&!x(r)&&z()}function _(){M(),x(s)||(f(n||""),u(l||""))}async function q(t){t.preventDefault(),t.stopPropagation();const r={},c=new FormData(t.target);for(const[A,I]of c.entries())r[A]=I;const{error:d}=await m.updateSystem(r);if(d){T(a("model-router.provider-picker.toast-save-failed",{error:d}),"error");return}const R=await m.keys();S(R??{}),M()}const k=w.find(t=>t.value===s),D=s&&k&&!x(s);return e.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium leading-5 text-white light:text-slate-950",children:b}),p&&e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600",children:p}),e.jsxs("div",{className:"flex gap-x-3",children:[e.jsx("div",{className:"flex-1",children:e.jsxs("select",{name:g,value:s,onChange:P,className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5",required:!0,children:[e.jsx("option",{value:"",children:a("model-router.provider-picker.select-provider")}),w.map(t=>e.jsxs("option",{value:t.value,children:[t.name,x(t.value)?"":` ${a("model-router.provider-picker.setup-required")}`]},t.value))]})}),e.jsx("div",{className:"flex-1",children:D?e.jsx("button",{type:"button",onClick:z,className:"border-none bg-zinc-800 light:bg-white light:border light:border-slate-300 text-blue-400 light:text-blue-500 text-sm rounded-[8px] block w-full h-8 px-3.5 text-left hover:text-blue-300 light:hover:text-blue-600 transition-colors",children:a("model-router.provider-picker.configure-to-continue",{name:k.name})}):E?e.jsx("div",{className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-zinc-400 light:text-slate-500 text-sm rounded-[8px] h-8 px-3.5 flex items-center",children:a("model-router.provider-picker.loading-models")}):y.length>0?e.jsxs("select",{name:i,value:v,onChange:t=>u(t.target.value),className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5",required:!0,children:[e.jsx("option",{value:"",children:a("model-router.provider-picker.select-model")}),y.map(t=>e.jsx("option",{value:t.id,children:t.id},t.id))]}):e.jsx("input",{type:"text",name:i,value:v,onChange:t=>u(t.target.value),placeholder:a(s?"model-router.provider-picker.enter-model":"model-router.provider-picker.select-provider-first"),disabled:!s,className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 placeholder:text-zinc-400 light:placeholder:text-slate-400 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5 disabled:opacity-50",required:!0})})]}),e.jsx(U,{isOpen:L,provider:k,settings:h,onSave:q,onClose:_})]})}function U({isOpen:g,provider:i,settings:b,onSave:p,onClose:n}){const{t:l}=C();return!g||!i?null:e.jsx($,{isOpen:g,children:e.jsxs("div",{className:"w-full max-w-2xl bg-zinc-900 light:bg-white rounded-[8px] shadow-lg border border-zinc-700 light:border-slate-300",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-zinc-700 light:border-slate-300",children:[e.jsxs("div",{className:"flex items-center gap-x-3",children:[i.logo&&e.jsx("img",{src:i.logo,alt:`${i.name} logo`,className:"w-8 h-8 rounded-md"}),e.jsx("h3",{className:"text-base font-semibold leading-6 text-white light:text-slate-950",children:l("model-router.provider-picker.configure-provider",{name:i.name})})]}),e.jsx("button",{onClick:n,type:"button",className:"border-none p-1 rounded-lg text-zinc-400 light:text-slate-500 hover:text-white light:hover:text-slate-900 hover:bg-zinc-800 light:hover:bg-slate-100 transition-colors",children:e.jsx(B,{size:16,weight:"bold"})})]}),e.jsxs("form",{id:"provider-setup-form",onSubmit:p,children:[e.jsxs("div",{className:"px-6 py-5",children:[e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600 mb-4",children:l("model-router.provider-picker.setup-credentials",{name:i.name})}),e.jsx("div",{className:"space-y-4",children:i.options(b??{})})]}),e.jsxs("div",{className:"flex justify-between gap-x-3 px-6 py-4 border-t border-zinc-700 light:border-slate-300",children:[e.jsx("button",{type:"button",onClick:n,className:"border border-zinc-600 light:border-slate-600 text-white light:text-slate-900 text-sm font-medium leading-5 rounded-[8px] h-[34px] px-3.5 hover:opacity-90 transition-opacity",children:l("model-router.provider-picker.cancel")}),e.jsx("button",{type:"submit",form:"provider-setup-form",className:"border-none text-sm font-medium leading-5 bg-zinc-50 light:bg-slate-900 text-zinc-900 light:text-white rounded-[8px] h-[34px] px-3.5 hover:opacity-90 transition-opacity",children:l("model-router.provider-picker.save-settings")})]})]})]})})}export{X as L};