@lacneu/atrium 0.91.2 → 0.91.4

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 (84) hide show
  1. package/dist/assets/{AccessTab-G2mgrnR5.js → AccessTab-CtjTuJS1.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-CyevWjzl.js → AdvancedFilter-BFXkHS7k.js} +1 -1
  3. package/dist/assets/AgentFilesTab-EIaok7Cs.js +3 -0
  4. package/dist/assets/AnomaliesTab-D1h-Tspq.js +1 -0
  5. package/dist/assets/AuditTab-CEji-XO8.js +1 -0
  6. package/dist/assets/BridgeTab-Bs8cvrzB.js +1 -0
  7. package/dist/assets/ChatDefaultsTab-B76_pV-a.js +1 -0
  8. package/dist/assets/{DataTableShell-C0SV7OUi.js → DataTableShell-7VOYauXM.js} +1 -1
  9. package/dist/assets/{DetailChips-BeKOuUKo.js → DetailChips-DxxeU-mf.js} +1 -1
  10. package/dist/assets/FeedbacksTab-CQJddboV.js +1 -0
  11. package/dist/assets/{FieldLabel-vvQixe9u.js → FieldLabel-CZ-m3Yh8.js} +1 -1
  12. package/dist/assets/FilesTab-BLVuhYUu.js +1 -0
  13. package/dist/assets/{FilterBar-DTlL2mzQ.js → FilterBar-B0W1nP3i.js} +1 -1
  14. package/dist/assets/GroupsTab-eCgjhSeI.js +1 -0
  15. package/dist/assets/InstancesTab-C9knJ9ku.js +1 -0
  16. package/dist/assets/IntegrationsTab-GG79wWrt.js +1 -0
  17. package/dist/assets/KpiTab-BVMR3rMZ.js +1 -0
  18. package/dist/assets/PreferencesTab-DOEuFzay.js +1 -0
  19. package/dist/assets/ProjectPage-CVpssY-3.js +1 -0
  20. package/dist/assets/PromptInjectionsTab-Dbp3yLMc.js +4 -0
  21. package/dist/assets/RolesTab-CFa0qonh.js +1 -0
  22. package/dist/assets/ScheduledTab-QgcyWf16.js +1 -0
  23. package/dist/assets/ServiceAccountsTab-X_bQzXIS.js +1 -0
  24. package/dist/assets/{SubAgentReportsTab-BHRuU4mA.js → SubAgentReportsTab-Jf1zcgs0.js} +1 -1
  25. package/dist/assets/ThemeShowroom-DCxA68bn.js +1 -0
  26. package/dist/assets/{TimeRangePicker-9-aQ6g1P.js → TimeRangePicker-BgJKavXM.js} +1 -1
  27. package/dist/assets/{TimezoneCombobox-DHBtL_j_.js → TimezoneCombobox-BkDGMdB2.js} +1 -1
  28. package/dist/assets/TracesTab-Bzw8y55N.js +1 -0
  29. package/dist/assets/TrashPage-YhpHdmVr.js +1 -0
  30. package/dist/assets/TrashTab-BuQ50Qu2.js +1 -0
  31. package/dist/assets/UsersTab-zHZZ8QUo.js +1 -0
  32. package/dist/assets/VoiceTab-IEStNr9Y.js +1 -0
  33. package/dist/assets/api-DcB3BxUc.js +44 -0
  34. package/dist/assets/{button-Dwru_Lf_.js → button-DgaBsJDX.js} +1 -1
  35. package/dist/assets/{card-s0ZpJ9CV.js → card-DnOLp6jN.js} +1 -1
  36. package/dist/assets/chevrons-up-down-R0Y7ndDn.js +1 -0
  37. package/dist/assets/{compatView-Cyi5F9Ss.js → compatView-Cyz2oaDo.js} +1 -1
  38. package/dist/assets/dispatchErrorInfo-ALhveHh9.js +1 -0
  39. package/dist/assets/{dist-BonvIBSy.js → dist-BFXL2p5c.js} +1 -1
  40. package/dist/assets/{dist-CaC4Zo1Q.js → dist-CYBhnY4b.js} +1 -1
  41. package/dist/assets/{dist-DLQaZf47.js → dist-D96qX4Zd.js} +1 -1
  42. package/dist/assets/{dist-CKSAyosJ.js → dist-DHnmL-lz.js} +1 -1
  43. package/dist/assets/{highlighted-body-OFNGDK62-DpJYuYNn.js → highlighted-body-OFNGDK62-CJ8J6p8l.js} +1 -1
  44. package/dist/assets/index-Ds-ybIOh.js +446 -0
  45. package/dist/assets/{index-CkNmrzkS.css → index-qA0SteHp.css} +1 -1
  46. package/dist/assets/{list-ClmCB0j4.js → list-CKshqcfm.js} +1 -1
  47. package/dist/assets/mermaid-GHXKKRXX-lChj9izi.js +1 -0
  48. package/dist/assets/{pdf-NJvkbSbt.js → pdf-DeAT0bfe.js} +1 -1
  49. package/dist/assets/roleDescriptions-DHMAPGYx.js +1 -0
  50. package/dist/assets/{table-BZJ_ifXB.js → table-A3AeBsY1.js} +1 -1
  51. package/dist/assets/{use_paginated_query-CknaCvRB.js → use_paginated_query-Dc9YWxua.js} +1 -1
  52. package/dist/assets/x-DJcI0sFP.js +1 -0
  53. package/dist/index.html +9 -9
  54. package/package.json +1 -1
  55. package/dist/assets/AgentFilesTab-Bquyszow.js +0 -3
  56. package/dist/assets/AnomaliesTab-w3RGpEVA.js +0 -1
  57. package/dist/assets/AuditTab-BfaA3aPE.js +0 -1
  58. package/dist/assets/BridgeTab-CbhPweRj.js +0 -1
  59. package/dist/assets/ChatDefaultsTab-BT8kt4oY.js +0 -1
  60. package/dist/assets/FeedbacksTab-Dhs0vcUt.js +0 -1
  61. package/dist/assets/FilesTab-B60GzpLb.js +0 -1
  62. package/dist/assets/GroupsTab-BekRX1wU.js +0 -1
  63. package/dist/assets/InstancesTab-B20hNMKz.js +0 -1
  64. package/dist/assets/IntegrationsTab-D53Gcl_R.js +0 -1
  65. package/dist/assets/KpiTab-Zg5ZHkfj.js +0 -1
  66. package/dist/assets/PreferencesTab-BfDU42yI.js +0 -1
  67. package/dist/assets/ProjectPage-zU6z6KS1.js +0 -1
  68. package/dist/assets/PromptInjectionsTab-CYApL0aB.js +0 -4
  69. package/dist/assets/RolesTab-Gutlgj_5.js +0 -1
  70. package/dist/assets/ScheduledTab-CMKobd5y.js +0 -1
  71. package/dist/assets/ServiceAccountsTab-Cf4EU2kL.js +0 -1
  72. package/dist/assets/ThemeShowroom-C5GcO6SU.js +0 -1
  73. package/dist/assets/TracesTab-COdbBLX_.js +0 -1
  74. package/dist/assets/TrashPage-Cpra3mll.js +0 -1
  75. package/dist/assets/TrashTab-Ba7c3pwl.js +0 -1
  76. package/dist/assets/UsersTab-k2pTMms6.js +0 -1
  77. package/dist/assets/VoiceTab-dVm89Owr.js +0 -1
  78. package/dist/assets/api-751U81xd.js +0 -44
  79. package/dist/assets/chevrons-up-down-DznzeuSP.js +0 -1
  80. package/dist/assets/dispatchErrorInfo-J5CG79Uk.js +0 -1
  81. package/dist/assets/index-oxINmoDf.js +0 -446
  82. package/dist/assets/mermaid-GHXKKRXX-C-Gj2Yhf.js +0 -1
  83. package/dist/assets/roleDescriptions-ex6WKrl0.js +0 -1
  84. package/dist/assets/x-C9PzBTHZ.js +0 -1
