@lacneu/atrium 0.11.0 → 0.11.1

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 (32) hide show
  1. package/dist/assets/{AccessTab-BgfZsfNr.js → AccessTab-CdyF1j7K.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-BHDc_Mha.js → AdvancedFilter-0hIaeD_5.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-DSPXqfOM.js → AgentFilesTab-BcyT_Ep9.js} +1 -1
  4. package/dist/assets/{AnomaliesTab-4g_AnyLu.js → AnomaliesTab-D8uOqg5K.js} +1 -1
  5. package/dist/assets/{AuditTab-CkPlBQRT.js → AuditTab-C-N4POzp.js} +1 -1
  6. package/dist/assets/{BridgeTab-BYYayIJU.js → BridgeTab-DwwnrXwF.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-C1ld4NBa.js → ChatDefaultsTab-hdfiXKvr.js} +1 -1
  8. package/dist/assets/{DataTableShell-D_G9F2EP.js → DataTableShell-B_P8ehdH.js} +1 -1
  9. package/dist/assets/{DetailChips-HmAlB_yt.js → DetailChips-DccwdoeS.js} +1 -1
  10. package/dist/assets/{FeedbacksTab-C_uUMTSv.js → FeedbacksTab-BKfLDVev.js} +1 -1
  11. package/dist/assets/{FieldLabel-CUj6dNrs.js → FieldLabel-CtF9VFJv.js} +1 -1
  12. package/dist/assets/{FilesTab-BFMU8erL.js → FilesTab-C0sB2U_I.js} +1 -1
  13. package/dist/assets/{FilterBar-B_NTOVaW.js → FilterBar-BmFEn3qs.js} +1 -1
  14. package/dist/assets/{GroupsTab-CdYeoYBE.js → GroupsTab-SlcsoVZV.js} +1 -1
  15. package/dist/assets/{InstancesTab-Dkc2Fe6L.js → InstancesTab-D4d7ISJ6.js} +1 -1
  16. package/dist/assets/{IntegrationsTab-DuOC5fWh.js → IntegrationsTab-BCXFK88J.js} +1 -1
  17. package/dist/assets/{KpiTab-C5oeAjTK.js → KpiTab-DNfNa6Oo.js} +1 -1
  18. package/dist/assets/{PreferencesTab-DuHg9Syi.js → PreferencesTab-CUiAii9X.js} +1 -1
  19. package/dist/assets/{PromptInjectionsTab-CB-1bh5C.js → PromptInjectionsTab-Dncvuu7j.js} +1 -1
  20. package/dist/assets/{RolesTab-Pf9vwOs8.js → RolesTab-Cieo--3o.js} +1 -1
  21. package/dist/assets/{ServiceAccountsTab-BJdu3AyM.js → ServiceAccountsTab-DrIUUd8f.js} +1 -1
  22. package/dist/assets/{ThemeShowroom-BU8IBnxU.js → ThemeShowroom-BPEHKIyD.js} +1 -1
  23. package/dist/assets/{TimeRangePicker-CW3Y_mIF.js → TimeRangePicker-BDN2rIcO.js} +1 -1
  24. package/dist/assets/{TracesTab-BOR4V9ff.js → TracesTab-C1P-cd2o.js} +1 -1
  25. package/dist/assets/{UsersTab-ByY5HbmY.js → UsersTab-dqn0iQJZ.js} +1 -1
  26. package/dist/assets/{highlighted-body-OFNGDK62-qhyRliwG.js → highlighted-body-OFNGDK62-whVEKGek.js} +1 -1
  27. package/dist/assets/index-Bp-uQn4K.js +226 -0
  28. package/dist/assets/mermaid-GHXKKRXX-Dg9-NNvT.js +1 -0
  29. package/dist/index.html +1 -1
  30. package/package.json +1 -1
  31. package/dist/assets/index-D2h8Mdp2.js +0 -226
  32. package/dist/assets/mermaid-GHXKKRXX-B7ZmJyV2.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bo as r,Fo as i,Ho as a,Io as o,Lo as s,Mo as c,No as l,Po as u,Ro as d,Uo as f,Vo as p,Wo as m,_w as h,jo as g,uw as _,zo as v}from"./dist-ws-D-Lv-.js";import{n as y,t as b}from"./TimeRangePicker-CW3Y_mIF.js";import{Ot as x,a as S,kt as C,n as w,r as T}from"./index-D2h8Mdp2.js";import{a as E,n as D,o as O,r as k,t as A}from"./card-CWLBezSK.js";var j=t(e(),1),M=n(),N=[{metric:`api.calls`,label:m(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:f(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:a(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:p(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:r(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:v(),unit:`/h`,group:`Assistant`,isError:!0}],P=N.length,F=[`API`,`OpenClaw`,`Chat`,`Assistant`],I=1e3,L=36e5;function R(e,t){let n=Math.max(1,Math.ceil((t-e)/L)),r=Math.min(n*P,I);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/P))}}function z(){let e=C({from:`/settings/kpi`}),t=x({from:`/settings/kpi`}),n=T(e.from,e.to,w,`now`),r=e=>void t({search:t=>({...t,...S(e)})}),{from:a,to:c}=y(n),{rowLimit:l,buckets:u}=R(a,c),f=h(_.kpi.listKpis,{limit:l,filter:{from:a,to:c}}),p=(0,j.useMemo)(()=>{let e=new Map;for(let t of f??[]){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},[f,u]),m=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`p`,{className:`oc-admin__hint`,children:[d(),` `,(0,M.jsx)(`span`,{className:`oc-filter__window`,children:s()})]}),(0,M.jsx)(B,{value:n,onChange:r})]});return f===void 0?(0,M.jsxs)(M.Fragment,{children:[m,(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:o()})]}):f.length===0?(0,M.jsxs)(M.Fragment,{children:[m,(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:i()})]}):(0,M.jsxs)(M.Fragment,{children:[m,F.map(e=>{let t=N.filter(t=>t.group===e);return t.some(e=>(p.get(e.metric)??[]).length>0)?(0,M.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,M.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,M.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,M.jsx)(V,{config:e,series:p.get(e.metric)??[]},e.metric))})]},e):null})]})}function B({value:e,onChange:t}){return(0,M.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,M.jsx)(b,{value:e,onChange:t})})}function V({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,M.jsxs)(A,{size:`sm`,className:`oc-kpi__card`,children:[(0,M.jsxs)(E,{children:[(0,M.jsx)(O,{className:`oc-kpi__card-title`,children:e.label}),(0,M.jsx)(k,{className:`oc-kpi__card-metric`,children:(0,M.jsx)(`code`,{children:e.metric})})]}),(0,M.jsxs)(D,{className:`oc-kpi__card-body`,children:[(0,M.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,M.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:K(r)}),(0,M.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,M.jsx)(G,{series:t,isError:e.isError,unit:e.unit}),(0,M.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,M.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:u({value:q(n.bucket)})}):(0,M.jsx)(`span`,{className:`oc-kpi__muted`,children:l()}),(0,M.jsx)(`span`,{className:`oc-kpi__muted`,children:c({count:t.length})})]})]})]})}var H=240,U=48,W=1;function G({series:e,isError:t,unit:n}){if(e.length===0)return(0,M.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=H/e.length,a=Math.max(i-W,1);return(0,M.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${H} ${U}`,preserveAspectRatio:`none`,role:`img`,"aria-label":g({max:K(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(U-1):0,c=o*i,l=U-s;return(0,M.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,M.jsxs)(`title`,{children:[q(e.bucket),` · `,K(e.value),` `,n]})},e.bucket)})})}function K(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function q(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{z as KpiTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bo as r,Fo as i,Ho as a,Io as o,Lo as s,Mo as c,No as l,Po as u,Ro as d,Uo as f,Vo as p,Wo as m,_w as h,jo as g,uw as _,zo as v}from"./dist-ws-D-Lv-.js";import{n as y,t as b}from"./TimeRangePicker-BDN2rIcO.js";import{Ot as x,a as S,kt as C,n as w,r as T}from"./index-Bp-uQn4K.js";import{a as E,n as D,o as O,r as k,t as A}from"./card-CWLBezSK.js";var j=t(e(),1),M=n(),N=[{metric:`api.calls`,label:m(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:f(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:a(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:p(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:r(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:v(),unit:`/h`,group:`Assistant`,isError:!0}],P=N.length,F=[`API`,`OpenClaw`,`Chat`,`Assistant`],I=1e3,L=36e5;function R(e,t){let n=Math.max(1,Math.ceil((t-e)/L)),r=Math.min(n*P,I);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/P))}}function z(){let e=C({from:`/settings/kpi`}),t=x({from:`/settings/kpi`}),n=T(e.from,e.to,w,`now`),r=e=>void t({search:t=>({...t,...S(e)})}),{from:a,to:c}=y(n),{rowLimit:l,buckets:u}=R(a,c),f=h(_.kpi.listKpis,{limit:l,filter:{from:a,to:c}}),p=(0,j.useMemo)(()=>{let e=new Map;for(let t of f??[]){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},[f,u]),m=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`p`,{className:`oc-admin__hint`,children:[d(),` `,(0,M.jsx)(`span`,{className:`oc-filter__window`,children:s()})]}),(0,M.jsx)(B,{value:n,onChange:r})]});return f===void 0?(0,M.jsxs)(M.Fragment,{children:[m,(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:o()})]}):f.length===0?(0,M.jsxs)(M.Fragment,{children:[m,(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:i()})]}):(0,M.jsxs)(M.Fragment,{children:[m,F.map(e=>{let t=N.filter(t=>t.group===e);return t.some(e=>(p.get(e.metric)??[]).length>0)?(0,M.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,M.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,M.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,M.jsx)(V,{config:e,series:p.get(e.metric)??[]},e.metric))})]},e):null})]})}function B({value:e,onChange:t}){return(0,M.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,M.jsx)(b,{value:e,onChange:t})})}function V({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,M.jsxs)(A,{size:`sm`,className:`oc-kpi__card`,children:[(0,M.jsxs)(E,{children:[(0,M.jsx)(O,{className:`oc-kpi__card-title`,children:e.label}),(0,M.jsx)(k,{className:`oc-kpi__card-metric`,children:(0,M.jsx)(`code`,{children:e.metric})})]}),(0,M.jsxs)(D,{className:`oc-kpi__card-body`,children:[(0,M.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,M.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:K(r)}),(0,M.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,M.jsx)(G,{series:t,isError:e.isError,unit:e.unit}),(0,M.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,M.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:u({value:q(n.bucket)})}):(0,M.jsx)(`span`,{className:`oc-kpi__muted`,children:l()}),(0,M.jsx)(`span`,{className:`oc-kpi__muted`,children:c({count:t.length})})]})]})]})}var H=240,U=48,W=1;function G({series:e,isError:t,unit:n}){if(e.length===0)return(0,M.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=H/e.length,a=Math.max(i-W,1);return(0,M.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${H} ${U}`,preserveAspectRatio:`none`,role:`img`,"aria-label":g({max:K(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(U-1):0,c=o*i,l=U-s;return(0,M.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,M.jsxs)(`title`,{children:[q(e.bucket),` · `,K(e.value),` `,n]})},e.bucket)})})}function K(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function q(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{z as KpiTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$b as r,Ab as i,Bb as a,CC as o,DC as s,EC as c,Fb as l,Gb as u,Hb as d,Ib as f,Jb as p,Kb as m,LC as ee,Lb as h,MC as g,Mb as _,Nb as v,OC as te,Pb as ne,Qb as re,Rb as ie,SC as ae,TC as oe,Ub as se,Vb as ce,Wb as y,Xb as le,Yb as ue,Zb as de,_C as fe,_w as b,ax as x,bC as S,cx as C,ex as w,gw as T,ix as E,jb as D,kC as O,lx as k,nx as A,ox as j,qb as M,rx as N,sx as P,tx as F,uw as I,vC as L,wC as R,xC as z,yC as B,zb as V,zp as pe}from"./dist-ws-D-Lv-.js";import{t as H}from"./button-DuXPa4Vl.js";import{C as me,J as U,O as W,S as he,b as ge,j as _e,k as ve,ot as G,x as K,y as ye}from"./index-D2h8Mdp2.js";var q=t(e(),1),J=[{id:`messages`,label:()=>k()},{id:`composer`,label:()=>C()},{id:`sidebar`,label:()=>P()},{id:`other`,label:()=>j()}],Y={showSource:{category:`messages`,label:()=>x(),help:()=>E()},showReport:{category:`messages`,label:()=>N(),help:()=>A()},copyAssistant:{category:`messages`,label:()=>F()},copyUser:{category:`messages`,label:()=>w()},showDelete:{category:`messages`,label:()=>r()},showTools:{category:`messages`,label:()=>re(),help:()=>de()},voiceInput:{category:`composer`,label:()=>le(),help:()=>ue()},showChatAge:{category:`sidebar`,label:()=>p(),help:()=>M()},showChatProvider:{category:`sidebar`,label:()=>m(),help:()=>u()}};function X(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function be(e,t){let n=X(t.trim()),r=new Map(J.map(e=>[e.id,e.label()])),i=new Map(J.map(e=>[e.id,[]]));for(let t of e){let e=Y[t],a=e?.category??`other`;n&&!X(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return J.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var xe=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showChatProvider`],Se={voiceInput:`voiceInput`};function Ce(e){return xe.includes(e)}function Z(e){return e===`admin`}function we(e){return e===!0?`on`:e===!1?`off`:`inherit`}function Q(e){return e===`on`?!0:e===`off`?!1:null}function Te(e){return Ce(e)?Se[e]:void 0}var $=n(),Ee={voiceInput:()=>ne()};function De({prefKey:e,ui:t}){let n=T(I.admin.setUiPrefDefault),r=T(I.admin.setFeatureEnabled),a=Te(e),o=a?Ee[e]?.():void 0;return(0,$.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,$.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,$.jsx)(`span`,{className:`oc-prefs__gov-label`,children:ie()}),(0,$.jsxs)(ye,{value:we(t.defaults[e]),onValueChange:t=>void n({key:e,value:Q(t)}),children:[(0,$.jsx)(he,{size:`sm`,className:`w-36`,children:(0,$.jsx)(me,{})}),(0,$.jsxs)(ge,{children:[(0,$.jsx)(K,{value:`on`,children:_()}),(0,$.jsx)(K,{value:`off`,children:D()}),(0,$.jsx)(K,{value:`inherit`,children:i()})]})]}),a?(0,$.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,$.jsx)(W,{checked:t.featuresEnabled[a]===!0,onCheckedChange:e=>void r({key:a,enabled:e===!0}),"aria-label":h()}),h()]}):null]}),o?(0,$.jsx)(`span`,{className:`oc-prefs__gov-help`,children:o}):null]})}function Oe(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=b(I.me.getMe,{host:G}),o=i?.ui,s=Z(i?.role)&&n,c=T(I.me.setUiPref).withOptimisticUpdate(ve),u=(0,q.useMemo)(()=>o?be(Object.keys(o.effective),e):[],[o,e]);return o?(0,$.jsxs)(`div`,{className:`oc-prefs-panel`,children:[Z(i?.role)?(0,$.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,$.jsx)(W,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":V()}),V()]}):null,s?(0,$.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,$.jsx)(`p`,{children:f()}),(0,$.jsx)(`p`,{children:l()}),(0,$.jsx)(`p`,{children:v()})]}):null,(0,$.jsx)(U,{value:e,onChange:e=>t(e.target.value),placeholder:y(),"aria-label":y(),className:`mb-2`}),u.length===0?(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:se()}):(0,$.jsx)(`div`,{className:`oc-prefs`,children:u.map(e=>(0,$.jsxs)(`div`,{className:`oc-prefs__group`,children:[(0,$.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=Y[e],n=t?t.label():e,r=t?.help?.(),i=o.locked[e],l=o.effective[e],u=o.userOverrides[e]!==void 0;return(0,$.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}${u&&!i?` is-overridden`:``}`,children:[(0,$.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,$.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,$.jsx)(`span`,{className:`oc-prefs__lock`,children:d()}):u?null:(0,$.jsx)(`span`,{className:`oc-prefs__def`,children:ce()})]}),r?(0,$.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,$.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&u?(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void c({key:e,value:null}),children:a()}):null,(0,$.jsx)(W,{checked:l,disabled:i,onCheckedChange:t=>void c({key:e,value:t===!0}),"aria-label":n})]}),s?(0,$.jsx)(De,{prefKey:e,ui:o}):null]},e)})]},e.id))})]}):(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:ee()})}function ke(){let e=b(I.me.getMe,{host:G}),t=T(I.me.setLocale),n=T(I.me.setMyName),r=_e(),i=e?.locale??`default`,a=e?.name??``,[l,u]=(0,q.useState)(null),d=l??a,f=d.trim()!==a.trim();async function p(){try{await n({name:d}),u(null),r.success(oe())}catch(e){r.error(R(),e)}}return(0,$.jsxs)(`div`,{className:`oc-appearance`,children:[(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:O()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:te()})]}),(0,$.jsxs)(`div`,{className:`oc-show__row`,children:[(0,$.jsx)(U,{className:`max-w-xs`,value:d,maxLength:120,placeholder:s(),onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f&&(e.preventDefault(),p())}}),(0,$.jsx)(H,{size:`sm`,disabled:!f,onClick:()=>void p(),children:pe()})]}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:c()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:o()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:ae()})]}),(0,$.jsx)(`div`,{className:`oc-show__row`,children:[`fr`,`en`,`default`].map(e=>(0,$.jsx)(H,{variant:i===e?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e==="default"?null:e}),children:e===`fr`?L():e===`en`?fe():g()},e))}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:z()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:S()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:B()})]}),(0,$.jsx)(Oe,{})]})]})}export{ke as PreferencesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$b as r,Ab as i,Bb as a,CC as o,DC as s,EC as c,Fb as l,Gb as u,Hb as d,Ib as f,Jb as p,Kb as m,LC as ee,Lb as h,MC as g,Mb as _,Nb as v,OC as te,Pb as ne,Qb as re,Rb as ie,SC as ae,TC as oe,Ub as se,Vb as ce,Wb as y,Xb as le,Yb as ue,Zb as de,_C as fe,_w as b,ax as x,bC as S,cx as C,ex as w,gw as T,ix as E,jb as D,kC as O,lx as k,nx as A,ox as j,qb as M,rx as N,sx as P,tx as F,uw as I,vC as L,wC as R,xC as z,yC as B,zb as V,zp as pe}from"./dist-ws-D-Lv-.js";import{t as H}from"./button-DuXPa4Vl.js";import{C as me,J as U,O as W,S as he,b as ge,j as _e,k as ve,ot as G,x as K,y as ye}from"./index-Bp-uQn4K.js";var q=t(e(),1),J=[{id:`messages`,label:()=>k()},{id:`composer`,label:()=>C()},{id:`sidebar`,label:()=>P()},{id:`other`,label:()=>j()}],Y={showSource:{category:`messages`,label:()=>x(),help:()=>E()},showReport:{category:`messages`,label:()=>N(),help:()=>A()},copyAssistant:{category:`messages`,label:()=>F()},copyUser:{category:`messages`,label:()=>w()},showDelete:{category:`messages`,label:()=>r()},showTools:{category:`messages`,label:()=>re(),help:()=>de()},voiceInput:{category:`composer`,label:()=>le(),help:()=>ue()},showChatAge:{category:`sidebar`,label:()=>p(),help:()=>M()},showChatProvider:{category:`sidebar`,label:()=>m(),help:()=>u()}};function X(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function be(e,t){let n=X(t.trim()),r=new Map(J.map(e=>[e.id,e.label()])),i=new Map(J.map(e=>[e.id,[]]));for(let t of e){let e=Y[t],a=e?.category??`other`;n&&!X(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return J.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var xe=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showChatProvider`],Se={voiceInput:`voiceInput`};function Ce(e){return xe.includes(e)}function Z(e){return e===`admin`}function we(e){return e===!0?`on`:e===!1?`off`:`inherit`}function Q(e){return e===`on`?!0:e===`off`?!1:null}function Te(e){return Ce(e)?Se[e]:void 0}var $=n(),Ee={voiceInput:()=>ne()};function De({prefKey:e,ui:t}){let n=T(I.admin.setUiPrefDefault),r=T(I.admin.setFeatureEnabled),a=Te(e),o=a?Ee[e]?.():void 0;return(0,$.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,$.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,$.jsx)(`span`,{className:`oc-prefs__gov-label`,children:ie()}),(0,$.jsxs)(ye,{value:we(t.defaults[e]),onValueChange:t=>void n({key:e,value:Q(t)}),children:[(0,$.jsx)(he,{size:`sm`,className:`w-36`,children:(0,$.jsx)(me,{})}),(0,$.jsxs)(ge,{children:[(0,$.jsx)(K,{value:`on`,children:_()}),(0,$.jsx)(K,{value:`off`,children:D()}),(0,$.jsx)(K,{value:`inherit`,children:i()})]})]}),a?(0,$.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,$.jsx)(W,{checked:t.featuresEnabled[a]===!0,onCheckedChange:e=>void r({key:a,enabled:e===!0}),"aria-label":h()}),h()]}):null]}),o?(0,$.jsx)(`span`,{className:`oc-prefs__gov-help`,children:o}):null]})}function Oe(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=b(I.me.getMe,{host:G}),o=i?.ui,s=Z(i?.role)&&n,c=T(I.me.setUiPref).withOptimisticUpdate(ve),u=(0,q.useMemo)(()=>o?be(Object.keys(o.effective),e):[],[o,e]);return o?(0,$.jsxs)(`div`,{className:`oc-prefs-panel`,children:[Z(i?.role)?(0,$.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,$.jsx)(W,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":V()}),V()]}):null,s?(0,$.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,$.jsx)(`p`,{children:f()}),(0,$.jsx)(`p`,{children:l()}),(0,$.jsx)(`p`,{children:v()})]}):null,(0,$.jsx)(U,{value:e,onChange:e=>t(e.target.value),placeholder:y(),"aria-label":y(),className:`mb-2`}),u.length===0?(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:se()}):(0,$.jsx)(`div`,{className:`oc-prefs`,children:u.map(e=>(0,$.jsxs)(`div`,{className:`oc-prefs__group`,children:[(0,$.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=Y[e],n=t?t.label():e,r=t?.help?.(),i=o.locked[e],l=o.effective[e],u=o.userOverrides[e]!==void 0;return(0,$.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}${u&&!i?` is-overridden`:``}`,children:[(0,$.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,$.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,$.jsx)(`span`,{className:`oc-prefs__lock`,children:d()}):u?null:(0,$.jsx)(`span`,{className:`oc-prefs__def`,children:ce()})]}),r?(0,$.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,$.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&u?(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void c({key:e,value:null}),children:a()}):null,(0,$.jsx)(W,{checked:l,disabled:i,onCheckedChange:t=>void c({key:e,value:t===!0}),"aria-label":n})]}),s?(0,$.jsx)(De,{prefKey:e,ui:o}):null]},e)})]},e.id))})]}):(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:ee()})}function ke(){let e=b(I.me.getMe,{host:G}),t=T(I.me.setLocale),n=T(I.me.setMyName),r=_e(),i=e?.locale??`default`,a=e?.name??``,[l,u]=(0,q.useState)(null),d=l??a,f=d.trim()!==a.trim();async function p(){try{await n({name:d}),u(null),r.success(oe())}catch(e){r.error(R(),e)}}return(0,$.jsxs)(`div`,{className:`oc-appearance`,children:[(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:O()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:te()})]}),(0,$.jsxs)(`div`,{className:`oc-show__row`,children:[(0,$.jsx)(U,{className:`max-w-xs`,value:d,maxLength:120,placeholder:s(),onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f&&(e.preventDefault(),p())}}),(0,$.jsx)(H,{size:`sm`,disabled:!f,onClick:()=>void p(),children:pe()})]}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:c()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:o()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:ae()})]}),(0,$.jsx)(`div`,{className:`oc-show__row`,children:[`fr`,`en`,`default`].map(e=>(0,$.jsx)(H,{variant:i===e?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e==="default"?null:e}),children:e===`fr`?L():e===`en`?fe():g()},e))}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:z()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:S()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:B()})]}),(0,$.jsx)(Oe,{})]})]})}export{ke as PreferencesTab};
