@lacneu/atrium 0.84.20 → 0.84.21
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.
- package/dist/assets/{AccessTab-CoFRPa-e.js → AccessTab-7DgwkLkg.js} +1 -1
- package/dist/assets/{AdvancedFilter-CZnbykZe.js → AdvancedFilter-D-mIQhPG.js} +1 -1
- package/dist/assets/{AgentFilesTab-Bcz9V6fH.js → AgentFilesTab-DI6SkJi3.js} +1 -1
- package/dist/assets/{AnomaliesTab-YUjA4XnE.js → AnomaliesTab-CcdmV3_N.js} +1 -1
- package/dist/assets/{AuditTab-Jes9HRNk.js → AuditTab-De1aUlfc.js} +1 -1
- package/dist/assets/{BridgeTab-CWbabhHl.js → BridgeTab-BvlinzLy.js} +1 -1
- package/dist/assets/{ChatDefaultsTab-DT3gBozQ.js → ChatDefaultsTab-LBCm6cXz.js} +1 -1
- package/dist/assets/{DataTableShell-CDmo0isC.js → DataTableShell-BK8Kucos.js} +1 -1
- package/dist/assets/{DetailChips-Csi8ao-5.js → DetailChips-DSrMAbLD.js} +1 -1
- package/dist/assets/{FeedbacksTab-9go4R--0.js → FeedbacksTab-Dn5lwj2V.js} +1 -1
- package/dist/assets/{FieldLabel-4AzJbj-7.js → FieldLabel-CgbnOAaa.js} +1 -1
- package/dist/assets/{FilesTab-CRGP9jbn.js → FilesTab-BR9OC5V_.js} +1 -1
- package/dist/assets/{FilterBar-CK5Wsnof.js → FilterBar-DHbB2cbQ.js} +1 -1
- package/dist/assets/{GroupsTab-HBoCEQWy.js → GroupsTab-CRUou4Sn.js} +1 -1
- package/dist/assets/{InstancesTab-CMEb9hT6.js → InstancesTab-DzK5DgDi.js} +1 -1
- package/dist/assets/{IntegrationsTab-hlpMleFu.js → IntegrationsTab-6rOgYMOt.js} +1 -1
- package/dist/assets/{KpiTab-Dqb9g4zO.js → KpiTab-BMKdEuEd.js} +1 -1
- package/dist/assets/{PreferencesTab-Bdlwezal.js → PreferencesTab-BNBLxTGr.js} +1 -1
- package/dist/assets/{ProjectPage-DWMUaSn7.js → ProjectPage-Dr7E7Gdc.js} +1 -1
- package/dist/assets/{PromptInjectionsTab-DAajt_Z1.js → PromptInjectionsTab-B-hui4r1.js} +1 -1
- package/dist/assets/{RolesTab-DHifxhw3.js → RolesTab-DYYmUvDN.js} +1 -1
- package/dist/assets/{ScheduledTab-CeVs9uJe.js → ScheduledTab-B6mlE1sC.js} +1 -1
- package/dist/assets/{ServiceAccountsTab-Bl7nm8Ph.js → ServiceAccountsTab-DcDezuba.js} +1 -1
- package/dist/assets/{SubAgentReportsTab-O1q9pZe2.js → SubAgentReportsTab-D6R_3oe8.js} +1 -1
- package/dist/assets/{ThemeShowroom-BSjPrQxB.js → ThemeShowroom-BUXpwJRo.js} +1 -1
- package/dist/assets/{TimeRangePicker-DOkbYJPt.js → TimeRangePicker-B8MRcEsu.js} +1 -1
- package/dist/assets/{TimezoneCombobox-DeJ3e50i.js → TimezoneCombobox-BYDYUkxC.js} +1 -1
- package/dist/assets/{TracesTab-M7MbrfPE.js → TracesTab-CGGE2Afj.js} +1 -1
- package/dist/assets/{UsersTab-DW6GasiH.js → UsersTab-LjXyy7nc.js} +1 -1
- package/dist/assets/{VoiceTab-CLMSu_Kx.js → VoiceTab-BGkLEvDq.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-CYEBDkYv.js → highlighted-body-OFNGDK62-qznyJ1AG.js} +1 -1
- package/dist/assets/{index-DMM3fags.js → index-Bkfx3eIe.js} +6 -6
- package/dist/assets/mermaid-GHXKKRXX-D1_QmKBf.js +1 -0
- package/dist/assets/{pdf-CNbyQJnG.js → pdf-RQlFQI9k.js} +1 -1
- package/dist/assets/{tabs-vdU2pkw5.js → tabs-BBnOOIhM.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/mermaid-GHXKKRXX-DDdByclK.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$ as r,$D as i,$E as a,$i as o,AD as s,AE as c,Ac as l,BD as u,BE as d,CD as f,CE as p,DD as m,DE as h,ED as g,EE as _,FD as v,FE as y,G as b,GD as ee,GE as x,H as S,HD as te,HE as C,ID as ne,IE as w,J as re,JD as ie,JE as T,K as ae,KD as oe,KE as E,LD as se,LE as ce,MD as le,ME as ue,ND as de,NE as fe,OD as pe,OE as me,Oc as he,PD as ge,PE as _e,Q as ve,QD as ye,QE as be,RD as xe,SD as Se,SE as Ce,TD as we,TE as Te,U as Ee,UD as De,UE as Oe,VD as ke,VE as Ae,W as je,WD as Me,WE as Ne,X as Pe,XD as Fe,XE as Ie,Y as Le,YD as Re,YE as ze,Z as Be,ZD as Ve,ZE as He,_D as Ue,_E as We,aD as Ge,aP as Ke,aV as D,bD as O,bE as qe,cD as Je,cV as k,dD as Ye,eD as Xe,eO as Ze,ea as Qe,et as $e,fD as et,gD as tt,gE as A,hD as nt,hE as rt,iD as it,iO as at,iP as j,it as ot,jD as st,jE as ct,jc as lt,kD as ut,kE as dt,kc as ft,lD as pt,mD as M,nD as mt,nO as ht,nS as gt,nt as _t,oD as vt,pD as yt,q as bt,qD as xt,qE as St,rD as Ct,rO as wt,rt as Tt,sD as Et,sV as N,t as P,tD as Dt,tO as Ot,tS as kt,ta as At,tt as jt,uD as Mt,vD as Nt,vE as Pt,wD as Ft,wE as It,xD as Lt,xE as Rt,yD as zt,yE as Bt,zD as Vt,zE as F}from"./api-B1lq0pb-.js";import{a as Ht,c as Ut}from"./FieldLabel-4AzJbj-7.js";import{t as I}from"./button-Ds98Pj53.js";import{$ as L,Bt as Wt,Dt as R,Et as z,Q as B,Rt as Gt,U as Kt,X as V,Z as H,_ as qt,at as U,et as W,jt as G,nt as K,ot as q,rt as J,tt as Jt,ut as Yt,zt as Xt}from"./index-DMM3fags.js";import{t as Zt}from"./DataTableShell-CDmo0isC.js";import{InstanceConfigDialog as Qt}from"./BridgeTab-CWbabhHl.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],$t=new Set(X),en=`conversational`;function tn(e){let t=new Set((e??[]).filter(e=>$t.has(e)));return t.size===0?[en]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,systemIdentity:``,streamTransport:Ht},nn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function rn(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,authMode:e.authMode??`token`,personScopes:e.personScopes??`capped`,identitySource:e.identitySource??`canonical`,systemIdentity:e.systemIdentity??``,streamTransport:e.streamTransport??`reactive`}}function an(){let e=k(P.admin.listInstances,{}),t=k(P.agents.listAllInstanceAgents,{}),n=N(P.admin.upsertInstance),a=N(P.admin.deleteInstance),c=R(),[l,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(Q),[h,g]=(0,Y.useState)(null),[_,y]=(0,Y.useState)(null),[x,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(null);async function E(){try{await n({instanceId:w??void 0,name:f.name,gatewayUrl:f.gatewayUrl,bridgeUrl:f.bridgeUrl||void 0,displayName:f.displayName||void 0,kind:f.kind,transport:f.kind===`hermes`?f.transport:void 0,gatewayVersion:f.gatewayVersion||void 0,gatewayHttpUrl:f.gatewayHttpUrl||void 0,...f.kind===`openclaw`?{authMode:f.authMode,personScopes:f.personScopes,identitySource:f.identitySource,systemIdentity:f.systemIdentity||void 0}:{},streamTransport:f.streamTransport}),p(Q),T(null),d(!1)}catch(e){c.error(ht(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[Ot(),(0,Z.jsx)(`strong`,{children:Ze()}),i()]}),(0,Z.jsx)(Zt,{title:ye(),rows:e,addLabel:Ve(),onAdd:()=>{T(null),p(Q),d(!0)},emptyHint:Fe(),columns:[{header:Re(),cell:e=>e.name,sort:e=>e.name},{header:ie(),cell:e=>(0,Z.jsx)(z,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:xt(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:oe(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:at(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(z,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?A():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:te(),onSelect:()=>{T(e._id),p(rn(e)),d(!0)}},{label:wt(),onSelect:()=>g(e.name)},{label:m(),onSelect:()=>C(e)},{label:ee(),onSelect:()=>y(e)},{label:Me(),variant:`destructive`,onSelect:()=>void a({instanceId:e._id})}],bulkActions:[{label:Me(),variant:`destructive`,onSelect:e=>e.forEach(e=>void a({instanceId:e}))}]}),(0,Z.jsx)(qt,{open:l,onOpenChange:d,title:w?ke():De(),description:Vt(),canSubmit:!!(f.name&&f.gatewayUrl),onSubmit:E,submitLabel:xe(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:se(),children:[(0,Z.jsx)(G,{value:f.name,disabled:w!==null,onChange:e=>p({...f,name:e.target.value})}),w?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u()}):null]}),(0,Z.jsx)($,{label:ne(),children:(0,Z.jsxs)(V,{value:f.kind,onValueChange:e=>p({...f,kind:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(B,{value:`hermes`,children:`Hermes`})]})]})}),f.kind===`hermes`?(0,Z.jsx)($,{label:At(),children:(0,Z.jsxs)(V,{value:f.transport,onValueChange:e=>p({...f,transport:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`ws`,children:Qe()}),(0,Z.jsx)(B,{value:`rest`,children:o()})]})]})}):null,(0,Z.jsx)($,{label:v(),children:(0,Z.jsx)(G,{value:f.gatewayUrl,onChange:e=>p({...f,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:ge(),children:(0,Z.jsx)(G,{value:f.bridgeUrl,placeholder:de(),onChange:e=>p({...f,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:le(),children:(0,Z.jsx)(G,{value:f.displayName,onChange:e=>p({...f,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:gt(),children:[(0,Z.jsxs)(V,{value:f.streamTransport,onValueChange:e=>p({...f,streamTransport:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsx)(H,{children:Ut.map(e=>(0,Z.jsx)(B,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:kt()})]}),(0,Z.jsx)($,{label:st(),children:(0,Z.jsx)(G,{value:f.gatewayVersion,placeholder:s(),onChange:e=>p({...f,gatewayVersion:e.target.value})})}),f.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:re(),children:[(0,Z.jsxs)(V,{value:f.authMode,onValueChange:e=>p({...f,authMode:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`token`,children:bt()}),(0,Z.jsx)(B,{value:`trusted-proxy`,children:ae()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.authMode===`trusted-proxy`?je():b()})]}),f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:ot(),children:[(0,Z.jsxs)(V,{value:f.personScopes,onValueChange:e=>p({...f,personScopes:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`capped`,children:Tt()}),(0,Z.jsx)(B,{value:`full`,children:_t()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.personScopes===`full`?$e():jt()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:r(),children:[(0,Z.jsxs)(V,{value:f.identitySource,onValueChange:e=>p({...f,identitySource:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`canonical`,children:ve()}),(0,Z.jsx)(B,{value:`email`,children:Be()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.identitySource===`email`?Le():Pe()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:Ee(),children:(0,Z.jsx)(G,{value:f.systemIdentity,placeholder:S(),onChange:e=>p({...f,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:ut(),children:(0,Z.jsx)(G,{value:f.gatewayHttpUrl,placeholder:pe(),onChange:e=>p({...f,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(hn,{instanceName:h,open:h!==null,onOpenChange:e=>{e||g(null)}}),_?(0,Z.jsx)(Qt,{instance:_,onClose:()=>y(null)},_._id):null,x?(0,Z.jsx)(on,{instance:x,onClose:()=>C(null)},x._id):null]})}function on({instance:e,onClose:t}){let n=k(P.instanceSecrets.listInstanceSecretStatus,{}),r=nn[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)(Jt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(K,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(q,{children:g({instance:e.displayName??e.name})}),(0,Z.jsx)(J,{children:we()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(ln,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(cn,{instance:e})}),(0,Z.jsx)(sn,{instance:e})]})})}function sn({instance:e}){let t=D(P.instanceSync.forceInstanceSync),n=R(),[r,i]=(0,Y.useState)(!1);async function o(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(Ge());break;case`no_agents`:n.success(Ct());break;case`no_bridge_url`:n.error(mt());break;case`deploy_misconfigured`:n.error(Dt());break;case`unauthorized`:n.error(a());break;case`not_served`:n.error(be());break;default:n.error(Xe());break}}catch(e){n.error(it(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:He()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void o(),disabled:r,children:r?vt():Et()})})]})}function cn({instance:e}){let t=k(P.bridgeAuth.listBridgeAuthStatus,{}),n=D(P.bridgeAuth.mintBridgeSecret),r=N(P.bridgeAuth.revokeBridgeSecret),i=R(),[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(Ne(),e)}finally{o(!1)}}}async function m(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(x())}catch(e){i.error(Ne(),e)}finally{o(!1)}}}async function h(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:Ie(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(z,{variant:f?`outline`:`secondary`,children:f?`${Lt()} · ${d.prefix}…${d.lastFour}`:O()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void p(),disabled:a,children:f?St():T()}),f?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void m(),disabled:a,children:E()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:Oe()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:l?Ke():j()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:C()})]}):null]})}function ln({instanceId:e,field:t,updatedAt:n}){let r=D(P.instanceSecrets.setInstanceSecret),i=N(P.instanceSecrets.clearInstanceSecret),a=D(P.deviceIdentity.generateDeviceIdentity),o=R(),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),g=n!==null,_=t===`deviceIdentity`,v=t===`token`?Ft():t===`deviceIdentity`?f():Se();async function y(){if(!(!s.trim()||l)){u(!0);try{await r({instanceId:e,field:t,plaintext:s}),c(``),p(null),h(!1),o.success(nt())}catch(e){o.error(M(),e)}finally{u(!1)}}}async function b(){if(!l){u(!0);try{await i({instanceId:e,field:t}),p(null),h(!1),o.success(yt())}catch(e){o.error(M(),e)}finally{u(!1)}}}async function ee(){if(!l){u(!0);try{p(await a({instanceId:e})),h(!1),o.success(Mt())}catch(e){o.error(Je(),e)}finally{u(!1)}}}let x=d?`openclaw devices approve ${d.id}`:``;async function S(){if(x)try{await navigator.clipboard.writeText(x),h(!0)}catch{}}return(0,Z.jsxs)($,{label:v,children:[_?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ye()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(z,{variant:g?`outline`:`secondary`,children:g?Lt():O()}),(0,Z.jsx)(G,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:g?Nt():zt(),onChange:e=>c(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void y(),disabled:l||s.trim().length===0,children:Ue()}),_?(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void ee(),disabled:l,children:et()}):null,g?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void b(),disabled:l,children:tt()}):null]})]}),d?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:Mt()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:pt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:x}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:m?Ke():j()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{p(null),h(!1)},children:C()})]}):null]})}var un={conversational:ct,documentary:dt,summarizer:lt,curator:ft},dn={conversational:c,documentary:me,summarizer:l,curator:he},fn=e=>(un[e]??(()=>e))(),pn=e=>(dn[e]??(()=>``))();function mn({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:y()}),t.map(e=>(0,Z.jsx)(z,{variant:`secondary`,className:`oc-agenttype__chip`,title:pn(e),children:fn(e)},e)),(0,Z.jsxs)(Gt,{children:[(0,Z.jsx)(Wt,{asChild:!0,children:(0,Z.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:_e()})}),(0,Z.jsxs)(Xt,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:fe()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:ue()}),(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)(Yt,{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:fn(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:pn(r)})]})]},r)})})]})]})]})}function hn({instanceName:e,open:t,onOpenChange:n}){let r=k(P.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=N(P.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=N(P.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=N(P.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=tn(r);e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),s=N(P.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),c=N(P.agents.removeInstanceAgent),l=Kt(),u=R();async function f(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){u.error(F(),e)}}async function m(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){u.error(F(),e)}}async function g(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){u.error(F(),e)}}async function v(t,n){if(e&&await l({title:Te({name:n}),description:It(),confirmLabel:p(),destructive:!0}))try{await c({instanceName:e,agentId:t}),u.success(Ce())}catch(e){u.error(F(),e)}}return(0,Z.jsx)(Jt,{open:t,onOpenChange:n,children:(0,Z.jsxs)(K,{className:`oc-access`,children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(q,{children:Ae({name:e??``})}),(0,Z.jsx)(J,{children:d()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:Rt()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?qe():r.discovery.lastPollOk?Bt():Pt({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:We()}):(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)(Yt,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void f(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)(z,{variant:`outline`,className:`oc-access__gone`,children:rt()}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void v(t.agentId,a),children:_()})]}):i?(0,Z.jsx)(z,{variant:`default`,children:A()}):(0,Z.jsx)(I,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void m(t.agentId),children:h()})]}),t.enabled?(0,Z.jsx)(mn,{agentId:t.agentId,types:o,onToggle:e=>void g(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(gn,{value:t.description??``,onSave:async n=>{if(e)try{await s({instanceName:e,agentId:t.agentId,description:n})}catch(e){u.error(F(),e)}}}):null]},t.agentId)})})]})]})})}function gn({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(G,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:ce(),"aria-label":w(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{an as InstancesTab};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$ as r,$D as i,$E as a,$i as o,AD as s,AE as c,Ac as l,BD as u,BE as d,CD as f,CE as p,DD as m,DE as h,ED as g,EE as _,FD as v,FE as y,G as b,GD as ee,GE as x,H as S,HD as te,HE as C,ID as ne,IE as w,J as re,JD as ie,JE as T,K as ae,KD as oe,KE as E,LD as se,LE as ce,MD as le,ME as ue,ND as de,NE as fe,OD as pe,OE as me,Oc as he,PD as ge,PE as _e,Q as ve,QD as ye,QE as be,RD as xe,SD as Se,SE as Ce,TD as we,TE as Te,U as Ee,UD as De,UE as Oe,VD as ke,VE as Ae,W as je,WD as Me,WE as Ne,X as Pe,XD as Fe,XE as Ie,Y as Le,YD as Re,YE as ze,Z as Be,ZD as Ve,ZE as He,_D as Ue,_E as We,aD as Ge,aP as Ke,aV as D,bD as O,bE as qe,cD as Je,cV as k,dD as Ye,eD as Xe,eO as Ze,ea as Qe,et as $e,fD as et,gD as tt,gE as A,hD as nt,hE as rt,iD as it,iO as at,iP as j,it as ot,jD as st,jE as ct,jc as lt,kD as ut,kE as dt,kc as ft,lD as pt,mD as M,nD as mt,nO as ht,nS as gt,nt as _t,oD as vt,pD as yt,q as bt,qD as xt,qE as St,rD as Ct,rO as wt,rt as Tt,sD as Et,sV as N,t as P,tD as Dt,tO as Ot,tS as kt,ta as At,tt as jt,uD as Mt,vD as Nt,vE as Pt,wD as Ft,wE as It,xD as Lt,xE as Rt,yD as zt,yE as Bt,zD as Vt,zE as F}from"./api-B1lq0pb-.js";import{a as Ht,c as Ut}from"./FieldLabel-CgbnOAaa.js";import{t as I}from"./button-Ds98Pj53.js";import{$ as L,Bt as Wt,Dt as R,Et as z,Q as B,Rt as Gt,U as Kt,X as V,Z as H,_ as qt,at as U,et as W,jt as G,nt as K,ot as q,rt as J,tt as Jt,ut as Yt,zt as Xt}from"./index-Bkfx3eIe.js";import{t as Zt}from"./DataTableShell-BK8Kucos.js";import{InstanceConfigDialog as Qt}from"./BridgeTab-BvlinzLy.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],$t=new Set(X),en=`conversational`;function tn(e){let t=new Set((e??[]).filter(e=>$t.has(e)));return t.size===0?[en]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,systemIdentity:``,streamTransport:Ht},nn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function rn(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,authMode:e.authMode??`token`,personScopes:e.personScopes??`capped`,identitySource:e.identitySource??`canonical`,systemIdentity:e.systemIdentity??``,streamTransport:e.streamTransport??`reactive`}}function an(){let e=k(P.admin.listInstances,{}),t=k(P.agents.listAllInstanceAgents,{}),n=N(P.admin.upsertInstance),a=N(P.admin.deleteInstance),c=R(),[l,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(Q),[h,g]=(0,Y.useState)(null),[_,y]=(0,Y.useState)(null),[x,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(null);async function E(){try{await n({instanceId:w??void 0,name:f.name,gatewayUrl:f.gatewayUrl,bridgeUrl:f.bridgeUrl||void 0,displayName:f.displayName||void 0,kind:f.kind,transport:f.kind===`hermes`?f.transport:void 0,gatewayVersion:f.gatewayVersion||void 0,gatewayHttpUrl:f.gatewayHttpUrl||void 0,...f.kind===`openclaw`?{authMode:f.authMode,personScopes:f.personScopes,identitySource:f.identitySource,systemIdentity:f.systemIdentity||void 0}:{},streamTransport:f.streamTransport}),p(Q),T(null),d(!1)}catch(e){c.error(ht(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[Ot(),(0,Z.jsx)(`strong`,{children:Ze()}),i()]}),(0,Z.jsx)(Zt,{title:ye(),rows:e,addLabel:Ve(),onAdd:()=>{T(null),p(Q),d(!0)},emptyHint:Fe(),columns:[{header:Re(),cell:e=>e.name,sort:e=>e.name},{header:ie(),cell:e=>(0,Z.jsx)(z,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:xt(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:oe(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:at(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(z,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?A():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:te(),onSelect:()=>{T(e._id),p(rn(e)),d(!0)}},{label:wt(),onSelect:()=>g(e.name)},{label:m(),onSelect:()=>C(e)},{label:ee(),onSelect:()=>y(e)},{label:Me(),variant:`destructive`,onSelect:()=>void a({instanceId:e._id})}],bulkActions:[{label:Me(),variant:`destructive`,onSelect:e=>e.forEach(e=>void a({instanceId:e}))}]}),(0,Z.jsx)(qt,{open:l,onOpenChange:d,title:w?ke():De(),description:Vt(),canSubmit:!!(f.name&&f.gatewayUrl),onSubmit:E,submitLabel:xe(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:se(),children:[(0,Z.jsx)(G,{value:f.name,disabled:w!==null,onChange:e=>p({...f,name:e.target.value})}),w?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u()}):null]}),(0,Z.jsx)($,{label:ne(),children:(0,Z.jsxs)(V,{value:f.kind,onValueChange:e=>p({...f,kind:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(B,{value:`hermes`,children:`Hermes`})]})]})}),f.kind===`hermes`?(0,Z.jsx)($,{label:At(),children:(0,Z.jsxs)(V,{value:f.transport,onValueChange:e=>p({...f,transport:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`ws`,children:Qe()}),(0,Z.jsx)(B,{value:`rest`,children:o()})]})]})}):null,(0,Z.jsx)($,{label:v(),children:(0,Z.jsx)(G,{value:f.gatewayUrl,onChange:e=>p({...f,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:ge(),children:(0,Z.jsx)(G,{value:f.bridgeUrl,placeholder:de(),onChange:e=>p({...f,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:le(),children:(0,Z.jsx)(G,{value:f.displayName,onChange:e=>p({...f,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:gt(),children:[(0,Z.jsxs)(V,{value:f.streamTransport,onValueChange:e=>p({...f,streamTransport:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsx)(H,{children:Ut.map(e=>(0,Z.jsx)(B,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:kt()})]}),(0,Z.jsx)($,{label:st(),children:(0,Z.jsx)(G,{value:f.gatewayVersion,placeholder:s(),onChange:e=>p({...f,gatewayVersion:e.target.value})})}),f.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:re(),children:[(0,Z.jsxs)(V,{value:f.authMode,onValueChange:e=>p({...f,authMode:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`token`,children:bt()}),(0,Z.jsx)(B,{value:`trusted-proxy`,children:ae()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.authMode===`trusted-proxy`?je():b()})]}),f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:ot(),children:[(0,Z.jsxs)(V,{value:f.personScopes,onValueChange:e=>p({...f,personScopes:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`capped`,children:Tt()}),(0,Z.jsx)(B,{value:`full`,children:_t()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.personScopes===`full`?$e():jt()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:r(),children:[(0,Z.jsxs)(V,{value:f.identitySource,onValueChange:e=>p({...f,identitySource:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(W,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`canonical`,children:ve()}),(0,Z.jsx)(B,{value:`email`,children:Be()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.identitySource===`email`?Le():Pe()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:Ee(),children:(0,Z.jsx)(G,{value:f.systemIdentity,placeholder:S(),onChange:e=>p({...f,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:ut(),children:(0,Z.jsx)(G,{value:f.gatewayHttpUrl,placeholder:pe(),onChange:e=>p({...f,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(hn,{instanceName:h,open:h!==null,onOpenChange:e=>{e||g(null)}}),_?(0,Z.jsx)(Qt,{instance:_,onClose:()=>y(null)},_._id):null,x?(0,Z.jsx)(on,{instance:x,onClose:()=>C(null)},x._id):null]})}function on({instance:e,onClose:t}){let n=k(P.instanceSecrets.listInstanceSecretStatus,{}),r=nn[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)(Jt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(K,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(q,{children:g({instance:e.displayName??e.name})}),(0,Z.jsx)(J,{children:we()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(ln,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(cn,{instance:e})}),(0,Z.jsx)(sn,{instance:e})]})})}function sn({instance:e}){let t=D(P.instanceSync.forceInstanceSync),n=R(),[r,i]=(0,Y.useState)(!1);async function o(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(Ge());break;case`no_agents`:n.success(Ct());break;case`no_bridge_url`:n.error(mt());break;case`deploy_misconfigured`:n.error(Dt());break;case`unauthorized`:n.error(a());break;case`not_served`:n.error(be());break;default:n.error(Xe());break}}catch(e){n.error(it(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:He()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void o(),disabled:r,children:r?vt():Et()})})]})}function cn({instance:e}){let t=k(P.bridgeAuth.listBridgeAuthStatus,{}),n=D(P.bridgeAuth.mintBridgeSecret),r=N(P.bridgeAuth.revokeBridgeSecret),i=R(),[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(Ne(),e)}finally{o(!1)}}}async function m(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(x())}catch(e){i.error(Ne(),e)}finally{o(!1)}}}async function h(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:Ie(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(z,{variant:f?`outline`:`secondary`,children:f?`${Lt()} · ${d.prefix}…${d.lastFour}`:O()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void p(),disabled:a,children:f?St():T()}),f?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void m(),disabled:a,children:E()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:Oe()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:l?Ke():j()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:C()})]}):null]})}function ln({instanceId:e,field:t,updatedAt:n}){let r=D(P.instanceSecrets.setInstanceSecret),i=N(P.instanceSecrets.clearInstanceSecret),a=D(P.deviceIdentity.generateDeviceIdentity),o=R(),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),g=n!==null,_=t===`deviceIdentity`,v=t===`token`?Ft():t===`deviceIdentity`?f():Se();async function y(){if(!(!s.trim()||l)){u(!0);try{await r({instanceId:e,field:t,plaintext:s}),c(``),p(null),h(!1),o.success(nt())}catch(e){o.error(M(),e)}finally{u(!1)}}}async function b(){if(!l){u(!0);try{await i({instanceId:e,field:t}),p(null),h(!1),o.success(yt())}catch(e){o.error(M(),e)}finally{u(!1)}}}async function ee(){if(!l){u(!0);try{p(await a({instanceId:e})),h(!1),o.success(Mt())}catch(e){o.error(Je(),e)}finally{u(!1)}}}let x=d?`openclaw devices approve ${d.id}`:``;async function S(){if(x)try{await navigator.clipboard.writeText(x),h(!0)}catch{}}return(0,Z.jsxs)($,{label:v,children:[_?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ye()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(z,{variant:g?`outline`:`secondary`,children:g?Lt():O()}),(0,Z.jsx)(G,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:g?Nt():zt(),onChange:e=>c(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void y(),disabled:l||s.trim().length===0,children:Ue()}),_?(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void ee(),disabled:l,children:et()}):null,g?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void b(),disabled:l,children:tt()}):null]})]}),d?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:Mt()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:pt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:x}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:m?Ke():j()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{p(null),h(!1)},children:C()})]}):null]})}var un={conversational:ct,documentary:dt,summarizer:lt,curator:ft},dn={conversational:c,documentary:me,summarizer:l,curator:he},fn=e=>(un[e]??(()=>e))(),pn=e=>(dn[e]??(()=>``))();function mn({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:y()}),t.map(e=>(0,Z.jsx)(z,{variant:`secondary`,className:`oc-agenttype__chip`,title:pn(e),children:fn(e)},e)),(0,Z.jsxs)(Gt,{children:[(0,Z.jsx)(Wt,{asChild:!0,children:(0,Z.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:_e()})}),(0,Z.jsxs)(Xt,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:fe()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:ue()}),(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)(Yt,{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:fn(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:pn(r)})]})]},r)})})]})]})]})}function hn({instanceName:e,open:t,onOpenChange:n}){let r=k(P.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=N(P.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=N(P.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=N(P.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=tn(r);e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),s=N(P.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),c=N(P.agents.removeInstanceAgent),l=Kt(),u=R();async function f(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){u.error(F(),e)}}async function m(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){u.error(F(),e)}}async function g(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){u.error(F(),e)}}async function v(t,n){if(e&&await l({title:Te({name:n}),description:It(),confirmLabel:p(),destructive:!0}))try{await c({instanceName:e,agentId:t}),u.success(Ce())}catch(e){u.error(F(),e)}}return(0,Z.jsx)(Jt,{open:t,onOpenChange:n,children:(0,Z.jsxs)(K,{className:`oc-access`,children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(q,{children:Ae({name:e??``})}),(0,Z.jsx)(J,{children:d()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:Rt()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?qe():r.discovery.lastPollOk?Bt():Pt({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:We()}):(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)(Yt,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void f(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)(z,{variant:`outline`,className:`oc-access__gone`,children:rt()}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void v(t.agentId,a),children:_()})]}):i?(0,Z.jsx)(z,{variant:`default`,children:A()}):(0,Z.jsx)(I,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void m(t.agentId),children:h()})]}),t.enabled?(0,Z.jsx)(mn,{agentId:t.agentId,types:o,onToggle:e=>void g(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(gn,{value:t.description??``,onSave:async n=>{if(e)try{await s({instanceName:e,agentId:t.agentId,description:n})}catch(e){u.error(F(),e)}}}):null]},t.agentId)})})]})]})})}function gn({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(G,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:ce(),"aria-label":w(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{an as InstancesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bk as r,Gk as i,Gl as a,Hk as o,Ik as s,Jk as c,Jl as l,Kk as u,Kl as d,Lk as f,Ql as p,Rk as m,Uk as h,Vk as g,Wk as _,Wl as v,Xl as y,Yk as b,Yl as x,Zl as S,aV as C,cV as w,qk as T,ql as E,sV as D,t as O,zk as k}from"./api-B1lq0pb-.js";import{t as A}from"./button-Ds98Pj53.js";import{Et as j,jt as M,ut as N}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bk as r,Gk as i,Gl as a,Hk as o,Ik as s,Jk as c,Jl as l,Kk as u,Kl as d,Lk as f,Ql as p,Rk as m,Uk as h,Vk as g,Wk as _,Wl as v,Xl as y,Yk as b,Yl as x,Zl as S,aV as C,cV as w,qk as T,ql as E,sV as D,t as O,zk as k}from"./api-B1lq0pb-.js";import{t as A}from"./button-Ds98Pj53.js";import{Et as j,jt as M,ut as N}from"./index-Bkfx3eIe.js";var P=t(e(),1),F=n();function I(){let e=w(O.integrations.status.status,{}),t=D(O.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:b()});let l=n,d=(e,t,n)=>a({...l,[e]:{...l[e],[t]:n}}),v=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[c(),` `,(0,F.jsx)(`strong`,{children:T()}),` `,u()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:i()}):(0,F.jsx)(j,{variant:`outline`,children:_()}):(0,F.jsx)(j,{variant:`outline`,children:h()}),note:o(),children:[(0,F.jsx)(R,{label:r(),children:(0,F.jsx)(M,{value:l.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>d(`langfuse`,`host`,e.target.value),onBlur:()=>v(`langfuse`,{host:l.langfuse.host??``})})}),(0,F.jsx)(z,{label:s(),checked:l.langfuse.enabled??!0,onChange:e=>{d(`langfuse`,`enabled`,e),v(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:i()}):(0,F.jsx)(j,{variant:`outline`,children:_()}):(0,F.jsx)(j,{variant:`outline`,children:h()}),note:g(),children:[(0,F.jsx)(R,{label:k(),children:(0,F.jsx)(M,{value:l.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>d(`opik`,`baseUrl`,e.target.value),onBlur:()=>v(`opik`,{baseUrl:l.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:m(),children:(0,F.jsx)(M,{value:l.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||f(),onChange:e=>d(`opik`,`workspace`,e.target.value),onBlur:()=>v(`opik`,{workspace:l.opik.workspace??``})})}),(0,F.jsx)(z,{label:s(),checked:l.opik.enabled??!0,onChange:e=>{d(`opik`,`enabled`,e),v(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:i()}):(0,F.jsx)(j,{variant:`outline`,children:_()}):(0,F.jsx)(j,{variant:`outline`,children:p()}),note:S(),children:[(0,F.jsx)(R,{label:y(),children:(0,F.jsx)(M,{value:l.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>d(`otlp`,`endpoint`,e.target.value),onBlur:()=>v(`otlp`,{endpoint:l.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:s(),checked:l.otlp.enabled??!0,onChange:e=>{d(`otlp`,`enabled`,e),v(`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=C(O.integrations.otlpSecret.setOtlpHeaders),n=D(O.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[o,s]=(0,P.useState)(null),[c,u]=(0,P.useState)(!1),f=async()=>{u(!0),s(null);try{await t({headersJson:r}),i(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,F.jsxs)(R,{label:x(),children:[(0,F.jsx)(M,{value:r,placeholder:e?l():E(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:c||r.trim().length===0,onClick:()=>void f(),children:d()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:c,onClick:()=>void n({}),children:a()}):null]}),o?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:o}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:v()})]})}export{I as IntegrationsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AA as r,CA as i,MA as a,NA as o,SA as s,_b as c,ab as l,cV as u,cb as d,db as f,fb as p,gb as m,hb as h,ij as g,jA as ee,lb as te,mb as _,ob as v,pb as y,sb as b,t as x,ub as S,vb as C,yb as w}from"./api-B1lq0pb-.js";import{Gn as ne,Kn as re,i as ie,o as T,q as E,r as D}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AA as r,CA as i,MA as a,NA as o,SA as s,_b as c,ab as l,cV as u,cb as d,db as f,fb as p,gb as m,hb as h,ij as g,jA as ee,lb as te,mb as _,ob as v,pb as y,sb as b,t as x,ub as S,vb as C,yb as w}from"./api-B1lq0pb-.js";import{Gn as ne,Kn as re,i as ie,o as T,q as E,r as D}from"./index-Bkfx3eIe.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-C2GdBOIp.js";import{n as N,t as P}from"./TimeRangePicker-B8MRcEsu.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=u(x.me.getMe,{host:E})?.permissions?.includes(`traces.read`)??!1,t=u(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:g()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:o()}),(0,R.jsx)(j,{children:ee()})]}),(0,R.jsx)(k,{children:n.length<2?(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(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),c=t=>6+t*468/(e.length-1),l=e=>74-e*68/r,u=e=>e.map((e,t)=>`${t===0?`M`:`L`}${c(t).toFixed(1)},${l(e).toFixed(1)}`).join(` `),d=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:[s(),` p50 `,B(d.cP50),` `,a()]}),(0,R.jsxs)(`span`,{children:[i(),` p50 `,B(d.aP50),` `,a()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":o(),children:[(0,R.jsx)(`path`,{d:u(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:u(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:w(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:C(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:c(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:m(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:h(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:_(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:y(),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 Y(){let e=re({from:`/settings/kpi`}),t=ne({from:`/settings/kpi`}),n=ie(e.from,e.to,D,`now`),r=e=>void t({search:t=>({...t,...T(e)})}),{from:i,to:a}=N(n),{rowLimit:o,buckets:s}=J(i,a),c=u(x.kpi.listKpis,{limit:o,filter:{from:i,to:a}}),l=(0,F.useMemo)(()=>{let e=new Map;for(let t of c??[]){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>s&&e.set(t,n.slice(n.length-s));return e},[c,s]),d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[p(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:f()})]}),(0,R.jsx)(ae,{value:n,onChange:r})]});return c===void 0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:S()})]}):c.length===0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:te()})]}):(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=>(l.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:l.get(e.metric)??[]},e.metric))})]},e):null})]})}function ae({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:d({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:b()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:v({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":l({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{Y as KpiTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$B as r,$F as i,$n as a,AB as o,AF as s,BB as c,BF as l,CB as u,CF as d,DB as ee,DF as f,EB as te,EF as p,FB as ne,FF as m,GB as re,GF as ie,HB as ae,HF as oe,IB as se,IF as ce,JB as le,JF as ue,Jn as de,KF as fe,LB as pe,LF as me,MB as he,MF as ge,NB as _e,NF as ve,OB as h,OF as g,PB as _,PF as v,QF as y,Qn as b,RB as x,RD as S,RF as C,SB as w,SF as T,TB as E,TF as D,UB as O,UF as k,VB as A,VF as j,WB as M,WF as N,XF as P,Xn as F,YF as ye,Yn as be,ZF as xe,Zn as Se,_F as Ce,bF as we,cV as I,eI as Te,er as Ee,hr as De,jB as Oe,jF as ke,kB as Ae,kF as je,lr as Me,mr as Ne,nI as Pe,qF as Fe,r as L,sV as R,t as z,tI as Ie,tr as Le,vF as Re,wB as ze,wF as B,xF as Be,yF as Ve,zB as He,zF as Ue}from"./api-B1lq0pb-.js";import{t as V}from"./button-Ds98Pj53.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-DMM3fags.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-DeJ3e50i.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:L(`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:L(`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:()=>Ie()},{id:`sidebar`,label:()=>Te()},{id:`notifications`,label:()=>me()},{id:`other`,label:()=>i()}],X={showSource:{category:`messages`,label:()=>y(),help:()=>xe()},showReport:{category:`messages`,label:()=>P(),help:()=>ye()},copyAssistant:{category:`messages`,label:()=>ue()},copyUser:{category:`messages`,label:()=>Fe()},showDelete:{category:`messages`,label:()=>fe()},showTools:{category:`messages`,label:()=>ie(),help:()=>N()},voiceInput:{category:`composer`,label:()=>k(),help:()=>oe()},showUsage:{category:`composer`,label:()=>j(),help:()=>l()},autoReadAloud:{category:`composer`,label:()=>De(),help:()=>Ne()},showChatAge:{category:`sidebar`,label:()=>Ue(),help:()=>C()},notifSound:{category:`notifications`,label:()=>ce(),help:()=>m()},notifSystem:{category:`notifications`,label:()=>v(),help:()=>ve()},replySound:{category:`notifications`,label:()=>ge(),help:()=>ke()}};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:()=>Be()};function ut({prefKey:e,ui:t}){let n=R(z.admin.setUiPrefDefault),r=R(z.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:D()}),(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:Ve()}),(0,J.jsx)(U,{value:`off`,children:Re()}),(0,J.jsx)(U,{value:`inherit`,children:Ce()})]})]}),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":B()}),B()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=R(z.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Qe(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(s(!0),window.setTimeout(()=>s(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[Le(),e?(0,J.jsx)(H,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:o?b():r?a():Ee()})]}),(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:de()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?be():e?F():Se()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,i]=(0,q.useState)(!1),a=I(z.me.getMe,{host:G}),o=a?.ui,c=$(a?.role)&&n,l=R(z.me.setUiPref).withOptimisticUpdate(Je),u=(0,q.useMemo)(()=>o?Q(Object.keys(o.effective),e):[],[o,e]);return o?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(a?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(K,{checked:n,onCheckedChange:e=>i(e===!0),"aria-label":p()}),p()]}):null,c?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:d()}),(0,J.jsx)(`p`,{children:T()}),(0,J.jsx)(`p`,{children:we()})]}):null,(0,J.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:s(),"aria-label":s(),className:`mb-2`}),u.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:je()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:u.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=o.locked[e],a=o.effective[e],s=o.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:g()}):s?(0,J.jsx)(H,{variant:`secondary`,children:Me()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&s?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void l({key:e,value:null}),children:f()}):null,(0,J.jsx)(nt,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),l({key:e,value:t})},"aria-label":n})]}),c?(0,J.jsx)(ut,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:a?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:r()})}var pt={sm:()=>_e(),md:()=>he(),lg:()=>Oe(),xl:()=>o(),"2xl":()=>Ae(),"3xl":()=>h()};function mt(){let e=I(z.me.getMe,{host:G}),t=R(z.me.setLocale),n=R(z.me.setTimezone),r=R(z.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(z.me.getMe,{host:G});n&&e.setQuery(z.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=R(z.me.setMyName),a=Ke(),o=e?.locale??`default`,s=e?.name??``,[l,d]=(0,q.useState)(null),f=l??s,p=f.trim()!==s.trim();async function m(){try{await i({name:f}),d(null),a.success(A())}catch(e){a.error(c(),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:re()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:M()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(W,{className:`max-w-xs`,value:f,maxLength:120,placeholder:O(),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:S()})]}),(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:He()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:x()})]}),(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:le()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:pe()})]}),(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:ee()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:te()})]}),(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:E()})]}),(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:se()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ne()})]}),(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:_()})]}),(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:u()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:w()})]}),(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{$B as r,$F as i,$n as a,AB as o,AF as s,BB as c,BF as l,CB as u,CF as d,DB as ee,DF as f,EB as te,EF as p,FB as ne,FF as m,GB as re,GF as ie,HB as ae,HF as oe,IB as se,IF as ce,JB as le,JF as ue,Jn as de,KF as fe,LB as pe,LF as me,MB as he,MF as ge,NB as _e,NF as ve,OB as h,OF as g,PB as _,PF as v,QF as y,Qn as b,RB as x,RD as S,RF as C,SB as w,SF as T,TB as E,TF as D,UB as O,UF as k,VB as A,VF as j,WB as M,WF as N,XF as P,Xn as F,YF as ye,Yn as be,ZF as xe,Zn as Se,_F as Ce,bF as we,cV as I,eI as Te,er as Ee,hr as De,jB as Oe,jF as ke,kB as Ae,kF as je,lr as Me,mr as Ne,nI as Pe,qF as Fe,r as L,sV as R,t as z,tI as Ie,tr as Le,vF as Re,wB as ze,wF as B,xF as Be,yF as Ve,zB as He,zF as Ue}from"./api-B1lq0pb-.js";import{t as V}from"./button-Ds98Pj53.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-Bkfx3eIe.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-BYDYUkxC.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:L(`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:L(`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:()=>Ie()},{id:`sidebar`,label:()=>Te()},{id:`notifications`,label:()=>me()},{id:`other`,label:()=>i()}],X={showSource:{category:`messages`,label:()=>y(),help:()=>xe()},showReport:{category:`messages`,label:()=>P(),help:()=>ye()},copyAssistant:{category:`messages`,label:()=>ue()},copyUser:{category:`messages`,label:()=>Fe()},showDelete:{category:`messages`,label:()=>fe()},showTools:{category:`messages`,label:()=>ie(),help:()=>N()},voiceInput:{category:`composer`,label:()=>k(),help:()=>oe()},showUsage:{category:`composer`,label:()=>j(),help:()=>l()},autoReadAloud:{category:`composer`,label:()=>De(),help:()=>Ne()},showChatAge:{category:`sidebar`,label:()=>Ue(),help:()=>C()},notifSound:{category:`notifications`,label:()=>ce(),help:()=>m()},notifSystem:{category:`notifications`,label:()=>v(),help:()=>ve()},replySound:{category:`notifications`,label:()=>ge(),help:()=>ke()}};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:()=>Be()};function ut({prefKey:e,ui:t}){let n=R(z.admin.setUiPrefDefault),r=R(z.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:D()}),(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:Ve()}),(0,J.jsx)(U,{value:`off`,children:Re()}),(0,J.jsx)(U,{value:`inherit`,children:Ce()})]})]}),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":B()}),B()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=R(z.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Qe(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(s(!0),window.setTimeout(()=>s(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[Le(),e?(0,J.jsx)(H,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:o?b():r?a():Ee()})]}),(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:de()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?be():e?F():Se()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,i]=(0,q.useState)(!1),a=I(z.me.getMe,{host:G}),o=a?.ui,c=$(a?.role)&&n,l=R(z.me.setUiPref).withOptimisticUpdate(Je),u=(0,q.useMemo)(()=>o?Q(Object.keys(o.effective),e):[],[o,e]);return o?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(a?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(K,{checked:n,onCheckedChange:e=>i(e===!0),"aria-label":p()}),p()]}):null,c?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:d()}),(0,J.jsx)(`p`,{children:T()}),(0,J.jsx)(`p`,{children:we()})]}):null,(0,J.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:s(),"aria-label":s(),className:`mb-2`}),u.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:je()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:u.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=o.locked[e],a=o.effective[e],s=o.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:g()}):s?(0,J.jsx)(H,{variant:`secondary`,children:Me()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&s?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void l({key:e,value:null}),children:f()}):null,(0,J.jsx)(nt,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),l({key:e,value:t})},"aria-label":n})]}),c?(0,J.jsx)(ut,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:a?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:r()})}var pt={sm:()=>_e(),md:()=>he(),lg:()=>Oe(),xl:()=>o(),"2xl":()=>Ae(),"3xl":()=>h()};function mt(){let e=I(z.me.getMe,{host:G}),t=R(z.me.setLocale),n=R(z.me.setTimezone),r=R(z.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(z.me.getMe,{host:G});n&&e.setQuery(z.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=R(z.me.setMyName),a=Ke(),o=e?.locale??`default`,s=e?.name??``,[l,d]=(0,q.useState)(null),f=l??s,p=f.trim()!==s.trim();async function m(){try{await i({name:f}),d(null),a.success(A())}catch(e){a.error(c(),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:re()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:M()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(W,{className:`max-w-xs`,value:f,maxLength:120,placeholder:O(),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:S()})]}),(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:He()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:x()})]}),(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:le()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:pe()})]}),(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:ee()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:te()})]}),(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:E()})]}),(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:se()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ne()})]}),(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:_()})]}),(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:u()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:w()})]}),(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{$B as r,$v as i,Bv as a,By as o,Ct as s,Cy as c,D as l,Dy as u,Ey as d,Fv as f,Fy as p,Hv as m,Hy as h,Iv as ee,Iy as g,Jv as te,Lv as ne,Mv as _,My as re,Ny as ie,Pv as ae,Rg as v,Rv as y,St as oe,Ty as se,Uv as ce,Vy as le,Wv as ue,Xv as de,Yv as fe,Zv as pe,_y as me,ay as b,by as x,cV as S,cy as C,dy as he,ey as ge,fy as w,hy as _e,iy as ve,ky as T,ly as ye,my as E,ny as D,oy as be,py as O,ry as xe,sV as k,sy as A,t as j,ty as Se,uy as Ce,vy as we,wy as Te,xy as M,yy as Ee,zv as N}from"./api-B1lq0pb-.js";import{t as De}from"./list-DhABairq.js";import{t as P}from"./button-Ds98Pj53.js";import{A as Oe,An as ke,Bn as Ae,C as je,D as F,Dt as Me,E as Ne,Ft as Pe,Gn as I,Hn as Fe,It as Ie,J as Le,Kn as Re,Lt as ze,Mn as Be,Mt as Ve,Nn as He,Nt as Ue,O as L,P as We,Pn as Ge,Pt as R,S as Ke,Sn as qe,T as Je,Tn as Ye,U as Xe,W as Ze,Y as Qe,_ as $e,b as z,bn as et,d as tt,dn as nt,f as rt,g as B,h as V,j as H,jn as U,jt as W,k as it,kn as G,m as at,p as ot,qn as st,v as K,vn as ct,w as lt,wn as ut,x as q,y as dt,yn as J}from"./index-DMM3fags.js";var ft=l(`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`}]]),pt=l(`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`}]]),mt=l(`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`}]]),Y=l(`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 ht({className:e}){return(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":a(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Ge,{})})})}function Q({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:a}){let s=k(j.projects.renameProject),l=k(j.projects.setProjectColor),p=k(j.projects.moveProject),g=k(j.projects.deleteProject),ne=k(j.projects.createProject),_=Xe(),ie=Ze(),[ae,v]=(0,X.useState)(!1),[y,oe]=(0,X.useState)(t),[ue,fe]=(0,X.useState)(!1),[pe,me]=(0,X.useState)(!1),b=S(j.projects.projectTreeCount,pe?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ve,{onOpenChange:e=>e&&me(!0),children:[(0,Z.jsx)(ht,{className:i}),(0,Z.jsxs)(Ue,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>a(),children:[(0,Z.jsx)(U,{}),` `,c()]}),(0,Z.jsxs)(R,{onSelect:()=>{oe(t),v(!0)},children:[(0,Z.jsx)(et,{}),` `,N()]}),(0,Z.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await ie({title:E(),label:h(),placeholder:le(),confirmLabel:o()});t&&await ne({name:t,parentId:e})})},children:[(0,Z.jsx)(ke,{}),` `,E()]}),(0,Z.jsxs)(R,{onSelect:()=>fe(!0),children:[(0,Z.jsx)(pt,{}),` `,de()]}),(0,Z.jsx)(Pe,{children:ee()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e,color:null}),"aria-label":f(),children:`✕`}),at.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 l({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=b?.folders??0,r=b?.chats??0;await _({title:d({name:t}),description:n>0?Te({folders:n,chats:r}):r>0?se({count:r}):ce(),confirmWord:m(),confirmLabel:u(),destructive:!0})&&await g({projectId:e})})},children:[(0,Z.jsx)(nt,{}),` `,m()]})]})]}),(0,Z.jsx)($e,{open:ae,onOpenChange:v,title:re(),canSubmit:y.trim().length>0,onSubmit:async()=>{await s({projectId:e,name:y.trim()}),v(!1)},submitLabel:N(),children:(0,Z.jsx)(W,{value:y,onChange:e=>oe(e.target.value),autoFocus:!0})}),ue?(0,Z.jsx)(ot,{open:ue,onOpenChange:fe,title:te(),movingFolderId:e,currentId:r,onPick:t=>void p({projectId:e,parentId:t})}):null]})}function gt({chat:e,currentFolderId:t,className:n}){let r=k(j.chats.pinChat),i=k(j.chats.deleteChat),a=k(j.chats.renameChat),o=k(j.chats.setChatSidebar),s=k(j.chats.moveChatToProject),c=Xe(),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(e.title??``),[p,h]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ve,{children:[(0,Z.jsx)(ht,{className:n}),(0,Z.jsxs)(Ue,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>{f(e.title??``),u(!0)},children:[(0,Z.jsx)(et,{}),` `,N()]}),(0,Z.jsxs)(R,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(ct,{}):(0,Z.jsx)(J,{}),e.pinned?y():ne()]}),(0,Z.jsxs)(R,{onSelect:()=>h(!0),children:[(0,Z.jsx)(pt,{}),` `,pe()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(R,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(qe,{}):(0,Z.jsx)(Y,{}),e.inSidebar?x():M()]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await c({title:ae(),description:ce(),confirmLabel:m(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Z.jsx)(nt,{}),` `,m()]})]})]}),(0,Z.jsx)($e,{open:l,onOpenChange:u,title:_(),canSubmit:d.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:d.trim()}),u(!1)},submitLabel:N(),children:(0,Z.jsx)(W,{value:d,onChange:e=>f(e.target.value),autoFocus:!0})}),p?(0,Z.jsx)(ot,{open:p,onOpenChange:h,title:fe(),currentId:t,onPick:t=>void s({chatId:e._id,projectId:t})}):null]})}function _t(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function vt(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 yt(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 bt=`oc.projpage.view`;function xt(){let e=localStorage.getItem(bt);return e===`cards`||e===`list`?e:`columns`}var $=e=>`into:${e}`,St=e=>`col:${e??`null`}`,Ct=e=>`crumb:${e}`;function wt(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 Tt(){let{projectId:e}=st({from:`/project/$projectId`}),t=I(),n=S(j.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:r()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:D()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Se()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:ge()})]}):(0,Z.jsx)(Et,{page:n})})}function Et({page:e}){let t=I(),n=Xe(),r=Ze(),a=Me(),c=k(j.projects.renameProject),l=k(j.projects.setProjectColor),p=k(j.projects.deleteProject),ne=k(j.projects.createProject),_=k(j.projects.moveProject),ae=k(j.projects.setProjectSidebar),y=k(j.chats.moveChatToProject),fe=k(j.chats.reorderChat),pe=k(j.projects.reorderProject),x=S(j.projects.projectTreeCount,{projectId:e.project._id}),[C,ge]=(0,X.useState)(xt),w=e=>{localStorage.setItem(bt,e),ge(e)},T=S(j.projects.folderColumns,C===`columns`?{projectId:e.project._id}:`skip`),D=S(j.projects.projectTreeList,C===`list`?{projectId:e.project._id}:`skip`),{c:O}=Re({from:`/project/$projectId`}),A=S(j.projects.listProjects,{}),Se=S(j.chatReads.myBusyChats,{}),M=(0,X.useMemo)(()=>new Set(Se??[]),[Se]),Ae=S(j.chatReads.myChatReads,{}),Fe=(0,X.useMemo)(()=>yt(e.chats,Ae??[]),[e.chats,Ae]),{startNewChat:L,picker:qe}=tt(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[z,rt]=(0,X.useState)(``),[V,H]=(0,X.useState)(!1),[U,st]=(0,X.useState)(e.project.name),[ct,J]=(0,X.useState)(!1),[Y,ht]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ht(z.trim()),180);return()=>clearTimeout(e)},[z]);let Q=S(j.search.searchConversations,Y.length>=2?{query:Y,projectId:e.project._id}:`skip`),gt=Oe(it(lt,{activationConstraint:{distance:4}}),it(Je,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),St=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[Ct,Tt]=(0,X.useState)(null),Et=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||g()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(A??[]).find(t=>t._id===e)?.name??``}}return null},kt=e=>Tt(Et(String(e.active.id))),jt=(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:Ne(n(t?`folder:`:`chat:`))},[]),Nt=t=>{if(C===`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(C===`list`){let e=D?.chats.find(e=>e._id===t);return e?{list:D.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},Pt=t=>{if(C===`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(C===`list`){let e=D?.folders.find(e=>e._id===t);if(!e||!D)return null;let n=e.parentId??D.rootId;return{list:Qe(D.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},It=async e=>{Tt(null),St();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=wt(r);if(e!==void 0){if(o)await y({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Le(A??[],t,e)){a.error(_e());return}await _({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=Nt(t);if(!n)return;n.list.some(t=>t._id===e)||await y({chatId:e,projectId:n.folderId});let a=vt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await fe({chatId:e,...a});return}if(!o&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Pt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Le(A??[],e,n.parentId)){a.error(_e());return}await _({projectId:e,parentId:n.parentId})}let o=vt(n.list,e=>e._id,e=>e.sortKey,e,t);o&&await pe({projectId:e,...o});return}}catch{a.error(_e())}},[,Lt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Lt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Rt=Date.now(),zt=B(e.project),Bt=_t(e.chats,z),Vt=e.breadcrumb.slice(0,-1),Ht=e=>()=>{$.current||e()};return(0,Z.jsxs)(Ke,{sensors:gt,collisionDetection:jt,onDragStart:kt,onDragEnd:It,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":zt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":i(),children:[Vt.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Dt,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Ht(()=>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}),e.project.sidebarHidden?(0,Z.jsxs)(P,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:s(),onClick:()=>{ae({projectId:e.project._id,hidden:!1})},children:[(0,Z.jsx)(He,{"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:oe()}),(0,Z.jsx)(Be,{"aria-hidden":!0})]}):null,(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":Ee(),children:[(0,Z.jsx)(P,{variant:C===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ee(),title:Ee(),"aria-pressed":C===`cards`,onClick:()=>w(`cards`),children:(0,Z.jsx)(mt,{})}),(0,Z.jsx)(P,{variant:C===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":we(),title:we(),"aria-pressed":C===`columns`,onClick:()=>w(`columns`),children:(0,Z.jsx)(ft,{})}),(0,Z.jsx)(P,{variant:C===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":me(),title:me(),"aria-pressed":C===`list`,onClick:()=>w(`list`),children:(0,Z.jsx)(De,{})})]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void L({projectId:e.project._id}),children:[(0,Z.jsx)(Ye,{}),ye()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await r({title:E(),label:h(),placeholder:le(),confirmLabel:o()});t&&await ne({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(ke,{}),E()]}),(0,Z.jsxs)(Ve,{children:[(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":ie(),children:(0,Z.jsx)(Ge,{})})}),(0,Z.jsxs)(Ue,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(R,{onSelect:()=>{st(e.project.name),H(!0)},children:[(0,Z.jsx)(et,{}),` `,N()]}),(0,Z.jsxs)(R,{onSelect:()=>J(!0),children:[(0,Z.jsx)(pt,{}),` `,de()]}),(0,Z.jsx)(Pe,{children:ee()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e.project._id,color:null}),"aria-label":f(),children:`✕`}),at.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 l({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=x?.folders??0,a=x?.chats??0;await n({title:d({name:e.project.name}),description:i>0?Te({folders:i,chats:a}):a>0?se({count:a}):ce(),confirmWord:m(),confirmLabel:u(),destructive:!0})&&(await p({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Z.jsx)(nt,{}),` `,m()]})]})]})]})]}),C===`columns`?(0,Z.jsx)(Ft,{data:T,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:O??null}):C===`list`?(0,Z.jsx)(Mt,{data:D,busyIds:M,suppressClick:$,locateChatId:O??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:he()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(K,{items:e.children.map(e=>`folder:${e._id}`),strategy:dt,children:e.children.map(t=>(0,Z.jsx)(Ot,{child:t,parentId:e.project._id,now:Rt,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:Ce()}),e.chats.length>0?(0,Z.jsx)(W,{value:z,onChange:e=>rt(e.target.value),placeholder:be(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?ve():xe()}):Bt.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b({term:z.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(K,{items:Bt.map(e=>`chat:${e._id}`),strategy:q,children:Bt.map(t=>(0,Z.jsx)(At,{chat:t,currentFolderId:e.project._id,now:Rt,busy:M.has(t._id),unread:Fe.has(t._id),locate:t._id===O,suppressClick:$},t._id))})})]}),Y.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ue()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b({term:Y})}):(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&&Y&&We(e.messageId,Y),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(ut,{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||v()}),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)($e,{open:V,onOpenChange:H,title:re(),canSubmit:U.trim().length>0,onSubmit:async()=>{await c({projectId:e.project._id,name:U.trim()}),H(!1)},submitLabel:N(),children:(0,Z.jsx)(W,{value:U,onChange:e=>st(e.target.value),autoFocus:!0})}),ct?(0,Z.jsx)(ot,{open:ct,onOpenChange:J,title:te(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void _({projectId:e.project._id,parentId:t})}):null,qe]}),(0,Z.jsx)(je,{children:Ct?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Ct.kind===`folder`?(0,Z.jsx)(G,{size:13,"aria-hidden":!0}):(0,Z.jsx)(ut,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:Ct.label})]}):null})]})}function Dt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=L({id:Ct(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Ot({child:e,parentId:t,now:n,suppressClick:r}){let i=I(),a=z({id:`folder:${e._id}`}),o=L({id:$(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":B(e),transform:H.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)(G,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Z.jsx)(Q,{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})+` · `:``,A({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:rt(e.lastActivityAt,n)})]})}function kt({chat:e}){let t=k(j.chats.setChatSidebar),n=e.inSidebar?x():M();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)(qe,{}):(0,Z.jsx)(Y,{})})}function At({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=I(),c=V(e.color),l=z({id:`chat:${e._id}`}),u=jt(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:H.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||g()}),e.pinned?(0,Z.jsx)(J,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:rt(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:p(),"aria-label":p()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:T(),"aria-label":T()}):null]}),(0,Z.jsx)(kt,{chat:e}),(0,Z.jsx)(gt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function jt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Mt({data:e,busyIds:t,suppressClick:n,locateChatId:i}){let[a,o]=(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:r()});if(e===null)return null;let c=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),l=(r,o)=>{let u=s.get(r??e.rootId)??[],d=Qe(e.folders,r);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{items:u.map(e=>`chat:${e._id}`),strategy:q,children:u.map(e=>(0,Z.jsx)(Pt,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===i,suppressClick:n},e._id))}),(0,Z.jsx)(K,{items:d.map(e=>`folder:${e._id}`),strategy:q,children:d.map(t=>(0,Z.jsx)(Nt,{folder:t,parentId:r??e.rootId,depth:o,folded:a.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:a.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&&Qe(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ve()}):l(null,0)})}function Nt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=I(),c=z({id:`folder:${e._id}`}),l=L({id:$(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":B(e),transform:H.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?O():w(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)(Ae,{size:13}):(0,Z.jsx)(Fe,{size:13})}),(0,Z.jsx)(G,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(Q,{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 Pt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=I(),o=z({id:`chat:${e._id}`}),s=jt(r),c=V(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:H.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||g()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)(gt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(kt,{chat:e})]})}function Ft({data:e,currentId:t,busyIds:n,suppressClick:i,locateChatId:a}){let o=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=o.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:r()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:o,children:e.columns.map((r,o)=>(0,Z.jsx)(It,{col:r,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:i,locateChatId:a},r.folderId??`root`))})}function It({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=I(),s=L({id:St(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)(K,{items:e.folders.map(e=>`folder:${e._id}`),strategy:q,children:e.folders.map(t=>(0,Z.jsx)(Lt,{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)(K,{items:e.chats.map(e=>`chat:${e._id}`),strategy:q,children:e.chats.map(t=>(0,Z.jsx)(Rt,{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:xe()}):null]})}function Lt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=z({id:`folder:${e._id}`}),o=L({id:$(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":B(e),transform:H.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)(G,{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)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Rt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=z({id:`chat:${e._id}`}),s=jt(r),c=V(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:H.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||g()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)(gt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(kt,{chat:e})]})}export{Tt as ProjectPage};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$B as r,$v as i,Bv as a,By as o,Ct as s,Cy as c,D as l,Dy as u,Ey as d,Fv as f,Fy as p,Hv as m,Hy as h,Iv as ee,Iy as g,Jv as te,Lv as ne,Mv as _,My as re,Ny as ie,Pv as ae,Rg as v,Rv as y,St as oe,Ty as se,Uv as ce,Vy as le,Wv as ue,Xv as de,Yv as fe,Zv as pe,_y as me,ay as b,by as x,cV as S,cy as C,dy as he,ey as ge,fy as w,hy as _e,iy as ve,ky as T,ly as ye,my as E,ny as D,oy as be,py as O,ry as xe,sV as k,sy as A,t as j,ty as Se,uy as Ce,vy as we,wy as Te,xy as M,yy as Ee,zv as N}from"./api-B1lq0pb-.js";import{t as De}from"./list-DhABairq.js";import{t as P}from"./button-Ds98Pj53.js";import{A as Oe,An as ke,Bn as Ae,C as je,D as F,Dt as Me,E as Ne,Ft as Pe,Gn as I,Hn as Fe,It as Ie,J as Le,Kn as Re,Lt as ze,Mn as Be,Mt as Ve,Nn as He,Nt as Ue,O as L,P as We,Pn as Ge,Pt as R,S as Ke,Sn as qe,T as Je,Tn as Ye,U as Xe,W as Ze,Y as Qe,_ as $e,b as z,bn as et,d as tt,dn as nt,f as rt,g as B,h as V,j as H,jn as U,jt as W,k as it,kn as G,m as at,p as ot,qn as st,v as K,vn as ct,w as lt,wn as ut,x as q,y as dt,yn as J}from"./index-Bkfx3eIe.js";var ft=l(`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`}]]),pt=l(`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`}]]),mt=l(`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`}]]),Y=l(`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 ht({className:e}){return(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":a(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Ge,{})})})}function Q({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:a}){let s=k(j.projects.renameProject),l=k(j.projects.setProjectColor),p=k(j.projects.moveProject),g=k(j.projects.deleteProject),ne=k(j.projects.createProject),_=Xe(),ie=Ze(),[ae,v]=(0,X.useState)(!1),[y,oe]=(0,X.useState)(t),[ue,fe]=(0,X.useState)(!1),[pe,me]=(0,X.useState)(!1),b=S(j.projects.projectTreeCount,pe?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ve,{onOpenChange:e=>e&&me(!0),children:[(0,Z.jsx)(ht,{className:i}),(0,Z.jsxs)(Ue,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>a(),children:[(0,Z.jsx)(U,{}),` `,c()]}),(0,Z.jsxs)(R,{onSelect:()=>{oe(t),v(!0)},children:[(0,Z.jsx)(et,{}),` `,N()]}),(0,Z.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await ie({title:E(),label:h(),placeholder:le(),confirmLabel:o()});t&&await ne({name:t,parentId:e})})},children:[(0,Z.jsx)(ke,{}),` `,E()]}),(0,Z.jsxs)(R,{onSelect:()=>fe(!0),children:[(0,Z.jsx)(pt,{}),` `,de()]}),(0,Z.jsx)(Pe,{children:ee()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e,color:null}),"aria-label":f(),children:`✕`}),at.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 l({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=b?.folders??0,r=b?.chats??0;await _({title:d({name:t}),description:n>0?Te({folders:n,chats:r}):r>0?se({count:r}):ce(),confirmWord:m(),confirmLabel:u(),destructive:!0})&&await g({projectId:e})})},children:[(0,Z.jsx)(nt,{}),` `,m()]})]})]}),(0,Z.jsx)($e,{open:ae,onOpenChange:v,title:re(),canSubmit:y.trim().length>0,onSubmit:async()=>{await s({projectId:e,name:y.trim()}),v(!1)},submitLabel:N(),children:(0,Z.jsx)(W,{value:y,onChange:e=>oe(e.target.value),autoFocus:!0})}),ue?(0,Z.jsx)(ot,{open:ue,onOpenChange:fe,title:te(),movingFolderId:e,currentId:r,onPick:t=>void p({projectId:e,parentId:t})}):null]})}function gt({chat:e,currentFolderId:t,className:n}){let r=k(j.chats.pinChat),i=k(j.chats.deleteChat),a=k(j.chats.renameChat),o=k(j.chats.setChatSidebar),s=k(j.chats.moveChatToProject),c=Xe(),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(e.title??``),[p,h]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ve,{children:[(0,Z.jsx)(ht,{className:n}),(0,Z.jsxs)(Ue,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>{f(e.title??``),u(!0)},children:[(0,Z.jsx)(et,{}),` `,N()]}),(0,Z.jsxs)(R,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(ct,{}):(0,Z.jsx)(J,{}),e.pinned?y():ne()]}),(0,Z.jsxs)(R,{onSelect:()=>h(!0),children:[(0,Z.jsx)(pt,{}),` `,pe()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(R,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(qe,{}):(0,Z.jsx)(Y,{}),e.inSidebar?x():M()]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await c({title:ae(),description:ce(),confirmLabel:m(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Z.jsx)(nt,{}),` `,m()]})]})]}),(0,Z.jsx)($e,{open:l,onOpenChange:u,title:_(),canSubmit:d.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:d.trim()}),u(!1)},submitLabel:N(),children:(0,Z.jsx)(W,{value:d,onChange:e=>f(e.target.value),autoFocus:!0})}),p?(0,Z.jsx)(ot,{open:p,onOpenChange:h,title:fe(),currentId:t,onPick:t=>void s({chatId:e._id,projectId:t})}):null]})}function _t(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function vt(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 yt(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 bt=`oc.projpage.view`;function xt(){let e=localStorage.getItem(bt);return e===`cards`||e===`list`?e:`columns`}var $=e=>`into:${e}`,St=e=>`col:${e??`null`}`,Ct=e=>`crumb:${e}`;function wt(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 Tt(){let{projectId:e}=st({from:`/project/$projectId`}),t=I(),n=S(j.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:r()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:D()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Se()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:ge()})]}):(0,Z.jsx)(Et,{page:n})})}function Et({page:e}){let t=I(),n=Xe(),r=Ze(),a=Me(),c=k(j.projects.renameProject),l=k(j.projects.setProjectColor),p=k(j.projects.deleteProject),ne=k(j.projects.createProject),_=k(j.projects.moveProject),ae=k(j.projects.setProjectSidebar),y=k(j.chats.moveChatToProject),fe=k(j.chats.reorderChat),pe=k(j.projects.reorderProject),x=S(j.projects.projectTreeCount,{projectId:e.project._id}),[C,ge]=(0,X.useState)(xt),w=e=>{localStorage.setItem(bt,e),ge(e)},T=S(j.projects.folderColumns,C===`columns`?{projectId:e.project._id}:`skip`),D=S(j.projects.projectTreeList,C===`list`?{projectId:e.project._id}:`skip`),{c:O}=Re({from:`/project/$projectId`}),A=S(j.projects.listProjects,{}),Se=S(j.chatReads.myBusyChats,{}),M=(0,X.useMemo)(()=>new Set(Se??[]),[Se]),Ae=S(j.chatReads.myChatReads,{}),Fe=(0,X.useMemo)(()=>yt(e.chats,Ae??[]),[e.chats,Ae]),{startNewChat:L,picker:qe}=tt(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[z,rt]=(0,X.useState)(``),[V,H]=(0,X.useState)(!1),[U,st]=(0,X.useState)(e.project.name),[ct,J]=(0,X.useState)(!1),[Y,ht]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ht(z.trim()),180);return()=>clearTimeout(e)},[z]);let Q=S(j.search.searchConversations,Y.length>=2?{query:Y,projectId:e.project._id}:`skip`),gt=Oe(it(lt,{activationConstraint:{distance:4}}),it(Je,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),St=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[Ct,Tt]=(0,X.useState)(null),Et=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||g()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(A??[]).find(t=>t._id===e)?.name??``}}return null},kt=e=>Tt(Et(String(e.active.id))),jt=(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:Ne(n(t?`folder:`:`chat:`))},[]),Nt=t=>{if(C===`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(C===`list`){let e=D?.chats.find(e=>e._id===t);return e?{list:D.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},Pt=t=>{if(C===`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(C===`list`){let e=D?.folders.find(e=>e._id===t);if(!e||!D)return null;let n=e.parentId??D.rootId;return{list:Qe(D.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},It=async e=>{Tt(null),St();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=wt(r);if(e!==void 0){if(o)await y({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Le(A??[],t,e)){a.error(_e());return}await _({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=Nt(t);if(!n)return;n.list.some(t=>t._id===e)||await y({chatId:e,projectId:n.folderId});let a=vt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await fe({chatId:e,...a});return}if(!o&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Pt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Le(A??[],e,n.parentId)){a.error(_e());return}await _({projectId:e,parentId:n.parentId})}let o=vt(n.list,e=>e._id,e=>e.sortKey,e,t);o&&await pe({projectId:e,...o});return}}catch{a.error(_e())}},[,Lt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Lt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Rt=Date.now(),zt=B(e.project),Bt=_t(e.chats,z),Vt=e.breadcrumb.slice(0,-1),Ht=e=>()=>{$.current||e()};return(0,Z.jsxs)(Ke,{sensors:gt,collisionDetection:jt,onDragStart:kt,onDragEnd:It,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":zt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":i(),children:[Vt.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Dt,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Ht(()=>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}),e.project.sidebarHidden?(0,Z.jsxs)(P,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:s(),onClick:()=>{ae({projectId:e.project._id,hidden:!1})},children:[(0,Z.jsx)(He,{"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:oe()}),(0,Z.jsx)(Be,{"aria-hidden":!0})]}):null,(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":Ee(),children:[(0,Z.jsx)(P,{variant:C===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ee(),title:Ee(),"aria-pressed":C===`cards`,onClick:()=>w(`cards`),children:(0,Z.jsx)(mt,{})}),(0,Z.jsx)(P,{variant:C===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":we(),title:we(),"aria-pressed":C===`columns`,onClick:()=>w(`columns`),children:(0,Z.jsx)(ft,{})}),(0,Z.jsx)(P,{variant:C===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":me(),title:me(),"aria-pressed":C===`list`,onClick:()=>w(`list`),children:(0,Z.jsx)(De,{})})]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void L({projectId:e.project._id}),children:[(0,Z.jsx)(Ye,{}),ye()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await r({title:E(),label:h(),placeholder:le(),confirmLabel:o()});t&&await ne({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(ke,{}),E()]}),(0,Z.jsxs)(Ve,{children:[(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":ie(),children:(0,Z.jsx)(Ge,{})})}),(0,Z.jsxs)(Ue,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(R,{onSelect:()=>{st(e.project.name),H(!0)},children:[(0,Z.jsx)(et,{}),` `,N()]}),(0,Z.jsxs)(R,{onSelect:()=>J(!0),children:[(0,Z.jsx)(pt,{}),` `,de()]}),(0,Z.jsx)(Pe,{children:ee()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e.project._id,color:null}),"aria-label":f(),children:`✕`}),at.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 l({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=x?.folders??0,a=x?.chats??0;await n({title:d({name:e.project.name}),description:i>0?Te({folders:i,chats:a}):a>0?se({count:a}):ce(),confirmWord:m(),confirmLabel:u(),destructive:!0})&&(await p({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Z.jsx)(nt,{}),` `,m()]})]})]})]})]}),C===`columns`?(0,Z.jsx)(Ft,{data:T,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:O??null}):C===`list`?(0,Z.jsx)(Mt,{data:D,busyIds:M,suppressClick:$,locateChatId:O??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:he()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(K,{items:e.children.map(e=>`folder:${e._id}`),strategy:dt,children:e.children.map(t=>(0,Z.jsx)(Ot,{child:t,parentId:e.project._id,now:Rt,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:Ce()}),e.chats.length>0?(0,Z.jsx)(W,{value:z,onChange:e=>rt(e.target.value),placeholder:be(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?ve():xe()}):Bt.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b({term:z.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(K,{items:Bt.map(e=>`chat:${e._id}`),strategy:q,children:Bt.map(t=>(0,Z.jsx)(At,{chat:t,currentFolderId:e.project._id,now:Rt,busy:M.has(t._id),unread:Fe.has(t._id),locate:t._id===O,suppressClick:$},t._id))})})]}),Y.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ue()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b({term:Y})}):(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&&Y&&We(e.messageId,Y),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(ut,{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||v()}),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)($e,{open:V,onOpenChange:H,title:re(),canSubmit:U.trim().length>0,onSubmit:async()=>{await c({projectId:e.project._id,name:U.trim()}),H(!1)},submitLabel:N(),children:(0,Z.jsx)(W,{value:U,onChange:e=>st(e.target.value),autoFocus:!0})}),ct?(0,Z.jsx)(ot,{open:ct,onOpenChange:J,title:te(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void _({projectId:e.project._id,parentId:t})}):null,qe]}),(0,Z.jsx)(je,{children:Ct?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Ct.kind===`folder`?(0,Z.jsx)(G,{size:13,"aria-hidden":!0}):(0,Z.jsx)(ut,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:Ct.label})]}):null})]})}function Dt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=L({id:Ct(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Ot({child:e,parentId:t,now:n,suppressClick:r}){let i=I(),a=z({id:`folder:${e._id}`}),o=L({id:$(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":B(e),transform:H.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)(G,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Z.jsx)(Q,{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})+` · `:``,A({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:rt(e.lastActivityAt,n)})]})}function kt({chat:e}){let t=k(j.chats.setChatSidebar),n=e.inSidebar?x():M();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)(qe,{}):(0,Z.jsx)(Y,{})})}function At({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=I(),c=V(e.color),l=z({id:`chat:${e._id}`}),u=jt(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:H.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||g()}),e.pinned?(0,Z.jsx)(J,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:rt(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:p(),"aria-label":p()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:T(),"aria-label":T()}):null]}),(0,Z.jsx)(kt,{chat:e}),(0,Z.jsx)(gt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function jt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Mt({data:e,busyIds:t,suppressClick:n,locateChatId:i}){let[a,o]=(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:r()});if(e===null)return null;let c=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),l=(r,o)=>{let u=s.get(r??e.rootId)??[],d=Qe(e.folders,r);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{items:u.map(e=>`chat:${e._id}`),strategy:q,children:u.map(e=>(0,Z.jsx)(Pt,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===i,suppressClick:n},e._id))}),(0,Z.jsx)(K,{items:d.map(e=>`folder:${e._id}`),strategy:q,children:d.map(t=>(0,Z.jsx)(Nt,{folder:t,parentId:r??e.rootId,depth:o,folded:a.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:a.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&&Qe(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ve()}):l(null,0)})}function Nt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=I(),c=z({id:`folder:${e._id}`}),l=L({id:$(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":B(e),transform:H.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?O():w(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)(Ae,{size:13}):(0,Z.jsx)(Fe,{size:13})}),(0,Z.jsx)(G,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(Q,{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 Pt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=I(),o=z({id:`chat:${e._id}`}),s=jt(r),c=V(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:H.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||g()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)(gt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(kt,{chat:e})]})}function Ft({data:e,currentId:t,busyIds:n,suppressClick:i,locateChatId:a}){let o=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=o.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:r()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:o,children:e.columns.map((r,o)=>(0,Z.jsx)(It,{col:r,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:i,locateChatId:a},r.folderId??`root`))})}function It({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=I(),s=L({id:St(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)(K,{items:e.folders.map(e=>`folder:${e._id}`),strategy:q,children:e.folders.map(t=>(0,Z.jsx)(Lt,{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)(K,{items:e.chats.map(e=>`chat:${e._id}`),strategy:q,children:e.chats.map(t=>(0,Z.jsx)(Rt,{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:xe()}):null]})}function Lt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=z({id:`folder:${e._id}`}),o=L({id:$(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":B(e),transform:H.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)(G,{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)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Rt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=z({id:`chat:${e._id}`}),s=jt(r),c=V(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:H.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||g()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)(gt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(kt,{chat:e})]})}export{Tt as ProjectPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bx as r,Fc as i,Fo as a,Fx as o,Go as s,Gx as c,Hx as l,Ic as u,Io as d,Ix as f,Jx as p,Ko as m,Kx as h,Lx as g,Mc as ee,Mo as te,Nc as ne,No as _,Nx as v,Pc as y,Po as b,Px as x,Qx as S,Rx as C,Uo as w,Ux as T,Vx as re,Wo as ie,Wx as ae,Xx as oe,Yx as E,Zx as D,aS as O,cV as k,ia as A,na as j,oS as M,qx as N,ra as P,sV as F,t as I,yt as L,zx as R}from"./api-B1lq0pb-.js";import{i as z,n as B,r as V,t as H}from"./FieldLabel-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bx as r,Fc as i,Fo as a,Fx as o,Go as s,Gx as c,Hx as l,Ic as u,Io as d,Ix as f,Jx as p,Ko as m,Kx as h,Lx as g,Mc as ee,Mo as te,Nc as ne,No as _,Nx as v,Pc as y,Po as b,Px as x,Qx as S,Rx as C,Uo as w,Ux as T,Vx as re,Wo as ie,Wx as ae,Xx as oe,Yx as E,Zx as D,aS as O,cV as k,ia as A,na as j,oS as M,qx as N,ra as P,sV as F,t as I,yt as L,zx as R}from"./api-B1lq0pb-.js";import{i as z,n as B,r as V,t as H}from"./FieldLabel-CgbnOAaa.js";import{t as U}from"./button-Ds98Pj53.js";import{$ as W,Dt as se,Q as G,Qt as K,X as q,Xt as ce,Yt as J,Z as Y,Zt as le,et as X,q as ue,ut as de}from"./index-Bkfx3eIe.js";import{r as Z,t as fe}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),me={media_delivery:{label:N,help:h},documentary_fetch:{label:c,help:ae},inbound_files:{label:T,help:l},history_summary:{label:u,help:i},file_curation:{label:m,help:d},quote_reply:{label:s,help:ie}},he={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.`},ge={outboundDir:o,references:x,files:v,previous_summary:y,new_messages:ne,max_chars:ee,file_name:a,budget_chars:b,feedback:_,content:te,excerpt:w};function _e(){let e=k(I.admin.listInstances,{}),[t,n]=(0,Q.useState)(null);if(e===void 0)return(0,$.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,$.jsx)(`div`,{className:`oc-injtab`,children:(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:r()})});let i=e.find(e=>e._id===t)??e[0];return(0,$.jsxs)(`div`,{className:`oc-injtab`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,$.jsx)(B,{label:S(),help:D()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:re()}),(0,$.jsxs)(q,{value:i._id,onValueChange:e=>n(e),children:[(0,$.jsx)(W,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(X,{})}),(0,$.jsx)(Y,{children:e.map(e=>(0,$.jsx)(G,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,$.jsx)(ve,{instance:i},i._id)]})}function ve({instance:e}){let t=F(I.admin.upsertInstanceConfig),n=se(),r=k(I.me.getMe,{host:ue}),i=e.config??{},a=Z(e.config?.contentLocale,r?.defaultLocale??void 0),[o,s]=(0,Q.useState)(()=>z(i,a));(0,Q.useEffect)(()=>{s(z(i,a))},[a,e._id]);let[c,l]=(0,Q.useState)(!1),u=o.promptInjections,d=(e,t)=>s({...o,promptInjections:{...u,[e]:{...u[e],...t}}});async function f(){l(!0);try{await t({instanceId:e._id,config:V(o,i,a)})}catch(e){n.error(O(),e)}finally{l(!1)}}async function p(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(O(),e)}}let m=e.config?.contentLocale??`default`,h=fe[Z(void 0,r?.defaultLocale??void 0)];return(0,$.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,$.jsx)(`span`,{children:A()}),(0,$.jsxs)(q,{value:m,onValueChange:e=>void p(e),children:[(0,$.jsx)(W,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(X,{})}),(0,$.jsxs)(Y,{children:[(0,$.jsx)(G,{value:`default`,children:j({locale:h})}),pe().map(e=>(0,$.jsx)(G,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:P()})]}),ce.map(e=>(0,$.jsx)(ye,{injKey:e,def:J[e],i18n:me[e],row:u[e]??{enabled:!0,template:J[e].defaultTemplate[a]},contentLocale:a,onChange:t=>d(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(U,{size:`sm`,onClick:()=>void f(),disabled:c,children:M()})})]})}function ye({injKey:e,def:t,i18n:n,row:r,contentLocale:i,onChange:a}){let[o,s]=(0,Q.useState)(!1),c=r.template.trim()!==t.defaultTemplate[i],l=t.togglable&&!r.enabled,u=Object.fromEntries(t.placeholders.map(e=>[e,he[e]??`{${e}}`])),d=le(e,r,i),m=d?K(d,u):``;return(0,$.jsxs)(`section`,{className:`oc-injcard`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,$.jsxs)(`label`,{className:`oc-field--row`,children:[(0,$.jsx)(de,{checked:r.enabled,onCheckedChange:e=>a({enabled:e===!0})}),(0,$.jsx)(B,{label:n.label(),help:n.help()})]}):(0,$.jsx)(B,{label:n.label(),help:n.help()}),c&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:E()})]}),(0,$.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:l,rows:8,spellCheck:!1,onChange:e=>a({template:e.target.value})}),(0,$.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:p()}),t.placeholders.map(e=>(0,$.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,$.jsx)(`code`,{children:`{${e}}`}),(0,$.jsx)(H,{text:(ge[e]??(()=>e))()})]},e))]}),(0,$.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,$.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>s(e=>!e),children:o?C():R()}),c&&(0,$.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>a({template:t.defaultTemplate[i]}),children:oe()})]})]}),o&&(0,$.jsx)(`div`,{className:`oc-injcard__preview`,children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:m}),(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:g()}),t.pluralDefaultTemplate!==void 0&&!l?(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:L()}):null]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:f()})})]})}export{_e as PromptInjectionsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$T as r,AT as ee,BT as i,CT as te,DT as a,ET as o,FT as s,GT as c,HT as l,IT as u,JT as d,KT as f,LT as ne,MT as re,NT as ie,OT as ae,PT as p,QT as m,RT as h,TT as g,UT as _,VT as v,WT as y,XT as b,YT as x,ZT as S,_T as C,cV as w,dT as T,fT as E,gT as D,gs as O,hT as k,jT as A,kT as j,lT as M,mT as N,pT as P,qT as F,sV as I,t as L,uT as oe,wT as R,zT as z}from"./api-B1lq0pb-.js";import{t as B}from"./button-Ds98Pj53.js";import{Dt as V,En as H,Et as U,U as W,_ as G,jt as K,ut as q}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$T as r,AT as ee,BT as i,CT as te,DT as a,ET as o,FT as s,GT as c,HT as l,IT as u,JT as d,KT as f,LT as ne,MT as re,NT as ie,OT as ae,PT as p,QT as m,RT as h,TT as g,UT as _,VT as v,WT as y,XT as b,YT as x,ZT as S,_T as C,cV as w,dT as T,fT as E,gT as D,gs as O,hT as k,jT as A,kT as j,lT as M,mT as N,pT as P,qT as F,sV as I,t as L,uT as oe,wT as R,zT as z}from"./api-B1lq0pb-.js";import{t as B}from"./button-Ds98Pj53.js";import{Dt as V,En as H,Et as U,U as W,_ as G,jt as K,ut as q}from"./index-Bkfx3eIe.js";import{t as J}from"./roleDescriptions-BV5RwGCx.js";var Y=t(e(),1),X=n(),Z=[{group:()=>r(),keys:[{key:`traces.read`,label:()=>d()},{key:`traces.read.content`,label:()=>F(),phi:!0},{key:`traces.write`,label:()=>f()}]},{group:()=>m(),keys:[{key:`kpi.read`,label:()=>d()},{key:`kpi.write`,label:()=>f()}]},{group:()=>S(),keys:[{key:`openclaw.query`,label:()=>c()},{key:`anomalies.read`,label:()=>y()},{key:`anomalies.report`,label:()=>_()}]},{group:()=>b(),keys:[{key:`chats.read`,label:()=>d()},{key:`selfheal`,label:()=>v()},{key:`media.repair`,label:()=>i()},{key:`feedback.respond`,label:()=>O()}]},{group:()=>x(),keys:[{key:`admin.manage`,label:()=>l()}]}],se=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function ce(){let e=w(L.apiKeys.listRoles,{}),t=I(L.apiKeys.createRole),n=I(L.apiKeys.ensureRolesSeeded),r=I(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))}),i=W(),c=V(),[l,d]=(0,Y.useState)(!1),[f,m]=(0,Y.useState)($),[_,v]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{c.error(h(),e)})},[n,c]);let y=e??[];async function b(e,t){if(Q(e.permissions))return;if(e.builtin){await i({title:ne({name:e.name}),description:u(),confirmLabel:s()});return}if(_.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];v(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){c.error(p(),e)}finally{v(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function x(){try{await t({key:f.key,name:f.name,description:f.description||void 0,permissions:[]}),m($),d(!1)}catch(e){c.error(ie(),e)}}let S=e===void 0,O=!S&&y.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[re(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,A(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,ee()]}),(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:j()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{m($),d(!0)},children:ae()})})]}),S?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):O?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(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:g()}),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?z({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:y.map(e=>{let t=Q(e.permissions),n=_.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)(U,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(H,{}),` `,R()]}):(0,X.jsx)(U,{variant:`secondary`,children:te()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),se.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(q,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?C():n?D():r,onCheckedChange:()=>void b(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(G,{open:l,onOpenChange:d,title:k(),description:N(),canSubmit:!!(f.key&&f.name),onSubmit:x,submitLabel:P(),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:E()}),(0,X.jsx)(K,{value:f.key,placeholder:T(),onChange:e=>m({...f,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:oe()}),(0,X.jsx)(K,{value:f.name,onChange:e=>m({...f,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:M()}),(0,X.jsx)(K,{value:f.description,onChange:e=>m({...f,description:e.target.value})})]})]})})]})}export{ce as RolesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$B as r,$R as i,AR as a,Az as o,BL as s,CR as c,Cz as l,D as u,Dz as ee,Ez as te,FL as d,FR as f,Fz as p,GL as ne,GR as re,HL as ie,HR as ae,IL as oe,IR as se,Iz as ce,JL as le,JR as ue,KL as de,KR as fe,LL as pe,LR as me,Lz as he,MR as ge,Mz as _e,NR as ve,Nz as ye,OR as be,Oz as xe,PR as Se,Pz as Ce,QL as we,QR as Te,RL as Ee,SR as De,Sz as Oe,Tz as ke,UL as Ae,UR as je,VL as Me,WL as Ne,WR as Pe,XL as Fe,XR as m,YL as Ie,YR as Le,ZL as Re,_R as ze,aV as h,bR as g,cR as Be,cV as Ve,dR as He,ez as Ue,fR as _,gR as We,hR as Ge,jR as Ke,jz as qe,kL as Je,kR as Ye,kz as Xe,lR as Ze,mR as Qe,nz as $e,pR as et,qL as tt,qR as nt,rz as rt,t as v,tV as y,tz as it,uR as b,vR as at,wz as ot,xR as x,yR as st,zL as ct,zR as lt}from"./api-B1lq0pb-.js";import{t as ut}from"./list-DhABairq.js";import{t as S}from"./button-Ds98Pj53.js";import{$ as C,Bn as w,Bt as T,Ct as dt,Dn as ft,Dt as pt,Et as E,Q as D,Rt as O,St as mt,Tt as ht,Vn as k,X as A,Z as j,_n as gt,_t,at as vt,bn as yt,bt,dn as xt,et as M,gt as St,hn as Ct,it as wt,jt as Tt,nt as Et,on as Dt,ot as Ot,q as kt,rt as At,tt as jt,vt as Mt,wt as Nt,xn as Pt,xt as Ft,yt as It,zt as N}from"./index-DMM3fags.js";import{a as Lt,i as P,n as Rt,o as zt,r as F,t as Bt}from"./table-B15ESmxP.js";import{t as Vt}from"./FilterBar-CK5Wsnof.js";/* empty css */import{a as Ht,c as I,i as L,l as Ut,n as Wt,o as R,r as Gt,s as Kt,t as qt,u as z}from"./TimezoneCombobox-DeJ3e50i.js";var Jt=u(`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=u(`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`}]]),B=t(e(),1),V=n();function H(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=Ut(e),r=(0,B.useMemo)(()=>new Date,[]),[i,a]=(0,B.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[o,s]=(0,B.useState)(!1),l=(0,B.useMemo)(()=>H(y()),[]),u=(0,B.useMemo)(()=>new Intl.DateTimeFormat(y(),{month:`long`,year:`numeric`}),[]),ee=(0,B.useMemo)(()=>new Intl.DateTimeFormat(y(),{dateStyle:`medium`,timeStyle:`short`}),[]),te=I(i.year,i.month),d=n?.hour??9,f=n?.minute??0,p=(e,n,r,i,a)=>t(z(e,n,r,i,a)),ne=(e,t,n)=>{a({year:e,month:t}),p(e,t,n,d,f)},re=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},ie=n===null?De():ee.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,V.jsxs)(O,{modal:!0,open:o,onOpenChange:s,children:[(0,V.jsx)(T,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":c(),children:[(0,V.jsx)(Jt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,V.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:ie})]})}),(0,V.jsxs)(N,{align:`start`,className:`oc-dtp__pop`,children:[(0,V.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":x(),onClick:()=>re(-1),children:(0,V.jsx)(k,{size:15,"aria-hidden":!0})}),(0,V.jsx)(`span`,{className:`oc-dtp__month`,children:u.format(new Date(i.year,i.month,1))}),(0,V.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":g(),onClick:()=>re(1),children:(0,V.jsx)(w,{size:15,"aria-hidden":!0})})]}),(0,V.jsxs)(`div`,{className:`oc-dtp__grid`,children:[l.map((e,t)=>(0,V.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),te.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,V.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:()=>ne(e.year,e.month,e.day),children:e.day},t)})]}),(0,V.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,V.jsxs)(A,{value:String(d),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),Number(e),f),children:[(0,V.jsx)(C,{size:`sm`,"aria-label":st(),children:(0,V.jsx)(M,{})}),(0,V.jsx)(j,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,V.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,V.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,V.jsxs)(A,{value:String(f),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),d,Number(e)),children:[(0,V.jsx)(C,{size:`sm`,"aria-label":at(),children:(0,V.jsx)(M,{})}),(0,V.jsx)(j,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,V.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function U(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=U(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 W(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 G=3;function nn({events:e,mode:t,cursor:n,onModeChange:r,onCursorChange:i,onEventClick:a,footnote:o}){let s=y(),c=(0,B.useMemo)(()=>Qt(e),[e]),l=(0,B.useMemo)(()=>$t(s),[s]),u=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`,year:`numeric`}),[s]),ee=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`}),[s]),te=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}),[s]),d=new Date,f=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()})},p=t===`year`?String(n.year):u.format(new Date(n.year,n.month,1));return(0,V.jsxs)(`div`,{className:`oc-cal`,children:[(0,V.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,V.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":He(),onClick:()=>f(-1),children:(0,V.jsx)(k,{})}),(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":b(),onClick:()=>f(1),children:(0,V.jsx)(w,{})}),(0,V.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>i({year:d.getFullYear(),month:d.getMonth()}),children:_()})]}),(0,V.jsx)(`span`,{className:`oc-cal__title`,children:p}),(0,V.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,V.jsx)(S,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:Qe()}),(0,V.jsx)(S,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:et()})]})]}),t===`month`?(0,V.jsx)(rn,{cursor:n,byDay:c,weekdays:l,timeFmt:te,now:d,onEventClick:a}):(0,V.jsx)(an,{year:n.year,byDay:c,monthShortFmt:ee,now:d,onOpenMonth:e=>{i({year:n.year,month:e}),r(`month`)}}),o?(0,V.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=I(e.year,e.month);return(0,V.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,V.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,V.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,V.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,G).map(e=>(0,V.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,V.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,V.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>G?(0,V.jsx)(`span`,{className:`oc-cal__more`,children:Ze({count:o.length-G})}):null]},n)})]})}function an({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,V.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=W(t,e,o),c=I(e,o);return(0,V.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,V.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,V.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,V.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var on={h:36e5,min:6e4,s:1e3,ms:1};function sn(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])*on[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 K(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 q(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=K(t[0],0,59),r=K(t[1],0,23),i=K(t[2],1,31),a=K(t[3],1,12),o=K(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 cn=new Map;function J(e){let t=cn.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 cn.set(e,n),n}function Y(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 X(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=Y(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 Z(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=q(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=Y(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=X(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=X(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 Q=`crons`;function ln(e,t){return`${e}\u0000${t}`}function un(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=ln(a.instanceName,e.id);i.set(o,a);let s=R(e)!==`active`,c=Z(s?null:sn(e.schedule),e.nextRunAtMs,t,n);for(let t of c)r.push({id:`${o}:${t.atMs}`,sourceId:Q,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:s,exact:t.exact})}return{events:r,byItemId:i}}var $={minutes:6e4,hours:36e5,days:864e5};function dn(e){return e?.data?.code??`unknown`}function fn({status:e}){switch(Kt(e)){case`ok`:return(0,V.jsx)(E,{variant:`secondary`,children:se()});case`error`:return(0,V.jsx)(E,{variant:`destructive`,children:Se()});case`running`:return(0,V.jsx)(E,{variant:`outline`,children:ve()});case`other`:return(0,V.jsx)(E,{variant:`outline`,children:e});case`none`:return(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function pn(){let e=h(v.scheduled.listMyCrons),t=h(v.scheduled.getCronDetail),n=h(v.scheduled.listCronRuns),c=h(v.scheduled.updateCron),u=h(v.scheduled.removeCron),De=h(v.scheduled.runCronNow),g=pt(),He=Ve(v.me.getMe,{host:kt})?.timezone,[_,Ze]=(0,B.useState)(null),[Qe,et]=(0,B.useState)(!1),[b,at]=(0,B.useState)(!1),[x,st]=(0,B.useState)(null),[w,T]=(0,B.useState)(null),[O,k]=(0,B.useState)(null),[N,I]=(0,B.useState)(null),[Ut,Kt]=(0,B.useState)(!1),[z,H]=(0,B.useState)(Wt),[U,Zt]=(0,B.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)},[W,$t]=(0,B.useState)(`month`),[G,rn]=(0,B.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),an=(0,B.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,z)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[_,z]),on=(0,B.useMemo)(()=>W===`year`?tn(G.year):en(G.year,G.month),[W,G]),sn=(0,B.useMemo)(()=>un(an,on.startMs,on.endMs),[an,on]),K=e=>{let t=sn.byItemId.get(e.itemId);t===void 0||!t.canEdit||t.job.id===null||pn(t.instanceName,t.job)},q=(0,B.useCallback)(async()=>{et(!0),at(!1);try{Ze(await e({}))}catch{at(!0)}finally{et(!1)}},[e]);(0,B.useEffect)(()=>{q()},[q]);let cn=(0,B.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),J=(0,B.useRef)(null);(0,B.useEffect)(()=>{_!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[_]);let Y=(0,B.useMemo)(()=>new Intl.DateTimeFormat(y(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{st(e);try{await t(),g.success(n),await q()}catch(e){g.toast({variant:`error`,title:m({code:dn(e)})})}finally{st(null)}},Z=(0,B.useRef)(0),Q=(0,B.useRef)(0),ln=async(e,t)=>{if(t.id===null)return;let r=++Z.current;k({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Z.current)return;k({name:t.name??t.id,entries:i})}catch(e){if(r!==Z.current)return;k(null),g.toast({variant:`error`,title:m({code:dn(e)})})}},pn=async(e,n)=>{if(n.id===null)return;let r=++Q.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%$.days===0?(s=String(e/$.days),c=`days`):e%$.hours===0?(s=String(e/$.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/$.minutes))),c=`minutes`))}if(r!==Q.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!==Q.current)return;I(null),g.toast({variant:`error`,title:m({code:dn(e)})})}},mn=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:d()});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*$[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:oe()});return}if(N.messageDirty&&N.hasMessage&&N.message.trim()!==``&&(e.message=N.message.trim()),Object.keys(e).length===0){I(null);return}let t=Q.current;Kt(!0);try{await c({instanceName:N.instanceName,jobId:N.jobId,patch:e}),g.success(Ie()),t===Q.current&&I(null),await q()}catch(e){g.toast({variant:`error`,title:m({code:dn(e)})})}finally{Kt(!1)}},hn=_?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,V.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:he()}),(0,V.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":ze(),children:[(0,V.jsx)(S,{variant:U===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":We(),title:We(),"aria-pressed":U===`list`,onClick:()=>Qt(`list`),children:(0,V.jsx)(ut,{})}),(0,V.jsx)(S,{variant:U===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ge(),title:Ge(),"aria-pressed":U===`calendar`,onClick:()=>Qt(`calendar`),children:(0,V.jsx)(Jt,{})})]}),(0,V.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>void q(),disabled:Qe,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,V.jsx)(Ct,{size:14,"aria-hidden":!0}),ce()]})]}),_!==null&&hn>0?(0,V.jsxs)(Vt,{q:z.q,onQChange:e=>H(t=>({...t,q:e})),searchPlaceholder:Ke(),onReset:()=>H(Wt),canReset:Gt(z),children:[(0,V.jsxs)(A,{value:z.state,onValueChange:e=>H(t=>({...t,state:e})),children:[(0,V.jsx)(C,{size:`sm`,className:`w-40`,children:(0,V.jsx)(M,{})}),(0,V.jsxs)(j,{children:[(0,V.jsx)(D,{value:`all`,children:a()}),(0,V.jsx)(D,{value:`active`,children:l()}),(0,V.jsx)(D,{value:`paused`,children:ot()}),(0,V.jsx)(D,{value:`auto-disabled`,children:Oe()})]})]}),(0,V.jsxs)(A,{value:z.result,onValueChange:e=>H(t=>({...t,result:e})),children:[(0,V.jsx)(C,{size:`sm`,className:`w-40`,children:(0,V.jsx)(M,{})}),(0,V.jsxs)(j,{children:[(0,V.jsx)(D,{value:`all`,children:Ye()}),(0,V.jsx)(D,{value:`ok`,children:se()}),(0,V.jsx)(D,{value:`error`,children:Se()}),(0,V.jsx)(D,{value:`running`,children:ve()}),(0,V.jsx)(D,{value:`none`,children:ge()})]})]})]}):null,_===null?(0,V.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":Qe,children:b?p():r()}):U===`calendar`?(0,V.jsxs)(V.Fragment,{children:[b?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):null,_.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}):(0,V.jsx)(nn,{events:sn.events,mode:W,cursor:G,onModeChange:$t,onCursorChange:rn,onEventClick:K,footnote:Be()})]}):(0,V.jsxs)(V.Fragment,{children:[b?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):null,_.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}):null,_.map(e=>{let t=e.jobs.filter(e=>Ht(e,z)),n=Gt(z)&&e.jobs.length>0&&t.length===0;return(0,V.jsxs)(`section`,{style:{marginBottom:20},children:[_.length>1||e.error||!e.supported?(0,V.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,V.jsx)(E,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:_e({code:e.error})}):e.jobs.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:qe()}):n?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:be()}):(0,V.jsxs)(Bt,{children:[(0,V.jsx)(Lt,{children:(0,V.jsxs)(zt,{children:[(0,V.jsx)(P,{children:o()}),(0,V.jsx)(P,{children:Xe()}),(0,V.jsx)(P,{children:xe()}),(0,V.jsx)(P,{children:ee()}),(0,V.jsx)(P,{children:te()}),(0,V.jsx)(P,{children:me()}),(0,V.jsx)(P,{children:we()})]})}),(0,V.jsx)(Rt,{children:t.map((t,n)=>{let r=`${e.instanceName}:${t.id??n}`,a=x===r,o=e.manageSupported,s=e.kind===`openclaw`&&o;return(0,V.jsxs)(zt,{ref:t.id!==null&&t.id===cn?J:void 0,"data-state":t.id!==null&&t.id===cn?`selected`:void 0,children:[(0,V.jsx)(F,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??ke()}),(0,V.jsx)(F,{children:(0,V.jsx)(E,{variant:`secondary`,children:t.agentId})}),(0,V.jsxs)(F,{className:`whitespace-nowrap`,children:[(0,V.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=St(t.schedule),n=e===null?null:_t(e);return n===null?null:(0,V.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,V.jsx)(F,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:Y.format(t.nextRunAtMs)}),(0,V.jsx)(F,{children:R(t)===`auto-disabled`?(0,V.jsx)(E,{variant:`destructive`,title:`${t.autoDisabledReason??``}${t.autoDisabledAtMs===null?``:` · ${Y.format(t.autoDisabledAtMs)}`}`,children:Oe()}):R(t)===`active`?(0,V.jsx)(E,{variant:`secondary`,children:l()}):R(t)===`paused`?(0,V.jsx)(E,{variant:`outline`,children:ot()}):(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,V.jsxs)(F,{children:[(0,V.jsx)(fn,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,V.jsx)(E,{variant:`destructive`,title:t.lastDeliveryError??rt(),children:f()}):null]}),(0,V.jsx)(F,{className:`whitespace-nowrap`,children:t.id===null?(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,V.jsx)(ft,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,V.jsxs)(`span`,{className:`oc-cronactions`,children:[s?(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:it(),"aria-label":it(),disabled:x!==null,onClick:()=>void X(r,async()=>{let n=await De({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},Le()),children:(0,V.jsx)(Dt,{size:14,"aria-hidden":!0})}):null,s&&t.enabled!==null?(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:L(t)===`pause`?Ue():i(),"aria-label":L(t)===`pause`?Ue():i(),disabled:x!==null,onClick:()=>void X(r,()=>c({instanceName:e.instanceName,jobId:t.id,patch:{enabled:L(t)===`resume`}}),L(t)===`pause`?ue():nt()),children:L(t)===`pause`?(0,V.jsx)(Pt,{size:14,"aria-hidden":!0}):(0,V.jsx)(gt,{size:14,"aria-hidden":!0})}):null,s?(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Re(),"aria-label":Re(),disabled:x!==null,onClick:()=>void pn(e.instanceName,t),children:(0,V.jsx)(yt,{size:14,"aria-hidden":!0})}):null,s?(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Fe(),"aria-label":Fe(),disabled:x!==null,onClick:()=>void ln(e.instanceName,t),children:(0,V.jsx)(Yt,{size:14,"aria-hidden":!0})}):null,o?(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Te(),"aria-label":Te(),disabled:x!==null,onClick:()=>T({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,V.jsx)(xt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:ye()})]},e.instanceName)}),hn>0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Je()}):null]}),(0,V.jsx)(Mt,{open:w!==null,onOpenChange:e=>{e||T(null)},children:(0,V.jsxs)(Ft,{children:[(0,V.jsxs)(Nt,{children:[(0,V.jsx)(ht,{children:re()}),(0,V.jsx)(mt,{children:Pe({name:w?.name??``})})]}),(0,V.jsxs)(dt,{children:[(0,V.jsx)(bt,{children:je()}),(0,V.jsx)(It,{onClick:()=>{let e=w;T(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>u({instanceName:e.instanceName,jobId:e.jobId}),fe())},children:ae()})]})]})}),(0,V.jsx)(jt,{open:O!==null,onOpenChange:e=>{e||(Z.current++,k(null))},children:(0,V.jsxs)(Et,{style:{maxWidth:640},children:[(0,V.jsx)(vt,{children:(0,V.jsx)(Ot,{children:le({name:O?.name??``})})}),O?.entries===null?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):O!==null&&O.entries.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:tt()}):O===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:O.entries.map((e,t)=>(0,V.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,V.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,V.jsx)(fn,{status:e.status}),(0,V.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?Y.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,V.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,V.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[lt({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,V.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,V.jsx)(jt,{open:N!==null,onOpenChange:e=>{e||(Q.current++,I(null))},children:(0,V.jsxs)(Et,{className:`oc-cronedit`,children:[(0,V.jsxs)(vt,{children:[(0,V.jsx)(Ot,{children:de()}),(0,V.jsx)(At,{children:ne()})]}),N===null?null:N.loading?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,V.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:o()}),(0,V.jsx)(Tt,{value:N.name,maxLength:200,onChange:e=>I({...N,name:e.target.value,nameDirty:!0})})]}),(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Ne()}),(0,V.jsxs)(A,{value:N.scheduleKind,onValueChange:e=>I({...N,scheduleKind:e,scheduleDirty:!0}),children:[(0,V.jsx)(C,{children:(0,V.jsx)(M,{})}),(0,V.jsxs)(j,{children:[(0,V.jsx)(D,{value:`cron`,children:Ae()}),(0,V.jsx)(D,{value:`every`,children:ie()}),(0,V.jsx)(D,{value:`at`,children:Me()})]})]}),N.scheduleKind===`cron`?(0,V.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,V.jsx)(Tt,{value:N.cronExpr,onChange:e=>I({...N,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,V.jsx)(qt,{value:N.tz,onChange:e=>I({...N,tz:e,scheduleDirty:!0}),fallbackTz:He??void 0})]}):N.scheduleKind===`every`?(0,V.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,V.jsx)(Tt,{type:`number`,min:1,value:N.everyValue,onChange:e=>I({...N,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,V.jsxs)(A,{value:N.everyUnit,onValueChange:e=>I({...N,everyUnit:e,scheduleDirty:!0}),children:[(0,V.jsx)(C,{style:{maxWidth:160},children:(0,V.jsx)(M,{})}),(0,V.jsxs)(j,{children:[(0,V.jsx)(D,{value:`minutes`,children:s()}),(0,V.jsx)(D,{value:`hours`,children:ct()}),(0,V.jsx)(D,{value:`days`,children:Ee()})]})]})]}):(0,V.jsx)(Xt,{value:N.at,onChange:e=>I({...N,at:e,scheduleDirty:!0})})]}),N.hasMessage?(0,V.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:$e()}),(0,V.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:N.message,onChange:e=>I({...N,message:e.target.value,messageDirty:!0})})]}):null]}),(0,V.jsxs)(wt,{children:[(0,V.jsx)(S,{variant:`ghost`,onClick:()=>I(null),children:je()}),(0,V.jsxs)(S,{onClick:()=>void mn(),disabled:N===null||N.loading||Ut,children:[Ut?(0,V.jsx)(ft,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,pe()]})]})]})})]})}export{pn as ScheduledTab};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$B as r,$R as i,AR as a,Az as o,BL as s,CR as c,Cz as l,D as u,Dz as ee,Ez as te,FL as d,FR as f,Fz as p,GL as ne,GR as re,HL as ie,HR as ae,IL as oe,IR as se,Iz as ce,JL as le,JR as ue,KL as de,KR as fe,LL as pe,LR as me,Lz as he,MR as ge,Mz as _e,NR as ve,Nz as ye,OR as be,Oz as xe,PR as Se,Pz as Ce,QL as we,QR as Te,RL as Ee,SR as De,Sz as Oe,Tz as ke,UL as Ae,UR as je,VL as Me,WL as Ne,WR as Pe,XL as Fe,XR as m,YL as Ie,YR as Le,ZL as Re,_R as ze,aV as h,bR as g,cR as Be,cV as Ve,dR as He,ez as Ue,fR as _,gR as We,hR as Ge,jR as Ke,jz as qe,kL as Je,kR as Ye,kz as Xe,lR as Ze,mR as Qe,nz as $e,pR as et,qL as tt,qR as nt,rz as rt,t as v,tV as y,tz as it,uR as b,vR as at,wz as ot,xR as x,yR as st,zL as ct,zR as lt}from"./api-B1lq0pb-.js";import{t as ut}from"./list-DhABairq.js";import{t as S}from"./button-Ds98Pj53.js";import{$ as C,Bn as w,Bt as T,Ct as dt,Dn as ft,Dt as pt,Et as E,Q as D,Rt as O,St as mt,Tt as ht,Vn as k,X as A,Z as j,_n as gt,_t,at as vt,bn as yt,bt,dn as xt,et as M,gt as St,hn as Ct,it as wt,jt as Tt,nt as Et,on as Dt,ot as Ot,q as kt,rt as At,tt as jt,vt as Mt,wt as Nt,xn as Pt,xt as Ft,yt as It,zt as N}from"./index-Bkfx3eIe.js";import{a as Lt,i as P,n as Rt,o as zt,r as F,t as Bt}from"./table-B15ESmxP.js";import{t as Vt}from"./FilterBar-DHbB2cbQ.js";/* empty css */import{a as Ht,c as I,i as L,l as Ut,n as Wt,o as R,r as Gt,s as Kt,t as qt,u as z}from"./TimezoneCombobox-BYDYUkxC.js";var Jt=u(`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=u(`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`}]]),B=t(e(),1),V=n();function H(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=Ut(e),r=(0,B.useMemo)(()=>new Date,[]),[i,a]=(0,B.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[o,s]=(0,B.useState)(!1),l=(0,B.useMemo)(()=>H(y()),[]),u=(0,B.useMemo)(()=>new Intl.DateTimeFormat(y(),{month:`long`,year:`numeric`}),[]),ee=(0,B.useMemo)(()=>new Intl.DateTimeFormat(y(),{dateStyle:`medium`,timeStyle:`short`}),[]),te=I(i.year,i.month),d=n?.hour??9,f=n?.minute??0,p=(e,n,r,i,a)=>t(z(e,n,r,i,a)),ne=(e,t,n)=>{a({year:e,month:t}),p(e,t,n,d,f)},re=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},ie=n===null?De():ee.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,V.jsxs)(O,{modal:!0,open:o,onOpenChange:s,children:[(0,V.jsx)(T,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":c(),children:[(0,V.jsx)(Jt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,V.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:ie})]})}),(0,V.jsxs)(N,{align:`start`,className:`oc-dtp__pop`,children:[(0,V.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":x(),onClick:()=>re(-1),children:(0,V.jsx)(k,{size:15,"aria-hidden":!0})}),(0,V.jsx)(`span`,{className:`oc-dtp__month`,children:u.format(new Date(i.year,i.month,1))}),(0,V.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":g(),onClick:()=>re(1),children:(0,V.jsx)(w,{size:15,"aria-hidden":!0})})]}),(0,V.jsxs)(`div`,{className:`oc-dtp__grid`,children:[l.map((e,t)=>(0,V.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),te.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,V.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:()=>ne(e.year,e.month,e.day),children:e.day},t)})]}),(0,V.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,V.jsxs)(A,{value:String(d),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),Number(e),f),children:[(0,V.jsx)(C,{size:`sm`,"aria-label":st(),children:(0,V.jsx)(M,{})}),(0,V.jsx)(j,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,V.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,V.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,V.jsxs)(A,{value:String(f),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),d,Number(e)),children:[(0,V.jsx)(C,{size:`sm`,"aria-label":at(),children:(0,V.jsx)(M,{})}),(0,V.jsx)(j,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,V.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function U(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=U(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 W(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 G=3;function nn({events:e,mode:t,cursor:n,onModeChange:r,onCursorChange:i,onEventClick:a,footnote:o}){let s=y(),c=(0,B.useMemo)(()=>Qt(e),[e]),l=(0,B.useMemo)(()=>$t(s),[s]),u=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`,year:`numeric`}),[s]),ee=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`}),[s]),te=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}),[s]),d=new Date,f=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()})},p=t===`year`?String(n.year):u.format(new Date(n.year,n.month,1));return(0,V.jsxs)(`div`,{className:`oc-cal`,children:[(0,V.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,V.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":He(),onClick:()=>f(-1),children:(0,V.jsx)(k,{})}),(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":b(),onClick:()=>f(1),children:(0,V.jsx)(w,{})}),(0,V.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>i({year:d.getFullYear(),month:d.getMonth()}),children:_()})]}),(0,V.jsx)(`span`,{className:`oc-cal__title`,children:p}),(0,V.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,V.jsx)(S,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:Qe()}),(0,V.jsx)(S,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:et()})]})]}),t===`month`?(0,V.jsx)(rn,{cursor:n,byDay:c,weekdays:l,timeFmt:te,now:d,onEventClick:a}):(0,V.jsx)(an,{year:n.year,byDay:c,monthShortFmt:ee,now:d,onOpenMonth:e=>{i({year:n.year,month:e}),r(`month`)}}),o?(0,V.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=I(e.year,e.month);return(0,V.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,V.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,V.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,V.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,G).map(e=>(0,V.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,V.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,V.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>G?(0,V.jsx)(`span`,{className:`oc-cal__more`,children:Ze({count:o.length-G})}):null]},n)})]})}function an({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,V.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=W(t,e,o),c=I(e,o);return(0,V.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,V.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,V.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,V.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var on={h:36e5,min:6e4,s:1e3,ms:1};function sn(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])*on[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 K(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 q(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=K(t[0],0,59),r=K(t[1],0,23),i=K(t[2],1,31),a=K(t[3],1,12),o=K(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 cn=new Map;function J(e){let t=cn.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 cn.set(e,n),n}function Y(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 X(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=Y(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 Z(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=q(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=Y(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=X(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=X(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 Q=`crons`;function ln(e,t){return`${e}\u0000${t}`}function un(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=ln(a.instanceName,e.id);i.set(o,a);let s=R(e)!==`active`,c=Z(s?null:sn(e.schedule),e.nextRunAtMs,t,n);for(let t of c)r.push({id:`${o}:${t.atMs}`,sourceId:Q,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:s,exact:t.exact})}return{events:r,byItemId:i}}var $={minutes:6e4,hours:36e5,days:864e5};function dn(e){return e?.data?.code??`unknown`}function fn({status:e}){switch(Kt(e)){case`ok`:return(0,V.jsx)(E,{variant:`secondary`,children:se()});case`error`:return(0,V.jsx)(E,{variant:`destructive`,children:Se()});case`running`:return(0,V.jsx)(E,{variant:`outline`,children:ve()});case`other`:return(0,V.jsx)(E,{variant:`outline`,children:e});case`none`:return(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function pn(){let e=h(v.scheduled.listMyCrons),t=h(v.scheduled.getCronDetail),n=h(v.scheduled.listCronRuns),c=h(v.scheduled.updateCron),u=h(v.scheduled.removeCron),De=h(v.scheduled.runCronNow),g=pt(),He=Ve(v.me.getMe,{host:kt})?.timezone,[_,Ze]=(0,B.useState)(null),[Qe,et]=(0,B.useState)(!1),[b,at]=(0,B.useState)(!1),[x,st]=(0,B.useState)(null),[w,T]=(0,B.useState)(null),[O,k]=(0,B.useState)(null),[N,I]=(0,B.useState)(null),[Ut,Kt]=(0,B.useState)(!1),[z,H]=(0,B.useState)(Wt),[U,Zt]=(0,B.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)},[W,$t]=(0,B.useState)(`month`),[G,rn]=(0,B.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),an=(0,B.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,z)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[_,z]),on=(0,B.useMemo)(()=>W===`year`?tn(G.year):en(G.year,G.month),[W,G]),sn=(0,B.useMemo)(()=>un(an,on.startMs,on.endMs),[an,on]),K=e=>{let t=sn.byItemId.get(e.itemId);t===void 0||!t.canEdit||t.job.id===null||pn(t.instanceName,t.job)},q=(0,B.useCallback)(async()=>{et(!0),at(!1);try{Ze(await e({}))}catch{at(!0)}finally{et(!1)}},[e]);(0,B.useEffect)(()=>{q()},[q]);let cn=(0,B.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),J=(0,B.useRef)(null);(0,B.useEffect)(()=>{_!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[_]);let Y=(0,B.useMemo)(()=>new Intl.DateTimeFormat(y(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{st(e);try{await t(),g.success(n),await q()}catch(e){g.toast({variant:`error`,title:m({code:dn(e)})})}finally{st(null)}},Z=(0,B.useRef)(0),Q=(0,B.useRef)(0),ln=async(e,t)=>{if(t.id===null)return;let r=++Z.current;k({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Z.current)return;k({name:t.name??t.id,entries:i})}catch(e){if(r!==Z.current)return;k(null),g.toast({variant:`error`,title:m({code:dn(e)})})}},pn=async(e,n)=>{if(n.id===null)return;let r=++Q.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%$.days===0?(s=String(e/$.days),c=`days`):e%$.hours===0?(s=String(e/$.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/$.minutes))),c=`minutes`))}if(r!==Q.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!==Q.current)return;I(null),g.toast({variant:`error`,title:m({code:dn(e)})})}},mn=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:d()});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*$[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:oe()});return}if(N.messageDirty&&N.hasMessage&&N.message.trim()!==``&&(e.message=N.message.trim()),Object.keys(e).length===0){I(null);return}let t=Q.current;Kt(!0);try{await c({instanceName:N.instanceName,jobId:N.jobId,patch:e}),g.success(Ie()),t===Q.current&&I(null),await q()}catch(e){g.toast({variant:`error`,title:m({code:dn(e)})})}finally{Kt(!1)}},hn=_?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,V.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:he()}),(0,V.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":ze(),children:[(0,V.jsx)(S,{variant:U===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":We(),title:We(),"aria-pressed":U===`list`,onClick:()=>Qt(`list`),children:(0,V.jsx)(ut,{})}),(0,V.jsx)(S,{variant:U===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ge(),title:Ge(),"aria-pressed":U===`calendar`,onClick:()=>Qt(`calendar`),children:(0,V.jsx)(Jt,{})})]}),(0,V.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>void q(),disabled:Qe,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,V.jsx)(Ct,{size:14,"aria-hidden":!0}),ce()]})]}),_!==null&&hn>0?(0,V.jsxs)(Vt,{q:z.q,onQChange:e=>H(t=>({...t,q:e})),searchPlaceholder:Ke(),onReset:()=>H(Wt),canReset:Gt(z),children:[(0,V.jsxs)(A,{value:z.state,onValueChange:e=>H(t=>({...t,state:e})),children:[(0,V.jsx)(C,{size:`sm`,className:`w-40`,children:(0,V.jsx)(M,{})}),(0,V.jsxs)(j,{children:[(0,V.jsx)(D,{value:`all`,children:a()}),(0,V.jsx)(D,{value:`active`,children:l()}),(0,V.jsx)(D,{value:`paused`,children:ot()}),(0,V.jsx)(D,{value:`auto-disabled`,children:Oe()})]})]}),(0,V.jsxs)(A,{value:z.result,onValueChange:e=>H(t=>({...t,result:e})),children:[(0,V.jsx)(C,{size:`sm`,className:`w-40`,children:(0,V.jsx)(M,{})}),(0,V.jsxs)(j,{children:[(0,V.jsx)(D,{value:`all`,children:Ye()}),(0,V.jsx)(D,{value:`ok`,children:se()}),(0,V.jsx)(D,{value:`error`,children:Se()}),(0,V.jsx)(D,{value:`running`,children:ve()}),(0,V.jsx)(D,{value:`none`,children:ge()})]})]})]}):null,_===null?(0,V.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":Qe,children:b?p():r()}):U===`calendar`?(0,V.jsxs)(V.Fragment,{children:[b?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):null,_.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}):(0,V.jsx)(nn,{events:sn.events,mode:W,cursor:G,onModeChange:$t,onCursorChange:rn,onEventClick:K,footnote:Be()})]}):(0,V.jsxs)(V.Fragment,{children:[b?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):null,_.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}):null,_.map(e=>{let t=e.jobs.filter(e=>Ht(e,z)),n=Gt(z)&&e.jobs.length>0&&t.length===0;return(0,V.jsxs)(`section`,{style:{marginBottom:20},children:[_.length>1||e.error||!e.supported?(0,V.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,V.jsx)(E,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:_e({code:e.error})}):e.jobs.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:qe()}):n?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:be()}):(0,V.jsxs)(Bt,{children:[(0,V.jsx)(Lt,{children:(0,V.jsxs)(zt,{children:[(0,V.jsx)(P,{children:o()}),(0,V.jsx)(P,{children:Xe()}),(0,V.jsx)(P,{children:xe()}),(0,V.jsx)(P,{children:ee()}),(0,V.jsx)(P,{children:te()}),(0,V.jsx)(P,{children:me()}),(0,V.jsx)(P,{children:we()})]})}),(0,V.jsx)(Rt,{children:t.map((t,n)=>{let r=`${e.instanceName}:${t.id??n}`,a=x===r,o=e.manageSupported,s=e.kind===`openclaw`&&o;return(0,V.jsxs)(zt,{ref:t.id!==null&&t.id===cn?J:void 0,"data-state":t.id!==null&&t.id===cn?`selected`:void 0,children:[(0,V.jsx)(F,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??ke()}),(0,V.jsx)(F,{children:(0,V.jsx)(E,{variant:`secondary`,children:t.agentId})}),(0,V.jsxs)(F,{className:`whitespace-nowrap`,children:[(0,V.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=St(t.schedule),n=e===null?null:_t(e);return n===null?null:(0,V.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,V.jsx)(F,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:Y.format(t.nextRunAtMs)}),(0,V.jsx)(F,{children:R(t)===`auto-disabled`?(0,V.jsx)(E,{variant:`destructive`,title:`${t.autoDisabledReason??``}${t.autoDisabledAtMs===null?``:` · ${Y.format(t.autoDisabledAtMs)}`}`,children:Oe()}):R(t)===`active`?(0,V.jsx)(E,{variant:`secondary`,children:l()}):R(t)===`paused`?(0,V.jsx)(E,{variant:`outline`,children:ot()}):(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,V.jsxs)(F,{children:[(0,V.jsx)(fn,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,V.jsx)(E,{variant:`destructive`,title:t.lastDeliveryError??rt(),children:f()}):null]}),(0,V.jsx)(F,{className:`whitespace-nowrap`,children:t.id===null?(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,V.jsx)(ft,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,V.jsxs)(`span`,{className:`oc-cronactions`,children:[s?(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:it(),"aria-label":it(),disabled:x!==null,onClick:()=>void X(r,async()=>{let n=await De({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},Le()),children:(0,V.jsx)(Dt,{size:14,"aria-hidden":!0})}):null,s&&t.enabled!==null?(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:L(t)===`pause`?Ue():i(),"aria-label":L(t)===`pause`?Ue():i(),disabled:x!==null,onClick:()=>void X(r,()=>c({instanceName:e.instanceName,jobId:t.id,patch:{enabled:L(t)===`resume`}}),L(t)===`pause`?ue():nt()),children:L(t)===`pause`?(0,V.jsx)(Pt,{size:14,"aria-hidden":!0}):(0,V.jsx)(gt,{size:14,"aria-hidden":!0})}):null,s?(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Re(),"aria-label":Re(),disabled:x!==null,onClick:()=>void pn(e.instanceName,t),children:(0,V.jsx)(yt,{size:14,"aria-hidden":!0})}):null,s?(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Fe(),"aria-label":Fe(),disabled:x!==null,onClick:()=>void ln(e.instanceName,t),children:(0,V.jsx)(Yt,{size:14,"aria-hidden":!0})}):null,o?(0,V.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:Te(),"aria-label":Te(),disabled:x!==null,onClick:()=>T({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,V.jsx)(xt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:ye()})]},e.instanceName)}),hn>0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Je()}):null]}),(0,V.jsx)(Mt,{open:w!==null,onOpenChange:e=>{e||T(null)},children:(0,V.jsxs)(Ft,{children:[(0,V.jsxs)(Nt,{children:[(0,V.jsx)(ht,{children:re()}),(0,V.jsx)(mt,{children:Pe({name:w?.name??``})})]}),(0,V.jsxs)(dt,{children:[(0,V.jsx)(bt,{children:je()}),(0,V.jsx)(It,{onClick:()=>{let e=w;T(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>u({instanceName:e.instanceName,jobId:e.jobId}),fe())},children:ae()})]})]})}),(0,V.jsx)(jt,{open:O!==null,onOpenChange:e=>{e||(Z.current++,k(null))},children:(0,V.jsxs)(Et,{style:{maxWidth:640},children:[(0,V.jsx)(vt,{children:(0,V.jsx)(Ot,{children:le({name:O?.name??``})})}),O?.entries===null?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):O!==null&&O.entries.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:tt()}):O===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:O.entries.map((e,t)=>(0,V.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,V.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,V.jsx)(fn,{status:e.status}),(0,V.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?Y.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,V.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,V.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[lt({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,V.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,V.jsx)(jt,{open:N!==null,onOpenChange:e=>{e||(Q.current++,I(null))},children:(0,V.jsxs)(Et,{className:`oc-cronedit`,children:[(0,V.jsxs)(vt,{children:[(0,V.jsx)(Ot,{children:de()}),(0,V.jsx)(At,{children:ne()})]}),N===null?null:N.loading?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,V.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:o()}),(0,V.jsx)(Tt,{value:N.name,maxLength:200,onChange:e=>I({...N,name:e.target.value,nameDirty:!0})})]}),(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Ne()}),(0,V.jsxs)(A,{value:N.scheduleKind,onValueChange:e=>I({...N,scheduleKind:e,scheduleDirty:!0}),children:[(0,V.jsx)(C,{children:(0,V.jsx)(M,{})}),(0,V.jsxs)(j,{children:[(0,V.jsx)(D,{value:`cron`,children:Ae()}),(0,V.jsx)(D,{value:`every`,children:ie()}),(0,V.jsx)(D,{value:`at`,children:Me()})]})]}),N.scheduleKind===`cron`?(0,V.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,V.jsx)(Tt,{value:N.cronExpr,onChange:e=>I({...N,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,V.jsx)(qt,{value:N.tz,onChange:e=>I({...N,tz:e,scheduleDirty:!0}),fallbackTz:He??void 0})]}):N.scheduleKind===`every`?(0,V.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,V.jsx)(Tt,{type:`number`,min:1,value:N.everyValue,onChange:e=>I({...N,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,V.jsxs)(A,{value:N.everyUnit,onValueChange:e=>I({...N,everyUnit:e,scheduleDirty:!0}),children:[(0,V.jsx)(C,{style:{maxWidth:160},children:(0,V.jsx)(M,{})}),(0,V.jsxs)(j,{children:[(0,V.jsx)(D,{value:`minutes`,children:s()}),(0,V.jsx)(D,{value:`hours`,children:ct()}),(0,V.jsx)(D,{value:`days`,children:Ee()})]})]})]}):(0,V.jsx)(Xt,{value:N.at,onChange:e=>I({...N,at:e,scheduleDirty:!0})})]}),N.hasMessage?(0,V.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:$e()}),(0,V.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:N.message,onChange:e=>I({...N,message:e.target.value,messageDirty:!0})})]}):null]}),(0,V.jsxs)(wt,{children:[(0,V.jsx)(S,{variant:`ghost`,onClick:()=>I(null),children:je()}),(0,V.jsxs)(S,{onClick:()=>void mn(),disabled:N===null||N.loading||Ut,children:[Ut?(0,V.jsx)(ft,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,pe()]})]})]})})]})}export{pn as ScheduledTab};
|