@@ -0,0 +1 @@
1
+ import{$M as e,QM as t,XM as n,YM as r,ZM as i}from"./api-DcB3BxUc.js";var a={pending:e,user:t,admin:i,observer:n,agent:r};function o(e){if(e.builtin){let t=a[e.key];if(t)return t()}return e.description}export{o as t};
@@ -1 +1 @@
1
- import{a as e,r as t}from"./bundle-mjs-C73ZY4La.js";import{r as n}from"./api-751U81xd.js";e();var r=t();function i({className:e,...t}){return(0,r.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,r.jsx)(`table`,{"data-slot":`table`,className:n(`w-full caption-bottom text-sm`,e),...t})})}function a({className:e,...t}){return(0,r.jsx)(`thead`,{"data-slot":`table-header`,className:n(`[&_tr]:border-b`,e),...t})}function o({className:e,...t}){return(0,r.jsx)(`tbody`,{"data-slot":`table-body`,className:n(`[&_tr:last-child]:border-0`,e),...t})}function s({className:e,...t}){return(0,r.jsx)(`tr`,{"data-slot":`table-row`,className:n(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function c({className:e,...t}){return(0,r.jsx)(`th`,{"data-slot":`table-head`,className:n(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function l({className:e,...t}){return(0,r.jsx)(`td`,{"data-slot":`table-cell`,className:n(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}export{a,c as i,o as n,s as o,l as r,i as t};
1
+ import{a as e,r as t}from"./bundle-mjs-C73ZY4La.js";import{r as n}from"./api-DcB3BxUc.js";e();var r=t();function i({className:e,...t}){return(0,r.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,r.jsx)(`table`,{"data-slot":`table`,className:n(`w-full caption-bottom text-sm`,e),...t})})}function a({className:e,...t}){return(0,r.jsx)(`thead`,{"data-slot":`table-header`,className:n(`[&_tr]:border-b`,e),...t})}function o({className:e,...t}){return(0,r.jsx)(`tbody`,{"data-slot":`table-body`,className:n(`[&_tr:last-child]:border-0`,e),...t})}function s({className:e,...t}){return(0,r.jsx)(`tr`,{"data-slot":`table-row`,className:n(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function c({className:e,...t}){return(0,r.jsx)(`th`,{"data-slot":`table-head`,className:n(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function l({className:e,...t}){return(0,r.jsx)(`td`,{"data-slot":`table-cell`,className:n(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}export{a,c as i,o as n,s as o,l as r,i as t};
@@ -1 +1 @@
1
- import{a as e,l as t}from"./bundle-mjs-C73ZY4La.js";import{FY as n,NY as r,OY as i,TY as a,xY as o}from"./api-751U81xd.js";var s=t(e(),1),c=(e,t,n)=>r=>{let i={...r.queries},a=r.nextPageKey,o=r.nextPageKey+1,s=r.nextPageKey+2;i[a]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,endCursor:t}}},i[o]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,cursor:t,endCursor:n}}};let c={...r.ongoingSplits};return c[e]=[a,o],{...r,nextPageKey:s,queries:i,ongoingSplits:c}},l=e=>t=>{let n=t.ongoingSplits[e];if(n===void 0)return t;let r={...t.queries};delete r[e];let i={...t.ongoingSplits};delete i[e];let a=t.pageKeys.slice(),o=t.pageKeys.findIndex(t=>t===e);return o>=0&&(a=[...t.pageKeys.slice(0,o),...n,...t.pageKeys.slice(o+1)]),{...t,queries:r,pageKeys:a,ongoingSplits:i}};function u(e,t,n){let{user:r}=p(e,t,n,!0);return r}var d=Symbol(`includePageKeys`),f=Symbol(`page`);function p(e,t,u,p=!0){if(typeof u?.initialNumItems!=`number`||u.initialNumItems<0)throw Error(`\`options.initialNumItems\` must be a positive number. Received \`${u?.initialNumItems}\`.`);let m=t===`skip`,g=m?{}:t,_=i(e),v=(0,s.useMemo)(()=>()=>{let t=h();return{query:e,args:g,id:t,nextPageKey:1,pageKeys:m?[]:[0],queries:m?{}:{0:{query:e,args:{...g,paginationOpts:{numItems:u.initialNumItems,cursor:null,id:t}}}},ongoingSplits:{},skip:m}},[JSON.stringify(n(g)),_,u.initialNumItems,m]),[y,b]=(0,s.useState)(v),x=y;(i(e)!==i(y.query)||JSON.stringify(n(g))!==JSON.stringify(n(y.args))||m!==y.skip)&&(x=v(),b(x));let S=a().logger,C=o(x.queries),w=u[d]??!1,[T,E,D]=(0,s.useMemo)(()=>{let e,t=[];for(let n of x.pageKeys){if(e=C[n],e===void 0)break;if(e instanceof Error){if(e.message.includes(`InvalidCursor`)||e instanceof r&&typeof e.data==`object`&&e.data?.isConvexSystemError===!0&&e.data?.paginationError===`InvalidCursor`)return S.warn(`usePaginatedQuery hit error, resetting pagination state: `+e.message),b(v),[[],void 0,void 0];if(p)throw e;return[t,void 0,e]}let i=x.ongoingSplits[n];if(i===void 0?e.splitCursor&&(e.pageStatus===`SplitRecommended`||e.pageStatus===`SplitRequired`||e.page.length>u.initialNumItems*2)&&b(c(n,e.splitCursor,e.continueCursor)):C[i[0]]!==void 0&&C[i[1]]!==void 0&&b(l(n)),e.pageStatus===`SplitRequired`)return[t,void 0,void 0];t.push(...w?e.page.map(e=>({...e,[f]:n.toString()})):e.page)}return[t,e,void 0]},[C,x.pageKeys,x.ongoingSplits,u.initialNumItems,v,S,w,p]);return{user:{results:T,...(0,s.useMemo)(()=>{if(D!==void 0)return{status:`Error`,isLoading:!1,error:D,loadMore:()=>{}};if(E===void 0)return x.nextPageKey===1?{status:`LoadingFirstPage`,isLoading:!0,loadMore:()=>{}}:{status:`LoadingMore`,isLoading:!0,loadMore:e=>{}};if(E.isDone)return{status:`Exhausted`,isLoading:!1,loadMore:e=>{}};let e=E.continueCursor,t=!1;return{status:`CanLoadMore`,isLoading:!1,loadMore:n=>{t||(t=!0,b(t=>{let r=[...t.pageKeys,t.nextPageKey],i={...t.queries};return i[t.nextPageKey]={query:t.query,args:{...t.args,paginationOpts:{numItems:n,cursor:e,id:t.id}}},{...t,nextPageKey:t.nextPageKey+1,pageKeys:r,queries:i}}))}}},[D,E,x.nextPageKey])},internal:{state:x}}}var m=0;function h(){return m++,m}export{u as t};
1
+ import{a as e,l as t}from"./bundle-mjs-C73ZY4La.js";import{FY as n,HY as r,YY as i,qY as a,zY as o}from"./api-DcB3BxUc.js";var s=t(e(),1),c=(e,t,n)=>r=>{let i={...r.queries},a=r.nextPageKey,o=r.nextPageKey+1,s=r.nextPageKey+2;i[a]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,endCursor:t}}},i[o]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,cursor:t,endCursor:n}}};let c={...r.ongoingSplits};return c[e]=[a,o],{...r,nextPageKey:s,queries:i,ongoingSplits:c}},l=e=>t=>{let n=t.ongoingSplits[e];if(n===void 0)return t;let r={...t.queries};delete r[e];let i={...t.ongoingSplits};delete i[e];let a=t.pageKeys.slice(),o=t.pageKeys.findIndex(t=>t===e);return o>=0&&(a=[...t.pageKeys.slice(0,o),...n,...t.pageKeys.slice(o+1)]),{...t,queries:r,pageKeys:a,ongoingSplits:i}};function u(e,t,n){let{user:r}=p(e,t,n,!0);return r}var d=Symbol(`includePageKeys`),f=Symbol(`page`);function p(e,t,u,p=!0){if(typeof u?.initialNumItems!=`number`||u.initialNumItems<0)throw Error(`\`options.initialNumItems\` must be a positive number. Received \`${u?.initialNumItems}\`.`);let m=t===`skip`,g=m?{}:t,_=r(e),v=(0,s.useMemo)(()=>()=>{let t=h();return{query:e,args:g,id:t,nextPageKey:1,pageKeys:m?[]:[0],queries:m?{}:{0:{query:e,args:{...g,paginationOpts:{numItems:u.initialNumItems,cursor:null,id:t}}}},ongoingSplits:{},skip:m}},[JSON.stringify(i(g)),_,u.initialNumItems,m]),[y,b]=(0,s.useState)(v),x=y;(r(e)!==r(y.query)||JSON.stringify(i(g))!==JSON.stringify(i(y.args))||m!==y.skip)&&(x=v(),b(x));let S=o().logger,C=n(x.queries),w=u[d]??!1,[T,E,D]=(0,s.useMemo)(()=>{let e,t=[];for(let n of x.pageKeys){if(e=C[n],e===void 0)break;if(e instanceof Error){if(e.message.includes(`InvalidCursor`)||e instanceof a&&typeof e.data==`object`&&e.data?.isConvexSystemError===!0&&e.data?.paginationError===`InvalidCursor`)return S.warn(`usePaginatedQuery hit error, resetting pagination state: `+e.message),b(v),[[],void 0,void 0];if(p)throw e;return[t,void 0,e]}let r=x.ongoingSplits[n];if(r===void 0?e.splitCursor&&(e.pageStatus===`SplitRecommended`||e.pageStatus===`SplitRequired`||e.page.length>u.initialNumItems*2)&&b(c(n,e.splitCursor,e.continueCursor)):C[r[0]]!==void 0&&C[r[1]]!==void 0&&b(l(n)),e.pageStatus===`SplitRequired`)return[t,void 0,void 0];t.push(...w?e.page.map(e=>({...e,[f]:n.toString()})):e.page)}return[t,e,void 0]},[C,x.pageKeys,x.ongoingSplits,u.initialNumItems,v,S,w,p]);return{user:{results:T,...(0,s.useMemo)(()=>{if(D!==void 0)return{status:`Error`,isLoading:!1,error:D,loadMore:()=>{}};if(E===void 0)return x.nextPageKey===1?{status:`LoadingFirstPage`,isLoading:!0,loadMore:()=>{}}:{status:`LoadingMore`,isLoading:!0,loadMore:e=>{}};if(E.isDone)return{status:`Exhausted`,isLoading:!1,loadMore:e=>{}};let e=E.continueCursor,t=!1;return{status:`CanLoadMore`,isLoading:!1,loadMore:n=>{t||(t=!0,b(t=>{let r=[...t.pageKeys,t.nextPageKey],i={...t.queries};return i[t.nextPageKey]={query:t.query,args:{...t.args,paginationOpts:{numItems:n,cursor:e,id:t.id}}},{...t,nextPageKey:t.nextPageKey+1,pageKeys:r,queries:i}}))}}},[D,E,x.nextPageKey])},internal:{state:x}}}var m=0;function h(){return m++,m}export{u as t};
@@ -0,0 +1 @@
1
+ import{E as e}from"./api-DcB3BxUc.js";var t=e(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t};
package/dist/index.html CHANGED
@@ -62,16 +62,16 @@
62
62
  document.documentElement.dataset.motion = "static";
63
63
  })();
64
64
  </script>
65
- <script type="module" crossorigin src="/assets/index-oxINmoDf.js"></script>
65
+ <script type="module" crossorigin src="/assets/index-Ds-ybIOh.js"></script>
66
66
  <link rel="modulepreload" crossorigin href="/assets/bundle-mjs-C73ZY4La.js">
67
- <link rel="modulepreload" crossorigin href="/assets/api-751U81xd.js">
68
- <link rel="modulepreload" crossorigin href="/assets/dist-CKSAyosJ.js">
69
- <link rel="modulepreload" crossorigin href="/assets/dist-BonvIBSy.js">
70
- <link rel="modulepreload" crossorigin href="/assets/dist-DLQaZf47.js">
71
- <link rel="modulepreload" crossorigin href="/assets/dist-CaC4Zo1Q.js">
72
- <link rel="modulepreload" crossorigin href="/assets/x-C9PzBTHZ.js">
73
- <link rel="modulepreload" crossorigin href="/assets/button-Dwru_Lf_.js">
74
- <link rel="stylesheet" crossorigin href="/assets/index-CkNmrzkS.css">
67
+ <link rel="modulepreload" crossorigin href="/assets/api-DcB3BxUc.js">
68
+ <link rel="modulepreload" crossorigin href="/assets/dist-DHnmL-lz.js">
69
+ <link rel="modulepreload" crossorigin href="/assets/dist-BFXL2p5c.js">
70
+ <link rel="modulepreload" crossorigin href="/assets/dist-D96qX4Zd.js">
71
+ <link rel="modulepreload" crossorigin href="/assets/dist-CYBhnY4b.js">
72
+ <link rel="modulepreload" crossorigin href="/assets/x-DJcI0sFP.js">
73
+ <link rel="modulepreload" crossorigin href="/assets/button-DgaBsJDX.js">
74
+ <link rel="stylesheet" crossorigin href="/assets/index-qA0SteHp.css">
75
75
  </head>
76
76
  <body>
77
77
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lacneu/atrium",
3
- "version": "0.91.2",
3
+ "version": "0.91.4",
4
4
  "description": "Atrium — public, self-hostable, Convex-backed web chat UI for AI agent gateways (OpenClaw today, Hermes next). Ships an origin-agnostic static bundle (Convex URL injected at runtime via /config.json).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,3 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,A_ as i,Ad as a,C_ as o,DY as s,D_ as c,EY as l,E_ as u,F_ as d,Fd as f,M_ as p,Md as m,N_ as h,Nd as g,OB as _,O_ as v,P_ as y,Pd as b,Qd as x,S_ as S,T_ as C,Zd as w,_Y as T,__ as E,_f as D,af as O,b_ as ee,c_ as k,cf as A,d_ as j,df as M,ef as N,f_ as P,ff as F,g_ as I,gf as L,h_ as te,hf as R,if as z,j_ as ne,jd as B,k_ as re,kd as V,l_ as ie,lf as ae,m_ as H,mf as oe,nf as U,o_ as se,of as ce,p_ as le,pf as ue,rf as de,s_ as fe,sf as pe,ss as me,t as W,tf as he,u_ as ge,uf as _e,v_ as ve,wY as G,w_ as ye,x_ as be,xv as K,yY as q,y_ as xe,yv as Se}from"./api-751U81xd.js";import{t as J}from"./button-Dwru_Lf_.js";import{Bt as Ce,Ct as we,Dt as Te,Gt as Ee,Ht as De,Jt as Oe,Kt as ke,Ot as Ae,St as je,Tt as Me,Ut as Ne,Vt as Pe,Wt as Fe,Yt as Y,bt as Ie,ft as Le,kn as Re,nt as ze,qt as Be,vt as Ve,wt as He,xt as Ue,yt as We}from"./index-oxINmoDf.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{a as qe}from"./compatView-Cyi5F9Ss.js";/* empty css */var X=t(e(),1),Je=2e4,Ye=6e4;function Xe(e){return typeof e!=`number`||e<=0?0:Math.round(e/Je*100)}function Ze(e){return e<=0?0:Math.round(e/Ye*100)}function Z(e,t){let n=(typeof e==`number`&&e>0?e:0)/1e3;return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(n)}function Qe(e){return e.reduce((e,t)=>e+(typeof t.size==`number`&&t.size>0?t.size:0),0)}var $e=3;function et(e,t){let n=new Map;for(let t of e.split(`
2
- `))n.set(t,(n.get(t)??0)+1);for(let e of t.split(`
3
- `))n.set(e,(n.get(e)??0)-1);let r=0,i=0,a=[],o=[];for(let[e,t]of n)t<0?(r+=-t,a.length<$e&&a.push(e)):t>0&&(i+=t,o.length<$e&&o.push(e));return{added:r,removed:i,sampleAdded:a,sampleRemoved:o}}function tt(e){return(e instanceof Error?e.message:String(e)).includes(`DASHBOARD_NOT_DEPLOYED`)}function nt(e){return e instanceof Error?e.message.includes(`conflict:`):String(e).includes(`conflict:`)}var Q=n(),$=e=>`${e.instanceName}::${e.agentId}`;function rt(){let e=s(W.me.getMe,{host:Le}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=s(W.admin.listInstances,e!==void 0&&t?{}:`skip`),[a,l]=(0,X.useState)(null);(0,X.useEffect)(()=>{!t||!r||r.length===0||(!a||!r.some(e=>e.name===a))&&l(r[0].name)},[t,r,a]);let f=s(W.agents.listAgentsForInstance,t&&a?{instanceName:a}:`skip`),m=s(W.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),g=(0,X.useMemo)(()=>{if(e!==void 0){if(t)return a===null||f===void 0?r!==void 0&&r.length===0?[]:void 0:f.agents.map(e=>({instanceName:a,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(m!==void 0)return m.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,a,f,r,m]),[_,b]=(0,X.useState)(null);(0,X.useEffect)(()=>{!g||g.length===0||(!_||!g.some(e=>$(e)===_))&&b($(g[0]))},[g,_]);let x=g?.find(e=>$(e)===_)??null,S=G(W.agentFiles.listAgentFiles),[w,E]=(0,X.useState)({status:`idle`}),D=x?.instanceName??null,O=x?.agentId??null,ee=s(W.compat.forInstance,n&&D!==null?{instanceName:D}:`skip`),k=n&&D!==null?ze(ee,`agentFiles`):null,A=k===null?!1:k===`loading`?null:k.blocked,j=(0,X.useCallback)(async()=>{if(!(D===null||O===null)){E({status:`loading`});try{E({status:`done`,files:(await S({instanceName:D,agentId:O})).files})}catch(e){E({status:`error`,dashboardAbsent:tt(e)})}}},[S,D,O]);(0,X.useEffect)(()=>{A===!1&&j()},[j,A]);let[M,N]=(0,X.useState)(null),P=s(W.agentFileCuration.listCurations,t&&D!==null&&O!==null?{instanceName:D,agentId:O}:`skip`),I=s(W.agentFileCuration.curationSettings,t&&D!==null?{instanceName:D}:`skip`),L=G(W.agentFileCuration.requestCuration),[te,R]=(0,X.useState)(null),[z,B]=(0,X.useState)(null),{toast:V}=Y(),ie=(0,X.useMemo)(()=>{let e=new Map;for(let t of P??[])e.has(t.name)||e.set(t.name,t);return e},[P]),ae=(0,X.useCallback)(async e=>{if(!(D===null||O===null)){R(e);try{let t=await L({instanceName:D,agentId:O,name:e,trigger:`manual`});t.ok?V({title:oe(),variant:`success`}):V({title:ue({reason:t.reason??`unknown`}),variant:`error`})}catch{V({title:F(),variant:`error`})}finally{R(null)}}},[L,D,O,V]),H=q(),U=(0,X.useMemo)(()=>new Intl.NumberFormat(H,{maximumFractionDigits:0}),[H]);return e===void 0||g===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:T()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:d()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,Q.jsxs)(Ve,{value:a??``,onValueChange:e=>l(e),children:[(0,Q.jsx)(Ue,{size:`sm`,"aria-label":y(),children:(0,Q.jsx)(je,{})}),(0,Q.jsx)(We,{children:(r??[]).map(e=>(0,Q.jsx)(Ie,{value:e.name,children:e.name},e.name))})]}):null,g.length>0?(0,Q.jsxs)(Ve,{value:_??``,onValueChange:e=>b(e),children:[(0,Q.jsx)(Ue,{size:`sm`,"aria-label":h(),children:(0,Q.jsx)(je,{})}),(0,Q.jsx)(We,{children:g.map(e=>(0,Q.jsx)(Ie,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:p()})]}),x===null?null:k===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:T()}):k!==null&&k.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(Re,{size:14,"aria-hidden":!0}),` `,qe(k.gatewayVersion,k.provider)]}):w.status===`loading`||w.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:T()}):w.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[w.dashboardAbsent?me():i(),` `,!w.dashboardAbsent&&(0,Q.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void j(),children:Se()})]}):w.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ne()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:w.files.map(e=>{let n=Xe(e.size),r=n>=80;return(0,Q.jsxs)(`div`,{className:`oc-afiles__row`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__name`,title:e.name,children:e.name}),e.missing?(0,Q.jsx)(Oe,{variant:`outline`,children:re()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:v({size:Z(e.size,H)})}),(0,Q.jsx)(`span`,{className:`oc-afiles__gauge${r?` is-warn`:``}`,"aria-hidden":!0,children:(0,Q.jsx)(`span`,{className:`oc-afiles__gauge-fill`,style:{width:`${Math.min(n,100)}%`}})}),(0,Q.jsx)(`span`,{className:`oc-afiles__pct`,children:c({pct:U.format(n)})}),r?(0,Q.jsx)(Re,{size:14,className:`oc-afiles__warn`,"aria-label":u()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(J,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>N(e),children:t?ye():o()}),t&&!e.missing?(0,Q.jsx)(it,{curatable:Ke.includes(e.name),size:e.size??0,budget:I?.budgetChars??null,enabled:I?.enabled??!1,curation:ie.get(e.name)??null,inFlight:te===e.name,onCurate:()=>void ae(e.name),onReview:e=>B(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:C({used:Z(Qe(w.files),H),total:Z(Ye,H),pct:U.format(Ze(Qe(w.files)))})})]}),M&&x?(0,Q.jsx)(at,{instanceName:x.instanceName,agentId:x.agentId,name:M.name,isAdmin:t,onClose:()=>N(null),onSaved:()=>void j()}):null,z?(0,Q.jsx)(ot,{curationId:z,onClose:()=>B(null),onApplied:()=>{B(null),j()}}):null]})}function it({curatable:e,size:t,budget:n,enabled:r,curation:i,inFlight:a,onCurate:o,onReview:s}){return i?.status===`proposed`?(0,Q.jsx)(J,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>s(i._id),children:L()}):a||i?.status===`dispatched`||i?.status===`applying`?(0,Q.jsx)(Oe,{variant:`outline`,className:`oc-afiles__curate-status`,children:R()}):e&&r&&n!==null&&Ge(t,n)?(0,Q.jsx)(J,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:o,children:D()}):null}function at({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:i,onSaved:a}){let o=G(W.agentFiles.getAgentFile),s=G(W.agentFiles.setAgentFile),c=Y(),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[C,w]=(0,X.useState)(!1),D=(0,X.useCallback)(async r=>{f(!1);try{let i=await o({instanceName:e,agentId:t,name:n});u({content:i.content,updatedAtMs:i.updatedAtMs}),r||m(i.content),x(!1)}catch{f(!0)}},[o,e,t,n]);(0,X.useEffect)(()=>{D(!1)},[D]);async function O(){if(l!==null){y(!0),w(!1);try{await s({instanceName:e,agentId:t,name:n,content:p,baseUpdatedAtMs:l.updatedAtMs??void 0}),c.success(I({name:n})),a(),await D(!1)}catch(e){nt(e)?x(!0):w(!0)}finally{y(!1)}}}let A=l!==null&&p!==l.content,M=(0,X.useMemo)(()=>l===null?null:et(l.content,p),[l,p]),N=p.length>Je,F=q(),L=(0,X.useMemo)(()=>new Intl.NumberFormat(F),[F]);return(0,Q.jsx)(we,{open:!0,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(He,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ae,{children:S({name:n})}),(0,Q.jsxs)(Me,{children:[be({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,ee()]})]})]}),d?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[H(),` `,(0,Q.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void D(!1),children:Se()})]}):l===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:T()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:p,readOnly:!r,spellCheck:!1,onChange:e=>m(e.target.value),"aria-label":S({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:xe()}),b?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[le(),` `,(0,Q.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void D(!0),children:P()})]}):null,C?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:te()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${N?` is-over`:``}`,children:ve({count:L.format(p.length),max:L.format(Je)})}),r?(0,Q.jsx)(J,{size:`sm`,disabled:!A||v||b,onClick:()=>g(!0),children:v?K():E()}):null]})]}),(0,Q.jsx)(Ce,{open:h,onOpenChange:g,children:(0,Q.jsxs)(Ne,{children:[(0,Q.jsxs)(ke,{children:[(0,Q.jsx)(Be,{children:j({name:n})}),(0,Q.jsx)(Fe,{children:ge({agent:t})})]}),M?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:ie({added:M.added,removed:M.removed})}),M.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:k()}),M.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,M.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:fe()}),M.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(De,{children:_()}),(0,Q.jsx)(Pe,{onClick:()=>void O(),children:se()})]})]})})]})})}function ot({curationId:e,onClose:t,onApplied:n}){let i=s(W.agentFileCuration.getProposal,{curationId:e}),o=G(W.agentFileCuration.approveCuration),c=l(W.agentFileCuration.rejectCuration),{toast:u}=Y(),[d,p]=(0,X.useState)(null),[h,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(``),S=q(),C=(0,X.useMemo)(()=>i?et(i.beforeContent,i.proposedContent):null,[i]);async function E(){p(`approve`);try{let t=await o({curationId:e});t.ok?(u({title:M(),variant:`success`}),n()):u({title:t.reason===`conflict`?ae():A({reason:t.reason??`unknown`}),variant:`error`})}catch{u({title:F(),variant:`error`})}finally{p(null)}}async function D(n){p(`reject`);try{let r=v.trim();(await c({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?u({title:n?a():_e(),variant:`success`}):u({title:O(),variant:`error`}),t()}catch{u({title:F(),variant:`error`})}finally{p(null)}}return(0,Q.jsx)(we,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(He,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ae,{children:i?pe({name:i.name}):T()}),(0,Q.jsx)(Me,{children:ce()})]}),i===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:T()}):i===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:O()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[z({before:Z(i.beforeSize,S),after:Z(i.proposedSize,S)}),i.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(Re,{size:13,"aria-hidden":!0}),` `,de()]}):null]}),C?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:U({added:C.added,removed:C.removed})}):null,i.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:V({feedback:i.feedback})}):null,C&&C.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:w()}),(0,Q.jsx)(`ul`,{children:C.sampleRemoved.map((e,t)=>(0,Q.jsx)(`li`,{children:e||`\xA0`},t))})]}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__review-panes oc-afiles__review-panes--2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:x()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:i.beforeContent})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:he()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:i.proposedContent})]})]})]}),h?(0,Q.jsxs)(`div`,{className:`oc-afiles__reject-form`,children:[(0,Q.jsx)(`label`,{className:`oc-afiles__review-label`,htmlFor:`curation-reject-comment`,children:f()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:b(),value:v,onChange:e=>y(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(J,{variant:`ghost`,onClick:()=>_(!1),disabled:d!==null,children:g()}),(0,Q.jsx)(J,{variant:`outline`,onClick:()=>void D(!1),disabled:d!==null,children:d===`reject`?K():m()}),(0,Q.jsx)(J,{variant:`default`,onClick:()=>void D(!0),disabled:d!==null,children:d===`reject`?K():B()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>_(!0),disabled:d!==null||i==null,children:N()}),(0,Q.jsx)(J,{variant:`default`,onClick:()=>void E(),disabled:d!==null||i==null,children:d===`approve`?K():r()})]})]})})}export{rt as AgentFilesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$j as r,Aj as i,Bj as ee,CM as a,DY as o,EY as s,Fj as c,Gj as te,Hj as l,Ij as u,Jj as ne,Kj as re,Lj as d,Mj as f,Nj as p,Pj as m,Qj as ie,Rj as ae,SM as oe,TM as h,Uj as se,Vj as ce,Wj as le,Xj as ue,Yj as g,Zj as _,_M as de,aM as fe,bM as pe,cM as me,dM as he,eM as ge,fM as _e,gM as ve,hM as ye,iM as be,jj as v,lM as xe,mM as Se,nM as y,oM as Ce,pM as b,qj as x,rM as S,sM as C,t as w,tM as T,uM as E,vM as D,wM as O,xM as k,yM as A,zj as we}from"./api-751U81xd.js";import{At as j,Ct as M,Dt as N,Jt as P,Ot as F,St as I,Yt as Te,bt as L,ct as Ee,dr as R,fr as De,ft as Oe,i as z,o as ke,vt as B,wt as V,xt as H,yt as U}from"./index-oxINmoDf.js";import{n as Ae}from"./TimeRangePicker-9-aQ6g1P.js";import{t as je}from"./FilterBar-DTlL2mzQ.js";import{t as Me}from"./DataTableShell-C0SV7OUi.js";import{t as W}from"./dispatchErrorInfo-J5CG79Uk.js";var G=t(e(),1),K=new Set([`openclaw.dispatch_failures`,`assistant.announce_errors`]),q=new Set([`assistant.cause.provider_auth_revoked`]);function J(e){let t=q.has(e.kind);if(!K.has(e.kind)&&!t||!e.evidence)return{};try{let n=JSON.parse(e.evidence);if(t){let e=Array.isArray(n.agents)?n.agents.filter(e=>typeof e==`string`):[],t=Array.isArray(n.providers)?n.providers.filter(e=>typeof e==`string`):[],r=e.length===1?e[0]:void 0;return{dominantCode:n.cause,sampleCorrelationId:n.sampleCorrelationId,context:{...r===void 0?{}:{agentId:r.slice(r.lastIndexOf(`/`)+1)},...t.length===1?{provider:t[0]}:{}}}}return{dominantCode:n.dominantCode,sampleCorrelationId:n.sampleCorrelationId}}catch{return{}}}var Y=n(),X=`__all__`,Ne=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Pe(e){return e===`open`?h():e===`acknowledged`?O():a()}var Fe=[`info`,`warn`,`critical`],Ie=[`detector`,`agent`,`user`],Le={kind:`relative`,from:`now-30d`,to:`now`},Re=200,Z=`all`;function Q(){let e=De({from:`/settings/anomalies`}),t=R({from:`/settings/anomalies`}),n=e.q??``,i=e.status===Z?X:e.status,a=e.severity??X,c=e.kind??X,[u,d]=(0,G.useState)(X),f=z(e.from,e.to),{from:p,to:m}=Ae(f),h=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),v=e=>void t({search:t=>({...t,status:e===X?Z:e})}),O=e=>void t({search:t=>({...t,severity:e===X?void 0:e})}),M=e=>void t({search:t=>({...t,kind:e===X?void 0:e})}),N=e=>void t({search:t=>({...t,...ke(e)})}),F=Ee(),V=Te(),W=s(w.anomalies.resolveAnomaly),K=(o(w.me.getMe,{host:Oe})?.permissions??[]).includes(`admin.manage`),q=o(w.anomalies.listAnomalies,{limit:Re,filter:{q:n||void 0,from:p,to:m,anomalyStatus:i===X?void 0:i,severity:a===X?void 0:a,source:u===X?void 0:u,kind:c===X?void 0:c}}),J=(0,G.useMemo)(()=>{let e=new Set;for(let t of q??[])e.add(t.kind);return[...e].sort()},[q]),Q=n!==``||i!==`open`||a!==X||u!==X||c!==X||f.kind!==`relative`||f.from!==Le.from;function $(){d(X),t({search:{status:`open`},replace:!0})}async function We(e){if(await F({title:oe(),description:(0,Y.jsxs)(Y.Fragment,{children:[k(),` `,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,pe(),` `,(0,Y.jsx)(`strong`,{children:A()}),`.`,` `,D()]}),confirmLabel:de()}))try{await W({anomalyId:e._id,status:`resolved`}),V.success(ve(),e.kind)}catch(e){V.error(ye(),e)}}async function Ge(e){try{await W({anomalyId:e._id,status:`acknowledged`}),V.success(Se(),e.kind)}catch(e){V.error(b(),e)}}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[_e(),` `,(0,Y.jsx)(`strong`,{children:he()}),` `,E(),` `,(0,Y.jsx)(`strong`,{children:xe()}),` `,me(),` `,(0,Y.jsx)(`strong`,{children:C()}),` `,Ce(),` `,(0,Y.jsx)(`span`,{className:`oc-filter__window`,children:fe()})]}),(0,Y.jsxs)(je,{q:n,onQChange:h,searchPlaceholder:be(),timeRange:f,onTimeRangeChange:N,onReset:$,canReset:Q,children:[(0,Y.jsxs)(B,{value:i,onValueChange:v,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(I,{})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:S()}),Ne.map(e=>(0,Y.jsx)(L,{value:e.value,children:Pe(e.value)},e.value))]})]}),(0,Y.jsxs)(B,{value:a,onValueChange:O,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(I,{placeholder:y()})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:ie()}),Fe.map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]})]}),(0,Y.jsxs)(B,{value:u,onValueChange:d,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(I,{placeholder:_()})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:ue()}),Ie.map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]})]}),(0,Y.jsxs)(B,{value:c,onValueChange:M,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(I,{placeholder:g()})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:ne()}),J.map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]})]})]}),(0,Y.jsx)(Me,{title:x(),rows:q,emptyHint:i===`open`?re():te(),rowActions:e=>K&&e.status===`open`?[{label:le(),onSelect:()=>void We(e)},{label:se(),onSelect:()=>void Ge(e)}]:[],columns:[{header:l(),cell:e=>(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:j(e.at)}),sort:e=>e.at},{header:g(),cell:e=>(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:T(),cell:e=>e.occurrenceCount!==null&&e.occurrenceCount>1?(0,Y.jsx)(`span`,{className:`oc-traces__time`,title:e.firstAt===null?void 0:r({when:j(e.firstAt)}),children:ge({count:String(e.occurrenceCount)})}):(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:`—`}),sort:e=>e.occurrenceCount??0},{header:y(),cell:e=>(0,Y.jsx)(Ve,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:ce(),cell:e=>(0,Y.jsx)(He,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:_(),cell:e=>(0,Y.jsx)(P,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:ee(),cell:e=>(0,Y.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,Y.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,Y.jsx)(Be,{row:e})]}),sort:e=>e.message},{header:we(),cell:e=>(0,Y.jsx)(ze,{row:e}),sort:e=>e.evidence??null},{header:ae(),cell:e=>e.correlationId?(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:Ue(e.correlationId)}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}function $(e){if(e.kind!==`subagent.failure`||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{failedCount:t.failedCount,totalCount:t.totalCount,errorCategories:t.errorCategories}}catch{return{}}}function ze({row:e}){let t=R();if(e.kind===`subagent.failure`){let n=$(e);return(0,Y.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,Y.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,d()]}):null]})}let n=J(e);if(!n.dominantCode){let e=n.sampleCorrelationId;return e?(0,Y.jsx)(`div`,{className:`oc-anomaly__cause`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:e,limit:100}}),children:[`↗ `,d()]})}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}let r=W(n.dominantCode,n.context),i=n.sampleCorrelationId;return(0,Y.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,Y.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,Y.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,Y.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:i,limit:100}}),children:[`↗ `,d()]}):null]})}function Be({row:e}){let[t,n]=(0,G.useState)(!1),r=o(w.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[u(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,Y.jsx)(M,{open:t,onOpenChange:n,children:(0,Y.jsxs)(V,{className:`oc-anomaly__attachments-dialog`,children:[(0,Y.jsx)(N,{children:(0,Y.jsx)(F,{children:c()})}),r===void 0?(0,Y.jsx)(`p`,{className:`oc-traces__muted`,children:m()}):r.length===0?(0,Y.jsx)(`p`,{className:`oc-traces__muted`,children:p()}):(0,Y.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,Y.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,Y.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,Y.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function Ve({severity:e}){return(0,Y.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function He({status:e}){return e===`open`?(0,Y.jsx)(P,{variant:`destructive`,children:f()}):e===`acknowledged`?(0,Y.jsx)(P,{variant:`secondary`,children:v()}):(0,Y.jsx)(P,{variant:`outline`,children:i()})}function Ue(e){return e.length>8?e.slice(0,8):e}export{Q as AnomaliesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AN as r,Au as i,CN as a,DN as o,DY as s,Du as c,EN as l,Eu as u,ON as d,Ou as f,SN as p,TN as m,_N as h,bN as g,jN as _,ju as v,kN as y,ku as b,t as x,vN as S,wN as C,xN as w,yN as T}from"./api-751U81xd.js";import{At as E,St as D,a as O,bt as k,dr as A,fr as j,i as M,n as N,o as P,s as F,vt as I,xt as L,yt as R}from"./index-oxINmoDf.js";import{n as ee}from"./TimeRangePicker-9-aQ6g1P.js";import{t as z}from"./FilterBar-DTlL2mzQ.js";import{t as B}from"./AdvancedFilter-CyevWjzl.js";import{t as V}from"./DataTableShell-C0SV7OUi.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:N,to:`now`},G=`__all__`,K=[{value:`action`,label:v()},{value:`realLabel`,label:i()},{value:`targetLabel`,label:b()},{value:`impersonated`,label:f()},{value:`resource`,label:c()},{value:`resourceId`,label:u()}];function q(){let e=j({from:`/settings/audit`}),t=A({from:`/settings/audit`}),n=e.q??``,i=e.action??G,c=e.impersonated??G,u=e.resource??G,f=M(e.from,e.to),v=(0,H.useMemo)(()=>F(e.adv),[e.adv]),{from:b,to:N}=ee(f),q=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),J=e=>void t({search:t=>({...t,action:e===G?void 0:e})}),Y=e=>void t({search:t=>({...t,impersonated:e===G?void 0:e})}),X=e=>void t({search:t=>({...t,resource:e===G?void 0:e})}),Z=e=>void t({search:t=>({...t,...P(e)})}),Q=e=>void t({search:t=>({...t,adv:O(e)}),replace:!0}),$=s(x.admin.listAudit,{filter:{q:n||void 0,from:b,to:N,action:i===G?void 0:i,resource:u===G?void 0:u,impersonated:c===G?void 0:c===`yes`,advanced:v.length>0?v:void 0}}),te=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])e.add(t.action);return[...e].sort()},[$]),ne=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])t.resource&&e.add(t.resource);return[...e].sort()},[$]),re=n!==``||i!==G||c!==G||u!==G||v.length>0||f.kind!==`relative`||f.from!==W.from;function ie(){t({search:{},replace:!0})}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`oc-admin__hint`,children:[_(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:r()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:y(),timeRange:f,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(I,{value:i,onValueChange:J,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{placeholder:d()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:o()}),te.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]}),(0,U.jsxs)(I,{value:c,onValueChange:Y,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:l()}),(0,U.jsx)(k,{value:`yes`,children:m()}),(0,U.jsx)(k,{value:`no`,children:C()})]})]}),(0,U.jsxs)(I,{value:u,onValueChange:X,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{placeholder:a()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:p()}),ne.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:v,onChange:Q}),(0,U.jsx)(V,{title:w(),rows:$,emptyHint:g(),columns:[{header:T(),cell:e=>E(e.at),sort:e=>e.at},{header:d(),cell:e=>e.action,sort:e=>e.action},{header:S(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:h(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:a(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$D as r,AO as i,Ak as a,BO as o,Bg as s,CO as c,Ck as l,DO as u,DY as d,Dk as f,E as p,EO as m,EY as ee,Ek as te,FO as ne,GO as re,Gg as h,HO as ie,Hg as g,IO as ae,JO as oe,Jg as _,Jl as v,KO as se,Kg as y,LO as ce,Lg as le,MO as ue,Mg as de,NO as fe,OO as pe,PO as me,QD as b,RO as he,Rg as ge,SO as _e,Sk as ve,TO as x,Tk as ye,UO as be,Ug as xe,VO as Se,Va as Ce,Vg as we,WO as Te,Wg as S,XD as C,Xl as Ee,Yg as De,Yl as Oe,ZD as ke,Zl as Ae,_O as je,_k as Me,aO as Ne,bO as Pe,bk as Fe,cO as Ie,cs as Le,dO as Re,eO as ze,eu as Be,fO as Ve,gO as He,gk as Ue,hO as We,iO as Ge,jO as Ke,kO as qe,kk as Je,lO as Ye,mO as Xe,nO as Ze,oO as Qe,pO as $e,qO as et,qg as tt,ql as nt,rO as rt,sO as it,t as w,tO as at,uO as T,vO as ot,wO as st,wY as ct,wk as lt,xO as ut,xk as dt,yO as ft,zO as pt,zg as mt}from"./api-751U81xd.js";import{r as E}from"./dist-DLQaZf47.js";import{t as ht}from"./chevrons-up-down-DznzeuSP.js";import{i as gt,n as D,o as _t,r as vt,s as yt}from"./FieldLabel-vvQixe9u.js";import{t as O}from"./button-Dwru_Lf_.js";import{$t as k,At as bt,Ct as xt,Dt as St,Jn as Ct,Jt as A,L as wt,Mt as Tt,Ot as Et,Pn as Dt,St as j,Tt as Ot,Yt as kt,ar as At,at as jt,bt as M,cn as Mt,dr as Nt,fr as Pt,ft as Ft,it as It,jt as N,kn as P,on as Lt,or as Rt,ot as zt,sn as Bt,sr as F,st as Vt,vt as I,wt as Ht,xt as L,yt as R}from"./index-oxINmoDf.js";import{r as Ut}from"./locales-CPjguROj.js";import{a as z,i as B,n as V,o as H,r as U,t as Wt}from"./table-BZJ_ifXB.js";import{t as Gt}from"./FilterBar-DTlL2mzQ.js";import{c as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./compatView-Cyi5F9Ss.js";import{t as W}from"./dispatchErrorInfo-J5CG79Uk.js";var $t=p(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),en=p(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),G=t(e(),1);function K(e){return e.filter(e=>e.state===`error`)}function tn(e){return e.reachable&&K(e.targets).length===0}function nn(e){return tn(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function rn(e){return e.state===`error`&&e.lastErrorCode!==null}function an(e){return!!e.lastDownstreamRejectCode}function on(e){return!!e.lastLocalRefusalCode}function sn(e){return rn(e)||an(e)||on(e)}function q(e){return e.kind??`openclaw`}function cn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function ln(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,q(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(q(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return cn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>q(e)===r)}))}function J(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var Y=`__all__`,un={q:``,state:Y,instance:Y,version:Y},X={connected:0,error:1,idle:2};function dn(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function fn(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function Z(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function pn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function mn(e,t,n){switch(e){case`state`:return(X[t.state]??99)-(X[n.state]??99);case`instance`:return Z(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return Z(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Zt(e,r)??Z(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return Z(t.targetLabel,n.targetLabel)}}function hn(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=pn(t.key,e),a=pn(t.key,r);return i&&a?0:i?1:a?-1:n*mn(t.key,e,r)})}function gn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(X[e]??99)-(X[t]??99))}function _n(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>Z(e.label,t.label))}function vn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Zt(e,t)??Z(e,t))}var Q=n();function yn({connections:e,displayByInstance:t}){let[n,i]=(0,G.useState)(un),[a,o]=(0,G.useState)(null),s=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0)+(e.localRefusalCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null,lastLocalRefusalCode:e.lastLocalRefusalCode??null,lastLocalRefusalAt:e.lastLocalRefusalAt??null})),[e,t]),c=(0,G.useMemo)(()=>gn(s),[s]),l=(0,G.useMemo)(()=>_n(s),[s]),u=(0,G.useMemo)(()=>vn(s),[s]),d=(0,G.useMemo)(()=>hn(fn(s,n),a),[s,n,a]);function f(e){o(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Xe()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(Gt,{q:n.q,onQChange:e=>i(t=>({...t,q:e})),searchPlaceholder:Re(),onReset:()=>i(un),canReset:dn(n),children:[(0,Q.jsxs)(I,{value:n.state,onValueChange:e=>i(t=>({...t,state:e})),children:[(0,Q.jsx)(L,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(j,{placeholder:Ye()})}),(0,Q.jsxs)(R,{children:[(0,Q.jsx)(M,{value:Y,children:T()}),c.map(e=>(0,Q.jsx)(M,{value:e,children:xn(e)},e))]})]}),(0,Q.jsxs)(I,{value:n.instance,onValueChange:e=>i(t=>({...t,instance:e})),children:[(0,Q.jsx)(L,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(j,{placeholder:Ie()})}),(0,Q.jsxs)(R,{children:[(0,Q.jsx)(M,{value:Y,children:T()}),l.map(e=>(0,Q.jsx)(M,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(I,{value:n.version,onValueChange:e=>i(t=>({...t,version:e})),children:[(0,Q.jsx)(L,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(j,{placeholder:it()})}),(0,Q.jsxs)(R,{children:[(0,Q.jsx)(M,{value:Y,children:T()}),u.map(e=>(0,Q.jsx)(M,{value:e,children:e},e))]})]})]}),d.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Qe()}):(0,Q.jsxs)(Wt,{className:`oc-conn__table`,children:[(0,Q.jsx)(z,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)($,{label:Ne(),sortKey:`target`,sort:a,onSort:f}),(0,Q.jsx)($,{label:Ge(),sortKey:`state`,sort:a,onSort:f}),(0,Q.jsx)($,{label:rt(),sortKey:`instance`,sort:a,onSort:f}),(0,Q.jsx)($,{label:Ze(),sortKey:`host`,sort:a,onSort:f}),(0,Q.jsx)($,{label:at(),sortKey:`version`,sort:a,onSort:f}),(0,Q.jsx)(B,{children:ze()}),(0,Q.jsx)($,{label:r(),sortKey:`lastOk`,sort:a,onSort:f})]})}),(0,Q.jsx)(V,{children:d.map(e=>(0,Q.jsx)(bn,{r:e},e._id))})]})]})}function $({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Q.jsx)(B,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Q.jsx)(Rt,{size:13,"aria-hidden":!0}):(0,Q.jsx)(E,{size:13,"aria-hidden":!0}):(0,Q.jsx)(ht,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function bn({r:e}){let t=rn(e)?W(e.lastErrorCode):null,n=an(e)?W(e.lastDownstreamRejectCode):null,r=on(e)?W(e.lastLocalRefusalCode):null;return(0,Q.jsxs)(G.Fragment,{children:[(0,Q.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(U,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(Sn,{state:e.state})}),(0,Q.jsx)(U,{children:e.instanceLabel?(0,Q.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(U,{children:e.gatewayVersion?(0,Q.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:$e({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(U,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:N(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),sn(e)?(0,Q.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Q.jsx)(`strong`,{children:t.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${N(e.lastErrorAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,r?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[Ce({label:r.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastLocalRefusalCode}),e.lastLocalRefusalAt?` · ${N(e.lastLocalRefusalAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:r.hint})]}):null,n?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[Ve({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${N(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function xn(e){return e===`connected`?b():e===`error`?ke():C()}function Sn({state:e}){return e===`connected`?(0,Q.jsx)(A,{variant:`secondary`,children:b()}):e===`error`?(0,Q.jsx)(A,{variant:`destructive`,children:ke()}):(0,Q.jsx)(A,{variant:`outline`,children:C()})}function Cn(){return d(w.bridgeHealth.getBridgeHealth,{})}function wn(){let e=Cn(),t=d(w.compat.getBridgeCompat,{}),n=d(w.me.getMe,{host:Ft})?.role===`admin`,r=d(w.admin.listInstances,n?{}:`skip`),i=d(w.agents.usageForInstances,n?{}:`skip`),a=Nt(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=ln(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=Pt({from:`/settings/bridge`}),l=Nt({from:`/settings/bridge`}),u=t?.compat??null,f=t===void 0?`loading`:t===null?`nodata`:`ready`,p=u!==null&&Xt(u,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Q.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Q.jsx)(Tn,{health:e,compat:t,onSeeAnomalies:o}),(0,Q.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:me()}),i&&i.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:fe()}),(0,Q.jsxs)(Wt,{children:[(0,Q.jsx)(z,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)(B,{children:Ae()}),(0,Q.jsx)(B,{children:Ee()}),(0,Q.jsx)(B,{children:Oe()}),(0,Q.jsx)(B,{children:v()}),(0,Q.jsx)(B,{children:nt()})]})}),(0,Q.jsx)(V,{children:i.flatMap(e=>{let t=wt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(H,{children:[(0,Q.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(U,{children:t.provider}),(0,Q.jsx)(U,{children:t.label}),(0,Q.jsx)(U,{children:(0,Q.jsxs)(A,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Q.jsxs)(It,{value:s.some(e=>e.key===c)?c:s[0]?.key??`openclaw`,onValueChange:e=>void l({search:{section:e},replace:!0}),children:[(0,Q.jsx)(zt,{className:`w-full`,children:s.map(e=>(0,Q.jsxs)(Vt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Dt,{size:13,"aria-hidden":!0}),J(e.key)]},e.key))}),s.map(e=>(0,Q.jsx)(jt,{value:e.key,children:(0,Q.jsx)(En,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:u,compatStatus:f,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,p?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:de()}):null]})}function Tn({health:e,compat:t,onSeeAnomalies:n}){let r=t!=null&&t.buildVersion!=null&&t.bridgeVersion!=null&&t.buildVersion!==t.bridgeVersion,i=t?.buildRevision&&t.buildRevision!==`unknown`?t.buildRevision.slice(0,7):null,a=t&&t!==null?(0,Q.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(t.bridgeVersion)}),i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:tt(),children:[`(`,i,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,y({build:t.buildVersion??`?`})]}):null,` · `,h(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?S():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:x()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:st()});let o=K(e.targets),s=!e.reachable,l=nn(e),u=e.unreachableInstances??[],d=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,f=bt(e.checkedAt),p=e.startedAt==null?null:bt(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Q.jsx)(At,{size:22}):s||l===`gateways_unreachable`?(0,Q.jsx)(en,{size:22}):(0,Q.jsx)(P,{size:22})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?c():l===`gateways_unreachable`?ft({count:u.length}):s?_e():ut({count:o.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)($t,{size:12,"aria-hidden":!0}),` `,Pe({time:f})]}),p?(0,Q.jsx)(`span`,{children:je({time:p})}):null,a]}),l===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:ot({names:u.join(`, `)})}):null,s?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Q.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:He()})]})}function En({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?Kt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=Qt(l.map(e=>e.state)),[f,p]=(0,G.useState)(!1);return(0,Q.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Q.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Q.jsx)(Dt,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Q.jsx)(`span`,{className:`oc-bridge-provider__name`,children:J(e)}),d?(0,Q.jsx)(A,{variant:d===`beyond`||d===`defective`?`destructive`:`secondary`,children:qt(d)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:De()}),(0,Q.jsx)(On,{providerName:J(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Q.jsx)(Dn,{protocol:o}):null,(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[f?(0,Q.jsx)(E,{size:13,"aria-hidden":!0}):(0,Q.jsx)(F,{size:13,"aria-hidden":!0}),We({count:t.length})]}),f?(0,Q.jsx)(yn,{connections:t,displayByInstance:c}):null]})}function Dn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,a=e.drift??[],o=(e.driftOverflow??0)+(e.driftTruncated??0);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[ue(),a.length>0?(0,Q.jsx)(A,{variant:`destructive`,children:i({count:a.length})}):o>0?(0,Q.jsx)(A,{variant:`destructive`,children:qe()}):(0,Q.jsx)(A,{variant:`secondary`,children:Ke()})]}),(0,Q.jsxs)(`p`,{className:`oc-admin__hint`,children:[pe({version:e.vendoredVersion}),r?` · `+u({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),o>0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Le({overflow:e.driftOverflow??0,truncated:e.driftTruncated??0})}):null,a.length>0?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:a.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Q.jsx)(E,{size:13,"aria-hidden":!0}):(0,Q.jsx)(F,{size:13,"aria-hidden":!0}),m({count:r.gapList.length})]}),t?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function On({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:x()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:xe()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:g()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:Be({provider:a})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:we({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:S()}),e?(0,Q.jsx)(Mn,{versions:e.validatedVersions}):null]}),i.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:le()}):(0,Q.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(e.version)}),(0,Q.jsx)(A,{variant:e.state===`supported`?`secondary`:e.state===`beyond`||e.state===`defective`?`destructive`:`outline`,children:qt(e.state)})]},e.instanceName))})]})}function kn({instance:e,onClose:t}){return(0,Q.jsx)(xt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(Ht,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(St,{children:[(0,Q.jsx)(Et,{children:a({instance:e.displayName??e.name})}),(0,Q.jsx)(Ot,{children:Je()})]}),(0,Q.jsx)(jn,{instance:e,onClose:t})]})})}function An({label:e,result:t}){return t?t.checked?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,Q.jsx)(At,{"aria-hidden":!0}):(0,Q.jsx)(P,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?he():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,ce()]}):null}function jn({instance:e,onClose:t}){let n=ee(w.admin.upsertInstanceConfig),r=ct(w.bridge.validateMediaPaths),i=kt(),a=Ut(e.config?.contentLocale,void 0),[s,c]=(0,G.useState)(()=>gt(e.config??{},a)),[u,d]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),_=s.inboundMediaMode===`shared-fs`,v=s.mediaMode===`shared-fs`,y=_||v;async function ce(){m(!0),g(null);try{g(await r({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){i.error(ie(),e)}finally{m(!1)}}async function le(){d(!0);try{let r=e.config??{};await n({instanceId:e._id,config:vt(s,r,a)}),t()}catch(e){i.error(ve(),e)}finally{d(!1)}}return(0,Q.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Q.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(D,{label:f(),help:dt()}),(0,Q.jsxs)(I,{value:s.mediaMode,onValueChange:e=>c({...s,mediaMode:e}),children:[(0,Q.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(R,{children:yt.map(e=>(0,Q.jsx)(M,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(D,{label:te(),help:Fe()}),(0,Q.jsxs)(I,{value:s.inboundMediaMode,onValueChange:e=>c({...s,inboundMediaMode:e}),children:[(0,Q.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(R,{children:_t.map(e=>(0,Q.jsx)(M,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(D,{label:ye(),help:Me()}),(0,Q.jsx)(k,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>c({...s,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),y&&(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[_&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(D,{label:oe(),help:et()}),(0,Q.jsx)(k,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>c({...s,inboundAgentMount:e.target.value})})]}),v&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(D,{label:se(),help:re()}),(0,Q.jsx)(k,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>c({...s,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(Tt,{checked:s.rehydration,onCheckedChange:e=>c({...s,rehydration:e===!0})}),(0,Q.jsx)(D,{label:lt(),help:Ue()})]}),y&&h!==null&&(0,Q.jsx)(`div`,{className:`oc-bridge-config__check`,children:h.reachable?!h.inbound&&!h.outbound?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(P,{"aria-hidden":!0}),ne({reason:h.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(An,{label:o(),result:h.inbound}),(0,Q.jsx)(An,{label:pt(),result:h.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Se()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(P,{"aria-hidden":!0}),ae()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[y&&(0,Q.jsxs)(O,{variant:`outline`,size:`sm`,onClick:()=>void ce(),disabled:p,children:[p?(0,Q.jsx)(Ct,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,p?be():Te()]}),(0,Q.jsx)(O,{size:`sm`,onClick:()=>void le(),disabled:u,children:l()})]})]})})}function Mn({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(Lt,{children:[(0,Q.jsx)(Mt,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?s():mt({count:e.length}),(0,Q.jsx)(E,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(Bt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:ge()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(A,{variant:`secondary`,children:e},e))})]})]})}export{wn as BridgeTab,kn as InstanceConfigDialog};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,$l as i,Ct as a,DY as o,EY as s,Ok as c,P_ as l,Qg as u,St as d,Tt as f,Xg as p,Zg as m,_Y as h,_p as g,_t as _,at as v,bt as y,ct as b,dp as x,dt as S,e_ as ee,et as te,fp as ne,ft as re,gp as C,gt as ie,hp as ae,ht as w,hv as oe,i_ as se,it as T,lt as ce,mp as E,mt as D,mv as le,n_ as ue,nt as de,ot as O,pp as fe,pt as pe,r_ as k,rt as A,st as me,t as j,t_ as M,tt as he,up as ge,ut as _e,vp as ve,vt as N,wY as P,wt as F,xt as ye,xv as I,yp as be,yt as xe,yv as Se}from"./api-751U81xd.js";import{t as Ce}from"./use_paginated_query-CknaCvRB.js";import{t as L}from"./button-Dwru_Lf_.js";import{$t as R,Mt as z,St as B,bt as V,kn as we,nt as Te,rt as Ee,tt as H,vt as U,xt as W,yt as G}from"./index-oxINmoDf.js";import{a as De}from"./compatView-Cyi5F9Ss.js";/* empty css */var K=t(e(),1),Oe=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function ke(e){let t=typeof e==`object`&&e?e:{},n=t.defaults!==null&&typeof t.defaults==`object`?t.defaults:{},r=n.thinkingDefault??t.thinkingDefault,i=n.fastModeDefault??t.fastModeDefault;return{thinkingDefault:typeof r==`string`?r:null,fastModeDefault:typeof i==`boolean`?i:null}}var q=[`auto`,`hybrid`,`tool`,`off`];function Ae(e){switch(e){case`auto`:return d();case`hybrid`:return ye();case`tool`:return y();default:return xe()}}function J(e){return{injection:e.injection??`auto`,defaultSources:e.defaultSources,...e.config?{config:e.config}:{}}}function Y(e){return typeof e==`string`&&q.includes(e)}function X(e){return{injection:Y(e.injection)?e.injection:`auto`,sources:e.defaultSources.filter(t=>e.sources.some(e=>e.id===t))}}function Z(e,t){let n=new Set(e);return n.size===new Set(t).size&&t.every(e=>n.has(e))}function je(e,t,n){let r=n?e.defaultWriteRefused===`scope_refused`?D():Me(e)?T():null:w(),i=X(e),a=t.injection!==i.injection||!Z(t.sources,i.sources),o=new Set(e.sources.map(e=>e.id)),s=t.sources.length>0&&t.sources.length<=16&&t.sources.every(e=>o.has(e));return{readOnlyReason:r,dirty:a,valid:s,invalidReason:s?null:_()}}function Me(e){return(e.contract??1)<2&&e.ownAllowlist===!1}function Ne(e,t,n){let r=t.sources.includes(n)?t.sources.filter(e=>e!==n):[...t.sources,n];return{...t,sources:e.sources.map(e=>e.id).filter(e=>r.includes(e))}}function Q(e){return e.ok?null:e.code===`scope_refused`?D():e.code===`stale_default`?pe():e.code===`write_unknown`||e.code===`not_confirmed`?_e():e.code===`not_applied`?ce():e.code===`default_too_large`?de():e.code===`allowlist_too_large`?A():e.code===`plugin_too_old`?T():e.code===`source_not_allowed`?v():e.code===`plugin_config_lag`?O():e.code===`knowledge_unavailable`&&e.reason===`plugin_absent`?ie():re({code:e.code})}function Pe(e,t){let n=J(e),r=J(t);if(n.injection!==r.injection||!Z(n.defaultSources,r.defaultSources))return!0;let i=n.config,a=r.config;return i===void 0||a===void 0?i!==a:i.injection!==a.injection||!((e,t)=>e===null||t===null?e===t:e.length===t.length&&e.every((e,n)=>e===t[n]))(i.sources,a.sources)}var $=n();function Fe({instanceName:e,row:t,supported:n}){let r=P(j.knowledge.setAgentKnowledgeDefault),[i,o]=(0,K.useState)(t),[s,c]=(0,K.useState)(()=>X(t)),[l,d]=(0,K.useState)(`idle`),[f,p]=(0,K.useState)(null),[h,g]=(0,K.useState)(!1),_=e=>{o(e),c(X(e)),p(null)},v=Pe(i,t);(0,K.useEffect)(()=>{h&&v&&(g(!1),_(t))},[h,v]);let y=je(i,s,n),b=y.readOnlyReason===null;async function x(){d(`saving`),p(null);try{let n=Q(await r({instanceName:e,agentId:t.agentId,injection:s.injection,sources:s.sources,expected:J(i)}));p(n),d(n===null?`done`:`idle`),n===null&&g(!0)}catch(e){p(Q({ok:!1,code:String(e?.message??`error`).slice(0,60)})),d(`idle`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,"data-knowledge-agent":t.agentId,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:t.agentId}),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsxs)(U,{value:s.injection,onValueChange:e=>{Y(e)&&c({...s,injection:e})},disabled:!b,children:[(0,$.jsx)(W,{className:`oc-cdefaults__select`,"aria-label":a(),children:(0,$.jsx)(B,{})}),(0,$.jsx)(G,{children:q.map(e=>(0,$.jsx)(V,{value:e,children:Ae(e)},e))})]})}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:N()}),t.sources.map(e=>(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:b?`pointer`:`default`},title:e.description||void 0,children:[(0,$.jsx)(z,{checked:s.sources.includes(e.id),onCheckedChange:()=>c(Ne(t,s,e.id)),disabled:!b,"aria-label":e.label,"data-knowledge-default-source":e.id}),(0,$.jsx)(`span`,{children:e.label})]},e.id)),v&&!h?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[he(),` `,(0,$.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>_(t),children:te()})]}):null,t.overridesAllowed?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:S()}),b?(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsx)(L,{size:`sm`,disabled:!y.dirty||!y.valid||l===`saving`,onClick:()=>void x(),children:l===`saving`?I():u()})}):(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:y.readOnlyReason}),b&&y.dirty&&y.invalidReason!==null?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:y.invalidReason}):null,l===`done`&&f===null?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:m()}):null,f===null?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:f})]})]})}function Ie({instanceName:e}){let t=o(j.knowledge.knowledgeAdminInstance,{instanceName:e}),{results:n,status:r,loadMore:i}=Ce(j.knowledge.agentKnowledgePage,{instanceName:e},{initialNumItems:50});return t===void 0||t.provider!==`openclaw`||n.length===0&&r!==`CanLoadMore`?null:(0,$.jsxs)(`section`,{className:`oc-cdefaults__row`,"aria-label":f(),children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:f()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:F()}),t.supported?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:w()}),n.map(n=>(0,$.jsx)(Fe,{instanceName:e,row:n,supported:t.supported},n.agentId)),r===`CanLoadMore`||r===`LoadingMore`?(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:b({shown:n.length})}),(0,$.jsx)(L,{variant:`outline`,size:`sm`,disabled:r===`LoadingMore`,onClick:()=>i(50),"data-knowledge-load-more":!0,children:me()})]}):null]})}function Le({instance:e}){let t=s(j.admin.upsertInstanceConfig),n=o(j.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,a]=(0,K.useState)(r),[c,l]=(0,K.useState)(`idle`);(0,K.useEffect)(()=>{a(r),l(`idle`)},[e._id,r]);let d=`__none__`,f=i!==r;async function h(){l(`saving`);try{let n={...e.config??{}};i===``||i===d?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),l(`done`)}catch{l(`error`)}}let g=n?.agents??[];return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:C()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsxs)(U,{value:i===``?d:i,onValueChange:e=>a(e===d?``:e),children:[(0,$.jsx)(W,{className:`oc-cdefaults__select`,"aria-label":C(),children:(0,$.jsx)(B,{placeholder:E()})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(V,{value:d,children:E()}),g.map(e=>(0,$.jsx)(V,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,$.jsx)(L,{size:`sm`,disabled:!f||c===`saving`,onClick:()=>void h(),children:c===`saving`?I():u()})]}),c===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:m()}):null,c===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:p()}):null]})}function Re({instance:e}){let t=s(j.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[i,a]=(0,K.useState)(n),[o,c]=(0,K.useState)(r===null?``:String(r)),[l,d]=(0,K.useState)(`idle`);(0,K.useEffect)(()=>{a(n),c(r===null?``:String(r)),d(`idle`)},[e._id,n,r]);let f=o.trim(),h=f===``?null:/^\d+$/.test(f)?Number.parseInt(f,10):NaN,_=!i||h===null||Number.isInteger(h)&&h>=4e3&&h<=6e4,v=i!==n||(h??null)!==r;async function y(){d(`saving`);try{let n={...e.config??{}};n.curationEnabled=i,!i||h===null||Number.isNaN(h)?delete n.curationBudgetChars:n.curationBudgetChars=h,await t({instanceId:e._id,config:n}),d(`done`)}catch{d(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,$.jsx)(z,{checked:i,onCheckedChange:e=>a(e===!0),"aria-label":g()}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:g()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(R,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:o,onChange:e=>c(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!_,"aria-label":fe(),disabled:!i}),(0,$.jsx)(L,{size:`sm`,disabled:!v||!_||l===`saving`,onClick:()=>void y(),children:l===`saving`?I():u()})]}),_?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:ne()}),l===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:m()}):null,l===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:p()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:x()})]})}function ze({instance:e}){let t=s(j.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,K.useState)(n===null?``:String(n)),[a,o]=(0,K.useState)(`idle`);(0,K.useEffect)(()=>{i(n===null?``:String(n)),o(`idle`)},[e._id,n]);let c=r.trim(),l=c===``?null:/^\d+$/.test(c)?Number.parseInt(c,10):NaN,d=l===null||Number.isInteger(l)&&l>=1e3&&l<=2e5,f=(l??null)!==n;async function h(){o(`saving`);try{let n={...e.config??{}};l===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=l,await t({instanceId:e._id,config:n}),o(`done`)}catch{o(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:be()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(R,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:r,onChange:e=>i(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!d}),(0,$.jsx)(L,{size:`sm`,disabled:!f||!d||a===`saving`,onClick:()=>void h(),children:a===`saving`?I():u()})]}),d?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:ge()}),a===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:m()}):null,a===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:p()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ve()})]})}function Be(){let e=P(j.agentFiles.getChatDefaults),[t,n]=(0,K.useState)({status:`loading`}),a=o(j.admin.listInstances,{}),[s,u]=(0,K.useState)(null);(0,K.useEffect)(()=>{!a||a.length===0||(!s||!a.some(e=>e.name===s))&&u(a[0].name)},[a,s]);let d=(a?.length??0)>1,f=a!==void 0&&a.length===0,p=o(j.compat.forInstance,s?{instanceName:s}:`skip`),m=s?Te(p,`configDefaults`):`loading`,g=m===`loading`?null:m.blocked,_=(0,K.useMemo)(()=>d&&s?{instanceName:s}:{},[d,s]),v=(0,K.useRef)(0),y=(0,K.useCallback)(async()=>{let t=++v.current;n({status:`loading`});try{let r=ke(await e(_));if(v.current!==t)return;n({status:`done`,current:r})}catch{if(v.current!==t)return;n({status:`error`})}},[e,_]);(0,K.useEffect)(()=>{g===!1&&(d&&!s||y())},[y,g,d,s]);let b=t.status===`done`?t.current:null,x=(0,K.useMemo)(()=>Oe.map(e=>({id:e,label:Ee(e)})),[]),S=(0,K.useMemo)(()=>[{id:`fast`,label:oe()},{id:`standard`,label:le()}],[]);return(0,$.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:se()}),d&&s?(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:l()}),(0,$.jsxs)(U,{value:s,onValueChange:e=>u(e),children:[(0,$.jsx)(W,{size:`sm`,"aria-label":l(),children:(0,$.jsx)(B,{})}),(0,$.jsx)(G,{children:(a??[]).map(e=>(0,$.jsx)(V,{value:e.name,children:e.name},e.name))})]})]}):null,f?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:c()}):m===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:h()}):m.blocked?(0,$.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,$.jsx)(we,{size:14,"aria-hidden":!0}),` `,De(m.gatewayVersion,m.provider)]}):t.status===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:h()}):t.status===`error`?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[r(),` `,(0,$.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void y(),children:Se()})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:k()}),(0,$.jsx)(H,{field:`thinkingLevel`,options:x,value:b?.thinkingDefault??null,onChange:()=>{},disabled:!0,ariaLabel:k()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ue()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:M()}),(0,$.jsx)(H,{field:`fastMode`,options:S,value:b===null||b.fastModeDefault===null?null:b.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0,ariaLabel:M()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ee()})]}),(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:i()})]}),(()=>{let e=a?.find(e=>e.name===(s??a[0]?.name));return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ze,{instance:e}),(0,$.jsx)(Re,{instance:e}),(0,$.jsx)(Le,{instance:e}),(0,$.jsx)(Ie,{instanceName:e.name})]}):null})()]})}export{Be as ChatDefaultsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$I as r,AI as i,BI as a,CI as o,Cf as s,DI as c,DY as l,EI as u,EY as d,FI as f,GI as p,HI as ee,II as te,JI as m,KI as ne,LI as h,MI as g,NI as _,OI as re,PI as ie,QI as v,RI as ae,SI as y,TI as b,UI as x,VI as S,WI as C,XI as w,YI as T,ZI as E,_I as D,aI as O,bI as k,cI as A,dI as j,eL as M,fI as N,gI as P,hI as F,iI as I,jI as L,kI as R,lI as z,mI as B,nI as V,nL as H,oI as U,pI as W,qI as oe,rI as G,rL as K,sI as q,t as J,tI as se,tL as ce,uI as le,vI as ue,wI as de,xI as fe,xf as pe,yI as me,zI as he}from"./api-751U81xd.js";import{t as ge}from"./button-Dwru_Lf_.js";import{At as _e,ct as Y}from"./index-oxINmoDf.js";import{t as ve}from"./DataTableShell-C0SV7OUi.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>K(),incorrect:()=>H(),incoherence:()=>ce(),formatting:()=>M(),latency:()=>r(),api_error:()=>v(),other:()=>E()},Q=e=>ye[e]?.()??e;function $({matches:e,sourceWasOpen:t}){return t?e===!0?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:T()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:m()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:w()})}function be({data:e,reference:t,closeReason:n}){let r=e.snapshot,o=d(J.feedback.respondToFeedback),[l,u]=(0,X.useState)(e.thread),[m,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(!1);async function w(){let t=m.trim();if(!(!t||y)){b(!0);try{await o({feedbackId:e._id,text:t}),u(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),v(``)}finally{b(!1)}}}let T=[];try{T=r.contextJson?JSON.parse(r.contextJson):[]}catch{T=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:r.displayedMatchesStored,sourceWasOpen:r.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,r.messageRole,r.isRegeneration?` · ${oe()}`:``,r.openclawModel?` · ${r.openclawModel}`:``,r.openclawRuntime?` (${r.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:fe(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ne()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,n?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:q()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:n})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:p()}),l.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:l.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Z.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?C():e.authorRole===`agent`?e.authorLabel??s():x()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:ee()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:S(),value:m,maxLength:2e3,rows:3,onChange:e=>v(e.target.value.slice(0,2e3))}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Z.jsx)(ge,{size:`sm`,onClick:()=>void w(),disabled:!m.trim()||y,children:y?a():he()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ae()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.messageText||h()})]}),r.clientInfo?.sourceWasOpen&&r.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:te()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.displayedText||h()})]}):null,r.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:f()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.promptText})]}):null,T.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ie({count:r.contextCount??T.length,truncated:r.contextTruncated?_():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:T.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,r.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[r.outboxText??``,r.outboxStatus?`\n[status: ${r.outboxStatus}]`:``]})]}):null,r.clientInfo?.extensionsDetected&&r.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:L()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:r.clientInfo.extensionsDetected.map(e=>(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:i()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[r.clientInfo?.language,r.clientInfo?.timezone,r.clientInfo?.theme?R({theme:r.clientInfo.theme}):null,r.runId?`run ${r.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,r.clientInfo?.plugins&&r.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[re(),` `,r.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,c()]})]}):null,r.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:r.clientInfo.userAgent}):null]})]})]})}function xe(){let e=l(J.feedback.listForAdmin,{}),t=d(J.feedback.readSnapshot),n=d(J.feedback.deleteFeedback),r=Y(),[i,a]=(0,X.useState)(null),[s,c]=(0,X.useState)({});async function f(e){if(i===e._id){a(null);return}if(!s[e._id]){let n=await t({feedbackId:e._id});c(t=>({...t,[e._id]:n}))}a(e._id)}async function p(e){await r({title:G(),description:V(),confirmLabel:se(),destructive:!0})&&(await n({feedbackId:e._id}),i===e._id&&a(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[u(),` `,(0,Z.jsx)(`strong`,{children:b()}),` `,de()]}),(0,Z.jsx)(ve,{title:o(),rows:e,emptyHint:y(),isExpanded:e=>i===e._id&&!!s[e._id],renderExpanded:e=>s[e._id]?(0,Z.jsx)(be,{data:s[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:k(),cell:e=>_e(e.at),sort:e=>e.at},{header:me(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:ue(),cell:e=>e.messageRole===`user`?D():P(),sort:e=>e.messageRole},{header:F(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${B({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:W(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:N(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:j(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:le()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:z()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:pe()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:A()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:i===e._id?U():O(),onSelect:()=>void f(e)},{label:I(),onSelect:()=>void p(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AJ as ee,CJ as r,DJ as i,DY as te,Df as a,EJ as o,EY as ne,Ef as re,FJ as s,IJ as c,LJ as l,MJ as u,NJ as d,OB as f,OJ as ie,PJ as p,RJ as ae,SJ as m,TJ as h,_J as oe,_Y as se,aJ as ce,bJ as le,cJ as ue,dJ as g,fJ as de,gJ as fe,hJ as pe,iJ as me,jJ as he,kJ as ge,lJ as _e,mJ as ve,oJ as ye,pJ as be,rJ as xe,sJ as Se,t as _,uJ as v,vJ as y,wJ as b,xJ as x,yJ as S,yY as C}from"./api-751U81xd.js";import{t as w}from"./button-Dwru_Lf_.js";import{An as T,Bt as E,Gt as D,Ht as O,In as k,Jt as A,Kt as j,Mt as Ce,St as M,Ut as we,Vt as Te,Wt as Ee,Yt as De,an as Oe,bt as N,en as ke,nn as P,nr as F,qt as Ae,tn as je,tr as Me,vt as I,xt as L,yt as R}from"./index-oxINmoDf.js";import{a as Ne,i as z,n as Pe,o as B,r as V,t as Fe}from"./table-BZJ_ifXB.js";var H=t(e(),1),U=n(),W=`all`;function G(e){switch(e){case`image`:return i();case`audio`:return o();case`video`:return h();case`pdf`:return b();case`document`:return r();case`archive`:return m();default:return x()}}function K(){let[e,t]=(0,H.useState)(W),[n,r]=(0,H.useState)(W),[i,o]=(0,H.useState)(W),[m,h]=(0,H.useState)(W),[b,x]=(0,H.useState)(!1),[K,q]=(0,H.useState)(null),J=ne(_.files.softDelete),Y=De();function Ie(){t(W),r(W),o(W),h(W)}async function Le(){let e=K;if(q(null),e)try{await J({fileId:e.id}),Y.success(v())}catch(e){Y.error(_e(),e)}}let X=te(_.files.listMine,{direction:e===W?void 0:e,chatId:n===W?void 0:n,instanceName:i===W?void 0:i,category:m===W?void 0:m,includeAutoGenerated:b||void 0}),Re=(0,H.useMemo)(()=>new Intl.DateTimeFormat(C(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:se()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==W||n!==W||i!==W||m!==W;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}),(0,U.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,U.jsxs)(I,{value:e,onValueChange:t,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":l(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:c()}),(0,U.jsx)(N,{value:`inbound`,children:s()}),(0,U.jsx)(N,{value:`outbound`,children:p()})]})]}),(0,U.jsxs)(I,{value:n,onValueChange:r,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":d(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:u()}),Q.chats.map(e=>(0,U.jsx)(N,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,U.jsxs)(I,{value:i,onValueChange:o,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":he(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:ee()}),Q.instances.map(e=>(0,U.jsx)(N,{value:e,children:e},e))]})]}):null,(0,U.jsxs)(I,{value:m,onValueChange:h,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":ge(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:ie()}),Q.categories.map(e=>(0,U.jsx)(N,{value:e,children:G(e)},e))]})]}),(0,U.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,U.jsx)(Ce,{checked:b,onCheckedChange:e=>x(e===!0),"aria-label":a()}),(0,U.jsx)(`span`,{children:a()})]}),$?(0,U.jsxs)(w,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,U.jsx)(k,{size:14,"aria-hidden":!0}),be()]}):null]}),Z.length===0?(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:$?me():ce()}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Ne,{children:(0,U.jsxs)(B,{children:[(0,U.jsx)(z,{children:le()}),(0,U.jsx)(z,{children:S()}),(0,U.jsx)(z,{children:y()}),(0,U.jsx)(z,{children:oe()}),(0,U.jsx)(z,{children:fe()}),(0,U.jsx)(z,{className:`text-right`,children:pe()})]})}),(0,U.jsx)(Pe,{children:Z.map(e=>(0,U.jsxs)(B,{children:[(0,U.jsxs)(V,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,U.jsx)(A,{variant:`outline`,style:{marginLeft:6},children:re()}):null]}),(0,U.jsx)(V,{title:e.mimeType,children:G(e.category)}),(0,U.jsx)(V,{children:(0,U.jsx)(A,{variant:`secondary`,children:e.direction===`inbound`?s():p()})}),(0,U.jsx)(V,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,U.jsx)(V,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,U.jsx)(V,{className:`text-right`,children:(0,U.jsxs)(ke,{children:[(0,U.jsx)(Oe,{asChild:!0,children:(0,U.jsx)(w,{variant:`ghost`,size:`icon`,"aria-label":de(),children:(0,U.jsx)(Me,{size:16})})}),(0,U.jsxs)(je,{align:`end`,children:[e.url?(0,U.jsx)(P,{asChild:!0,children:(0,U.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,U.jsx)(F,{size:14}),ve()]})}):(0,U.jsxs)(P,{disabled:!0,children:[(0,U.jsx)(F,{size:14}),ye()]}),(0,U.jsxs)(P,{variant:`destructive`,onSelect:()=>q({id:e._id,filename:e.filename}),children:[(0,U.jsx)(T,{size:14}),g()]})]})]})})]},e._id))})]}),ze?(0,U.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:xe({cap:Be})}):null]}),(0,U.jsx)(E,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,U.jsxs)(we,{children:[(0,U.jsxs)(j,{children:[(0,U.jsx)(Ae,{children:ue()}),(0,U.jsx)(Ee,{children:Se()})]}),(0,U.jsxs)(D,{children:[(0,U.jsx)(O,{children:f()}),(0,U.jsx)(Te,{onClick:()=>void Le(),children:g()})]})]})})]})}export{K as FilesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,$y as i,Ab as a,Bb as o,By as s,Cb as c,Cy as l,DY as u,Db as d,Dy as f,E as p,EY as m,Eb as h,Ey as g,Fb as _,Fy as v,Gb as y,Gv as b,Gy as x,Hb as S,Hy as C,Ib as w,Iv as T,Iy as E,Jb as D,Jv as O,Jy as k,Kb as A,Kv as j,Ky as ee,Lb as te,Lv as ne,Ly as M,Mb as N,My as re,Nb as ie,Ny as P,Ob as ae,Oy as F,Pb as oe,Py as se,Qv as I,Qy as ce,Rb as L,Rv as le,Ry as ue,Sb as de,Sy as fe,Tb as pe,Ty as me,Ub as he,Uy as ge,Vb as _e,Vy as ve,Wb as ye,Wy as be,Xv as xe,Xy as Se,Yb as Ce,Yv as we,Yy as Te,Zv as Ee,Zy as De,_b as Oe,_y as ke,ab as Ae,ay as je,bb as R,by as Me,cb as Ne,cy as Pe,db as z,dy as Fe,eb as Ie,ey as Le,fb as Re,fy as ze,gy as Be,hy as Ve,ib as He,iy as Ue,jb as We,kb as Ge,lb as Ke,ly as qe,my as Je,nb as Ye,ny as Xe,ob as Ze,oy as Qe,pb as $e,py as et,qb as tt,qv as nt,qy as rt,rb as it,ry as at,sb as ot,sy as st,t as B,tb as ct,ty as lt,ub as ut,uy as dt,vb as ft,vy as pt,wb as mt,wy as ht,xb as gt,xy as _t,yb as vt,yy as yt,zb as bt,zv as xt,zy as St}from"./api-751U81xd.js";import{t as Ct}from"./x-C9PzBTHZ.js";import{t as V}from"./button-Dwru_Lf_.js";import{$ as wt,$t as H,Ct as Tt,Dn as Et,Dt,En as Ot,G as kt,J as U,Jt as W,K as At,Mn as jt,Mt as G,Nn as K,Ot as Mt,Pn as Nt,Q as Pt,St as Ft,Tt as It,W as q,X as Lt,Y as Rt,Yt as J,Z as zt,at as Bt,b as Vt,bt as Ht,cr as Ut,ct as Wt,et as Gt,ft as Kt,it as qt,jn as Y,ot as Jt,q as Yt,sr as Xt,st as Zt,vt as Qt,wt as $t,xt as en,yt as tn}from"./index-oxINmoDf.js";import{t as nn}from"./FilterBar-DTlL2mzQ.js";import{t as rn}from"./DataTableShell-C0SV7OUi.js";import{t as X}from"./DetailChips-BeKOuUKo.js";var an=p(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Z=t(e(),1),Q=n(),on={name:``,description:``};function sn(){let e=u(B.groups.listGroups,{}),t=u(B.me.getMe,{host:Kt})?.role===`admin`,n=m(B.groups.createGroup),r=m(B.groups.updateGroup),i=m(B.groups.deleteGroup),s=Wt(),c=J(),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(on),[v,b]=(0,Z.useState)(null),[x,C]=(0,Z.useState)(``),T=(0,Z.useMemo)(()=>{if(!e)return e;let t=x.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,x]);function E(){p(null),g(on),d(!0)}function O(e){p(e),g({name:e.name,description:e.description??``}),d(!0)}async function k(){try{f?await r({groupId:f._id,name:h.name,description:h.description}):await n({name:h.name,description:h.description||void 0}),g(on),p(null),d(!1)}catch(e){c.error(be(),e)}}async function j(e){if(await s({title:a({name:e.name}),description:Ge(),confirmWord:e.name,confirmLabel:ae(),cancelLabel:w(),destructive:!0}))try{await i({groupId:e._id})}catch(e){c.error(ge(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:D()}),t?(0,Q.jsx)(pn,{}):null,(0,Q.jsx)(nn,{q:x,onQChange:C,onReset:()=>C(``),canReset:x!==``,searchPlaceholder:_e()}),(0,Q.jsx)(rn,{title:Ce(),rows:T,addLabel:tt(),onAdd:t?E:void 0,emptyHint:A(),columns:[{header:y(),cell:e=>e.name,sort:e=>e.name},{header:ye(),cell:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ot,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,Q.jsx)(K,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),e.pendingInviteCount>0?(0,Q.jsx)(W,{variant:`secondary`,children:re({count:String(e.pendingInviteCount)})}):null]}),sort:e=>e.memberCount},{header:he(),cell:e=>(0,Q.jsx)(X,{icon:(0,Q.jsx)(Nt,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:S(),cell:e=>(0,Q.jsx)(X,{icon:(0,Q.jsx)(an,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,Q.jsx)(Y,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:o(),onSelect:()=>b({groupId:e._id,name:e.name})},...t?[{label:bt(),onSelect:()=>O(e)},{label:L(),variant:`destructive`,onSelect:()=>void j(e)}]:[]]}),(0,Q.jsx)(Vt,{open:l,onOpenChange:d,title:f?oe():_(),description:ie(),canSubmit:!!h.name.trim(),onSubmit:k,submitLabel:te(),children:(0,Q.jsxs)(`div`,{className:`oc-form`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:N()}),(0,Q.jsx)(H,{value:h.name,onChange:e=>g({...h,name:e.target.value})})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:We()}),(0,Q.jsx)(H,{value:h.description,onChange:e=>g({...h,description:e.target.value})})]})]})}),(0,Q.jsx)(ln,{groupId:v?.groupId??null,groupName:v?.name??``,open:v!==null,onOpenChange:e=>{e||b(null)}})]})}var cn=8;function $({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,Q.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,Q.jsxs)(V,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,Q.jsx)(Ut,{size:14,"aria-hidden":!0}),vt()]}),(0,Q.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":Oe({page:e,pages:t}),children:[e,` / `,t]}),(0,Q.jsxs)(V,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[ft(),(0,Q.jsx)(Xt,{size:14,"aria-hidden":!0})]})]})}function ln({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=u(B.groups.getGroup,n&&e?{groupId:e}:`skip`),a=i?.viewerIsAdmin===!0,o=u(B.groups.listAssignableInstances,n&&e?{groupId:e}:`skip`),f=u(B.groups.listAssignableUsers,n&&a?{}:`skip`),p=m(B.groups.addMember),g=m(B.groups.removeMember),_=m(B.groups.bulkSetMembers),v=m(B.groups.setGroupManager),y=J(),[b,x]=(0,Z.useState)(``),[S,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(`members`),[D,O]=(0,Z.useState)(1),[A,j]=(0,Z.useState)(null),[te,ne]=(0,Z.useState)(new Set),M=(0,Z.useRef)(null),N=(0,Z.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),re=(0,Z.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),ie=(0,Z.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.restricted).map(e=>e.userId)),[i]),P=(0,Z.useMemo)(()=>new Set((i?.agents??[]).map(e=>q(e.instanceName,e.agentId))),[i]),ae=(0,Z.useMemo)(()=>{let e=(i?.agents??[]).find(e=>e.isDefault);return e?q(e.instanceName,e.agentId):null},[i]);(0,Z.useEffect)(()=>{x(``),w(``),E(`members`),O(1),j(null),M.current=null},[n,e]),(0,Z.useEffect)(()=>{O(1)},[b]),(0,Z.useEffect)(()=>{n&&i&&e&&M.current!==e&&(M.current=e,ne(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let F=(0,Z.useMemo)(()=>f?Yt(f,b,te):[],[f,b,te]);async function oe(t,n){if(e)try{n?await g({groupId:e,userId:t}):await p({groupId:e,userId:t})}catch(e){y.error(C(),U(e))}}async function se(t,n){if(e)try{await v({groupId:e,userId:t,manager:!n})}catch(e){y.error(ee(),e)}}let I=wt(F,e=>N.has(e.userId)),ce=F.filter(e=>N.has(e.userId)).length,L=zt(F,D,cn);async function le(){if(!e||F.length===0)return;let t=F.map(e=>e.userId);try{await _({groupId:e,userIds:t,member:I!==`all`})}catch(e){y.error(C(),U(e))}}let ue=(e,t)=>(0,Q.jsxs)(V,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7`,"aria-label":l({user:t}),title:l({user:t}),onClick:()=>j({userId:e,label:t}),children:[(0,Q.jsx)(jt,{size:13,"aria-hidden":!0}),ht()]});return(0,Q.jsx)(Tt,{open:n,onOpenChange:r,children:(0,Q.jsxs)($t,{className:`oc-access`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Mt,{children:d({name:t})}),(0,Q.jsx)(It,{children:i&&!a?s():h()})]}),(0,Q.jsxs)(qt,{value:T,onValueChange:E,className:`oc-access__tabs`,children:[(0,Q.jsxs)(Jt,{className:`w-full`,children:[(0,Q.jsxs)(Zt,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Ot,{size:13,"aria-hidden":!0}),pe(),i?(0,Q.jsx)(W,{variant:`secondary`,className:`oc-access__tabcount`,children:N.size}):null]}),(0,Q.jsxs)(Zt,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Nt,{size:13,"aria-hidden":!0}),c(),i?(0,Q.jsx)(W,{variant:`secondary`,className:`oc-access__tabcount`,children:P.size}):null]}),(0,Q.jsxs)(Zt,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(an,{size:13,"aria-hidden":!0}),it(),i?(0,Q.jsx)(W,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,Q.jsx)(Bt,{value:`members`,children:i===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:z()}):a?f===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:z()}):f.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Ke()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(H,{value:b,onChange:e=>x(e.target.value),placeholder:mt(),className:`oc-access__search`}),F.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:gt()}):(0,Q.jsxs)(Q.Fragment,{children:[F.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(G,{checked:I===`all`?!0:I===`some`?`indeterminate`:!1,onCheckedChange:()=>void le(),"aria-label":R()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:R()}),(0,Q.jsxs)(W,{variant:`outline`,className:`oc-access__count`,children:[ce,` / `,F.length]})]}):null,(0,Q.jsx)(`div`,{className:`oc-access__list`,children:L.pageItems.map(e=>{let t=N.has(e.userId),n=Gt(e),r=re.has(e.userId);return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(G,{checked:t,onCheckedChange:()=>void oe(e.userId,t),"aria-label":$e({user:n.primary})}),(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,Q.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),t&&ie.has(e.userId)?(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:fe()}):null,(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:Pt(e.role)}),t?ue(e.userId,n.primary):null,(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:t?(0,Q.jsx)(V,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?rt():k(),title:r?rt():k(),onClick:()=>void se(e.userId,r),children:(0,Q.jsx)(K,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,Q.jsx)($,{page:L.page,pageCount:L.pageCount,onPage:O})]})]}):e?(0,Q.jsx)(un,{groupId:e,members:i.members,agentsButton:ue}):null}),(0,Q.jsxs)(Bt,{value:`agents`,children:[i&&!a?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:et()}):null,o===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:z()}):o.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Ne()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(H,{value:S,onChange:e=>w(e.target.value),placeholder:de(),className:`oc-access__search`}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:o.map(t=>(0,Q.jsx)(fn,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:P,defaultKey:ae,viewerIsAdmin:a,query:S},`${e}-${t._id}`))})]})]}),(0,Q.jsx)(Bt,{value:`charts`,children:(0,Q.jsx)(mn,{groupId:e})})]}),(0,Q.jsx)(dn,{groupId:e,member:A,onOpenChange:e=>{e||j(null)}})]})})}function un({groupId:e,members:t,agentsButton:n}){let r=u(B.groupInvites.listGroupInviteRequests,{groupId:e}),i=m(B.groupInvites.requestGroupInvite),a=m(B.groups.removeMember),o=Wt(),s=J(),[c,l]=(0,Z.useState)(``),[d,p]=(0,Z.useState)(1),h=zt(t,d,cn);async function _(t){t.preventDefault();let n=c.trim();if(n)try{await i({groupId:e,email:n}),l(``),s.success(v())}catch(e){s.error(se(),e)}}async function y(t,n){if(await o({title:F({user:n}),description:g({user:n}),confirmLabel:me(),cancelLabel:w(),destructive:!0}))try{await a({groupId:e,userId:t})}catch(e){s.error(C(),U(e))}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`form`,{className:`oc-access__invite`,onSubmit:e=>void _(e),children:[(0,Q.jsx)(H,{type:`email`,value:c,onChange:e=>l(e.target.value),placeholder:M(),"aria-label":St()}),(0,Q.jsxs)(V,{type:`submit`,size:`sm`,disabled:!c.trim(),children:[(0,Q.jsx)(Et,{size:14,"aria-hidden":!0}),E()]})]}),(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ue()}),t.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:_t()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:h.pageItems.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.label,children:e.label}),e.restricted?(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:fe()}):null,n(e.userId,e.label),(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:e.manager?(0,Q.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":Te(),title:Te(),children:(0,Q.jsx)(K,{size:15,"aria-hidden":!0})}):null}),(0,Q.jsx)(V,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.manager||e.lastGroup,"aria-label":F({user:e.label}),title:e.manager?f():e.lastGroup?b():F({user:e.label}),onClick:()=>void y(e.userId,e.label),children:(0,Q.jsx)(Ct,{size:14,"aria-hidden":!0})})]},e.userId))}),(0,Q.jsx)($,{page:h.page,pageCount:h.pageCount,onPage:p})]}),r!==void 0&&r.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-access__subhead`,children:P()}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:r.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,Q.jsx)(W,{variant:e.status===`pending`?`secondary`:`outline`,className:`oc-access__role`,children:Rt(e.status)})]},e._id))})]}):null]})}function dn({groupId:e,member:t,onOpenChange:n}){let i=u(B.groups.getMemberAgentSettings,e&&t?{groupId:e,userId:t.userId}:`skip`),a=m(B.groups.setMemberAgents),o=m(B.groups.setMemberDefaultAgent),s=J();async function c(e){try{await e()}catch(e){s.error(j(),e)}}let l=i?.agents??[],d=new Map(l.map(e=>[q(e.instanceName,e.agentId),e])),f=[...d.keys()],p=new Set(l.filter(e=>e.allowed).map(e=>q(e.instanceName,e.agentId)));function h(n){if(!e||!t||!i)return;let r=Lt(f,p,i.restricted,n).map(e=>{let t=d.get(e);return{instanceName:t.instanceName,agentId:t.agentId}});c(()=>a({groupId:e,userId:t.userId,agents:r}))}return(0,Q.jsx)(Tt,{open:t!==null,onOpenChange:n,children:(0,Q.jsxs)($t,{className:`oc-access`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Mt,{children:lt({user:t?.label??``})}),(0,Q.jsx)(It,{children:Le()})]}),i===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:z()}):i===null||l.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:nt()}):(0,Q.jsxs)(Q.Fragment,{children:[i.settable?null:(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:T()}),i.adminNarrowed?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:xt()}):null,i.restrictedByAdmin&&!i.viewerIsAdmin?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ne()}):null,(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,children:i.restricted?I():r()}),i.restricted?(0,Q.jsx)(V,{type:`button`,size:`sm`,variant:`outline`,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin,onClick:()=>e&&t?void c(()=>a({groupId:e,userId:t.userId,agents:null})):void 0,children:Ee()}):null]}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:l.map(n=>{let r=q(n.instanceName,n.agentId),a=n.displayName??n.agentId;return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(G,{checked:n.allowed,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin&&!n.allowed,onCheckedChange:()=>h(r),"aria-label":xe({name:a})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:a,children:a}),n.limitedByAdmin?(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:le()}):null,n.state===`deleted`?(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:He()}):null,n.allowed?n.isMemberDefault?(0,Q.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,disabled:!i.settable,"aria-label":we(),title:we(),onClick:()=>e&&t?void c(()=>o({groupId:e,userId:t.userId,agent:null})):void 0,children:(0,Q.jsx)(Y,{size:14,fill:`currentColor`})}):(0,Q.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,disabled:!i.settable,"aria-label":O(),title:O(),onClick:()=>e&&t?void c(()=>o({groupId:e,userId:t.userId,agent:{instanceName:n.instanceName,agentId:n.agentId}})):void 0,children:(0,Q.jsx)(Y,{size:14})}):null]},r)})})]})]})})}function fn({groupId:e,instanceName:t,kind:n,assigned:r,defaultKey:i,viewerIsAdmin:a,query:o}){let s=u(B.groups.listAssignableAgents,e?{instanceName:t,groupId:e}:`skip`),c=m(B.groups.assignAgentToGroup),l=m(B.groups.removeAgentFromGroup),d=m(B.groups.bulkSetGroupAgents),f=m(B.groups.claimAgentForGroup),p=m(B.groups.setGroupDefaultAgent),h=J(),[g,_]=(0,Z.useState)(1);if((0,Z.useEffect)(()=>{_(1)},[o]),!e)return null;let v=At(s?.agents??[],o),y=s?.discovery&&!s.discovery.lastPollOk,b=e=>kt({assigned:r.has(q(t,e.agentId)),claimable:e.claimable,reservedForGroup:e.reservedForGroup,enabled:e.enabled,present:e.presentInLastOk!==!1},a),x=v.filter(e=>b(e)!==`claim`),S=v.filter(e=>b(e)===`claim`);if(o.trim()&&v.length===0)return null;let C=x.filter(e=>b(e)===`toggle`&&e.presentInLastOk!==!1&&e.enabled!==!1),w=wt(C,e=>r.has(q(t,e.agentId))),T=zt(x,g,cn);async function E(n,r){try{r?await l({groupId:e,instanceName:t,agentId:n}):await c({groupId:e,instanceName:t,agentId:n})}catch(e){h.error(ve(),U(e))}}async function D(){if(C.length===0)return;let n=C.map(e=>e.agentId);try{await d({groupId:e,instanceName:t,agentIds:n,assigned:w!==`all`})}catch(e){h.error(ve(),U(e))}}async function O(n){try{await f({groupId:e,instanceName:t,agentId:n})}catch(e){h.error(Pe(),e)}}async function k(n){try{await p({groupId:e,agent:n===null?null:{instanceName:t,agentId:n}})}catch(e){h.error(Xe(),e)}}let A=e=>e.reservedForGroup?(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:st()}):e.reserved?(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:e.reservedGroupName===null?je():Qe({group:e.reservedGroupName})}):null;return(0,Q.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Q.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Q.jsx)(Nt,{size:13,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__kind`,children:n}),y?(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__stale`,children:Ae()}):null]}),s===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ut()}):v.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:y?Ze():ot()}):(0,Q.jsxs)(Q.Fragment,{children:[C.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(G,{checked:w===`all`?!0:w===`some`?`indeterminate`:!1,onCheckedChange:()=>void D(),"aria-label":R()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:R()})]}):null,T.pageItems.map(e=>{let n=q(t,e.agentId),a=r.has(n),o=e.presentInLastOk===!1,s=b(e)===`locked`;return(0,Q.jsxs)(`div`,{className:`oc-access__row${s?` is-disabled`:``}`,children:[(0,Q.jsx)(G,{checked:a,disabled:s&&!a,onCheckedChange:()=>void E(e.agentId,a),"aria-label":Re({name:e.displayName??e.agentId})}),(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,A(e),o?(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:He()}):null,a?i===n?(0,Q.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,"aria-label":Ue(),title:Ue(),onClick:()=>void k(null),children:(0,Q.jsx)(Y,{size:14,fill:`currentColor`})}):(0,Q.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":at(),title:at(),onClick:()=>void k(e.agentId),children:(0,Q.jsx)(Y,{size:14})}):null]},e.agentId)}),(0,Q.jsx)($,{page:T.page,pageCount:T.pageCount,onPage:_}),S.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-access__subhead`,children:ze()}),(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Fe()}),S.map(e=>{let t=e.displayName??e.agentId;return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:t,children:[e.emoji?`${e.emoji} `:``,t]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,(0,Q.jsx)(V,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,"aria-label":qe({name:t}),onClick:()=>void O(e.agentId),children:dt()})]},e.agentId)})]}):null]})]})}function pn(){let e=u(B.groupInvites.listPendingInviteRequests,{}),t=m(B.groupInvites.decideGroupInvite),n=J();if(e===void 0||e.length===0)return null;async function r(e,r){try{await t({requestId:e,approve:r})}catch(e){n.error(Je(),e)}}return(0,Q.jsxs)(`section`,{className:`oc-invites`,"aria-label":Me(),children:[(0,Q.jsxs)(`h3`,{className:`oc-invites__title`,children:[(0,Q.jsx)(Et,{size:14,"aria-hidden":!0}),Me(),(0,Q.jsx)(W,{variant:`secondary`,children:e.length})]}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,Q.jsxs)(`span`,{className:`oc-access__sub`,children:[e.groupName??`?`,` ·`,` `,yt({by:e.requestedBy})]})]}),e.account===`ready`?null:(0,Q.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:e.account===`none`?Be():Ve()}),(0,Q.jsx)(V,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,disabled:e.account!==`ready`,onClick:()=>void r(e._id,!0),children:pt()}),(0,Q.jsx)(V,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>void r(e._id,!1),children:ke()})]},e._id))})]})}function mn({groupId:e}){let t=u(B.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=m(B.charts.assignChartToGroup),r=m(B.charts.removeChartFromGroup),a=m(B.charts.setGroupDefaultChart),o=m(B.charts.addChartToGroupPool),s=m(B.charts.removeChartFromGroupPool),c=J();if(!e)return null;if(t===void 0)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:z()});let{pool:l,addable:d,canManagePool:f}=t;if(l.length===0&&!f)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Ye()});async function p(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){c.error(x(),e)}}async function h(t){try{await a({groupId:e,chartKey:t})}catch(e){c.error(x(),e)}}async function g(t){try{await o({groupId:e,chartKey:t})}catch(e){c.error(x(),e)}}async function _(t){try{await s({groupId:e,chartKey:t})}catch(e){c.error(x(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:l.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(G,{checked:e.selected,onCheckedChange:()=>void p(e.chartKey,e.selected),"aria-label":ce({name:e.name})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":De(),title:De(),children:(0,Q.jsx)(Y,{size:14,fill:`currentColor`})}):(0,Q.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void h(e.chartKey),children:Se()}):null,f?(0,Q.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":i({name:e.name}),title:i({name:e.name}),onClick:()=>void _(e.chartKey),children:(0,Q.jsx)(Ct,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),f?d.length>0?(0,Q.jsxs)(Qt,{value:``,onValueChange:e=>void g(e),children:[(0,Q.jsx)(en,{size:`sm`,className:`oc-access__search`,children:(0,Q.jsx)(Ft,{placeholder:Ie()})}),(0,Q.jsx)(tn,{children:d.map(e=>(0,Q.jsx)(Ht,{value:e.chartKey,children:e.name},e.chartKey))})]}):l.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ct()}):null:null]})}export{sn as GroupsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,$P as i,$a as a,A as o,AP as s,BN as c,BP as l,CF as u,CH as d,CP as f,D as p,DF as m,DP as h,DY as g,EF as _,EP as v,EY as y,F as b,FN as x,FP as S,Fp as C,Fv as w,GN as T,GP as E,HN as D,HP as O,IN as ee,IP as te,Ip as ne,JN as re,JP as ie,KN as ae,KP as oe,LN as se,LP as ce,Lp as le,M as ue,MN as de,MP as fe,N as pe,NN as me,NP as he,Nv as ge,O as _e,OP as ve,P as ye,PN as be,PP as xe,Pp as Se,Pv as Ce,QN as we,QP as Te,Qa as Ee,RN as De,RP as Oe,SF as ke,SH as Ae,SP as je,TF as Me,TP as Ne,UN as Pe,UP as k,VN as Fe,VP as Ie,WN as Le,WP as A,XN as Re,XP as ze,YN as Be,YP as Ve,ZN as He,ZP as Ue,Za as We,_F as Ge,_P as Ke,aF as qe,aP as Je,ao as Ye,bF as Xe,bP as Ze,cF as Qe,cP as j,cn as $e,co as et,dF as tt,dP as nt,dn as rt,do as it,eF as at,eP as ot,eo as st,fF as ct,fP as lt,fn as ut,fo as dt,gF as ft,gP as pt,gn as mt,hF as ht,hP as gt,hn as _t,iF as vt,iP as yt,io as bt,iu as xt,j as St,jP as Ct,k as wt,kP as Tt,lF as Et,lP as Dt,ln as Ot,lo as kt,mF as At,mP as jt,mn as Mt,nF as Nt,nP as Pt,no as Ft,nu as It,oF as Lt,oP as Rt,oo as zt,pF as Bt,pP as Vt,pn as Ht,po as Ut,qN as Wt,qP as Gt,rF as Kt,rP as qt,ro as Jt,ru as Yt,sF as Xt,sn as Zt,so as Qt,t as M,tF as $t,tP as en,to as tn,uF as nn,uP as rn,un as an,uo as on,vF as sn,vP as cn,vk as ln,wF as un,wP as dn,wY as N,xF as fn,xP as pn,yF as mn,yP as hn,yk as gn,zN as _n,zP as vn}from"./api-751U81xd.js";import{a as yn,c as bn}from"./FieldLabel-vvQixe9u.js";import{t as P}from"./button-Dwru_Lf_.js";import{$t as F,Ct as I,Dt as L,J as R,Jt as z,Mt as B,Ot as V,St as H,Tt as U,Yt as W,b as xn,bt as G,cn as Sn,ct as Cn,on as wn,sn as Tn,vt as K,wt as En,xt as q,yt as J}from"./index-oxINmoDf.js";import{t as Dn}from"./DataTableShell-C0SV7OUi.js";import{InstanceConfigDialog as On}from"./BridgeTab-CbhPweRj.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],kn=new Set(X),An=`conversational`;function jn(e){let t=new Set((e??[]).filter(e=>kn.has(e)));return t.size===0?[An]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,participantIdentity:`owner`,managePermissionModes:!1,systemIdentity:``,streamTransport:yn,widgetsEnabled:!0,widgetPromptConfirm:!1},Mn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Nn(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,authMode:e.authMode??`token`,personScopes:e.personScopes??`capped`,identitySource:e.identitySource??`canonical`,participantIdentity:e.participantIdentity??`owner`,managePermissionModes:e.managePermissionModes===!0,systemIdentity:e.systemIdentity??``,streamTransport:e.streamTransport??`reactive`,widgetsEnabled:e.config?.widgetsEnabled!==!1,widgetPromptConfirm:e.config?.widgetPromptConfirm===!0}}function Pn(){let e=g(M.admin.listInstances,{}),t=g(M.agents.listAllInstanceAgents,{}),n=y(M.admin.upsertInstance),r=y(M.widgets.setInstanceWidgets),s=y(M.admin.deleteInstance),c=W(),[l,d]=(0,Y.useState)(!1),[f,h]=(0,Y.useState)(Q),[v,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(null);async function O(){try{let t=await n({instanceId:E??void 0,name:f.name,gatewayUrl:f.gatewayUrl,bridgeUrl:f.bridgeUrl||void 0,displayName:f.displayName||void 0,kind:f.kind,transport:f.kind===`hermes`?f.transport:void 0,gatewayVersion:f.gatewayVersion||void 0,gatewayHttpUrl:f.gatewayHttpUrl||void 0,...f.kind===`openclaw`?{authMode:f.authMode,personScopes:f.personScopes,identitySource:f.identitySource,participantIdentity:f.participantIdentity,managePermissionModes:f.managePermissionModes,systemIdentity:f.systemIdentity||void 0}:{},streamTransport:f.streamTransport}),i=E===null?null:e?.find(e=>e._id===E),a=i?.config?.widgetsEnabled!==!1,o=i?.config?.widgetPromptConfirm===!0;f.kind===`openclaw`&&(f.widgetsEnabled!==a||f.widgetPromptConfirm!==o)&&await r({instanceId:t,enabled:f.widgetsEnabled,promptConfirm:f.widgetPromptConfirm}),h(Q),D(null),d(!1)}catch(e){c.error(Me(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[un(),(0,Z.jsx)(`strong`,{children:u()}),ke()]}),(0,Z.jsx)(Dn,{title:fn(),rows:e,addLabel:Xe(),onAdd:()=>{D(null),h(Q),d(!0)},emptyHint:mn(),columns:[{header:sn(),cell:e=>e.name,sort:e=>e.name},{header:Ge(),cell:e=>(0,Z.jsx)(z,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:ft(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:ht(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:m(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(z,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?_n():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:tt(),onSelect:()=>{D(e._id),h(Nn(e)),d(!0)}},{label:_(),onSelect:()=>x(e.name)},{label:ze(),onSelect:()=>T(e)},{label:At(),onSelect:()=>C(e)},{label:Bt(),variant:`destructive`,onSelect:()=>void s({instanceId:e._id})}],bulkActions:[{label:Bt(),variant:`destructive`,onSelect:e=>e.forEach(e=>void s({instanceId:e}))}]}),(0,Z.jsx)(xn,{open:l,onOpenChange:d,title:E?nn():ct(),description:Qe(),canSubmit:!!(f.name&&f.gatewayUrl),onSubmit:O,submitLabel:Xt(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:Lt(),children:[(0,Z.jsx)(F,{value:f.name,disabled:E!==null,onChange:e=>h({...f,name:e.target.value})}),E?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Et()}):null]}),(0,Z.jsx)($,{label:qe(),children:(0,Z.jsxs)(K,{value:f.kind,onValueChange:e=>h({...f,kind:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(G,{value:`hermes`,children:`Hermes`})]})]})}),f.kind===`hermes`?(0,Z.jsx)($,{label:xt(),children:(0,Z.jsxs)(K,{value:f.transport,onValueChange:e=>h({...f,transport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`ws`,children:Yt()}),(0,Z.jsx)(G,{value:`rest`,children:It()})]})]})}):null,(0,Z.jsx)($,{label:vt(),children:(0,Z.jsx)(F,{value:f.gatewayUrl,onChange:e=>h({...f,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:Kt(),children:(0,Z.jsx)(F,{value:f.bridgeUrl,placeholder:Nt(),onChange:e=>h({...f,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:$t(),children:(0,Z.jsx)(F,{value:f.displayName,onChange:e=>h({...f,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:gn(),children:[(0,Z.jsxs)(K,{value:f.streamTransport,onValueChange:e=>h({...f,streamTransport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsx)(J,{children:bn.map(e=>(0,Z.jsx)(G,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ln()})]}),(0,Z.jsx)($,{label:at(),children:(0,Z.jsx)(F,{value:f.gatewayVersion,placeholder:i(),onChange:e=>h({...f,gatewayVersion:e.target.value})})}),f.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:Jt(),children:[(0,Z.jsxs)(K,{value:f.authMode,onValueChange:e=>h({...f,authMode:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`token`,children:Ft()}),(0,Z.jsx)(G,{value:`trusted-proxy`,children:tn()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.authMode===`trusted-proxy`?a():st()})]}),f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Ut(),children:[(0,Z.jsxs)(K,{value:f.personScopes,onValueChange:e=>h({...f,personScopes:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`capped`,children:dt()}),(0,Z.jsx)(G,{value:`full`,children:it()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.personScopes===`full`?kt():on()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:et(),children:[(0,Z.jsxs)(K,{value:f.identitySource,onValueChange:e=>h({...f,identitySource:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`canonical`,children:Qt()}),(0,Z.jsx)(G,{value:`email`,children:zt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.identitySource===`email`?bt():Ye()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:mt(),children:[(0,Z.jsxs)(K,{value:f.participantIdentity,onValueChange:e=>h({...f,participantIdentity:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`owner`,children:_t()}),(0,Z.jsx)(G,{value:`self`,children:Mt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.participantIdentity===`self`?Zt():Ht()})]}):null,f.kind===`openclaw`?(0,Z.jsxs)($,{label:ut(),children:[(0,Z.jsxs)(K,{value:f.managePermissionModes?`on`:`off`,onValueChange:e=>h({...f,managePermissionModes:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:rt()}),(0,Z.jsx)(G,{value:`on`,children:an()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.managePermissionModes?$e():Ot()})]}):null,f.kind===`openclaw`?(0,Z.jsxs)($,{label:b(),children:[(0,Z.jsxs)(K,{value:f.widgetsEnabled?`on`:`off`,onValueChange:e=>h({...f,widgetsEnabled:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`on`,children:ye()}),(0,Z.jsx)(G,{value:`off`,children:pe()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.widgetsEnabled?ue():St()})]}):null,f.kind===`openclaw`&&f.widgetsEnabled?(0,Z.jsxs)($,{label:o(),children:[(0,Z.jsxs)(K,{value:f.widgetPromptConfirm?`on`:`off`,onValueChange:e=>h({...f,widgetPromptConfirm:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:wt()}),(0,Z.jsx)(G,{value:`on`,children:_e()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:p()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:Ee(),children:(0,Z.jsx)(F,{value:f.systemIdentity,placeholder:We(),onChange:e=>h({...f,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:Te(),children:(0,Z.jsx)(F,{value:f.gatewayHttpUrl,placeholder:Ue(),onChange:e=>h({...f,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Wn,{instanceName:v,open:v!==null,onOpenChange:e=>{e||x(null)}}),S?(0,Z.jsx)(On,{instance:S,onClose:()=>C(null)},S._id):null,w?(0,Z.jsx)(Fn,{instance:w,onClose:()=>T(null)},w._id):null]})}function Fn({instance:e,onClose:t}){let n=g(M.instanceSecrets.listInstanceSecretStatus,{}),r=Mn[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(I,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(En,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(L,{children:[(0,Z.jsx)(V,{children:Ve({instance:e.displayName??e.name})}),(0,Z.jsx)(U,{children:ie()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Rn,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Ln,{instance:e})}),(0,Z.jsx)(In,{instance:e})]})})}function In({instance:e}){let t=N(M.instanceSync.forceInstanceSync),n=W(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(ve());break;case`no_agents`:n.success(v());break;case`no_bridge_url`:n.error(Ne());break;case`deploy_misconfigured`:n.error(dn());break;case`unauthorized`:n.error(je());break;case`not_served`:n.error(pn());break;default:n.error(f());break}}catch(e){n.error(h(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ze()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?Tt():s()})})]})}function Ln({instance:e}){let t=g(M.bridgeAuth.listBridgeAuthStatus,{}),n=N(M.bridgeAuth.mintBridgeSecret),r=y(M.bridgeAuth.revokeBridgeSecret),i=W(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),p=f!==void 0;async function m(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),u(!1)}catch(e){i.error(Vt(),e)}finally{o(!1)}}}async function h(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(jt())}catch(e){i.error(Vt(),e)}finally{o(!1)}}}async function _(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:hn(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:cn()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(z,{variant:p?`outline`:`secondary`,children:p?`${A()} · ${f.prefix}…${f.lastFour}`:k()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void m(),disabled:a,children:p?pt():Ke()}),p?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void h(),disabled:a,children:gt()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:lt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void _(),children:l?d():Ae()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:nt()})]}):null]})}function Rn({instanceId:e,field:t,updatedAt:n}){let r=N(M.instanceSecrets.setInstanceSecret),i=y(M.instanceSecrets.clearInstanceSecret),a=N(M.deviceIdentity.generateDeviceIdentity),o=W(),[s,c]=(0,Y.useState)(``),[u,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),_=n!==null,v=t===`deviceIdentity`,b=t===`token`?Gt():t===`deviceIdentity`?oe():E();async function x(){if(!(!s.trim()||u)){f(!0);try{await r({instanceId:e,field:t,plaintext:s}),c(``),m(null),g(!1),o.success(Oe())}catch(e){o.error(ce(),e)}finally{f(!1)}}}async function C(){if(!u){f(!0);try{await i({instanceId:e,field:t}),m(null),g(!1),o.success(te())}catch(e){o.error(ce(),e)}finally{f(!1)}}}async function w(){if(!u){f(!0);try{m(await a({instanceId:e})),g(!1),o.success(he())}catch(e){o.error(Ct(),e)}finally{f(!1)}}}let T=p?`openclaw devices approve ${p.id}`:``;async function D(){if(T)try{await navigator.clipboard.writeText(T),g(!0)}catch{}}return(0,Z.jsxs)($,{label:b,children:[v?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:xe()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(z,{variant:_?`outline`:`secondary`,children:_?A():k()}),(0,Z.jsx)(F,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:_?Ie():O(),onChange:e=>c(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void x(),disabled:u||s.trim().length===0,children:l()}),v?(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void w(),disabled:u,children:S()}):null,_?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void C(),disabled:u,children:vn()}):null]})]}),p?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:he()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:fe()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:T}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void D(),children:h?d():Ae()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{m(null),g(!1)},children:nt()})]}):null]})}var zn={conversational:ot,documentary:we,summarizer:le,curator:C},Bn={conversational:r,documentary:He,summarizer:ne,curator:Se},Vn=e=>(zn[e]??(()=>e))(),Hn=e=>(Bn[e]??(()=>``))();function Un({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:yt()}),t.map(e=>(0,Z.jsx)(z,{variant:`secondary`,className:`oc-agenttype__chip`,title:Hn(e),children:Vn(e)},e)),(0,Z.jsxs)(wn,{children:[(0,Z.jsx)(Sn,{asChild:!0,children:(0,Z.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:qt()})}),(0,Z.jsxs)(Tn,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:Pt()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:en()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(B,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Vn(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Hn(r)})]})]},r)})})]})]})]})}function Wn({instanceName:e,open:t,onOpenChange:n}){let r=g(M.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=y(M.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=y(M.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=y(M.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=jn(r);e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),s=y(M.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),l=y(M.agents.removeInstanceAgent),u=y(M.agents.setAgentReservation),d=g(M.groups.listGroupLabels,t?{}:`skip`),f=Cn(),p=W();async function m(t,n){if(e&&await f({title:x({name:n}),description:be(),confirmLabel:ee()}))try{await u({instanceName:e,agentId:t,groupId:null})}catch(e){p.error(j(),R(e))}}async function h(t,n,r){if(!e)return;let i=(d??[]).find(e=>e._id===r)?.name??`?`;if(await f({title:w({name:n,group:i}),description:Ce({group:i}),confirmLabel:ge()}))try{await u({instanceName:e,agentId:t,groupId:r})}catch(e){p.error(j(),R(e))}}async function _(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){p.error(j(),e)}}async function v(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){p.error(j(),e)}}async function b(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){p.error(j(),e)}}async function S(t,n){if(e&&await f({title:re({name:n}),description:Wt(),confirmLabel:ae(),destructive:!0}))try{await l({instanceName:e,agentId:t}),p.success(T())}catch(e){p.error(j(),e)}}return(0,Z.jsx)(I,{open:t,onOpenChange:n,children:(0,Z.jsxs)(En,{className:`oc-access`,children:[(0,Z.jsxs)(L,{children:[(0,Z.jsx)(V,{children:rn({name:e??``})}),(0,Z.jsx)(U,{children:Dt()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:Le()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?Pe():r.discovery.lastPollOk?D():Fe({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:c()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,i=r.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(B,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void _(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,t.reserved?(0,Z.jsx)(z,{variant:`outline`,children:t.reserved.groupName===null?se():De({group:t.reserved.groupName})}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(z,{variant:`outline`,className:`oc-access__gone`,children:de()}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void S(t.agentId,a),children:Be()})]}):i?(0,Z.jsx)(z,{variant:`default`,children:_n()}):(0,Z.jsx)(P,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled||t.reserved!==null,onClick:()=>void v(t.agentId),children:Re()})]}),t.reserved?(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(P,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>void m(t.agentId,a),children:ee()}),(0,Z.jsxs)(K,{value:``,onValueChange:e=>void h(t.agentId,a,e),children:[(0,Z.jsx)(q,{size:`sm`,className:`h-7`,children:(0,Z.jsx)(H,{placeholder:me()})}),(0,Z.jsx)(J,{children:(d??[]).filter(e=>e._id!==t.reserved?.groupId).map(e=>(0,Z.jsx)(G,{value:e._id,children:e.name},e._id))})]})]}):null,t.enabled?(0,Z.jsx)(Un,{agentId:t.agentId,types:o,onToggle:e=>void b(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Gn,{value:t.description??``,onSave:async n=>{if(e)try{await s({instanceName:e,agentId:t.agentId,description:n})}catch(e){p.error(j(),e)}}}):null]},t.agentId)})})]})]})})}function Gn({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(F,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Rt(),"aria-label":Je(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Pn as InstancesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$m as r,DY as i,EY as a,Qm as o,Xm as s,Zm as c,_L as l,aL as u,cL as d,dL as f,eh as p,fL as m,gL as h,hL as g,ih as _,lL as v,mL as y,nh as b,oL as x,pL as S,rh as C,sL as w,t as T,th as E,uL as D,vL as O,wY as k}from"./api-751U81xd.js";import{t as A}from"./button-Dwru_Lf_.js";import{$t as j,Jt as M,Mt as N}from"./index-oxINmoDf.js";var P=t(e(),1),F=n();function I(){let e=i(T.integrations.status.status,{}),t=a(T.admin.setIntegrationConfig),[n,r]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&r(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:O()});let o=n,s=(e,t,n)=>r({...o,[e]:{...o[e],[t]:n}}),c=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[l(),` `,(0,F.jsx)(`strong`,{children:h()}),` `,g()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(M,{variant:`secondary`,children:y()}):(0,F.jsx)(M,{variant:`outline`,children:S()}):(0,F.jsx)(M,{variant:`outline`,children:m()}),note:f(),children:[(0,F.jsx)(R,{label:v(),children:(0,F.jsx)(j,{value:o.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>s(`langfuse`,`host`,e.target.value),onBlur:()=>c(`langfuse`,{host:o.langfuse.host??``})})}),(0,F.jsx)(z,{label:u(),checked:o.langfuse.enabled??!0,onChange:e=>{s(`langfuse`,`enabled`,e),c(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(M,{variant:`secondary`,children:y()}):(0,F.jsx)(M,{variant:`outline`,children:S()}):(0,F.jsx)(M,{variant:`outline`,children:m()}),note:D(),children:[(0,F.jsx)(R,{label:d(),children:(0,F.jsx)(j,{value:o.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>s(`opik`,`baseUrl`,e.target.value),onBlur:()=>c(`opik`,{baseUrl:o.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:w(),children:(0,F.jsx)(j,{value:o.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||x(),onChange:e=>s(`opik`,`workspace`,e.target.value),onBlur:()=>c(`opik`,{workspace:o.opik.workspace??``})})}),(0,F.jsx)(z,{label:u(),checked:o.opik.enabled??!0,onChange:e=>{s(`opik`,`enabled`,e),c(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(M,{variant:`secondary`,children:y()}):(0,F.jsx)(M,{variant:`outline`,children:S()}):(0,F.jsx)(M,{variant:`outline`,children:_()}),note:C(),children:[(0,F.jsx)(R,{label:b(),children:(0,F.jsx)(j,{value:o.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>s(`otlp`,`endpoint`,e.target.value),onBlur:()=>c(`otlp`,{endpoint:o.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:u(),checked:o.otlp.enabled??!0,onChange:e=>{s(`otlp`,`enabled`,e),c(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(N,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=k(T.integrations.otlpSecret.setOtlpHeaders),n=a(T.integrations.otlpSecret.clearOtlpHeaders),[i,l]=(0,P.useState)(``),[u,d]=(0,P.useState)(null),[f,m]=(0,P.useState)(!1),h=async()=>{m(!0),d(null);try{await t({headersJson:i}),l(``)}catch(e){d(e instanceof Error?e.message:String(e))}finally{m(!1)}};return(0,F.jsxs)(R,{label:E(),children:[(0,F.jsx)(j,{value:i,placeholder:e?p():r(),onChange:e=>l(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:f||i.trim().length===0,onClick:()=>void h(),children:o()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void n({}),children:c()}):null]}),u?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:u}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:s()})]})}export{I as IntegrationsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AD as r,CD as i,DD as a,DY as o,ED as s,FD as c,ID as l,KL as u,MD as d,ND as f,OD as ee,OR as p,PD as m,SD as h,TD as g,eR as _,jD as te,kD as ne,nR as v,qL as y,rR as b,t as x,tR as S,wD as C}from"./api-751U81xd.js";import{dr as w,fr as T,ft as E,i as D,o as re,r as ie}from"./index-oxINmoDf.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-s0ZpJ9CV.js";import{n as N,t as P}from"./TimeRangePicker-9-aQ6g1P.js";var F=t(e(),1),I={API_CALLS:`api.calls`,API_ERRORS:`api.errors`,API_LATENCY_AVG_MS:`api.latency.avg_ms`,OPENCLAW_INGEST:`openclaw.ingest`,CHAT_SEND:`chat.send`,ASSISTANT_STREAM_ERRORS:`assistant.stream.errors`,ASSISTANT_ANNOUNCE_ERRORS:`assistant.announce.errors`,CONVEX_PROBE_LATENCY_AVG_MS:`convex.probe.latency.avg_ms`},L=Object.keys(I).length,R=n(),z=15,B=e=>String(Math.round(e));function V(){let e=o(x.me.getMe,{host:E})?.permissions?.includes(`traces.read`)??!1,t=o(x.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,F.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,z).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:p()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:b()}),(0,R.jsx)(j,{children:S()})]}),(0,R.jsx)(k,{children:n.length<2?(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,R.jsx)(H,{series:n})})]})]})}function H({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{style:{color:`var(--primary)`},children:[u(),` p50 `,B(s.cP50),` `,v()]}),(0,R.jsxs)(`span`,{children:[y(),` p50 `,B(s.aP50),` `,v()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":b(),children:[(0,R.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:l(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:c(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:m(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:f(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:d(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:te(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:r(),unit:`/h`,group:`Assistant`,isError:!0}],W=L,G=[`API`,`OpenClaw`,`Chat`,`Assistant`],K=1e3,q=36e5;function J(e,t){let n=Math.max(1,Math.ceil((t-e)/q)),r=Math.min(n*W,K);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/W))}}function ae(){let e=T({from:`/settings/kpi`}),t=w({from:`/settings/kpi`}),n=D(e.from,e.to,ie,`now`),r=e=>void t({search:t=>({...t,...re(e)})}),{from:i,to:c}=N(n),{rowLimit:l,buckets:u}=J(i,c),d=o(x.kpi.listKpis,{limit:l,filter:{from:i,to:c}}),f=(0,F.useMemo)(()=>{let e=new Map;for(let t of d??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>u&&e.set(t,n.slice(n.length-u));return e},[d,u]),p=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[ne(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:ee()})]}),(0,R.jsx)(oe,{value:n,onChange:r})]});return d===void 0?(0,R.jsxs)(R.Fragment,{children:[p,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:a()})]}):d.length===0?(0,R.jsxs)(R.Fragment,{children:[p,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:s()})]}):(0,R.jsxs)(R.Fragment,{children:[p,(0,R.jsx)(V,{}),G.map(e=>{let t=U.filter(t=>t.group===e);return t.some(e=>(f.get(e.metric)??[]).length>0)?(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,R.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,R.jsx)(Y,{config:e,series:f.get(e.metric)??[]},e.metric))})]},e):null})]})}function oe({value:e,onChange:t}){return(0,R.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,R.jsx)(P,{value:e,onChange:t})})}function Y({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,R.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,R.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,R.jsx)(`code`,{children:e.metric})})]}),(0,R.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,R.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,R.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,R.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,R.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,R.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,R.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:g({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:C()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:i({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,R.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-se,1);return(0,R.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":h({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,R.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,R.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{ae as KpiTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$J as r,$U as i,$s as a,BJ as o,BU as s,DY as c,EY as l,FU as u,GJ as d,GU as f,HJ as ee,HU as p,IU as m,JJ as h,JU as g,KJ as _,KU as te,LU as ne,QJ as re,QU as ie,Qs as ae,RU as oe,UJ as se,UU as ce,VJ as le,VU as ue,WJ as de,WU as v,XJ as fe,XU as pe,YJ as me,YU as he,ZJ as y,ZU as b,Zs as x,_W as S,_Y as C,_c as w,aW as T,aY as E,bW as D,cW as O,cY as k,dW as A,eW as j,eY as M,ec as N,fW as P,fY as F,fc as I,gW as L,hW as R,iW as ge,iY as _e,ic as ve,lW as ye,lY as be,mW as xe,nW as Se,nY as Ce,nc as we,oW as Te,oY as Ee,pW as De,qJ as Oe,qU as ke,r as z,rW as Ae,rY as je,rc as Me,sF as Ne,sW as Pe,sY as Fe,t as B,tW as Ie,tY as Le,tc as Re,uW as ze,vW as Be,vc as Ve,yW as He,zU as Ue}from"./api-751U81xd.js";import{t as V}from"./button-Dwru_Lf_.js";import{$t as H,H as We,Jt as U,Mt as W,Qt as Ge,St as Ke,Xt as qe,Yt as Je,Zt as Ye,bt as G,ft as K,t as Xe,vt as Ze,xt as Qe,yt as $e}from"./index-oxINmoDf.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-DHBtL_j_.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:z(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:z(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>D()},{id:`composer`,label:()=>He()},{id:`sidebar`,label:()=>Be()},{id:`notifications`,label:()=>Ie()},{id:`other`,label:()=>S()}],X={showSource:{category:`messages`,label:()=>L(),help:()=>R()},showReport:{category:`messages`,label:()=>xe(),help:()=>De()},copyAssistant:{category:`messages`,label:()=>P()},copyUser:{category:`messages`,label:()=>A()},showDelete:{category:`messages`,label:()=>ze()},showTools:{category:`messages`,label:()=>ye(),help:()=>O()},voiceInput:{category:`composer`,label:()=>Pe(),help:()=>Te()},showUsage:{category:`composer`,label:()=>T(),help:()=>ge()},autoReadAloud:{category:`composer`,label:()=>Ve(),help:()=>w()},showChatAge:{category:`sidebar`,label:()=>Ae(),help:()=>Se()},notifSound:{category:`notifications`,label:()=>j(),help:()=>i()},notifSystem:{category:`notifications`,label:()=>ie(),help:()=>b()},replySound:{category:`notifications`,label:()=>pe(),help:()=>he()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>Ue()};function ut({prefKey:e,ui:t}){let n=l(B.admin.setUiPrefDefault),r=l(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:ce()}),(0,J.jsxs)(Ze,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(Qe,{size:`sm`,className:`w-36`,children:(0,J.jsx)(Ke,{})}),(0,J.jsxs)($e,{children:[(0,J.jsx)(G,{value:`on`,children:ne()}),(0,J.jsx)(G,{value:`off`,children:m()}),(0,J.jsx)(G,{value:`inherit`,children:u()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(W,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":p()}),p()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=l(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Ye(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(s(!0),window.setTimeout(()=>s(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[ve(),e?(0,J.jsx)(U,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:o?Re():r?we():Me()})]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:x()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?ae():e?a():N()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=c(B.me.getMe,{host:K}),a=i?.ui,o=$(i?.role)&&n,u=l(B.me.setUiPref).withOptimisticUpdate(We),d=(0,q.useMemo)(()=>a?Q(Object.keys(a.effective),e):[],[a,e]);return a?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(W,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":v()}),v()]}):null,o?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:ue()}),(0,J.jsx)(`p`,{children:s()}),(0,J.jsx)(`p`,{children:oe()})]}):null,(0,J.jsx)(H,{value:e,onChange:e=>t(e.target.value),placeholder:g(),"aria-label":g(),className:`mb-2`}),d.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:ke()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:d.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],s=a.effective[e],c=a.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(U,{variant:`outline`,children:te()}):c?(0,J.jsx)(U,{variant:`secondary`,children:I()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&c?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void u({key:e,value:null}),children:f()}):null,(0,J.jsx)(nt,{checked:s,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),u({key:e,value:t})},"aria-label":n})]}),o?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:C()})}var pt={sm:()=>y(),md:()=>fe(),lg:()=>me(),xl:()=>h(),"2xl":()=>Oe(),"3xl":()=>_()};function mt(){let e=c(B.me.getMe,{host:K}),t=l(B.me.setLocale),n=l(B.me.setTimezone),i=l(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:K});n&&e.setQuery(B.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),a=l(B.me.setMyName),s=Je(),u=e?.locale??`default`,f=e?.name??``,[p,m]=(0,q.useState)(null),h=p??f,g=h.trim()!==f.trim();async function _(){try{await a({name:h}),m(null),s.success(E())}catch(e){s.error(_e(),e)}}return(0,J.jsxs)(`div`,{className:`oc-appearance`,children:[(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:be()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:k()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(H,{className:`max-w-xs`,value:h,maxLength:120,placeholder:Fe(),onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g&&(e.preventDefault(),_())}}),(0,J.jsx)(V,{size:`sm`,disabled:!g,onClick:()=>void _(),children:Ne()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ee()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:je()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ce()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:u===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:u==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:F()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Le()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:d()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:de()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,J.jsx)(V,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:se()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ee()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:M()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:r()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:Xe.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void i({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:re()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:le()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:o()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$E as r,$T as i,AE as a,BE as o,CE as s,DE as c,DY as l,E as u,EE as d,EY as f,FE as p,IE as m,KE as h,LE as g,ME as _,OE as ee,PE as v,QE as y,QT as te,RE as b,SE as ne,TE as x,To as re,UE as ie,WE as ae,XE as oe,XT as se,YE as ce,ZT as le,_E as ue,_Y as de,aD as fe,aE as S,bE as pe,dE as me,eE as he,fE as C,gE as ge,gT as _e,iD as ve,jE as w,kE as T,mE as E,nE as D,oC as ye,pE as be,rD as xe,rE as O,sE as Se,t as k,tE as Ce,vE as A,wE as j,wo as we,xE as Te,yE as M}from"./api-751U81xd.js";import{r as Ee}from"./dist-DLQaZf47.js";import{t as De}from"./list-ClmCB0j4.js";import{t as N}from"./button-Dwru_Lf_.js";import{$n as Oe,$t as P,A as ke,An as Ae,Bn as je,C as F,D as Me,E as Ne,Gn as Pe,I as Fe,Kn as Ie,M as Le,N as Re,O as ze,P as I,Qn as Be,S as Ve,T as He,Un as L,Vn as Ue,Xn as R,Yt as We,Zn as Ge,_ as Ke,_t as qe,an as Je,b as Ye,ct as Xe,d as Ze,dr as z,en as Qe,er as $e,f as et,fr as tt,g as nt,gt as B,h as rt,ht as V,in as it,j as H,k as at,lt as ot,mt as st,nn as U,p as ct,pr as W,pt as lt,rn as ut,sr as dt,tn as ft,tr as pt,v as G,w as K,x as q,y as mt,zn as ht}from"./index-oxINmoDf.js";var gt=u(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),_t=u(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),vt=u(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),J=u(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Y=t(e(),1),X=n();function yt({className:e}){return(0,X.jsx)(Je,{asChild:!0,children:(0,X.jsx)(N,{variant:`ghost`,size:`icon-xs`,"aria-label":O(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,X.jsx)(pt,{})})})}function Z({folderId:e,name:t,color:n,currentParentId:r,className:a,onOpen:s}){let c=f(k.projects.renameProject),u=f(k.projects.setProjectColor),d=f(k.projects.moveProject),p=f(k.projects.deleteProject),m=f(k.projects.createProject),h=Xe(),g=rt(),_=ot(),[ee,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(t),[ne,x]=(0,Y.useState)(!1),[re,oe]=(0,Y.useState)(!1),se=l(k.projects.projectTreeCount,re?{projectId:e}:`skip`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Qe,{onOpenChange:e=>e&&oe(!0),children:[(0,X.jsx)(yt,{className:a}),(0,X.jsxs)(ft,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(U,{onSelect:()=>s(),children:[(0,X.jsx)(Be,{}),` `,o()]}),(0,X.jsxs)(U,{onSelect:()=>{b(t),v(!0)},children:[(0,X.jsx)(Ue,{}),` `,D()]}),(0,X.jsxs)(U,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await _({title:w(),label:fe(),placeholder:ve(),confirmLabel:xe()});t&&await m({name:t,parentId:e})})},children:[(0,X.jsx)(Ge,{}),` `,w()]}),(0,X.jsxs)(U,{onSelect:()=>x(!0),children:[(0,X.jsx)(_t,{}),` `,be()]}),(0,X.jsx)(ut,{children:i()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void u({projectId:e,color:null}),"aria-label":te(),children:`✕`}),Ke.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void u({projectId:e,color:t.value})},t.value))]}),(0,X.jsx)(it,{}),(0,X.jsxs)(U,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=se?.folders??0,r=se?.chats??0;await h({title:ie({name:t}),description:ct({folders:n,chats:r,days:g}),confirmWord:S(),confirmLabel:ae(),destructive:!0})&&await p({projectId:e})})},children:[(0,X.jsx)(Ae,{}),` `,S()]})]})]}),(0,X.jsx)(Ye,{open:ee,onOpenChange:v,title:ce(),canSubmit:y.trim().length>0,onSubmit:async()=>{await c({projectId:e,name:y.trim()}),v(!1)},submitLabel:D(),children:(0,X.jsx)(P,{value:y,onChange:e=>b(e.target.value),autoFocus:!0})}),ne?(0,X.jsx)(nt,{open:ne,onOpenChange:x,title:me(),movingFolderId:e,currentId:r,onPick:t=>void d({projectId:e,parentId:t})}):null]})}function bt({chat:e,currentFolderId:t,className:n}){let r=f(k.chats.pinChat),i=f(k.chats.deleteChat),a=f(k.chats.renameChat),o=f(k.chats.setChatSidebar),s=f(k.chats.moveChatToProject),c=Xe(),l=rt(),[u,d]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(e.title??``),[h,_]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Qe,{children:[(0,X.jsx)(yt,{className:n}),(0,X.jsxs)(ft,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(U,{onSelect:()=>{m(e.title??``),d(!0)},children:[(0,X.jsx)(Ue,{}),` `,D()]}),(0,X.jsxs)(U,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,X.jsx)(ht,{}):(0,X.jsx)(je,{}),e.pinned?Ce():he()]}),(0,X.jsxs)(U,{onSelect:()=>_(!0),children:[(0,X.jsx)(_t,{}),` `,E()]}),e.pinned&&e.inSidebar?null:(0,X.jsxs)(U,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,X.jsx)(L,{}):(0,X.jsx)(J,{}),e.inSidebar?g():b()]}),(0,X.jsx)(it,{}),(0,X.jsxs)(U,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await c({title:le(),description:se({days:l}),confirmLabel:S(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,X.jsx)(Ae,{}),` `,S()]})]})]}),(0,X.jsx)(Ye,{open:u,onOpenChange:d,title:_e(),canSubmit:p.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:p.trim()}),d(!1)},submitLabel:D(),children:(0,X.jsx)(P,{value:p,onChange:e=>m(e.target.value),autoFocus:!0})}),h?(0,X.jsx)(nt,{open:h,onOpenChange:_,title:C(),currentId:t,onPick:t=>void s({chatId:e._id,projectId:t})}):null]})}function xt(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function St(e,t,n,r,i){let a=e.map(t),o=a.indexOf(i);if(o<0)return null;let s=a.indexOf(r);if(s>=0){let t=[...e],[r]=t.splice(s,1);t.splice(o,0,r);let i=t[o-1],a=t[o+1];return{prevKey:i===void 0?null:n(i),nextKey:a===void 0?null:n(a)}}let c=e[o-1];return{prevKey:c===void 0?null:n(c),nextKey:n(e[o])}}function Ct(e,t){let n=new Map(t.map(e=>[e.chatId,e.lastSeenAt])),r=new Set;for(let t of e){let e=n.get(t._id);e!==void 0&&t.lastAssistantAt!==null&&t.lastAssistantAt>e&&r.add(t._id)}return r}var wt=`oc.projpage.view`;function Tt(){let e=localStorage.getItem(wt);return e===`cards`||e===`list`?e:`columns`}var Q=e=>`into:${e}`,Et=e=>`col:${e??`null`}`,Dt=e=>`crumb:${e}`;function Ot(e){if(e.startsWith(`into:`))return e.slice(5);if(e.startsWith(`crumb:`))return e.slice(6);if(e.startsWith(`col:`)){let t=e.slice(4);return t===`null`?null:t}}function kt(){let{projectId:e}=W({from:`/project/$projectId`}),t=z(),n=l(k.projects.projectPage,{projectId:e});return(0,X.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:de()}):n===null?(0,X.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,X.jsx)(`h2`,{children:M()}),(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:A()}),(0,X.jsx)(N,{variant:`outline`,onClick:()=>void t({to:`/`}),children:ue()})]}):(0,X.jsx)(At,{page:n})})}function At({page:e}){let t=z(),n=Xe(),a=rt(),o=ot(),u=We(),h=f(k.projects.renameProject),g=f(k.projects.setProjectColor),y=f(k.projects.deleteProject),b=f(k.projects.createProject),x=f(k.projects.moveProject),se=f(k.projects.setProjectSidebar),le=f(k.chats.moveChatToProject),ue=f(k.chats.reorderChat),de=f(k.projects.reorderProject),he=l(k.projects.projectTreeCount,{projectId:e.project._id}),[C,_e]=(0,Y.useState)(Tt),T=e=>{localStorage.setItem(wt,e),_e(e)},E=l(k.projects.folderColumns,C===`columns`?{projectId:e.project._id}:`skip`),O=l(k.projects.projectTreeList,C===`list`?{projectId:e.project._id}:`skip`),{c:Ce}=tt({from:`/project/$projectId`}),A=l(k.projects.listProjects,{}),j=l(k.chatReads.myBusyChats,{}),M=(0,Y.useMemo)(()=>new Set(j??[]),[j]),{byChat:Ee}=qe(j??null),je=l(k.chatReads.myChatReads,{}),F=(0,Y.useMemo)(()=>Ct(e.chats,je??[]),[e.chats,je]),{startNewChat:I,picker:Be}=Ze(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[L,et]=(0,Y.useState)(``),[B,H]=(0,Y.useState)(!1),[W,dt]=(0,Y.useState)(e.project.name),[G,ht]=(0,Y.useState)(!1),[J,yt]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let e=setTimeout(()=>yt(L.trim()),180);return()=>clearTimeout(e)},[L]);let Z=l(k.search.searchConversations,J.length>=2?{query:J,projectId:e.project._id}:`skip`),bt=Re(Le(Me,{activationConstraint:{distance:4}}),Le(ze,{activationConstraint:{delay:250,tolerance:8}})),Q=(0,Y.useRef)(!1),Et=()=>{Q.current=!0,setTimeout(()=>{Q.current=!1},0)},[Dt,kt]=(0,Y.useState)(null),At=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),i=e.chats.find(e=>e._id===n),a=E?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(i??a)?.title||r()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(A??[]).find(t=>t._id===e)?.name??``}}return null},Nt=e=>kt(At(String(e.active.id))),$=(0,Y.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=ke(n(`into:`));if(r.length>0){if(!t)return r;let n=r[0],i=e.droppableRects.get(n.id),a=e.pointerCoordinates?.y;if(i&&a!=null){let e=i.height*.3;if(a>i.top+e&&a<i.top+i.height-e)return r}}let i=ke(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=ke(n(`crumb:`));if(a.length>0)return a;let o=ke(n(`col:`));return o.length>0?o:at(n(t?`folder:`:`chat:`))},[]),It=t=>{if(C===`columns`){for(let e of E?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(C===`list`){let e=O?.chats.find(e=>e._id===t);return e?{list:O.chats.filter(t=>t.folderId===e.folderId),folderId:e.folderId}:null}return e.chats.some(e=>e._id===t)?{list:e.chats,folderId:e.project._id}:null},Lt=t=>{if(C===`columns`){for(let e of E?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(C===`list`){let e=O?.folders.find(e=>e._id===t);if(!e||!O)return null;let n=e.parentId??O.rootId;return{list:st(O.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},zt=async e=>{kt(null),Et();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),i=String(t.id),a=i.startsWith(`chat:`);try{let e=Ot(r);if(e!==void 0){if(a)await le({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!lt(A??[],t,e)){u.error(_());return}await x({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=It(t);if(!n)return;n.list.some(t=>t._id===e)||await le({chatId:e,projectId:n.folderId});let a=St(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await ue({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Lt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!lt(A??[],e,n.parentId)){u.error(_());return}await x({projectId:e,parentId:n.parentId})}let a=St(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await de({projectId:e,...a});return}}catch{u.error(_())}},[,Bt]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{let e=window.setInterval(()=>Bt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Vt=Date.now(),Ht=mt(e.project),Ut=xt(e.chats,L),Wt=e.breadcrumb.slice(0,-1),Gt=e=>()=>{Q.current||e()};return(0,X.jsx)(V.Provider,{value:Ee,children:(0,X.jsxs)(He,{sensors:bt,collisionDetection:$,onDragStart:Nt,onDragEnd:zt,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Ht},children:[(0,X.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":ge(),children:[Wt.map(e=>(0,X.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,X.jsx)(jt,{folderId:e._id,children:(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Gt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,X.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,X.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,X.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,X.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,X.jsxs)(N,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:re(),onClick:()=>{se({projectId:e.project._id,hidden:!1})},children:[(0,X.jsx)($e,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:we()}),(0,X.jsx)(Oe,{"aria-hidden":!0})]}):null,(0,X.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":m(),children:[(0,X.jsx)(N,{variant:C===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":m(),title:m(),"aria-pressed":C===`cards`,onClick:()=>T(`cards`),children:(0,X.jsx)(vt,{})}),(0,X.jsx)(N,{variant:C===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":p(),title:p(),"aria-pressed":C===`columns`,onClick:()=>T(`columns`),children:(0,X.jsx)(gt,{})}),(0,X.jsx)(N,{variant:C===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":v(),title:v(),"aria-pressed":C===`list`,onClick:()=>T(`list`),children:(0,X.jsx)(De,{})})]}),(0,X.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>void I({projectId:e.project._id}),children:[(0,X.jsx)(Ie,{}),d()]}),(0,X.jsxs)(N,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await o({title:w(),label:fe(),placeholder:ve(),confirmLabel:xe()});t&&await b({name:t,parentId:e.project._id})},children:[(0,X.jsx)(Ge,{}),w()]}),(0,X.jsxs)(Qe,{children:[(0,X.jsx)(Je,{asChild:!0,children:(0,X.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":oe(),children:(0,X.jsx)(pt,{})})}),(0,X.jsxs)(ft,{align:`end`,className:`w-48`,children:[(0,X.jsxs)(U,{onSelect:()=>{dt(e.project.name),H(!0)},children:[(0,X.jsx)(Ue,{}),` `,D()]}),(0,X.jsxs)(U,{onSelect:()=>ht(!0),children:[(0,X.jsx)(_t,{}),` `,be()]}),(0,X.jsx)(ut,{children:i()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void g({projectId:e.project._id,color:null}),"aria-label":te(),children:`✕`}),Ke.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void g({projectId:e.project._id,color:t.value})},t.value))]}),(0,X.jsx)(it,{}),(0,X.jsxs)(U,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=he?.folders??0,o=he?.chats??0;await n({title:ie({name:e.project.name}),description:ct({folders:i,chats:o,days:a}),confirmWord:S(),confirmLabel:ae(),destructive:!0})&&(await y({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,X.jsx)(Ae,{}),` `,S()]})]})]})]})]}),C===`columns`?(0,X.jsx)(Rt,{data:E,currentId:e.project._id,busyIds:M,suppressClick:Q,locateChatId:Ce??null}):C===`list`?(0,X.jsx)(Ft,{data:O,busyIds:M,suppressClick:Q,locateChatId:Ce??null}):(0,X.jsxs)(X.Fragment,{children:[e.children.length>0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ee()}),(0,X.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,X.jsx)(q,{items:e.children.map(e=>`folder:${e._id}`),strategy:Ve,children:e.children.map(t=>(0,X.jsx)(Mt,{child:t,parentId:e.project._id,now:Vt,suppressClick:Q},t._id))})})]}):null,(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:c()}),e.chats.length>0?(0,X.jsx)(P,{value:L,onChange:e=>et(e.target.value),placeholder:s(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?Te():pe()}):Ut.length===0&&(Z??[]).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:ne({term:L.trim()})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,X.jsx)(q,{items:Ut.map(e=>`chat:${e._id}`),strategy:K,children:Ut.map(t=>(0,X.jsx)(Pt,{chat:t,currentFolderId:e.project._id,now:Vt,busy:M.has(t._id),unread:F.has(t._id),locate:t._id===Ce,suppressClick:Q},t._id))})})]}),J.length>=2&&Z!==void 0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:Se()}),Z.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:ne({term:J})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:Z.map(e=>(0,X.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&J&&Fe(e.messageId,J),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,X.jsx)(Pe,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,X.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||ye()}),e.projectPath&&e.projectPath.length>1?(0,X.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,X.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,X.jsx)(Ye,{open:B,onOpenChange:H,title:ce(),canSubmit:W.trim().length>0,onSubmit:async()=>{await h({projectId:e.project._id,name:W.trim()}),H(!1)},submitLabel:D(),children:(0,X.jsx)(P,{value:W,onChange:e=>dt(e.target.value),autoFocus:!0})}),G?(0,X.jsx)(nt,{open:G,onOpenChange:ht,title:me(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void x({projectId:e.project._id,parentId:t})}):null,Be]}),(0,X.jsx)(Ne,{children:Dt?(0,X.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Dt.kind===`folder`?(0,X.jsx)(R,{size:13,"aria-hidden":!0}):(0,X.jsx)(Pe,{size:13,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:Dt.label})]}):null})]})})}function jt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=H({id:Dt(e)});return(0,X.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Mt({child:e,parentId:t,now:n,suppressClick:r}){let i=z(),a=F({id:`folder:${e._id}`}),o=H({id:Q(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":mt(e),transform:I.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&i({to:`/project/$projectId`,params:{projectId:e._id}})},...a.listeners,...a.attributes,role:`link`,tabIndex:0,children:[(0,X.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,X.jsx)(R,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,X.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,X.jsx)(Z,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,X.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?x({count:e.folderCount})+` · `:``,j({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,X.jsx)(`span`,{className:`oc-projpage__cardage`,children:et(e.lastActivityAt,n)})]})}function Nt({chat:e}){let t=f(k.chats.setChatSidebar),n=e.inSidebar?g():b();return(0,X.jsx)(N,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,X.jsx)(L,{}):(0,X.jsx)(J,{})})}function Pt({chat:e,currentFolderId:t,now:n,busy:i,unread:a,locate:o,suppressClick:s}){let c=(0,Y.useContext)(V).get(e._id),l=z(),u=G(e.color),d=F({id:`chat:${e._id}`}),f=$(o);return(0,X.jsxs)(`li`,{ref:e=>{d.setNodeRef(e),f.current=e},className:`oc-projpage__chatrow`+(d.isDragging?` is-dragging`:``)+(o?` is-locate`:``),style:{transform:I.Transform.toString(d.transform),transition:d.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{s.current||l({to:`/chat/$chatId`,params:{chatId:e._id}})},...d.listeners,...d.attributes,children:[u?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:u}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||r()}),e.pinned?(0,X.jsx)(je,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,X.jsx)(`span`,{className:`oc-projpage__chatage`,children:et(e.updatedAt,n)}),i?(0,X.jsx)(`span`,{className:B(c,y()).className,title:B(c,y()).label,"aria-label":B(c,y()).label}):null,a&&!i?(0,X.jsx)(`span`,{className:`oc-chatitem__unread`,title:h(),"aria-label":h()}):null]}),(0,X.jsx)(Nt,{chat:e}),(0,X.jsx)(bt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function $(e){let t=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ft({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,Y.useState)(new Set),o=(0,Y.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:de()});if(e===null)return null;let s=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),c=(a,l)=>{let u=o.get(a??e.rootId)??[],d=st(e.folders,a);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{items:u.map(e=>`chat:${e._id}`),strategy:K,children:u.map(e=>(0,X.jsx)(Lt,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,X.jsx)(q,{items:d.map(e=>`folder:${e._id}`),strategy:K,children:d.map(t=>(0,X.jsx)(It,{folder:t,parentId:a??e.rootId,depth:l,folded:i.has(t._id),onToggle:()=>s(t._id),suppressClick:n,children:i.has(t._id)?null:c(t._id,l+1)},t._id))})]})};return(0,X.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&st(e.folders,null).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:Te()}):c(null,0)})}function It({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:o,children:s}){let c=z(),l=F({id:`folder:${e._id}`}),u=H({id:Q(e._id)});return(0,X.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,X.jsxs)(`div`,{ref:e=>{l.setNodeRef(e),u.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(u.isOver?` is-over`:``)+(l.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":mt(e),transform:I.Transform.toString(l.transform),transition:l.transition},...l.listeners,...l.attributes,role:`button`,tabIndex:0,onClick:()=>{o.current||c({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&c({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?a():T(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!o.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,X.jsx)(dt,{size:13}):(0,X.jsx)(Ee,{size:13})}),(0,X.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(Z,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void c({to:`/project/$projectId`,params:{projectId:e._id}})})]}),s]})}function Lt({chat:e,depth:t,busy:n,locate:i,suppressClick:a}){let o=(0,Y.useContext)(V).get(e._id),s=z(),c=F({id:`chat:${e._id}`}),l=$(i),u=G(e.color);return(0,X.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(c.isDragging?` is-dragging`:``)+(i?` is-locate`:``),style:{"--tree-depth":t,transform:I.Transform.toString(c.transform),transition:c.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{a.current||s({to:`/chat/$chatId`,params:{chatId:e._id}})},...c.listeners,...c.attributes,children:[u?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:u}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||r()}),n?(0,X.jsx)(`span`,{className:B(o,``).className,"aria-hidden":!0}):null]}),(0,X.jsx)(bt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,X.jsx)(Nt,{chat:e})]})}function Rt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:de()}):(0,X.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,X.jsx)(zt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function zt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=z(),s=H({id:Et(e.folderId)});return(0,X.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,X.jsx)(q,{items:e.folders.map(e=>`folder:${e._id}`),strategy:K,children:e.folders.map(t=>(0,X.jsx)(Bt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,X.jsx)(q,{items:e.chats.map(e=>`chat:${e._id}`),strategy:K,children:e.chats.map(t=>(0,X.jsx)(Vt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__colempty`,children:pe()}):null]})}function Bt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=F({id:`folder:${e._id}`}),o=H({id:Q(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":mt(e),transform:I.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,X.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,X.jsx)(Z,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Vt({chat:e,folderId:t,busy:n,locate:i,suppressClick:a,onOpen:o}){let s=(0,Y.useContext)(V).get(e._id),c=F({id:`chat:${e._id}`}),l=$(i),u=G(e.color);return(0,X.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(c.isDragging?` is-dragging`:``)+(i?` is-locate`:``),style:{transform:I.Transform.toString(c.transform),transition:c.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{a.current||o()},...c.listeners,...c.attributes,children:[u?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:u}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||r()}),n?(0,X.jsx)(`span`,{className:B(s,``).className,"aria-hidden":!0}):null]}),(0,X.jsx)(bt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,X.jsx)(Nt,{chat:e})]})}export{kt as ProjectPage};
@@ -1,4 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$O as r,Bd as i,Bp as a,Ck as o,DY as s,EY as c,Hp as l,Id as u,Jd as d,Ld as f,QO as p,Rd as m,Rp as h,Sk as g,Vp as _,XO as v,Xd as y,Yd as b,ZO as x,ak as S,au as C,ck as w,dk as T,ek as E,fk as ee,hk as te,ik as ne,lk as re,mk as ie,nk as ae,ok as oe,ou as se,pk as D,qd as O,rk as k,sk as A,su as j,t as M,tk as N,uk as P,xo as F,zd as I,zp as L}from"./api-751U81xd.js";import{i as R,n as z,r as B,t as V}from"./FieldLabel-vvQixe9u.js";import{t as H}from"./button-Dwru_Lf_.js";import{Mt as U,St as W,Yt as G,bt as K,ft as ce,gn as le,hn as ue,mn as de,pn as q,vt as J,xt as Y,yt as X}from"./index-oxINmoDf.js";import{r as Z,t as fe}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),me={media_delivery:{label:P,help:re},documentary_fetch:{label:w,help:A},inbound_files:{label:oe,help:S},history_summary:{label:l,help:_},file_curation:{label:y,help:i},quote_reply:{label:b,help:d}},he={outboundDir:`/home/node/.openclaw/media/outbound`,references:`- gdrive/1a2b3c4d5e6f7890abcd
2
- - gdrive/0f9e8d7c6b5a4321dcba`,files:`- /home/node/.openclaw/media/inbound/rapport.pdf (124800 o, application/pdf)`,previous_summary:`Projet Alpha : budget 40 000 EUR ; choix du serveur en cours.`,new_messages:`Utilisateur : Compare OVH et Scaleway.
3
- Assistant : Comparaison en cours.`,max_chars:`6000`,file_name:`MEMORY.md`,budget_chars:`20000`,feedback:`Trop de suppressions dans la section des liens, garde-les.`,content:`# Memory index
4
- - [Fait 1](fait-1.md) - note du projet`,excerpt:`Le classement propose trois dossiers : Clients, Fournisseurs, Interne.`},ge={outboundDir:p,references:x,files:v,previous_summary:a,new_messages:L,max_chars:h,file_name:I,budget_chars:m,feedback:f,content:u,excerpt:O};function _e(){let e=s(M.admin.listInstances,{}),[t,n]=(0,Q.useState)(null);if(e===void 0)return(0,$.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,$.jsx)(`div`,{className:`oc-injtab`,children:(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:k()})});let r=e.find(e=>e._id===t)??e[0];return(0,$.jsxs)(`div`,{className:`oc-injtab`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,$.jsx)(z,{label:te(),help:ie()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:ne()}),(0,$.jsxs)(J,{value:r._id,onValueChange:e=>n(e),children:[(0,$.jsx)(Y,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(W,{})}),(0,$.jsx)(X,{children:e.map(e=>(0,$.jsx)(K,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,$.jsx)(ve,{instance:r},r._id)]})}function ve({instance:e}){let t=c(M.admin.upsertInstanceConfig),n=G(),r=s(M.me.getMe,{host:ce}),i=e.config??{},a=Z(e.config?.contentLocale,r?.defaultLocale??void 0),[l,u]=(0,Q.useState)(()=>R(i,a));(0,Q.useEffect)(()=>{u(R(i,a))},[a,e._id]);let[d,f]=(0,Q.useState)(!1),p=l.promptInjections,m=(e,t)=>u({...l,promptInjections:{...p,[e]:{...p[e],...t}}});async function h(){f(!0);try{await t({instanceId:e._id,config:B(l,i,a)})}catch(e){n.error(g(),e)}finally{f(!1)}}async function _(r){let i={...e.config??{}};r==="default"?delete i.contentLocale:i.contentLocale=r;try{await t({instanceId:e._id,config:i})}catch(e){n.error(g(),e)}}let v=e.config?.contentLocale??`default`,y=fe[Z(void 0,r?.defaultLocale??void 0)];return(0,$.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,$.jsx)(`span`,{children:j()}),(0,$.jsxs)(J,{value:v,onValueChange:e=>void _(e),children:[(0,$.jsx)(Y,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(W,{})}),(0,$.jsxs)(X,{children:[(0,$.jsx)(K,{value:`default`,children:C({locale:y})}),pe().map(e=>(0,$.jsx)(K,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:se()})]}),de.map(e=>(0,$.jsx)(ye,{injKey:e,def:q[e],i18n:me[e],row:p[e]??{enabled:!0,template:q[e].defaultTemplate[a]},contentLocale:a,onChange:t=>m(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(H,{size:`sm`,onClick:()=>void h(),disabled:d,children:o()})})]})}function ye({injKey:e,def:t,i18n:n,row:i,contentLocale:a,onChange:o}){let[s,c]=(0,Q.useState)(!1),l=i.template.trim()!==t.defaultTemplate[a],u=t.togglable&&!i.enabled,d=Object.fromEntries(t.placeholders.map(e=>[e,he[e]??`{${e}}`])),f=ue(e,i,a),p=f?le(f,d):``;return(0,$.jsxs)(`section`,{className:`oc-injcard`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,$.jsxs)(`label`,{className:`oc-field--row`,children:[(0,$.jsx)(U,{checked:i.enabled,onCheckedChange:e=>o({enabled:e===!0})}),(0,$.jsx)(z,{label:n.label(),help:n.help()})]}):(0,$.jsx)(z,{label:n.label(),help:n.help()}),l&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:ee()})]}),(0,$.jsx)(`textarea`,{className:`oc-injcard__text`,value:i.template,disabled:u,rows:8,spellCheck:!1,onChange:e=>o({template:e.target.value})}),(0,$.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:T()}),t.placeholders.map(e=>(0,$.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,$.jsx)(`code`,{children:`{${e}}`}),(0,$.jsx)(V,{text:(ge[e]??(()=>e))()})]},e))]}),(0,$.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,$.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>c(e=>!e),children:s?N():ae()}),l&&(0,$.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>o({template:t.defaultTemplate[a]}),children:D()})]})]}),s&&(0,$.jsx)(`div`,{className:`oc-injcard__preview`,children:p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:p}),(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:E()}),t.pluralDefaultTemplate!==void 0&&!u?(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:F()}):null]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:r()})})]})}export{_e as PromptInjectionsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,AM as ee,BM as te,DM as i,DY as a,EM as o,EY as s,GM as c,HM as l,JM as ne,KM as re,MM as u,NM as d,OM as f,PM as p,QM as m,UM as h,VM as g,WM as _,XM as v,YM as y,ZM as ie,aN as b,bf as x,cN as S,dN as C,eN as ae,fN as w,gN as T,hN as E,iN as D,jM as O,kM as k,lN as A,mN as j,nN as M,oN as N,pN as P,qM as F,rN as I,sN as L,t as R,tN as oe,uN as z}from"./api-751U81xd.js";import{t as B}from"./button-Dwru_Lf_.js";import{$t as V,Jt as H,Mt as U,Yt as W,b as G,ct as K,qn as q}from"./index-oxINmoDf.js";import{t as J}from"./roleDescriptions-ex6WKrl0.js";var Y=t(e(),1),X=n(),Z=[{group:()=>T(),keys:[{key:`traces.read`,label:()=>C()},{key:`traces.read.content`,label:()=>z(),phi:!0},{key:`traces.write`,label:()=>A()}]},{group:()=>E(),keys:[{key:`kpi.read`,label:()=>C()},{key:`kpi.write`,label:()=>A()}]},{group:()=>j(),keys:[{key:`openclaw.query`,label:()=>S()},{key:`anomalies.read`,label:()=>L()},{key:`anomalies.report`,label:()=>N()}]},{group:()=>P(),keys:[{key:`chats.read`,label:()=>C()},{key:`selfheal`,label:()=>D()},{key:`media.repair`,label:()=>I()},{key:`feedback.respond`,label:()=>x()}]},{group:()=>w(),keys:[{key:`admin.manage`,label:()=>b()}]}],se=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function ce(){let e=a(R.apiKeys.listRoles,{}),t=s(R.apiKeys.createRole),n=s(R.apiKeys.ensureRolesSeeded),b=s(R.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(R.apiKeys.listRoles,{});r&&e.setQuery(R.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),x=K(),S=W(),[C,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)($),[D,A]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{S.error(oe(),e)})},[n,S]);let j=e??[];async function N(e,t){if(Q(e.permissions))return;if(e.builtin){await x({title:ae({name:e.name}),description:r(),confirmLabel:m()});return}if(D.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];A(t=>new Set(t).add(e._id));try{await b({roleId:e._id,permissions:n})}catch(e){S.error(ie(),e)}finally{A(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function P(){try{await t({key:T.key,name:T.name,description:T.description||void 0,permissions:[]}),E($),w(!1)}catch(e){S.error(v(),e)}}let I=e===void 0,L=!I&&j.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[y(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,ne(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,F()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:re()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{E($),w(!0)},children:c()})})]}),I?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):L?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:h()}):(0,X.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,X.jsxs)(`table`,{className:`oc-matrix`,children:[(0,X.jsxs)(`thead`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:l()}),Z.map(e=>(0,X.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,X.jsx)(`tr`,{children:Z.flatMap(e=>e.keys.map(e=>(0,X.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?M({key:e.key}):e.key,children:[e.label(),e.phi?(0,X.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,X.jsx)(`tbody`,{children:j.map(e=>{let t=Q(e.permissions),n=D.has(e._id);return(0,X.jsxs)(`tr`,{children:[(0,X.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,X.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,X.jsx)(`span`,{children:e.name}),(0,X.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,X.jsxs)(H,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(q,{}),` `,g()]}):(0,X.jsx)(H,{variant:`secondary`,children:te()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),se.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(U,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?p():n?d():r,onCheckedChange:()=>void N(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(G,{open:C,onOpenChange:w,title:u(),description:O(),canSubmit:!!(T.key&&T.name),onSubmit:P,submitLabel:ee(),children:(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:k()}),(0,X.jsx)(V,{value:T.key,placeholder:f(),onChange:e=>E({...T,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:i()}),(0,X.jsx)(V,{value:T.name,onChange:e=>E({...T,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:o()}),(0,X.jsx)(V,{value:T.description,onChange:e=>E({...T,description:e.target.value})})]})]})})]})}export{ce as RolesTab};