@@ -1,2 +1,2 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$s as r,Js as i,Qs as a,Xs as o,Ys as s,Zs as c,_w as l,ac as u,bc as d,cc as f,dc as p,ec as m,fc as h,gw as g,ic as _,lc as v,nc as y,oc as b,qs as x,rc as S,sc as C,tc as w,uc as T,uw as E,yc as D}from"./dist-ws-D-Lv-.js";import{d as O,f as k,i as A,l as j,n as M,r as N,t as P,u as F}from"./FieldLabel-CUj6dNrs.js";import{t as I}from"./button-DuXPa4Vl.js";import{C as L,O as R,S as z,b as B,j as V,x as H,y as U}from"./index-D2h8Mdp2.js";/* empty css */var W=t(e(),1),G=n(),K={media_delivery:{label:C,help:b},documentary_fetch:{label:u,help:_},inbound_files:{label:S,help:y}},q={outboundDir:`/home/node/.openclaw/media/outbound`,references:`- gdrive/1a2b3c4d5e6f7890abcd
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$s as r,Js as i,Qs as a,Xs as o,Ys as s,Zs as c,_w as l,ac as u,bc as d,cc as f,dc as p,ec as m,fc as h,gw as g,ic as _,lc as v,nc as y,oc as b,qs as x,rc as S,sc as C,tc as w,uc as T,uw as E,yc as D}from"./dist-ws-D-Lv-.js";import{d as O,f as k,i as A,l as j,n as M,r as N,t as P,u as F}from"./FieldLabel-CtF9VFJv.js";import{t as I}from"./button-DuXPa4Vl.js";import{C as L,O as R,S as z,b as B,j as V,x as H,y as U}from"./index-Bp-uQn4K.js";/* empty css */var W=t(e(),1),G=n(),K={media_delivery:{label:C,help:b},documentary_fetch:{label:u,help:_},inbound_files:{label:S,help:y}},q={outboundDir:`/home/node/.openclaw/media/outbound`,references:`- gdrive/1a2b3c4d5e6f7890abcd
2
2
  - gdrive/0f9e8d7c6b5a4321dcba`,files:`- /home/node/.openclaw/media/inbound/rapport.pdf (124800 o, application/pdf)`},J={outboundDir:s,references:i,files:x};function Y(){let e=l(E.admin.listInstances,{}),[t,n]=(0,W.useState)(null);if(e===void 0)return(0,G.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,G.jsx)(`div`,{className:`oc-injtab`,children:(0,G.jsx)(`p`,{className:`oc-admin__hint`,children:m()})});let r=e.find(e=>e._id===t)??e[0];return(0,G.jsxs)(`div`,{className:`oc-injtab`,children:[(0,G.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,G.jsx)(M,{label:h(),help:p()}),(0,G.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,G.jsx)(`span`,{children:w()}),(0,G.jsxs)(U,{value:r._id,onValueChange:e=>n(e),children:[(0,G.jsx)(z,{size:`sm`,className:`min-w-44`,children:(0,G.jsx)(L,{})}),(0,G.jsx)(B,{children:e.map(e=>(0,G.jsx)(H,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,G.jsx)(X,{instance:r},r._id)]})}function X({instance:e}){let t=g(E.admin.upsertInstanceConfig),n=V(),r=e.config??{},[i,a]=(0,W.useState)(()=>A(r)),[o,s]=(0,W.useState)(!1),c=i.promptInjections,l=(e,t)=>a({...i,promptInjections:{...c,[e]:{...c[e],...t}}});async function u(){s(!0);try{await t({instanceId:e._id,config:N(i,r)})}catch(e){n.error(D(),e)}finally{s(!1)}}return(0,G.jsxs)(`div`,{className:`oc-injtab__body`,children:[F.map(e=>(0,G.jsx)(Z,{injKey:e,def:j[e],i18n:K[e],row:c[e]??{enabled:!0,template:j[e].defaultTemplate},onChange:t=>l(e,t)},e)),(0,G.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,G.jsx)(I,{size:`sm`,onClick:()=>void u(),disabled:o,children:d()})})]})}function Z({injKey:e,def:t,i18n:n,row:i,onChange:s}){let[l,u]=(0,W.useState)(!1),d=i.template.trim()!==t.defaultTemplate,p=t.togglable&&!i.enabled,m=Object.fromEntries(t.placeholders.map(e=>[e,q[e]??`{${e}}`])),h=O(e,i),g=h?k(h,m):``;return(0,G.jsxs)(`section`,{className:`oc-injcard`,children:[(0,G.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,G.jsxs)(`label`,{className:`oc-field--row`,children:[(0,G.jsx)(R,{checked:i.enabled,onCheckedChange:e=>s({enabled:e===!0})}),(0,G.jsx)(M,{label:n.label(),help:n.help()})]}):(0,G.jsx)(M,{label:n.label(),help:n.help()}),d&&(0,G.jsx)(`span`,{className:`oc-injection__badge`,children:v()})]}),(0,G.jsx)(`textarea`,{className:`oc-injcard__text`,value:i.template,disabled:p,rows:8,spellCheck:!1,onChange:e=>s({template:e.target.value})}),(0,G.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,G.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,G.jsx)(`span`,{className:`oc-injection__ph`,children:f()}),t.placeholders.map(e=>(0,G.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,G.jsx)(`code`,{children:`{${e}}`}),(0,G.jsx)(P,{text:(J[e]??(()=>e))()})]},e))]}),(0,G.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,G.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>u(e=>!e),children:l?a():r()}),d&&(0,G.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>s({template:t.defaultTemplate}),children:T()})]})]}),l&&(0,G.jsx)(`div`,{className:`oc-injcard__preview`,children:g?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:g}),(0,G.jsx)(`span`,{className:`oc-injection__ph`,children:c()})]}):(0,G.jsx)(`span`,{className:`oc-injection__ph`,children:o()})})]})}export{Y as PromptInjectionsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,Ad as i,Bd as ee,Fd as a,Gd as o,Hd as te,Id as ne,Jd as s,Kd as c,Ld as l,Md as u,Nd as d,Od as f,Pd as p,Qd as m,Rd as h,Sd as g,Ud as _,Vd as v,Wd as y,Xd as b,Yd as x,Zd as S,_d as re,_w as ie,bd as C,ef as w,gd as T,gw as E,hd as D,jd as O,kd as k,md as A,nf as j,qd as M,rf as N,tf as P,uw as F,vd as I,xd as L,yd as R,zd as ae}from"./dist-ws-D-Lv-.js";import{t as z}from"./button-DuXPa4Vl.js";import{J as B,M as V,O as H,h as U,j as W,m as G,xt as K}from"./index-D2h8Mdp2.js";import{t as q}from"./roleDescriptions-KrB9-er6.js";var J=t(e(),1),Y=n(),X=[{group:()=>N(),keys:[{key:`traces.read`,label:()=>m()},{key:`traces.read.content`,label:()=>S(),phi:!0},{key:`traces.write`,label:()=>b()}]},{group:()=>j(),keys:[{key:`kpi.read`,label:()=>m()},{key:`kpi.write`,label:()=>b()}]},{group:()=>P(),keys:[{key:`openclaw.query`,label:()=>x()},{key:`anomalies.read`,label:()=>s()},{key:`anomalies.report`,label:()=>M()}]},{group:()=>w(),keys:[{key:`chats.read`,label:()=>m()},{key:`selfheal`,label:()=>o()}]},{group:()=>r(),keys:[{key:`admin.manage`,label:()=>c()}]}],oe=X.flatMap(e=>e.keys.map(e=>e.key));function Z(e){return e.includes(`*`)}var Q={key:``,name:``,description:``};function $(){let e=ie(F.apiKeys.listRoles,{}),t=E(F.apiKeys.createRole),n=E(F.apiKeys.ensureRolesSeeded),r=E(F.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(F.apiKeys.listRoles,{});r&&e.setQuery(F.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),o=V(),s=W(),[c,m]=(0,J.useState)(!1),[b,x]=(0,J.useState)(Q),[S,w]=(0,J.useState)(new Set);(0,J.useEffect)(()=>{n({}).catch(e=>{s.error(_(),e)})},[n,s]);let j=e??[];async function M(e,t){if(Z(e.permissions)||S.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];if(!(e.builtin&&!await o({title:te({name:e.name}),description:v(),confirmLabel:ee()}))){w(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){s.error(ae(),e)}finally{w(t=>{let n=new Set(t);return n.delete(e._id),n})}}}async function N(){try{await t({key:b.key,name:b.name,description:b.description||void 0,permissions:[]}),x(Q),m(!1)}catch(e){s.error(h(),e)}}let P=e===void 0,$=!P&&j.length===0;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[l(),` `,(0,Y.jsx)(`code`,{children:`admin`}),` `,ne(),` `,(0,Y.jsx)(`code`,{children:`traces.read.content`}),` `,a()]}),(0,Y.jsxs)(`div`,{className:`oc-dt`,children:[(0,Y.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,Y.jsx)(`h2`,{className:`oc-dt__title`,children:p()}),(0,Y.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,Y.jsx)(z,{size:`sm`,onClick:()=>{x(Q),m(!0)},children:d()})})]}),P?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):$?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:O()}):(0,Y.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,Y.jsxs)(`table`,{className:`oc-matrix`,children:[(0,Y.jsxs)(`thead`,{children:[(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:i()}),X.map(e=>(0,Y.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,Y.jsx)(`tr`,{children:X.flatMap(e=>e.keys.map(e=>(0,Y.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?y({key:e.key}):e.key,children:[e.label(),e.phi?(0,Y.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,Y.jsx)(`tbody`,{children:j.map(e=>{let t=Z(e.permissions),n=S.has(e._id);return(0,Y.jsxs)(`tr`,{children:[(0,Y.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,Y.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,Y.jsx)(`span`,{children:e.name}),(0,Y.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,Y.jsxs)(G,{variant:`outline`,className:`gap-1`,children:[(0,Y.jsx)(K,{}),` `,k()]}):(0,Y.jsx)(G,{variant:`secondary`,children:f()})]}),q(e)?(0,Y.jsx)(`p`,{className:`oc-matrix__roledesc`,children:q(e)}):null]}),oe.map(r=>(0,Y.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,Y.jsx)(H,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?g():n?L():r,onCheckedChange:()=>void M(e,r)})},r))]},e.key)})})]})})]}),(0,Y.jsx)(U,{open:c,onOpenChange:m,title:C(),description:R(),canSubmit:!!(b.key&&b.name),onSubmit:N,submitLabel:I(),children:(0,Y.jsxs)(`div`,{className:`oc-form`,children:[(0,Y.jsxs)(`label`,{className:`oc-field`,children:[(0,Y.jsx)(`span`,{className:`oc-field__label`,children:re()}),(0,Y.jsx)(B,{value:b.key,placeholder:T(),onChange:e=>x({...b,key:e.target.value})})]}),(0,Y.jsxs)(`label`,{className:`oc-field`,children:[(0,Y.jsx)(`span`,{className:`oc-field__label`,children:D()}),(0,Y.jsx)(B,{value:b.name,onChange:e=>x({...b,name:e.target.value})})]}),(0,Y.jsxs)(`label`,{className:`oc-field`,children:[(0,Y.jsx)(`span`,{className:`oc-field__label`,children:A()}),(0,Y.jsx)(B,{value:b.description,onChange:e=>x({...b,description:e.target.value})})]})]})})]})}export{$ as RolesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,Ad as i,Bd as ee,Fd as a,Gd as o,Hd as te,Id as ne,Jd as s,Kd as c,Ld as l,Md as u,Nd as d,Od as f,Pd as p,Qd as m,Rd as h,Sd as g,Ud as _,Vd as v,Wd as y,Xd as b,Yd as x,Zd as S,_d as re,_w as ie,bd as C,ef as w,gd as T,gw as E,hd as D,jd as O,kd as k,md as A,nf as j,qd as M,rf as N,tf as P,uw as F,vd as I,xd as L,yd as R,zd as ae}from"./dist-ws-D-Lv-.js";import{t as z}from"./button-DuXPa4Vl.js";import{J as B,M as V,O as H,h as U,j as W,m as G,xt as K}from"./index-Bp-uQn4K.js";import{t as q}from"./roleDescriptions-KrB9-er6.js";var J=t(e(),1),Y=n(),X=[{group:()=>N(),keys:[{key:`traces.read`,label:()=>m()},{key:`traces.read.content`,label:()=>S(),phi:!0},{key:`traces.write`,label:()=>b()}]},{group:()=>j(),keys:[{key:`kpi.read`,label:()=>m()},{key:`kpi.write`,label:()=>b()}]},{group:()=>P(),keys:[{key:`openclaw.query`,label:()=>x()},{key:`anomalies.read`,label:()=>s()},{key:`anomalies.report`,label:()=>M()}]},{group:()=>w(),keys:[{key:`chats.read`,label:()=>m()},{key:`selfheal`,label:()=>o()}]},{group:()=>r(),keys:[{key:`admin.manage`,label:()=>c()}]}],oe=X.flatMap(e=>e.keys.map(e=>e.key));function Z(e){return e.includes(`*`)}var Q={key:``,name:``,description:``};function $(){let e=ie(F.apiKeys.listRoles,{}),t=E(F.apiKeys.createRole),n=E(F.apiKeys.ensureRolesSeeded),r=E(F.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(F.apiKeys.listRoles,{});r&&e.setQuery(F.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),o=V(),s=W(),[c,m]=(0,J.useState)(!1),[b,x]=(0,J.useState)(Q),[S,w]=(0,J.useState)(new Set);(0,J.useEffect)(()=>{n({}).catch(e=>{s.error(_(),e)})},[n,s]);let j=e??[];async function M(e,t){if(Z(e.permissions)||S.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];if(!(e.builtin&&!await o({title:te({name:e.name}),description:v(),confirmLabel:ee()}))){w(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){s.error(ae(),e)}finally{w(t=>{let n=new Set(t);return n.delete(e._id),n})}}}async function N(){try{await t({key:b.key,name:b.name,description:b.description||void 0,permissions:[]}),x(Q),m(!1)}catch(e){s.error(h(),e)}}let P=e===void 0,$=!P&&j.length===0;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[l(),` `,(0,Y.jsx)(`code`,{children:`admin`}),` `,ne(),` `,(0,Y.jsx)(`code`,{children:`traces.read.content`}),` `,a()]}),(0,Y.jsxs)(`div`,{className:`oc-dt`,children:[(0,Y.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,Y.jsx)(`h2`,{className:`oc-dt__title`,children:p()}),(0,Y.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,Y.jsx)(z,{size:`sm`,onClick:()=>{x(Q),m(!0)},children:d()})})]}),P?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):$?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:O()}):(0,Y.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,Y.jsxs)(`table`,{className:`oc-matrix`,children:[(0,Y.jsxs)(`thead`,{children:[(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:i()}),X.map(e=>(0,Y.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,Y.jsx)(`tr`,{children:X.flatMap(e=>e.keys.map(e=>(0,Y.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?y({key:e.key}):e.key,children:[e.label(),e.phi?(0,Y.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,Y.jsx)(`tbody`,{children:j.map(e=>{let t=Z(e.permissions),n=S.has(e._id);return(0,Y.jsxs)(`tr`,{children:[(0,Y.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,Y.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,Y.jsx)(`span`,{children:e.name}),(0,Y.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,Y.jsxs)(G,{variant:`outline`,className:`gap-1`,children:[(0,Y.jsx)(K,{}),` `,k()]}):(0,Y.jsx)(G,{variant:`secondary`,children:f()})]}),q(e)?(0,Y.jsx)(`p`,{className:`oc-matrix__roledesc`,children:q(e)}):null]}),oe.map(r=>(0,Y.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,Y.jsx)(H,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?g():n?L():r,onCheckedChange:()=>void M(e,r)})},r))]},e.key)})})]})})]}),(0,Y.jsx)(U,{open:c,onOpenChange:m,title:C(),description:R(),canSubmit:!!(b.key&&b.name),onSubmit:N,submitLabel:I(),children:(0,Y.jsxs)(`div`,{className:`oc-form`,children:[(0,Y.jsxs)(`label`,{className:`oc-field`,children:[(0,Y.jsx)(`span`,{className:`oc-field__label`,children:re()}),(0,Y.jsx)(B,{value:b.key,placeholder:T(),onChange:e=>x({...b,key:e.target.value})})]}),(0,Y.jsxs)(`label`,{className:`oc-field`,children:[(0,Y.jsx)(`span`,{className:`oc-field__label`,children:D()}),(0,Y.jsx)(B,{value:b.name,onChange:e=>x({...b,name:e.target.value})})]}),(0,Y.jsxs)(`label`,{className:`oc-field`,children:[(0,Y.jsx)(`span`,{className:`oc-field__label`,children:A()}),(0,Y.jsx)(B,{value:b.description,onChange:e=>x({...b,description:e.target.value})})]})]})})]})}export{$ as RolesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$y as r,Ay as i,By as ee,Cb as a,Cy as o,Db as te,Dy as s,Eb as ne,Ey as c,Fy as re,Gy as ie,Hy as ae,Iy as oe,Jy as se,Ky as ce,Ly as le,My as l,Ny as ue,Ob as de,Oy as u,Py as fe,Qy as pe,Ry as me,Sb as he,Sy as d,Tb as ge,Ty as f,Uy as _e,Vy as ve,Wy as ye,Xy as be,Yy as xe,Zy as Se,_b as Ce,_w as p,_y as we,ab as Te,bb as Ee,by as m,cb as De,db as Oe,dy as ke,eb as Ae,fb as je,fy as h,gb as Me,gw as g,gy as _,hb as Ne,hy as v,ib as Pe,jy as y,kb as Fe,ky as b,lb as Ie,ly as x,mb as Le,mw as Re,my as S,nb as ze,ob as Be,pb as Ve,py as C,qy as He,rb as Ue,sb as We,tb as Ge,ub as Ke,uw as w,uy as T,vb as qe,vy as E,wb as D,wy as O,xb as Je,xy as k,yb as Ye,yy as A,zy as Xe}from"./dist-ws-D-Lv-.js";import{n as j}from"./dist-DjXzB84V.js";import{i as Ze}from"./dist-ZW9rNZ8M.js";import{t as M}from"./button-DuXPa4Vl.js";import{C as N,Dt as Qe,F as P,I as F,J as I,L,M as $e,Ot as et,P as R,R as z,S as B,Tt as V,b as H,h as tt,j as nt,kt as rt,m as U,x as W,y as G,z as K}from"./index-D2h8Mdp2.js";import{t as it}from"./FilterBar-B_NTOVaW.js";import{t as at}from"./DataTableShell-D_G9F2EP.js";import{t as ot}from"./roleDescriptions-KrB9-er6.js";var q=t(e(),1),J=n(),st=[{value:`never`,label:()=>v(),days:null},{value:`30`,label:()=>S(),days:30},{value:`90`,label:()=>C(),days:90}],ct=720*60*60*1e3,Y=`__all__`,X={name:``,roleKey:``,description:``};function Z(){let e=rt({from:`/settings/serviceAccounts`}),t=et({from:`/settings/serviceAccounts`}),n=e.q??``,i=e.status??Y,[o,s]=(0,q.useState)(Y),c=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),l=e=>void t({search:t=>({...t,status:e===Y?void 0:e})}),u=p(w.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:o===Y?void 0:o,disabled:i===Y?void 0:i===`disabled`}}),d=p(w.apiKeys.listKeys,{}),f=p(w.apiKeys.listRoles,{}),we=g(w.apiKeys.createServiceAccount),m=g(w.apiKeys.updateServiceAccount),ke=g(w.apiKeys.deleteServiceAccount),h=Re(w.apiKeys.mintApiKey),_=g(w.apiKeys.revokeApiKey),v=$e(),y=nt(),b=n!==``||o!==Y||i!==Y;function x(){s(Y),t({search:{},replace:!0})}let[S,C]=(0,q.useState)(!1),[T,E]=(0,q.useState)(X),[O,k]=(0,q.useState)(null),[A,j]=(0,q.useState)(new Set),[P,F]=(0,q.useState)(null),L=(0,q.useRef)(!1),[R,z]=(0,q.useState)(new Set),[V,K]=(0,q.useState)({}),[ct,Z]=(0,q.useState)(null),Q=(0,q.useMemo)(()=>{let e=new Map;for(let t of d??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[d]);function $(e){j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function dt(){try{O?(await m({serviceAccountId:O,name:T.name,roleKey:T.roleKey,description:T.description}),y.success(He())):await we({name:T.name,roleKey:T.roleKey,description:T.description||void 0}),E(X),k(null),C(!1)}catch(e){y.error(O?se():xe(),e)}}function ft(e){E({name:e.name,roleKey:e.roleKey,description:e.description??``}),k(e._id),C(!0)}async function pt(e){if(L.current)return;L.current=!0;let t=V[e._id]??`never`,n=st.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;F(e._id);try{let t=await h({serviceAccountId:e._id,expiresAt:r});Z({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){y.error(ce(),e)}finally{L.current=!1,F(null)}}async function mt(e){if(await v({title:ie(),description:(0,J.jsxs)(J.Fragment,{children:[ye(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,_e(),` `,(0,J.jsx)(`strong`,{children:ae()}),` `,ve()]}),confirmWord:e.name,confirmLabel:ee(),destructive:!0}))try{await ke({serviceAccountId:e._id}),y.success(Xe(),e.name)}catch(e){y.error(me(),e)}}async function ht(e){if(await v({title:le(),description:(0,J.jsxs)(J.Fragment,{children:[oe(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,re()]}),confirmLabel:fe(),destructive:!0})&&!R.has(e._id)){z(t=>new Set(t).add(e._id));try{await _({keyId:e._id})}catch(e){y.error(ue(),e)}finally{z(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Fe()}),(0,J.jsxs)(it,{q:n,onQChange:c,searchPlaceholder:de(),onReset:x,canReset:b,children:[(0,J.jsxs)(G,{value:o,onValueChange:s,children:[(0,J.jsx)(B,{size:`sm`,className:`w-40`,children:(0,J.jsx)(N,{placeholder:te()})}),(0,J.jsxs)(H,{children:[(0,J.jsx)(W,{value:Y,children:ne()}),(f??[]).map(e=>(0,J.jsx)(W,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(G,{value:i,onValueChange:l,children:[(0,J.jsx)(B,{size:`sm`,className:`w-36`,children:(0,J.jsx)(N,{})}),(0,J.jsxs)(H,{children:[(0,J.jsx)(W,{value:Y,children:ge()}),(0,J.jsx)(W,{value:`active`,children:D()}),(0,J.jsx)(W,{value:`disabled`,children:a()})]})]})]}),(0,J.jsx)(at,{title:he(),rows:u,addLabel:Je(),onAdd:()=>{E(X),k(null),C(!0)},emptyHint:Ee(),isExpanded:e=>A.has(e._id),renderExpanded:e=>(0,J.jsx)(lt,{account:e,keys:Q.get(e._id)??[],onRevoke:ht,revoking:R}),rowActions:e=>[{label:Me(),onSelect:()=>ft(e)},{label:Ye(),onSelect:()=>void pt(e)},{label:A.has(e._id)?qe():Ce(),onSelect:()=>$(e._id)},{label:Ne(),variant:`destructive`,onSelect:()=>void mt(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(M,{variant:`ghost`,size:`icon-sm`,"aria-label":A.has(e._id)?Le():Ve(),onClick:()=>$(e._id),children:A.has(e._id)?(0,J.jsx)(Ze,{}):(0,J.jsx)(Qe,{})})},{header:je(),sort:e=>e.name,cell:e=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{children:e.name}),e.description?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:Oe(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(U,{variant:`secondary`,children:e.roleKey})},{header:Ke(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(U,{variant:`destructive`,children:a()}):(0,J.jsx)(U,{variant:`outline`,children:D()})},{header:Ie(),cell:e=>(0,J.jsxs)(G,{value:V[e._id]??`never`,onValueChange:t=>K(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(B,{size:`sm`,className:`w-32`,children:(0,J.jsx)(N,{})}),(0,J.jsx)(H,{children:st.map(e=>(0,J.jsx)(W,{value:e.value,children:e.label()},e.value))})]})},{header:De(),sort:e=>(Q.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Q.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:P===e._id?We():Be({count:t})})}}]}),(0,J.jsx)(tt,{open:S,onOpenChange:e=>{C(e),e||k(null)},title:O?Te():ze(),description:O?Pe():Ge(),canSubmit:!!(T.name&&T.roleKey),onSubmit:dt,submitLabel:O?Ue():Ae(),children:(0,J.jsxs)(`div`,{className:`oc-form`,children:[(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:r()}),(0,J.jsx)(I,{value:T.name,onChange:e=>E({...T,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:pe()}),(0,J.jsxs)(G,{value:T.roleKey||void 0,onValueChange:e=>E({...T,roleKey:e}),children:[(0,J.jsx)(B,{className:`w-full`,children:(0,J.jsx)(N,{placeholder:Se()})}),(0,J.jsx)(H,{children:(f??[]).map(e=>(0,J.jsxs)(W,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(f??[]).find(e=>e.key===T.roleKey),t=e?ot(e):null;return t?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:be()}),(0,J.jsx)(I,{value:T.description,onChange:e=>E({...T,description:e.target.value})})]})]})}),(0,J.jsx)(ut,{minted:ct,onClose:()=>Z(null)})]})}function lt({account:e,keys:t,onRevoke:n,revoking:r}){return(0,J.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,J.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[l(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:y()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:i()}),(0,J.jsx)(`th`,{children:b()}),(0,J.jsx)(`th`,{children:u()}),(0,J.jsx)(`th`,{children:s()}),(0,J.jsx)(`th`,{children:c()}),(0,J.jsx)(`th`,{children:f()}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:t.map(t=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(U,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:Q(t.createdAt)}),(0,J.jsx)(`td`,{className:$(t.lastUsedAt)?`oc-sa__stale`:``,children:dt(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:ft(t.expiresAt)}),(0,J.jsx)(`td`,{children:pt(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,J.jsx)(M,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?O():o()})})]},t._id))})]})]})}function ut({minted:e,onClose:t}){let[n,r]=(0,q.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,J.jsx)(R,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(P,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(K,{children:d()}),(0,J.jsx)(F,{children:k({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:m()}),(0,J.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,J.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,J.jsxs)(M,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":A(),children:[n?(0,J.jsx)(j,{}):(0,J.jsx)(V,{}),n?E():we()]})]}),(0,J.jsx)(L,{children:(0,J.jsx)(M,{onClick:()=>{r(!1),t()},children:_()})})]}):null})}function Q(e){return new Date(e).toLocaleString(`fr-FR`)}function $(e){return e===null?!1:Date.now()-e>ct}function dt(e){return e===null?h():new Date(e).toLocaleString(`fr-FR`)}function ft(e){return e===null?`—`:new Date(e).toLocaleDateString(`fr-FR`)}function pt(e){return e.disabled?(0,J.jsx)(U,{variant:`destructive`,children:ke()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(U,{variant:`outline`,children:T()}):(0,J.jsx)(U,{variant:`outline`,children:x()})}export{Z as ServiceAccountsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$y as r,Ay as i,By as ee,Cb as a,Cy as o,Db as te,Dy as s,Eb as ne,Ey as c,Fy as re,Gy as ie,Hy as ae,Iy as oe,Jy as se,Ky as ce,Ly as le,My as l,Ny as ue,Ob as de,Oy as u,Py as fe,Qy as pe,Ry as me,Sb as he,Sy as d,Tb as ge,Ty as f,Uy as _e,Vy as ve,Wy as ye,Xy as be,Yy as xe,Zy as Se,_b as Ce,_w as p,_y as we,ab as Te,bb as Ee,by as m,cb as De,db as Oe,dy as ke,eb as Ae,fb as je,fy as h,gb as Me,gw as g,gy as _,hb as Ne,hy as v,ib as Pe,jy as y,kb as Fe,ky as b,lb as Ie,ly as x,mb as Le,mw as Re,my as S,nb as ze,ob as Be,pb as Ve,py as C,qy as He,rb as Ue,sb as We,tb as Ge,ub as Ke,uw as w,uy as T,vb as qe,vy as E,wb as D,wy as O,xb as Je,xy as k,yb as Ye,yy as A,zy as Xe}from"./dist-ws-D-Lv-.js";import{n as j}from"./dist-DjXzB84V.js";import{i as Ze}from"./dist-ZW9rNZ8M.js";import{t as M}from"./button-DuXPa4Vl.js";import{C as N,Dt as Qe,F as P,I as F,J as I,L,M as $e,Ot as et,P as R,R as z,S as B,Tt as V,b as H,h as tt,j as nt,kt as rt,m as U,x as W,y as G,z as K}from"./index-Bp-uQn4K.js";import{t as it}from"./FilterBar-BmFEn3qs.js";import{t as at}from"./DataTableShell-B_P8ehdH.js";import{t as ot}from"./roleDescriptions-KrB9-er6.js";var q=t(e(),1),J=n(),st=[{value:`never`,label:()=>v(),days:null},{value:`30`,label:()=>S(),days:30},{value:`90`,label:()=>C(),days:90}],ct=720*60*60*1e3,Y=`__all__`,X={name:``,roleKey:``,description:``};function Z(){let e=rt({from:`/settings/serviceAccounts`}),t=et({from:`/settings/serviceAccounts`}),n=e.q??``,i=e.status??Y,[o,s]=(0,q.useState)(Y),c=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),l=e=>void t({search:t=>({...t,status:e===Y?void 0:e})}),u=p(w.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:o===Y?void 0:o,disabled:i===Y?void 0:i===`disabled`}}),d=p(w.apiKeys.listKeys,{}),f=p(w.apiKeys.listRoles,{}),we=g(w.apiKeys.createServiceAccount),m=g(w.apiKeys.updateServiceAccount),ke=g(w.apiKeys.deleteServiceAccount),h=Re(w.apiKeys.mintApiKey),_=g(w.apiKeys.revokeApiKey),v=$e(),y=nt(),b=n!==``||o!==Y||i!==Y;function x(){s(Y),t({search:{},replace:!0})}let[S,C]=(0,q.useState)(!1),[T,E]=(0,q.useState)(X),[O,k]=(0,q.useState)(null),[A,j]=(0,q.useState)(new Set),[P,F]=(0,q.useState)(null),L=(0,q.useRef)(!1),[R,z]=(0,q.useState)(new Set),[V,K]=(0,q.useState)({}),[ct,Z]=(0,q.useState)(null),Q=(0,q.useMemo)(()=>{let e=new Map;for(let t of d??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[d]);function $(e){j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function dt(){try{O?(await m({serviceAccountId:O,name:T.name,roleKey:T.roleKey,description:T.description}),y.success(He())):await we({name:T.name,roleKey:T.roleKey,description:T.description||void 0}),E(X),k(null),C(!1)}catch(e){y.error(O?se():xe(),e)}}function ft(e){E({name:e.name,roleKey:e.roleKey,description:e.description??``}),k(e._id),C(!0)}async function pt(e){if(L.current)return;L.current=!0;let t=V[e._id]??`never`,n=st.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;F(e._id);try{let t=await h({serviceAccountId:e._id,expiresAt:r});Z({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){y.error(ce(),e)}finally{L.current=!1,F(null)}}async function mt(e){if(await v({title:ie(),description:(0,J.jsxs)(J.Fragment,{children:[ye(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,_e(),` `,(0,J.jsx)(`strong`,{children:ae()}),` `,ve()]}),confirmWord:e.name,confirmLabel:ee(),destructive:!0}))try{await ke({serviceAccountId:e._id}),y.success(Xe(),e.name)}catch(e){y.error(me(),e)}}async function ht(e){if(await v({title:le(),description:(0,J.jsxs)(J.Fragment,{children:[oe(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,re()]}),confirmLabel:fe(),destructive:!0})&&!R.has(e._id)){z(t=>new Set(t).add(e._id));try{await _({keyId:e._id})}catch(e){y.error(ue(),e)}finally{z(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Fe()}),(0,J.jsxs)(it,{q:n,onQChange:c,searchPlaceholder:de(),onReset:x,canReset:b,children:[(0,J.jsxs)(G,{value:o,onValueChange:s,children:[(0,J.jsx)(B,{size:`sm`,className:`w-40`,children:(0,J.jsx)(N,{placeholder:te()})}),(0,J.jsxs)(H,{children:[(0,J.jsx)(W,{value:Y,children:ne()}),(f??[]).map(e=>(0,J.jsx)(W,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(G,{value:i,onValueChange:l,children:[(0,J.jsx)(B,{size:`sm`,className:`w-36`,children:(0,J.jsx)(N,{})}),(0,J.jsxs)(H,{children:[(0,J.jsx)(W,{value:Y,children:ge()}),(0,J.jsx)(W,{value:`active`,children:D()}),(0,J.jsx)(W,{value:`disabled`,children:a()})]})]})]}),(0,J.jsx)(at,{title:he(),rows:u,addLabel:Je(),onAdd:()=>{E(X),k(null),C(!0)},emptyHint:Ee(),isExpanded:e=>A.has(e._id),renderExpanded:e=>(0,J.jsx)(lt,{account:e,keys:Q.get(e._id)??[],onRevoke:ht,revoking:R}),rowActions:e=>[{label:Me(),onSelect:()=>ft(e)},{label:Ye(),onSelect:()=>void pt(e)},{label:A.has(e._id)?qe():Ce(),onSelect:()=>$(e._id)},{label:Ne(),variant:`destructive`,onSelect:()=>void mt(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(M,{variant:`ghost`,size:`icon-sm`,"aria-label":A.has(e._id)?Le():Ve(),onClick:()=>$(e._id),children:A.has(e._id)?(0,J.jsx)(Ze,{}):(0,J.jsx)(Qe,{})})},{header:je(),sort:e=>e.name,cell:e=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{children:e.name}),e.description?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:Oe(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(U,{variant:`secondary`,children:e.roleKey})},{header:Ke(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(U,{variant:`destructive`,children:a()}):(0,J.jsx)(U,{variant:`outline`,children:D()})},{header:Ie(),cell:e=>(0,J.jsxs)(G,{value:V[e._id]??`never`,onValueChange:t=>K(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(B,{size:`sm`,className:`w-32`,children:(0,J.jsx)(N,{})}),(0,J.jsx)(H,{children:st.map(e=>(0,J.jsx)(W,{value:e.value,children:e.label()},e.value))})]})},{header:De(),sort:e=>(Q.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Q.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:P===e._id?We():Be({count:t})})}}]}),(0,J.jsx)(tt,{open:S,onOpenChange:e=>{C(e),e||k(null)},title:O?Te():ze(),description:O?Pe():Ge(),canSubmit:!!(T.name&&T.roleKey),onSubmit:dt,submitLabel:O?Ue():Ae(),children:(0,J.jsxs)(`div`,{className:`oc-form`,children:[(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:r()}),(0,J.jsx)(I,{value:T.name,onChange:e=>E({...T,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:pe()}),(0,J.jsxs)(G,{value:T.roleKey||void 0,onValueChange:e=>E({...T,roleKey:e}),children:[(0,J.jsx)(B,{className:`w-full`,children:(0,J.jsx)(N,{placeholder:Se()})}),(0,J.jsx)(H,{children:(f??[]).map(e=>(0,J.jsxs)(W,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(f??[]).find(e=>e.key===T.roleKey),t=e?ot(e):null;return t?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:be()}),(0,J.jsx)(I,{value:T.description,onChange:e=>E({...T,description:e.target.value})})]})]})}),(0,J.jsx)(ut,{minted:ct,onClose:()=>Z(null)})]})}function lt({account:e,keys:t,onRevoke:n,revoking:r}){return(0,J.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,J.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[l(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:y()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:i()}),(0,J.jsx)(`th`,{children:b()}),(0,J.jsx)(`th`,{children:u()}),(0,J.jsx)(`th`,{children:s()}),(0,J.jsx)(`th`,{children:c()}),(0,J.jsx)(`th`,{children:f()}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:t.map(t=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(U,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:Q(t.createdAt)}),(0,J.jsx)(`td`,{className:$(t.lastUsedAt)?`oc-sa__stale`:``,children:dt(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:ft(t.expiresAt)}),(0,J.jsx)(`td`,{children:pt(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,J.jsx)(M,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?O():o()})})]},t._id))})]})]})}function ut({minted:e,onClose:t}){let[n,r]=(0,q.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,J.jsx)(R,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(P,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(K,{children:d()}),(0,J.jsx)(F,{children:k({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:m()}),(0,J.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,J.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,J.jsxs)(M,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":A(),children:[n?(0,J.jsx)(j,{}):(0,J.jsx)(V,{}),n?E():we()]})]}),(0,J.jsx)(L,{children:(0,J.jsx)(M,{onClick:()=>{r(!1),t()},children:_()})})]}):null})}function Q(e){return new Date(e).toLocaleString(`fr-FR`)}function $(e){return e===null?!1:Date.now()-e>ct}function dt(e){return e===null?h():new Date(e).toLocaleString(`fr-FR`)}function ft(e){return e===null?`—`:new Date(e).toLocaleDateString(`fr-FR`)}function pt(e){return e.disabled?(0,J.jsx)(U,{variant:`destructive`,children:ke()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(U,{variant:`outline`,children:T()}):(0,J.jsx)(U,{variant:`outline`,children:x()})}export{Z as ServiceAccountsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$x as r,AS as i,Ax as a,Bx as o,CS as s,Cx as c,DS as l,Dx as u,ES as d,Ex as f,FC as p,Fx as m,Gx as h,Hx as g,Ix as ee,Jx as te,Kx as ne,Lx as re,MS as ie,Mx as ae,NC as oe,Nx as se,OS as ce,Ox as le,PC as ue,Px as de,Qx as fe,Rx as pe,SS as _,Sx as me,TS as he,Tx as ge,Ux as _e,Vx as ve,Wx as ye,Xx as be,Yx as v,Zx as xe,_C as Se,_S as Ce,_w as y,_x as we,aS as Te,bS as Ee,bx as De,cS as Oe,dS as ke,dw as Ae,dx as je,eS as Me,fS as Ne,fx as Pe,gS as Fe,gw as b,gx as Ie,hS as Le,hx as Re,iS as ze,jS as Be,jx as Ve,kS as He,kx as Ue,lS as We,mS as Ge,mw as Ke,mx as x,n as qe,nS as Je,oS as Ye,pS as Xe,px as Ze,qx as Qe,rS as $e,sS as et,tS as tt,uS as nt,uw as S,ux as rt,vC as it,vS as at,vx as C,wS as ot,wx as st,xS as ct,xx as lt,yS as ut,yx as dt,zx as ft}from"./dist-ws-D-Lv-.js";import{n as w}from"./dist-DjXzB84V.js";import{t as pt}from"./TimeRangePicker-CW3Y_mIF.js";import{t as T}from"./x-D96nOW2m.js";import{t as E}from"./button-DuXPa4Vl.js";import{$ as mt,C as D,Ct as O,J as k,O as A,Q as ht,S as j,at as gt,b as M,et as N,it as _t,m as P,nt as F,ot as I,rt as vt,tt as yt,x as L,y as R}from"./index-D2h8Mdp2.js";import{a as bt,i as xt,n as St,o as Ct,r as wt,t as Tt}from"./card-CWLBezSK.js";import{a as Et,i as z,n as Dt,o as B,r as V,t as Ot}from"./table-CoglL6L8.js";import{t as kt}from"./FilterBar-B_NTOVaW.js";import{t as At}from"./AdvancedFilter-BHDc_Mha.js";var H=Ae(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),U=t(e(),1),jt=.1,Mt=[248,248,248],Nt=[24,24,24];function Pt(e,t,n){let r=t,i=n,a=-1,o=-1;for(let s=0;s<n;s++)for(let n=0;n<t;n++)e[(s*t+n)*4+3]>8&&(n<r&&(r=n),n>a&&(a=n),s<i&&(i=s),s>o&&(o=s));return a<0?null:{x:r,y:i,width:a-r+1,height:o-i+1}}function Ft(e,t,n){let r=t*n;if(r===0)return 0;let i=0;for(let t=3;t<e.length;t+=4)e[t]<=8&&i++;return i/r}function W(e,t,n){return Ft(e,t,n)>=jt}function It(e,t){for(let n=0;n<e.length;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2]}function Lt(e){for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}var Rt=12*1024*1024,zt=480,Bt=160,Vt=.92;async function Ht(e,t={}){if(!e.type.startsWith(`image/`))throw Error(se());if(e.size>Rt)throw Error(ae());let{source:n,width:r,height:i,cleanup:o}=await Ut(e);try{let o=e.type===`image/svg+xml`,s=Math.min(zt/r,Bt/i,o?1/0:1),c=Math.max(1,Math.round(r*s)),l=Math.max(1,Math.round(i*s)),u=document.createElement(`canvas`);u.width=c,u.height=l;let d=u.getContext(`2d`);if(!d)throw Error(a());d.imageSmoothingEnabled=!0,d.imageSmoothingQuality=`high`,d.drawImage(n,0,0,c,l);let f=Pt(d.getImageData(0,0,c,l).data,c,l)??{x:0,y:0,width:c,height:l},p=document.createElement(`canvas`);p.width=f.width,p.height=f.height;let m=p.getContext(`2d`);if(!m)throw Error(a());if(m.drawImage(u,f.x,f.y,f.width,f.height,0,0,f.width,f.height),t.variantFor){let e=m.getImageData(0,0,f.width,f.height);W(e.data,f.width,f.height)?It(e.data,t.variantFor===`dark`?Mt:Nt):Lt(e.data),m.putImageData(e,0,0)}let h=W(m.getImageData(0,0,f.width,f.height).data,f.width,f.height),g=await K(p,`image/webp`,Vt)??await K(p,`image/png`);if(!g)throw Error(Ue());return{blob:g,hasAlpha:h}}finally{o()}}async function Ut(e){if(e.type===`image/svg+xml`)return G(e);if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,cleanup:()=>t.close()}}catch{}return G(e)}async function G(e){let t=URL.createObjectURL(e);try{let e=new Image;return e.decoding=`async`,await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(Ve())),e.src=t}),{source:e,width:e.naturalWidth||300,height:e.naturalHeight||150,cleanup:()=>URL.revokeObjectURL(t)}}catch(e){throw URL.revokeObjectURL(t),e}}function K(e,t,n){return new Promise(r=>e.toBlob(e=>r(e),t,n))}var q=n(),J=`__all__`,Y={kind:`relative`,from:`now-24h`,to:`now`},X=[{value:`status`,label:`Statut`},{value:`latencyMs`,label:`Latence (ms)`},{value:`route`,label:`Route`},{value:`roleKey`,label:`Rôle`},{value:`correlationId`,label:`Corrélation`}];function Z({title:e,description:t,children:n}){return(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h2`,{className:`oc-show__title`,children:e}),t?(0,q.jsx)(`p`,{className:`oc-show__desc`,children:t}):null]}),(0,q.jsx)(`div`,{className:`oc-show__demo`,children:n})]})}function Wt(e){return e===`light`?p():e===`dark`?ue():oe()}var Gt=[`primary`,`secondary`,`accent`,`muted`,`chart-1`,`chart-2`];function Kt({tokens:e,mode:t}){let n=e.colors[t];return(0,q.jsx)(`div`,{className:`oc-chart-swatches`,"aria-hidden":!0,children:Gt.map(e=>{let t=n[e];return(0,q.jsx)(`span`,{className:`oc-chart-swatch`,style:t?{background:t}:void 0},e)})})}function Q({selected:e,title:t,subtitle:n,tokens:r,mode:i,onSelect:a}){return(0,q.jsxs)(`button`,{type:`button`,className:qe(`oc-chart-card`,e&&`oc-chart-card--selected`),"aria-pressed":e,onClick:a,children:[(0,q.jsxs)(`div`,{className:`oc-chart-card__head`,children:[(0,q.jsx)(`span`,{className:`oc-chart-card__title`,children:t}),e?(0,q.jsx)(w,{className:`size-4 text-primary`,"aria-hidden":!0}):null]}),r?(0,q.jsx)(Kt,{tokens:r,mode:i}):(0,q.jsx)(`div`,{className:`oc-chart-swatches oc-chart-swatches--native`,"aria-hidden":!0}),(0,q.jsx)(`div`,{className:`oc-chart-card__meta`,children:(0,q.jsx)(`span`,{className:`oc-chart-card__subtitle`,children:n})})]})}function qt({selectedKey:e,resolvedMode:t}){let n=y(S.charts.listMyCharts),r=b(S.charts.setMyChart);async function i(e){try{await r({name:e})}catch{}}return(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h2`,{className:`oc-show__title`,children:ot()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:s()})]}),(0,q.jsxs)(`div`,{className:`oc-chart-grid`,children:[(0,q.jsx)(Q,{selected:e===null,title:_(),subtitle:ct(),tokens:null,mode:t,onSelect:()=>void i(null)}),(n??[]).map(n=>{let r=n.via===`common`?Ee():n.via===`owner`?ut():at({group:n.via.group});return(0,q.jsx)(Q,{selected:e===n.key,title:n.name,subtitle:r,tokens:n.tokens,mode:t,onSelect:()=>void i(n.key)},n.key)})]}),n!==void 0&&n.length===0?(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Ce()}):null]})}function Jt(){let e=b(S.charts.importChart),[t,n]=(0,U.useState)(``),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(!1);async function f(e){let t=e.target.files?.[0];if(e.target.value=``,t){s(null),l(!1);try{a(await t.text())}catch{s(v())}}}async function p(){if(s(null),l(!1),t.trim()===``){s(Qe());return}let r;try{r=JSON.parse(i)}catch{s(v());return}d(!0);try{await e({name:t.trim(),tokens:r}),l(!0),n(``),a(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{d(!1)}}return(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h2`,{className:`oc-show__title`,children:$e()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Je()})]}),(0,q.jsxs)(`div`,{className:`oc-chart-import`,children:[(0,q.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,q.jsx)(`span`,{className:`oc-chart-import__label`,children:tt()}),(0,q.jsx)(k,{value:t,onChange:e=>n(e.target.value),placeholder:Me(),maxLength:60})]}),(0,q.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,q.jsx)(`span`,{className:`oc-chart-import__label`,children:r()}),(0,q.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:i,onChange:e=>a(e.target.value),placeholder:fe(),rows:8,spellCheck:!1})]}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(E,{variant:`outline`,size:`sm`,asChild:!0,children:(0,q.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,q.jsx)(H,{className:`size-4`}),xe(),(0,q.jsx)(`input`,{type:`file`,accept:`application/json,.json`,className:`oc-chart-import__file-input`,onChange:e=>void f(e)})]})}),(0,q.jsx)(E,{size:`sm`,disabled:u,onClick:()=>void p(),children:be()})]}),o?(0,q.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null,c?(0,q.jsx)(`p`,{className:`oc-chart-import__ok`,children:te()}):null]})]})}function Yt({chart:e}){let t=Ke(S.charts.setChartLogo),n=b(S.charts.removeChartLogo),[r,i]=(0,U.useState)(!1),[a,s]=(0,U.useState)(null),c=t=>t===`light`?e.logoLightUrl:e.logoDarkUrl;async function l(n,r,a){if(e.chartId!==void 0){s(null),i(!0);try{let{blob:i,hasAlpha:o}=await Ht(r,a?{variantFor:a}:{}),s=await i.arrayBuffer();await t({chartId:e.chartId,bytes:s,mode:n,hasAlpha:o})}catch(e){s(e instanceof Error?e.message:String(e))}finally{i(!1)}}}async function u(e,t){let n=t.target.files?.[0];t.target.value=``,n&&await l(e,n)}async function d(t){if(e.chartId!==void 0){s(null),i(!0);try{await n({chartId:e.chartId,mode:t})}catch(e){s(e instanceof Error?e.message:String(e))}finally{i(!1)}}}async function f(e){let t=c(e===`light`?`dark`:`light`);if(t){s(null),i(!0);try{await l(e,await(await fetch(t)).blob(),e)}catch(e){s(e instanceof Error?e.message:String(e))}finally{i(!1)}}}function p({mode:e}){let t=c(e),n=c(e===`light`?`dark`:`light`);return(0,q.jsxs)(`div`,{className:`oc-chart-mine__logo-slot`,children:[(0,q.jsx)(`span`,{className:`oc-chart-mine__logo-mode`,children:e===`light`?o():ft()}),(0,q.jsx)(`span`,{className:`oc-chart-mine__logo-preview`,"data-mode":e,"data-empty":t?void 0:`1`,children:t?(0,q.jsx)(`img`,{src:t,alt:``}):null}),(0,q.jsx)(E,{variant:`outline`,size:`sm`,asChild:!0,children:(0,q.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,q.jsx)(H,{className:`size-4`}),t?re():pe(),(0,q.jsx)(`input`,{type:`file`,accept:`image/*`,className:`oc-chart-import__file-input`,onChange:t=>void u(e,t)})]})}),!t&&n?(0,q.jsx)(E,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void f(e),children:m()}):null,t?(0,q.jsx)(E,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void d(e),children:ee()}):null]})}return(0,q.jsxs)(`div`,{className:`oc-chart-mine__logo`,children:[(0,q.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:ve()}),(0,q.jsxs)(`div`,{className:`oc-chart-mine__logo-slots`,children:[(0,q.jsx)(p,{mode:`light`}),(0,q.jsx)(p,{mode:`dark`})]}),r?(0,q.jsx)(`span`,{className:`oc-show__desc`,children:de()}):null,a?(0,q.jsx)(`p`,{className:`oc-chart-import__error`,children:a}):null]})}function $({chart:e}){let t=y(S.me.getMe,{host:I}),n=b(S.charts.addChartDomain),r=b(S.charts.removeChartDomain),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(null),[l,d]=(0,U.useState)(!1);if(t?.role!==`admin`)return null;let p=e.domains??[];async function m(){let t=i.trim();if(t!==``){s(null),d(!0);try{await n({chartKey:e.key,domain:t}),a(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{d(!1)}}}async function h(t){s(null);try{await r({chartKey:e.key,domain:t})}catch{}}return(0,q.jsxs)(`div`,{className:`oc-chart-mine__domains`,children:[(0,q.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:le()}),(0,q.jsxs)(`div`,{className:`oc-chart-mine__domains-body`,children:[(0,q.jsx)(`div`,{className:`oc-chart-avail__groups`,children:p.length===0?(0,q.jsx)(`span`,{className:`oc-show__desc`,children:st()}):p.map(e=>(0,q.jsxs)(P,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e,(0,q.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":c({domain:e}),onClick:()=>void h(e),children:(0,q.jsx)(T,{className:`size-3`})})]},e))}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(k,{value:i,onChange:e=>a(e.target.value),placeholder:f(),className:`oc-chart-mine__domains-input`,onKeyDown:e=>{e.key===`Enter`&&m()}}),(0,q.jsx)(E,{variant:`outline`,size:`sm`,disabled:l,onClick:()=>void m(),children:ge()})]}),(0,q.jsx)(`span`,{className:`oc-show__desc`,children:u()}),o?(0,q.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null]})]})}function Xt({chart:e}){let t=b(S.charts.updateChart),n=b(S.charts.deleteChart),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(e.name),[s,c]=(0,U.useState)(()=>JSON.stringify(e.tokens,null,2)),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(!1);function p(){o(e.name),c(JSON.stringify(e.tokens,null,2)),u(null),i(!0)}async function m(){if(e.chartId===void 0)return;u(null);let n;try{n=JSON.parse(s)}catch{u(v());return}f(!0);try{await t({chartId:e.chartId,name:a.trim(),tokens:n}),i(!1)}catch(e){u(e instanceof Error?e.message:String(e))}finally{f(!1)}}async function h(){if(e.chartId!==void 0&&window.confirm(C()))try{await n({chartId:e.chartId})}catch{}}return(0,q.jsxs)(`div`,{className:`oc-chart-mine__row`,children:[(0,q.jsxs)(`div`,{className:`oc-chart-mine__head`,children:[(0,q.jsx)(`span`,{className:`oc-chart-mine__name`,children:e.name}),(0,q.jsx)(`div`,{className:`oc-show__row`,children:r?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(E,{variant:`outline`,size:`sm`,onClick:p,children:_e()}),(0,q.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>void h(),children:g()})]})})]}),r?(0,q.jsxs)(`div`,{className:`oc-chart-mine__editor`,children:[(0,q.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,q.jsx)(`span`,{className:`oc-chart-import__label`,children:De()}),(0,q.jsx)(k,{value:a,onChange:e=>o(e.target.value),maxLength:60})]}),(0,q.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,q.jsx)(`span`,{className:`oc-chart-import__label`,children:dt()}),(0,q.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:s,onChange:e=>c(e.target.value),rows:10,spellCheck:!1})]}),l?(0,q.jsx)(`p`,{className:`oc-chart-import__error`,children:l}):null,(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(E,{size:`sm`,disabled:d,onClick:()=>void m(),children:me()}),(0,q.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>i(!1),children:lt()})]})]}):null,(0,q.jsx)(Yt,{chart:e}),(0,q.jsx)($,{chart:e})]})}function Zt(){let e=y(S.charts.listMyCharts),t=(e??[]).filter(e=>e.via===`owner`);return(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h2`,{className:`oc-show__title`,children:ne()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:h()})]}),e!==void 0&&t.length===0?(0,q.jsx)(`p`,{className:`oc-show__desc`,children:ye()}):(0,q.jsx)(`div`,{className:`oc-chart-mine-list`,children:t.map(e=>(0,q.jsx)(Xt,{chart:e},e.key))})]})}function Qt({chart:e,groups:t}){let n=b(S.charts.addChartToGroupPool),r=b(S.charts.removeChartFromGroupPool),i=e.restrictedToGroups,a=e.poolGroups,o=new Set((a??[]).map(e=>e.groupId)),s=t.filter(e=>!o.has(e._id));async function c(t){try{await n({groupId:t,chartKey:e.key})}catch{}}async function l(t){try{await r({groupId:t,chartKey:e.key})}catch{}}return(0,q.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,q.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,q.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,q.jsx)(P,{variant:i?`secondary`:`outline`,className:`oc-chart-avail__state`,children:i?We():e.kind===`custom`&&e.scope===`personal`?x():nt()}),e.isGlobalDefault?(0,q.jsx)(P,{variant:`default`,children:Oe()}):null]}),(0,q.jsxs)(`div`,{className:`oc-chart-avail__groups`,children:[(0,q.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:Ye()}),(a??[]).map(e=>(0,q.jsxs)(P,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e.name,(0,q.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":ze({group:e.name}),onClick:()=>void l(e.groupId),children:(0,q.jsx)(T,{className:`size-3`})})]},e.groupId)),s.length>0?(0,q.jsxs)(R,{value:``,onValueChange:e=>void c(e),children:[(0,q.jsx)(j,{size:`sm`,className:`w-56`,children:(0,q.jsx)(D,{placeholder:Te()})}),(0,q.jsx)(M,{children:s.map(e=>(0,q.jsx)(L,{value:e._id,children:e.name},e._id))})]}):t.length===0?(0,q.jsx)(`span`,{className:`oc-show__desc`,children:et()}):null]})]})}function $t({chart:e}){let t=b(S.charts.promoteChartToCommon),n=b(S.charts.deleteChart);async function r(){if(e.chartId!==void 0)try{await t({chartId:e.chartId})}catch{}}async function i(){if(e.chartId!==void 0&&window.confirm(C()))try{await n({chartId:e.chartId})}catch{}}return(0,q.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,q.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,q.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,q.jsx)(P,{variant:e.scope===`common`?`outline`:`secondary`,children:e.scope===`common`?Ze():x()}),e.ownerLabel?(0,q.jsx)(`span`,{className:`oc-show__desc`,children:Re({owner:e.ownerLabel})}):null]}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[e.scope===`personal`?(0,q.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>void r(),children:Pe()}):null,(0,q.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>void i(),children:je()})]})]})}function en({defaultThemeMode:e,defaultLocale:t,defaultChartKey:n}){let r=b(S.admin.setDefaultThemeMode),a=b(S.admin.setDefaultLocale),o=b(S.charts.setDefaultChart),s=y(S.charts.listChartsAdmin),c=y(S.groups.listGroups,{}),l=e??`system`,u=t??`fr`;return(0,q.jsxs)(`div`,{className:`oc-appearance-admin`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h2`,{className:`oc-show__title`,children:d()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:he()})]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:Fe()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Le()})]}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(E,{variant:n===null?`default`:`outline`,size:`sm`,onClick:()=>void o({name:null}),children:_()}),gt.map(e=>(0,q.jsx)(E,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void o({name:e.key}),children:e.name},e.key)),(s??[]).filter(e=>e.kind===`custom`&&e.scope===`common`).map(e=>(0,q.jsx)(E,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void o({name:e.key}),children:e.name},e.key))]})]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:Ge()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Xe()})]}),(0,q.jsx)(`div`,{className:`oc-chart-avail-list`,children:(s??[]).filter(e=>!(e.kind===`custom`&&e.scope===`common`)).map(e=>(0,q.jsx)(Qt,{chart:e,groups:c??[]},e.key))})]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:Ne()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:ke()})]}),(0,q.jsx)(`div`,{className:`oc-chart-avail-list`,children:(s??[]).filter(e=>e.kind===`builtin`||e.scope===`common`).map(e=>(0,q.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,q.jsx)(`div`,{className:`oc-chart-avail__head`,children:(0,q.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name})}),(0,q.jsx)($,{chart:e})]},e.key))})]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:we()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Ie()})]}),(()=>{let e=(s??[]).filter(e=>e.kind===`custom`);return e.length===0?(0,q.jsx)(`p`,{className:`oc-show__desc`,children:rt()}):(0,q.jsx)(`div`,{className:`oc-chart-avail-list`,children:e.map(e=>(0,q.jsx)($t,{chart:e},e.key))})})()]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:ie()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Be()})]}),(0,q.jsx)(`div`,{className:`oc-show__row`,children:[`light`,`dark`,`system`].map(e=>(0,q.jsx)(E,{variant:l===e?`default`:`outline`,size:`sm`,onClick:()=>void r({mode:e}),children:Wt(e)},e))})]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:i()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:He()})]}),(0,q.jsx)(`div`,{className:`oc-show__row`,children:[`fr`,`en`].map(e=>(0,q.jsx)(E,{variant:u===e?`default`:`outline`,size:`sm`,onClick:()=>void a({locale:e}),children:e===`fr`?it():Se()},e))}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:ce()})]})]})}function tn(){let e=y(S.me.getMe,{host:I}),t=_t(e?.resolvedThemeMode);return(0,q.jsxs)(`div`,{className:`oc-appearance`,children:[(0,q.jsx)(qt,{selectedKey:e?.chartKey??null,resolvedMode:t}),(0,q.jsx)(Jt,{}),(0,q.jsx)(Zt,{}),e?.role===`admin`?(0,q.jsx)(en,{defaultThemeMode:e.defaultThemeMode,defaultLocale:e.defaultLocale,defaultChartKey:e.defaultChartKey}):null]})}function nn(){let[e,t]=(0,U.useState)(!0),[n,r]=(0,U.useState)(`per-user`),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(J),[c,u]=(0,U.useState)(J),[d,f]=(0,U.useState)(Y),p=i!==``||o!==J||c!==J;function m(){a(``),s(J),u(J),f(Y)}return(0,q.jsxs)(`div`,{className:`oc-show`,children:[(0,q.jsx)(tn,{}),(0,q.jsxs)(`details`,{className:`oc-show__ref`,children:[(0,q.jsx)(`summary`,{className:`oc-show__title`,children:l()}),(0,q.jsxs)(Z,{title:`Buttons`,description:`Variants`,children:[(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(E,{children:`Default`}),(0,q.jsx)(E,{variant:`secondary`,children:`Secondary`}),(0,q.jsx)(E,{variant:`outline`,children:`Outline`}),(0,q.jsx)(E,{variant:`ghost`,children:`Ghost`}),(0,q.jsx)(E,{variant:`destructive`,children:`Destructive`}),(0,q.jsx)(E,{variant:`link`,children:`Link`})]}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(E,{size:`sm`,children:`Small`}),(0,q.jsx)(E,{children:`Default`}),(0,q.jsx)(E,{size:`lg`,children:`Large`}),(0,q.jsx)(E,{size:`icon`,"aria-label":`more`,children:(0,q.jsx)(O,{})}),(0,q.jsx)(E,{disabled:!0,children:`Disabled`})]})]}),(0,q.jsx)(Z,{title:`Badges`,children:(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(P,{children:`Default`}),(0,q.jsx)(P,{variant:`secondary`,children:`Secondary`}),(0,q.jsx)(P,{variant:`outline`,children:`Outline`}),(0,q.jsx)(P,{variant:`destructive`,children:`Destructive`})]})}),(0,q.jsx)(Z,{title:`Inputs & selection`,children:(0,q.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,q.jsx)(k,{placeholder:`Text input…`}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsxs)(R,{value:n,onValueChange:r,children:[(0,q.jsx)(j,{className:`w-56`,children:(0,q.jsx)(D,{placeholder:`Select…`})}),(0,q.jsxs)(M,{children:[(0,q.jsx)(L,{value:`per-user`,children:`per-user (chacun son agent)`}),(0,q.jsx)(L,{value:`shared`,children:`shared (agent commun)`})]})]}),(0,q.jsxs)(`label`,{className:`oc-show__check`,children:[(0,q.jsx)(A,{checked:e,onCheckedChange:e=>t(!!e)}),`Checkbox`]})]})]})}),(0,q.jsx)(Z,{title:`Filtres & plage temporelle`,description:`Barre réutilisable (recherche debouncée + selects rapides à largeur auto + plage façon Grafana) et constructeur de filtre avancé. Câblée dans Users, Groups, Comptes de service, Traces, Anomalies, Audit et KPI.`,children:(0,q.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,q.jsxs)(kt,{q:i,onQChange:a,searchPlaceholder:`Rechercher (kind, principal, rôle, route…)`,timeRange:d,onTimeRangeChange:f,onReset:m,canReset:p,children:[(0,q.jsxs)(R,{value:o,onValueChange:s,children:[(0,q.jsx)(j,{size:`sm`,children:(0,q.jsx)(D,{})}),(0,q.jsxs)(M,{children:[(0,q.jsx)(L,{value:J,children:`Toutes directions`}),(0,q.jsx)(L,{value:`inbound`,children:`inbound`}),(0,q.jsx)(L,{value:`outbound`,children:`outbound`}),(0,q.jsx)(L,{value:`internal`,children:`internal`})]})]}),(0,q.jsxs)(R,{value:c,onValueChange:u,children:[(0,q.jsx)(j,{size:`sm`,children:(0,q.jsx)(D,{})}),(0,q.jsxs)(M,{children:[(0,q.jsx)(L,{value:J,children:`Toutes sévérités`}),(0,q.jsx)(L,{value:`info`,children:`info`}),(0,q.jsx)(L,{value:`warn`,children:`warn`}),(0,q.jsx)(L,{value:`critical`,children:`critical`})]})]})]}),(0,q.jsx)(At,{fields:X,onChange:()=>{}}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(`span`,{className:`oc-show__desc`,children:`Sélecteur de plage seul :`}),(0,q.jsx)(pt,{value:d,onChange:f})]})]})}),(0,q.jsx)(Z,{title:`Dropdown menu`,description:`Row actions / kebab`,children:(0,q.jsxs)(ht,{children:[(0,q.jsx)(vt,{asChild:!0,children:(0,q.jsx)(E,{variant:`outline`,size:`icon`,"aria-label":`Open menu`,children:(0,q.jsx)(O,{})})}),(0,q.jsxs)(mt,{align:`start`,children:[(0,q.jsx)(yt,{children:`Actions`}),(0,q.jsx)(F,{}),(0,q.jsx)(N,{children:`Edit`}),(0,q.jsx)(N,{children:`Duplicate`}),(0,q.jsx)(F,{}),(0,q.jsx)(N,{variant:`destructive`,children:`Delete`})]})]})}),(0,q.jsx)(Z,{title:`Card`,children:(0,q.jsxs)(Tt,{className:`w-80`,children:[(0,q.jsxs)(bt,{children:[(0,q.jsx)(Ct,{children:`Instance`}),(0,q.jsx)(wt,{children:`Non-secret metadata only.`})]}),(0,q.jsx)(St,{className:`text-sm text-muted-foreground`,children:`ws://gateway.example.org:18789`}),(0,q.jsxs)(xt,{className:`gap-2`,children:[(0,q.jsx)(E,{size:`sm`,children:`Save`}),(0,q.jsx)(E,{size:`sm`,variant:`ghost`,children:`Cancel`})]})]})}),(0,q.jsx)(Z,{title:`Table`,children:(0,q.jsxs)(Ot,{children:[(0,q.jsx)(Et,{children:(0,q.jsxs)(B,{children:[(0,q.jsx)(z,{className:`w-8`,children:(0,q.jsx)(A,{"aria-label":`select all`})}),(0,q.jsx)(z,{children:`Name`}),(0,q.jsx)(z,{children:`Mode`}),(0,q.jsx)(z,{className:`text-right`,children:`Status`}),(0,q.jsx)(z,{className:`w-8`})]})}),(0,q.jsx)(Dt,{children:[{n:`admins`,m:`per-user`,s:`active`},{n:`family`,m:`shared`,s:`active`}].map(e=>(0,q.jsxs)(B,{children:[(0,q.jsx)(V,{children:(0,q.jsx)(A,{"aria-label":`select ${e.n}`})}),(0,q.jsx)(V,{className:`font-medium`,children:e.n}),(0,q.jsx)(V,{children:(0,q.jsx)(P,{variant:`secondary`,children:e.m})}),(0,q.jsx)(V,{className:`text-right`,children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,q.jsx)(w,{className:`size-3.5`}),` `,e.s]})}),(0,q.jsx)(V,{children:(0,q.jsx)(E,{variant:`ghost`,size:`icon`,"aria-label":`row actions`,children:(0,q.jsx)(O,{})})})]},e.n))})]})}),(0,q.jsx)(Z,{title:`App fragments`,description:`Chat-specific components`,children:(0,q.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,q.jsx)(`div`,{className:`oc-msg oc-msg--assistant`,children:(0,q.jsx)(`div`,{className:`oc-msg__body`,children:`Assistant message bubble.`})}),(0,q.jsx)(`div`,{className:`oc-tool oc-tool--completed`,children:(0,q.jsxs)(`div`,{className:`oc-tool__header`,children:[(0,q.jsx)(`span`,{className:`oc-tool__icon`,children:`✓`}),(0,q.jsx)(`span`,{className:`oc-tool__name`,children:`write-file`}),(0,q.jsx)(`span`,{className:`oc-tool__phase`,children:`completed`})]})}),(0,q.jsxs)(`div`,{className:`oc-run-status oc-run-status--streaming`,children:[(0,q.jsx)(`span`,{className:`oc-run-status__dot`}),(0,q.jsx)(`span`,{className:`oc-run-status__label`,children:`Running`})]})]})})]})]})}export{nn as ThemeShowroom};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$x as r,AS as i,Ax as a,Bx as o,CS as s,Cx as c,DS as l,Dx as u,ES as d,Ex as f,FC as p,Fx as m,Gx as h,Hx as g,Ix as ee,Jx as te,Kx as ne,Lx as re,MS as ie,Mx as ae,NC as oe,Nx as se,OS as ce,Ox as le,PC as ue,Px as de,Qx as fe,Rx as pe,SS as _,Sx as me,TS as he,Tx as ge,Ux as _e,Vx as ve,Wx as ye,Xx as be,Yx as v,Zx as xe,_C as Se,_S as Ce,_w as y,_x as we,aS as Te,bS as Ee,bx as De,cS as Oe,dS as ke,dw as Ae,dx as je,eS as Me,fS as Ne,fx as Pe,gS as Fe,gw as b,gx as Ie,hS as Le,hx as Re,iS as ze,jS as Be,jx as Ve,kS as He,kx as Ue,lS as We,mS as Ge,mw as Ke,mx as x,n as qe,nS as Je,oS as Ye,pS as Xe,px as Ze,qx as Qe,rS as $e,sS as et,tS as tt,uS as nt,uw as S,ux as rt,vC as it,vS as at,vx as C,wS as ot,wx as st,xS as ct,xx as lt,yS as ut,yx as dt,zx as ft}from"./dist-ws-D-Lv-.js";import{n as w}from"./dist-DjXzB84V.js";import{t as pt}from"./TimeRangePicker-BDN2rIcO.js";import{t as T}from"./x-D96nOW2m.js";import{t as E}from"./button-DuXPa4Vl.js";import{$ as mt,C as D,Ct as O,J as k,O as A,Q as ht,S as j,at as gt,b as M,et as N,it as _t,m as P,nt as F,ot as I,rt as vt,tt as yt,x as L,y as R}from"./index-Bp-uQn4K.js";import{a as bt,i as xt,n as St,o as Ct,r as wt,t as Tt}from"./card-CWLBezSK.js";import{a as Et,i as z,n as Dt,o as B,r as V,t as Ot}from"./table-CoglL6L8.js";import{t as kt}from"./FilterBar-BmFEn3qs.js";import{t as At}from"./AdvancedFilter-0hIaeD_5.js";var H=Ae(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),U=t(e(),1),jt=.1,Mt=[248,248,248],Nt=[24,24,24];function Pt(e,t,n){let r=t,i=n,a=-1,o=-1;for(let s=0;s<n;s++)for(let n=0;n<t;n++)e[(s*t+n)*4+3]>8&&(n<r&&(r=n),n>a&&(a=n),s<i&&(i=s),s>o&&(o=s));return a<0?null:{x:r,y:i,width:a-r+1,height:o-i+1}}function Ft(e,t,n){let r=t*n;if(r===0)return 0;let i=0;for(let t=3;t<e.length;t+=4)e[t]<=8&&i++;return i/r}function W(e,t,n){return Ft(e,t,n)>=jt}function It(e,t){for(let n=0;n<e.length;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2]}function Lt(e){for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}var Rt=12*1024*1024,zt=480,Bt=160,Vt=.92;async function Ht(e,t={}){if(!e.type.startsWith(`image/`))throw Error(se());if(e.size>Rt)throw Error(ae());let{source:n,width:r,height:i,cleanup:o}=await Ut(e);try{let o=e.type===`image/svg+xml`,s=Math.min(zt/r,Bt/i,o?1/0:1),c=Math.max(1,Math.round(r*s)),l=Math.max(1,Math.round(i*s)),u=document.createElement(`canvas`);u.width=c,u.height=l;let d=u.getContext(`2d`);if(!d)throw Error(a());d.imageSmoothingEnabled=!0,d.imageSmoothingQuality=`high`,d.drawImage(n,0,0,c,l);let f=Pt(d.getImageData(0,0,c,l).data,c,l)??{x:0,y:0,width:c,height:l},p=document.createElement(`canvas`);p.width=f.width,p.height=f.height;let m=p.getContext(`2d`);if(!m)throw Error(a());if(m.drawImage(u,f.x,f.y,f.width,f.height,0,0,f.width,f.height),t.variantFor){let e=m.getImageData(0,0,f.width,f.height);W(e.data,f.width,f.height)?It(e.data,t.variantFor===`dark`?Mt:Nt):Lt(e.data),m.putImageData(e,0,0)}let h=W(m.getImageData(0,0,f.width,f.height).data,f.width,f.height),g=await K(p,`image/webp`,Vt)??await K(p,`image/png`);if(!g)throw Error(Ue());return{blob:g,hasAlpha:h}}finally{o()}}async function Ut(e){if(e.type===`image/svg+xml`)return G(e);if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,cleanup:()=>t.close()}}catch{}return G(e)}async function G(e){let t=URL.createObjectURL(e);try{let e=new Image;return e.decoding=`async`,await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(Ve())),e.src=t}),{source:e,width:e.naturalWidth||300,height:e.naturalHeight||150,cleanup:()=>URL.revokeObjectURL(t)}}catch(e){throw URL.revokeObjectURL(t),e}}function K(e,t,n){return new Promise(r=>e.toBlob(e=>r(e),t,n))}var q=n(),J=`__all__`,Y={kind:`relative`,from:`now-24h`,to:`now`},X=[{value:`status`,label:`Statut`},{value:`latencyMs`,label:`Latence (ms)`},{value:`route`,label:`Route`},{value:`roleKey`,label:`Rôle`},{value:`correlationId`,label:`Corrélation`}];function Z({title:e,description:t,children:n}){return(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h2`,{className:`oc-show__title`,children:e}),t?(0,q.jsx)(`p`,{className:`oc-show__desc`,children:t}):null]}),(0,q.jsx)(`div`,{className:`oc-show__demo`,children:n})]})}function Wt(e){return e===`light`?p():e===`dark`?ue():oe()}var Gt=[`primary`,`secondary`,`accent`,`muted`,`chart-1`,`chart-2`];function Kt({tokens:e,mode:t}){let n=e.colors[t];return(0,q.jsx)(`div`,{className:`oc-chart-swatches`,"aria-hidden":!0,children:Gt.map(e=>{let t=n[e];return(0,q.jsx)(`span`,{className:`oc-chart-swatch`,style:t?{background:t}:void 0},e)})})}function Q({selected:e,title:t,subtitle:n,tokens:r,mode:i,onSelect:a}){return(0,q.jsxs)(`button`,{type:`button`,className:qe(`oc-chart-card`,e&&`oc-chart-card--selected`),"aria-pressed":e,onClick:a,children:[(0,q.jsxs)(`div`,{className:`oc-chart-card__head`,children:[(0,q.jsx)(`span`,{className:`oc-chart-card__title`,children:t}),e?(0,q.jsx)(w,{className:`size-4 text-primary`,"aria-hidden":!0}):null]}),r?(0,q.jsx)(Kt,{tokens:r,mode:i}):(0,q.jsx)(`div`,{className:`oc-chart-swatches oc-chart-swatches--native`,"aria-hidden":!0}),(0,q.jsx)(`div`,{className:`oc-chart-card__meta`,children:(0,q.jsx)(`span`,{className:`oc-chart-card__subtitle`,children:n})})]})}function qt({selectedKey:e,resolvedMode:t}){let n=y(S.charts.listMyCharts),r=b(S.charts.setMyChart);async function i(e){try{await r({name:e})}catch{}}return(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h2`,{className:`oc-show__title`,children:ot()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:s()})]}),(0,q.jsxs)(`div`,{className:`oc-chart-grid`,children:[(0,q.jsx)(Q,{selected:e===null,title:_(),subtitle:ct(),tokens:null,mode:t,onSelect:()=>void i(null)}),(n??[]).map(n=>{let r=n.via===`common`?Ee():n.via===`owner`?ut():at({group:n.via.group});return(0,q.jsx)(Q,{selected:e===n.key,title:n.name,subtitle:r,tokens:n.tokens,mode:t,onSelect:()=>void i(n.key)},n.key)})]}),n!==void 0&&n.length===0?(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Ce()}):null]})}function Jt(){let e=b(S.charts.importChart),[t,n]=(0,U.useState)(``),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(!1);async function f(e){let t=e.target.files?.[0];if(e.target.value=``,t){s(null),l(!1);try{a(await t.text())}catch{s(v())}}}async function p(){if(s(null),l(!1),t.trim()===``){s(Qe());return}let r;try{r=JSON.parse(i)}catch{s(v());return}d(!0);try{await e({name:t.trim(),tokens:r}),l(!0),n(``),a(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{d(!1)}}return(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h2`,{className:`oc-show__title`,children:$e()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Je()})]}),(0,q.jsxs)(`div`,{className:`oc-chart-import`,children:[(0,q.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,q.jsx)(`span`,{className:`oc-chart-import__label`,children:tt()}),(0,q.jsx)(k,{value:t,onChange:e=>n(e.target.value),placeholder:Me(),maxLength:60})]}),(0,q.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,q.jsx)(`span`,{className:`oc-chart-import__label`,children:r()}),(0,q.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:i,onChange:e=>a(e.target.value),placeholder:fe(),rows:8,spellCheck:!1})]}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(E,{variant:`outline`,size:`sm`,asChild:!0,children:(0,q.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,q.jsx)(H,{className:`size-4`}),xe(),(0,q.jsx)(`input`,{type:`file`,accept:`application/json,.json`,className:`oc-chart-import__file-input`,onChange:e=>void f(e)})]})}),(0,q.jsx)(E,{size:`sm`,disabled:u,onClick:()=>void p(),children:be()})]}),o?(0,q.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null,c?(0,q.jsx)(`p`,{className:`oc-chart-import__ok`,children:te()}):null]})]})}function Yt({chart:e}){let t=Ke(S.charts.setChartLogo),n=b(S.charts.removeChartLogo),[r,i]=(0,U.useState)(!1),[a,s]=(0,U.useState)(null),c=t=>t===`light`?e.logoLightUrl:e.logoDarkUrl;async function l(n,r,a){if(e.chartId!==void 0){s(null),i(!0);try{let{blob:i,hasAlpha:o}=await Ht(r,a?{variantFor:a}:{}),s=await i.arrayBuffer();await t({chartId:e.chartId,bytes:s,mode:n,hasAlpha:o})}catch(e){s(e instanceof Error?e.message:String(e))}finally{i(!1)}}}async function u(e,t){let n=t.target.files?.[0];t.target.value=``,n&&await l(e,n)}async function d(t){if(e.chartId!==void 0){s(null),i(!0);try{await n({chartId:e.chartId,mode:t})}catch(e){s(e instanceof Error?e.message:String(e))}finally{i(!1)}}}async function f(e){let t=c(e===`light`?`dark`:`light`);if(t){s(null),i(!0);try{await l(e,await(await fetch(t)).blob(),e)}catch(e){s(e instanceof Error?e.message:String(e))}finally{i(!1)}}}function p({mode:e}){let t=c(e),n=c(e===`light`?`dark`:`light`);return(0,q.jsxs)(`div`,{className:`oc-chart-mine__logo-slot`,children:[(0,q.jsx)(`span`,{className:`oc-chart-mine__logo-mode`,children:e===`light`?o():ft()}),(0,q.jsx)(`span`,{className:`oc-chart-mine__logo-preview`,"data-mode":e,"data-empty":t?void 0:`1`,children:t?(0,q.jsx)(`img`,{src:t,alt:``}):null}),(0,q.jsx)(E,{variant:`outline`,size:`sm`,asChild:!0,children:(0,q.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,q.jsx)(H,{className:`size-4`}),t?re():pe(),(0,q.jsx)(`input`,{type:`file`,accept:`image/*`,className:`oc-chart-import__file-input`,onChange:t=>void u(e,t)})]})}),!t&&n?(0,q.jsx)(E,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void f(e),children:m()}):null,t?(0,q.jsx)(E,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void d(e),children:ee()}):null]})}return(0,q.jsxs)(`div`,{className:`oc-chart-mine__logo`,children:[(0,q.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:ve()}),(0,q.jsxs)(`div`,{className:`oc-chart-mine__logo-slots`,children:[(0,q.jsx)(p,{mode:`light`}),(0,q.jsx)(p,{mode:`dark`})]}),r?(0,q.jsx)(`span`,{className:`oc-show__desc`,children:de()}):null,a?(0,q.jsx)(`p`,{className:`oc-chart-import__error`,children:a}):null]})}function $({chart:e}){let t=y(S.me.getMe,{host:I}),n=b(S.charts.addChartDomain),r=b(S.charts.removeChartDomain),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(null),[l,d]=(0,U.useState)(!1);if(t?.role!==`admin`)return null;let p=e.domains??[];async function m(){let t=i.trim();if(t!==``){s(null),d(!0);try{await n({chartKey:e.key,domain:t}),a(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{d(!1)}}}async function h(t){s(null);try{await r({chartKey:e.key,domain:t})}catch{}}return(0,q.jsxs)(`div`,{className:`oc-chart-mine__domains`,children:[(0,q.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:le()}),(0,q.jsxs)(`div`,{className:`oc-chart-mine__domains-body`,children:[(0,q.jsx)(`div`,{className:`oc-chart-avail__groups`,children:p.length===0?(0,q.jsx)(`span`,{className:`oc-show__desc`,children:st()}):p.map(e=>(0,q.jsxs)(P,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e,(0,q.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":c({domain:e}),onClick:()=>void h(e),children:(0,q.jsx)(T,{className:`size-3`})})]},e))}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(k,{value:i,onChange:e=>a(e.target.value),placeholder:f(),className:`oc-chart-mine__domains-input`,onKeyDown:e=>{e.key===`Enter`&&m()}}),(0,q.jsx)(E,{variant:`outline`,size:`sm`,disabled:l,onClick:()=>void m(),children:ge()})]}),(0,q.jsx)(`span`,{className:`oc-show__desc`,children:u()}),o?(0,q.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null]})]})}function Xt({chart:e}){let t=b(S.charts.updateChart),n=b(S.charts.deleteChart),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(e.name),[s,c]=(0,U.useState)(()=>JSON.stringify(e.tokens,null,2)),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(!1);function p(){o(e.name),c(JSON.stringify(e.tokens,null,2)),u(null),i(!0)}async function m(){if(e.chartId===void 0)return;u(null);let n;try{n=JSON.parse(s)}catch{u(v());return}f(!0);try{await t({chartId:e.chartId,name:a.trim(),tokens:n}),i(!1)}catch(e){u(e instanceof Error?e.message:String(e))}finally{f(!1)}}async function h(){if(e.chartId!==void 0&&window.confirm(C()))try{await n({chartId:e.chartId})}catch{}}return(0,q.jsxs)(`div`,{className:`oc-chart-mine__row`,children:[(0,q.jsxs)(`div`,{className:`oc-chart-mine__head`,children:[(0,q.jsx)(`span`,{className:`oc-chart-mine__name`,children:e.name}),(0,q.jsx)(`div`,{className:`oc-show__row`,children:r?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(E,{variant:`outline`,size:`sm`,onClick:p,children:_e()}),(0,q.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>void h(),children:g()})]})})]}),r?(0,q.jsxs)(`div`,{className:`oc-chart-mine__editor`,children:[(0,q.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,q.jsx)(`span`,{className:`oc-chart-import__label`,children:De()}),(0,q.jsx)(k,{value:a,onChange:e=>o(e.target.value),maxLength:60})]}),(0,q.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,q.jsx)(`span`,{className:`oc-chart-import__label`,children:dt()}),(0,q.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:s,onChange:e=>c(e.target.value),rows:10,spellCheck:!1})]}),l?(0,q.jsx)(`p`,{className:`oc-chart-import__error`,children:l}):null,(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(E,{size:`sm`,disabled:d,onClick:()=>void m(),children:me()}),(0,q.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>i(!1),children:lt()})]})]}):null,(0,q.jsx)(Yt,{chart:e}),(0,q.jsx)($,{chart:e})]})}function Zt(){let e=y(S.charts.listMyCharts),t=(e??[]).filter(e=>e.via===`owner`);return(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h2`,{className:`oc-show__title`,children:ne()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:h()})]}),e!==void 0&&t.length===0?(0,q.jsx)(`p`,{className:`oc-show__desc`,children:ye()}):(0,q.jsx)(`div`,{className:`oc-chart-mine-list`,children:t.map(e=>(0,q.jsx)(Xt,{chart:e},e.key))})]})}function Qt({chart:e,groups:t}){let n=b(S.charts.addChartToGroupPool),r=b(S.charts.removeChartFromGroupPool),i=e.restrictedToGroups,a=e.poolGroups,o=new Set((a??[]).map(e=>e.groupId)),s=t.filter(e=>!o.has(e._id));async function c(t){try{await n({groupId:t,chartKey:e.key})}catch{}}async function l(t){try{await r({groupId:t,chartKey:e.key})}catch{}}return(0,q.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,q.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,q.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,q.jsx)(P,{variant:i?`secondary`:`outline`,className:`oc-chart-avail__state`,children:i?We():e.kind===`custom`&&e.scope===`personal`?x():nt()}),e.isGlobalDefault?(0,q.jsx)(P,{variant:`default`,children:Oe()}):null]}),(0,q.jsxs)(`div`,{className:`oc-chart-avail__groups`,children:[(0,q.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:Ye()}),(a??[]).map(e=>(0,q.jsxs)(P,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e.name,(0,q.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":ze({group:e.name}),onClick:()=>void l(e.groupId),children:(0,q.jsx)(T,{className:`size-3`})})]},e.groupId)),s.length>0?(0,q.jsxs)(R,{value:``,onValueChange:e=>void c(e),children:[(0,q.jsx)(j,{size:`sm`,className:`w-56`,children:(0,q.jsx)(D,{placeholder:Te()})}),(0,q.jsx)(M,{children:s.map(e=>(0,q.jsx)(L,{value:e._id,children:e.name},e._id))})]}):t.length===0?(0,q.jsx)(`span`,{className:`oc-show__desc`,children:et()}):null]})]})}function $t({chart:e}){let t=b(S.charts.promoteChartToCommon),n=b(S.charts.deleteChart);async function r(){if(e.chartId!==void 0)try{await t({chartId:e.chartId})}catch{}}async function i(){if(e.chartId!==void 0&&window.confirm(C()))try{await n({chartId:e.chartId})}catch{}}return(0,q.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,q.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,q.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,q.jsx)(P,{variant:e.scope===`common`?`outline`:`secondary`,children:e.scope===`common`?Ze():x()}),e.ownerLabel?(0,q.jsx)(`span`,{className:`oc-show__desc`,children:Re({owner:e.ownerLabel})}):null]}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[e.scope===`personal`?(0,q.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>void r(),children:Pe()}):null,(0,q.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>void i(),children:je()})]})]})}function en({defaultThemeMode:e,defaultLocale:t,defaultChartKey:n}){let r=b(S.admin.setDefaultThemeMode),a=b(S.admin.setDefaultLocale),o=b(S.charts.setDefaultChart),s=y(S.charts.listChartsAdmin),c=y(S.groups.listGroups,{}),l=e??`system`,u=t??`fr`;return(0,q.jsxs)(`div`,{className:`oc-appearance-admin`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h2`,{className:`oc-show__title`,children:d()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:he()})]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:Fe()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Le()})]}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(E,{variant:n===null?`default`:`outline`,size:`sm`,onClick:()=>void o({name:null}),children:_()}),gt.map(e=>(0,q.jsx)(E,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void o({name:e.key}),children:e.name},e.key)),(s??[]).filter(e=>e.kind===`custom`&&e.scope===`common`).map(e=>(0,q.jsx)(E,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void o({name:e.key}),children:e.name},e.key))]})]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:Ge()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Xe()})]}),(0,q.jsx)(`div`,{className:`oc-chart-avail-list`,children:(s??[]).filter(e=>!(e.kind===`custom`&&e.scope===`common`)).map(e=>(0,q.jsx)(Qt,{chart:e,groups:c??[]},e.key))})]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:Ne()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:ke()})]}),(0,q.jsx)(`div`,{className:`oc-chart-avail-list`,children:(s??[]).filter(e=>e.kind===`builtin`||e.scope===`common`).map(e=>(0,q.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,q.jsx)(`div`,{className:`oc-chart-avail__head`,children:(0,q.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name})}),(0,q.jsx)($,{chart:e})]},e.key))})]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:we()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Ie()})]}),(()=>{let e=(s??[]).filter(e=>e.kind===`custom`);return e.length===0?(0,q.jsx)(`p`,{className:`oc-show__desc`,children:rt()}):(0,q.jsx)(`div`,{className:`oc-chart-avail-list`,children:e.map(e=>(0,q.jsx)($t,{chart:e},e.key))})})()]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:ie()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:Be()})]}),(0,q.jsx)(`div`,{className:`oc-show__row`,children:[`light`,`dark`,`system`].map(e=>(0,q.jsx)(E,{variant:l===e?`default`:`outline`,size:`sm`,onClick:()=>void r({mode:e}),children:Wt(e)},e))})]}),(0,q.jsxs)(`section`,{className:`oc-show__section`,children:[(0,q.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,q.jsx)(`h3`,{className:`oc-show__title`,children:i()}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:He()})]}),(0,q.jsx)(`div`,{className:`oc-show__row`,children:[`fr`,`en`].map(e=>(0,q.jsx)(E,{variant:u===e?`default`:`outline`,size:`sm`,onClick:()=>void a({locale:e}),children:e===`fr`?it():Se()},e))}),(0,q.jsx)(`p`,{className:`oc-show__desc`,children:ce()})]})]})}function tn(){let e=y(S.me.getMe,{host:I}),t=_t(e?.resolvedThemeMode);return(0,q.jsxs)(`div`,{className:`oc-appearance`,children:[(0,q.jsx)(qt,{selectedKey:e?.chartKey??null,resolvedMode:t}),(0,q.jsx)(Jt,{}),(0,q.jsx)(Zt,{}),e?.role===`admin`?(0,q.jsx)(en,{defaultThemeMode:e.defaultThemeMode,defaultLocale:e.defaultLocale,defaultChartKey:e.defaultChartKey}):null]})}function nn(){let[e,t]=(0,U.useState)(!0),[n,r]=(0,U.useState)(`per-user`),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(J),[c,u]=(0,U.useState)(J),[d,f]=(0,U.useState)(Y),p=i!==``||o!==J||c!==J;function m(){a(``),s(J),u(J),f(Y)}return(0,q.jsxs)(`div`,{className:`oc-show`,children:[(0,q.jsx)(tn,{}),(0,q.jsxs)(`details`,{className:`oc-show__ref`,children:[(0,q.jsx)(`summary`,{className:`oc-show__title`,children:l()}),(0,q.jsxs)(Z,{title:`Buttons`,description:`Variants`,children:[(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(E,{children:`Default`}),(0,q.jsx)(E,{variant:`secondary`,children:`Secondary`}),(0,q.jsx)(E,{variant:`outline`,children:`Outline`}),(0,q.jsx)(E,{variant:`ghost`,children:`Ghost`}),(0,q.jsx)(E,{variant:`destructive`,children:`Destructive`}),(0,q.jsx)(E,{variant:`link`,children:`Link`})]}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(E,{size:`sm`,children:`Small`}),(0,q.jsx)(E,{children:`Default`}),(0,q.jsx)(E,{size:`lg`,children:`Large`}),(0,q.jsx)(E,{size:`icon`,"aria-label":`more`,children:(0,q.jsx)(O,{})}),(0,q.jsx)(E,{disabled:!0,children:`Disabled`})]})]}),(0,q.jsx)(Z,{title:`Badges`,children:(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(P,{children:`Default`}),(0,q.jsx)(P,{variant:`secondary`,children:`Secondary`}),(0,q.jsx)(P,{variant:`outline`,children:`Outline`}),(0,q.jsx)(P,{variant:`destructive`,children:`Destructive`})]})}),(0,q.jsx)(Z,{title:`Inputs & selection`,children:(0,q.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,q.jsx)(k,{placeholder:`Text input…`}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsxs)(R,{value:n,onValueChange:r,children:[(0,q.jsx)(j,{className:`w-56`,children:(0,q.jsx)(D,{placeholder:`Select…`})}),(0,q.jsxs)(M,{children:[(0,q.jsx)(L,{value:`per-user`,children:`per-user (chacun son agent)`}),(0,q.jsx)(L,{value:`shared`,children:`shared (agent commun)`})]})]}),(0,q.jsxs)(`label`,{className:`oc-show__check`,children:[(0,q.jsx)(A,{checked:e,onCheckedChange:e=>t(!!e)}),`Checkbox`]})]})]})}),(0,q.jsx)(Z,{title:`Filtres & plage temporelle`,description:`Barre réutilisable (recherche debouncée + selects rapides à largeur auto + plage façon Grafana) et constructeur de filtre avancé. Câblée dans Users, Groups, Comptes de service, Traces, Anomalies, Audit et KPI.`,children:(0,q.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,q.jsxs)(kt,{q:i,onQChange:a,searchPlaceholder:`Rechercher (kind, principal, rôle, route…)`,timeRange:d,onTimeRangeChange:f,onReset:m,canReset:p,children:[(0,q.jsxs)(R,{value:o,onValueChange:s,children:[(0,q.jsx)(j,{size:`sm`,children:(0,q.jsx)(D,{})}),(0,q.jsxs)(M,{children:[(0,q.jsx)(L,{value:J,children:`Toutes directions`}),(0,q.jsx)(L,{value:`inbound`,children:`inbound`}),(0,q.jsx)(L,{value:`outbound`,children:`outbound`}),(0,q.jsx)(L,{value:`internal`,children:`internal`})]})]}),(0,q.jsxs)(R,{value:c,onValueChange:u,children:[(0,q.jsx)(j,{size:`sm`,children:(0,q.jsx)(D,{})}),(0,q.jsxs)(M,{children:[(0,q.jsx)(L,{value:J,children:`Toutes sévérités`}),(0,q.jsx)(L,{value:`info`,children:`info`}),(0,q.jsx)(L,{value:`warn`,children:`warn`}),(0,q.jsx)(L,{value:`critical`,children:`critical`})]})]})]}),(0,q.jsx)(At,{fields:X,onChange:()=>{}}),(0,q.jsxs)(`div`,{className:`oc-show__row`,children:[(0,q.jsx)(`span`,{className:`oc-show__desc`,children:`Sélecteur de plage seul :`}),(0,q.jsx)(pt,{value:d,onChange:f})]})]})}),(0,q.jsx)(Z,{title:`Dropdown menu`,description:`Row actions / kebab`,children:(0,q.jsxs)(ht,{children:[(0,q.jsx)(vt,{asChild:!0,children:(0,q.jsx)(E,{variant:`outline`,size:`icon`,"aria-label":`Open menu`,children:(0,q.jsx)(O,{})})}),(0,q.jsxs)(mt,{align:`start`,children:[(0,q.jsx)(yt,{children:`Actions`}),(0,q.jsx)(F,{}),(0,q.jsx)(N,{children:`Edit`}),(0,q.jsx)(N,{children:`Duplicate`}),(0,q.jsx)(F,{}),(0,q.jsx)(N,{variant:`destructive`,children:`Delete`})]})]})}),(0,q.jsx)(Z,{title:`Card`,children:(0,q.jsxs)(Tt,{className:`w-80`,children:[(0,q.jsxs)(bt,{children:[(0,q.jsx)(Ct,{children:`Instance`}),(0,q.jsx)(wt,{children:`Non-secret metadata only.`})]}),(0,q.jsx)(St,{className:`text-sm text-muted-foreground`,children:`ws://gateway.example.org:18789`}),(0,q.jsxs)(xt,{className:`gap-2`,children:[(0,q.jsx)(E,{size:`sm`,children:`Save`}),(0,q.jsx)(E,{size:`sm`,variant:`ghost`,children:`Cancel`})]})]})}),(0,q.jsx)(Z,{title:`Table`,children:(0,q.jsxs)(Ot,{children:[(0,q.jsx)(Et,{children:(0,q.jsxs)(B,{children:[(0,q.jsx)(z,{className:`w-8`,children:(0,q.jsx)(A,{"aria-label":`select all`})}),(0,q.jsx)(z,{children:`Name`}),(0,q.jsx)(z,{children:`Mode`}),(0,q.jsx)(z,{className:`text-right`,children:`Status`}),(0,q.jsx)(z,{className:`w-8`})]})}),(0,q.jsx)(Dt,{children:[{n:`admins`,m:`per-user`,s:`active`},{n:`family`,m:`shared`,s:`active`}].map(e=>(0,q.jsxs)(B,{children:[(0,q.jsx)(V,{children:(0,q.jsx)(A,{"aria-label":`select ${e.n}`})}),(0,q.jsx)(V,{className:`font-medium`,children:e.n}),(0,q.jsx)(V,{children:(0,q.jsx)(P,{variant:`secondary`,children:e.m})}),(0,q.jsx)(V,{className:`text-right`,children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,q.jsx)(w,{className:`size-3.5`}),` `,e.s]})}),(0,q.jsx)(V,{children:(0,q.jsx)(E,{variant:`ghost`,size:`icon`,"aria-label":`row actions`,children:(0,q.jsx)(O,{})})})]},e.n))})]})}),(0,q.jsx)(Z,{title:`App fragments`,description:`Chat-specific components`,children:(0,q.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,q.jsx)(`div`,{className:`oc-msg oc-msg--assistant`,children:(0,q.jsx)(`div`,{className:`oc-msg__body`,children:`Assistant message bubble.`})}),(0,q.jsx)(`div`,{className:`oc-tool oc-tool--completed`,children:(0,q.jsxs)(`div`,{className:`oc-tool__header`,children:[(0,q.jsx)(`span`,{className:`oc-tool__icon`,children:`✓`}),(0,q.jsx)(`span`,{className:`oc-tool__name`,children:`write-file`}),(0,q.jsx)(`span`,{className:`oc-tool__phase`,children:`completed`})]})}),(0,q.jsxs)(`div`,{className:`oc-run-status oc-run-status--streaming`,children:[(0,q.jsx)(`span`,{className:`oc-run-status__dot`}),(0,q.jsx)(`span`,{className:`oc-run-status__label`,children:`Running`})]})]})})]})]})}export{nn as ThemeShowroom};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$o as r,Go as i,Jo as a,Ko as o,Qo as s,Xo as c,Yo as l,Zo as u,dw as d,es as f,ns as p,qo as m,ts as h}from"./dist-ws-D-Lv-.js";import{t as g}from"./button-DuXPa4Vl.js";import{J as _,ct as v,lt as y,st as b,ut as x,vt as S}from"./index-D2h8Mdp2.js";var C=d(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),w=t(e(),1),T={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function E(e,t){let n=e.trim();if(n===`now`)return t;let r=/^now-(\d+)([smhdw])$/.exec(n);if(r===null)return null;let i=Number(r[1]),a=T[r[2]];return!Number.isFinite(i)||a===void 0?null:t-i*a}function D(e,t=Date.now()){return e.kind===`absolute`?{from:e.from,to:e.to}:{from:E(e.from,t)??t-T.h,to:E(e.to,t)??t}}var O=[{label:p(),from:`now-5m`},{label:h(),from:`now-15m`},{label:f(),from:`now-30m`},{label:r(),from:`now-1h`},{label:s(),from:`now-3h`},{label:u(),from:`now-6h`},{label:c(),from:`now-12h`},{label:l(),from:`now-24h`},{label:a(),from:`now-2d`},{label:m(),from:`now-7d`},{label:o(),from:`now-30d`},{label:i(),from:`now-90d`}];function k(e){return new Date(e).toLocaleString(`fr-FR`,{day:`2-digit`,month:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function A(e){if(e.kind===`relative`){let t=O.find(t=>t.from===e.from&&e.to===`now`);return t?t.label:`${e.from} → ${e.to}`}return`${k(e.from)} → ${k(e.to)}`}function j(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function M(e){if(e===``)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function N(e){let t=e.trim();return t===`true`?!0:t===`false`?!1:t!==``&&Number.isFinite(Number(t))?Number(t):e}var P=n();function F(e){let[t,n]=(0,w.useState)(0);return(0,w.useEffect)(()=>{if(e.kind!==`relative`)return;let t=window.setInterval(()=>n(e=>e+1),3e4);return()=>window.clearInterval(t)},[e.kind]),(0,w.useMemo)(()=>{let{from:t,to:n}=D(e);return e.kind===`absolute`?{from:t,to:n}:{from:I(t),to:I(n)}},[e,t])}function I(e){return Math.floor(e/6e4)*6e4}function L({value:e,onChange:t}){let[n,r]=(0,w.useState)(!1),[i,a]=(0,w.useState)(``),o=D(e),[s,c]=(0,w.useState)(()=>j(o.from)),[l,u]=(0,w.useState)(()=>j(o.to));function d(t){if(t){let t=D(e);c(j(t.from)),u(j(t.to)),a(``)}r(t)}function f(e){t({kind:`relative`,from:e,to:`now`}),r(!1)}function p(){let e=M(s),n=M(l);e===null||n===null||(t({kind:`absolute`,from:e,to:n}),r(!1))}let m=(0,w.useMemo)(()=>{let e=i.trim().toLowerCase();return e===``?O:O.filter(t=>t.label.toLowerCase().includes(e)||t.from.toLowerCase().includes(e))},[i]),h=M(s)!==null&&M(l)!==null;return(0,P.jsxs)(y,{open:n,onOpenChange:d,children:[(0,P.jsx)(x,{asChild:!0,children:(0,P.jsxs)(g,{variant:`outline`,size:`sm`,className:`oc-timerange__trigger`,children:[(0,P.jsx)(C,{}),A(e)]})}),(0,P.jsx)(v,{children:(0,P.jsx)(b,{align:`end`,sideOffset:6,className:`oc-timerange__panel z-50 rounded-lg border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,children:(0,P.jsxs)(`div`,{className:`oc-timerange__cols`,children:[(0,P.jsxs)(`div`,{className:`oc-timerange__absolute`,children:[(0,P.jsx)(`div`,{className:`oc-timerange__section-title`,children:`Plage absolue`}),(0,P.jsxs)(`label`,{className:`oc-field`,children:[(0,P.jsx)(`span`,{className:`oc-field__label`,children:`De`}),(0,P.jsx)(_,{type:`datetime-local`,value:s,onChange:e=>c(e.target.value)})]}),(0,P.jsxs)(`label`,{className:`oc-field`,children:[(0,P.jsx)(`span`,{className:`oc-field__label`,children:`À`}),(0,P.jsx)(_,{type:`datetime-local`,value:l,onChange:e=>u(e.target.value)})]}),(0,P.jsx)(g,{size:`sm`,className:`oc-timerange__apply`,disabled:!h,onClick:p,children:`Appliquer`})]}),(0,P.jsxs)(`div`,{className:`oc-timerange__relative`,children:[(0,P.jsxs)(`div`,{className:`oc-timerange__search`,children:[(0,P.jsx)(S,{className:`oc-timerange__search-icon`,"aria-hidden":!0}),(0,P.jsx)(_,{value:i,onChange:e=>a(e.target.value),placeholder:`Rechercher une plage`,"aria-label":`Rechercher une plage relative`})]}),(0,P.jsx)(`ul`,{className:`oc-timerange__list`,children:m.length===0?(0,P.jsx)(`li`,{className:`oc-timerange__empty`,children:`Aucune plage.`}):m.map(t=>(0,P.jsx)(`li`,{children:(0,P.jsx)(`button`,{type:`button`,className:`oc-timerange__option`+(e.kind===`relative`&&e.from===t.from&&e.to===`now`?` is-active`:``),onClick:()=>f(t.from),children:t.label})},t.from))})]})]})})})]})}export{F as n,N as r,L as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$o as r,Go as i,Jo as a,Ko as o,Qo as s,Xo as c,Yo as l,Zo as u,dw as d,es as f,ns as p,qo as m,ts as h}from"./dist-ws-D-Lv-.js";import{t as g}from"./button-DuXPa4Vl.js";import{J as _,ct as v,lt as y,st as b,ut as x,vt as S}from"./index-Bp-uQn4K.js";var C=d(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),w=t(e(),1),T={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function E(e,t){let n=e.trim();if(n===`now`)return t;let r=/^now-(\d+)([smhdw])$/.exec(n);if(r===null)return null;let i=Number(r[1]),a=T[r[2]];return!Number.isFinite(i)||a===void 0?null:t-i*a}function D(e,t=Date.now()){return e.kind===`absolute`?{from:e.from,to:e.to}:{from:E(e.from,t)??t-T.h,to:E(e.to,t)??t}}var O=[{label:p(),from:`now-5m`},{label:h(),from:`now-15m`},{label:f(),from:`now-30m`},{label:r(),from:`now-1h`},{label:s(),from:`now-3h`},{label:u(),from:`now-6h`},{label:c(),from:`now-12h`},{label:l(),from:`now-24h`},{label:a(),from:`now-2d`},{label:m(),from:`now-7d`},{label:o(),from:`now-30d`},{label:i(),from:`now-90d`}];function k(e){return new Date(e).toLocaleString(`fr-FR`,{day:`2-digit`,month:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function A(e){if(e.kind===`relative`){let t=O.find(t=>t.from===e.from&&e.to===`now`);return t?t.label:`${e.from} → ${e.to}`}return`${k(e.from)} → ${k(e.to)}`}function j(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function M(e){if(e===``)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function N(e){let t=e.trim();return t===`true`?!0:t===`false`?!1:t!==``&&Number.isFinite(Number(t))?Number(t):e}var P=n();function F(e){let[t,n]=(0,w.useState)(0);return(0,w.useEffect)(()=>{if(e.kind!==`relative`)return;let t=window.setInterval(()=>n(e=>e+1),3e4);return()=>window.clearInterval(t)},[e.kind]),(0,w.useMemo)(()=>{let{from:t,to:n}=D(e);return e.kind===`absolute`?{from:t,to:n}:{from:I(t),to:I(n)}},[e,t])}function I(e){return Math.floor(e/6e4)*6e4}function L({value:e,onChange:t}){let[n,r]=(0,w.useState)(!1),[i,a]=(0,w.useState)(``),o=D(e),[s,c]=(0,w.useState)(()=>j(o.from)),[l,u]=(0,w.useState)(()=>j(o.to));function d(t){if(t){let t=D(e);c(j(t.from)),u(j(t.to)),a(``)}r(t)}function f(e){t({kind:`relative`,from:e,to:`now`}),r(!1)}function p(){let e=M(s),n=M(l);e===null||n===null||(t({kind:`absolute`,from:e,to:n}),r(!1))}let m=(0,w.useMemo)(()=>{let e=i.trim().toLowerCase();return e===``?O:O.filter(t=>t.label.toLowerCase().includes(e)||t.from.toLowerCase().includes(e))},[i]),h=M(s)!==null&&M(l)!==null;return(0,P.jsxs)(y,{open:n,onOpenChange:d,children:[(0,P.jsx)(x,{asChild:!0,children:(0,P.jsxs)(g,{variant:`outline`,size:`sm`,className:`oc-timerange__trigger`,children:[(0,P.jsx)(C,{}),A(e)]})}),(0,P.jsx)(v,{children:(0,P.jsx)(b,{align:`end`,sideOffset:6,className:`oc-timerange__panel z-50 rounded-lg border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,children:(0,P.jsxs)(`div`,{className:`oc-timerange__cols`,children:[(0,P.jsxs)(`div`,{className:`oc-timerange__absolute`,children:[(0,P.jsx)(`div`,{className:`oc-timerange__section-title`,children:`Plage absolue`}),(0,P.jsxs)(`label`,{className:`oc-field`,children:[(0,P.jsx)(`span`,{className:`oc-field__label`,children:`De`}),(0,P.jsx)(_,{type:`datetime-local`,value:s,onChange:e=>c(e.target.value)})]}),(0,P.jsxs)(`label`,{className:`oc-field`,children:[(0,P.jsx)(`span`,{className:`oc-field__label`,children:`À`}),(0,P.jsx)(_,{type:`datetime-local`,value:l,onChange:e=>u(e.target.value)})]}),(0,P.jsx)(g,{size:`sm`,className:`oc-timerange__apply`,disabled:!h,onClick:p,children:`Appliquer`})]}),(0,P.jsxs)(`div`,{className:`oc-timerange__relative`,children:[(0,P.jsxs)(`div`,{className:`oc-timerange__search`,children:[(0,P.jsx)(S,{className:`oc-timerange__search-icon`,"aria-hidden":!0}),(0,P.jsx)(_,{value:i,onChange:e=>a(e.target.value),placeholder:`Rechercher une plage`,"aria-label":`Rechercher une plage relative`})]}),(0,P.jsx)(`ul`,{className:`oc-timerange__list`,children:m.length===0?(0,P.jsx)(`li`,{className:`oc-timerange__empty`,children:`Aucune plage.`}):m.map(t=>(0,P.jsx)(`li`,{children:(0,P.jsx)(`button`,{type:`button`,className:`oc-timerange__option`+(e.kind===`relative`&&e.from===t.from&&e.to===`now`?` is-active`:``),onClick:()=>f(t.from),children:t.label})},t.from))})]})]})})})]})}export{F as n,N as r,L as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,Al as i,Bl as a,Cl as o,Dl as s,El as c,Fl as l,Gg as u,Gl as d,Hg as f,Hl as p,Il as m,Jg as h,Jl as g,Kg as _,Kl as v,Ll as ee,Ml as te,Nl as ne,Ol as re,Pl as ie,Qg as y,Rl as ae,Sl as oe,Tl as se,Ug as b,Ul as ce,Vg as x,Vl as le,Wg as ue,Wl as de,Xg as fe,Xl as pe,Yg as S,Yl as me,Zg as C,Zl as he,_l as ge,_w as w,a_ as T,bl as _e,c_ as E,d_ as D,e_ as O,f_ as k,gl as ve,gw as A,hl as j,i_ as M,jl as ye,kl as be,l_ as N,ml as P,n_ as F,o_ as I,pl as L,qg as R,ql as xe,r_ as z,s_ as Se,t_ as Ce,u_ as we,uw as B,vl as Te,wl as Ee,xl as De,yl as Oe,zl as ke}from"./dist-ws-D-Lv-.js";import{n as Ae}from"./dist-DjXzB84V.js";import{n as je}from"./TimeRangePicker-CW3Y_mIF.js";import{t as Me}from"./x-D96nOW2m.js";import{t as V}from"./button-DuXPa4Vl.js";import{A as Ne,C as H,F as Pe,I as Fe,Ot as Ie,P as Le,R as Re,S as U,Tt as ze,a as Be,b as W,i as Ve,kt as He,m as G,o as Ue,ot as We,r as Ge,x as K,y as q,z as Ke}from"./index-D2h8Mdp2.js";import{t as qe}from"./FilterBar-B_NTOVaW.js";import{t as Je}from"./AdvancedFilter-BHDc_Mha.js";import{t as Ye}from"./DataTableShell-D_G9F2EP.js";var J=t(e(),1),Y=n(),X=e=>e===null?`—`:String(Math.round(e));function Xe(){let e=w(B.me.getMe,{host:We})?.role===`admin`,t=w(B.deliveryTiming.getDeliveryStatus,{}),n=A(B.deliveryTiming.startDeliveryRecord),r=A(B.deliveryTiming.stopDeliveryRecord),i=A(B.deliveryTiming.deleteDeliverySessions),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(new Set),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(!1),h=w(B.deliveryTiming.listDeliverySessions,a?{}:`skip`),g=w(B.deliveryTiming.getDeliveryReport,a?{sessionId:s??void 0}:`skip`),v=t?.recording??!1,ee=async()=>{f(!0);try{v?await r({}):await n({})}finally{f(!1)}},te=()=>{g&&navigator.clipboard?.writeText(Ne(g)).then(()=>{m(!0),window.setTimeout(()=>m(!1),1200)}).catch(()=>{})},ne=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),re=async()=>{let e=[...l];if(e.length!==0){f(!0);try{await i({sessionIds:e}),s!==null&&l.has(s)&&c(null),u(new Set)}finally{f(!1)}}};return(0,Y.jsxs)(`section`,{className:`mb-4 flex flex-col gap-3 rounded-lg border border-border p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:k()}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:D()})]}),e?(0,Y.jsx)(V,{variant:v?`destructive`:`default`,size:`sm`,disabled:d||t===void 0,onClick:()=>void ee(),children:v?N():we()}):null]}),v?(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(G,{variant:`secondary`,children:E()}),t?.startedAt?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:Se({time:new Date(t.startedAt).toLocaleTimeString()})}):null]}):null,(0,Y.jsx)(`div`,{children:(0,Y.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>o(e=>!e),children:a?T():I()})}),a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ze,{sessions:h,selected:s,checked:l,isAdmin:e,onSelect:c,onToggleCheck:ne}),e&&l.size>0?(0,Y.jsx)(`div`,{children:(0,Y.jsx)(V,{variant:`destructive`,size:`sm`,disabled:d,onClick:()=>void re(),children:_({n:l.size})})}):null,(0,Y.jsx)(Qe,{report:g,copied:p,onCopy:te})]}):null]})}function Ze({sessions:e,selected:t,checked:n,isAdmin:r,onSelect:i,onToggleCheck:a}){return e?e.length===0?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:ue()}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>{let o=t===e.sessionId,s=new Date(e.startedAt).toLocaleString();return(0,Y.jsxs)(`li`,{className:`flex items-center gap-2 border-t border-border py-1 text-sm first:border-t-0`,children:[r?(0,Y.jsx)(`input`,{type:`checkbox`,"aria-label":`${b()} — ${s}`,checked:n.has(e.sessionId),onChange:()=>a(e.sessionId)}):null,(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":o,className:`flex-1 truncate text-left ${o?`font-medium`:`text-muted-foreground`}`,onClick:()=>i(o?null:e.sessionId),children:s}),e.active?(0,Y.jsx)(G,{variant:`secondary`,children:f()}):null]},e.sessionId)})})]}):null}function Qe({report:e,copied:t,onCopy:n}){if(!e)return null;if(e.count===0||e.segments===null)return(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:M()});let i=e.segments,a=(e,t)=>(0,Y.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,Y.jsx)(`td`,{className:`py-1`,children:e}),(0,Y.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.count}),(0,Y.jsxs)(`td`,{className:`py-1 text-right tabular-nums`,children:[X(t.p50),` / `,X(t.p95),` / `,X(t.max)]})]});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.count,` `,x()]}),(0,Y.jsxs)(V,{variant:`outline`,size:`sm`,onClick:n,children:[t?(0,Y.jsx)(Ae,{size:13,"aria-hidden":!0}):(0,Y.jsx)(ze,{size:13,"aria-hidden":!0}),t?R():h()]})]}),(0,Y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`py-1 font-medium`,children:z()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:F()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:Ce()})]})}),(0,Y.jsxs)(`tbody`,{children:[a(O(),i.bridge),a(r(),i.A),a(y(),i.C)]})]}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:C()}),e.truncated?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:S()}):null,(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:fe()})]})}var $e=[50,100,200,500],Z=`all`,Q=`__all__`,et=[`2xx`,`4xx`,`5xx`],tt=[`user`,`service`,`system`],nt=[`inbound`,`outbound`,`internal`],rt={kind:`relative`,from:`now-30d`,to:`now`},it=[{value:`kind`,label:`kind`},{value:`status`,label:`status`},{value:`latencyMs`,label:`latence (ms)`},{value:`principalType`,label:`principal`},{value:`direction`,label:`direction`},{value:`roleKey`,label:`rôle`},{value:`route`,label:`route`},{value:`correlationId`,label:`correlationId`}];function at(){let e=He({from:`/settings/traces`}),t=Ie({from:`/settings/traces`}),n=e.limit,r=e.kind,u=e.statusClass??Q,f=e.principalType??Q,h=e.direction??Q,_=e.roleKey??Q,y=e.q??``,b=Ge(e.from,e.to),x=(0,J.useMemo)(()=>Ue(e.adv),[e.adv]),{from:ue,to:fe}=je(b),[S,C]=(0,J.useState)(null),[T,E]=(0,J.useState)(null),D=e=>void t({search:t=>({...t,limit:e})}),O=e=>void t({search:t=>({...t,kind:e})}),k=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),A=e=>void t({search:t=>({...t,statusClass:e===Q?void 0:e})}),j=e=>void t({search:t=>({...t,principalType:e===Q?void 0:e})}),M=e=>void t({search:t=>({...t,direction:e===Q?void 0:e})}),N=e=>void t({search:t=>({...t,roleKey:e===Q?void 0:e})}),P=e=>void t({search:t=>({...t,...Be(e)})}),F=e=>void t({search:t=>({...t,adv:Ve(e)}),replace:!0}),I=w(B.observability.listEvents,{limit:n}),L=w(B.observability.listEvents,{limit:n,kind:r===Z?void 0:r,filter:{q:y||void 0,from:ue,to:fe,statusClass:u===Q?void 0:u,principalType:f===Q?void 0:f,direction:h===Q?void 0:h,roleKey:_===Q?void 0:_,advanced:x.length>0?x:void 0}}),R=(0,J.useMemo)(()=>{let e=new Set;for(let t of I??[])e.add(t.kind);return[...e].sort()},[I]),z=(0,J.useMemo)(()=>{let e=new Set;for(let t of I??[])t.roleKey&&e.add(t.roleKey);return[...e].sort()},[I]),Se=y!==``||u!==Q||f!==Q||h!==Q||_!==Q||x.length>0||b.kind!==`relative`||b.from!==rt.from;function Ce(){t({search:{limit:100,kind:`all`},replace:!0})}let we=S?I?.filter(e=>e.correlationId===S):L;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Xe,{}),(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[he(),(0,Y.jsx)(`strong`,{children:pe()}),me(),` `,(0,Y.jsx)(`span`,{className:`oc-filter__window`,children:g()})]}),(0,Y.jsxs)(qe,{q:y,onQChange:k,searchPlaceholder:xe(),timeRange:b,onTimeRangeChange:P,onReset:Ce,canReset:Se,children:[(0,Y.jsxs)(q,{value:u,onValueChange:A,children:[(0,Y.jsx)(U,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(H,{placeholder:v()})}),(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{value:Q,children:d()}),et.map(e=>(0,Y.jsx)(K,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:f,onValueChange:j,children:[(0,Y.jsx)(U,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(H,{placeholder:de()})}),(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{value:Q,children:ce()}),tt.map(e=>(0,Y.jsx)(K,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:h,onValueChange:M,children:[(0,Y.jsx)(U,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(H,{placeholder:p()})}),(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{value:Q,children:le()}),nt.map(e=>(0,Y.jsx)(K,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:_,onValueChange:N,children:[(0,Y.jsx)(U,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(H,{placeholder:a()})}),(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{value:Q,children:ke()}),z.map(e=>(0,Y.jsx)(K,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:r,onValueChange:O,children:[(0,Y.jsx)(U,{size:`sm`,className:`w-44`,children:(0,Y.jsx)(H,{placeholder:ae()})}),(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{value:Z,children:ee()}),R.map(e=>(0,Y.jsx)(K,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:String(n),onValueChange:e=>D(Number(e)),children:[(0,Y.jsx)(U,{size:`sm`,className:`w-28`,children:(0,Y.jsx)(H,{})}),(0,Y.jsx)(W,{children:$e.map(e=>(0,Y.jsx)(K,{value:String(e),children:m({count:e})},e))})]})]}),(0,Y.jsx)(Je,{fields:it,seed:x,onChange:F}),S?(0,Y.jsx)(`div`,{className:`oc-traces__followline`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-traces__chip`,onClick:()=>C(null),title:l(),children:[(0,Y.jsxs)(`span`,{className:`oc-traces__chip-label`,children:[ie(),(0,Y.jsx)(`code`,{children:$(S)})]}),(0,Y.jsx)(Me,{className:`oc-traces__chip-x`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`sr-only`,children:ne()})]})}):null,(0,Y.jsx)(Ye,{title:te(),rows:we,emptyHint:S?ye():i(),columns:[{header:be(),sort:e=>e.at,cell:e=>(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:new Date(e.at).toLocaleString(`fr-FR`)})},{header:re(),sort:e=>e.kind,cell:e=>(0,Y.jsx)(G,{variant:`secondary`,children:e.kind})},{header:s(),sort:e=>st(e)??null,cell:e=>{let t=st(e);return t?(0,Y.jsxs)(`span`,{className:`oc-traces__fail`,title:t,children:[`✕ `,t]}):(0,Y.jsx)(`span`,{className:`oc-traces__ok`,"aria-label":c(),children:`✓`})}},{header:se(),sort:e=>e.direction,cell:e=>e.direction?(0,Y.jsx)(G,{variant:`outline`,children:e.direction}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Ee(),sort:e=>e.principalType,cell:e=>(0,Y.jsxs)(`span`,{className:`oc-traces__principal`,children:[(0,Y.jsx)(G,{variant:`outline`,children:e.principalType}),e.principalId?(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:$(e.principalId)}):null]})},{header:o(),sort:e=>e.roleKey,cell:e=>e.roleKey?(0,Y.jsx)(G,{variant:`secondary`,children:e.roleKey}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:oe(),sort:e=>e.route,cell:e=>e.route?(0,Y.jsxs)(`span`,{className:`oc-traces__route`,children:[e.method?(0,Y.jsx)(`span`,{className:`oc-traces__method`,children:e.method}):null,(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.route})]}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:De(),sort:e=>e.status,cell:e=>e.status===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsx)(`span`,{className:`oc-traces__status ${ot(e.status)}`,children:e.status})},{header:_e(),sort:e=>e.latencyMs,cell:e=>e.latencyMs===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsxs)(`span`,{className:`oc-traces__mono`,children:[e.latencyMs,` ms`]})},{header:Oe(),sort:e=>e.correlationId,cell:e=>e.correlationId?(0,Y.jsx)(`button`,{type:`button`,className:`oc-traces__corr`,title:Te(),onClick:()=>C(e.correlationId),children:$(e.correlationId)}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:ge(),sort:e=>+!!e.meta,cell:e=>e.meta?(0,Y.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>E(e),children:ve()}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}]}),(0,Y.jsx)(ct,{row:T,onClose:()=>E(null)})]})}function ot(e){return e>=500?`oc-traces__status--5xx`:e>=400?`oc-traces__status--4xx`:e>=200&&e<300?`oc-traces__status--2xx`:`oc-traces__status--other`}function $(e){return e.length>8?e.slice(0,8):e}function st(e){if(typeof e.status==`number`&&e.status>=400)return String(e.status);if(!e.meta)return null;try{let t=JSON.parse(e.meta);if(e.kind===`openclaw.dispatch`&&t.dispatchStatus===`failed`)return t.errorCode??`failed`;if(e.kind===`assistant.stream`&&t.phase===`finalize`&&(t.streamStatus===`error`||t.streamStatus===`aborted`))return t.streamStatus;if(e.kind===`openclaw.ingest.denied`)return`denied`}catch{}return null}function ct({row:e,onClose:t}){let n=(0,J.useMemo)(()=>{if(!e?.meta)return``;try{return JSON.stringify(JSON.parse(e.meta),null,2)}catch{return e.meta}},[e]);return(0,Y.jsx)(Le,{open:e!==null,onOpenChange:e=>{e||t()},children:e?(0,Y.jsxs)(Pe,{className:`max-w-lg`,children:[(0,Y.jsxs)(Re,{children:[(0,Y.jsxs)(Ke,{className:`oc-traces__meta-title`,children:[j(),` `,(0,Y.jsx)(`code`,{children:e.kind}),(0,Y.jsx)(G,{variant:`outline`,children:P()})]}),(0,Y.jsx)(Fe,{children:L()})]}),(0,Y.jsx)(`pre`,{className:`oc-traces__meta-json`,children:n})]}):null})}export{at as TracesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,Al as i,Bl as a,Cl as o,Dl as s,El as c,Fl as l,Gg as u,Gl as d,Hg as f,Hl as p,Il as m,Jg as h,Jl as g,Kg as _,Kl as v,Ll as ee,Ml as te,Nl as ne,Ol as re,Pl as ie,Qg as y,Rl as ae,Sl as oe,Tl as se,Ug as b,Ul as ce,Vg as x,Vl as le,Wg as ue,Wl as de,Xg as fe,Xl as pe,Yg as S,Yl as me,Zg as C,Zl as he,_l as ge,_w as w,a_ as T,bl as _e,c_ as E,d_ as D,e_ as O,f_ as k,gl as ve,gw as A,hl as j,i_ as M,jl as ye,kl as be,l_ as N,ml as P,n_ as F,o_ as I,pl as L,qg as R,ql as xe,r_ as z,s_ as Se,t_ as Ce,u_ as we,uw as B,vl as Te,wl as Ee,xl as De,yl as Oe,zl as ke}from"./dist-ws-D-Lv-.js";import{n as Ae}from"./dist-DjXzB84V.js";import{n as je}from"./TimeRangePicker-BDN2rIcO.js";import{t as Me}from"./x-D96nOW2m.js";import{t as V}from"./button-DuXPa4Vl.js";import{A as Ne,C as H,F as Pe,I as Fe,Ot as Ie,P as Le,R as Re,S as U,Tt as ze,a as Be,b as W,i as Ve,kt as He,m as G,o as Ue,ot as We,r as Ge,x as K,y as q,z as Ke}from"./index-Bp-uQn4K.js";import{t as qe}from"./FilterBar-BmFEn3qs.js";import{t as Je}from"./AdvancedFilter-0hIaeD_5.js";import{t as Ye}from"./DataTableShell-B_P8ehdH.js";var J=t(e(),1),Y=n(),X=e=>e===null?`—`:String(Math.round(e));function Xe(){let e=w(B.me.getMe,{host:We})?.role===`admin`,t=w(B.deliveryTiming.getDeliveryStatus,{}),n=A(B.deliveryTiming.startDeliveryRecord),r=A(B.deliveryTiming.stopDeliveryRecord),i=A(B.deliveryTiming.deleteDeliverySessions),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(new Set),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(!1),h=w(B.deliveryTiming.listDeliverySessions,a?{}:`skip`),g=w(B.deliveryTiming.getDeliveryReport,a?{sessionId:s??void 0}:`skip`),v=t?.recording??!1,ee=async()=>{f(!0);try{v?await r({}):await n({})}finally{f(!1)}},te=()=>{g&&navigator.clipboard?.writeText(Ne(g)).then(()=>{m(!0),window.setTimeout(()=>m(!1),1200)}).catch(()=>{})},ne=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),re=async()=>{let e=[...l];if(e.length!==0){f(!0);try{await i({sessionIds:e}),s!==null&&l.has(s)&&c(null),u(new Set)}finally{f(!1)}}};return(0,Y.jsxs)(`section`,{className:`mb-4 flex flex-col gap-3 rounded-lg border border-border p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:k()}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:D()})]}),e?(0,Y.jsx)(V,{variant:v?`destructive`:`default`,size:`sm`,disabled:d||t===void 0,onClick:()=>void ee(),children:v?N():we()}):null]}),v?(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(G,{variant:`secondary`,children:E()}),t?.startedAt?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:Se({time:new Date(t.startedAt).toLocaleTimeString()})}):null]}):null,(0,Y.jsx)(`div`,{children:(0,Y.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>o(e=>!e),children:a?T():I()})}),a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ze,{sessions:h,selected:s,checked:l,isAdmin:e,onSelect:c,onToggleCheck:ne}),e&&l.size>0?(0,Y.jsx)(`div`,{children:(0,Y.jsx)(V,{variant:`destructive`,size:`sm`,disabled:d,onClick:()=>void re(),children:_({n:l.size})})}):null,(0,Y.jsx)(Qe,{report:g,copied:p,onCopy:te})]}):null]})}function Ze({sessions:e,selected:t,checked:n,isAdmin:r,onSelect:i,onToggleCheck:a}){return e?e.length===0?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:ue()}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>{let o=t===e.sessionId,s=new Date(e.startedAt).toLocaleString();return(0,Y.jsxs)(`li`,{className:`flex items-center gap-2 border-t border-border py-1 text-sm first:border-t-0`,children:[r?(0,Y.jsx)(`input`,{type:`checkbox`,"aria-label":`${b()} — ${s}`,checked:n.has(e.sessionId),onChange:()=>a(e.sessionId)}):null,(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":o,className:`flex-1 truncate text-left ${o?`font-medium`:`text-muted-foreground`}`,onClick:()=>i(o?null:e.sessionId),children:s}),e.active?(0,Y.jsx)(G,{variant:`secondary`,children:f()}):null]},e.sessionId)})})]}):null}function Qe({report:e,copied:t,onCopy:n}){if(!e)return null;if(e.count===0||e.segments===null)return(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:M()});let i=e.segments,a=(e,t)=>(0,Y.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,Y.jsx)(`td`,{className:`py-1`,children:e}),(0,Y.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.count}),(0,Y.jsxs)(`td`,{className:`py-1 text-right tabular-nums`,children:[X(t.p50),` / `,X(t.p95),` / `,X(t.max)]})]});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.count,` `,x()]}),(0,Y.jsxs)(V,{variant:`outline`,size:`sm`,onClick:n,children:[t?(0,Y.jsx)(Ae,{size:13,"aria-hidden":!0}):(0,Y.jsx)(ze,{size:13,"aria-hidden":!0}),t?R():h()]})]}),(0,Y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`py-1 font-medium`,children:z()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:F()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:Ce()})]})}),(0,Y.jsxs)(`tbody`,{children:[a(O(),i.bridge),a(r(),i.A),a(y(),i.C)]})]}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:C()}),e.truncated?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:S()}):null,(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:fe()})]})}var $e=[50,100,200,500],Z=`all`,Q=`__all__`,et=[`2xx`,`4xx`,`5xx`],tt=[`user`,`service`,`system`],nt=[`inbound`,`outbound`,`internal`],rt={kind:`relative`,from:`now-30d`,to:`now`},it=[{value:`kind`,label:`kind`},{value:`status`,label:`status`},{value:`latencyMs`,label:`latence (ms)`},{value:`principalType`,label:`principal`},{value:`direction`,label:`direction`},{value:`roleKey`,label:`rôle`},{value:`route`,label:`route`},{value:`correlationId`,label:`correlationId`}];function at(){let e=He({from:`/settings/traces`}),t=Ie({from:`/settings/traces`}),n=e.limit,r=e.kind,u=e.statusClass??Q,f=e.principalType??Q,h=e.direction??Q,_=e.roleKey??Q,y=e.q??``,b=Ge(e.from,e.to),x=(0,J.useMemo)(()=>Ue(e.adv),[e.adv]),{from:ue,to:fe}=je(b),[S,C]=(0,J.useState)(null),[T,E]=(0,J.useState)(null),D=e=>void t({search:t=>({...t,limit:e})}),O=e=>void t({search:t=>({...t,kind:e})}),k=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),A=e=>void t({search:t=>({...t,statusClass:e===Q?void 0:e})}),j=e=>void t({search:t=>({...t,principalType:e===Q?void 0:e})}),M=e=>void t({search:t=>({...t,direction:e===Q?void 0:e})}),N=e=>void t({search:t=>({...t,roleKey:e===Q?void 0:e})}),P=e=>void t({search:t=>({...t,...Be(e)})}),F=e=>void t({search:t=>({...t,adv:Ve(e)}),replace:!0}),I=w(B.observability.listEvents,{limit:n}),L=w(B.observability.listEvents,{limit:n,kind:r===Z?void 0:r,filter:{q:y||void 0,from:ue,to:fe,statusClass:u===Q?void 0:u,principalType:f===Q?void 0:f,direction:h===Q?void 0:h,roleKey:_===Q?void 0:_,advanced:x.length>0?x:void 0}}),R=(0,J.useMemo)(()=>{let e=new Set;for(let t of I??[])e.add(t.kind);return[...e].sort()},[I]),z=(0,J.useMemo)(()=>{let e=new Set;for(let t of I??[])t.roleKey&&e.add(t.roleKey);return[...e].sort()},[I]),Se=y!==``||u!==Q||f!==Q||h!==Q||_!==Q||x.length>0||b.kind!==`relative`||b.from!==rt.from;function Ce(){t({search:{limit:100,kind:`all`},replace:!0})}let we=S?I?.filter(e=>e.correlationId===S):L;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Xe,{}),(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[he(),(0,Y.jsx)(`strong`,{children:pe()}),me(),` `,(0,Y.jsx)(`span`,{className:`oc-filter__window`,children:g()})]}),(0,Y.jsxs)(qe,{q:y,onQChange:k,searchPlaceholder:xe(),timeRange:b,onTimeRangeChange:P,onReset:Ce,canReset:Se,children:[(0,Y.jsxs)(q,{value:u,onValueChange:A,children:[(0,Y.jsx)(U,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(H,{placeholder:v()})}),(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{value:Q,children:d()}),et.map(e=>(0,Y.jsx)(K,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:f,onValueChange:j,children:[(0,Y.jsx)(U,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(H,{placeholder:de()})}),(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{value:Q,children:ce()}),tt.map(e=>(0,Y.jsx)(K,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:h,onValueChange:M,children:[(0,Y.jsx)(U,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(H,{placeholder:p()})}),(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{value:Q,children:le()}),nt.map(e=>(0,Y.jsx)(K,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:_,onValueChange:N,children:[(0,Y.jsx)(U,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(H,{placeholder:a()})}),(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{value:Q,children:ke()}),z.map(e=>(0,Y.jsx)(K,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:r,onValueChange:O,children:[(0,Y.jsx)(U,{size:`sm`,className:`w-44`,children:(0,Y.jsx)(H,{placeholder:ae()})}),(0,Y.jsxs)(W,{children:[(0,Y.jsx)(K,{value:Z,children:ee()}),R.map(e=>(0,Y.jsx)(K,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:String(n),onValueChange:e=>D(Number(e)),children:[(0,Y.jsx)(U,{size:`sm`,className:`w-28`,children:(0,Y.jsx)(H,{})}),(0,Y.jsx)(W,{children:$e.map(e=>(0,Y.jsx)(K,{value:String(e),children:m({count:e})},e))})]})]}),(0,Y.jsx)(Je,{fields:it,seed:x,onChange:F}),S?(0,Y.jsx)(`div`,{className:`oc-traces__followline`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-traces__chip`,onClick:()=>C(null),title:l(),children:[(0,Y.jsxs)(`span`,{className:`oc-traces__chip-label`,children:[ie(),(0,Y.jsx)(`code`,{children:$(S)})]}),(0,Y.jsx)(Me,{className:`oc-traces__chip-x`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`sr-only`,children:ne()})]})}):null,(0,Y.jsx)(Ye,{title:te(),rows:we,emptyHint:S?ye():i(),columns:[{header:be(),sort:e=>e.at,cell:e=>(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:new Date(e.at).toLocaleString(`fr-FR`)})},{header:re(),sort:e=>e.kind,cell:e=>(0,Y.jsx)(G,{variant:`secondary`,children:e.kind})},{header:s(),sort:e=>st(e)??null,cell:e=>{let t=st(e);return t?(0,Y.jsxs)(`span`,{className:`oc-traces__fail`,title:t,children:[`✕ `,t]}):(0,Y.jsx)(`span`,{className:`oc-traces__ok`,"aria-label":c(),children:`✓`})}},{header:se(),sort:e=>e.direction,cell:e=>e.direction?(0,Y.jsx)(G,{variant:`outline`,children:e.direction}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Ee(),sort:e=>e.principalType,cell:e=>(0,Y.jsxs)(`span`,{className:`oc-traces__principal`,children:[(0,Y.jsx)(G,{variant:`outline`,children:e.principalType}),e.principalId?(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:$(e.principalId)}):null]})},{header:o(),sort:e=>e.roleKey,cell:e=>e.roleKey?(0,Y.jsx)(G,{variant:`secondary`,children:e.roleKey}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:oe(),sort:e=>e.route,cell:e=>e.route?(0,Y.jsxs)(`span`,{className:`oc-traces__route`,children:[e.method?(0,Y.jsx)(`span`,{className:`oc-traces__method`,children:e.method}):null,(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.route})]}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:De(),sort:e=>e.status,cell:e=>e.status===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsx)(`span`,{className:`oc-traces__status ${ot(e.status)}`,children:e.status})},{header:_e(),sort:e=>e.latencyMs,cell:e=>e.latencyMs===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsxs)(`span`,{className:`oc-traces__mono`,children:[e.latencyMs,` ms`]})},{header:Oe(),sort:e=>e.correlationId,cell:e=>e.correlationId?(0,Y.jsx)(`button`,{type:`button`,className:`oc-traces__corr`,title:Te(),onClick:()=>C(e.correlationId),children:$(e.correlationId)}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:ge(),sort:e=>+!!e.meta,cell:e=>e.meta?(0,Y.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>E(e),children:ve()}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}]}),(0,Y.jsx)(ct,{row:T,onClose:()=>E(null)})]})}function ot(e){return e>=500?`oc-traces__status--5xx`:e>=400?`oc-traces__status--4xx`:e>=200&&e<300?`oc-traces__status--2xx`:`oc-traces__status--other`}function $(e){return e.length>8?e.slice(0,8):e}function st(e){if(typeof e.status==`number`&&e.status>=400)return String(e.status);if(!e.meta)return null;try{let t=JSON.parse(e.meta);if(e.kind===`openclaw.dispatch`&&t.dispatchStatus===`failed`)return t.errorCode??`failed`;if(e.kind===`assistant.stream`&&t.phase===`finalize`&&(t.streamStatus===`error`||t.streamStatus===`aborted`))return t.streamStatus;if(e.kind===`openclaw.ingest.denied`)return`denied`}catch{}return null}function ct({row:e,onClose:t}){let n=(0,J.useMemo)(()=>{if(!e?.meta)return``;try{return JSON.stringify(JSON.parse(e.meta),null,2)}catch{return e.meta}},[e]);return(0,Y.jsx)(Le,{open:e!==null,onOpenChange:e=>{e||t()},children:e?(0,Y.jsxs)(Pe,{className:`max-w-lg`,children:[(0,Y.jsxs)(Re,{children:[(0,Y.jsxs)(Ke,{className:`oc-traces__meta-title`,children:[j(),` `,(0,Y.jsx)(`code`,{children:e.kind}),(0,Y.jsx)(G,{variant:`outline`,children:P()})]}),(0,Y.jsx)(Fe,{children:L()})]}),(0,Y.jsx)(`pre`,{className:`oc-traces__meta-json`,children:n})]}):null})}export{at as TracesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ac as r,Am as i,Bc as a,Cm as o,Dm as s,Em as c,Fc as l,Ic as u,Lc as d,Mc as f,Mm as p,Nc as m,Oc as h,Om as ee,Pc as g,Rc as _,Sm as v,Tm as te,_m as ne,_w as y,am as re,bm as b,cm as x,dm as S,fm as C,gm as w,gw as T,hm as ie,im as ae,jc as E,jm as D,kc as O,km as oe,lm as se,mm as ce,om as le,pm as ue,sm as de,um as fe,uw as k,vm as pe,wm as me,xm as he,ym as ge,zc as A,zp as j}from"./dist-ws-D-Lv-.js";import{t as M}from"./button-DuXPa4Vl.js";import{$ as N,C as P,F,I,M as L,N as _e,O as R,Ot as ve,P as z,Q as ye,R as be,S as B,_t as V,b as H,d as U,et as xe,f as Se,gt as W,j as G,kt as Ce,m as K,ot as we,p as q,rt as Te,tt as Ee,x as J,y as Y,z as De}from"./index-D2h8Mdp2.js";import{t as Oe}from"./FilterBar-B_NTOVaW.js";import{t as ke}from"./DataTableShell-D_G9F2EP.js";import{t as Ae}from"./DetailChips-HmAlB_yt.js";var X=t(e(),1),Z=n();function je({profileId:e,userLabel:t,open:n,onOpenChange:r}){let i=y(k.agents.listAgentPoolForUser,n&&e?{profileId:e}:`skip`),o=y(k.agents.listUserAgents,n&&e?{profileId:e}:`skip`),s=new Set((o??[]).map(e=>`${e.instanceName}/${e.agentId}`)),c=(o??[]).find(e=>e.isDefault)??null,l=c?`${c.instanceName}/${c.agentId}`:null,f=new Set((i?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),p=[...(i?.agents??[]).map(e=>({...e,outOfPool:!1})),...(o??[]).filter(e=>!f.has(`${e.instanceName}/${e.agentId}`)).map(e=>({instanceName:e.instanceName,agentId:e.agentId,displayName:e.displayName,emoji:e.emoji,model:e.model,kind:e.kind,state:e.state,outOfPool:!0}))],h=new Map;for(let e of p){let t=h.get(e.instanceName)??[];t.push(e),h.set(e.instanceName,t)}return(0,Z.jsx)(z,{open:n,onOpenChange:r,children:(0,Z.jsxs)(F,{className:`oc-access`,children:[(0,Z.jsxs)(be,{children:[(0,Z.jsx)(De,{children:a({user:t})}),(0,Z.jsx)(I,{children:A()})]}),i?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:i.inGroup?_():d()}):null,(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:u()}):p.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:m()}):[...h.entries()].map(([t,n])=>(0,Z.jsx)(Q,{profileId:e,instanceName:t,kind:n[0].kind,agents:n,assigned:s,defaultKey:l},t))})]})})}function Q({profileId:e,instanceName:t,kind:n,agents:i,assigned:a,defaultKey:o}){let s=T(k.agents.assignAgent),c=T(k.agents.removeAgent),u=T(k.agents.setDefaultAgent),d=G();if(!e)return null;async function p(n,r){try{r?await c({profileId:e,instanceName:t,agentId:n}):await s({profileId:e,instanceName:t,agentId:n})}catch(e){d.error(l(),e)}}async function m(n){try{await u({profileId:e,instanceName:t,agentId:n})}catch(e){d.error(g(),e)}}return(0,Z.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Z.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Z.jsx)(V,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(K,{variant:`outline`,className:`oc-access__kind`,children:n})]}),i.map(e=>{let n=`${t}/${e.agentId}`,i=a.has(n),s=o===n,c=e.state===`deleted`;return(0,Z.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Z.jsx)(R,{checked:i,disabled:c&&!i,onCheckedChange:()=>void p(e.agentId,i),"aria-label":f({name:e.displayName??e.agentId})}),(0,Z.jsxs)(`span`,{className:`oc-access__label`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,c?(0,Z.jsx)(K,{variant:`outline`,className:`oc-access__gone`,children:E()}):null,e.outOfPool?(0,Z.jsx)(K,{variant:`outline`,className:`oc-access__gone`,children:r()}):null,i?s?(0,Z.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":O(),title:O(),children:(0,Z.jsx)(W,{size:14,fill:`currentColor`})}):(0,Z.jsx)(M,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":h(),title:h(),onClick:()=>void m(e.agentId),children:(0,Z.jsx)(W,{size:14})}):null]},e.agentId)})]})}var $=`__all__`;function Me({granted:e,onToggle:t}){let n=new Set(e),r=U.filter(e=>n.has(q[e])).length;return(0,Z.jsxs)(ye,{children:[(0,Z.jsx)(Te,{asChild:!0,children:(0,Z.jsx)(M,{variant:`outline`,size:`sm`,className:`h-8 w-36 justify-start font-normal`,children:r===0?p():D({count:r})})}),(0,Z.jsxs)(N,{align:`start`,className:`w-52`,children:[(0,Z.jsx)(Ee,{children:i()}),U.map(e=>{let r=q[e];return(0,Z.jsxs)(xe,{className:`gap-2`,onSelect:e=>{e.preventDefault(),t(r)},children:[(0,Z.jsx)(R,{checked:n.has(r),"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none`}),(0,Z.jsx)(`span`,{children:Se[e]??e})]},e)})]})]})}function Ne(){let e=Ce({from:`/settings/users`}),t=ve({from:`/settings/users`}),n=e.q??``,r=e.role??$,i=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),a=e=>void t({search:t=>({...t,role:e===$?void 0:e})}),l=y(k.admin.listUsers,{filter:{q:n||void 0,role:r===$?void 0:r},withAgents:!0}),u=y(k.me.getMe,{host:we}),d=T(k.admin.setRole),f=T(k.admin.setUserPermissions),p=T(k.admin.startImpersonation),m=T(k.admin.deleteUser),h=T(k.admin.setUserName),g=L(),_=_e(),E=G(),[D,O]=(0,X.useState)(null),A=(0,X.useMemo)(()=>{let e=new Set([`pending`,`user`,`admin`]);for(let t of l??[])e.add(t.role);return[...e]},[l]),M=n!==``||r!==$;function N(){t({search:{},replace:!0})}async function F(e){try{await d(e)}catch(e){E.error(oe(),e)}}async function I(e){try{await f(e)}catch(e){E.error(ee(),e)}}async function R(e){let t=e.email||e.name||e.canonical||e.userId.slice(0,8);if(await g({title:he(),description:b({user:t}),confirmWord:ge(),confirmLabel:pe(),destructive:!0}))try{await m({profileId:e._id}),E.success(w({user:t}))}catch(e){E.error(ne(),e)}}async function z(e){let t=e.email||e.name||e.userId.slice(0,8),n=await _({title:ce(),label:ue({user:t}),placeholder:C(),defaultValue:e.name??``,confirmLabel:j()});if(n!==null)try{await h({profileId:e._id,name:n}),E.success(S())}catch(e){E.error(fe(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Oe,{q:n,onQChange:i,searchPlaceholder:s(),onReset:N,canReset:M,children:(0,Z.jsxs)(Y,{value:r,onValueChange:a,children:[(0,Z.jsx)(B,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(P,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(J,{value:$,children:c()}),A.map(e=>(0,Z.jsx)(J,{value:e,children:e},e))]})]})}),(0,Z.jsx)(ke,{title:te(),rows:l,emptyHint:me(),rowActions:e=>{let t=[{label:ae(),onSelect:()=>O({profileId:e._id,label:e.email||e.name||e.canonical||e.userId.slice(0,8)})},{label:ie(),onSelect:()=>void z(e)}];return e.userId!==u?.userId&&t.push({label:o(),onSelect:()=>void p({profileId:e._id})},{label:v(),variant:`destructive`,onSelect:()=>void R(e)}),t},columns:[{header:se(),cell:e=>{let t=e.email||e.name||e.canonical||e.userId.slice(0,8),n=e.email&&e.name&&e.name!==e.email?e.name:null;return(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{children:t}),n?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n}):null]})},sort:e=>e.email||e.name||e.canonical||e.userId},{header:x(),sort:e=>e.role===`admin`?2:+(e.role===`user`),cell:e=>(0,Z.jsxs)(Y,{value:e.role,onValueChange:t=>void F({profileId:e._id,role:t}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-28`,children:(0,Z.jsx)(P,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(J,{value:`pending`,children:`pending`}),(0,Z.jsx)(J,{value:`user`,children:`user`}),(0,Z.jsx)(J,{value:`admin`,children:`admin`})]})]})},{header:de(),sort:e=>e.role===`admin`?9999:e.extraPermissions?.length??0,cell:e=>e.role===`admin`?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:le()}):(0,Z.jsx)(Me,{granted:e.extraPermissions??[],onToggle:t=>{let n=new Set(e.extraPermissions??[]);n.has(t)?n.delete(t):n.add(t),I({profileId:e._id,permissions:[...n]})}})},{header:re(),cell:e=>(0,Z.jsx)(Ae,{icon:(0,Z.jsx)(V,{size:12,"aria-hidden":!0}),total:e.agentCount??0,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount??0}]}),(0,Z.jsx)(je,{profileId:D?.profileId??null,userLabel:D?.label??``,open:D!==null,onOpenChange:e=>{e||O(null)}})]})}export{Ne as UsersTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ac as r,Am as i,Bc as a,Cm as o,Dm as s,Em as c,Fc as l,Ic as u,Lc as d,Mc as f,Mm as p,Nc as m,Oc as h,Om as ee,Pc as g,Rc as _,Sm as v,Tm as te,_m as ne,_w as y,am as re,bm as b,cm as x,dm as S,fm as C,gm as w,gw as T,hm as ie,im as ae,jc as E,jm as D,kc as O,km as oe,lm as se,mm as ce,om as le,pm as ue,sm as de,um as fe,uw as k,vm as pe,wm as me,xm as he,ym as ge,zc as A,zp as j}from"./dist-ws-D-Lv-.js";import{t as M}from"./button-DuXPa4Vl.js";import{$ as N,C as P,F,I,M as L,N as _e,O as R,Ot as ve,P as z,Q as ye,R as be,S as B,_t as V,b as H,d as U,et as xe,f as Se,gt as W,j as G,kt as Ce,m as K,ot as we,p as q,rt as Te,tt as Ee,x as J,y as Y,z as De}from"./index-Bp-uQn4K.js";import{t as Oe}from"./FilterBar-BmFEn3qs.js";import{t as ke}from"./DataTableShell-B_P8ehdH.js";import{t as Ae}from"./DetailChips-DccwdoeS.js";var X=t(e(),1),Z=n();function je({profileId:e,userLabel:t,open:n,onOpenChange:r}){let i=y(k.agents.listAgentPoolForUser,n&&e?{profileId:e}:`skip`),o=y(k.agents.listUserAgents,n&&e?{profileId:e}:`skip`),s=new Set((o??[]).map(e=>`${e.instanceName}/${e.agentId}`)),c=(o??[]).find(e=>e.isDefault)??null,l=c?`${c.instanceName}/${c.agentId}`:null,f=new Set((i?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),p=[...(i?.agents??[]).map(e=>({...e,outOfPool:!1})),...(o??[]).filter(e=>!f.has(`${e.instanceName}/${e.agentId}`)).map(e=>({instanceName:e.instanceName,agentId:e.agentId,displayName:e.displayName,emoji:e.emoji,model:e.model,kind:e.kind,state:e.state,outOfPool:!0}))],h=new Map;for(let e of p){let t=h.get(e.instanceName)??[];t.push(e),h.set(e.instanceName,t)}return(0,Z.jsx)(z,{open:n,onOpenChange:r,children:(0,Z.jsxs)(F,{className:`oc-access`,children:[(0,Z.jsxs)(be,{children:[(0,Z.jsx)(De,{children:a({user:t})}),(0,Z.jsx)(I,{children:A()})]}),i?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:i.inGroup?_():d()}):null,(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:u()}):p.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:m()}):[...h.entries()].map(([t,n])=>(0,Z.jsx)(Q,{profileId:e,instanceName:t,kind:n[0].kind,agents:n,assigned:s,defaultKey:l},t))})]})})}function Q({profileId:e,instanceName:t,kind:n,agents:i,assigned:a,defaultKey:o}){let s=T(k.agents.assignAgent),c=T(k.agents.removeAgent),u=T(k.agents.setDefaultAgent),d=G();if(!e)return null;async function p(n,r){try{r?await c({profileId:e,instanceName:t,agentId:n}):await s({profileId:e,instanceName:t,agentId:n})}catch(e){d.error(l(),e)}}async function m(n){try{await u({profileId:e,instanceName:t,agentId:n})}catch(e){d.error(g(),e)}}return(0,Z.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Z.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Z.jsx)(V,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(K,{variant:`outline`,className:`oc-access__kind`,children:n})]}),i.map(e=>{let n=`${t}/${e.agentId}`,i=a.has(n),s=o===n,c=e.state===`deleted`;return(0,Z.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Z.jsx)(R,{checked:i,disabled:c&&!i,onCheckedChange:()=>void p(e.agentId,i),"aria-label":f({name:e.displayName??e.agentId})}),(0,Z.jsxs)(`span`,{className:`oc-access__label`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,c?(0,Z.jsx)(K,{variant:`outline`,className:`oc-access__gone`,children:E()}):null,e.outOfPool?(0,Z.jsx)(K,{variant:`outline`,className:`oc-access__gone`,children:r()}):null,i?s?(0,Z.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":O(),title:O(),children:(0,Z.jsx)(W,{size:14,fill:`currentColor`})}):(0,Z.jsx)(M,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":h(),title:h(),onClick:()=>void m(e.agentId),children:(0,Z.jsx)(W,{size:14})}):null]},e.agentId)})]})}var $=`__all__`;function Me({granted:e,onToggle:t}){let n=new Set(e),r=U.filter(e=>n.has(q[e])).length;return(0,Z.jsxs)(ye,{children:[(0,Z.jsx)(Te,{asChild:!0,children:(0,Z.jsx)(M,{variant:`outline`,size:`sm`,className:`h-8 w-36 justify-start font-normal`,children:r===0?p():D({count:r})})}),(0,Z.jsxs)(N,{align:`start`,className:`w-52`,children:[(0,Z.jsx)(Ee,{children:i()}),U.map(e=>{let r=q[e];return(0,Z.jsxs)(xe,{className:`gap-2`,onSelect:e=>{e.preventDefault(),t(r)},children:[(0,Z.jsx)(R,{checked:n.has(r),"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none`}),(0,Z.jsx)(`span`,{children:Se[e]??e})]},e)})]})]})}function Ne(){let e=Ce({from:`/settings/users`}),t=ve({from:`/settings/users`}),n=e.q??``,r=e.role??$,i=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),a=e=>void t({search:t=>({...t,role:e===$?void 0:e})}),l=y(k.admin.listUsers,{filter:{q:n||void 0,role:r===$?void 0:r},withAgents:!0}),u=y(k.me.getMe,{host:we}),d=T(k.admin.setRole),f=T(k.admin.setUserPermissions),p=T(k.admin.startImpersonation),m=T(k.admin.deleteUser),h=T(k.admin.setUserName),g=L(),_=_e(),E=G(),[D,O]=(0,X.useState)(null),A=(0,X.useMemo)(()=>{let e=new Set([`pending`,`user`,`admin`]);for(let t of l??[])e.add(t.role);return[...e]},[l]),M=n!==``||r!==$;function N(){t({search:{},replace:!0})}async function F(e){try{await d(e)}catch(e){E.error(oe(),e)}}async function I(e){try{await f(e)}catch(e){E.error(ee(),e)}}async function R(e){let t=e.email||e.name||e.canonical||e.userId.slice(0,8);if(await g({title:he(),description:b({user:t}),confirmWord:ge(),confirmLabel:pe(),destructive:!0}))try{await m({profileId:e._id}),E.success(w({user:t}))}catch(e){E.error(ne(),e)}}async function z(e){let t=e.email||e.name||e.userId.slice(0,8),n=await _({title:ce(),label:ue({user:t}),placeholder:C(),defaultValue:e.name??``,confirmLabel:j()});if(n!==null)try{await h({profileId:e._id,name:n}),E.success(S())}catch(e){E.error(fe(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Oe,{q:n,onQChange:i,searchPlaceholder:s(),onReset:N,canReset:M,children:(0,Z.jsxs)(Y,{value:r,onValueChange:a,children:[(0,Z.jsx)(B,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(P,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(J,{value:$,children:c()}),A.map(e=>(0,Z.jsx)(J,{value:e,children:e},e))]})]})}),(0,Z.jsx)(ke,{title:te(),rows:l,emptyHint:me(),rowActions:e=>{let t=[{label:ae(),onSelect:()=>O({profileId:e._id,label:e.email||e.name||e.canonical||e.userId.slice(0,8)})},{label:ie(),onSelect:()=>void z(e)}];return e.userId!==u?.userId&&t.push({label:o(),onSelect:()=>void p({profileId:e._id})},{label:v(),variant:`destructive`,onSelect:()=>void R(e)}),t},columns:[{header:se(),cell:e=>{let t=e.email||e.name||e.canonical||e.userId.slice(0,8),n=e.email&&e.name&&e.name!==e.email?e.name:null;return(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{children:t}),n?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n}):null]})},sort:e=>e.email||e.name||e.canonical||e.userId},{header:x(),sort:e=>e.role===`admin`?2:+(e.role===`user`),cell:e=>(0,Z.jsxs)(Y,{value:e.role,onValueChange:t=>void F({profileId:e._id,role:t}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-28`,children:(0,Z.jsx)(P,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(J,{value:`pending`,children:`pending`}),(0,Z.jsx)(J,{value:`user`,children:`user`}),(0,Z.jsx)(J,{value:`admin`,children:`admin`})]})]})},{header:de(),sort:e=>e.role===`admin`?9999:e.extraPermissions?.length??0,cell:e=>e.role===`admin`?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:le()}):(0,Z.jsx)(Me,{granted:e.extraPermissions??[],onToggle:t=>{let n=new Set(e.extraPermissions??[]);n.has(t)?n.delete(t):n.add(t),I({profileId:e._id,permissions:[...n]})}})},{header:re(),cell:e=>(0,Z.jsx)(Ae,{icon:(0,Z.jsx)(V,{size:12,"aria-hidden":!0}),total:e.agentCount??0,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount??0}]}),(0,Z.jsx)(je,{profileId:D?.profileId??null,userLabel:D?.label??``,open:D!==null,onOpenChange:e=>{e||O(null)}})]})}export{Ne as UsersTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{E as r,T as i,w as a}from"./index-D2h8Mdp2.js";var o=t(e(),1),s=n(),c=({code:e,language:t,raw:n,className:c,startLine:l,lineNumbers:u,...d})=>{let{shikiTheme:f}=(0,o.useContext)(r),p=i(),[m,h]=(0,o.useState)(n);return(0,o.useEffect)(()=>{if(!p){h(n);return}let r=p.highlight({code:e,language:t,themes:f},e=>{h(e)});r&&h(r)},[e,t,f,p,n]),(0,s.jsx)(a,{className:c,language:t,lineNumbers:u,result:m,startLine:l,...d})};export{c as HighlightedCodeBlockBody};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{E as r,T as i,w as a}from"./index-Bp-uQn4K.js";var o=t(e(),1),s=n(),c=({code:e,language:t,raw:n,className:c,startLine:l,lineNumbers:u,...d})=>{let{shikiTheme:f}=(0,o.useContext)(r),p=i(),[m,h]=(0,o.useState)(n);return(0,o.useEffect)(()=>{if(!p){h(n);return}let r=p.highlight({code:e,language:t,themes:f},e=>{h(e)});r&&h(r)},[e,t,f,p,n]),(0,s.jsx)(a,{className:c,language:t,lineNumbers:u,result:m,startLine:l,...d})};export{c as HighlightedCodeBlockBody};