@lacneu/atrium 0.74.2 → 0.74.3

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 (39) hide show
  1. package/dist/assets/{AccessTab-DStk63ub.js → AccessTab-jEh3iYB7.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-D9vv5fSO.js → AdvancedFilter-CddmHJ3w.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-BtxlN1ws.js → AgentFilesTab-Bm4UCoem.js} +1 -1
  4. package/dist/assets/{AnomaliesTab-CI4tjmIN.js → AnomaliesTab-6y5Od0XI.js} +1 -1
  5. package/dist/assets/{AuditTab-D4uX3vAo.js → AuditTab-C2G5v_Qa.js} +1 -1
  6. package/dist/assets/{BridgeTab-oURsmznB.js → BridgeTab-CFlYnmQx.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-Cv8YntGa.js → ChatDefaultsTab-CJicxQ2m.js} +1 -1
  8. package/dist/assets/{DataTableShell-D2PIAVAw.js → DataTableShell-CFPC-1m0.js} +1 -1
  9. package/dist/assets/{DetailChips-Z_U4y6U9.js → DetailChips-BzlFlRnK.js} +1 -1
  10. package/dist/assets/{FeedbacksTab-CVqv0gek.js → FeedbacksTab-TvLJvmvO.js} +1 -1
  11. package/dist/assets/{FieldLabel-DylbQ765.js → FieldLabel-DRaqrHBA.js} +1 -1
  12. package/dist/assets/{FilesTab-rfwATtRD.js → FilesTab-DpMD122m.js} +1 -1
  13. package/dist/assets/{FilterBar-D99V_QOK.js → FilterBar-DqZs9qry.js} +1 -1
  14. package/dist/assets/{GroupsTab-BjneoHMM.js → GroupsTab-D7Bedj8Y.js} +1 -1
  15. package/dist/assets/{InstancesTab-Bj3E0xRe.js → InstancesTab-ajTCr_rQ.js} +1 -1
  16. package/dist/assets/{IntegrationsTab-Bxx_tCDk.js → IntegrationsTab-dZwon69M.js} +1 -1
  17. package/dist/assets/{KpiTab-B6FjAeft.js → KpiTab-CI_vX795.js} +1 -1
  18. package/dist/assets/{PreferencesTab-DoFiqtFh.js → PreferencesTab-DiWwpvUZ.js} +1 -1
  19. package/dist/assets/{ProjectPage-VO-zERMD.js → ProjectPage-Bl3z7qKJ.js} +1 -1
  20. package/dist/assets/{PromptInjectionsTab-CC5UtKbU.js → PromptInjectionsTab-CVCzk8WZ.js} +1 -1
  21. package/dist/assets/{RolesTab-DIfAPBDN.js → RolesTab-Cwvh5UX7.js} +1 -1
  22. package/dist/assets/{ScheduledTab-CqTxkCOW.js → ScheduledTab-CSi-6T6L.js} +1 -1
  23. package/dist/assets/{ServiceAccountsTab-D1xuJN0i.js → ServiceAccountsTab-lWYGnbru.js} +1 -1
  24. package/dist/assets/{SubAgentReportsTab-BRQaHEfK.js → SubAgentReportsTab-DgywNtaI.js} +1 -1
  25. package/dist/assets/{ThemeShowroom-roD7KgSn.js → ThemeShowroom-D2G9Tsvs.js} +1 -1
  26. package/dist/assets/{TimeRangePicker-B-foA1-L.js → TimeRangePicker-4TbN0Xgb.js} +1 -1
  27. package/dist/assets/{TimezoneCombobox-C33f4gjg.js → TimezoneCombobox-CSGhMAXx.js} +1 -1
  28. package/dist/assets/{TracesTab-CMbFlcVv.js → TracesTab-B--i9MDN.js} +1 -1
  29. package/dist/assets/{UsersTab-tghO1HS0.js → UsersTab-ClI6-Y1a.js} +1 -1
  30. package/dist/assets/{VoiceTab-DuE2Wg3C.js → VoiceTab-DMhqIkTY.js} +1 -1
  31. package/dist/assets/{highlighted-body-OFNGDK62-D3zI5Iaq.js → highlighted-body-OFNGDK62-DB0iRCUQ.js} +1 -1
  32. package/dist/assets/{index-DtAFZhtv.js → index-B0ufU8aN.js} +6 -6
  33. package/dist/assets/{index-SBwQs_kQ.css → index-BrEi5y-K.css} +1 -1
  34. package/dist/assets/mermaid-GHXKKRXX-C4N2jMYZ.js +1 -0
  35. package/dist/assets/{pdf-BcmjxerI.js → pdf-9uj30gDA.js} +1 -1
  36. package/dist/assets/{tabs-Nve_dRxd.js → tabs-DbSY71M_.js} +1 -1
  37. package/dist/index.html +2 -2
  38. package/package.json +1 -1
  39. package/dist/assets/mermaid-GHXKKRXX-gnKwp22y.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$T as r,$w as i,AT as a,BT as o,Bw as s,CT as c,DT as l,ET as u,FT as d,Fw as f,GT as p,Gw as m,HT as h,Hw as g,IT as _,Iw as v,JT as y,Jw as b,KT as x,Kw as S,LT as ee,Lw as te,MT as ne,Mr as re,Mw as C,NT as ie,Nr as w,Nw as T,OT as ae,PT as oe,Pr as se,Pw as ce,QT as le,Qw as ue,RT as de,Rw as fe,ST as pe,TT as me,UT as he,Uw as ge,VT as _e,Vw as ve,WT as ye,Ww as be,XT as xe,Xw as Se,YT as Ce,Yw as we,ZT as Te,Zw as Ee,_E as De,_T as Oe,aE as ke,aT as Ae,az as E,bE as je,bT as Me,bb as Ne,cE as Pe,cT as Fe,cs as Ie,dE as Le,dT as Re,eE as ze,fE as Be,fT as Ve,gE as He,gT as Ue,hE as We,hT as Ge,iE as Ke,iM as qe,iT as Je,iz as D,jT as Ye,jw as Xe,kT as Ze,lE as Qe,lT as $e,ls as et,mE as tt,mT as nt,nE as rt,nT as it,nz as O,oE as k,oT as A,pE as at,pT as ot,qT as st,qw as ct,rE as lt,rM as j,rT as ut,sE as dt,sT as ft,ss as pt,t as M,tE as mt,tT as N,uE as ht,uT as gt,us as _t,vE as vt,vT as yt,wT as bt,xT as xt,xb as St,yE as Ct,yT as wt,zT as Tt,zw as Et}from"./api-BDOBe_HI.js";import{a as Dt,c as Ot}from"./FieldLabel-DylbQ765.js";import{t as P}from"./button-BXoUycz-.js";import{$ as F,Bt as kt,Dt as I,Et as L,Q as R,Rt as At,U as jt,X as z,Z as B,_ as Mt,at as V,et as H,jt as U,nt as W,ot as G,rt as K,tt as q,ut as J,zt as Nt}from"./index-DtAFZhtv.js";import{t as Pt}from"./DataTableShell-D2PIAVAw.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-oURsmznB.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],It=new Set(X),Lt=`conversational`;function Rt(e){let t=new Set((e??[]).filter(e=>It.has(e)));return t.size===0?[Lt]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport:Dt},zt={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Bt(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,streamTransport:e.streamTransport??`reactive`}}function Vt(){let e=E(M.admin.listInstances,{}),t=E(M.agents.listAllInstanceAgents,{}),n=D(M.admin.upsertInstance),i=D(M.admin.deleteInstance),a=I(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(Q),[u,d]=(0,Y.useState)(null),[f,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null);async function b(){try{await n({instanceId:_??void 0,name:c.name,gatewayUrl:c.gatewayUrl,bridgeUrl:c.bridgeUrl||void 0,displayName:c.displayName||void 0,kind:c.kind,transport:c.kind===`hermes`?c.transport:void 0,gatewayVersion:c.gatewayVersion||void 0,gatewayHttpUrl:c.gatewayHttpUrl||void 0,streamTransport:c.streamTransport}),l(Q),v(null),s(!1)}catch(e){a.error(vt(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[De(),(0,Z.jsx)(`strong`,{children:He()}),We()]}),(0,Z.jsx)(Pt,{title:tt(),rows:e,addLabel:at(),onAdd:()=>{v(null),l(Q),s(!0)},emptyHint:Be(),columns:[{header:Le(),cell:e=>e.name,sort:e=>e.name},{header:ht(),cell:e=>(0,Z.jsx)(L,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Qe(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:Pe(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:je(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(L,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?C():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Ke(),onSelect:()=>{v(e._id),l(Bt(e)),s(!0)}},{label:Ct(),onSelect:()=>d(e.name)},{label:he(),onSelect:()=>g(e)},{label:dt(),onSelect:()=>m(e)},{label:k(),variant:`destructive`,onSelect:()=>void i({instanceId:e._id})}],bulkActions:[{label:k(),variant:`destructive`,onSelect:e=>e.forEach(e=>void i({instanceId:e}))}]}),(0,Z.jsx)(Mt,{open:o,onOpenChange:s,title:_?lt():ke(),description:mt(),canSubmit:!!(c.name&&c.gatewayUrl),onSubmit:b,submitLabel:ze(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:r(),children:[(0,Z.jsx)(U,{value:c.name,disabled:_!==null,onChange:e=>l({...c,name:e.target.value})}),_?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:rt()}):null]}),(0,Z.jsx)($,{label:le(),children:(0,Z.jsxs)(z,{value:c.kind,onValueChange:e=>l({...c,kind:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(R,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(R,{value:`hermes`,children:`Hermes`})]})]})}),c.kind===`hermes`?(0,Z.jsx)($,{label:se(),children:(0,Z.jsxs)(z,{value:c.transport,onValueChange:e=>l({...c,transport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(R,{value:`ws`,children:w()}),(0,Z.jsx)(R,{value:`rest`,children:re()})]})]})}):null,(0,Z.jsx)($,{label:Te(),children:(0,Z.jsx)(U,{value:c.gatewayUrl,onChange:e=>l({...c,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:xe(),children:(0,Z.jsx)(U,{value:c.bridgeUrl,placeholder:Ce(),onChange:e=>l({...c,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:y(),children:(0,Z.jsx)(U,{value:c.displayName,onChange:e=>l({...c,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:St(),children:[(0,Z.jsxs)(z,{value:c.streamTransport,onValueChange:e=>l({...c,streamTransport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsx)(B,{children:Ot.map(e=>(0,Z.jsx)(R,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Ne()})]}),(0,Z.jsx)($,{label:st(),children:(0,Z.jsx)(U,{value:c.gatewayVersion,placeholder:x(),onChange:e=>l({...c,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:p(),children:(0,Z.jsx)(U,{value:c.gatewayHttpUrl,placeholder:ye(),onChange:e=>l({...c,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:u,open:u!==null,onOpenChange:e=>{e||d(null)}}),f?(0,Z.jsx)(Ft,{instance:f,onClose:()=>m(null)},f._id):null,h?(0,Z.jsx)(Ht,{instance:h,onClose:()=>g(null)},h._id):null]})}function Ht({instance:e,onClose:t}){let n=E(M.instanceSecrets.listInstanceSecretStatus,{}),r=zt[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(q,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(W,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(V,{children:[(0,Z.jsx)(G,{children:h({instance:e.displayName??e.name})}),(0,Z.jsx)(K,{children:_e()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Gt,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Wt,{instance:e})}),(0,Z.jsx)(Ut,{instance:e})]})})}function Ut({instance:e}){let t=O(M.instanceSync.forceInstanceSync),n=I(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(xt());break;case`no_agents`:n.success(wt());break;case`no_bridge_url`:n.error(yt());break;case`deploy_misconfigured`:n.error(Oe());break;case`unauthorized`:n.error(Ge());break;case`not_served`:n.error(nt());break;default:n.error(Ue());break}}catch(e){n.error(Me(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ot()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?pe():c()})})]})}function Wt({instance:e}){let t=E(M.bridgeAuth.listBridgeAuthStatus,{}),n=O(M.bridgeAuth.mintBridgeSecret),r=D(M.bridgeAuth.revokeBridgeSecret),i=I(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),d=(t??[]).find(t=>t.instanceId===e._id),f=d!==void 0;async function p(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),u(!1)}catch(e){i.error(A(),e)}finally{o(!1)}}}async function m(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(ft())}catch(e){i.error(A(),e)}finally{o(!1)}}}async function h(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:Ve(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Re()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(L,{variant:f?`outline`:`secondary`,children:f?`${ee()} · ${d.prefix}…${d.lastFour}`:_()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void p(),disabled:a,children:f?$e():gt()}),f?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void m(),disabled:a,children:Fe()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:Ae()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:l?qe():j()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:Je()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let r=O(M.instanceSecrets.setInstanceSecret),i=D(M.instanceSecrets.clearInstanceSecret),s=O(M.deviceIdentity.generateDeviceIdentity),c=I(),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(!1),[g,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(!1),x=n!==null,S=t===`deviceIdentity`,te=t===`token`?o():t===`deviceIdentity`?Tt():de();async function re(){if(!(!f.trim()||m)){h(!0);try{await r({instanceId:e,field:t,plaintext:f}),p(``),v(null),b(!1),c.success(Ye())}catch(e){c.error(a(),e)}finally{h(!1)}}}async function C(){if(!m){h(!0);try{await i({instanceId:e,field:t}),v(null),b(!1),c.success(Ze())}catch(e){c.error(a(),e)}finally{h(!1)}}}async function w(){if(!m){h(!0);try{v(await s({instanceId:e})),b(!1),c.success(u())}catch(e){c.error(bt(),e)}finally{h(!1)}}}let T=g?`openclaw devices approve ${g.id}`:``;async function se(){if(T)try{await navigator.clipboard.writeText(T),b(!0)}catch{}}return(0,Z.jsxs)($,{label:te,children:[S?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:l()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(L,{variant:x?`outline`:`secondary`,children:x?ee():_()}),(0,Z.jsx)(U,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:f,placeholder:x?oe():d(),onChange:e=>p(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void re(),disabled:m||f.trim().length===0,children:ie()}),S?(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void w(),disabled:m,children:ae()}):null,x?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void C(),disabled:m,children:ne()}):null]})]}),g?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:u()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:me()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:T}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void se(),children:y?qe():j()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{v(null),b(!1)},children:Je()})]}):null]})}var Kt={conversational:ct,documentary:m,summarizer:_t,curator:Ie},qt={conversational:S,documentary:be,summarizer:et,curator:pt},Jt=e=>(Kt[e]??(()=>e))(),Yt=e=>(qt[e]??(()=>``))();function Xt({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:Ee()}),t.map(e=>(0,Z.jsx)(L,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(At,{children:[(0,Z.jsx)(kt,{asChild:!0,children:(0,Z.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:Se()})}),(0,Z.jsxs)(Nt,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:we()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:b()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(J,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Jt(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Yt(r)})]})]},r)})})]})]})]})}function Zt({instanceName:e,open:t,onOpenChange:n}){let r=E(M.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=D(M.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=D(M.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=D(M.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),c=D(M.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),l=D(M.agents.removeInstanceAgent),u=jt(),d=I();async function p(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){d.error(N(),e)}}async function m(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){d.error(N(),e)}}async function h(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){d.error(N(),e)}}async function _(t,n){if(e&&await u({title:ve({name:n}),description:s(),confirmLabel:Et(),destructive:!0}))try{await l({instanceName:e,agentId:t}),d.success(fe())}catch(e){d.error(N(),e)}}return(0,Z.jsx)(q,{open:t,onOpenChange:n,children:(0,Z.jsxs)(W,{className:`oc-access`,children:[(0,Z.jsxs)(V,{children:[(0,Z.jsx)(G,{children:ut({name:e??``})}),(0,Z.jsx)(K,{children:it()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:te()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?v():r.discovery.lastPollOk?f():ce({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:T()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,i=r.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(J,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void p(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(L,{variant:`outline`,className:`oc-access__gone`,children:Xe()}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void _(t.agentId,a),children:g()})]}):i?(0,Z.jsx)(L,{variant:`default`,children:C()}):(0,Z.jsx)(P,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void m(t.agentId),children:ge()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:o,onToggle:e=>void h(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Qt,{value:t.description??``,onSave:async n=>{if(e)try{await c({instanceName:e,agentId:t.agentId,description:n})}catch(e){d.error(N(),e)}}}):null]},t.agentId)})})]})]})})}function Qt({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let a=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(U,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:i(),"aria-label":ue(),onChange:e=>r(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),a())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Vt as InstancesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$T as r,$w as i,AT as a,BT as o,Bw as s,CT as c,DT as l,ET as u,FT as d,Fw as f,GT as p,Gw as m,HT as h,Hw as g,IT as _,Iw as v,JT as y,Jw as b,KT as x,Kw as S,LT as ee,Lw as te,MT as ne,Mr as re,Mw as C,NT as ie,Nr as w,Nw as T,OT as ae,PT as oe,Pr as se,Pw as ce,QT as le,Qw as ue,RT as de,Rw as fe,ST as pe,TT as me,UT as he,Uw as ge,VT as _e,Vw as ve,WT as ye,Ww as be,XT as xe,Xw as Se,YT as Ce,Yw as we,ZT as Te,Zw as Ee,_E as De,_T as Oe,aE as ke,aT as Ae,az as E,bE as je,bT as Me,bb as Ne,cE as Pe,cT as Fe,cs as Ie,dE as Le,dT as Re,eE as ze,fE as Be,fT as Ve,gE as He,gT as Ue,hE as We,hT as Ge,iE as Ke,iM as qe,iT as Je,iz as D,jT as Ye,jw as Xe,kT as Ze,lE as Qe,lT as $e,ls as et,mE as tt,mT as nt,nE as rt,nT as it,nz as O,oE as k,oT as A,pE as at,pT as ot,qT as st,qw as ct,rE as lt,rM as j,rT as ut,sE as dt,sT as ft,ss as pt,t as M,tE as mt,tT as N,uE as ht,uT as gt,us as _t,vE as vt,vT as yt,wT as bt,xT as xt,xb as St,yE as Ct,yT as wt,zT as Tt,zw as Et}from"./api-BDOBe_HI.js";import{a as Dt,c as Ot}from"./FieldLabel-DRaqrHBA.js";import{t as P}from"./button-BXoUycz-.js";import{$ as F,Bt as kt,Dt as I,Et as L,Q as R,Rt as At,U as jt,X as z,Z as B,_ as Mt,at as V,et as H,jt as U,nt as W,ot as G,rt as K,tt as q,ut as J,zt as Nt}from"./index-B0ufU8aN.js";import{t as Pt}from"./DataTableShell-CFPC-1m0.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-CFlYnmQx.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],It=new Set(X),Lt=`conversational`;function Rt(e){let t=new Set((e??[]).filter(e=>It.has(e)));return t.size===0?[Lt]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport:Dt},zt={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Bt(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,streamTransport:e.streamTransport??`reactive`}}function Vt(){let e=E(M.admin.listInstances,{}),t=E(M.agents.listAllInstanceAgents,{}),n=D(M.admin.upsertInstance),i=D(M.admin.deleteInstance),a=I(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(Q),[u,d]=(0,Y.useState)(null),[f,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null);async function b(){try{await n({instanceId:_??void 0,name:c.name,gatewayUrl:c.gatewayUrl,bridgeUrl:c.bridgeUrl||void 0,displayName:c.displayName||void 0,kind:c.kind,transport:c.kind===`hermes`?c.transport:void 0,gatewayVersion:c.gatewayVersion||void 0,gatewayHttpUrl:c.gatewayHttpUrl||void 0,streamTransport:c.streamTransport}),l(Q),v(null),s(!1)}catch(e){a.error(vt(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[De(),(0,Z.jsx)(`strong`,{children:He()}),We()]}),(0,Z.jsx)(Pt,{title:tt(),rows:e,addLabel:at(),onAdd:()=>{v(null),l(Q),s(!0)},emptyHint:Be(),columns:[{header:Le(),cell:e=>e.name,sort:e=>e.name},{header:ht(),cell:e=>(0,Z.jsx)(L,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Qe(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:Pe(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:je(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(L,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?C():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Ke(),onSelect:()=>{v(e._id),l(Bt(e)),s(!0)}},{label:Ct(),onSelect:()=>d(e.name)},{label:he(),onSelect:()=>g(e)},{label:dt(),onSelect:()=>m(e)},{label:k(),variant:`destructive`,onSelect:()=>void i({instanceId:e._id})}],bulkActions:[{label:k(),variant:`destructive`,onSelect:e=>e.forEach(e=>void i({instanceId:e}))}]}),(0,Z.jsx)(Mt,{open:o,onOpenChange:s,title:_?lt():ke(),description:mt(),canSubmit:!!(c.name&&c.gatewayUrl),onSubmit:b,submitLabel:ze(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:r(),children:[(0,Z.jsx)(U,{value:c.name,disabled:_!==null,onChange:e=>l({...c,name:e.target.value})}),_?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:rt()}):null]}),(0,Z.jsx)($,{label:le(),children:(0,Z.jsxs)(z,{value:c.kind,onValueChange:e=>l({...c,kind:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(R,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(R,{value:`hermes`,children:`Hermes`})]})]})}),c.kind===`hermes`?(0,Z.jsx)($,{label:se(),children:(0,Z.jsxs)(z,{value:c.transport,onValueChange:e=>l({...c,transport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(R,{value:`ws`,children:w()}),(0,Z.jsx)(R,{value:`rest`,children:re()})]})]})}):null,(0,Z.jsx)($,{label:Te(),children:(0,Z.jsx)(U,{value:c.gatewayUrl,onChange:e=>l({...c,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:xe(),children:(0,Z.jsx)(U,{value:c.bridgeUrl,placeholder:Ce(),onChange:e=>l({...c,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:y(),children:(0,Z.jsx)(U,{value:c.displayName,onChange:e=>l({...c,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:St(),children:[(0,Z.jsxs)(z,{value:c.streamTransport,onValueChange:e=>l({...c,streamTransport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsx)(B,{children:Ot.map(e=>(0,Z.jsx)(R,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Ne()})]}),(0,Z.jsx)($,{label:st(),children:(0,Z.jsx)(U,{value:c.gatewayVersion,placeholder:x(),onChange:e=>l({...c,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:p(),children:(0,Z.jsx)(U,{value:c.gatewayHttpUrl,placeholder:ye(),onChange:e=>l({...c,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:u,open:u!==null,onOpenChange:e=>{e||d(null)}}),f?(0,Z.jsx)(Ft,{instance:f,onClose:()=>m(null)},f._id):null,h?(0,Z.jsx)(Ht,{instance:h,onClose:()=>g(null)},h._id):null]})}function Ht({instance:e,onClose:t}){let n=E(M.instanceSecrets.listInstanceSecretStatus,{}),r=zt[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(q,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(W,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(V,{children:[(0,Z.jsx)(G,{children:h({instance:e.displayName??e.name})}),(0,Z.jsx)(K,{children:_e()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Gt,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Wt,{instance:e})}),(0,Z.jsx)(Ut,{instance:e})]})})}function Ut({instance:e}){let t=O(M.instanceSync.forceInstanceSync),n=I(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(xt());break;case`no_agents`:n.success(wt());break;case`no_bridge_url`:n.error(yt());break;case`deploy_misconfigured`:n.error(Oe());break;case`unauthorized`:n.error(Ge());break;case`not_served`:n.error(nt());break;default:n.error(Ue());break}}catch(e){n.error(Me(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ot()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?pe():c()})})]})}function Wt({instance:e}){let t=E(M.bridgeAuth.listBridgeAuthStatus,{}),n=O(M.bridgeAuth.mintBridgeSecret),r=D(M.bridgeAuth.revokeBridgeSecret),i=I(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),d=(t??[]).find(t=>t.instanceId===e._id),f=d!==void 0;async function p(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),u(!1)}catch(e){i.error(A(),e)}finally{o(!1)}}}async function m(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(ft())}catch(e){i.error(A(),e)}finally{o(!1)}}}async function h(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:Ve(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Re()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(L,{variant:f?`outline`:`secondary`,children:f?`${ee()} · ${d.prefix}…${d.lastFour}`:_()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void p(),disabled:a,children:f?$e():gt()}),f?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void m(),disabled:a,children:Fe()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:Ae()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:l?qe():j()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:Je()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let r=O(M.instanceSecrets.setInstanceSecret),i=D(M.instanceSecrets.clearInstanceSecret),s=O(M.deviceIdentity.generateDeviceIdentity),c=I(),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(!1),[g,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(!1),x=n!==null,S=t===`deviceIdentity`,te=t===`token`?o():t===`deviceIdentity`?Tt():de();async function re(){if(!(!f.trim()||m)){h(!0);try{await r({instanceId:e,field:t,plaintext:f}),p(``),v(null),b(!1),c.success(Ye())}catch(e){c.error(a(),e)}finally{h(!1)}}}async function C(){if(!m){h(!0);try{await i({instanceId:e,field:t}),v(null),b(!1),c.success(Ze())}catch(e){c.error(a(),e)}finally{h(!1)}}}async function w(){if(!m){h(!0);try{v(await s({instanceId:e})),b(!1),c.success(u())}catch(e){c.error(bt(),e)}finally{h(!1)}}}let T=g?`openclaw devices approve ${g.id}`:``;async function se(){if(T)try{await navigator.clipboard.writeText(T),b(!0)}catch{}}return(0,Z.jsxs)($,{label:te,children:[S?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:l()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(L,{variant:x?`outline`:`secondary`,children:x?ee():_()}),(0,Z.jsx)(U,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:f,placeholder:x?oe():d(),onChange:e=>p(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void re(),disabled:m||f.trim().length===0,children:ie()}),S?(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void w(),disabled:m,children:ae()}):null,x?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void C(),disabled:m,children:ne()}):null]})]}),g?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:u()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:me()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:T}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void se(),children:y?qe():j()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{v(null),b(!1)},children:Je()})]}):null]})}var Kt={conversational:ct,documentary:m,summarizer:_t,curator:Ie},qt={conversational:S,documentary:be,summarizer:et,curator:pt},Jt=e=>(Kt[e]??(()=>e))(),Yt=e=>(qt[e]??(()=>``))();function Xt({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:Ee()}),t.map(e=>(0,Z.jsx)(L,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(At,{children:[(0,Z.jsx)(kt,{asChild:!0,children:(0,Z.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:Se()})}),(0,Z.jsxs)(Nt,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:we()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:b()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(J,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Jt(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Yt(r)})]})]},r)})})]})]})]})}function Zt({instanceName:e,open:t,onOpenChange:n}){let r=E(M.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=D(M.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=D(M.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=D(M.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),c=D(M.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),l=D(M.agents.removeInstanceAgent),u=jt(),d=I();async function p(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){d.error(N(),e)}}async function m(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){d.error(N(),e)}}async function h(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){d.error(N(),e)}}async function _(t,n){if(e&&await u({title:ve({name:n}),description:s(),confirmLabel:Et(),destructive:!0}))try{await l({instanceName:e,agentId:t}),d.success(fe())}catch(e){d.error(N(),e)}}return(0,Z.jsx)(q,{open:t,onOpenChange:n,children:(0,Z.jsxs)(W,{className:`oc-access`,children:[(0,Z.jsxs)(V,{children:[(0,Z.jsx)(G,{children:ut({name:e??``})}),(0,Z.jsx)(K,{children:it()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:te()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?v():r.discovery.lastPollOk?f():ce({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:T()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,i=r.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(J,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void p(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(L,{variant:`outline`,className:`oc-access__gone`,children:Xe()}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void _(t.agentId,a),children:g()})]}):i?(0,Z.jsx)(L,{variant:`default`,children:C()}):(0,Z.jsx)(P,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void m(t.agentId),children:ge()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:o,onToggle:e=>void h(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Qt,{value:t.description??``,onSave:async n=>{if(e)try{await c({instanceName:e,agentId:t.agentId,description:n})}catch(e){d.error(N(),e)}}}):null]},t.agentId)})})]})]})})}function Qt({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let a=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(U,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:i(),"aria-label":ue(),onChange:e=>r(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),a())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Vt as InstancesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$D as r,Ac as i,Cc as a,Dc as o,Ec as s,Oc as c,QD as l,Tc as u,aO as d,az as f,cO as p,dO as m,eO as h,iO as g,iz as _,jc as v,kc as y,lO as b,nO as x,nz as S,oO as C,rO as w,sO as T,t as E,tO as D,uO as O,wc as k}from"./api-BDOBe_HI.js";import{t as A}from"./button-BXoUycz-.js";import{Et as j,jt as M,ut as N}from"./index-DtAFZhtv.js";var P=t(e(),1),F=n();function I(){let e=f(E.integrations.status.status,{}),t=_(E.admin.setIntegrationConfig),[n,a]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&a(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:m()});let o=n,s=(e,t,n)=>a({...o,[e]:{...o[e],[t]:n}}),c=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[O(),` `,(0,F.jsx)(`strong`,{children:b()}),` `,p()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:T()}):(0,F.jsx)(j,{variant:`outline`,children:C()}):(0,F.jsx)(j,{variant:`outline`,children:d()}),note:g(),children:[(0,F.jsx)(R,{label:x(),children:(0,F.jsx)(M,{value:o.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>s(`langfuse`,`host`,e.target.value),onBlur:()=>c(`langfuse`,{host:o.langfuse.host??``})})}),(0,F.jsx)(z,{label:l(),checked:o.langfuse.enabled??!0,onChange:e=>{s(`langfuse`,`enabled`,e),c(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:T()}):(0,F.jsx)(j,{variant:`outline`,children:C()}):(0,F.jsx)(j,{variant:`outline`,children:d()}),note:w(),children:[(0,F.jsx)(R,{label:D(),children:(0,F.jsx)(M,{value:o.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>s(`opik`,`baseUrl`,e.target.value),onBlur:()=>c(`opik`,{baseUrl:o.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:h(),children:(0,F.jsx)(M,{value:o.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||r(),onChange:e=>s(`opik`,`workspace`,e.target.value),onBlur:()=>c(`opik`,{workspace:o.opik.workspace??``})})}),(0,F.jsx)(z,{label:l(),checked:o.opik.enabled??!0,onChange:e=>{s(`opik`,`enabled`,e),c(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:T()}):(0,F.jsx)(j,{variant:`outline`,children:C()}):(0,F.jsx)(j,{variant:`outline`,children:v()}),note:i(),children:[(0,F.jsx)(R,{label:y(),children:(0,F.jsx)(M,{value:o.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>s(`otlp`,`endpoint`,e.target.value),onBlur:()=>c(`otlp`,{endpoint:o.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:l(),checked:o.otlp.enabled??!0,onChange:e=>{s(`otlp`,`enabled`,e),c(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(N,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=S(E.integrations.otlpSecret.setOtlpHeaders),n=_(E.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[l,d]=(0,P.useState)(null),[f,p]=(0,P.useState)(!1),m=async()=>{p(!0),d(null);try{await t({headersJson:r}),i(``)}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}};return(0,F.jsxs)(R,{label:c(),children:[(0,F.jsx)(M,{value:r,placeholder:e?o():s(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:f||r.trim().length===0,onClick:()=>void m(),children:u()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void n({}),children:k()}):null]}),l?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:l}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:a()})]})}export{I as IntegrationsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$D as r,Ac as i,Cc as a,Dc as o,Ec as s,Oc as c,QD as l,Tc as u,aO as d,az as f,cO as p,dO as m,eO as h,iO as g,iz as _,jc as v,kc as y,lO as b,nO as x,nz as S,oO as C,rO as w,sO as T,t as E,tO as D,uO as O,wc as k}from"./api-BDOBe_HI.js";import{t as A}from"./button-BXoUycz-.js";import{Et as j,jt as M,ut as N}from"./index-B0ufU8aN.js";var P=t(e(),1),F=n();function I(){let e=f(E.integrations.status.status,{}),t=_(E.admin.setIntegrationConfig),[n,a]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&a(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:m()});let o=n,s=(e,t,n)=>a({...o,[e]:{...o[e],[t]:n}}),c=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[O(),` `,(0,F.jsx)(`strong`,{children:b()}),` `,p()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:T()}):(0,F.jsx)(j,{variant:`outline`,children:C()}):(0,F.jsx)(j,{variant:`outline`,children:d()}),note:g(),children:[(0,F.jsx)(R,{label:x(),children:(0,F.jsx)(M,{value:o.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>s(`langfuse`,`host`,e.target.value),onBlur:()=>c(`langfuse`,{host:o.langfuse.host??``})})}),(0,F.jsx)(z,{label:l(),checked:o.langfuse.enabled??!0,onChange:e=>{s(`langfuse`,`enabled`,e),c(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:T()}):(0,F.jsx)(j,{variant:`outline`,children:C()}):(0,F.jsx)(j,{variant:`outline`,children:d()}),note:w(),children:[(0,F.jsx)(R,{label:D(),children:(0,F.jsx)(M,{value:o.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>s(`opik`,`baseUrl`,e.target.value),onBlur:()=>c(`opik`,{baseUrl:o.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:h(),children:(0,F.jsx)(M,{value:o.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||r(),onChange:e=>s(`opik`,`workspace`,e.target.value),onBlur:()=>c(`opik`,{workspace:o.opik.workspace??``})})}),(0,F.jsx)(z,{label:l(),checked:o.opik.enabled??!0,onChange:e=>{s(`opik`,`enabled`,e),c(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:T()}):(0,F.jsx)(j,{variant:`outline`,children:C()}):(0,F.jsx)(j,{variant:`outline`,children:v()}),note:i(),children:[(0,F.jsx)(R,{label:y(),children:(0,F.jsx)(M,{value:o.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>s(`otlp`,`endpoint`,e.target.value),onBlur:()=>c(`otlp`,{endpoint:o.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:l(),checked:o.otlp.enabled??!0,onChange:e=>{s(`otlp`,`enabled`,e),c(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(N,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=S(E.integrations.otlpSecret.setOtlpHeaders),n=_(E.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[l,d]=(0,P.useState)(null),[f,p]=(0,P.useState)(!1),m=async()=>{p(!0),d(null);try{await t({headersJson:r}),i(``)}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}};return(0,F.jsxs)(R,{label:c(),children:[(0,F.jsx)(M,{value:r,placeholder:e?o():s(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:f||r.trim().length===0,onClick:()=>void m(),children:u()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void n({}),children:k()}):null]}),l?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:l}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:a()})]})}export{I as IntegrationsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Av as r,Dv as i,Ev as a,Fv as o,GO as s,Iv as c,JO as l,KO as u,LO as d,Lv as ee,Mv as f,Nv as p,Ov as m,Pv as h,RO as g,Rv as te,Tv as ne,az as _,jv as v,kv as y,qO as b,t as x,wv as S,yk as C}from"./api-BDOBe_HI.js";import{Fn as w,Pn as T,i as E,o as re,q as ie,r as D}from"./index-DtAFZhtv.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-fSeRBVIZ.js";import{n as N,t as P}from"./TimeRangePicker-B-foA1-L.js";var F=t(e(),1),I={API_CALLS:`api.calls`,API_ERRORS:`api.errors`,API_LATENCY_AVG_MS:`api.latency.avg_ms`,OPENCLAW_INGEST:`openclaw.ingest`,CHAT_SEND:`chat.send`,ASSISTANT_STREAM_ERRORS:`assistant.stream.errors`,ASSISTANT_ANNOUNCE_ERRORS:`assistant.announce.errors`,CONVEX_PROBE_LATENCY_AVG_MS:`convex.probe.latency.avg_ms`},L=Object.keys(I).length,R=n(),z=15,B=e=>String(Math.round(e));function V(){let e=_(x.me.getMe,{host:ie})?.permissions?.includes(`traces.read`)??!1,t=_(x.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,F.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,z).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:C()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:l()}),(0,R.jsx)(j,{children:u()})]}),(0,R.jsx)(k,{children:n.length<2?(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):(0,R.jsx)(H,{series:n})})]})]})}function H({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{style:{color:`var(--primary)`},children:[d(),` p50 `,B(s.cP50),` `,b()]}),(0,R.jsxs)(`span`,{children:[g(),` p50 `,B(s.aP50),` `,b()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":l(),children:[(0,R.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:te(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:ee(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:c(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:o(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:h(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:p(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:f(),unit:`/h`,group:`Assistant`,isError:!0}],W=L,G=[`API`,`OpenClaw`,`Chat`,`Assistant`],K=1e3,q=36e5;function J(e,t){let n=Math.max(1,Math.ceil((t-e)/q)),r=Math.min(n*W,K);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/W))}}function ae(){let e=w({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=E(e.from,e.to,D,`now`),i=e=>void t({search:t=>({...t,...re(e)})}),{from:a,to:o}=N(n),{rowLimit:s,buckets:c}=J(a,o),l=_(x.kpi.listKpis,{limit:s,filter:{from:a,to:o}}),u=(0,F.useMemo)(()=>{let e=new Map;for(let t of l??[]){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>c&&e.set(t,n.slice(n.length-c));return e},[l,c]),d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[v(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:r()})]}),(0,R.jsx)(Y,{value:n,onChange:i})]});return l===void 0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:y()})]}):l.length===0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:m()})]}):(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),G.map(e=>{let t=U.filter(t=>t.group===e);return t.some(e=>(u.get(e.metric)??[]).length>0)?(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,R.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,R.jsx)(oe,{config:e,series:u.get(e.metric)??[]},e.metric))})]},e):null})]})}function Y({value:e,onChange:t}){return(0,R.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,R.jsx)(P,{value:e,onChange:t})})}function oe({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,R.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,R.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,R.jsx)(`code`,{children:e.metric})})]}),(0,R.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,R.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,R.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,R.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,R.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,R.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,R.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:i({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:a()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:ne({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,R.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-se,1);return(0,R.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":S({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,R.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,R.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{ae as KpiTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Av as r,Dv as i,Ev as a,Fv as o,GO as s,Iv as c,JO as l,KO as u,LO as d,Lv as ee,Mv as f,Nv as p,Ov as m,Pv as h,RO as g,Rv as te,Tv as ne,az as _,jv as v,kv as y,qO as b,t as x,wv as S,yk as C}from"./api-BDOBe_HI.js";import{Fn as w,Pn as T,i as E,o as re,q as ie,r as D}from"./index-B0ufU8aN.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-fSeRBVIZ.js";import{n as N,t as P}from"./TimeRangePicker-4TbN0Xgb.js";var F=t(e(),1),I={API_CALLS:`api.calls`,API_ERRORS:`api.errors`,API_LATENCY_AVG_MS:`api.latency.avg_ms`,OPENCLAW_INGEST:`openclaw.ingest`,CHAT_SEND:`chat.send`,ASSISTANT_STREAM_ERRORS:`assistant.stream.errors`,ASSISTANT_ANNOUNCE_ERRORS:`assistant.announce.errors`,CONVEX_PROBE_LATENCY_AVG_MS:`convex.probe.latency.avg_ms`},L=Object.keys(I).length,R=n(),z=15,B=e=>String(Math.round(e));function V(){let e=_(x.me.getMe,{host:ie})?.permissions?.includes(`traces.read`)??!1,t=_(x.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,F.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,z).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:C()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:l()}),(0,R.jsx)(j,{children:u()})]}),(0,R.jsx)(k,{children:n.length<2?(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):(0,R.jsx)(H,{series:n})})]})]})}function H({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{style:{color:`var(--primary)`},children:[d(),` p50 `,B(s.cP50),` `,b()]}),(0,R.jsxs)(`span`,{children:[g(),` p50 `,B(s.aP50),` `,b()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":l(),children:[(0,R.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:te(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:ee(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:c(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:o(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:h(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:p(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:f(),unit:`/h`,group:`Assistant`,isError:!0}],W=L,G=[`API`,`OpenClaw`,`Chat`,`Assistant`],K=1e3,q=36e5;function J(e,t){let n=Math.max(1,Math.ceil((t-e)/q)),r=Math.min(n*W,K);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/W))}}function ae(){let e=w({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=E(e.from,e.to,D,`now`),i=e=>void t({search:t=>({...t,...re(e)})}),{from:a,to:o}=N(n),{rowLimit:s,buckets:c}=J(a,o),l=_(x.kpi.listKpis,{limit:s,filter:{from:a,to:o}}),u=(0,F.useMemo)(()=>{let e=new Map;for(let t of l??[]){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>c&&e.set(t,n.slice(n.length-c));return e},[l,c]),d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[v(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:r()})]}),(0,R.jsx)(Y,{value:n,onChange:i})]});return l===void 0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:y()})]}):l.length===0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:m()})]}):(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),G.map(e=>{let t=U.filter(t=>t.group===e);return t.some(e=>(u.get(e.metric)??[]).length>0)?(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,R.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,R.jsx)(oe,{config:e,series:u.get(e.metric)??[]},e.metric))})]},e):null})]})}function Y({value:e,onChange:t}){return(0,R.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,R.jsx)(P,{value:e,onChange:t})})}function oe({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,R.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,R.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,R.jsx)(`code`,{children:e.metric})})]}),(0,R.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,R.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,R.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,R.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,R.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,R.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,R.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:i({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:a()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:ne({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,R.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-se,1);return(0,R.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":S({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,R.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,R.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{ae as KpiTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,AN as i,AR as a,BN as o,BR as s,CN as c,CR as l,DN as u,DR as d,EN as f,ER as p,FN as m,FR as h,Ft as ee,GN as te,GR as ne,HN as re,HR as ie,IN as ae,IR as oe,It as se,JN as ce,KN as le,Kt as ue,LN as de,LR as fe,Lt as pe,MN as me,MR as he,Mt as ge,NN as _e,NR as ve,Nt as g,ON as _,OR as v,PN as y,PR as b,Pt as x,QN as S,Qt as C,RN as w,RR as T,Rt as E,SN as D,SR as O,TN as k,TR as A,UN as j,VN as M,VR as N,WN as P,XN as F,XR as ye,YN as be,ZN as xe,Zt as Se,_N as Ce,az as I,bN as we,bR as Te,eE as Ee,eP as De,gN as Oe,iz as L,jN as ke,jR as Ae,jt as je,kN as R,kR as Me,qN as Ne,r as z,t as B,tP as Pe,vN as Fe,wN as Ie,wR as Le,xN as Re,xR as ze,yN as Be,yR as Ve,zN as He,zR as Ue}from"./api-BDOBe_HI.js";import{t as V}from"./button-BXoUycz-.js";import{$ as We,At as Ge,Dt as Ke,Et as H,Ot as qe,Q as U,V as Je,X as Ye,Z as Xe,et as Ze,jt as W,kt as Qe,q as G,t as $e,ut as K}from"./index-DtAFZhtv.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-C33f4gjg.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:z(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:z(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>Pe()},{id:`composer`,label:()=>De()},{id:`sidebar`,label:()=>r()},{id:`notifications`,label:()=>ae()},{id:`other`,label:()=>S()}],X={showSource:{category:`messages`,label:()=>xe(),help:()=>F()},showReport:{category:`messages`,label:()=>be(),help:()=>ce()},copyAssistant:{category:`messages`,label:()=>Ne()},copyUser:{category:`messages`,label:()=>le()},showDelete:{category:`messages`,label:()=>te()},showTools:{category:`messages`,label:()=>P(),help:()=>j()},voiceInput:{category:`composer`,label:()=>re(),help:()=>M()},showUsage:{category:`composer`,label:()=>o(),help:()=>He()},autoReadAloud:{category:`composer`,label:()=>C(),help:()=>Se()},showChatAge:{category:`sidebar`,label:()=>w(),help:()=>de()},notifSound:{category:`notifications`,label:()=>m(),help:()=>y()},notifSystem:{category:`notifications`,label:()=>_e(),help:()=>me()},replySound:{category:`notifications`,label:()=>ke(),help:()=>i()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>we()};function ut({prefKey:e,ui:t}){let n=L(B.admin.setUiPrefDefault),r=L(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:Ie()}),(0,J.jsxs)(Ye,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(We,{size:`sm`,className:`w-36`,children:(0,J.jsx)(Ze,{})}),(0,J.jsxs)(Xe,{children:[(0,J.jsx)(U,{value:`on`,children:Fe()}),(0,J.jsx)(U,{value:`off`,children:Ce()}),(0,J.jsx)(U,{value:`inherit`,children:Oe()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(K,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":c()}),c()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=L(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Qe(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[E(),e?(0,J.jsx)(H,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?ee():r?se():pe()})]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:je()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?ge():e?g():x()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=I(B.me.getMe,{host:G}),a=i?.ui,o=$(i?.role)&&n,s=L(B.me.setUiPref).withOptimisticUpdate(Je),c=(0,q.useMemo)(()=>a?Q(Object.keys(a.effective),e):[],[a,e]);return a?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(K,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":k()}),k()]}):null,o?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:D()}),(0,J.jsx)(`p`,{children:Re()}),(0,J.jsx)(`p`,{children:Be()})]}):null,(0,J.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:R(),"aria-label":R(),className:`mb-2`}),c.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:_()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:c.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],c=a.effective[e],l=a.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(H,{variant:`outline`,children:u()}):l?(0,J.jsx)(H,{variant:`secondary`,children:ue()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void s({key:e,value:null}),children:f()}):null,(0,J.jsx)(nt,{checked:c,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),s({key:e,value:t})},"aria-label":n})]}),o?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:ye()})}var pt={sm:()=>a(),md:()=>Me(),lg:()=>v(),xl:()=>d(),"2xl":()=>p(),"3xl":()=>A()};function mt(){let e=I(B.me.getMe,{host:G}),t=L(B.me.setLocale),n=L(B.me.setTimezone),r=L(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:G});n&&e.setQuery(B.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=L(B.me.setMyName),a=Ke(),o=e?.locale??`default`,c=e?.name??``,[u,d]=(0,q.useState)(null),f=u??c,p=f.trim()!==c.trim();async function m(){try{await i({name:f}),d(null),a.success(T())}catch(e){a.error(fe(),e)}}return(0,J.jsxs)(`div`,{className:`oc-appearance`,children:[(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ie()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:N()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(W,{className:`max-w-xs`,value:f,maxLength:120,placeholder:s(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p&&(e.preventDefault(),m())}}),(0,J.jsx)(V,{size:`sm`,disabled:!p,onClick:()=>void m(),children:Ee()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ue()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:oe()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:h()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:o===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:o==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:ne()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:b()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Le()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:l()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,J.jsx)(V,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:O()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ze()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ve()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:he()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:$e.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void r({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ae()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Te()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ve()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,AN as i,AR as a,BN as o,BR as s,CN as c,CR as l,DN as u,DR as d,EN as f,ER as p,FN as m,FR as h,Ft as ee,GN as te,GR as ne,HN as re,HR as ie,IN as ae,IR as oe,It as se,JN as ce,KN as le,Kt as ue,LN as de,LR as fe,Lt as pe,MN as me,MR as he,Mt as ge,NN as _e,NR as ve,Nt as g,ON as _,OR as v,PN as y,PR as b,Pt as x,QN as S,Qt as C,RN as w,RR as T,Rt as E,SN as D,SR as O,TN as k,TR as A,UN as j,VN as M,VR as N,WN as P,XN as F,XR as ye,YN as be,ZN as xe,Zt as Se,_N as Ce,az as I,bN as we,bR as Te,eE as Ee,eP as De,gN as Oe,iz as L,jN as ke,jR as Ae,jt as je,kN as R,kR as Me,qN as Ne,r as z,t as B,tP as Pe,vN as Fe,wN as Ie,wR as Le,xN as Re,xR as ze,yN as Be,yR as Ve,zN as He,zR as Ue}from"./api-BDOBe_HI.js";import{t as V}from"./button-BXoUycz-.js";import{$ as We,At as Ge,Dt as Ke,Et as H,Ot as qe,Q as U,V as Je,X as Ye,Z as Xe,et as Ze,jt as W,kt as Qe,q as G,t as $e,ut as K}from"./index-B0ufU8aN.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-CSGhMAXx.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:z(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:z(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>Pe()},{id:`composer`,label:()=>De()},{id:`sidebar`,label:()=>r()},{id:`notifications`,label:()=>ae()},{id:`other`,label:()=>S()}],X={showSource:{category:`messages`,label:()=>xe(),help:()=>F()},showReport:{category:`messages`,label:()=>be(),help:()=>ce()},copyAssistant:{category:`messages`,label:()=>Ne()},copyUser:{category:`messages`,label:()=>le()},showDelete:{category:`messages`,label:()=>te()},showTools:{category:`messages`,label:()=>P(),help:()=>j()},voiceInput:{category:`composer`,label:()=>re(),help:()=>M()},showUsage:{category:`composer`,label:()=>o(),help:()=>He()},autoReadAloud:{category:`composer`,label:()=>C(),help:()=>Se()},showChatAge:{category:`sidebar`,label:()=>w(),help:()=>de()},notifSound:{category:`notifications`,label:()=>m(),help:()=>y()},notifSystem:{category:`notifications`,label:()=>_e(),help:()=>me()},replySound:{category:`notifications`,label:()=>ke(),help:()=>i()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>we()};function ut({prefKey:e,ui:t}){let n=L(B.admin.setUiPrefDefault),r=L(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:Ie()}),(0,J.jsxs)(Ye,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(We,{size:`sm`,className:`w-36`,children:(0,J.jsx)(Ze,{})}),(0,J.jsxs)(Xe,{children:[(0,J.jsx)(U,{value:`on`,children:Fe()}),(0,J.jsx)(U,{value:`off`,children:Ce()}),(0,J.jsx)(U,{value:`inherit`,children:Oe()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(K,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":c()}),c()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=L(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Qe(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[E(),e?(0,J.jsx)(H,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?ee():r?se():pe()})]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:je()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?ge():e?g():x()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=I(B.me.getMe,{host:G}),a=i?.ui,o=$(i?.role)&&n,s=L(B.me.setUiPref).withOptimisticUpdate(Je),c=(0,q.useMemo)(()=>a?Q(Object.keys(a.effective),e):[],[a,e]);return a?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(K,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":k()}),k()]}):null,o?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:D()}),(0,J.jsx)(`p`,{children:Re()}),(0,J.jsx)(`p`,{children:Be()})]}):null,(0,J.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:R(),"aria-label":R(),className:`mb-2`}),c.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:_()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:c.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],c=a.effective[e],l=a.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(H,{variant:`outline`,children:u()}):l?(0,J.jsx)(H,{variant:`secondary`,children:ue()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void s({key:e,value:null}),children:f()}):null,(0,J.jsx)(nt,{checked:c,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),s({key:e,value:t})},"aria-label":n})]}),o?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:ye()})}var pt={sm:()=>a(),md:()=>Me(),lg:()=>v(),xl:()=>d(),"2xl":()=>p(),"3xl":()=>A()};function mt(){let e=I(B.me.getMe,{host:G}),t=L(B.me.setLocale),n=L(B.me.setTimezone),r=L(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:G});n&&e.setQuery(B.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=L(B.me.setMyName),a=Ke(),o=e?.locale??`default`,c=e?.name??``,[u,d]=(0,q.useState)(null),f=u??c,p=f.trim()!==c.trim();async function m(){try{await i({name:f}),d(null),a.success(T())}catch(e){a.error(fe(),e)}}return(0,J.jsxs)(`div`,{className:`oc-appearance`,children:[(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ie()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:N()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(W,{className:`max-w-xs`,value:f,maxLength:120,placeholder:s(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p&&(e.preventDefault(),m())}}),(0,J.jsx)(V,{size:`sm`,disabled:!p,onClick:()=>void m(),children:Ee()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ue()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:oe()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:h()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:o===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:o==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:ne()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:b()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Le()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:l()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,J.jsx)(V,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:O()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ze()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ve()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:he()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:$e.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void r({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ae()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Te()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ve()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,A_ as i,B_ as a,C_ as o,D as s,D_ as c,E_ as l,G_ as u,H_ as d,I_ as f,J_ as p,K_ as ee,L_ as m,M_ as h,N_ as g,O_ as _,P_ as v,Q_ as te,R_ as y,S_ as ne,T_ as re,U_ as ie,W_ as ae,XR as b,Z_ as oe,Zg as se,a_ as ce,av as le,az as x,b_ as S,c_ as ue,e_ as de,ev as fe,g_ as pe,h_ as me,i_ as C,iz as w,j_ as T,k_ as he,l_ as ge,m_ as E,n_ as D,ov as _e,p_ as ve,ph as ye,r_ as O,s_ as k,sv as be,t as A,t_ as xe,tv as j,v_ as Se,w_ as Ce,x_ as we,y_ as M,z_ as N}from"./api-BDOBe_HI.js";import{r as Te}from"./dist-Ct8KdJzy.js";import{t as Ee}from"./list-CTIbo6ut.js";import{t as P}from"./button-BXoUycz-.js";import{A as De,C as Oe,Cn as ke,D as F,Dt as Ae,E as je,En as Me,Fn as Ne,Ft as Pe,In as Fe,It as Ie,J as Le,Lt as Re,Mt as ze,Nt as Be,O as I,P as Ve,Pn as L,Pt as R,S as He,Sn as z,T as Ue,U as We,W as Ge,Y as Ke,_ as qe,_n as Je,b as B,d as Ye,dn as Xe,f as Ze,fn as V,g as H,h as U,hn as W,in as Qe,j as G,jn as $e,jt as K,k as et,m as tt,p as nt,pn as rt,v as q,vn as it,w as at,wn as J,x as Y,y as ot}from"./index-DtAFZhtv.js";var st=s(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),ct=s(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),lt=s(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),ut=s(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),X=t(e(),1),Z=n();function Q({className:e}){return(0,Z.jsx)(Re,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":ce(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Me,{})})})}function dt({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:a}){let o=w(A.projects.renameProject),s=w(A.projects.setProjectColor),c=w(A.projects.moveProject),l=w(A.projects.deleteProject),f=w(A.projects.createProject),p=We(),m=Ge(),[h,_]=(0,X.useState)(!1),[v,te]=(0,X.useState)(t),[y,ne]=(0,X.useState)(!1),[re,b]=(0,X.useState)(!1),se=x(A.projects.projectTreeCount,re?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ze,{onOpenChange:e=>e&&b(!0),children:[(0,Z.jsx)(Q,{className:i}),(0,Z.jsxs)(Be,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>a(),children:[(0,Z.jsx)(J,{}),` `,d()]}),(0,Z.jsxs)(R,{onSelect:()=>{te(t),_(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await m({title:g(),label:be(),placeholder:_e(),confirmLabel:le()});t&&await f({name:t,parentId:e})})},children:[(0,Z.jsx)(ke,{}),` `,g()]}),(0,Z.jsxs)(R,{onSelect:()=>ne(!0),children:[(0,Z.jsx)(ct,{}),` `,me()]}),(0,Z.jsx)(Pe,{children:xe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void s({projectId:e,color:null}),"aria-label":de(),children:`✕`}),tt.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void s({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=se?.folders??0,r=se?.chats??0;await p({title:u({name:t}),description:n>0?ie({folders:n,chats:r}):r>0?ae({count:r}):ue(),confirmWord:k(),confirmLabel:ee(),destructive:!0})&&await l({projectId:e})})},children:[(0,Z.jsx)(Qe,{}),` `,k()]})]})]}),(0,Z.jsx)(qe,{open:h,onOpenChange:_,title:oe(),canSubmit:v.trim().length>0,onSubmit:async()=>{await o({projectId:e,name:v.trim()}),_(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:v,onChange:e=>te(e.target.value),autoFocus:!0})}),y?(0,Z.jsx)(nt,{open:y,onOpenChange:ne,title:ve(),movingFolderId:e,currentId:r,onPick:t=>void c({projectId:e,parentId:t})}):null]})}function $({chat:e,currentFolderId:t,className:n}){let i=w(A.chats.pinChat),o=w(A.chats.deleteChat),s=w(A.chats.renameChat),c=w(A.chats.setChatSidebar),l=w(A.chats.moveChatToProject),u=We(),[d,f]=(0,X.useState)(!1),[p,ee]=(0,X.useState)(e.title??``),[m,h]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Q,{className:n}),(0,Z.jsxs)(Be,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>{ee(e.title??``),f(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>void i({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(Xe,{}):(0,Z.jsx)(V,{}),e.pinned?O():D()]}),(0,Z.jsxs)(R,{onSelect:()=>h(!0),children:[(0,Z.jsx)(ct,{}),` `,pe()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(R,{onSelect:()=>void c({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(W,{}):(0,Z.jsx)(ut,{}),e.inSidebar?N():a()]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await u({title:r(),description:ue(),confirmLabel:k(),destructive:!0})&&await o({chatId:e._id})})},children:[(0,Z.jsx)(Qe,{}),` `,k()]})]})]}),(0,Z.jsx)(qe,{open:d,onOpenChange:f,title:se(),canSubmit:p.trim().length>0,onSubmit:async()=>{await s({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:p,onChange:e=>ee(e.target.value),autoFocus:!0})}),m?(0,Z.jsx)(nt,{open:m,onOpenChange:h,title:E(),currentId:t,onPick:t=>void l({chatId:e._id,projectId:t})}):null]})}function ft(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function pt(e,t,n,r,i){let a=e.map(t),o=a.indexOf(i);if(o<0)return null;let s=a.indexOf(r);if(s>=0){let t=[...e],[r]=t.splice(s,1);t.splice(o,0,r);let i=t[o-1],a=t[o+1];return{prevKey:i===void 0?null:n(i),nextKey:a===void 0?null:n(a)}}let c=e[o-1];return{prevKey:c===void 0?null:n(c),nextKey:n(e[o])}}function mt(e,t){let n=new Map(t.map(e=>[e.chatId,e.lastSeenAt])),r=new Set;for(let t of e){let e=n.get(t._id);e!==void 0&&t.lastAssistantAt!==null&&t.lastAssistantAt>e&&r.add(t._id)}return r}var ht=`oc.projpage.view`;function gt(){let e=localStorage.getItem(ht);return e===`cards`||e===`list`?e:`columns`}var _t=e=>`into:${e}`,vt=e=>`col:${e??`null`}`,yt=e=>`crumb:${e}`;function bt(e){if(e.startsWith(`into:`))return e.slice(5);if(e.startsWith(`crumb:`))return e.slice(6);if(e.startsWith(`col:`)){let t=e.slice(4);return t===`null`?null:t}}function xt(){let{projectId:e}=Fe({from:`/project/$projectId`}),t=L(),n=x(A.projects.projectPage,{projectId:e});return(0,Z.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:we()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:S()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:M()})]}):(0,Z.jsx)(St,{page:n})})}function St({page:e}){let t=L(),n=We(),r=Ge(),a=Ae(),s=w(A.projects.renameProject),c=w(A.projects.setProjectColor),l=w(A.projects.deleteProject),d=w(A.projects.createProject),p=w(A.projects.moveProject),h=w(A.chats.moveChatToProject),b=w(A.chats.reorderChat),se=w(A.projects.reorderProject),ce=x(A.projects.projectTreeCount,{projectId:e.project._id}),[S,fe]=(0,X.useState)(gt),pe=e=>{localStorage.setItem(ht,e),fe(e)},T=x(A.projects.folderColumns,S===`columns`?{projectId:e.project._id}:`skip`),E=x(A.projects.projectTreeList,S===`list`?{projectId:e.project._id}:`skip`),{c:D}=Ne({from:`/project/$projectId`}),O=x(A.projects.listProjects,{}),we=x(A.chatReads.myBusyChats,{}),M=(0,X.useMemo)(()=>new Set(we??[]),[we]),N=x(A.chatReads.myChatReads,{}),Te=(0,X.useMemo)(()=>mt(e.chats,N??[]),[e.chats,N]),{startNewChat:Fe,picker:I}=Ye(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[B,Xe]=(0,X.useState)(``),[Ze,V]=(0,X.useState)(!1),[U,W]=(0,X.useState)(e.project.name),[G,$e]=(0,X.useState)(!1),[J,ut]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ut(B.trim()),180);return()=>clearTimeout(e)},[B]);let Q=x(A.search.searchConversations,J.length>=2?{query:J,projectId:e.project._id}:`skip`),dt=De(et(at,{activationConstraint:{distance:4}}),et(Ue,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),_t=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[vt,yt]=(0,X.useState)(null),xt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=T?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||j()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(O??[]).find(t=>t._id===e)?.name??``}}return null},St=e=>yt(xt(String(e.active.id))),Tt=(0,X.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=F(n(`into:`));if(r.length>0){if(!t)return r;let n=r[0],i=e.droppableRects.get(n.id),a=e.pointerCoordinates?.y;if(i&&a!=null){let e=i.height*.3;if(a>i.top+e&&a<i.top+i.height-e)return r}}let i=F(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=F(n(`crumb:`));if(a.length>0)return a;let o=F(n(`col:`));return o.length>0?o:je(n(t?`folder:`:`chat:`))},[]),Dt=t=>{if(S===`columns`){for(let e of T?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(S===`list`){let e=E?.chats.find(e=>e._id===t);return e?{list:E.chats.filter(t=>t.folderId===e.folderId),folderId:e.folderId}:null}return e.chats.some(e=>e._id===t)?{list:e.chats,folderId:e.project._id}:null},kt=t=>{if(S===`columns`){for(let e of T?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(S===`list`){let e=E?.folders.find(e=>e._id===t);if(!e||!E)return null;let n=e.parentId??E.rootId;return{list:Ke(E.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},At=async e=>{yt(null),_t();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),i=String(t.id),o=i.startsWith(`chat:`);try{let e=bt(r);if(e!==void 0){if(o)await h({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Le(O??[],t,e)){a.error(v());return}await p({projectId:t,parentId:e})}return}if(o&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=Dt(t);if(!n)return;n.list.some(t=>t._id===e)||await h({chatId:e,projectId:n.folderId});let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await b({chatId:e,...a});return}if(!o&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=kt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Le(O??[],e,n.parentId)){a.error(v());return}await p({projectId:e,parentId:n.parentId})}let o=pt(n.list,e=>e._id,e=>e.sortKey,e,t);o&&await se({projectId:e,...o});return}}catch{a.error(v())}},[,Mt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Mt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Nt=Date.now(),Pt=H(e.project),Ft=ft(e.chats,B),It=e.breadcrumb.slice(0,-1),Lt=e=>()=>{$.current||e()};return(0,Z.jsxs)(He,{sensors:dt,collisionDetection:Tt,onDragStart:St,onDragEnd:At,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Pt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":Se(),children:[It.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Ct,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Lt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Z.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Z.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":y(),children:[(0,Z.jsx)(P,{variant:S===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":y(),title:y(),"aria-pressed":S===`cards`,onClick:()=>pe(`cards`),children:(0,Z.jsx)(lt,{})}),(0,Z.jsx)(P,{variant:S===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":m(),title:m(),"aria-pressed":S===`columns`,onClick:()=>pe(`columns`),children:(0,Z.jsx)(st,{})}),(0,Z.jsx)(P,{variant:S===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":f(),title:f(),"aria-pressed":S===`list`,onClick:()=>pe(`list`),children:(0,Z.jsx)(Ee,{})})]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void Fe({projectId:e.project._id}),children:[(0,Z.jsx)(it,{}),_()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await r({title:g(),label:be(),placeholder:_e(),confirmLabel:le()});t&&await d({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(ke,{}),g()]}),(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Re,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":te(),children:(0,Z.jsx)(Me,{})})}),(0,Z.jsxs)(Be,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(R,{onSelect:()=>{W(e.project.name),V(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>$e(!0),children:[(0,Z.jsx)(ct,{}),` `,me()]}),(0,Z.jsx)(Pe,{children:xe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void c({projectId:e.project._id,color:null}),"aria-label":de(),children:`✕`}),tt.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void c({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=ce?.folders??0,a=ce?.chats??0;await n({title:u({name:e.project.name}),description:i>0?ie({folders:i,chats:a}):a>0?ae({count:a}):ue(),confirmWord:k(),confirmLabel:ee(),destructive:!0})&&(await l({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Z.jsx)(Qe,{}),` `,k()]})]})]})]})]}),S===`columns`?(0,Z.jsx)(jt,{data:T,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:D??null}):S===`list`?(0,Z.jsx)(Ot,{data:E,busyIds:M,suppressClick:$,locateChatId:D??null}):(0,Z.jsxs)(Z.Fragment,{children:[e.children.length>0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:i()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(q,{items:e.children.map(e=>`folder:${e._id}`),strategy:ot,children:e.children.map(t=>(0,Z.jsx)(wt,{child:t,parentId:e.project._id,now:Nt,suppressClick:$},t._id))})})]}):null,(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:he()}),e.chats.length>0?(0,Z.jsx)(K,{value:B,onChange:e=>Xe(e.target.value),placeholder:re(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?o():ne()}):Ft.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Ce({term:B.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(q,{items:Ft.map(e=>`chat:${e._id}`),strategy:Y,children:Ft.map(t=>(0,Z.jsx)(Et,{chat:t,currentFolderId:e.project._id,now:Nt,busy:M.has(t._id),unread:Te.has(t._id),locate:t._id===D,suppressClick:$},t._id))})})]}),J.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ge()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Ce({term:J})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:Q.map(e=>(0,Z.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&J&&Ve(e.messageId,J),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(Je,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Z.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||ye()}),e.projectPath&&e.projectPath.length>1?(0,Z.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Z.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Z.jsx)(qe,{open:Ze,onOpenChange:V,title:oe(),canSubmit:U.trim().length>0,onSubmit:async()=>{await s({projectId:e.project._id,name:U.trim()}),V(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:U,onChange:e=>W(e.target.value),autoFocus:!0})}),G?(0,Z.jsx)(nt,{open:G,onOpenChange:$e,title:ve(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void p({projectId:e.project._id,parentId:t})}):null,I]}),(0,Z.jsx)(Oe,{children:vt?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[vt.kind===`folder`?(0,Z.jsx)(z,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Je,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:vt.label})]}):null})]})}function Ct({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=I({id:yt(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function wt({child:e,parentId:t,now:n,suppressClick:r}){let i=L(),a=B({id:`folder:${e._id}`}),o=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:G.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&i({to:`/project/$projectId`,params:{projectId:e._id}})},...a.listeners,...a.attributes,role:`link`,tabIndex:0,children:[(0,Z.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Z.jsx)(z,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,Z.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?c({count:e.folderCount})+` · `:``,l({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:Ze(e.lastActivityAt,n)})]})}function Tt({chat:e}){let t=w(A.chats.setChatSidebar),n=e.inSidebar?N():a();return(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Z.jsx)(W,{}):(0,Z.jsx)(ut,{})})}function Et({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=L(),c=U(e.color),l=B({id:`chat:${e._id}`}),u=Dt(a);return(0,Z.jsxs)(`li`,{ref:e=>{l.setNodeRef(e),u.current=e},className:`oc-projpage__chatrow`+(l.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:G.Transform.toString(l.transform),transition:l.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||s({to:`/chat/$chatId`,params:{chatId:e._id}})},...l.listeners,...l.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||j()}),e.pinned?(0,Z.jsx)(V,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:Ze(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:fe(),"aria-label":fe()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:p(),"aria-label":p()}):null]}),(0,Z.jsx)(Tt,{chat:e}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function Dt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ot({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,X.useState)(new Set),s=(0,X.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()});if(e===null)return null;let c=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),l=(a,o)=>{let u=s.get(a??e.rootId)??[],d=Ke(e.folders,a);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{items:u.map(e=>`chat:${e._id}`),strategy:Y,children:u.map(e=>(0,Z.jsx)(At,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Z.jsx)(q,{items:d.map(e=>`folder:${e._id}`),strategy:Y,children:d.map(t=>(0,Z.jsx)(kt,{folder:t,parentId:a??e.rootId,depth:o,folded:i.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:i.has(t._id)?null:l(t._id,o+1)},t._id))})]})};return(0,Z.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Ke(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:o()}):l(null,0)})}function kt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=L(),c=B({id:`folder:${e._id}`}),l=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Z.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":H(e),transform:G.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?h():T(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)($e,{size:13}):(0,Z.jsx)(Te,{size:13})}),(0,Z.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function At({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=L(),o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||j()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(Tt,{chat:e})]})}function jt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(Mt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function Mt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=L(),s=I({id:vt(e.folderId)});return(0,Z.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Z.jsx)(q,{items:e.folders.map(e=>`folder:${e._id}`),strategy:Y,children:e.folders.map(t=>(0,Z.jsx)(Nt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Z.jsx)(q,{items:e.chats.map(e=>`chat:${e._id}`),strategy:Y,children:e.chats.map(t=>(0,Z.jsx)(Pt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__colempty`,children:ne()}):null]})}function Nt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:G.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,Z.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Pt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||j()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(Tt,{chat:e})]})}export{xt as ProjectPage};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,A_ as i,B_ as a,C_ as o,D as s,D_ as c,E_ as l,G_ as u,H_ as d,I_ as f,J_ as p,K_ as ee,L_ as m,M_ as h,N_ as g,O_ as _,P_ as v,Q_ as te,R_ as y,S_ as ne,T_ as re,U_ as ie,W_ as ae,XR as b,Z_ as oe,Zg as se,a_ as ce,av as le,az as x,b_ as S,c_ as ue,e_ as de,ev as fe,g_ as pe,h_ as me,i_ as C,iz as w,j_ as T,k_ as he,l_ as ge,m_ as E,n_ as D,ov as _e,p_ as ve,ph as ye,r_ as O,s_ as k,sv as be,t as A,t_ as xe,tv as j,v_ as Se,w_ as Ce,x_ as we,y_ as M,z_ as N}from"./api-BDOBe_HI.js";import{r as Te}from"./dist-Ct8KdJzy.js";import{t as Ee}from"./list-CTIbo6ut.js";import{t as P}from"./button-BXoUycz-.js";import{A as De,C as Oe,Cn as ke,D as F,Dt as Ae,E as je,En as Me,Fn as Ne,Ft as Pe,In as Fe,It as Ie,J as Le,Lt as Re,Mt as ze,Nt as Be,O as I,P as Ve,Pn as L,Pt as R,S as He,Sn as z,T as Ue,U as We,W as Ge,Y as Ke,_ as qe,_n as Je,b as B,d as Ye,dn as Xe,f as Ze,fn as V,g as H,h as U,hn as W,in as Qe,j as G,jn as $e,jt as K,k as et,m as tt,p as nt,pn as rt,v as q,vn as it,w as at,wn as J,x as Y,y as ot}from"./index-B0ufU8aN.js";var st=s(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),ct=s(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),lt=s(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),ut=s(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),X=t(e(),1),Z=n();function Q({className:e}){return(0,Z.jsx)(Re,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":ce(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Me,{})})})}function dt({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:a}){let o=w(A.projects.renameProject),s=w(A.projects.setProjectColor),c=w(A.projects.moveProject),l=w(A.projects.deleteProject),f=w(A.projects.createProject),p=We(),m=Ge(),[h,_]=(0,X.useState)(!1),[v,te]=(0,X.useState)(t),[y,ne]=(0,X.useState)(!1),[re,b]=(0,X.useState)(!1),se=x(A.projects.projectTreeCount,re?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ze,{onOpenChange:e=>e&&b(!0),children:[(0,Z.jsx)(Q,{className:i}),(0,Z.jsxs)(Be,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>a(),children:[(0,Z.jsx)(J,{}),` `,d()]}),(0,Z.jsxs)(R,{onSelect:()=>{te(t),_(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await m({title:g(),label:be(),placeholder:_e(),confirmLabel:le()});t&&await f({name:t,parentId:e})})},children:[(0,Z.jsx)(ke,{}),` `,g()]}),(0,Z.jsxs)(R,{onSelect:()=>ne(!0),children:[(0,Z.jsx)(ct,{}),` `,me()]}),(0,Z.jsx)(Pe,{children:xe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void s({projectId:e,color:null}),"aria-label":de(),children:`✕`}),tt.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void s({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=se?.folders??0,r=se?.chats??0;await p({title:u({name:t}),description:n>0?ie({folders:n,chats:r}):r>0?ae({count:r}):ue(),confirmWord:k(),confirmLabel:ee(),destructive:!0})&&await l({projectId:e})})},children:[(0,Z.jsx)(Qe,{}),` `,k()]})]})]}),(0,Z.jsx)(qe,{open:h,onOpenChange:_,title:oe(),canSubmit:v.trim().length>0,onSubmit:async()=>{await o({projectId:e,name:v.trim()}),_(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:v,onChange:e=>te(e.target.value),autoFocus:!0})}),y?(0,Z.jsx)(nt,{open:y,onOpenChange:ne,title:ve(),movingFolderId:e,currentId:r,onPick:t=>void c({projectId:e,parentId:t})}):null]})}function $({chat:e,currentFolderId:t,className:n}){let i=w(A.chats.pinChat),o=w(A.chats.deleteChat),s=w(A.chats.renameChat),c=w(A.chats.setChatSidebar),l=w(A.chats.moveChatToProject),u=We(),[d,f]=(0,X.useState)(!1),[p,ee]=(0,X.useState)(e.title??``),[m,h]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Q,{className:n}),(0,Z.jsxs)(Be,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>{ee(e.title??``),f(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>void i({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(Xe,{}):(0,Z.jsx)(V,{}),e.pinned?O():D()]}),(0,Z.jsxs)(R,{onSelect:()=>h(!0),children:[(0,Z.jsx)(ct,{}),` `,pe()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(R,{onSelect:()=>void c({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(W,{}):(0,Z.jsx)(ut,{}),e.inSidebar?N():a()]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await u({title:r(),description:ue(),confirmLabel:k(),destructive:!0})&&await o({chatId:e._id})})},children:[(0,Z.jsx)(Qe,{}),` `,k()]})]})]}),(0,Z.jsx)(qe,{open:d,onOpenChange:f,title:se(),canSubmit:p.trim().length>0,onSubmit:async()=>{await s({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:p,onChange:e=>ee(e.target.value),autoFocus:!0})}),m?(0,Z.jsx)(nt,{open:m,onOpenChange:h,title:E(),currentId:t,onPick:t=>void l({chatId:e._id,projectId:t})}):null]})}function ft(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function pt(e,t,n,r,i){let a=e.map(t),o=a.indexOf(i);if(o<0)return null;let s=a.indexOf(r);if(s>=0){let t=[...e],[r]=t.splice(s,1);t.splice(o,0,r);let i=t[o-1],a=t[o+1];return{prevKey:i===void 0?null:n(i),nextKey:a===void 0?null:n(a)}}let c=e[o-1];return{prevKey:c===void 0?null:n(c),nextKey:n(e[o])}}function mt(e,t){let n=new Map(t.map(e=>[e.chatId,e.lastSeenAt])),r=new Set;for(let t of e){let e=n.get(t._id);e!==void 0&&t.lastAssistantAt!==null&&t.lastAssistantAt>e&&r.add(t._id)}return r}var ht=`oc.projpage.view`;function gt(){let e=localStorage.getItem(ht);return e===`cards`||e===`list`?e:`columns`}var _t=e=>`into:${e}`,vt=e=>`col:${e??`null`}`,yt=e=>`crumb:${e}`;function bt(e){if(e.startsWith(`into:`))return e.slice(5);if(e.startsWith(`crumb:`))return e.slice(6);if(e.startsWith(`col:`)){let t=e.slice(4);return t===`null`?null:t}}function xt(){let{projectId:e}=Fe({from:`/project/$projectId`}),t=L(),n=x(A.projects.projectPage,{projectId:e});return(0,Z.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:we()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:S()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:M()})]}):(0,Z.jsx)(St,{page:n})})}function St({page:e}){let t=L(),n=We(),r=Ge(),a=Ae(),s=w(A.projects.renameProject),c=w(A.projects.setProjectColor),l=w(A.projects.deleteProject),d=w(A.projects.createProject),p=w(A.projects.moveProject),h=w(A.chats.moveChatToProject),b=w(A.chats.reorderChat),se=w(A.projects.reorderProject),ce=x(A.projects.projectTreeCount,{projectId:e.project._id}),[S,fe]=(0,X.useState)(gt),pe=e=>{localStorage.setItem(ht,e),fe(e)},T=x(A.projects.folderColumns,S===`columns`?{projectId:e.project._id}:`skip`),E=x(A.projects.projectTreeList,S===`list`?{projectId:e.project._id}:`skip`),{c:D}=Ne({from:`/project/$projectId`}),O=x(A.projects.listProjects,{}),we=x(A.chatReads.myBusyChats,{}),M=(0,X.useMemo)(()=>new Set(we??[]),[we]),N=x(A.chatReads.myChatReads,{}),Te=(0,X.useMemo)(()=>mt(e.chats,N??[]),[e.chats,N]),{startNewChat:Fe,picker:I}=Ye(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[B,Xe]=(0,X.useState)(``),[Ze,V]=(0,X.useState)(!1),[U,W]=(0,X.useState)(e.project.name),[G,$e]=(0,X.useState)(!1),[J,ut]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ut(B.trim()),180);return()=>clearTimeout(e)},[B]);let Q=x(A.search.searchConversations,J.length>=2?{query:J,projectId:e.project._id}:`skip`),dt=De(et(at,{activationConstraint:{distance:4}}),et(Ue,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),_t=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[vt,yt]=(0,X.useState)(null),xt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=T?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||j()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(O??[]).find(t=>t._id===e)?.name??``}}return null},St=e=>yt(xt(String(e.active.id))),Tt=(0,X.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=F(n(`into:`));if(r.length>0){if(!t)return r;let n=r[0],i=e.droppableRects.get(n.id),a=e.pointerCoordinates?.y;if(i&&a!=null){let e=i.height*.3;if(a>i.top+e&&a<i.top+i.height-e)return r}}let i=F(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=F(n(`crumb:`));if(a.length>0)return a;let o=F(n(`col:`));return o.length>0?o:je(n(t?`folder:`:`chat:`))},[]),Dt=t=>{if(S===`columns`){for(let e of T?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(S===`list`){let e=E?.chats.find(e=>e._id===t);return e?{list:E.chats.filter(t=>t.folderId===e.folderId),folderId:e.folderId}:null}return e.chats.some(e=>e._id===t)?{list:e.chats,folderId:e.project._id}:null},kt=t=>{if(S===`columns`){for(let e of T?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(S===`list`){let e=E?.folders.find(e=>e._id===t);if(!e||!E)return null;let n=e.parentId??E.rootId;return{list:Ke(E.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},At=async e=>{yt(null),_t();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),i=String(t.id),o=i.startsWith(`chat:`);try{let e=bt(r);if(e!==void 0){if(o)await h({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Le(O??[],t,e)){a.error(v());return}await p({projectId:t,parentId:e})}return}if(o&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=Dt(t);if(!n)return;n.list.some(t=>t._id===e)||await h({chatId:e,projectId:n.folderId});let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await b({chatId:e,...a});return}if(!o&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=kt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Le(O??[],e,n.parentId)){a.error(v());return}await p({projectId:e,parentId:n.parentId})}let o=pt(n.list,e=>e._id,e=>e.sortKey,e,t);o&&await se({projectId:e,...o});return}}catch{a.error(v())}},[,Mt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Mt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Nt=Date.now(),Pt=H(e.project),Ft=ft(e.chats,B),It=e.breadcrumb.slice(0,-1),Lt=e=>()=>{$.current||e()};return(0,Z.jsxs)(He,{sensors:dt,collisionDetection:Tt,onDragStart:St,onDragEnd:At,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Pt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":Se(),children:[It.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Ct,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Lt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Z.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Z.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":y(),children:[(0,Z.jsx)(P,{variant:S===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":y(),title:y(),"aria-pressed":S===`cards`,onClick:()=>pe(`cards`),children:(0,Z.jsx)(lt,{})}),(0,Z.jsx)(P,{variant:S===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":m(),title:m(),"aria-pressed":S===`columns`,onClick:()=>pe(`columns`),children:(0,Z.jsx)(st,{})}),(0,Z.jsx)(P,{variant:S===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":f(),title:f(),"aria-pressed":S===`list`,onClick:()=>pe(`list`),children:(0,Z.jsx)(Ee,{})})]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void Fe({projectId:e.project._id}),children:[(0,Z.jsx)(it,{}),_()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await r({title:g(),label:be(),placeholder:_e(),confirmLabel:le()});t&&await d({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(ke,{}),g()]}),(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Re,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":te(),children:(0,Z.jsx)(Me,{})})}),(0,Z.jsxs)(Be,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(R,{onSelect:()=>{W(e.project.name),V(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>$e(!0),children:[(0,Z.jsx)(ct,{}),` `,me()]}),(0,Z.jsx)(Pe,{children:xe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void c({projectId:e.project._id,color:null}),"aria-label":de(),children:`✕`}),tt.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void c({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=ce?.folders??0,a=ce?.chats??0;await n({title:u({name:e.project.name}),description:i>0?ie({folders:i,chats:a}):a>0?ae({count:a}):ue(),confirmWord:k(),confirmLabel:ee(),destructive:!0})&&(await l({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Z.jsx)(Qe,{}),` `,k()]})]})]})]})]}),S===`columns`?(0,Z.jsx)(jt,{data:T,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:D??null}):S===`list`?(0,Z.jsx)(Ot,{data:E,busyIds:M,suppressClick:$,locateChatId:D??null}):(0,Z.jsxs)(Z.Fragment,{children:[e.children.length>0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:i()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(q,{items:e.children.map(e=>`folder:${e._id}`),strategy:ot,children:e.children.map(t=>(0,Z.jsx)(wt,{child:t,parentId:e.project._id,now:Nt,suppressClick:$},t._id))})})]}):null,(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:he()}),e.chats.length>0?(0,Z.jsx)(K,{value:B,onChange:e=>Xe(e.target.value),placeholder:re(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?o():ne()}):Ft.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Ce({term:B.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(q,{items:Ft.map(e=>`chat:${e._id}`),strategy:Y,children:Ft.map(t=>(0,Z.jsx)(Et,{chat:t,currentFolderId:e.project._id,now:Nt,busy:M.has(t._id),unread:Te.has(t._id),locate:t._id===D,suppressClick:$},t._id))})})]}),J.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ge()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Ce({term:J})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:Q.map(e=>(0,Z.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&J&&Ve(e.messageId,J),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(Je,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Z.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||ye()}),e.projectPath&&e.projectPath.length>1?(0,Z.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Z.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Z.jsx)(qe,{open:Ze,onOpenChange:V,title:oe(),canSubmit:U.trim().length>0,onSubmit:async()=>{await s({projectId:e.project._id,name:U.trim()}),V(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:U,onChange:e=>W(e.target.value),autoFocus:!0})}),G?(0,Z.jsx)(nt,{open:G,onOpenChange:$e,title:ve(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void p({projectId:e.project._id,parentId:t})}):null,I]}),(0,Z.jsx)(Oe,{children:vt?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[vt.kind===`folder`?(0,Z.jsx)(z,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Je,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:vt.label})]}):null})]})}function Ct({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=I({id:yt(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function wt({child:e,parentId:t,now:n,suppressClick:r}){let i=L(),a=B({id:`folder:${e._id}`}),o=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:G.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&i({to:`/project/$projectId`,params:{projectId:e._id}})},...a.listeners,...a.attributes,role:`link`,tabIndex:0,children:[(0,Z.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Z.jsx)(z,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,Z.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?c({count:e.folderCount})+` · `:``,l({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:Ze(e.lastActivityAt,n)})]})}function Tt({chat:e}){let t=w(A.chats.setChatSidebar),n=e.inSidebar?N():a();return(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Z.jsx)(W,{}):(0,Z.jsx)(ut,{})})}function Et({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=L(),c=U(e.color),l=B({id:`chat:${e._id}`}),u=Dt(a);return(0,Z.jsxs)(`li`,{ref:e=>{l.setNodeRef(e),u.current=e},className:`oc-projpage__chatrow`+(l.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:G.Transform.toString(l.transform),transition:l.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||s({to:`/chat/$chatId`,params:{chatId:e._id}})},...l.listeners,...l.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||j()}),e.pinned?(0,Z.jsx)(V,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:Ze(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:fe(),"aria-label":fe()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:p(),"aria-label":p()}):null]}),(0,Z.jsx)(Tt,{chat:e}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function Dt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ot({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,X.useState)(new Set),s=(0,X.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()});if(e===null)return null;let c=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),l=(a,o)=>{let u=s.get(a??e.rootId)??[],d=Ke(e.folders,a);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{items:u.map(e=>`chat:${e._id}`),strategy:Y,children:u.map(e=>(0,Z.jsx)(At,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Z.jsx)(q,{items:d.map(e=>`folder:${e._id}`),strategy:Y,children:d.map(t=>(0,Z.jsx)(kt,{folder:t,parentId:a??e.rootId,depth:o,folded:i.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:i.has(t._id)?null:l(t._id,o+1)},t._id))})]})};return(0,Z.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Ke(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:o()}):l(null,0)})}function kt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=L(),c=B({id:`folder:${e._id}`}),l=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Z.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":H(e),transform:G.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?h():T(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)($e,{size:13}):(0,Z.jsx)(Te,{size:13})}),(0,Z.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function At({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=L(),o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||j()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(Tt,{chat:e})]})}function jt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(Mt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function Mt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=L(),s=I({id:vt(e.folderId)});return(0,Z.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Z.jsx)(q,{items:e.folders.map(e=>`folder:${e._id}`),strategy:Y,children:e.folders.map(t=>(0,Z.jsx)(Nt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Z.jsx)(q,{items:e.chats.map(e=>`chat:${e._id}`),strategy:Y,children:e.chats.map(t=>(0,Z.jsx)(Pt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__colempty`,children:ne()}):null]})}function Nt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:G.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,Z.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Pt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||j()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(Tt,{chat:e})]})}export{xt as ProjectPage};
@@ -1,4 +1,4 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$y as r,Ca as i,Fr as a,Ir as o,Lr as s,Qy as c,Sa as l,Ta as u,Tb as d,_b as f,ab as p,az as m,cb as h,da as g,db as _,ds as v,eb as y,fa as b,fb as x,fs as S,gb as C,ha as w,hb as T,hs as E,ib as D,iz as ee,lb as te,ma as ne,mb as re,ms as ie,nb as ae,ob as oe,pa as se,pb as O,ps as k,rb as A,sb as j,t as M,tb as N,ub as P,wa as F,wb as I}from"./api-BDOBe_HI.js";import{d as L,f as R,i as z,l as B,n as V,r as H,t as U,u as ce}from"./FieldLabel-DylbQ765.js";import{t as W}from"./button-BXoUycz-.js";import{$ as G,Dt as le,Q as K,X as q,Z as J,et as Y,q as ue,ut as de}from"./index-DtAFZhtv.js";import{r as X,t as fe}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Z=t(e(),1),Q=n(),$={media_delivery:{label:x,help:_},documentary_fetch:{label:P,help:te},inbound_files:{label:h,help:j},history_summary:{label:E,help:ie},file_curation:{label:u,help:w},quote_reply:{label:F,help:i}},me={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{$y as r,Ca as i,Fr as a,Ir as o,Lr as s,Qy as c,Sa as l,Ta as u,Tb as d,_b as f,ab as p,az as m,cb as h,da as g,db as _,ds as v,eb as y,fa as b,fb as x,fs as S,gb as C,ha as w,hb as T,hs as E,ib as D,iz as ee,lb as te,ma as ne,mb as re,ms as ie,nb as ae,ob as oe,pa as se,pb as O,ps as k,rb as A,sb as j,t as M,tb as N,ub as P,wa as F,wb as I}from"./api-BDOBe_HI.js";import{d as L,f as R,i as z,l as B,n as V,r as H,t as U,u as ce}from"./FieldLabel-DRaqrHBA.js";import{t as W}from"./button-BXoUycz-.js";import{$ as G,Dt as le,Q as K,X as q,Z as J,et as Y,q as ue,ut as de}from"./index-B0ufU8aN.js";import{r as X,t as fe}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Z=t(e(),1),Q=n(),$={media_delivery:{label:x,help:_},documentary_fetch:{label:P,help:te},inbound_files:{label:h,help:j},history_summary:{label:E,help:ie},file_curation:{label:u,help:w},quote_reply:{label:F,help:i}},me={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)`,previous_summary:`Projet Alpha : budget 40 000 EUR ; choix du serveur en cours.`,new_messages:`Utilisateur : Compare OVH et Scaleway.
3
3
  Assistant : Comparaison en cours.`,max_chars:`6000`,file_name:`MEMORY.md`,budget_chars:`20000`,feedback:`Trop de suppressions dans la section des liens, garde-les.`,content:`# Memory index
4
4
  - [Fait 1](fait-1.md) - note du projet`,excerpt:`Le classement propose trois dossiers : Clients, Fournisseurs, Interne.`},he={outboundDir:y,references:r,files:c,previous_summary:k,new_messages:S,max_chars:v,file_name:ne,budget_chars:se,feedback:b,content:g,excerpt:l};function ge(){let e=m(M.admin.listInstances,{}),[t,n]=(0,Z.useState)(null);if(e===void 0)return(0,Q.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,Q.jsx)(`div`,{className:`oc-injtab`,children:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:p()})});let r=e.find(e=>e._id===t)??e[0];return(0,Q.jsxs)(`div`,{className:`oc-injtab`,children:[(0,Q.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,Q.jsx)(V,{label:f(),help:C()}),(0,Q.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,Q.jsx)(`span`,{children:oe()}),(0,Q.jsxs)(q,{value:r._id,onValueChange:e=>n(e),children:[(0,Q.jsx)(G,{size:`sm`,className:`min-w-44`,children:(0,Q.jsx)(Y,{})}),(0,Q.jsx)(J,{children:e.map(e=>(0,Q.jsx)(K,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,Q.jsx)(_e,{instance:r},r._id)]})}function _e({instance:e}){let t=ee(M.admin.upsertInstanceConfig),n=le(),r=m(M.me.getMe,{host:ue}),i=e.config??{},c=X(e.config?.contentLocale,r?.defaultLocale??void 0),[l,u]=(0,Z.useState)(()=>z(i,c));(0,Z.useEffect)(()=>{u(z(i,c))},[c,e._id]);let[f,p]=(0,Z.useState)(!1),h=l.promptInjections,g=(e,t)=>u({...l,promptInjections:{...h,[e]:{...h[e],...t}}});async function _(){p(!0);try{await t({instanceId:e._id,config:H(l,i,c)})}catch(e){n.error(I(),e)}finally{p(!1)}}async function v(r){let i={...e.config??{}};r==="default"?delete i.contentLocale:i.contentLocale=r;try{await t({instanceId:e._id,config:i})}catch(e){n.error(I(),e)}}let y=e.config?.contentLocale??`default`,b=fe[X(void 0,r?.defaultLocale??void 0)];return(0,Q.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,Q.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,Q.jsx)(`span`,{children:s()}),(0,Q.jsxs)(q,{value:y,onValueChange:e=>void v(e),children:[(0,Q.jsx)(G,{size:`sm`,className:`min-w-44`,children:(0,Q.jsx)(Y,{})}),(0,Q.jsxs)(J,{children:[(0,Q.jsx)(K,{value:`default`,children:a({locale:b})}),pe().map(e=>(0,Q.jsx)(K,{value:e.value,children:e.label},e.value))]})]}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:o()})]}),ce.map(e=>(0,Q.jsx)(ve,{injKey:e,def:B[e],i18n:$[e],row:h[e]??{enabled:!0,template:B[e].defaultTemplate[c]},contentLocale:c,onChange:t=>g(e,t)},e)),(0,Q.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,Q.jsx)(W,{size:`sm`,onClick:()=>void _(),disabled:f,children:d()})})]})}function ve({injKey:e,def:t,i18n:n,row:r,contentLocale:i,onChange:a}){let[o,s]=(0,Z.useState)(!1),c=r.template.trim()!==t.defaultTemplate[i],l=t.togglable&&!r.enabled,u=Object.fromEntries(t.placeholders.map(e=>[e,me[e]??`{${e}}`])),d=L(e,r,i),f=d?R(d,u):``;return(0,Q.jsxs)(`section`,{className:`oc-injcard`,children:[(0,Q.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(de,{checked:r.enabled,onCheckedChange:e=>a({enabled:e===!0})}),(0,Q.jsx)(V,{label:n.label(),help:n.help()})]}):(0,Q.jsx)(V,{label:n.label(),help:n.help()}),c&&(0,Q.jsx)(`span`,{className:`oc-injection__badge`,children:re()})]}),(0,Q.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:l,rows:8,spellCheck:!1,onChange:e=>a({template:e.target.value})}),(0,Q.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,Q.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,Q.jsx)(`span`,{className:`oc-injection__ph`,children:O()}),t.placeholders.map(e=>(0,Q.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,Q.jsx)(`code`,{children:`{${e}}`}),(0,Q.jsx)(U,{text:(he[e]??(()=>e))()})]},e))]}),(0,Q.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,Q.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>s(e=>!e),children:o?A():D()}),c&&(0,Q.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>a({template:t.defaultTemplate[i]}),children:T()})]})]}),o&&(0,Q.jsx)(`div`,{className:`oc-injcard__preview`,children:f?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:f}),(0,Q.jsx)(`span`,{className:`oc-injection__ph`,children:ae()})]}):(0,Q.jsx)(`span`,{className:`oc-injection__ph`,children:N()})})]})}export{ge as PromptInjectionsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$C as r,AC as i,BC as ee,DC as te,EC as ne,GC as a,HC as o,JC as s,KC as c,MC as l,NC as u,OC as d,PC as f,QC as p,UC as m,VC as h,WC as re,XC as g,YC as _,Ya as v,ZC as y,aw as b,az as ie,cw as x,dw as S,ew as ae,fw as C,hw as w,iw as T,iz as E,jC as D,kC as O,lw as k,mw as A,nw as j,ow as M,pw as N,qC as P,rw as F,sw as I,t as L,tw as R,uw as z}from"./api-BDOBe_HI.js";import{t as B}from"./button-BXoUycz-.js";import{Dt as V,Et as H,U,_ as W,jt as G,ut as K,yn as q}from"./index-DtAFZhtv.js";import{t as J}from"./roleDescriptions-BJHinaor.js";var Y=t(e(),1),X=n(),Z=[{group:()=>w(),keys:[{key:`traces.read`,label:()=>z()},{key:`traces.read.content`,label:()=>k(),phi:!0},{key:`traces.write`,label:()=>x()}]},{group:()=>A(),keys:[{key:`kpi.read`,label:()=>z()},{key:`kpi.write`,label:()=>x()}]},{group:()=>N(),keys:[{key:`openclaw.query`,label:()=>I()},{key:`anomalies.read`,label:()=>M()},{key:`anomalies.report`,label:()=>b()}]},{group:()=>C(),keys:[{key:`chats.read`,label:()=>z()},{key:`selfheal`,label:()=>F()},{key:`feedback.respond`,label:()=>v()}]},{group:()=>S(),keys:[{key:`admin.manage`,label:()=>T()}]}],oe=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function se(){let e=ie(L.apiKeys.listRoles,{}),t=E(L.apiKeys.createRole),n=E(L.apiKeys.ensureRolesSeeded),v=E(L.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(L.apiKeys.listRoles,{});r&&e.setQuery(L.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),b=U(),x=V(),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)($),[k,A]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{x.error(R(),e)})},[n,x]);let M=e??[];async function N(e,t){if(Q(e.permissions))return;if(e.builtin){await b({title:ae({name:e.name}),description:r(),confirmLabel:p()});return}if(k.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];A(t=>new Set(t).add(e._id));try{await v({roleId:e._id,permissions:n})}catch(e){x.error(y(),e)}finally{A(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function F(){try{await t({key:w.key,name:w.name,description:w.description||void 0,permissions:[]}),T($),C(!1)}catch(e){x.error(g(),e)}}let I=e===void 0,z=!I&&M.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[_(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,s(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,P()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:c()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{T($),C(!0)},children:a()})})]}),I?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:re()}):z?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,X.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,X.jsxs)(`table`,{className:`oc-matrix`,children:[(0,X.jsxs)(`thead`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:o()}),Z.map(e=>(0,X.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,X.jsx)(`tr`,{children:Z.flatMap(e=>e.keys.map(e=>(0,X.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?j({key:e.key}):e.key,children:[e.label(),e.phi?(0,X.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,X.jsx)(`tbody`,{children:M.map(e=>{let t=Q(e.permissions),n=k.has(e._id);return(0,X.jsxs)(`tr`,{children:[(0,X.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,X.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,X.jsx)(`span`,{children:e.name}),(0,X.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,X.jsxs)(H,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(q,{}),` `,h()]}):(0,X.jsx)(H,{variant:`secondary`,children:ee()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),oe.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(K,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?f():n?u():r,onCheckedChange:()=>void N(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(W,{open:S,onOpenChange:C,title:l(),description:D(),canSubmit:!!(w.key&&w.name),onSubmit:F,submitLabel:i(),children:(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:O()}),(0,X.jsx)(G,{value:w.key,placeholder:d(),onChange:e=>T({...w,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:te()}),(0,X.jsx)(G,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:ne()}),(0,X.jsx)(G,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})})]})}export{se as RolesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$C as r,AC as i,BC as ee,DC as te,EC as ne,GC as a,HC as o,JC as s,KC as c,MC as l,NC as u,OC as d,PC as f,QC as p,UC as m,VC as h,WC as re,XC as g,YC as _,Ya as v,ZC as y,aw as b,az as ie,cw as x,dw as S,ew as ae,fw as C,hw as w,iw as T,iz as E,jC as D,kC as O,lw as k,mw as A,nw as j,ow as M,pw as N,qC as P,rw as F,sw as I,t as L,tw as R,uw as z}from"./api-BDOBe_HI.js";import{t as B}from"./button-BXoUycz-.js";import{Dt as V,Et as H,U,_ as W,jt as G,ut as K,yn as q}from"./index-B0ufU8aN.js";import{t as J}from"./roleDescriptions-BJHinaor.js";var Y=t(e(),1),X=n(),Z=[{group:()=>w(),keys:[{key:`traces.read`,label:()=>z()},{key:`traces.read.content`,label:()=>k(),phi:!0},{key:`traces.write`,label:()=>x()}]},{group:()=>A(),keys:[{key:`kpi.read`,label:()=>z()},{key:`kpi.write`,label:()=>x()}]},{group:()=>N(),keys:[{key:`openclaw.query`,label:()=>I()},{key:`anomalies.read`,label:()=>M()},{key:`anomalies.report`,label:()=>b()}]},{group:()=>C(),keys:[{key:`chats.read`,label:()=>z()},{key:`selfheal`,label:()=>F()},{key:`feedback.respond`,label:()=>v()}]},{group:()=>S(),keys:[{key:`admin.manage`,label:()=>T()}]}],oe=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function se(){let e=ie(L.apiKeys.listRoles,{}),t=E(L.apiKeys.createRole),n=E(L.apiKeys.ensureRolesSeeded),v=E(L.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(L.apiKeys.listRoles,{});r&&e.setQuery(L.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),b=U(),x=V(),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)($),[k,A]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{x.error(R(),e)})},[n,x]);let M=e??[];async function N(e,t){if(Q(e.permissions))return;if(e.builtin){await b({title:ae({name:e.name}),description:r(),confirmLabel:p()});return}if(k.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];A(t=>new Set(t).add(e._id));try{await v({roleId:e._id,permissions:n})}catch(e){x.error(y(),e)}finally{A(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function F(){try{await t({key:w.key,name:w.name,description:w.description||void 0,permissions:[]}),T($),C(!1)}catch(e){x.error(g(),e)}}let I=e===void 0,z=!I&&M.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[_(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,s(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,P()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:c()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{T($),C(!0)},children:a()})})]}),I?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:re()}):z?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,X.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,X.jsxs)(`table`,{className:`oc-matrix`,children:[(0,X.jsxs)(`thead`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:o()}),Z.map(e=>(0,X.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,X.jsx)(`tr`,{children:Z.flatMap(e=>e.keys.map(e=>(0,X.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?j({key:e.key}):e.key,children:[e.label(),e.phi?(0,X.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,X.jsx)(`tbody`,{children:M.map(e=>{let t=Q(e.permissions),n=k.has(e._id);return(0,X.jsxs)(`tr`,{children:[(0,X.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,X.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,X.jsx)(`span`,{children:e.name}),(0,X.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,X.jsxs)(H,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(q,{}),` `,h()]}):(0,X.jsx)(H,{variant:`secondary`,children:ee()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),oe.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(K,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?f():n?u():r,onCheckedChange:()=>void N(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(W,{open:S,onOpenChange:C,title:l(),description:D(),canSubmit:!!(w.key&&w.name),onSubmit:F,submitLabel:i(),children:(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:O()}),(0,X.jsx)(G,{value:w.key,placeholder:d(),onChange:e=>T({...w,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:te()}),(0,X.jsx)(G,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:ne()}),(0,X.jsx)(G,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})})]})}export{se as RolesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$I as r,AI as i,AL as a,BF as o,CL as s,D as c,DI as l,DL as u,EL as ee,FF as d,FI as f,GF as p,GI as te,HF as ne,HI as re,IF as ie,II as ae,JF as oe,JI as se,KF as ce,KI as le,LF as ue,MI as de,ML as fe,NI as pe,NL as me,OF as he,OI as ge,OL as _e,PF as ve,PI as ye,PL as be,QI as xe,QR as m,RF as Se,RI as Ce,SI as we,SL as Te,TL as Ee,UF as De,UI as Oe,VF as ke,VI as Ae,WF as je,WI as Me,XF as Ne,XR as Pe,YF as Fe,YI as h,ZF as Ie,ZI as Le,_I as Re,az as ze,bI as g,bL as Be,cI as Ve,dI as _,eL as He,fI as Ue,gI as We,hI as Ge,jI as Ke,jL as qe,kI as Je,kL as Ye,lI as Xe,mI as Ze,nL as Qe,nz as v,pI as $e,qF as et,qI as tt,sI as nt,t as y,tL as rt,uI as b,vI as it,wL as at,xI as x,xL as ot,yI as st,zF as ct}from"./api-BDOBe_HI.js";import{t as lt}from"./list-CTIbo6ut.js";import{t as S}from"./button-BXoUycz-.js";import{$ as C,Bt as w,Ct as ut,Dt as dt,Et as T,Mn as E,Q as D,Rt as O,St as ft,Tt as pt,X as k,Z as A,_t as mt,at as ht,bn as gt,bt as _t,cn as vt,et as j,gt as yt,in as bt,it as xt,jn as M,jt as St,mn as Ct,nt as wt,ot as Tt,pn as Et,q as Dt,rt as Ot,tn as kt,tt as At,un as jt,vt as Mt,wt as Nt,xt as Pt,yt as Ft,zt as N}from"./index-DtAFZhtv.js";import{a as It,i as P,n as Lt,o as Rt,r as F,t as zt}from"./table-Ql8c7BIW.js";import{t as Bt}from"./FilterBar-D99V_QOK.js";/* empty css */import{a as I,c as Vt,i as Ht,l as Ut,n as Wt,o as Gt,r as Kt,s as L,t as qt}from"./TimezoneCombobox-C33f4gjg.js";var Jt=c(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),Yt=c(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),R=t(e(),1),z=n();function B(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function Xt({value:e,onChange:t}){let n=Vt(e),r=(0,R.useMemo)(()=>new Date,[]),[i,a]=(0,R.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[o,s]=(0,R.useState)(!1),c=(0,R.useMemo)(()=>B(m()),[]),l=(0,R.useMemo)(()=>new Intl.DateTimeFormat(m(),{month:`long`,year:`numeric`}),[]),u=(0,R.useMemo)(()=>new Intl.DateTimeFormat(m(),{dateStyle:`medium`,timeStyle:`short`}),[]),ee=L(i.year,i.month),d=n?.hour??9,f=n?.minute??0,p=(e,n,r,i,a)=>t(Ut(e,n,r,i,a)),te=(e,t,n)=>{a({year:e,month:t}),p(e,t,n,d,f)},ne=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},re=n===null?x():u.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,z.jsxs)(O,{modal:!0,open:o,onOpenChange:s,children:[(0,z.jsx)(w,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":we(),children:[(0,z.jsx)(Jt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,z.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:re})]})}),(0,z.jsxs)(N,{align:`start`,className:`oc-dtp__pop`,children:[(0,z.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":g(),onClick:()=>ne(-1),children:(0,z.jsx)(E,{size:15,"aria-hidden":!0})}),(0,z.jsx)(`span`,{className:`oc-dtp__month`,children:l.format(new Date(i.year,i.month,1))}),(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":st(),onClick:()=>ne(1),children:(0,z.jsx)(M,{size:15,"aria-hidden":!0})})]}),(0,z.jsxs)(`div`,{className:`oc-dtp__grid`,children:[c.map((e,t)=>(0,z.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),ee.map((e,t)=>{let i=n!==null&&n.year===e.year&&n.month===e.month&&n.day===e.day,a=r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__day`+(e.inMonth?``:` oc-dtp__day--out`)+(i?` oc-dtp__day--sel`:``)+(a&&!i?` oc-dtp__day--today`:``),onClick:()=>te(e.year,e.month,e.day),children:e.day},t)})]}),(0,z.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,z.jsxs)(k,{value:String(d),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),Number(e),f),children:[(0,z.jsx)(C,{size:`sm`,"aria-label":it(),children:(0,z.jsx)(j,{})}),(0,z.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,z.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,z.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,z.jsxs)(k,{value:String(f),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),d,Number(e)),children:[(0,z.jsx)(C,{size:`sm`,"aria-label":Re(),children:(0,z.jsx)(j,{})}),(0,z.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,z.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function V(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Zt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function Qt(e){let t=new Map;for(let n of e){let e=V(n.atMs),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}for(let e of t.values())e.sort((e,t)=>e.atMs-t.atMs);return t}function H(e,t,n){let r=new Map,i=new Date(t,n+1,0).getDate();for(let a=1;a<=i;a++){let i=e.get(Zt(t,n,a));i!==void 0&&i.length>0&&r.set(a,i.length)}return r}function $t(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function en(e,t){let n=(new Date(e,t,1).getDay()+6)%7,r=new Date(e,t,1-n),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()+42);return{startMs:r.getTime(),endMs:i.getTime()}}function tn(e){return{startMs:new Date(e,0,1).getTime(),endMs:new Date(e+1,0,1).getTime()}}var U=3;function nn({events:e,mode:t,cursor:n,onModeChange:r,onCursorChange:i,onEventClick:a,footnote:o}){let s=m(),c=(0,R.useMemo)(()=>Qt(e),[e]),l=(0,R.useMemo)(()=>$t(s),[s]),u=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`,year:`numeric`}),[s]),ee=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`}),[s]),d=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}),[s]),f=new Date,p=e=>{if(t===`year`){i({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);i({year:r.getFullYear(),month:r.getMonth()})},te=t===`year`?String(n.year):u.format(new Date(n.year,n.month,1));return(0,z.jsxs)(`div`,{className:`oc-cal`,children:[(0,z.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,z.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":b(),onClick:()=>p(-1),children:(0,z.jsx)(E,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":Xe(),onClick:()=>p(1),children:(0,z.jsx)(M,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>i({year:f.getFullYear(),month:f.getMonth()}),children:_()})]}),(0,z.jsx)(`span`,{className:`oc-cal__title`,children:te}),(0,z.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,z.jsx)(S,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:$e()}),(0,z.jsx)(S,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:Ue()})]})]}),t===`month`?(0,z.jsx)(rn,{cursor:n,byDay:c,weekdays:l,timeFmt:d,now:f,onEventClick:a}):(0,z.jsx)(an,{year:n.year,byDay:c,monthShortFmt:ee,now:f,onOpenMonth:e=>{i({year:n.year,month:e}),r(`month`)}}),o?(0,z.jsx)(`p`,{className:`oc-cal__footnote`,children:o}):null]})}function rn({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=L(e.year,e.month);return(0,z.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,z.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Zt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,z.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,z.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,U).map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`oc-cal__event`+(e.muted?` oc-cal__event--muted`:``)+(e.exact?` oc-cal__event--exact`:``),style:e.color?{"--cal-ev":e.color}:void 0,title:`${r.format(e.atMs)} ${e.title}`,onClick:a?()=>a(e):void 0,children:[(0,z.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,z.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>U?(0,z.jsx)(`span`,{className:`oc-cal__more`,children:Ve({count:o.length-U})}):null]},n)})]})}function an({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,z.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=H(t,e,o),c=L(e,o);return(0,z.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,z.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,z.jsx)(`span`,{className:`oc-cal__minigrid`,"aria-hidden":!0,children:c.map((e,t)=>{let n=e.inMonth?s.get(e.day)??0:0,i=e.inMonth&&r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,z.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var W={h:36e5,min:6e4,s:1e3,ms:1};function on(e){if(e===null)return null;let t=e.trim(),n=/^every\s+(\d+(?:\.\d+)?)(h|min|s|ms)$/.exec(t);if(n!==null){let e=Number(n[1])*W[n[2]];return Number.isFinite(e)&&e>0?{kind:`every`,everyMs:e}:null}let r=/^(?:cron\s+)?([\d*,/-]+(?:\s+[\d*,/-]+){4})(?:\s*\(([^)]+)\))?$/.exec(t);if(r!==null)return{kind:`cron`,expr:r[1],tz:r[2]??null};let i=Date.parse(t);return Number.isFinite(i)?{kind:`at`,atMs:i}:null}function G(e,t,n){let r=new Set;for(let i of e.split(`,`)){let e=i,a=1,o=/^(.+)\/(\d{1,3})$/.exec(i);if(o!==null&&(e=o[1],a=Number(o[2]),a<1))return null;let s,c;if(e===`*`)s=t,c=n;else{let r=/^(\d{1,3})(?:-(\d{1,3}))?$/.exec(e);if(r===null||(s=Number(r[1]),c=r[2]===void 0?s:Number(r[2]),r[2]===void 0&&o!==null&&(c=n),s<t||c>n||s>c))return null}for(let e=s;e<=c;e+=a)r.add(e)}return r.size>0?[...r].sort((e,t)=>e-t):null}function K(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=G(t[0],0,59),r=G(t[1],0,23),i=G(t[2],1,31),a=G(t[3],1,12),o=G(t[4],0,7);if(!n||!r||!i||!a||!o)return null;let s=new Set(o.map(e=>e%7));return{minutes:n,hours:r,dom:new Set(i),months:new Set(a),dow:s,domRestricted:t[2]!==`*`,dowRestricted:t[4]!==`*`}}var q=new Map;function J(e){let t=q.get(e);if(t!==void 0)return t;let n=null;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}catch{n=null}return q.set(e,n),n}function sn(e,t){if(t!==null){let n=J(t);if(n!==null){let t={};for(let r of n.formatToParts(e))r.type!==`literal`&&(t[r.type]=Number(r.value));return{y:t.year,mo:t.month-1,d:t.day,h:t.hour===24?0:t.hour,mi:t.minute}}}let n=new Date(e);return{y:n.getFullYear(),mo:n.getMonth(),d:n.getDate(),h:n.getHours(),mi:n.getMinutes()}}function Y(e,t,n,r,i,a){if(a===null||J(a)===null)return new Date(e,t,n,r,i).getTime();let o=Date.UTC(e,t,n,r,i),s=e=>{let t=sn(e,a);return Date.UTC(t.y,t.mo,t.d,t.h,t.mi)-e},c=s(o),l=o-c,u=s(l);return u!==c&&(l=o-u),l}function X(e,t,n,r){let i=new Map,a=(e,t)=>{e<n||e>=r||i.set(e,t||(i.get(e)??!1))};if(e?.kind===`at`)a(e.atMs,!0);else if(e?.kind===`every`){if(t!==null){let i=e.everyMs,o=Math.ceil((n-t)/i);for(let e=t+o*i,n=0;e<r&&n<400;e+=i,n++)a(e,e===t)}}else if(e?.kind===`cron`){let t=K(e.expr);if(t!==null&&t.hours.length*t.minutes.length<=400){let i=0,o=n-864e5;for(;o<r+864e5&&i<400;){let s=sn(o,e.tz);if(t.months.has(s.mo+1)){let o=new Date(Date.UTC(s.y,s.mo,s.d)).getUTCDay(),c=t.dom.has(s.d),l=t.dow.has(o);if(t.domRestricted&&t.dowRestricted?c||l:c&&l)for(let o of t.hours)for(let c of t.minutes){if(i>=400)break;let t=Y(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=Y(s.y,s.mo,s.d,12,0,e.tz)+864e5}}}return t!==null&&a(t,!0),[...i.entries()].map(([e,t])=>({atMs:e,exact:t})).sort((e,t)=>e.atMs-t.atMs).slice(0,400)}var Z=`crons`;function cn(e,t){return`${e}\u0000${t}`}function ln(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=cn(a.instanceName,e.id);i.set(o,a);let s=X(e.enabled===!1?null:on(e.schedule),e.nextRunAtMs,t,n);for(let t of s)r.push({id:`${o}:${t.atMs}`,sourceId:Z,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:e.enabled===!1,exact:t.exact})}return{events:r,byItemId:i}}var Q={minutes:6e4,hours:36e5,days:864e5};function $(e){return e?.data?.code??`unknown`}function un({status:e}){switch(I(e)){case`ok`:return(0,z.jsx)(T,{variant:`secondary`,children:f()});case`error`:return(0,z.jsx)(T,{variant:`destructive`,children:pe()});case`running`:return(0,z.jsx)(T,{variant:`outline`,children:de()});case`other`:return(0,z.jsx)(T,{variant:`outline`,children:e});case`none`:return(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function dn(){let e=v(y.scheduled.listMyCrons),t=v(y.scheduled.getCronDetail),n=v(y.scheduled.listCronRuns),c=v(y.scheduled.updateCron),we=v(y.scheduled.removeCron),Re=v(y.scheduled.runCronNow),g=dt(),Ve=ze(y.me.getMe,{host:Dt})?.timezone,[_,Ue]=(0,R.useState)(null),[Xe,$e]=(0,R.useState)(!1),[b,it]=(0,R.useState)(!1),[x,st]=(0,R.useState)(null),[w,E]=(0,R.useState)(null),[O,M]=(0,R.useState)(null),[N,I]=(0,R.useState)(null),[Vt,Ut]=(0,R.useState)(!1),[L,B]=(0,R.useState)(Wt),[V,Zt]=(0,R.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),Qt=e=>{localStorage.setItem(`oc.sched.view`,e),Zt(e)},[H,$t]=(0,R.useState)(`month`),[U,rn]=(0,R.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),an=(0,R.useMemo)(()=>{let e=[];for(let t of _??[]){if(!t.supported||t.error!==null)continue;let n=t.kind===`openclaw`&&t.manageSupported;for(let r of t.jobs)Ht(r,L)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[_,L]),W=(0,R.useMemo)(()=>H===`year`?tn(U.year):en(U.year,U.month),[H,U]),on=(0,R.useMemo)(()=>ln(an,W.startMs,W.endMs),[an,W]),G=e=>{let t=on.byItemId.get(e.itemId);t===void 0||!t.canEdit||t.job.id===null||dn(t.instanceName,t.job)},K=(0,R.useCallback)(async()=>{$e(!0),it(!1);try{Ue(await e({}))}catch{it(!0)}finally{$e(!1)}},[e]);(0,R.useEffect)(()=>{K()},[K]);let q=(0,R.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),J=(0,R.useRef)(null);(0,R.useEffect)(()=>{_!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[_]);let sn=(0,R.useMemo)(()=>new Intl.DateTimeFormat(m(),{dateStyle:`medium`,timeStyle:`short`}),[]),Y=async(e,t,n)=>{st(e);try{await t(),g.success(n),await K()}catch(e){g.toast({variant:`error`,title:h({code:$(e)})})}finally{st(null)}},X=(0,R.useRef)(0),Z=(0,R.useRef)(0),cn=async(e,t)=>{if(t.id===null)return;let r=++X.current;M({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==X.current)return;M({name:t.name??t.id,entries:i})}catch(e){if(r!==X.current)return;M(null),g.toast({variant:`error`,title:h({code:$(e)})})}},dn=async(e,n)=>{if(n.id===null)return;let r=++Z.current;I({instanceName:e,jobId:n.id,loading:!0,name:n.name??``,scheduleKind:`cron`,cronExpr:``,tz:``,everyValue:`1`,everyUnit:`hours`,at:``,message:``,hasMessage:!1,scheduleDirty:!1,messageDirty:!1,nameDirty:!1});try{let i=(await t({instanceName:e,jobId:n.id})).job,a=i.scheduleKind===`every`||i.scheduleKind===`at`?i.scheduleKind:`cron`,o=``;if(a===`at`&&i.scheduleExpr!==null){let e=Date.parse(i.scheduleExpr);Number.isFinite(e)&&(o=new Date(e-new Date(e).getTimezoneOffset()*6e4).toISOString().slice(0,16))}let s=`1`,c=`hours`;if(a===`every`&&i.scheduleExpr!==null){let e=Number(i.scheduleExpr);Number.isFinite(e)&&e>0&&(e%Q.days===0?(s=String(e/Q.days),c=`days`):e%Q.hours===0?(s=String(e/Q.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/Q.minutes))),c=`minutes`))}if(r!==Z.current)return;I(e=>e===null||e.jobId!==n.id?e:{...e,loading:!1,name:i.name??e.name,scheduleKind:a,cronExpr:a===`cron`?i.scheduleExpr??``:``,tz:i.tz??``,everyValue:s,everyUnit:c,at:o,message:i.message??``,hasMessage:i.message!==null&&!i.messageTruncated})}catch(e){if(r!==Z.current)return;I(null),g.toast({variant:`error`,title:h({code:$(e)})})}},fn=async()=>{if(N===null)return;let e={};if(N.nameDirty&&N.name.trim()===``||N.messageDirty&&N.hasMessage&&N.message.trim()===``){g.toast({variant:`error`,title:ve()});return}if(N.nameDirty&&N.name.trim()!==``&&(e.name=N.name.trim()),N.scheduleDirty){if(N.scheduleKind===`cron`&&N.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:N.cronExpr.trim(),...N.tz.trim()===``?{}:{tz:N.tz.trim()}};else if(N.scheduleKind===`every`){let t=Number(N.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*Q[N.everyUnit])})}else if(N.scheduleKind===`at`&&N.at!==``){let t=Date.parse(N.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(N.scheduleDirty&&e.schedule===void 0){g.toast({variant:`error`,title:d()});return}if(N.messageDirty&&N.hasMessage&&N.message.trim()!==``&&(e.message=N.message.trim()),Object.keys(e).length===0){I(null);return}let t=Z.current;Ut(!0);try{await c({instanceName:N.instanceName,jobId:N.jobId,patch:e}),g.success(oe()),t===Z.current&&I(null),await K()}catch(e){g.toast({variant:`error`,title:h({code:$(e)})})}finally{Ut(!1)}},pn=_?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,z.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:be()}),(0,z.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":We(),children:[(0,z.jsx)(S,{variant:V===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ge(),title:Ge(),"aria-pressed":V===`list`,onClick:()=>Qt(`list`),children:(0,z.jsx)(lt,{})}),(0,z.jsx)(S,{variant:V===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ze(),title:Ze(),"aria-pressed":V===`calendar`,onClick:()=>Qt(`calendar`),children:(0,z.jsx)(Jt,{})})]}),(0,z.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>void K(),disabled:Xe,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,z.jsx)(vt,{size:14,"aria-hidden":!0}),me()]})]}),_!==null&&pn>0?(0,z.jsxs)(Bt,{q:L.q,onQChange:e=>B(t=>({...t,q:e})),searchPlaceholder:i(),onReset:()=>B(Wt),canReset:Kt(L),children:[(0,z.jsxs)(k,{value:L.state,onValueChange:e=>B(t=>({...t,state:e})),children:[(0,z.jsx)(C,{size:`sm`,className:`w-40`,children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(D,{value:`all`,children:Je()}),(0,z.jsx)(D,{value:`active`,children:Be()}),(0,z.jsx)(D,{value:`paused`,children:ot()})]})]}),(0,z.jsxs)(k,{value:L.result,onValueChange:e=>B(t=>({...t,result:e})),children:[(0,z.jsx)(C,{size:`sm`,className:`w-40`,children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(D,{value:`all`,children:ge()}),(0,z.jsx)(D,{value:`ok`,children:f()}),(0,z.jsx)(D,{value:`error`,children:pe()}),(0,z.jsx)(D,{value:`running`,children:de()}),(0,z.jsx)(D,{value:`none`,children:Ke()})]})]})]}):null,_===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":Xe,children:b?fe():Pe()}):V===`calendar`?(0,z.jsxs)(z.Fragment,{children:[b?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:fe()}):null,_.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:qe()}):(0,z.jsx)(nn,{events:on.events,mode:H,cursor:U,onModeChange:$t,onCursorChange:rn,onEventClick:G,footnote:nt()})]}):(0,z.jsxs)(z.Fragment,{children:[b?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:fe()}):null,_.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:qe()}):null,_.map(e=>{let t=e.jobs.filter(e=>Ht(e,L)),n=Kt(L)&&e.jobs.length>0&&t.length===0;return(0,z.jsxs)(`section`,{style:{marginBottom:20},children:[_.length>1||e.error||!e.supported?(0,z.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,z.jsx)(T,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Ye({code:e.error})}):e.jobs.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:_e()}):n?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:l()}):(0,z.jsxs)(zt,{children:[(0,z.jsx)(It,{children:(0,z.jsxs)(Rt,{children:[(0,z.jsx)(P,{children:u()}),(0,z.jsx)(P,{children:ee()}),(0,z.jsx)(P,{children:Ee()}),(0,z.jsx)(P,{children:at()}),(0,z.jsx)(P,{children:s()}),(0,z.jsx)(P,{children:ae()}),(0,z.jsx)(P,{children:Ie()})]})}),(0,z.jsx)(Lt,{children:t.map((t,n)=>{let i=`${e.instanceName}:${t.id??n}`,a=x===i,o=e.manageSupported,s=e.kind===`openclaw`&&o;return(0,z.jsxs)(Rt,{ref:t.id!==null&&t.id===q?J:void 0,"data-state":t.id!==null&&t.id===q?`selected`:void 0,children:[(0,z.jsx)(F,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??Te()}),(0,z.jsx)(F,{children:(0,z.jsx)(T,{variant:`secondary`,children:t.agentId})}),(0,z.jsxs)(F,{className:`whitespace-nowrap`,children:[(0,z.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=yt(t.schedule),n=e===null?null:mt(e);return n===null?null:(0,z.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,z.jsx)(F,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:sn.format(t.nextRunAtMs)}),(0,z.jsx)(F,{children:Gt(t.enabled)===`active`?(0,z.jsx)(T,{variant:`secondary`,children:Be()}):Gt(t.enabled)===`paused`?(0,z.jsx)(T,{variant:`outline`,children:ot()}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,z.jsxs)(F,{children:[(0,z.jsx)(un,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,z.jsx)(T,{variant:`destructive`,title:t.lastDeliveryError??Qe(),children:ye()}):null]}),(0,z.jsx)(F,{className:`whitespace-nowrap`,children:t.id===null?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,z.jsx)(gt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,z.jsxs)(`span`,{className:`oc-cronactions`,children:[s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:He(),"aria-label":He(),disabled:x!==null,onClick:()=>void Y(i,async()=>{let n=await Re({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},se()),children:(0,z.jsx)(kt,{size:14,"aria-hidden":!0})}):null,s&&t.enabled!==null?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:t.enabled?r():xe(),"aria-label":t.enabled?r():xe(),disabled:x!==null,onClick:()=>void Y(i,()=>c({instanceName:e.instanceName,jobId:t.id,patch:{enabled:!t.enabled}}),t.enabled?tt():le()),children:t.enabled?(0,z.jsx)(Ct,{size:14,"aria-hidden":!0}):(0,z.jsx)(jt,{size:14,"aria-hidden":!0})}):null,s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Ne(),"aria-label":Ne(),disabled:x!==null,onClick:()=>void dn(e.instanceName,t),children:(0,z.jsx)(Et,{size:14,"aria-hidden":!0})}):null,s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Fe(),"aria-label":Fe(),disabled:x!==null,onClick:()=>void cn(e.instanceName,t),children:(0,z.jsx)(Yt,{size:14,"aria-hidden":!0})}):null,o?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Le(),"aria-label":Le(),disabled:x!==null,onClick:()=>E({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,z.jsx)(bt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:a()})]},e.instanceName)}),pn>0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:he()}):null]}),(0,z.jsx)(Mt,{open:w!==null,onOpenChange:e=>{e||E(null)},children:(0,z.jsxs)(Pt,{children:[(0,z.jsxs)(Nt,{children:[(0,z.jsx)(pt,{children:Me()}),(0,z.jsx)(ft,{children:Oe({name:w?.name??``})})]}),(0,z.jsxs)(ut,{children:[(0,z.jsx)(_t,{children:re()}),(0,z.jsx)(Ft,{onClick:()=>{let e=w;E(null),e!==null&&Y(`${e.instanceName}:${e.jobId}`,()=>we({instanceName:e.instanceName,jobId:e.jobId}),te())},children:Ae()})]})]})}),(0,z.jsx)(At,{open:O!==null,onOpenChange:e=>{e||(X.current++,M(null))},children:(0,z.jsxs)(wt,{style:{maxWidth:640},children:[(0,z.jsx)(ht,{children:(0,z.jsx)(Tt,{children:et({name:O?.name??``})})}),O?.entries===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):O!==null&&O.entries.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:ce()}):O===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:O.entries.map((e,t)=>(0,z.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,z.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,z.jsx)(un,{status:e.status}),(0,z.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?sn.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,z.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,z.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[Ce({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,z.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,z.jsx)(At,{open:N!==null,onOpenChange:e=>{e||(Z.current++,I(null))},children:(0,z.jsxs)(wt,{className:`oc-cronedit`,children:[(0,z.jsxs)(ht,{children:[(0,z.jsx)(Tt,{children:p()}),(0,z.jsx)(Ot,{children:je()})]}),N===null?null:N.loading?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:u()}),(0,z.jsx)(St,{value:N.name,maxLength:200,onChange:e=>I({...N,name:e.target.value,nameDirty:!0})})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:De()}),(0,z.jsxs)(k,{value:N.scheduleKind,onValueChange:e=>I({...N,scheduleKind:e,scheduleDirty:!0}),children:[(0,z.jsx)(C,{children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(D,{value:`cron`,children:ne()}),(0,z.jsx)(D,{value:`every`,children:ke()}),(0,z.jsx)(D,{value:`at`,children:o()})]})]}),N.scheduleKind===`cron`?(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(St,{value:N.cronExpr,onChange:e=>I({...N,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,z.jsx)(qt,{value:N.tz,onChange:e=>I({...N,tz:e,scheduleDirty:!0}),fallbackTz:Ve??void 0})]}):N.scheduleKind===`every`?(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(St,{type:`number`,min:1,value:N.everyValue,onChange:e=>I({...N,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,z.jsxs)(k,{value:N.everyUnit,onValueChange:e=>I({...N,everyUnit:e,scheduleDirty:!0}),children:[(0,z.jsx)(C,{style:{maxWidth:160},children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(D,{value:`minutes`,children:ct()}),(0,z.jsx)(D,{value:`hours`,children:Se()}),(0,z.jsx)(D,{value:`days`,children:ue()})]})]})]}):(0,z.jsx)(Xt,{value:N.at,onChange:e=>I({...N,at:e,scheduleDirty:!0})})]}),N.hasMessage?(0,z.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:rt()}),(0,z.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:N.message,onChange:e=>I({...N,message:e.target.value,messageDirty:!0})})]}):null]}),(0,z.jsxs)(xt,{children:[(0,z.jsx)(S,{variant:`ghost`,onClick:()=>I(null),children:re()}),(0,z.jsxs)(S,{onClick:()=>void fn(),disabled:N===null||N.loading||Vt,children:[Vt?(0,z.jsx)(gt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,ie()]})]})]})})]})}export{dn as ScheduledTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$I as r,AI as i,AL as a,BF as o,CL as s,D as c,DI as l,DL as u,EL as ee,FF as d,FI as f,GF as p,GI as te,HF as ne,HI as re,IF as ie,II as ae,JF as oe,JI as se,KF as ce,KI as le,LF as ue,MI as de,ML as fe,NI as pe,NL as me,OF as he,OI as ge,OL as _e,PF as ve,PI as ye,PL as be,QI as xe,QR as m,RF as Se,RI as Ce,SI as we,SL as Te,TL as Ee,UF as De,UI as Oe,VF as ke,VI as Ae,WF as je,WI as Me,XF as Ne,XR as Pe,YF as Fe,YI as h,ZF as Ie,ZI as Le,_I as Re,az as ze,bI as g,bL as Be,cI as Ve,dI as _,eL as He,fI as Ue,gI as We,hI as Ge,jI as Ke,jL as qe,kI as Je,kL as Ye,lI as Xe,mI as Ze,nL as Qe,nz as v,pI as $e,qF as et,qI as tt,sI as nt,t as y,tL as rt,uI as b,vI as it,wL as at,xI as x,xL as ot,yI as st,zF as ct}from"./api-BDOBe_HI.js";import{t as lt}from"./list-CTIbo6ut.js";import{t as S}from"./button-BXoUycz-.js";import{$ as C,Bt as w,Ct as ut,Dt as dt,Et as T,Mn as E,Q as D,Rt as O,St as ft,Tt as pt,X as k,Z as A,_t as mt,at as ht,bn as gt,bt as _t,cn as vt,et as j,gt as yt,in as bt,it as xt,jn as M,jt as St,mn as Ct,nt as wt,ot as Tt,pn as Et,q as Dt,rt as Ot,tn as kt,tt as At,un as jt,vt as Mt,wt as Nt,xt as Pt,yt as Ft,zt as N}from"./index-B0ufU8aN.js";import{a as It,i as P,n as Lt,o as Rt,r as F,t as zt}from"./table-Ql8c7BIW.js";import{t as Bt}from"./FilterBar-DqZs9qry.js";/* empty css */import{a as I,c as Vt,i as Ht,l as Ut,n as Wt,o as Gt,r as Kt,s as L,t as qt}from"./TimezoneCombobox-CSGhMAXx.js";var Jt=c(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),Yt=c(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),R=t(e(),1),z=n();function B(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function Xt({value:e,onChange:t}){let n=Vt(e),r=(0,R.useMemo)(()=>new Date,[]),[i,a]=(0,R.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[o,s]=(0,R.useState)(!1),c=(0,R.useMemo)(()=>B(m()),[]),l=(0,R.useMemo)(()=>new Intl.DateTimeFormat(m(),{month:`long`,year:`numeric`}),[]),u=(0,R.useMemo)(()=>new Intl.DateTimeFormat(m(),{dateStyle:`medium`,timeStyle:`short`}),[]),ee=L(i.year,i.month),d=n?.hour??9,f=n?.minute??0,p=(e,n,r,i,a)=>t(Ut(e,n,r,i,a)),te=(e,t,n)=>{a({year:e,month:t}),p(e,t,n,d,f)},ne=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},re=n===null?x():u.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,z.jsxs)(O,{modal:!0,open:o,onOpenChange:s,children:[(0,z.jsx)(w,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":we(),children:[(0,z.jsx)(Jt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,z.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:re})]})}),(0,z.jsxs)(N,{align:`start`,className:`oc-dtp__pop`,children:[(0,z.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":g(),onClick:()=>ne(-1),children:(0,z.jsx)(E,{size:15,"aria-hidden":!0})}),(0,z.jsx)(`span`,{className:`oc-dtp__month`,children:l.format(new Date(i.year,i.month,1))}),(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":st(),onClick:()=>ne(1),children:(0,z.jsx)(M,{size:15,"aria-hidden":!0})})]}),(0,z.jsxs)(`div`,{className:`oc-dtp__grid`,children:[c.map((e,t)=>(0,z.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),ee.map((e,t)=>{let i=n!==null&&n.year===e.year&&n.month===e.month&&n.day===e.day,a=r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__day`+(e.inMonth?``:` oc-dtp__day--out`)+(i?` oc-dtp__day--sel`:``)+(a&&!i?` oc-dtp__day--today`:``),onClick:()=>te(e.year,e.month,e.day),children:e.day},t)})]}),(0,z.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,z.jsxs)(k,{value:String(d),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),Number(e),f),children:[(0,z.jsx)(C,{size:`sm`,"aria-label":it(),children:(0,z.jsx)(j,{})}),(0,z.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,z.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,z.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,z.jsxs)(k,{value:String(f),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),d,Number(e)),children:[(0,z.jsx)(C,{size:`sm`,"aria-label":Re(),children:(0,z.jsx)(j,{})}),(0,z.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,z.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function V(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Zt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function Qt(e){let t=new Map;for(let n of e){let e=V(n.atMs),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}for(let e of t.values())e.sort((e,t)=>e.atMs-t.atMs);return t}function H(e,t,n){let r=new Map,i=new Date(t,n+1,0).getDate();for(let a=1;a<=i;a++){let i=e.get(Zt(t,n,a));i!==void 0&&i.length>0&&r.set(a,i.length)}return r}function $t(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function en(e,t){let n=(new Date(e,t,1).getDay()+6)%7,r=new Date(e,t,1-n),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()+42);return{startMs:r.getTime(),endMs:i.getTime()}}function tn(e){return{startMs:new Date(e,0,1).getTime(),endMs:new Date(e+1,0,1).getTime()}}var U=3;function nn({events:e,mode:t,cursor:n,onModeChange:r,onCursorChange:i,onEventClick:a,footnote:o}){let s=m(),c=(0,R.useMemo)(()=>Qt(e),[e]),l=(0,R.useMemo)(()=>$t(s),[s]),u=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`,year:`numeric`}),[s]),ee=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`}),[s]),d=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}),[s]),f=new Date,p=e=>{if(t===`year`){i({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);i({year:r.getFullYear(),month:r.getMonth()})},te=t===`year`?String(n.year):u.format(new Date(n.year,n.month,1));return(0,z.jsxs)(`div`,{className:`oc-cal`,children:[(0,z.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,z.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":b(),onClick:()=>p(-1),children:(0,z.jsx)(E,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":Xe(),onClick:()=>p(1),children:(0,z.jsx)(M,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>i({year:f.getFullYear(),month:f.getMonth()}),children:_()})]}),(0,z.jsx)(`span`,{className:`oc-cal__title`,children:te}),(0,z.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,z.jsx)(S,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:$e()}),(0,z.jsx)(S,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:Ue()})]})]}),t===`month`?(0,z.jsx)(rn,{cursor:n,byDay:c,weekdays:l,timeFmt:d,now:f,onEventClick:a}):(0,z.jsx)(an,{year:n.year,byDay:c,monthShortFmt:ee,now:f,onOpenMonth:e=>{i({year:n.year,month:e}),r(`month`)}}),o?(0,z.jsx)(`p`,{className:`oc-cal__footnote`,children:o}):null]})}function rn({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=L(e.year,e.month);return(0,z.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,z.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Zt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,z.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,z.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,U).map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`oc-cal__event`+(e.muted?` oc-cal__event--muted`:``)+(e.exact?` oc-cal__event--exact`:``),style:e.color?{"--cal-ev":e.color}:void 0,title:`${r.format(e.atMs)} ${e.title}`,onClick:a?()=>a(e):void 0,children:[(0,z.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,z.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>U?(0,z.jsx)(`span`,{className:`oc-cal__more`,children:Ve({count:o.length-U})}):null]},n)})]})}function an({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,z.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=H(t,e,o),c=L(e,o);return(0,z.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,z.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,z.jsx)(`span`,{className:`oc-cal__minigrid`,"aria-hidden":!0,children:c.map((e,t)=>{let n=e.inMonth?s.get(e.day)??0:0,i=e.inMonth&&r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,z.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var W={h:36e5,min:6e4,s:1e3,ms:1};function on(e){if(e===null)return null;let t=e.trim(),n=/^every\s+(\d+(?:\.\d+)?)(h|min|s|ms)$/.exec(t);if(n!==null){let e=Number(n[1])*W[n[2]];return Number.isFinite(e)&&e>0?{kind:`every`,everyMs:e}:null}let r=/^(?:cron\s+)?([\d*,/-]+(?:\s+[\d*,/-]+){4})(?:\s*\(([^)]+)\))?$/.exec(t);if(r!==null)return{kind:`cron`,expr:r[1],tz:r[2]??null};let i=Date.parse(t);return Number.isFinite(i)?{kind:`at`,atMs:i}:null}function G(e,t,n){let r=new Set;for(let i of e.split(`,`)){let e=i,a=1,o=/^(.+)\/(\d{1,3})$/.exec(i);if(o!==null&&(e=o[1],a=Number(o[2]),a<1))return null;let s,c;if(e===`*`)s=t,c=n;else{let r=/^(\d{1,3})(?:-(\d{1,3}))?$/.exec(e);if(r===null||(s=Number(r[1]),c=r[2]===void 0?s:Number(r[2]),r[2]===void 0&&o!==null&&(c=n),s<t||c>n||s>c))return null}for(let e=s;e<=c;e+=a)r.add(e)}return r.size>0?[...r].sort((e,t)=>e-t):null}function K(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=G(t[0],0,59),r=G(t[1],0,23),i=G(t[2],1,31),a=G(t[3],1,12),o=G(t[4],0,7);if(!n||!r||!i||!a||!o)return null;let s=new Set(o.map(e=>e%7));return{minutes:n,hours:r,dom:new Set(i),months:new Set(a),dow:s,domRestricted:t[2]!==`*`,dowRestricted:t[4]!==`*`}}var q=new Map;function J(e){let t=q.get(e);if(t!==void 0)return t;let n=null;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}catch{n=null}return q.set(e,n),n}function sn(e,t){if(t!==null){let n=J(t);if(n!==null){let t={};for(let r of n.formatToParts(e))r.type!==`literal`&&(t[r.type]=Number(r.value));return{y:t.year,mo:t.month-1,d:t.day,h:t.hour===24?0:t.hour,mi:t.minute}}}let n=new Date(e);return{y:n.getFullYear(),mo:n.getMonth(),d:n.getDate(),h:n.getHours(),mi:n.getMinutes()}}function Y(e,t,n,r,i,a){if(a===null||J(a)===null)return new Date(e,t,n,r,i).getTime();let o=Date.UTC(e,t,n,r,i),s=e=>{let t=sn(e,a);return Date.UTC(t.y,t.mo,t.d,t.h,t.mi)-e},c=s(o),l=o-c,u=s(l);return u!==c&&(l=o-u),l}function X(e,t,n,r){let i=new Map,a=(e,t)=>{e<n||e>=r||i.set(e,t||(i.get(e)??!1))};if(e?.kind===`at`)a(e.atMs,!0);else if(e?.kind===`every`){if(t!==null){let i=e.everyMs,o=Math.ceil((n-t)/i);for(let e=t+o*i,n=0;e<r&&n<400;e+=i,n++)a(e,e===t)}}else if(e?.kind===`cron`){let t=K(e.expr);if(t!==null&&t.hours.length*t.minutes.length<=400){let i=0,o=n-864e5;for(;o<r+864e5&&i<400;){let s=sn(o,e.tz);if(t.months.has(s.mo+1)){let o=new Date(Date.UTC(s.y,s.mo,s.d)).getUTCDay(),c=t.dom.has(s.d),l=t.dow.has(o);if(t.domRestricted&&t.dowRestricted?c||l:c&&l)for(let o of t.hours)for(let c of t.minutes){if(i>=400)break;let t=Y(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=Y(s.y,s.mo,s.d,12,0,e.tz)+864e5}}}return t!==null&&a(t,!0),[...i.entries()].map(([e,t])=>({atMs:e,exact:t})).sort((e,t)=>e.atMs-t.atMs).slice(0,400)}var Z=`crons`;function cn(e,t){return`${e}\u0000${t}`}function ln(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=cn(a.instanceName,e.id);i.set(o,a);let s=X(e.enabled===!1?null:on(e.schedule),e.nextRunAtMs,t,n);for(let t of s)r.push({id:`${o}:${t.atMs}`,sourceId:Z,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:e.enabled===!1,exact:t.exact})}return{events:r,byItemId:i}}var Q={minutes:6e4,hours:36e5,days:864e5};function $(e){return e?.data?.code??`unknown`}function un({status:e}){switch(I(e)){case`ok`:return(0,z.jsx)(T,{variant:`secondary`,children:f()});case`error`:return(0,z.jsx)(T,{variant:`destructive`,children:pe()});case`running`:return(0,z.jsx)(T,{variant:`outline`,children:de()});case`other`:return(0,z.jsx)(T,{variant:`outline`,children:e});case`none`:return(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function dn(){let e=v(y.scheduled.listMyCrons),t=v(y.scheduled.getCronDetail),n=v(y.scheduled.listCronRuns),c=v(y.scheduled.updateCron),we=v(y.scheduled.removeCron),Re=v(y.scheduled.runCronNow),g=dt(),Ve=ze(y.me.getMe,{host:Dt})?.timezone,[_,Ue]=(0,R.useState)(null),[Xe,$e]=(0,R.useState)(!1),[b,it]=(0,R.useState)(!1),[x,st]=(0,R.useState)(null),[w,E]=(0,R.useState)(null),[O,M]=(0,R.useState)(null),[N,I]=(0,R.useState)(null),[Vt,Ut]=(0,R.useState)(!1),[L,B]=(0,R.useState)(Wt),[V,Zt]=(0,R.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),Qt=e=>{localStorage.setItem(`oc.sched.view`,e),Zt(e)},[H,$t]=(0,R.useState)(`month`),[U,rn]=(0,R.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),an=(0,R.useMemo)(()=>{let e=[];for(let t of _??[]){if(!t.supported||t.error!==null)continue;let n=t.kind===`openclaw`&&t.manageSupported;for(let r of t.jobs)Ht(r,L)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[_,L]),W=(0,R.useMemo)(()=>H===`year`?tn(U.year):en(U.year,U.month),[H,U]),on=(0,R.useMemo)(()=>ln(an,W.startMs,W.endMs),[an,W]),G=e=>{let t=on.byItemId.get(e.itemId);t===void 0||!t.canEdit||t.job.id===null||dn(t.instanceName,t.job)},K=(0,R.useCallback)(async()=>{$e(!0),it(!1);try{Ue(await e({}))}catch{it(!0)}finally{$e(!1)}},[e]);(0,R.useEffect)(()=>{K()},[K]);let q=(0,R.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),J=(0,R.useRef)(null);(0,R.useEffect)(()=>{_!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[_]);let sn=(0,R.useMemo)(()=>new Intl.DateTimeFormat(m(),{dateStyle:`medium`,timeStyle:`short`}),[]),Y=async(e,t,n)=>{st(e);try{await t(),g.success(n),await K()}catch(e){g.toast({variant:`error`,title:h({code:$(e)})})}finally{st(null)}},X=(0,R.useRef)(0),Z=(0,R.useRef)(0),cn=async(e,t)=>{if(t.id===null)return;let r=++X.current;M({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==X.current)return;M({name:t.name??t.id,entries:i})}catch(e){if(r!==X.current)return;M(null),g.toast({variant:`error`,title:h({code:$(e)})})}},dn=async(e,n)=>{if(n.id===null)return;let r=++Z.current;I({instanceName:e,jobId:n.id,loading:!0,name:n.name??``,scheduleKind:`cron`,cronExpr:``,tz:``,everyValue:`1`,everyUnit:`hours`,at:``,message:``,hasMessage:!1,scheduleDirty:!1,messageDirty:!1,nameDirty:!1});try{let i=(await t({instanceName:e,jobId:n.id})).job,a=i.scheduleKind===`every`||i.scheduleKind===`at`?i.scheduleKind:`cron`,o=``;if(a===`at`&&i.scheduleExpr!==null){let e=Date.parse(i.scheduleExpr);Number.isFinite(e)&&(o=new Date(e-new Date(e).getTimezoneOffset()*6e4).toISOString().slice(0,16))}let s=`1`,c=`hours`;if(a===`every`&&i.scheduleExpr!==null){let e=Number(i.scheduleExpr);Number.isFinite(e)&&e>0&&(e%Q.days===0?(s=String(e/Q.days),c=`days`):e%Q.hours===0?(s=String(e/Q.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/Q.minutes))),c=`minutes`))}if(r!==Z.current)return;I(e=>e===null||e.jobId!==n.id?e:{...e,loading:!1,name:i.name??e.name,scheduleKind:a,cronExpr:a===`cron`?i.scheduleExpr??``:``,tz:i.tz??``,everyValue:s,everyUnit:c,at:o,message:i.message??``,hasMessage:i.message!==null&&!i.messageTruncated})}catch(e){if(r!==Z.current)return;I(null),g.toast({variant:`error`,title:h({code:$(e)})})}},fn=async()=>{if(N===null)return;let e={};if(N.nameDirty&&N.name.trim()===``||N.messageDirty&&N.hasMessage&&N.message.trim()===``){g.toast({variant:`error`,title:ve()});return}if(N.nameDirty&&N.name.trim()!==``&&(e.name=N.name.trim()),N.scheduleDirty){if(N.scheduleKind===`cron`&&N.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:N.cronExpr.trim(),...N.tz.trim()===``?{}:{tz:N.tz.trim()}};else if(N.scheduleKind===`every`){let t=Number(N.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*Q[N.everyUnit])})}else if(N.scheduleKind===`at`&&N.at!==``){let t=Date.parse(N.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(N.scheduleDirty&&e.schedule===void 0){g.toast({variant:`error`,title:d()});return}if(N.messageDirty&&N.hasMessage&&N.message.trim()!==``&&(e.message=N.message.trim()),Object.keys(e).length===0){I(null);return}let t=Z.current;Ut(!0);try{await c({instanceName:N.instanceName,jobId:N.jobId,patch:e}),g.success(oe()),t===Z.current&&I(null),await K()}catch(e){g.toast({variant:`error`,title:h({code:$(e)})})}finally{Ut(!1)}},pn=_?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,z.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:be()}),(0,z.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":We(),children:[(0,z.jsx)(S,{variant:V===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ge(),title:Ge(),"aria-pressed":V===`list`,onClick:()=>Qt(`list`),children:(0,z.jsx)(lt,{})}),(0,z.jsx)(S,{variant:V===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ze(),title:Ze(),"aria-pressed":V===`calendar`,onClick:()=>Qt(`calendar`),children:(0,z.jsx)(Jt,{})})]}),(0,z.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>void K(),disabled:Xe,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,z.jsx)(vt,{size:14,"aria-hidden":!0}),me()]})]}),_!==null&&pn>0?(0,z.jsxs)(Bt,{q:L.q,onQChange:e=>B(t=>({...t,q:e})),searchPlaceholder:i(),onReset:()=>B(Wt),canReset:Kt(L),children:[(0,z.jsxs)(k,{value:L.state,onValueChange:e=>B(t=>({...t,state:e})),children:[(0,z.jsx)(C,{size:`sm`,className:`w-40`,children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(D,{value:`all`,children:Je()}),(0,z.jsx)(D,{value:`active`,children:Be()}),(0,z.jsx)(D,{value:`paused`,children:ot()})]})]}),(0,z.jsxs)(k,{value:L.result,onValueChange:e=>B(t=>({...t,result:e})),children:[(0,z.jsx)(C,{size:`sm`,className:`w-40`,children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(D,{value:`all`,children:ge()}),(0,z.jsx)(D,{value:`ok`,children:f()}),(0,z.jsx)(D,{value:`error`,children:pe()}),(0,z.jsx)(D,{value:`running`,children:de()}),(0,z.jsx)(D,{value:`none`,children:Ke()})]})]})]}):null,_===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":Xe,children:b?fe():Pe()}):V===`calendar`?(0,z.jsxs)(z.Fragment,{children:[b?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:fe()}):null,_.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:qe()}):(0,z.jsx)(nn,{events:on.events,mode:H,cursor:U,onModeChange:$t,onCursorChange:rn,onEventClick:G,footnote:nt()})]}):(0,z.jsxs)(z.Fragment,{children:[b?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:fe()}):null,_.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:qe()}):null,_.map(e=>{let t=e.jobs.filter(e=>Ht(e,L)),n=Kt(L)&&e.jobs.length>0&&t.length===0;return(0,z.jsxs)(`section`,{style:{marginBottom:20},children:[_.length>1||e.error||!e.supported?(0,z.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,z.jsx)(T,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Ye({code:e.error})}):e.jobs.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:_e()}):n?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:l()}):(0,z.jsxs)(zt,{children:[(0,z.jsx)(It,{children:(0,z.jsxs)(Rt,{children:[(0,z.jsx)(P,{children:u()}),(0,z.jsx)(P,{children:ee()}),(0,z.jsx)(P,{children:Ee()}),(0,z.jsx)(P,{children:at()}),(0,z.jsx)(P,{children:s()}),(0,z.jsx)(P,{children:ae()}),(0,z.jsx)(P,{children:Ie()})]})}),(0,z.jsx)(Lt,{children:t.map((t,n)=>{let i=`${e.instanceName}:${t.id??n}`,a=x===i,o=e.manageSupported,s=e.kind===`openclaw`&&o;return(0,z.jsxs)(Rt,{ref:t.id!==null&&t.id===q?J:void 0,"data-state":t.id!==null&&t.id===q?`selected`:void 0,children:[(0,z.jsx)(F,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??Te()}),(0,z.jsx)(F,{children:(0,z.jsx)(T,{variant:`secondary`,children:t.agentId})}),(0,z.jsxs)(F,{className:`whitespace-nowrap`,children:[(0,z.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=yt(t.schedule),n=e===null?null:mt(e);return n===null?null:(0,z.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,z.jsx)(F,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:sn.format(t.nextRunAtMs)}),(0,z.jsx)(F,{children:Gt(t.enabled)===`active`?(0,z.jsx)(T,{variant:`secondary`,children:Be()}):Gt(t.enabled)===`paused`?(0,z.jsx)(T,{variant:`outline`,children:ot()}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,z.jsxs)(F,{children:[(0,z.jsx)(un,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,z.jsx)(T,{variant:`destructive`,title:t.lastDeliveryError??Qe(),children:ye()}):null]}),(0,z.jsx)(F,{className:`whitespace-nowrap`,children:t.id===null?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,z.jsx)(gt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,z.jsxs)(`span`,{className:`oc-cronactions`,children:[s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:He(),"aria-label":He(),disabled:x!==null,onClick:()=>void Y(i,async()=>{let n=await Re({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},se()),children:(0,z.jsx)(kt,{size:14,"aria-hidden":!0})}):null,s&&t.enabled!==null?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:t.enabled?r():xe(),"aria-label":t.enabled?r():xe(),disabled:x!==null,onClick:()=>void Y(i,()=>c({instanceName:e.instanceName,jobId:t.id,patch:{enabled:!t.enabled}}),t.enabled?tt():le()),children:t.enabled?(0,z.jsx)(Ct,{size:14,"aria-hidden":!0}):(0,z.jsx)(jt,{size:14,"aria-hidden":!0})}):null,s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Ne(),"aria-label":Ne(),disabled:x!==null,onClick:()=>void dn(e.instanceName,t),children:(0,z.jsx)(Et,{size:14,"aria-hidden":!0})}):null,s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Fe(),"aria-label":Fe(),disabled:x!==null,onClick:()=>void cn(e.instanceName,t),children:(0,z.jsx)(Yt,{size:14,"aria-hidden":!0})}):null,o?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Le(),"aria-label":Le(),disabled:x!==null,onClick:()=>E({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,z.jsx)(bt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:a()})]},e.instanceName)}),pn>0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:he()}):null]}),(0,z.jsx)(Mt,{open:w!==null,onOpenChange:e=>{e||E(null)},children:(0,z.jsxs)(Pt,{children:[(0,z.jsxs)(Nt,{children:[(0,z.jsx)(pt,{children:Me()}),(0,z.jsx)(ft,{children:Oe({name:w?.name??``})})]}),(0,z.jsxs)(ut,{children:[(0,z.jsx)(_t,{children:re()}),(0,z.jsx)(Ft,{onClick:()=>{let e=w;E(null),e!==null&&Y(`${e.instanceName}:${e.jobId}`,()=>we({instanceName:e.instanceName,jobId:e.jobId}),te())},children:Ae()})]})]})}),(0,z.jsx)(At,{open:O!==null,onOpenChange:e=>{e||(X.current++,M(null))},children:(0,z.jsxs)(wt,{style:{maxWidth:640},children:[(0,z.jsx)(ht,{children:(0,z.jsx)(Tt,{children:et({name:O?.name??``})})}),O?.entries===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):O!==null&&O.entries.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:ce()}):O===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:O.entries.map((e,t)=>(0,z.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,z.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,z.jsx)(un,{status:e.status}),(0,z.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?sn.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,z.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,z.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[Ce({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,z.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,z.jsx)(At,{open:N!==null,onOpenChange:e=>{e||(Z.current++,I(null))},children:(0,z.jsxs)(wt,{className:`oc-cronedit`,children:[(0,z.jsxs)(ht,{children:[(0,z.jsx)(Tt,{children:p()}),(0,z.jsx)(Ot,{children:je()})]}),N===null?null:N.loading?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:u()}),(0,z.jsx)(St,{value:N.name,maxLength:200,onChange:e=>I({...N,name:e.target.value,nameDirty:!0})})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:De()}),(0,z.jsxs)(k,{value:N.scheduleKind,onValueChange:e=>I({...N,scheduleKind:e,scheduleDirty:!0}),children:[(0,z.jsx)(C,{children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(D,{value:`cron`,children:ne()}),(0,z.jsx)(D,{value:`every`,children:ke()}),(0,z.jsx)(D,{value:`at`,children:o()})]})]}),N.scheduleKind===`cron`?(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(St,{value:N.cronExpr,onChange:e=>I({...N,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,z.jsx)(qt,{value:N.tz,onChange:e=>I({...N,tz:e,scheduleDirty:!0}),fallbackTz:Ve??void 0})]}):N.scheduleKind===`every`?(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(St,{type:`number`,min:1,value:N.everyValue,onChange:e=>I({...N,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,z.jsxs)(k,{value:N.everyUnit,onValueChange:e=>I({...N,everyUnit:e,scheduleDirty:!0}),children:[(0,z.jsx)(C,{style:{maxWidth:160},children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(D,{value:`minutes`,children:ct()}),(0,z.jsx)(D,{value:`hours`,children:Se()}),(0,z.jsx)(D,{value:`days`,children:ue()})]})]})]}):(0,z.jsx)(Xt,{value:N.at,onChange:e=>I({...N,at:e,scheduleDirty:!0})})]}),N.hasMessage?(0,z.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:rt()}),(0,z.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:N.message,onChange:e=>I({...N,message:e.target.value,messageDirty:!0})})]}):null]}),(0,z.jsxs)(xt,{children:[(0,z.jsx)(S,{variant:`ghost`,onClick:()=>I(null),children:re()}),(0,z.jsxs)(S,{onClick:()=>void fn(),disabled:N===null||N.loading||Vt,children:[Vt?(0,z.jsx)(gt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,ie()]})]})]})})]})}export{dn as ScheduledTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,$j as i,AM as ee,BM as te,CM as ne,DM as re,EM as ie,FM as ae,GM as oe,HM as se,IM as ce,JM as le,KM as ue,LM as de,MM as fe,NM as pe,OM as me,PM as he,QM as ge,Qj as a,RM as _e,SM as ve,TM as ye,UM as be,VM as xe,WM as Se,XM as Ce,Xj as o,YM as we,Yj as Te,ZM as Ee,Zj as De,_M as Oe,aM as s,aN as ke,az as c,bM as Ae,cM as l,cN as je,dM as u,dN as Me,eM as d,eN as Ne,fM as f,fN as Pe,gM as p,hM as m,hN as Fe,iM as h,iN as Ie,iz as g,jM as Le,kM as Re,lM as _,lN as v,mM as y,mN as ze,nM as b,nN as Be,nz as Ve,oM as x,oN as He,pM as S,pN as Ue,qM as We,rM as C,rN as Ge,sM as w,sN as Ke,t as T,tM as E,tN as qe,uM as D,uN as O,vM as k,wM as Je,xM as Ye,yM as Xe,zM as Ze}from"./api-BDOBe_HI.js";import{t as A}from"./check-BbblETdU.js";import{r as Qe}from"./dist-Ct8KdJzy.js";import{t as j}from"./button-BXoUycz-.js";import{$ as M,Dt as $e,Et as N,Fn as et,On as P,Pn as tt,Q as F,U as nt,X as I,Z as L,_ as rt,at as R,ct as z,et as B,it as V,jn as it,jt as H,nt as U,ot as W,rt as at,st as G,tt as K}from"./index-DtAFZhtv.js";import{t as ot}from"./FilterBar-D99V_QOK.js";import{t as st}from"./DataTableShell-D2PIAVAw.js";import{t as ct}from"./roleDescriptions-BJHinaor.js";var q=t(e(),1),J=n(),lt=[{value:`never`,label:()=>E(),days:null},{value:`30`,label:()=>d(),days:30},{value:`90`,label:()=>i(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=et({from:`/settings/serviceAccounts`}),t=tt({from:`/settings/serviceAccounts`}),n=e.q??``,i=e.status??X,[a,o]=(0,q.useState)(X),Te=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),De=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),Oe=c(T.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===X?void 0:a,disabled:i===X?void 0:i===`disabled`}}),s=c(T.apiKeys.listKeys,{}),l=c(T.apiKeys.listRoles,{}),u=g(T.apiKeys.createServiceAccount),d=g(T.apiKeys.updateServiceAccount),f=g(T.apiKeys.deleteServiceAccount),p=Ve(T.apiKeys.mintApiKey),m=g(T.apiKeys.revokeApiKey),h=nt(),_=$e(),y=n!==``||a!==X||i!==X;function b(){o(X),t({search:{},replace:!0})}let[x,S]=(0,q.useState)(!1),[C,w]=(0,q.useState)(Z),[E,D]=(0,q.useState)(null),[k,A]=(0,q.useState)(new Set),[P,R]=(0,q.useState)(null),z=(0,q.useRef)(!1),[V,U]=(0,q.useState)(new Set),[W,at]=(0,q.useState)({}),[G,K]=(0,q.useState)(null),Y=(0,q.useMemo)(()=>{let e=new Map;for(let t of s??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[s]);function Q(e){A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ft(){try{E?(await d({serviceAccountId:E,name:C.name,roleKey:C.roleKey,description:C.description}),_.success(pe())):await u({name:C.name,roleKey:C.roleKey,description:C.description||void 0}),w(Z),D(null),S(!1)}catch(e){_.error(E?he():ae(),e)}}function pt(e){w({name:e.name,roleKey:e.roleKey,description:e.description??``}),D(e._id),S(!0)}async function mt(e){if(z.current)return;z.current=!0;let t=W[e._id]??`never`,n=lt.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;R(e._id);try{let t=await p({serviceAccountId:e._id,expiresAt:r});K({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){_.error(fe(),e)}finally{z.current=!1,R(null)}}async function $(e){if(await h({title:Le(),description:(0,J.jsxs)(J.Fragment,{children:[ee(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Re(),` `,(0,J.jsx)(`strong`,{children:me()}),` `,re()]}),confirmWord:e.name,confirmLabel:ie(),destructive:!0}))try{await f({serviceAccountId:e._id}),_.success(ye(),e.name)}catch(e){_.error(Je(),e)}}async function ht(e){if(await h({title:ne(),description:(0,J.jsxs)(J.Fragment,{children:[ve(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Ye()]}),confirmLabel:Ae(),destructive:!0})&&!V.has(e._id)){U(t=>new Set(t).add(e._id));try{await m({keyId:e._id})}catch(e){_.error(Xe(),e)}finally{U(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)(ot,{q:n,onQChange:Te,searchPlaceholder:ze(),onReset:b,canReset:y,children:[(0,J.jsxs)(I,{value:a,onValueChange:o,children:[(0,J.jsx)(M,{size:`sm`,className:`w-40`,children:(0,J.jsx)(B,{placeholder:Ue()})}),(0,J.jsxs)(L,{children:[(0,J.jsx)(F,{value:X,children:Pe()}),(l??[]).map(e=>(0,J.jsx)(F,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(I,{value:i,onValueChange:De,children:[(0,J.jsx)(M,{size:`sm`,className:`w-36`,children:(0,J.jsx)(B,{})}),(0,J.jsxs)(L,{children:[(0,J.jsx)(F,{value:X,children:Me()}),(0,J.jsx)(F,{value:`active`,children:O()}),(0,J.jsx)(F,{value:`disabled`,children:v()})]})]})]}),(0,J.jsx)(st,{title:je(),rows:Oe,addLabel:Ke(),onAdd:()=>{w(Z),D(null),S(!0)},emptyHint:He(),isExpanded:e=>k.has(e._id),renderExpanded:e=>(0,J.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:V}),rowActions:e=>[...(e.managedBy??null)===null?[{label:Be(),onSelect:()=>pt(e)},{label:ke(),onSelect:()=>void mt(e)}]:[],{label:k.has(e._id)?Ie():Ge(),onSelect:()=>Q(e._id)},...(e.managedBy??null)===null?[{label:qe(),variant:`destructive`,onSelect:()=>void $(e)}]:[]],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":k.has(e._id)?Ne():r(),onClick:()=>Q(e._id),children:k.has(e._id)?(0,J.jsx)(Qe,{}):(0,J.jsx)(it,{})})},{header:ge(),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:Ee(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(N,{variant:`secondary`,children:e.roleKey})},{header:Ce(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(N,{variant:`destructive`,children:v()}):(0,J.jsx)(N,{variant:`outline`,children:O()})},{header:we(),cell:e=>(0,J.jsxs)(I,{value:W[e._id]??`never`,onValueChange:t=>at(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(M,{size:`sm`,className:`w-32`,children:(0,J.jsx)(B,{})}),(0,J.jsx)(L,{children:lt.map(e=>(0,J.jsx)(F,{value:e.value,children:e.label()},e.value))})]})},{header:le(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:P===e._id?We():ue({count:t})})}}]}),(0,J.jsx)(rt,{open:x,onOpenChange:e=>{S(e),e||D(null)},title:E?oe():se(),description:E?Se():xe(),canSubmit:!!(C.name&&C.roleKey),onSubmit:ft,submitLabel:E?be():te(),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:Ze()}),(0,J.jsx)(H,{value:C.name,onChange:e=>w({...C,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:_e()}),(0,J.jsxs)(I,{value:C.roleKey||void 0,onValueChange:e=>w({...C,roleKey:e}),children:[(0,J.jsx)(M,{className:`w-full`,children:(0,J.jsx)(B,{placeholder:de()})}),(0,J.jsx)(L,{children:(l??[]).map(e=>(0,J.jsxs)(F,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(l??[]).find(e=>e.key===C.roleKey),t=e?ct(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:ce()}),(0,J.jsx)(H,{value:C.description,onChange:e=>w({...C,description:e.target.value})})]})]})}),(0,J.jsx)(dt,{minted:G,onClose:()=>K(null)})]})}function ut({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:[k(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Oe()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:p()}),(0,J.jsx)(`th`,{children:m()}),(0,J.jsx)(`th`,{children:y()}),(0,J.jsx)(`th`,{children:S()}),(0,J.jsx)(`th`,{children:f()}),(0,J.jsx)(`th`,{children:u()}),(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)(N,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:z(t.createdAt)}),(0,J.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:mt(t.expiresAt)}),(0,J.jsx)(`td`,{children:$(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:!t.disabled&&(e.managedBy??null)===null?(0,J.jsx)(j,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?D():_()}):null})]},t._id))})]})]})}function dt({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)(K,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(U,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(R,{children:[(0,J.jsx)(W,{children:l()}),(0,J.jsx)(at,{children:w({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:x()}),(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)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":s(),children:[n?(0,J.jsx)(A,{}):(0,J.jsx)(P,{}),n?h():C()]})]}),(0,J.jsx)(V,{children:(0,J.jsx)(j,{onClick:()=>{r(!1),t()},children:b()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?a():z(e)}function mt(e){return e===null?`—`:G(e)}function $(e){return e.disabled?(0,J.jsx)(N,{variant:`destructive`,children:De()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(N,{variant:`outline`,children:o()}):(0,J.jsx)(N,{variant:`outline`,children:Te()})}export{Q as ServiceAccountsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,$j as i,AM as ee,BM as te,CM as ne,DM as re,EM as ie,FM as ae,GM as oe,HM as se,IM as ce,JM as le,KM as ue,LM as de,MM as fe,NM as pe,OM as me,PM as he,QM as ge,Qj as a,RM as _e,SM as ve,TM as ye,UM as be,VM as xe,WM as Se,XM as Ce,Xj as o,YM as we,Yj as Te,ZM as Ee,Zj as De,_M as Oe,aM as s,aN as ke,az as c,bM as Ae,cM as l,cN as je,dM as u,dN as Me,eM as d,eN as Ne,fM as f,fN as Pe,gM as p,hM as m,hN as Fe,iM as h,iN as Ie,iz as g,jM as Le,kM as Re,lM as _,lN as v,mM as y,mN as ze,nM as b,nN as Be,nz as Ve,oM as x,oN as He,pM as S,pN as Ue,qM as We,rM as C,rN as Ge,sM as w,sN as Ke,t as T,tM as E,tN as qe,uM as D,uN as O,vM as k,wM as Je,xM as Ye,yM as Xe,zM as Ze}from"./api-BDOBe_HI.js";import{t as A}from"./check-BbblETdU.js";import{r as Qe}from"./dist-Ct8KdJzy.js";import{t as j}from"./button-BXoUycz-.js";import{$ as M,Dt as $e,Et as N,Fn as et,On as P,Pn as tt,Q as F,U as nt,X as I,Z as L,_ as rt,at as R,ct as z,et as B,it as V,jn as it,jt as H,nt as U,ot as W,rt as at,st as G,tt as K}from"./index-B0ufU8aN.js";import{t as ot}from"./FilterBar-DqZs9qry.js";import{t as st}from"./DataTableShell-CFPC-1m0.js";import{t as ct}from"./roleDescriptions-BJHinaor.js";var q=t(e(),1),J=n(),lt=[{value:`never`,label:()=>E(),days:null},{value:`30`,label:()=>d(),days:30},{value:`90`,label:()=>i(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=et({from:`/settings/serviceAccounts`}),t=tt({from:`/settings/serviceAccounts`}),n=e.q??``,i=e.status??X,[a,o]=(0,q.useState)(X),Te=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),De=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),Oe=c(T.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===X?void 0:a,disabled:i===X?void 0:i===`disabled`}}),s=c(T.apiKeys.listKeys,{}),l=c(T.apiKeys.listRoles,{}),u=g(T.apiKeys.createServiceAccount),d=g(T.apiKeys.updateServiceAccount),f=g(T.apiKeys.deleteServiceAccount),p=Ve(T.apiKeys.mintApiKey),m=g(T.apiKeys.revokeApiKey),h=nt(),_=$e(),y=n!==``||a!==X||i!==X;function b(){o(X),t({search:{},replace:!0})}let[x,S]=(0,q.useState)(!1),[C,w]=(0,q.useState)(Z),[E,D]=(0,q.useState)(null),[k,A]=(0,q.useState)(new Set),[P,R]=(0,q.useState)(null),z=(0,q.useRef)(!1),[V,U]=(0,q.useState)(new Set),[W,at]=(0,q.useState)({}),[G,K]=(0,q.useState)(null),Y=(0,q.useMemo)(()=>{let e=new Map;for(let t of s??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[s]);function Q(e){A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ft(){try{E?(await d({serviceAccountId:E,name:C.name,roleKey:C.roleKey,description:C.description}),_.success(pe())):await u({name:C.name,roleKey:C.roleKey,description:C.description||void 0}),w(Z),D(null),S(!1)}catch(e){_.error(E?he():ae(),e)}}function pt(e){w({name:e.name,roleKey:e.roleKey,description:e.description??``}),D(e._id),S(!0)}async function mt(e){if(z.current)return;z.current=!0;let t=W[e._id]??`never`,n=lt.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;R(e._id);try{let t=await p({serviceAccountId:e._id,expiresAt:r});K({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){_.error(fe(),e)}finally{z.current=!1,R(null)}}async function $(e){if(await h({title:Le(),description:(0,J.jsxs)(J.Fragment,{children:[ee(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Re(),` `,(0,J.jsx)(`strong`,{children:me()}),` `,re()]}),confirmWord:e.name,confirmLabel:ie(),destructive:!0}))try{await f({serviceAccountId:e._id}),_.success(ye(),e.name)}catch(e){_.error(Je(),e)}}async function ht(e){if(await h({title:ne(),description:(0,J.jsxs)(J.Fragment,{children:[ve(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Ye()]}),confirmLabel:Ae(),destructive:!0})&&!V.has(e._id)){U(t=>new Set(t).add(e._id));try{await m({keyId:e._id})}catch(e){_.error(Xe(),e)}finally{U(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)(ot,{q:n,onQChange:Te,searchPlaceholder:ze(),onReset:b,canReset:y,children:[(0,J.jsxs)(I,{value:a,onValueChange:o,children:[(0,J.jsx)(M,{size:`sm`,className:`w-40`,children:(0,J.jsx)(B,{placeholder:Ue()})}),(0,J.jsxs)(L,{children:[(0,J.jsx)(F,{value:X,children:Pe()}),(l??[]).map(e=>(0,J.jsx)(F,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(I,{value:i,onValueChange:De,children:[(0,J.jsx)(M,{size:`sm`,className:`w-36`,children:(0,J.jsx)(B,{})}),(0,J.jsxs)(L,{children:[(0,J.jsx)(F,{value:X,children:Me()}),(0,J.jsx)(F,{value:`active`,children:O()}),(0,J.jsx)(F,{value:`disabled`,children:v()})]})]})]}),(0,J.jsx)(st,{title:je(),rows:Oe,addLabel:Ke(),onAdd:()=>{w(Z),D(null),S(!0)},emptyHint:He(),isExpanded:e=>k.has(e._id),renderExpanded:e=>(0,J.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:V}),rowActions:e=>[...(e.managedBy??null)===null?[{label:Be(),onSelect:()=>pt(e)},{label:ke(),onSelect:()=>void mt(e)}]:[],{label:k.has(e._id)?Ie():Ge(),onSelect:()=>Q(e._id)},...(e.managedBy??null)===null?[{label:qe(),variant:`destructive`,onSelect:()=>void $(e)}]:[]],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":k.has(e._id)?Ne():r(),onClick:()=>Q(e._id),children:k.has(e._id)?(0,J.jsx)(Qe,{}):(0,J.jsx)(it,{})})},{header:ge(),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:Ee(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(N,{variant:`secondary`,children:e.roleKey})},{header:Ce(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(N,{variant:`destructive`,children:v()}):(0,J.jsx)(N,{variant:`outline`,children:O()})},{header:we(),cell:e=>(0,J.jsxs)(I,{value:W[e._id]??`never`,onValueChange:t=>at(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(M,{size:`sm`,className:`w-32`,children:(0,J.jsx)(B,{})}),(0,J.jsx)(L,{children:lt.map(e=>(0,J.jsx)(F,{value:e.value,children:e.label()},e.value))})]})},{header:le(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:P===e._id?We():ue({count:t})})}}]}),(0,J.jsx)(rt,{open:x,onOpenChange:e=>{S(e),e||D(null)},title:E?oe():se(),description:E?Se():xe(),canSubmit:!!(C.name&&C.roleKey),onSubmit:ft,submitLabel:E?be():te(),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:Ze()}),(0,J.jsx)(H,{value:C.name,onChange:e=>w({...C,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:_e()}),(0,J.jsxs)(I,{value:C.roleKey||void 0,onValueChange:e=>w({...C,roleKey:e}),children:[(0,J.jsx)(M,{className:`w-full`,children:(0,J.jsx)(B,{placeholder:de()})}),(0,J.jsx)(L,{children:(l??[]).map(e=>(0,J.jsxs)(F,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(l??[]).find(e=>e.key===C.roleKey),t=e?ct(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:ce()}),(0,J.jsx)(H,{value:C.description,onChange:e=>w({...C,description:e.target.value})})]})]})}),(0,J.jsx)(dt,{minted:G,onClose:()=>K(null)})]})}function ut({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:[k(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Oe()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:p()}),(0,J.jsx)(`th`,{children:m()}),(0,J.jsx)(`th`,{children:y()}),(0,J.jsx)(`th`,{children:S()}),(0,J.jsx)(`th`,{children:f()}),(0,J.jsx)(`th`,{children:u()}),(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)(N,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:z(t.createdAt)}),(0,J.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:mt(t.expiresAt)}),(0,J.jsx)(`td`,{children:$(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:!t.disabled&&(e.managedBy??null)===null?(0,J.jsx)(j,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?D():_()}):null})]},t._id))})]})]})}function dt({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)(K,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(U,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(R,{children:[(0,J.jsx)(W,{children:l()}),(0,J.jsx)(at,{children:w({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:x()}),(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)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":s(),children:[n?(0,J.jsx)(A,{}):(0,J.jsx)(P,{}),n?h():C()]})]}),(0,J.jsx)(V,{children:(0,J.jsx)(j,{onClick:()=>{r(!1),t()},children:b()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?a():z(e)}function mt(e){return e===null?`—`:G(e)}function $(e){return e.disabled?(0,J.jsx)(N,{variant:`destructive`,children:De()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(N,{variant:`outline`,children:o()}):(0,J.jsx)(N,{variant:`outline`,children:Te()})}export{Q as ServiceAccountsTab};