@lacneu/atrium 0.81.0 → 0.81.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/assets/{AccessTab-BgWLWjSu.js → AccessTab-OP6MT853.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-CDngwUem.js → AdvancedFilter-CYKmk_LK.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-CL0cJrKE.js → AgentFilesTab-Bzj4n4RS.js} +1 -1
  4. package/dist/assets/{AnomaliesTab-CKSRbds6.js → AnomaliesTab-DIOsMkIt.js} +1 -1
  5. package/dist/assets/{AuditTab-BnDFtbaS.js → AuditTab-B-v9HjgO.js} +1 -1
  6. package/dist/assets/{BridgeTab-QW9px1z5.js → BridgeTab-D7jnblPV.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-XNB8jInh.js → ChatDefaultsTab-DE7qape9.js} +1 -1
  8. package/dist/assets/{DataTableShell-BWoSBli_.js → DataTableShell-CR2Pxo32.js} +1 -1
  9. package/dist/assets/{DetailChips-CUfCyLvN.js → DetailChips-BttzOfap.js} +1 -1
  10. package/dist/assets/{FeedbacksTab-Ba-zMA-p.js → FeedbacksTab-BPxuXa49.js} +1 -1
  11. package/dist/assets/{FieldLabel-8vj4ipPC.js → FieldLabel-DvlvfpGK.js} +1 -1
  12. package/dist/assets/{FilesTab-Dht0_RDj.js → FilesTab-Da5f-Q53.js} +1 -1
  13. package/dist/assets/{FilterBar-BJ1mhU3e.js → FilterBar-D8d3TG3L.js} +1 -1
  14. package/dist/assets/{GroupsTab-Bz7Mvvwj.js → GroupsTab-02Klvfu1.js} +1 -1
  15. package/dist/assets/InstancesTab-CvcFYqzZ.js +1 -0
  16. package/dist/assets/{IntegrationsTab-D3y4_fhI.js → IntegrationsTab-C3v_UYdO.js} +1 -1
  17. package/dist/assets/{KpiTab-D9ujtelb.js → KpiTab-NBnWW7mn.js} +1 -1
  18. package/dist/assets/{PreferencesTab-CHqxxQ3R.js → PreferencesTab-Dtc4NXr7.js} +1 -1
  19. package/dist/assets/{ProjectPage-Dom5dB_v.js → ProjectPage-3M9H_seP.js} +1 -1
  20. package/dist/assets/{PromptInjectionsTab-D-7L-yZy.js → PromptInjectionsTab-ydfl3LIa.js} +1 -1
  21. package/dist/assets/{RolesTab-2nGoIoBg.js → RolesTab-rtjEoRka.js} +1 -1
  22. package/dist/assets/{ScheduledTab-_v_HWkIY.js → ScheduledTab-1Z--saSr.js} +1 -1
  23. package/dist/assets/{ServiceAccountsTab-foQObSmk.js → ServiceAccountsTab-BDQcZy4S.js} +1 -1
  24. package/dist/assets/{SubAgentReportsTab-DIzBgBj5.js → SubAgentReportsTab-BlttiEor.js} +1 -1
  25. package/dist/assets/{ThemeShowroom-Gqbq2MWW.js → ThemeShowroom-D1Av-z7w.js} +1 -1
  26. package/dist/assets/{TimeRangePicker-qNMV_Gj-.js → TimeRangePicker-CdzW5P7l.js} +1 -1
  27. package/dist/assets/{TimezoneCombobox-D2e6UjGY.js → TimezoneCombobox-Byz56evB.js} +1 -1
  28. package/dist/assets/{TracesTab-D_Z__oYy.js → TracesTab-DuT8lvo4.js} +1 -1
  29. package/dist/assets/{UsersTab-1HZ5mAYl.js → UsersTab-6m5HSxal.js} +1 -1
  30. package/dist/assets/{VoiceTab-DGQk5yGt.js → VoiceTab-DFVKbQpO.js} +1 -1
  31. package/dist/assets/{api-CCk5U5gB.js → api-Borb_oKz.js} +1 -1
  32. package/dist/assets/{button-CbUSFbZL.js → button-Bcf40mKN.js} +1 -1
  33. package/dist/assets/{card-PW6qFB8Z.js → card-BVQ_SWDd.js} +1 -1
  34. package/dist/assets/chevrons-up-down-DQp99IbP.js +1 -0
  35. package/dist/assets/{compatView-DgV9jG5C.js → compatView-CowuHUom.js} +1 -1
  36. package/dist/assets/{dispatchErrorInfo-CW9VFOfh.js → dispatchErrorInfo-DwvABR74.js} +1 -1
  37. package/dist/assets/{dist-CeBeEhXM.js → dist-BCOYDeQS.js} +1 -1
  38. package/dist/assets/{dist-BF1pXGOi.js → dist-Bq0h0jBi.js} +1 -1
  39. package/dist/assets/{highlighted-body-OFNGDK62-B0i3QCx_.js → highlighted-body-OFNGDK62-DSC5jaxG.js} +1 -1
  40. package/dist/assets/index-DEMhzN6j.css +1 -0
  41. package/dist/assets/{index-DY7zoioz.js → index-lMzb_P_p.js} +7 -7
  42. package/dist/assets/{list-wMpxVo2w.js → list-DfIPa6Dk.js} +1 -1
  43. package/dist/assets/mermaid-GHXKKRXX-BoodyZnM.js +1 -0
  44. package/dist/assets/{pdf-BFBPmq_U.js → pdf-CO5wvqSF.js} +1 -1
  45. package/dist/assets/roleDescriptions-xzqDDCcp.js +1 -0
  46. package/dist/assets/{table-BhYNJKZu.js → table-B5YoMU9b.js} +1 -1
  47. package/dist/assets/{tabs-BwhZusQZ.js → tabs-D7icC_cj.js} +1 -1
  48. package/dist/assets/x-XSJ8VGVc.js +1 -0
  49. package/dist/index.html +7 -7
  50. package/package.json +1 -1
  51. package/dist/assets/InstancesTab-BTESpzxw.js +0 -1
  52. package/dist/assets/chevrons-up-down-DAdQ-ohu.js +0 -1
  53. package/dist/assets/index-vuXE_6pY.css +0 -1
  54. package/dist/assets/mermaid-GHXKKRXX-CWDFvVZH.js +0 -1
  55. package/dist/assets/roleDescriptions-Du6v2lbA.js +0 -1
  56. package/dist/assets/x-BvfQ_1AZ.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ay as r,Dy as i,Ey as a,Fy as o,Gk as s,Iy as c,Jk as l,Kk as u,Lk as d,Ly as f,My as p,Ny as m,Oy as h,Py as g,Rk as _,Ry as ee,Ty as te,jy as ne,ky as v,oB as y,qk as b,t as x,wy as S,yA as C}from"./api-CCk5U5gB.js";import{Gn as w,Kn as T,i as E,o as re,q as ie,r as D}from"./index-DY7zoioz.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-PW6qFB8Z.js";import{n as N,t as P}from"./TimeRangePicker-qNMV_Gj-.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=y(x.me.getMe,{host:ie})?.permissions?.includes(`traces.read`)??!1,t=y(x.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,F.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,z).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:C()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:l()}),(0,R.jsx)(j,{children:u()})]}),(0,R.jsx)(k,{children:n.length<2?(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):(0,R.jsx)(H,{series:n})})]})]})}function H({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{style:{color:`var(--primary)`},children:[d(),` p50 `,B(s.cP50),` `,b()]}),(0,R.jsxs)(`span`,{children:[_(),` p50 `,B(s.aP50),` `,b()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":l(),children:[(0,R.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:ee(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:f(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:c(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:o(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:g(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:m(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:p(),unit:`/h`,group:`Assistant`,isError:!0}],W=L,G=[`API`,`OpenClaw`,`Chat`,`Assistant`],K=1e3,q=36e5;function J(e,t){let n=Math.max(1,Math.ceil((t-e)/q)),r=Math.min(n*W,K);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/W))}}function ae(){let e=T({from:`/settings/kpi`}),t=w({from:`/settings/kpi`}),n=E(e.from,e.to,D,`now`),i=e=>void t({search:t=>({...t,...re(e)})}),{from:a,to:o}=N(n),{rowLimit:s,buckets:c}=J(a,o),l=y(x.kpi.listKpis,{limit:s,filter:{from:a,to:o}}),u=(0,F.useMemo)(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>c&&e.set(t,n.slice(n.length-c));return e},[l,c]),d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[ne(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:r()})]}),(0,R.jsx)(Y,{value:n,onChange:i})]});return l===void 0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:v()})]}):l.length===0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:h()})]}):(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),G.map(e=>{let t=U.filter(t=>t.group===e);return t.some(e=>(u.get(e.metric)??[]).length>0)?(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,R.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,R.jsx)(oe,{config:e,series:u.get(e.metric)??[]},e.metric))})]},e):null})]})}function Y({value:e,onChange:t}){return(0,R.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,R.jsx)(P,{value:e,onChange:t})})}function oe({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,R.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,R.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,R.jsx)(`code`,{children:e.metric})})]}),(0,R.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,R.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,R.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,R.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,R.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,R.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,R.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:i({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:a()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:te({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,R.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-se,1);return(0,R.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":S({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,R.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,R.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{ae as KpiTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ay as r,Dy as i,Ey as a,Fy as o,Gk as s,Iy as c,Jk as l,Kk as u,Lk as d,Ly as f,My as p,Ny as m,Oy as h,Py as g,Rk as _,Ry as ee,Ty as te,jy as ne,ky as v,oB as y,qk as b,t as x,wy as S,yA as C}from"./api-Borb_oKz.js";import{Gn as w,Kn as T,i as E,o as re,q as ie,r as D}from"./index-lMzb_P_p.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-BVQ_SWDd.js";import{n as N,t as P}from"./TimeRangePicker-CdzW5P7l.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=y(x.me.getMe,{host:ie})?.permissions?.includes(`traces.read`)??!1,t=y(x.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,F.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,z).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:C()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:l()}),(0,R.jsx)(j,{children:u()})]}),(0,R.jsx)(k,{children:n.length<2?(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):(0,R.jsx)(H,{series:n})})]})]})}function H({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{style:{color:`var(--primary)`},children:[d(),` p50 `,B(s.cP50),` `,b()]}),(0,R.jsxs)(`span`,{children:[_(),` p50 `,B(s.aP50),` `,b()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":l(),children:[(0,R.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:ee(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:f(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:c(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:o(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:g(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:m(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:p(),unit:`/h`,group:`Assistant`,isError:!0}],W=L,G=[`API`,`OpenClaw`,`Chat`,`Assistant`],K=1e3,q=36e5;function J(e,t){let n=Math.max(1,Math.ceil((t-e)/q)),r=Math.min(n*W,K);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/W))}}function ae(){let e=T({from:`/settings/kpi`}),t=w({from:`/settings/kpi`}),n=E(e.from,e.to,D,`now`),i=e=>void t({search:t=>({...t,...re(e)})}),{from:a,to:o}=N(n),{rowLimit:s,buckets:c}=J(a,o),l=y(x.kpi.listKpis,{limit:s,filter:{from:a,to:o}}),u=(0,F.useMemo)(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>c&&e.set(t,n.slice(n.length-c));return e},[l,c]),d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[ne(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:r()})]}),(0,R.jsx)(Y,{value:n,onChange:i})]});return l===void 0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:v()})]}):l.length===0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:h()})]}):(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),G.map(e=>{let t=U.filter(t=>t.group===e);return t.some(e=>(u.get(e.metric)??[]).length>0)?(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,R.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,R.jsx)(oe,{config:e,series:u.get(e.metric)??[]},e.metric))})]},e):null})]})}function Y({value:e,onChange:t}){return(0,R.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,R.jsx)(P,{value:e,onChange:t})})}function oe({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,R.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,R.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,R.jsx)(`code`,{children:e.metric})})]}),(0,R.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,R.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,R.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,R.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,R.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,R.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,R.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:i({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:a()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:te({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,R.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-se,1);return(0,R.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":S({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,R.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,R.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{ae as KpiTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,AP as i,An as a,Az as o,BP as s,Bz as c,CP as l,Cz as u,DP as d,Dn as f,Dz as p,EP as m,Ez as ee,FP as te,Fz as ne,GP as re,HP as ie,Hn as ae,Hz as oe,IP as se,Iz as ce,JP as le,Jn as ue,KP as de,Kz as fe,LP as pe,Lz as me,MP as he,Mn as ge,Mz as _e,NP as ve,Nn as h,Nz as g,OP as _,On as v,Oz as y,PP as b,Pn as x,Pz as S,QP as C,RP as w,Rz as T,SP as E,Sz as D,TP as O,Tz as k,UP as A,Uz as j,VP as M,Vz as N,WP as P,XP as F,YP as ye,ZP as be,Zz as xe,_P as Se,aB as I,bP as Ce,bz as we,eD as Te,eF as Ee,gP as De,jP as Oe,jn as ke,jz as Ae,kP as L,kn as je,kz as Me,oB as R,qP as Ne,qn as Pe,r as z,t as B,tF as Fe,vP as Ie,wP as Le,wz as Re,xP as ze,xz as Be,yP as Ve,zP as He,zz as Ue}from"./api-CCk5U5gB.js";import{t as V}from"./button-CbUSFbZL.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-DY7zoioz.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-D2e6UjGY.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:z(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:z(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>Fe()},{id:`composer`,label:()=>Ee()},{id:`sidebar`,label:()=>r()},{id:`notifications`,label:()=>se()},{id:`other`,label:()=>C()}],X={showSource:{category:`messages`,label:()=>be(),help:()=>F()},showReport:{category:`messages`,label:()=>ye(),help:()=>le()},copyAssistant:{category:`messages`,label:()=>Ne()},copyUser:{category:`messages`,label:()=>de()},showDelete:{category:`messages`,label:()=>re()},showTools:{category:`messages`,label:()=>P(),help:()=>A()},voiceInput:{category:`composer`,label:()=>ie(),help:()=>M()},showUsage:{category:`composer`,label:()=>s(),help:()=>He()},autoReadAloud:{category:`composer`,label:()=>ue(),help:()=>Pe()},showChatAge:{category:`sidebar`,label:()=>w(),help:()=>pe()},notifSound:{category:`notifications`,label:()=>te(),help:()=>b()},notifSystem:{category:`notifications`,label:()=>ve(),help:()=>he()},replySound:{category:`notifications`,label:()=>Oe(),help:()=>i()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>Ce()};function ut({prefKey:e,ui:t}){let n=I(B.admin.setUiPrefDefault),r=I(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:Le()}),(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:Ie()}),(0,J.jsx)(U,{value:`off`,children:Se()}),(0,J.jsx)(U,{value:`inherit`,children:De()})]})]}),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":l()}),l()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=I(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=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:[x(),e?(0,J.jsx)(H,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:o?ke():r?ge():h()})]}),(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:f()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?v():e?je():a()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=R(B.me.getMe,{host:G}),a=i?.ui,o=$(i?.role)&&n,s=I(B.me.setUiPref).withOptimisticUpdate(Je),c=(0,q.useMemo)(()=>a?Q(Object.keys(a.effective),e):[],[a,e]);return a?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(K,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":O()}),O()]}):null,o?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:E()}),(0,J.jsx)(`p`,{children:ze()}),(0,J.jsx)(`p`,{children:Ve()})]}):null,(0,J.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:L(),"aria-label":L(),className:`mb-2`}),c.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:_()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:c.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],c=a.effective[e],l=a.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(H,{variant:`outline`,children:d()}):l?(0,J.jsx)(H,{variant:`secondary`,children:ae()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void s({key:e,value:null}),children:m()}):null,(0,J.jsx)(nt,{checked:c,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),s({key:e,value:t})},"aria-label":n})]}),o?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:xe()})}var pt={sm:()=>Ae(),md:()=>o(),lg:()=>Me(),xl:()=>y(),"2xl":()=>p(),"3xl":()=>ee()};function mt(){let e=R(B.me.getMe,{host:G}),t=I(B.me.setLocale),n=I(B.me.setTimezone),r=I(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:G});n&&e.setQuery(B.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=I(B.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(Ue())}catch(e){a.error(T(),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:j()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:oe()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(W,{className:`max-w-xs`,value:f,maxLength:120,placeholder:N(),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:Te()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:c()})]}),(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:me()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ce()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant: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:fe()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ne()})]}),(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:k()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Re()})]}),(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:u()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:D()})]}),(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:S()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:g()})]}),(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:_e()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Be()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:we()})]}),(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{$P as r,AP as i,An as a,Az as o,BP as s,Bz as c,CP as l,Cz as u,DP as d,Dn as f,Dz as p,EP as m,Ez as ee,FP as te,Fz as ne,GP as re,HP as ie,Hn as ae,Hz as oe,IP as se,Iz as ce,JP as le,Jn as ue,KP as de,Kz as fe,LP as pe,Lz as me,MP as he,Mn as ge,Mz as _e,NP as ve,Nn as h,Nz as g,OP as _,On as v,Oz as y,PP as b,Pn as x,Pz as S,QP as C,RP as w,Rz as T,SP as E,Sz as D,TP as O,Tz as k,UP as A,Uz as j,VP as M,Vz as N,WP as P,XP as F,YP as ye,ZP as be,Zz as xe,_P as Se,aB as I,bP as Ce,bz as we,eD as Te,eF as Ee,gP as De,jP as Oe,jn as ke,jz as Ae,kP as L,kn as je,kz as Me,oB as R,qP as Ne,qn as Pe,r as z,t as B,tF as Fe,vP as Ie,wP as Le,wz as Re,xP as ze,xz as Be,yP as Ve,zP as He,zz as Ue}from"./api-Borb_oKz.js";import{t as V}from"./button-Bcf40mKN.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-lMzb_P_p.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-Byz56evB.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:z(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:z(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>Fe()},{id:`composer`,label:()=>Ee()},{id:`sidebar`,label:()=>r()},{id:`notifications`,label:()=>se()},{id:`other`,label:()=>C()}],X={showSource:{category:`messages`,label:()=>be(),help:()=>F()},showReport:{category:`messages`,label:()=>ye(),help:()=>le()},copyAssistant:{category:`messages`,label:()=>Ne()},copyUser:{category:`messages`,label:()=>de()},showDelete:{category:`messages`,label:()=>re()},showTools:{category:`messages`,label:()=>P(),help:()=>A()},voiceInput:{category:`composer`,label:()=>ie(),help:()=>M()},showUsage:{category:`composer`,label:()=>s(),help:()=>He()},autoReadAloud:{category:`composer`,label:()=>ue(),help:()=>Pe()},showChatAge:{category:`sidebar`,label:()=>w(),help:()=>pe()},notifSound:{category:`notifications`,label:()=>te(),help:()=>b()},notifSystem:{category:`notifications`,label:()=>ve(),help:()=>he()},replySound:{category:`notifications`,label:()=>Oe(),help:()=>i()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>Ce()};function ut({prefKey:e,ui:t}){let n=I(B.admin.setUiPrefDefault),r=I(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:Le()}),(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:Ie()}),(0,J.jsx)(U,{value:`off`,children:Se()}),(0,J.jsx)(U,{value:`inherit`,children:De()})]})]}),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":l()}),l()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=I(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=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:[x(),e?(0,J.jsx)(H,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:o?ke():r?ge():h()})]}),(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:f()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?v():e?je():a()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=R(B.me.getMe,{host:G}),a=i?.ui,o=$(i?.role)&&n,s=I(B.me.setUiPref).withOptimisticUpdate(Je),c=(0,q.useMemo)(()=>a?Q(Object.keys(a.effective),e):[],[a,e]);return a?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(K,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":O()}),O()]}):null,o?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:E()}),(0,J.jsx)(`p`,{children:ze()}),(0,J.jsx)(`p`,{children:Ve()})]}):null,(0,J.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:L(),"aria-label":L(),className:`mb-2`}),c.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:_()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:c.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],c=a.effective[e],l=a.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(H,{variant:`outline`,children:d()}):l?(0,J.jsx)(H,{variant:`secondary`,children:ae()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void s({key:e,value:null}),children:m()}):null,(0,J.jsx)(nt,{checked:c,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),s({key:e,value:t})},"aria-label":n})]}),o?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:xe()})}var pt={sm:()=>Ae(),md:()=>o(),lg:()=>Me(),xl:()=>y(),"2xl":()=>p(),"3xl":()=>ee()};function mt(){let e=R(B.me.getMe,{host:G}),t=I(B.me.setLocale),n=I(B.me.setTimezone),r=I(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:G});n&&e.setQuery(B.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=I(B.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(Ue())}catch(e){a.error(T(),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:j()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:oe()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(W,{className:`max-w-xs`,value:f,maxLength:120,placeholder:N(),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:Te()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:c()})]}),(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:me()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ce()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant: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:fe()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ne()})]}),(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:k()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Re()})]}),(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:u()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:D()})]}),(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:S()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:g()})]}),(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:_e()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Be()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:we()})]}),(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{$_ as r,Av as i,Bv as a,Cv as o,D as s,Dv as c,Ev as l,Gv as u,Hv as d,Iv as f,Jv as p,Kv as m,Lv as h,Mv as g,Nv as _,Ov as ee,Pv as v,Qv as te,Rv as y,Sv as b,Tv as ne,Uv as re,Wv as ie,Z_ as ae,Zv as oe,Zz as x,aB as S,av as se,ay as ce,bv as le,cv as ue,ev as de,ey as C,fg as fe,gv as pe,hv as me,iv as w,jv as T,kv as he,lv as ge,mv as E,nt as _e,nv as D,oB as O,oy as ve,pv as ye,rv as k,sv as A,sy as be,t as j,tt as xe,tv as Se,ty as Ce,vv as we,wv as Te,xv as M,yv as Ee,zv as N}from"./api-CCk5U5gB.js";import{t as De}from"./list-wMpxVo2w.js";import{t as P}from"./button-CbUSFbZL.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-DY7zoioz.js";var ft=s(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),pt=s(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),mt=s(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Y=s(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),X=t(e(),1),Z=n();function ht({className:e}){return(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":se(),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 o=S(j.projects.renameProject),s=S(j.projects.setProjectColor),c=S(j.projects.moveProject),l=S(j.projects.deleteProject),f=S(j.projects.createProject),p=Xe(),h=Ze(),[g,ee]=(0,X.useState)(!1),[v,te]=(0,X.useState)(t),[y,b]=(0,X.useState)(!1),[ne,ae]=(0,X.useState)(!1),x=O(j.projects.projectTreeCount,ne?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ve,{onOpenChange:e=>e&&ae(!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,{}),` `,d()]}),(0,Z.jsxs)(R,{onSelect:()=>{te(t),ee(!0)},children:[(0,Z.jsx)(et,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await h({title:_(),label:be(),placeholder:ve(),confirmLabel:ce()});t&&await f({name:t,parentId:e})})},children:[(0,Z.jsx)(ke,{}),` `,_()]}),(0,Z.jsxs)(R,{onSelect:()=>b(!0),children:[(0,Z.jsx)(pt,{}),` `,me()]}),(0,Z.jsx)(Pe,{children:Se()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void s({projectId:e,color:null}),"aria-label":de(),children:`✕`}),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 s({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=x?.folders??0,r=x?.chats??0;await p({title:u({name:t}),description:n>0?re({folders:n,chats:r}):r>0?ie({count:r}):ue(),confirmWord:A(),confirmLabel:m(),destructive:!0})&&await l({projectId:e})})},children:[(0,Z.jsx)(nt,{}),` `,A()]})]})]}),(0,Z.jsx)($e,{open:g,onOpenChange:ee,title:oe(),canSubmit:v.trim().length>0,onSubmit:async()=>{await o({projectId:e,name:v.trim()}),ee(!1)},submitLabel:w(),children:(0,Z.jsx)(W,{value:v,onChange:e=>te(e.target.value),autoFocus:!0})}),y?(0,Z.jsx)(ot,{open:y,onOpenChange:b,title:ye(),movingFolderId:e,currentId:r,onPick:t=>void c({projectId:e,parentId:t})}):null]})}function gt({chat:e,currentFolderId:t,className:n}){let i=S(j.chats.pinChat),o=S(j.chats.deleteChat),s=S(j.chats.renameChat),c=S(j.chats.setChatSidebar),l=S(j.chats.moveChatToProject),u=Xe(),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(e.title??``),[h,g]=(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:()=>{m(e.title??``),f(!0)},children:[(0,Z.jsx)(et,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>void i({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(ct,{}):(0,Z.jsx)(J,{}),e.pinned?k():D()]}),(0,Z.jsxs)(R,{onSelect:()=>g(!0),children:[(0,Z.jsx)(pt,{}),` `,pe()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(R,{onSelect:()=>void c({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(qe,{}):(0,Z.jsx)(Y,{}),e.inSidebar?N():a()]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await u({title:r(),description:ue(),confirmLabel:A(),destructive:!0})&&await o({chatId:e._id})})},children:[(0,Z.jsx)(nt,{}),` `,A()]})]})]}),(0,Z.jsx)($e,{open:d,onOpenChange:f,title:ae(),canSubmit:p.trim().length>0,onSubmit:async()=>{await s({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:w(),children:(0,Z.jsx)(W,{value:p,onChange:e=>m(e.target.value),autoFocus:!0})}),h?(0,Z.jsx)(ot,{open:h,onOpenChange:g,title:E(),currentId:t,onPick:t=>void l({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=O(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:x()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:M()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:le()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:Ee()})]}):(0,Z.jsx)(Et,{page:n})})}function Et({page:e}){let t=I(),n=Xe(),r=Ze(),a=Me(),s=S(j.projects.renameProject),c=S(j.projects.setProjectColor),l=S(j.projects.deleteProject),d=S(j.projects.createProject),p=S(j.projects.moveProject),g=S(j.projects.setProjectSidebar),ae=S(j.chats.moveChatToProject),x=S(j.chats.reorderChat),se=S(j.projects.reorderProject),le=O(j.projects.projectTreeCount,{projectId:e.project._id}),[C,pe]=(0,X.useState)(xt),T=e=>{localStorage.setItem(bt,e),pe(e)},E=O(j.projects.folderColumns,C===`columns`?{projectId:e.project._id}:`skip`),D=O(j.projects.projectTreeList,C===`list`?{projectId:e.project._id}:`skip`),{c:k}=Re({from:`/project/$projectId`}),M=O(j.projects.listProjects,{}),Ee=O(j.chatReads.myBusyChats,{}),N=(0,X.useMemo)(()=>new Set(Ee??[]),[Ee]),Ae=O(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=O(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=E?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||Ce()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(M??[]).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 E?.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 E?.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 ae({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Le(M??[],t,e)){a.error(v());return}await p({projectId:t,parentId:e})}return}if(o&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=Nt(t);if(!n)return;n.list.some(t=>t._id===e)||await ae({chatId:e,projectId:n.folderId});let a=vt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await x({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(M??[],e,n.parentId)){a.error(v());return}await p({projectId:e,parentId:n.parentId})}let o=vt(n.list,e=>e._id,e=>e.sortKey,e,t);o&&await se({projectId:e,...o});return}}catch{a.error(v())}},[,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":we(),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:_e(),onClick:()=>{g({projectId:e.project._id,hidden:!1})},children:[(0,Z.jsx)(He,{"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:xe()}),(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":y(),children:[(0,Z.jsx)(P,{variant:C===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":y(),title:y(),"aria-pressed":C===`cards`,onClick:()=>T(`cards`),children:(0,Z.jsx)(mt,{})}),(0,Z.jsx)(P,{variant:C===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":h(),title:h(),"aria-pressed":C===`columns`,onClick:()=>T(`columns`),children:(0,Z.jsx)(ft,{})}),(0,Z.jsx)(P,{variant:C===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":f(),title:f(),"aria-pressed":C===`list`,onClick:()=>T(`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,{}),ee()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await r({title:_(),label:be(),placeholder:ve(),confirmLabel:ce()});t&&await d({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(ke,{}),_()]}),(0,Z.jsxs)(Ve,{children:[(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":te(),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,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>J(!0),children:[(0,Z.jsx)(pt,{}),` `,me()]}),(0,Z.jsx)(Pe,{children:Se()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void c({projectId:e.project._id,color:null}),"aria-label":de(),children:`✕`}),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 c({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=le?.folders??0,a=le?.chats??0;await n({title:u({name:e.project.name}),description:i>0?re({folders:i,chats:a}):a>0?ie({count:a}):ue(),confirmWord:A(),confirmLabel:m(),destructive:!0})&&(await l({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Z.jsx)(nt,{}),` `,A()]})]})]})]})]}),C===`columns`?(0,Z.jsx)(Ft,{data:E,currentId:e.project._id,busyIds:N,suppressClick:$,locateChatId:k??null}):C===`list`?(0,Z.jsx)(Mt,{data:D,busyIds:N,suppressClick:$,locateChatId:k??null}):(0,Z.jsxs)(Z.Fragment,{children:[e.children.length>0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:i()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(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:he()}),e.chats.length>0?(0,Z.jsx)(W,{value:z,onChange:e=>rt(e.target.value),placeholder:ne(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?o():b()}):Bt.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Te({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:N.has(t._id),unread:Fe.has(t._id),locate:t._id===k,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:ge()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Te({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||fe()}),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:oe(),canSubmit:U.trim().length>0,onSubmit:async()=>{await s({projectId:e.project._id,name:U.trim()}),H(!1)},submitLabel:w(),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:ye(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void p({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})+` · `:``,l({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=S(j.chats.setChatSidebar),n=e.inSidebar?N():a();return(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Z.jsx)(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||Ce()}),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:C(),"aria-label":C()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:p(),"aria-label":p()}):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:r}){let[i,a]=(0,X.useState)(new Set),s=(0,X.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:x()});if(e===null)return null;let c=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),l=(a,o)=>{let u=s.get(a??e.rootId)??[],d=Qe(e.folders,a);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===r,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:a??e.rootId,depth:o,folded:i.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:i.has(t._id)?null:l(t._id,o+1)},t._id))})]})};return(0,Z.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Qe(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:o()}):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?g():T(),"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||Ce()}),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:r,locateChatId:i}){let a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:x()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(It,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.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:b()}):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||Ce()}),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{$_ as r,Av as i,Bv as a,Cv as o,D as s,Dv as c,Ev as l,Gv as u,Hv as d,Iv as f,Jv as p,Kv as m,Lv as h,Mv as g,Nv as _,Ov as ee,Pv as v,Qv as te,Rv as y,Sv as b,Tv as ne,Uv as re,Wv as ie,Z_ as ae,Zv as oe,Zz as x,aB as S,av as se,ay as ce,bv as le,cv as ue,ev as de,ey as C,fg as fe,gv as pe,hv as me,iv as w,jv as T,kv as he,lv as ge,mv as E,nt as _e,nv as D,oB as O,oy as ve,pv as ye,rv as k,sv as A,sy as be,t as j,tt as xe,tv as Se,ty as Ce,vv as we,wv as Te,xv as M,yv as Ee,zv as N}from"./api-Borb_oKz.js";import{t as De}from"./list-DfIPa6Dk.js";import{t as P}from"./button-Bcf40mKN.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-lMzb_P_p.js";var ft=s(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),pt=s(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),mt=s(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Y=s(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),X=t(e(),1),Z=n();function ht({className:e}){return(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":se(),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 o=S(j.projects.renameProject),s=S(j.projects.setProjectColor),c=S(j.projects.moveProject),l=S(j.projects.deleteProject),f=S(j.projects.createProject),p=Xe(),h=Ze(),[g,ee]=(0,X.useState)(!1),[v,te]=(0,X.useState)(t),[y,b]=(0,X.useState)(!1),[ne,ae]=(0,X.useState)(!1),x=O(j.projects.projectTreeCount,ne?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ve,{onOpenChange:e=>e&&ae(!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,{}),` `,d()]}),(0,Z.jsxs)(R,{onSelect:()=>{te(t),ee(!0)},children:[(0,Z.jsx)(et,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await h({title:_(),label:be(),placeholder:ve(),confirmLabel:ce()});t&&await f({name:t,parentId:e})})},children:[(0,Z.jsx)(ke,{}),` `,_()]}),(0,Z.jsxs)(R,{onSelect:()=>b(!0),children:[(0,Z.jsx)(pt,{}),` `,me()]}),(0,Z.jsx)(Pe,{children:Se()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void s({projectId:e,color:null}),"aria-label":de(),children:`✕`}),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 s({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=x?.folders??0,r=x?.chats??0;await p({title:u({name:t}),description:n>0?re({folders:n,chats:r}):r>0?ie({count:r}):ue(),confirmWord:A(),confirmLabel:m(),destructive:!0})&&await l({projectId:e})})},children:[(0,Z.jsx)(nt,{}),` `,A()]})]})]}),(0,Z.jsx)($e,{open:g,onOpenChange:ee,title:oe(),canSubmit:v.trim().length>0,onSubmit:async()=>{await o({projectId:e,name:v.trim()}),ee(!1)},submitLabel:w(),children:(0,Z.jsx)(W,{value:v,onChange:e=>te(e.target.value),autoFocus:!0})}),y?(0,Z.jsx)(ot,{open:y,onOpenChange:b,title:ye(),movingFolderId:e,currentId:r,onPick:t=>void c({projectId:e,parentId:t})}):null]})}function gt({chat:e,currentFolderId:t,className:n}){let i=S(j.chats.pinChat),o=S(j.chats.deleteChat),s=S(j.chats.renameChat),c=S(j.chats.setChatSidebar),l=S(j.chats.moveChatToProject),u=Xe(),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(e.title??``),[h,g]=(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:()=>{m(e.title??``),f(!0)},children:[(0,Z.jsx)(et,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>void i({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(ct,{}):(0,Z.jsx)(J,{}),e.pinned?k():D()]}),(0,Z.jsxs)(R,{onSelect:()=>g(!0),children:[(0,Z.jsx)(pt,{}),` `,pe()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(R,{onSelect:()=>void c({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(qe,{}):(0,Z.jsx)(Y,{}),e.inSidebar?N():a()]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await u({title:r(),description:ue(),confirmLabel:A(),destructive:!0})&&await o({chatId:e._id})})},children:[(0,Z.jsx)(nt,{}),` `,A()]})]})]}),(0,Z.jsx)($e,{open:d,onOpenChange:f,title:ae(),canSubmit:p.trim().length>0,onSubmit:async()=>{await s({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:w(),children:(0,Z.jsx)(W,{value:p,onChange:e=>m(e.target.value),autoFocus:!0})}),h?(0,Z.jsx)(ot,{open:h,onOpenChange:g,title:E(),currentId:t,onPick:t=>void l({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=O(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:x()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:M()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:le()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:Ee()})]}):(0,Z.jsx)(Et,{page:n})})}function Et({page:e}){let t=I(),n=Xe(),r=Ze(),a=Me(),s=S(j.projects.renameProject),c=S(j.projects.setProjectColor),l=S(j.projects.deleteProject),d=S(j.projects.createProject),p=S(j.projects.moveProject),g=S(j.projects.setProjectSidebar),ae=S(j.chats.moveChatToProject),x=S(j.chats.reorderChat),se=S(j.projects.reorderProject),le=O(j.projects.projectTreeCount,{projectId:e.project._id}),[C,pe]=(0,X.useState)(xt),T=e=>{localStorage.setItem(bt,e),pe(e)},E=O(j.projects.folderColumns,C===`columns`?{projectId:e.project._id}:`skip`),D=O(j.projects.projectTreeList,C===`list`?{projectId:e.project._id}:`skip`),{c:k}=Re({from:`/project/$projectId`}),M=O(j.projects.listProjects,{}),Ee=O(j.chatReads.myBusyChats,{}),N=(0,X.useMemo)(()=>new Set(Ee??[]),[Ee]),Ae=O(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=O(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=E?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||Ce()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(M??[]).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 E?.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 E?.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 ae({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Le(M??[],t,e)){a.error(v());return}await p({projectId:t,parentId:e})}return}if(o&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=Nt(t);if(!n)return;n.list.some(t=>t._id===e)||await ae({chatId:e,projectId:n.folderId});let a=vt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await x({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(M??[],e,n.parentId)){a.error(v());return}await p({projectId:e,parentId:n.parentId})}let o=vt(n.list,e=>e._id,e=>e.sortKey,e,t);o&&await se({projectId:e,...o});return}}catch{a.error(v())}},[,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":we(),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:_e(),onClick:()=>{g({projectId:e.project._id,hidden:!1})},children:[(0,Z.jsx)(He,{"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:xe()}),(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":y(),children:[(0,Z.jsx)(P,{variant:C===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":y(),title:y(),"aria-pressed":C===`cards`,onClick:()=>T(`cards`),children:(0,Z.jsx)(mt,{})}),(0,Z.jsx)(P,{variant:C===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":h(),title:h(),"aria-pressed":C===`columns`,onClick:()=>T(`columns`),children:(0,Z.jsx)(ft,{})}),(0,Z.jsx)(P,{variant:C===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":f(),title:f(),"aria-pressed":C===`list`,onClick:()=>T(`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,{}),ee()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await r({title:_(),label:be(),placeholder:ve(),confirmLabel:ce()});t&&await d({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(ke,{}),_()]}),(0,Z.jsxs)(Ve,{children:[(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":te(),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,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>J(!0),children:[(0,Z.jsx)(pt,{}),` `,me()]}),(0,Z.jsx)(Pe,{children:Se()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void c({projectId:e.project._id,color:null}),"aria-label":de(),children:`✕`}),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 c({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=le?.folders??0,a=le?.chats??0;await n({title:u({name:e.project.name}),description:i>0?re({folders:i,chats:a}):a>0?ie({count:a}):ue(),confirmWord:A(),confirmLabel:m(),destructive:!0})&&(await l({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Z.jsx)(nt,{}),` `,A()]})]})]})]})]}),C===`columns`?(0,Z.jsx)(Ft,{data:E,currentId:e.project._id,busyIds:N,suppressClick:$,locateChatId:k??null}):C===`list`?(0,Z.jsx)(Mt,{data:D,busyIds:N,suppressClick:$,locateChatId:k??null}):(0,Z.jsxs)(Z.Fragment,{children:[e.children.length>0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:i()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(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:he()}),e.chats.length>0?(0,Z.jsx)(W,{value:z,onChange:e=>rt(e.target.value),placeholder:ne(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?o():b()}):Bt.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Te({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:N.has(t._id),unread:Fe.has(t._id),locate:t._id===k,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:ge()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Te({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||fe()}),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:oe(),canSubmit:U.trim().length>0,onSubmit:async()=>{await s({projectId:e.project._id,name:U.trim()}),H(!1)},submitLabel:w(),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:ye(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void p({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})+` · `:``,l({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=S(j.chats.setChatSidebar),n=e.inSidebar?N():a();return(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Z.jsx)(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||Ce()}),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:C(),"aria-label":C()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:p(),"aria-label":p()}):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:r}){let[i,a]=(0,X.useState)(new Set),s=(0,X.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:x()});if(e===null)return null;let c=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),l=(a,o)=>{let u=s.get(a??e.rootId)??[],d=Qe(e.folders,a);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===r,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:a??e.rootId,depth:o,folded:i.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:i.has(t._id)?null:l(t._id,o+1)},t._id))})]})};return(0,Z.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Qe(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:o()}):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?g():T(),"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||Ce()}),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:r,locateChatId:i}){let a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:x()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(It,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.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:b()}):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||Ce()}),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{$b as r,Mi as i,Ni as a,Q as o,Qb as s,Tx as c,_x as l,aB as u,ax as d,bo as f,cc as p,co as m,cx as h,dc as g,do as _,dx as v,ex as y,fx as ee,gx as b,hx as x,ix as S,ji as C,lc as w,lo as T,lx as E,mx as D,nx as O,oB as k,ox as te,px as ne,rx as re,sc as ie,so as ae,sx as oe,t as A,tx as j,uc as M,uo as N,ux as P,vo as F,wx as I,xo as L,yo as R}from"./api-CCk5U5gB.js";import{i as z,n as B,r as V,t as H}from"./FieldLabel-8vj4ipPC.js";import{t as U}from"./button-CbUSFbZL.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-DY7zoioz.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:ee,help:v},documentary_fetch:{label:P,help:E},inbound_files:{label:h,help:oe},history_summary:{label:g,help:M},file_curation:{label:L,help:_},quote_reply:{label:f,help:R}},he={outboundDir:`/home/node/.openclaw/media/outbound`,references:`- gdrive/1a2b3c4d5e6f7890abcd
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$b as r,Mi as i,Ni as a,Q as o,Qb as s,Tx as c,_x as l,aB as u,ax as d,bo as f,cc as p,co as m,cx as h,dc as g,do as _,dx as v,ex as y,fx as ee,gx as b,hx as x,ix as S,ji as C,lc as w,lo as T,lx as E,mx as D,nx as O,oB as k,ox as te,px as ne,rx as re,sc as ie,so as ae,sx as oe,t as A,tx as j,uc as M,uo as N,ux as P,vo as F,wx as I,xo as L,yo as R}from"./api-Borb_oKz.js";import{i as z,n as B,r as V,t as H}from"./FieldLabel-DvlvfpGK.js";import{t as U}from"./button-Bcf40mKN.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-lMzb_P_p.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:ee,help:v},documentary_fetch:{label:P,help:E},inbound_files:{label:h,help:oe},history_summary:{label:g,help:M},file_curation:{label:L,help:_},quote_reply:{label:f,help:R}},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:y,references:r,files:s,previous_summary:w,new_messages:p,max_chars:ie,file_name:N,budget_chars:T,feedback:m,content:ae,excerpt:F};function _e(){let e=k(A.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:d()})});let r=e.find(e=>e._id===t)??e[0];return(0,$.jsxs)(`div`,{className:`oc-injtab`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,$.jsx)(B,{label:l(),help:b()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:te()}),(0,$.jsxs)(q,{value:r._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:r},r._id)]})}function ve({instance:e}){let t=u(A.admin.upsertInstanceConfig),n=se(),r=k(A.me.getMe,{host:ue}),o=e.config??{},s=Z(e.config?.contentLocale,r?.defaultLocale??void 0),[l,d]=(0,Q.useState)(()=>z(o,s));(0,Q.useEffect)(()=>{d(z(o,s))},[s,e._id]);let[f,p]=(0,Q.useState)(!1),m=l.promptInjections,h=(e,t)=>d({...l,promptInjections:{...m,[e]:{...m[e],...t}}});async function g(){p(!0);try{await t({instanceId:e._id,config:V(l,o,s)})}catch(e){n.error(I(),e)}finally{p(!1)}}async function _(r){let i={...e.config??{}};r==="default"?delete i.contentLocale:i.contentLocale=r;try{await t({instanceId:e._id,config:i})}catch(e){n.error(I(),e)}}let v=e.config?.contentLocale??`default`,y=fe[Z(void 0,r?.defaultLocale??void 0)];return(0,$.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,$.jsx)(`span`,{children:a()}),(0,$.jsxs)(q,{value:v,onValueChange:e=>void _(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:C({locale:y})}),pe().map(e=>(0,$.jsx)(G,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:i()})]}),ce.map(e=>(0,$.jsx)(ye,{injKey:e,def:J[e],i18n:me[e],row:m[e]??{enabled:!0,template:J[e].defaultTemplate[s]},contentLocale:s,onChange:t=>h(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(U,{size:`sm`,onClick:()=>void g(),disabled:f,children:c()})})]})}function ye({injKey:e,def:t,i18n:n,row:r,contentLocale:i,onChange:a}){let[s,c]=(0,Q.useState)(!1),l=r.template.trim()!==t.defaultTemplate[i],u=t.togglable&&!r.enabled,d=Object.fromEntries(t.placeholders.map(e=>[e,he[e]??`{${e}}`])),f=le(e,r,i),p=f?K(f,d):``;return(0,$.jsxs)(`section`,{className:`oc-injcard`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,$.jsxs)(`label`,{className:`oc-field--row`,children:[(0,$.jsx)(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()}),l&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:D()})]}),(0,$.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:u,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:ne()}),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:()=>c(e=>!e),children:s?re():S()}),l&&(0,$.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>a({template:t.defaultTemplate[i]}),children:x()})]})]}),s&&(0,$.jsx)(`div`,{className:`oc-injcard__preview`,children:p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:p}),(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:O()}),t.pluralDefaultTemplate!==void 0&&!u?(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:o()}):null]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:j()})})]})}export{_e as PromptInjectionsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$w as r,Aw as i,Bw as a,Dw as ee,Ew as o,Go as s,Gw as c,Hw as l,Jw as u,Kw as d,Mw as f,Nw as te,Ow as p,Pw as m,Qw as ne,Uw as h,Vw as re,Ww as ie,Xw as ae,Yw as g,Zw as _,aB as v,aT as y,cT as b,dT as x,eT as S,fT as C,hT as w,iT as T,jw as E,kw as D,lT as O,mT as k,nT as A,oB as j,oT as M,pT as N,qw as P,rT as F,sT as I,t as L,tT as R,uT as z}from"./api-CCk5U5gB.js";import{t as B}from"./button-CbUSFbZL.js";import{Dt as V,En as H,Et as U,U as W,_ as G,jt as K,ut as q}from"./index-DY7zoioz.js";import{t as J}from"./roleDescriptions-Du6v2lbA.js";var Y=t(e(),1),X=n(),Z=[{group:()=>w(),keys:[{key:`traces.read`,label:()=>z()},{key:`traces.read.content`,label:()=>O(),phi:!0},{key:`traces.write`,label:()=>b()}]},{group:()=>k(),keys:[{key:`kpi.read`,label:()=>z()},{key:`kpi.write`,label:()=>b()}]},{group:()=>N(),keys:[{key:`openclaw.query`,label:()=>I()},{key:`anomalies.read`,label:()=>M()},{key:`anomalies.report`,label:()=>y()}]},{group:()=>C(),keys:[{key:`chats.read`,label:()=>z()},{key:`selfheal`,label:()=>F()},{key:`feedback.respond`,label:()=>s()}]},{group:()=>x(),keys:[{key:`admin.manage`,label:()=>T()}]}],oe=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function se(){let e=j(L.apiKeys.listRoles,{}),t=v(L.apiKeys.createRole),n=v(L.apiKeys.ensureRolesSeeded),s=v(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))}),y=W(),b=V(),[x,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)($),[O,k]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{b.error(R(),e)})},[n,b]);let M=e??[];async function N(e,t){if(Q(e.permissions))return;if(e.builtin){await y({title:S({name:e.name}),description:r(),confirmLabel:ne()});return}if(O.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];k(t=>new Set(t).add(e._id));try{await s({roleId:e._id,permissions:n})}catch(e){b.error(_(),e)}finally{k(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function F(){try{await t({key:w.key,name:w.name,description:w.description||void 0,permissions:[]}),T($),C(!1)}catch(e){b.error(ae(),e)}}let I=e===void 0,z=!I&&M.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[g(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,u(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,P()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:d()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{T($),C(!0)},children:c()})})]}),I?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:ie()}):z?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:h()}):(0,X.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,X.jsxs)(`table`,{className:`oc-matrix`,children:[(0,X.jsxs)(`thead`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:l()}),Z.map(e=>(0,X.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,X.jsx)(`tr`,{children:Z.flatMap(e=>e.keys.map(e=>(0,X.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?A({key:e.key}):e.key,children:[e.label(),e.phi?(0,X.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,X.jsx)(`tbody`,{children:M.map(e=>{let t=Q(e.permissions),n=O.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,{}),` `,re()]}):(0,X.jsx)(U,{variant:`secondary`,children:a()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),oe.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(q,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?m():n?te():r,onCheckedChange:()=>void N(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(G,{open:x,onOpenChange:C,title:f(),description:E(),canSubmit:!!(w.key&&w.name),onSubmit:F,submitLabel:i(),children:(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:D()}),(0,X.jsx)(K,{value:w.key,placeholder:p(),onChange:e=>T({...w,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:ee()}),(0,X.jsx)(K,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:o()}),(0,X.jsx)(K,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})})]})}export{se as RolesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$w as r,Aw as i,Bw as a,Dw as ee,Ew as o,Go as s,Gw as c,Hw as l,Jw as u,Kw as d,Mw as f,Nw as te,Ow as p,Pw as m,Qw as ne,Uw as h,Vw as re,Ww as ie,Xw as ae,Yw as g,Zw as _,aB as v,aT as y,cT as b,dT as x,eT as S,fT as C,hT as w,iT as T,jw as E,kw as D,lT as O,mT as k,nT as A,oB as j,oT as M,pT as N,qw as P,rT as F,sT as I,t as L,tT as R,uT as z}from"./api-Borb_oKz.js";import{t as B}from"./button-Bcf40mKN.js";import{Dt as V,En as H,Et as U,U as W,_ as G,jt as K,ut as q}from"./index-lMzb_P_p.js";import{t as J}from"./roleDescriptions-xzqDDCcp.js";var Y=t(e(),1),X=n(),Z=[{group:()=>w(),keys:[{key:`traces.read`,label:()=>z()},{key:`traces.read.content`,label:()=>O(),phi:!0},{key:`traces.write`,label:()=>b()}]},{group:()=>k(),keys:[{key:`kpi.read`,label:()=>z()},{key:`kpi.write`,label:()=>b()}]},{group:()=>N(),keys:[{key:`openclaw.query`,label:()=>I()},{key:`anomalies.read`,label:()=>M()},{key:`anomalies.report`,label:()=>y()}]},{group:()=>C(),keys:[{key:`chats.read`,label:()=>z()},{key:`selfheal`,label:()=>F()},{key:`feedback.respond`,label:()=>s()}]},{group:()=>x(),keys:[{key:`admin.manage`,label:()=>T()}]}],oe=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function se(){let e=j(L.apiKeys.listRoles,{}),t=v(L.apiKeys.createRole),n=v(L.apiKeys.ensureRolesSeeded),s=v(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))}),y=W(),b=V(),[x,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)($),[O,k]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{b.error(R(),e)})},[n,b]);let M=e??[];async function N(e,t){if(Q(e.permissions))return;if(e.builtin){await y({title:S({name:e.name}),description:r(),confirmLabel:ne()});return}if(O.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];k(t=>new Set(t).add(e._id));try{await s({roleId:e._id,permissions:n})}catch(e){b.error(_(),e)}finally{k(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function F(){try{await t({key:w.key,name:w.name,description:w.description||void 0,permissions:[]}),T($),C(!1)}catch(e){b.error(ae(),e)}}let I=e===void 0,z=!I&&M.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[g(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,u(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,P()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:d()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{T($),C(!0)},children:c()})})]}),I?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:ie()}):z?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:h()}):(0,X.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,X.jsxs)(`table`,{className:`oc-matrix`,children:[(0,X.jsxs)(`thead`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:l()}),Z.map(e=>(0,X.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,X.jsx)(`tr`,{children:Z.flatMap(e=>e.keys.map(e=>(0,X.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?A({key:e.key}):e.key,children:[e.label(),e.phi?(0,X.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,X.jsx)(`tbody`,{children:M.map(e=>{let t=Q(e.permissions),n=O.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,{}),` `,re()]}):(0,X.jsx)(U,{variant:`secondary`,children:a()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),oe.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(q,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?m():n?te():r,onCheckedChange:()=>void N(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(G,{open:x,onOpenChange:C,title:f(),description:E(),canSubmit:!!(w.key&&w.name),onSubmit:F,submitLabel:i(),children:(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:D()}),(0,X.jsx)(K,{value:w.key,placeholder:p(),onChange:e=>T({...w,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:ee()}),(0,X.jsx)(K,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:o()}),(0,X.jsx)(K,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})})]})}export{se as RolesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$L as r,$z as i,AL as a,AR as o,BI as s,CR as c,D as l,DL as u,DR as ee,ER as te,FI as d,FL as f,FR as p,GI as ne,GL as re,HI as ie,HL as ae,II as oe,IL as se,JI as ce,JL as le,KI as ue,KL as de,LI as fe,ML as pe,MR as me,NL as he,NR as ge,OI as _e,OL as ve,OR as ye,PI as be,PL as xe,PR as Se,QL as Ce,RI as we,RL as Te,SL as Ee,SR as De,TR as Oe,UI as ke,UL as Ae,VI as je,VL as Me,WI as Ne,WL as Pe,XI as Fe,YI as Ie,YL as m,ZI as Le,ZL as Re,Zz as ze,_L as Be,bL as h,bR as Ve,cL as He,dL as g,eR as Ue,fL as We,gL as Ge,hL as Ke,jL as qe,jR as Je,kL as Ye,kR as Xe,lL as Ze,mL as Qe,nR as $e,oB as et,pL as tt,qI as nt,qL as rt,rB as _,sL as it,t as v,tR as at,uL as y,vL as ot,wR as st,xL as b,xR as ct,yL as lt,zI as ut}from"./api-CCk5U5gB.js";import{t as dt}from"./list-wMpxVo2w.js";import{t as x}from"./button-CbUSFbZL.js";import{$ as S,Bn as C,Bt as w,Ct as ft,Dn as pt,Dt as mt,Et as T,Q as E,Rt as D,St as ht,Tt as gt,Vn as O,X as k,Z as A,_n as _t,_t as vt,at as yt,bn as bt,bt as xt,dn as St,et as j,gt as Ct,hn as wt,it as Tt,jt as Et,nt as Dt,on as Ot,ot as kt,q as At,rt as jt,tt as Mt,vt as Nt,wt as Pt,xn as Ft,xt as It,yt as Lt,zt as M}from"./index-DY7zoioz.js";import{a as Rt,i as N,n as zt,o as Bt,r as P,t as Vt}from"./table-BhYNJKZu.js";import{t as Ht}from"./FilterBar-BJ1mhU3e.js";/* empty css */import{a as Ut,c as F,i as I,l as Wt,n as Gt,o as L,r as Kt,s as qt,t as Jt,u as R}from"./TimezoneCombobox-D2e6UjGY.js";var Yt=l(`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`}]]),Xt=l(`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`}]]),z=t(e(),1),B=n();function V(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 Zt({value:e,onChange:t}){let n=Wt(e),r=(0,z.useMemo)(()=>new Date,[]),[a,o]=(0,z.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[s,c]=(0,z.useState)(!1),l=(0,z.useMemo)(()=>V(i()),[]),u=(0,z.useMemo)(()=>new Intl.DateTimeFormat(i(),{month:`long`,year:`numeric`}),[]),ee=(0,z.useMemo)(()=>new Intl.DateTimeFormat(i(),{dateStyle:`medium`,timeStyle:`short`}),[]),te=F(a.year,a.month),d=n?.hour??9,f=n?.minute??0,p=(e,n,r,i,a)=>t(R(e,n,r,i,a)),ne=(e,t,n)=>{o({year:e,month:t}),p(e,t,n,d,f)},re=e=>{let t=new Date(a.year,a.month+e,1);o({year:t.getFullYear(),month:t.getMonth()})},ie=n===null?b():ee.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,B.jsxs)(D,{modal:!0,open:s,onOpenChange:c,children:[(0,B.jsx)(w,{asChild:!0,children:(0,B.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":Ee(),children:[(0,B.jsx)(Yt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,B.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:ie})]})}),(0,B.jsxs)(M,{align:`start`,className:`oc-dtp__pop`,children:[(0,B.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":h(),onClick:()=>re(-1),children:(0,B.jsx)(O,{size:15,"aria-hidden":!0})}),(0,B.jsx)(`span`,{className:`oc-dtp__month`,children:u.format(new Date(a.year,a.month,1))}),(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":lt(),onClick:()=>re(1),children:(0,B.jsx)(C,{size:15,"aria-hidden":!0})})]}),(0,B.jsxs)(`div`,{className:`oc-dtp__grid`,children:[l.map((e,t)=>(0,B.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,B.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,B.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,B.jsxs)(k,{value:String(d),onValueChange:e=>p(a.year,a.month,n?.day??r.getDate(),Number(e),f),children:[(0,B.jsx)(S,{size:`sm`,"aria-label":ot(),children:(0,B.jsx)(j,{})}),(0,B.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,B.jsx)(E,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,B.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,B.jsxs)(k,{value:String(f),onValueChange:e=>p(a.year,a.month,n?.day??r.getDate(),d,Number(e)),children:[(0,B.jsx)(S,{size:`sm`,"aria-label":Be(),children:(0,B.jsx)(j,{})}),(0,B.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,B.jsx)(E,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function H(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Qt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function $t(e){let t=new Map;for(let n of e){let e=H(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 U(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(Qt(t,n,a));i!==void 0&&i.length>0&&r.set(a,i.length)}return r}function en(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 tn(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 nn(e){return{startMs:new Date(e,0,1).getTime(),endMs:new Date(e+1,0,1).getTime()}}var W=3;function rn({events:e,mode:t,cursor:n,onModeChange:r,onCursorChange:a,onEventClick:o,footnote:s}){let c=i(),l=(0,z.useMemo)(()=>$t(e),[e]),u=(0,z.useMemo)(()=>en(c),[c]),ee=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`,year:`numeric`}),[c]),te=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`}),[c]),d=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{hour:`2-digit`,minute:`2-digit`}),[c]),f=new Date,p=e=>{if(t===`year`){a({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);a({year:r.getFullYear(),month:r.getMonth()})},ne=t===`year`?String(n.year):ee.format(new Date(n.year,n.month,1));return(0,B.jsxs)(`div`,{className:`oc-cal`,children:[(0,B.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,B.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":y(),onClick:()=>p(-1),children:(0,B.jsx)(O,{})}),(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":Ze(),onClick:()=>p(1),children:(0,B.jsx)(C,{})}),(0,B.jsx)(x,{variant:`ghost`,size:`sm`,onClick:()=>a({year:f.getFullYear(),month:f.getMonth()}),children:g()})]}),(0,B.jsx)(`span`,{className:`oc-cal__title`,children:ne}),(0,B.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,B.jsx)(x,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:tt()}),(0,B.jsx)(x,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:We()})]})]}),t===`month`?(0,B.jsx)(an,{cursor:n,byDay:l,weekdays:u,timeFmt:d,now:f,onEventClick:o}):(0,B.jsx)(on,{year:n.year,byDay:l,monthShortFmt:te,now:f,onOpenMonth:e=>{a({year:n.year,month:e}),r(`month`)}}),s?(0,B.jsx)(`p`,{className:`oc-cal__footnote`,children:s}):null]})}function an({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=F(e.year,e.month);return(0,B.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,B.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Qt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,B.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,B.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,W).map(e=>(0,B.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,B.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,B.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>W?(0,B.jsx)(`span`,{className:`oc-cal__more`,children:He({count:o.length-W})}):null]},n)})]})}function on({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,B.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=U(t,e,o),c=F(e,o);return(0,B.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,B.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,B.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,B.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var G={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])*G[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=L(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(qt(e)){case`ok`:return(0,B.jsx)(T,{variant:`secondary`,children:f()});case`error`:return(0,B.jsx)(T,{variant:`destructive`,children:he()});case`running`:return(0,B.jsx)(T,{variant:`outline`,children:pe()});case`other`:return(0,B.jsx)(T,{variant:`outline`,children:e});case`none`:return(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function pn(){let e=_(v.scheduled.listMyCrons),t=_(v.scheduled.getCronDetail),n=_(v.scheduled.listCronRuns),l=_(v.scheduled.updateCron),Ee=_(v.scheduled.removeCron),Be=_(v.scheduled.runCronNow),h=mt(),He=et(v.me.getMe,{host:At})?.timezone,[g,We]=(0,z.useState)(null),[Ze,tt]=(0,z.useState)(!1),[y,ot]=(0,z.useState)(!1),[b,lt]=(0,z.useState)(null),[C,w]=(0,z.useState)(null),[D,O]=(0,z.useState)(null),[M,F]=(0,z.useState)(null),[Wt,qt]=(0,z.useState)(!1),[R,V]=(0,z.useState)(Gt),[H,Qt]=(0,z.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),$t=e=>{localStorage.setItem(`oc.sched.view`,e),Qt(e)},[U,en]=(0,z.useState)(`month`),[W,an]=(0,z.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),on=(0,z.useMemo)(()=>{let e=[];for(let t of g??[]){if(!t.supported||t.error!==null)continue;let n=t.kind===`openclaw`&&t.manageSupported;for(let r of t.jobs)Ut(r,R)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[g,R]),G=(0,z.useMemo)(()=>U===`year`?nn(W.year):tn(W.year,W.month),[U,W]),sn=(0,z.useMemo)(()=>un(on,G.startMs,G.endMs),[on,G]),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,z.useCallback)(async()=>{tt(!0),ot(!1);try{We(await e({}))}catch{ot(!0)}finally{tt(!1)}},[e]);(0,z.useEffect)(()=>{q()},[q]);let cn=(0,z.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),J=(0,z.useRef)(null);(0,z.useEffect)(()=>{g!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[g]);let Y=(0,z.useMemo)(()=>new Intl.DateTimeFormat(i(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{lt(e);try{await t(),h.success(n),await q()}catch(e){h.toast({variant:`error`,title:m({code:dn(e)})})}finally{lt(null)}},Z=(0,z.useRef)(0),Q=(0,z.useRef)(0),ln=async(e,t)=>{if(t.id===null)return;let r=++Z.current;O({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Z.current)return;O({name:t.name??t.id,entries:i})}catch(e){if(r!==Z.current)return;O(null),h.toast({variant:`error`,title:m({code:dn(e)})})}},pn=async(e,n)=>{if(n.id===null)return;let r=++Q.current;F({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;F(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;F(null),h.toast({variant:`error`,title:m({code:dn(e)})})}},mn=async()=>{if(M===null)return;let e={};if(M.nameDirty&&M.name.trim()===``||M.messageDirty&&M.hasMessage&&M.message.trim()===``){h.toast({variant:`error`,title:be()});return}if(M.nameDirty&&M.name.trim()!==``&&(e.name=M.name.trim()),M.scheduleDirty){if(M.scheduleKind===`cron`&&M.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:M.cronExpr.trim(),...M.tz.trim()===``?{}:{tz:M.tz.trim()}};else if(M.scheduleKind===`every`){let t=Number(M.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*$[M.everyUnit])})}else if(M.scheduleKind===`at`&&M.at!==``){let t=Date.parse(M.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(M.scheduleDirty&&e.schedule===void 0){h.toast({variant:`error`,title:d()});return}if(M.messageDirty&&M.hasMessage&&M.message.trim()!==``&&(e.message=M.message.trim()),Object.keys(e).length===0){F(null);return}let t=Q.current;qt(!0);try{await l({instanceName:M.instanceName,jobId:M.jobId,patch:e}),h.success(ce()),t===Q.current&&F(null),await q()}catch(e){h.toast({variant:`error`,title:m({code:dn(e)})})}finally{qt(!1)}},hn=g?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,B.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:p()}),(0,B.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":Ge(),children:[(0,B.jsx)(x,{variant:H===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ke(),title:Ke(),"aria-pressed":H===`list`,onClick:()=>$t(`list`),children:(0,B.jsx)(dt,{})}),(0,B.jsx)(x,{variant:H===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Qe(),title:Qe(),"aria-pressed":H===`calendar`,onClick:()=>$t(`calendar`),children:(0,B.jsx)(Yt,{})})]}),(0,B.jsxs)(x,{variant:`ghost`,size:`sm`,onClick:()=>void q(),disabled:Ze,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,B.jsx)(wt,{size:14,"aria-hidden":!0}),Se()]})]}),g!==null&&hn>0?(0,B.jsxs)(Ht,{q:R.q,onQChange:e=>V(t=>({...t,q:e})),searchPlaceholder:a(),onReset:()=>V(Gt),canReset:Kt(R),children:[(0,B.jsxs)(k,{value:R.state,onValueChange:e=>V(t=>({...t,state:e})),children:[(0,B.jsx)(S,{size:`sm`,className:`w-40`,children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(E,{value:`all`,children:Ye()}),(0,B.jsx)(E,{value:`active`,children:ct()}),(0,B.jsx)(E,{value:`paused`,children:De()}),(0,B.jsx)(E,{value:`auto-disabled`,children:Ve()})]})]}),(0,B.jsxs)(k,{value:R.result,onValueChange:e=>V(t=>({...t,result:e})),children:[(0,B.jsx)(S,{size:`sm`,className:`w-40`,children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(E,{value:`all`,children:ve()}),(0,B.jsx)(E,{value:`ok`,children:f()}),(0,B.jsx)(E,{value:`error`,children:he()}),(0,B.jsx)(E,{value:`running`,children:pe()}),(0,B.jsx)(E,{value:`none`,children:qe()})]})]})]}):null,g===null?(0,B.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":Ze,children:y?ge():ze()}):H===`calendar`?(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ge()}):null,g.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:me()}):(0,B.jsx)(rn,{events:sn.events,mode:U,cursor:W,onModeChange:en,onCursorChange:an,onEventClick:K,footnote:it()})]}):(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ge()}):null,g.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:me()}):null,g.map(e=>{let t=e.jobs.filter(e=>Ut(e,R)),n=Kt(R)&&e.jobs.length>0&&t.length===0;return(0,B.jsxs)(`section`,{style:{marginBottom:20},children:[g.length>1||e.error||!e.supported?(0,B.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,B.jsx)(T,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:o({code:e.error})}):e.jobs.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:Xe()}):n?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):(0,B.jsxs)(Vt,{children:[(0,B.jsx)(Rt,{children:(0,B.jsxs)(Bt,{children:[(0,B.jsx)(N,{children:ye()}),(0,B.jsx)(N,{children:ee()}),(0,B.jsx)(N,{children:te()}),(0,B.jsx)(N,{children:Oe()}),(0,B.jsx)(N,{children:st()}),(0,B.jsx)(N,{children:se()}),(0,B.jsx)(N,{children:Le()})]})}),(0,B.jsx)(zt,{children:t.map((t,n)=>{let i=`${e.instanceName}:${t.id??n}`,a=b===i,o=e.manageSupported,s=e.kind===`openclaw`&&o;return(0,B.jsxs)(Bt,{ref:t.id!==null&&t.id===cn?J:void 0,"data-state":t.id!==null&&t.id===cn?`selected`:void 0,children:[(0,B.jsx)(P,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??c()}),(0,B.jsx)(P,{children:(0,B.jsx)(T,{variant:`secondary`,children:t.agentId})}),(0,B.jsxs)(P,{className:`whitespace-nowrap`,children:[(0,B.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=Ct(t.schedule),n=e===null?null:vt(e);return n===null?null:(0,B.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,B.jsx)(P,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:Y.format(t.nextRunAtMs)}),(0,B.jsx)(P,{children:L(t)===`auto-disabled`?(0,B.jsx)(T,{variant:`destructive`,title:`${t.autoDisabledReason??``}${t.autoDisabledAtMs===null?``:` · ${Y.format(t.autoDisabledAtMs)}`}`,children:Ve()}):L(t)===`active`?(0,B.jsx)(T,{variant:`secondary`,children:ct()}):L(t)===`paused`?(0,B.jsx)(T,{variant:`outline`,children:De()}):(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,B.jsxs)(P,{children:[(0,B.jsx)(fn,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,B.jsx)(T,{variant:`destructive`,title:t.lastDeliveryError??$e(),children:xe()}):null]}),(0,B.jsx)(P,{className:`whitespace-nowrap`,children:t.id===null?(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,B.jsx)(pt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,B.jsxs)(`span`,{className:`oc-cronactions`,children:[s?(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:Ue(),"aria-label":Ue(),disabled:b!==null,onClick:()=>void X(i,async()=>{let n=await Be({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},le()),children:(0,B.jsx)(Ot,{size:14,"aria-hidden":!0})}):null,s&&t.enabled!==null?(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:I(t)===`pause`?r():Ce(),"aria-label":I(t)===`pause`?r():Ce(),disabled:b!==null,onClick:()=>void X(i,()=>l({instanceName:e.instanceName,jobId:t.id,patch:{enabled:I(t)===`resume`}}),I(t)===`pause`?rt():de()),children:I(t)===`pause`?(0,B.jsx)(Ft,{size:14,"aria-hidden":!0}):(0,B.jsx)(_t,{size:14,"aria-hidden":!0})}):null,s?(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:Fe(),"aria-label":Fe(),disabled:b!==null,onClick:()=>void pn(e.instanceName,t),children:(0,B.jsx)(bt,{size:14,"aria-hidden":!0})}):null,s?(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:Ie(),"aria-label":Ie(),disabled:b!==null,onClick:()=>void ln(e.instanceName,t),children:(0,B.jsx)(Xt,{size:14,"aria-hidden":!0})}):null,o?(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:Re(),"aria-label":Re(),disabled:b!==null,onClick:()=>w({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,B.jsx)(St,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:Je()})]},e.instanceName)}),hn>0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:_e()}):null]}),(0,B.jsx)(Nt,{open:C!==null,onOpenChange:e=>{e||w(null)},children:(0,B.jsxs)(It,{children:[(0,B.jsxs)(Pt,{children:[(0,B.jsx)(gt,{children:Pe()}),(0,B.jsx)(ht,{children:Ae({name:C?.name??``})})]}),(0,B.jsxs)(ft,{children:[(0,B.jsx)(xt,{children:ae()}),(0,B.jsx)(Lt,{onClick:()=>{let e=C;w(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>Ee({instanceName:e.instanceName,jobId:e.jobId}),re())},children:Me()})]})]})}),(0,B.jsx)(Mt,{open:D!==null,onOpenChange:e=>{e||(Z.current++,O(null))},children:(0,B.jsxs)(Dt,{style:{maxWidth:640},children:[(0,B.jsx)(yt,{children:(0,B.jsx)(kt,{children:nt({name:D?.name??``})})}),D?.entries===null?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}):D!==null&&D.entries.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}):D===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:D.entries.map((e,t)=>(0,B.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,B.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,B.jsx)(fn,{status:e.status}),(0,B.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?Y.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,B.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,B.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[Te({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,B.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,B.jsx)(Mt,{open:M!==null,onOpenChange:e=>{e||(Q.current++,F(null))},children:(0,B.jsxs)(Dt,{className:`oc-cronedit`,children:[(0,B.jsxs)(yt,{children:[(0,B.jsx)(kt,{children:ne()}),(0,B.jsx)(jt,{children:Ne()})]}),M===null?null:M.loading?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}):(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:ye()}),(0,B.jsx)(Et,{value:M.name,maxLength:200,onChange:e=>F({...M,name:e.target.value,nameDirty:!0})})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:ke()}),(0,B.jsxs)(k,{value:M.scheduleKind,onValueChange:e=>F({...M,scheduleKind:e,scheduleDirty:!0}),children:[(0,B.jsx)(S,{children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(E,{value:`cron`,children:ie()}),(0,B.jsx)(E,{value:`every`,children:je()}),(0,B.jsx)(E,{value:`at`,children:s()})]})]}),M.scheduleKind===`cron`?(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,B.jsx)(Et,{value:M.cronExpr,onChange:e=>F({...M,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,B.jsx)(Jt,{value:M.tz,onChange:e=>F({...M,tz:e,scheduleDirty:!0}),fallbackTz:He??void 0})]}):M.scheduleKind===`every`?(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,B.jsx)(Et,{type:`number`,min:1,value:M.everyValue,onChange:e=>F({...M,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,B.jsxs)(k,{value:M.everyUnit,onValueChange:e=>F({...M,everyUnit:e,scheduleDirty:!0}),children:[(0,B.jsx)(S,{style:{maxWidth:160},children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(E,{value:`minutes`,children:ut()}),(0,B.jsx)(E,{value:`hours`,children:we()}),(0,B.jsx)(E,{value:`days`,children:fe()})]})]})]}):(0,B.jsx)(Zt,{value:M.at,onChange:e=>F({...M,at:e,scheduleDirty:!0})})]}),M.hasMessage?(0,B.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:at()}),(0,B.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:M.message,onChange:e=>F({...M,message:e.target.value,messageDirty:!0})})]}):null]}),(0,B.jsxs)(Tt,{children:[(0,B.jsx)(x,{variant:`ghost`,onClick:()=>F(null),children:ae()}),(0,B.jsxs)(x,{onClick:()=>void mn(),disabled:M===null||M.loading||Wt,children:[Wt?(0,B.jsx)(pt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,oe()]})]})]})})]})}export{pn as ScheduledTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$L as r,$z as i,AL as a,AR as o,BI as s,CR as c,D as l,DL as u,DR as ee,ER as te,FI as d,FL as f,FR as p,GI as ne,GL as re,HI as ie,HL as ae,II as oe,IL as se,JI as ce,JL as le,KI as ue,KL as de,LI as fe,ML as pe,MR as me,NL as he,NR as ge,OI as _e,OL as ve,OR as ye,PI as be,PL as xe,PR as Se,QL as Ce,RI as we,RL as Te,SL as Ee,SR as De,TR as Oe,UI as ke,UL as Ae,VI as je,VL as Me,WI as Ne,WL as Pe,XI as Fe,YI as Ie,YL as m,ZI as Le,ZL as Re,Zz as ze,_L as Be,bL as h,bR as Ve,cL as He,dL as g,eR as Ue,fL as We,gL as Ge,hL as Ke,jL as qe,jR as Je,kL as Ye,kR as Xe,lL as Ze,mL as Qe,nR as $e,oB as et,pL as tt,qI as nt,qL as rt,rB as _,sL as it,t as v,tR as at,uL as y,vL as ot,wR as st,xL as b,xR as ct,yL as lt,zI as ut}from"./api-Borb_oKz.js";import{t as dt}from"./list-DfIPa6Dk.js";import{t as x}from"./button-Bcf40mKN.js";import{$ as S,Bn as C,Bt as w,Ct as ft,Dn as pt,Dt as mt,Et as T,Q as E,Rt as D,St as ht,Tt as gt,Vn as O,X as k,Z as A,_n as _t,_t as vt,at as yt,bn as bt,bt as xt,dn as St,et as j,gt as Ct,hn as wt,it as Tt,jt as Et,nt as Dt,on as Ot,ot as kt,q as At,rt as jt,tt as Mt,vt as Nt,wt as Pt,xn as Ft,xt as It,yt as Lt,zt as M}from"./index-lMzb_P_p.js";import{a as Rt,i as N,n as zt,o as Bt,r as P,t as Vt}from"./table-B5YoMU9b.js";import{t as Ht}from"./FilterBar-D8d3TG3L.js";/* empty css */import{a as Ut,c as F,i as I,l as Wt,n as Gt,o as L,r as Kt,s as qt,t as Jt,u as R}from"./TimezoneCombobox-Byz56evB.js";var Yt=l(`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`}]]),Xt=l(`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`}]]),z=t(e(),1),B=n();function V(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 Zt({value:e,onChange:t}){let n=Wt(e),r=(0,z.useMemo)(()=>new Date,[]),[a,o]=(0,z.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[s,c]=(0,z.useState)(!1),l=(0,z.useMemo)(()=>V(i()),[]),u=(0,z.useMemo)(()=>new Intl.DateTimeFormat(i(),{month:`long`,year:`numeric`}),[]),ee=(0,z.useMemo)(()=>new Intl.DateTimeFormat(i(),{dateStyle:`medium`,timeStyle:`short`}),[]),te=F(a.year,a.month),d=n?.hour??9,f=n?.minute??0,p=(e,n,r,i,a)=>t(R(e,n,r,i,a)),ne=(e,t,n)=>{o({year:e,month:t}),p(e,t,n,d,f)},re=e=>{let t=new Date(a.year,a.month+e,1);o({year:t.getFullYear(),month:t.getMonth()})},ie=n===null?b():ee.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,B.jsxs)(D,{modal:!0,open:s,onOpenChange:c,children:[(0,B.jsx)(w,{asChild:!0,children:(0,B.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":Ee(),children:[(0,B.jsx)(Yt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,B.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:ie})]})}),(0,B.jsxs)(M,{align:`start`,className:`oc-dtp__pop`,children:[(0,B.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":h(),onClick:()=>re(-1),children:(0,B.jsx)(O,{size:15,"aria-hidden":!0})}),(0,B.jsx)(`span`,{className:`oc-dtp__month`,children:u.format(new Date(a.year,a.month,1))}),(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":lt(),onClick:()=>re(1),children:(0,B.jsx)(C,{size:15,"aria-hidden":!0})})]}),(0,B.jsxs)(`div`,{className:`oc-dtp__grid`,children:[l.map((e,t)=>(0,B.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,B.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,B.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,B.jsxs)(k,{value:String(d),onValueChange:e=>p(a.year,a.month,n?.day??r.getDate(),Number(e),f),children:[(0,B.jsx)(S,{size:`sm`,"aria-label":ot(),children:(0,B.jsx)(j,{})}),(0,B.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,B.jsx)(E,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,B.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,B.jsxs)(k,{value:String(f),onValueChange:e=>p(a.year,a.month,n?.day??r.getDate(),d,Number(e)),children:[(0,B.jsx)(S,{size:`sm`,"aria-label":Be(),children:(0,B.jsx)(j,{})}),(0,B.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,B.jsx)(E,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function H(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Qt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function $t(e){let t=new Map;for(let n of e){let e=H(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 U(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(Qt(t,n,a));i!==void 0&&i.length>0&&r.set(a,i.length)}return r}function en(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 tn(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 nn(e){return{startMs:new Date(e,0,1).getTime(),endMs:new Date(e+1,0,1).getTime()}}var W=3;function rn({events:e,mode:t,cursor:n,onModeChange:r,onCursorChange:a,onEventClick:o,footnote:s}){let c=i(),l=(0,z.useMemo)(()=>$t(e),[e]),u=(0,z.useMemo)(()=>en(c),[c]),ee=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`,year:`numeric`}),[c]),te=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`}),[c]),d=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{hour:`2-digit`,minute:`2-digit`}),[c]),f=new Date,p=e=>{if(t===`year`){a({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);a({year:r.getFullYear(),month:r.getMonth()})},ne=t===`year`?String(n.year):ee.format(new Date(n.year,n.month,1));return(0,B.jsxs)(`div`,{className:`oc-cal`,children:[(0,B.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,B.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":y(),onClick:()=>p(-1),children:(0,B.jsx)(O,{})}),(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":Ze(),onClick:()=>p(1),children:(0,B.jsx)(C,{})}),(0,B.jsx)(x,{variant:`ghost`,size:`sm`,onClick:()=>a({year:f.getFullYear(),month:f.getMonth()}),children:g()})]}),(0,B.jsx)(`span`,{className:`oc-cal__title`,children:ne}),(0,B.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,B.jsx)(x,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:tt()}),(0,B.jsx)(x,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:We()})]})]}),t===`month`?(0,B.jsx)(an,{cursor:n,byDay:l,weekdays:u,timeFmt:d,now:f,onEventClick:o}):(0,B.jsx)(on,{year:n.year,byDay:l,monthShortFmt:te,now:f,onOpenMonth:e=>{a({year:n.year,month:e}),r(`month`)}}),s?(0,B.jsx)(`p`,{className:`oc-cal__footnote`,children:s}):null]})}function an({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=F(e.year,e.month);return(0,B.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,B.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Qt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,B.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,B.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,W).map(e=>(0,B.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,B.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,B.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>W?(0,B.jsx)(`span`,{className:`oc-cal__more`,children:He({count:o.length-W})}):null]},n)})]})}function on({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,B.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=U(t,e,o),c=F(e,o);return(0,B.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,B.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,B.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,B.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var G={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])*G[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=L(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(qt(e)){case`ok`:return(0,B.jsx)(T,{variant:`secondary`,children:f()});case`error`:return(0,B.jsx)(T,{variant:`destructive`,children:he()});case`running`:return(0,B.jsx)(T,{variant:`outline`,children:pe()});case`other`:return(0,B.jsx)(T,{variant:`outline`,children:e});case`none`:return(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function pn(){let e=_(v.scheduled.listMyCrons),t=_(v.scheduled.getCronDetail),n=_(v.scheduled.listCronRuns),l=_(v.scheduled.updateCron),Ee=_(v.scheduled.removeCron),Be=_(v.scheduled.runCronNow),h=mt(),He=et(v.me.getMe,{host:At})?.timezone,[g,We]=(0,z.useState)(null),[Ze,tt]=(0,z.useState)(!1),[y,ot]=(0,z.useState)(!1),[b,lt]=(0,z.useState)(null),[C,w]=(0,z.useState)(null),[D,O]=(0,z.useState)(null),[M,F]=(0,z.useState)(null),[Wt,qt]=(0,z.useState)(!1),[R,V]=(0,z.useState)(Gt),[H,Qt]=(0,z.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),$t=e=>{localStorage.setItem(`oc.sched.view`,e),Qt(e)},[U,en]=(0,z.useState)(`month`),[W,an]=(0,z.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),on=(0,z.useMemo)(()=>{let e=[];for(let t of g??[]){if(!t.supported||t.error!==null)continue;let n=t.kind===`openclaw`&&t.manageSupported;for(let r of t.jobs)Ut(r,R)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[g,R]),G=(0,z.useMemo)(()=>U===`year`?nn(W.year):tn(W.year,W.month),[U,W]),sn=(0,z.useMemo)(()=>un(on,G.startMs,G.endMs),[on,G]),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,z.useCallback)(async()=>{tt(!0),ot(!1);try{We(await e({}))}catch{ot(!0)}finally{tt(!1)}},[e]);(0,z.useEffect)(()=>{q()},[q]);let cn=(0,z.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),J=(0,z.useRef)(null);(0,z.useEffect)(()=>{g!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[g]);let Y=(0,z.useMemo)(()=>new Intl.DateTimeFormat(i(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{lt(e);try{await t(),h.success(n),await q()}catch(e){h.toast({variant:`error`,title:m({code:dn(e)})})}finally{lt(null)}},Z=(0,z.useRef)(0),Q=(0,z.useRef)(0),ln=async(e,t)=>{if(t.id===null)return;let r=++Z.current;O({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Z.current)return;O({name:t.name??t.id,entries:i})}catch(e){if(r!==Z.current)return;O(null),h.toast({variant:`error`,title:m({code:dn(e)})})}},pn=async(e,n)=>{if(n.id===null)return;let r=++Q.current;F({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;F(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;F(null),h.toast({variant:`error`,title:m({code:dn(e)})})}},mn=async()=>{if(M===null)return;let e={};if(M.nameDirty&&M.name.trim()===``||M.messageDirty&&M.hasMessage&&M.message.trim()===``){h.toast({variant:`error`,title:be()});return}if(M.nameDirty&&M.name.trim()!==``&&(e.name=M.name.trim()),M.scheduleDirty){if(M.scheduleKind===`cron`&&M.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:M.cronExpr.trim(),...M.tz.trim()===``?{}:{tz:M.tz.trim()}};else if(M.scheduleKind===`every`){let t=Number(M.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*$[M.everyUnit])})}else if(M.scheduleKind===`at`&&M.at!==``){let t=Date.parse(M.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(M.scheduleDirty&&e.schedule===void 0){h.toast({variant:`error`,title:d()});return}if(M.messageDirty&&M.hasMessage&&M.message.trim()!==``&&(e.message=M.message.trim()),Object.keys(e).length===0){F(null);return}let t=Q.current;qt(!0);try{await l({instanceName:M.instanceName,jobId:M.jobId,patch:e}),h.success(ce()),t===Q.current&&F(null),await q()}catch(e){h.toast({variant:`error`,title:m({code:dn(e)})})}finally{qt(!1)}},hn=g?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,B.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:p()}),(0,B.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":Ge(),children:[(0,B.jsx)(x,{variant:H===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ke(),title:Ke(),"aria-pressed":H===`list`,onClick:()=>$t(`list`),children:(0,B.jsx)(dt,{})}),(0,B.jsx)(x,{variant:H===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Qe(),title:Qe(),"aria-pressed":H===`calendar`,onClick:()=>$t(`calendar`),children:(0,B.jsx)(Yt,{})})]}),(0,B.jsxs)(x,{variant:`ghost`,size:`sm`,onClick:()=>void q(),disabled:Ze,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,B.jsx)(wt,{size:14,"aria-hidden":!0}),Se()]})]}),g!==null&&hn>0?(0,B.jsxs)(Ht,{q:R.q,onQChange:e=>V(t=>({...t,q:e})),searchPlaceholder:a(),onReset:()=>V(Gt),canReset:Kt(R),children:[(0,B.jsxs)(k,{value:R.state,onValueChange:e=>V(t=>({...t,state:e})),children:[(0,B.jsx)(S,{size:`sm`,className:`w-40`,children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(E,{value:`all`,children:Ye()}),(0,B.jsx)(E,{value:`active`,children:ct()}),(0,B.jsx)(E,{value:`paused`,children:De()}),(0,B.jsx)(E,{value:`auto-disabled`,children:Ve()})]})]}),(0,B.jsxs)(k,{value:R.result,onValueChange:e=>V(t=>({...t,result:e})),children:[(0,B.jsx)(S,{size:`sm`,className:`w-40`,children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(E,{value:`all`,children:ve()}),(0,B.jsx)(E,{value:`ok`,children:f()}),(0,B.jsx)(E,{value:`error`,children:he()}),(0,B.jsx)(E,{value:`running`,children:pe()}),(0,B.jsx)(E,{value:`none`,children:qe()})]})]})]}):null,g===null?(0,B.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":Ze,children:y?ge():ze()}):H===`calendar`?(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ge()}):null,g.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:me()}):(0,B.jsx)(rn,{events:sn.events,mode:U,cursor:W,onModeChange:en,onCursorChange:an,onEventClick:K,footnote:it()})]}):(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ge()}):null,g.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:me()}):null,g.map(e=>{let t=e.jobs.filter(e=>Ut(e,R)),n=Kt(R)&&e.jobs.length>0&&t.length===0;return(0,B.jsxs)(`section`,{style:{marginBottom:20},children:[g.length>1||e.error||!e.supported?(0,B.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,B.jsx)(T,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:o({code:e.error})}):e.jobs.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:Xe()}):n?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):(0,B.jsxs)(Vt,{children:[(0,B.jsx)(Rt,{children:(0,B.jsxs)(Bt,{children:[(0,B.jsx)(N,{children:ye()}),(0,B.jsx)(N,{children:ee()}),(0,B.jsx)(N,{children:te()}),(0,B.jsx)(N,{children:Oe()}),(0,B.jsx)(N,{children:st()}),(0,B.jsx)(N,{children:se()}),(0,B.jsx)(N,{children:Le()})]})}),(0,B.jsx)(zt,{children:t.map((t,n)=>{let i=`${e.instanceName}:${t.id??n}`,a=b===i,o=e.manageSupported,s=e.kind===`openclaw`&&o;return(0,B.jsxs)(Bt,{ref:t.id!==null&&t.id===cn?J:void 0,"data-state":t.id!==null&&t.id===cn?`selected`:void 0,children:[(0,B.jsx)(P,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??c()}),(0,B.jsx)(P,{children:(0,B.jsx)(T,{variant:`secondary`,children:t.agentId})}),(0,B.jsxs)(P,{className:`whitespace-nowrap`,children:[(0,B.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=Ct(t.schedule),n=e===null?null:vt(e);return n===null?null:(0,B.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,B.jsx)(P,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:Y.format(t.nextRunAtMs)}),(0,B.jsx)(P,{children:L(t)===`auto-disabled`?(0,B.jsx)(T,{variant:`destructive`,title:`${t.autoDisabledReason??``}${t.autoDisabledAtMs===null?``:` · ${Y.format(t.autoDisabledAtMs)}`}`,children:Ve()}):L(t)===`active`?(0,B.jsx)(T,{variant:`secondary`,children:ct()}):L(t)===`paused`?(0,B.jsx)(T,{variant:`outline`,children:De()}):(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,B.jsxs)(P,{children:[(0,B.jsx)(fn,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,B.jsx)(T,{variant:`destructive`,title:t.lastDeliveryError??$e(),children:xe()}):null]}),(0,B.jsx)(P,{className:`whitespace-nowrap`,children:t.id===null?(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,B.jsx)(pt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,B.jsxs)(`span`,{className:`oc-cronactions`,children:[s?(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:Ue(),"aria-label":Ue(),disabled:b!==null,onClick:()=>void X(i,async()=>{let n=await Be({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},le()),children:(0,B.jsx)(Ot,{size:14,"aria-hidden":!0})}):null,s&&t.enabled!==null?(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:I(t)===`pause`?r():Ce(),"aria-label":I(t)===`pause`?r():Ce(),disabled:b!==null,onClick:()=>void X(i,()=>l({instanceName:e.instanceName,jobId:t.id,patch:{enabled:I(t)===`resume`}}),I(t)===`pause`?rt():de()),children:I(t)===`pause`?(0,B.jsx)(Ft,{size:14,"aria-hidden":!0}):(0,B.jsx)(_t,{size:14,"aria-hidden":!0})}):null,s?(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:Fe(),"aria-label":Fe(),disabled:b!==null,onClick:()=>void pn(e.instanceName,t),children:(0,B.jsx)(bt,{size:14,"aria-hidden":!0})}):null,s?(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:Ie(),"aria-label":Ie(),disabled:b!==null,onClick:()=>void ln(e.instanceName,t),children:(0,B.jsx)(Xt,{size:14,"aria-hidden":!0})}):null,o?(0,B.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:Re(),"aria-label":Re(),disabled:b!==null,onClick:()=>w({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,B.jsx)(St,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:Je()})]},e.instanceName)}),hn>0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:_e()}):null]}),(0,B.jsx)(Nt,{open:C!==null,onOpenChange:e=>{e||w(null)},children:(0,B.jsxs)(It,{children:[(0,B.jsxs)(Pt,{children:[(0,B.jsx)(gt,{children:Pe()}),(0,B.jsx)(ht,{children:Ae({name:C?.name??``})})]}),(0,B.jsxs)(ft,{children:[(0,B.jsx)(xt,{children:ae()}),(0,B.jsx)(Lt,{onClick:()=>{let e=C;w(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>Ee({instanceName:e.instanceName,jobId:e.jobId}),re())},children:Me()})]})]})}),(0,B.jsx)(Mt,{open:D!==null,onOpenChange:e=>{e||(Z.current++,O(null))},children:(0,B.jsxs)(Dt,{style:{maxWidth:640},children:[(0,B.jsx)(yt,{children:(0,B.jsx)(kt,{children:nt({name:D?.name??``})})}),D?.entries===null?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}):D!==null&&D.entries.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}):D===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:D.entries.map((e,t)=>(0,B.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,B.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,B.jsx)(fn,{status:e.status}),(0,B.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?Y.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,B.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,B.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[Te({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,B.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,B.jsx)(Mt,{open:M!==null,onOpenChange:e=>{e||(Q.current++,F(null))},children:(0,B.jsxs)(Dt,{className:`oc-cronedit`,children:[(0,B.jsxs)(yt,{children:[(0,B.jsx)(kt,{children:ne()}),(0,B.jsx)(jt,{children:Ne()})]}),M===null?null:M.loading?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}):(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:ye()}),(0,B.jsx)(Et,{value:M.name,maxLength:200,onChange:e=>F({...M,name:e.target.value,nameDirty:!0})})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:ke()}),(0,B.jsxs)(k,{value:M.scheduleKind,onValueChange:e=>F({...M,scheduleKind:e,scheduleDirty:!0}),children:[(0,B.jsx)(S,{children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(E,{value:`cron`,children:ie()}),(0,B.jsx)(E,{value:`every`,children:je()}),(0,B.jsx)(E,{value:`at`,children:s()})]})]}),M.scheduleKind===`cron`?(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,B.jsx)(Et,{value:M.cronExpr,onChange:e=>F({...M,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,B.jsx)(Jt,{value:M.tz,onChange:e=>F({...M,tz:e,scheduleDirty:!0}),fallbackTz:He??void 0})]}):M.scheduleKind===`every`?(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,B.jsx)(Et,{type:`number`,min:1,value:M.everyValue,onChange:e=>F({...M,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,B.jsxs)(k,{value:M.everyUnit,onValueChange:e=>F({...M,everyUnit:e,scheduleDirty:!0}),children:[(0,B.jsx)(S,{style:{maxWidth:160},children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(E,{value:`minutes`,children:ut()}),(0,B.jsx)(E,{value:`hours`,children:we()}),(0,B.jsx)(E,{value:`days`,children:fe()})]})]})]}):(0,B.jsx)(Zt,{value:M.at,onChange:e=>F({...M,at:e,scheduleDirty:!0})})]}),M.hasMessage?(0,B.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:at()}),(0,B.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:M.message,onChange:e=>F({...M,message:e.target.value,messageDirty:!0})})]}):null]}),(0,B.jsxs)(Tt,{children:[(0,B.jsx)(x,{variant:`ghost`,onClick:()=>F(null),children:ae()}),(0,B.jsxs)(x,{onClick:()=>void mn(),disabled:M===null||M.loading||Wt,children:[Wt?(0,B.jsx)(pt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,oe()]})]})]})})]})}export{pn as ScheduledTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,$N as i,AN as ee,BN as te,CN as ne,DN as re,EN as ie,FN as ae,GN as oe,HN as se,IN as ce,JN as le,KN as ue,LN as de,MN as fe,NN as pe,ON as me,PN as he,QM as a,QN as ge,RN as _e,SN as ve,TN as ye,UN as be,VN as xe,WN as Se,XM as o,XN as Ce,YM as s,YN as we,ZM as Te,ZN as Ee,_N as De,aB as c,aN as l,aP as Oe,bN as ke,cN as u,cP as Ae,dN as d,dP as je,eN as f,eP as Me,fN as p,fP as Ne,gN as m,hN as h,hP as Pe,iN as g,iP as Fe,jN as Ie,kN as Le,lN as _,lP as v,mN as y,mP as Re,nN as b,nP as ze,oB as x,oN as S,oP as Be,pN as C,pP as Ve,qN as He,rB as Ue,rN as w,rP as We,sN as T,sP as Ge,t as E,tN as D,tP as Ke,uN as O,uP as k,vN as A,wN as qe,xN as Je,yN as Ye,zN as Xe}from"./api-CCk5U5gB.js";import{t as j}from"./button-CbUSFbZL.js";import{$ as M,Bn as Ze,Dt as Qe,Et as N,Gn as $e,Hn as et,In as P,Kn as tt,Q as F,U as nt,Un as I,X as L,Z as R,_ as rt,at as z,ct as B,et as V,it as H,jt as U,nt as W,ot as G,rt as it,st as at,tt as K}from"./index-DY7zoioz.js";import{t as ot}from"./FilterBar-BJ1mhU3e.js";import{t as st}from"./DataTableShell-BWoSBli_.js";import{t as ct}from"./roleDescriptions-Du6v2lbA.js";var q=t(e(),1),J=n(),lt=[{value:`never`,label:()=>D(),days:null},{value:`30`,label:()=>f(),days:30},{value:`90`,label:()=>r(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=tt({from:`/settings/serviceAccounts`}),t=$e({from:`/settings/serviceAccounts`}),n=e.q??``,r=e.status??X,[a,o]=(0,q.useState)(X),s=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),Te=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),De=x(E.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===X?void 0:a,disabled:r===X?void 0:r===`disabled`}}),l=x(E.apiKeys.listKeys,{}),u=x(E.apiKeys.listRoles,{}),d=c(E.apiKeys.createServiceAccount),f=c(E.apiKeys.updateServiceAccount),p=c(E.apiKeys.deleteServiceAccount),m=Ue(E.apiKeys.mintApiKey),h=c(E.apiKeys.revokeApiKey),g=nt(),_=Qe(),y=n!==``||a!==X||r!==X;function b(){o(X),t({search:{},replace:!0})}let[S,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(Z),[D,O]=(0,q.useState)(null),[A,P]=(0,q.useState)(new Set),[I,z]=(0,q.useState)(null),B=(0,q.useRef)(!1),[H,W]=(0,q.useState)(new Set),[G,it]=(0,q.useState)({}),[at,K]=(0,q.useState)(null),Y=(0,q.useMemo)(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[l]);function Q(e){P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ft(){try{D?(await f({serviceAccountId:D,name:w.name,roleKey:w.roleKey,description:w.description}),_.success(pe())):await d({name:w.name,roleKey:w.roleKey,description:w.description||void 0}),T(Z),O(null),C(!1)}catch(e){_.error(D?he():ae(),e)}}function pt(e){T({name:e.name,roleKey:e.roleKey,description:e.description??``}),O(e._id),C(!0)}async function mt(e){if(B.current)return;B.current=!0;let t=G[e._id]??`never`,n=lt.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;z(e._id);try{let t=await m({serviceAccountId:e._id,expiresAt:r});K({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){_.error(fe(),e)}finally{B.current=!1,z(null)}}async function $(e){if(await g({title:Ie(),description:(0,J.jsxs)(J.Fragment,{children:[ee(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Le(),` `,(0,J.jsx)(`strong`,{children:me()}),` `,re()]}),confirmWord:e.name,confirmLabel:ie(),destructive:!0}))try{await p({serviceAccountId:e._id}),_.success(ye(),e.name)}catch(e){_.error(qe(),e)}}async function ht(e){if(await g({title:ne(),description:(0,J.jsxs)(J.Fragment,{children:[ve(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Je()]}),confirmLabel:ke(),destructive:!0})&&!H.has(e._id)){W(t=>new Set(t).add(e._id));try{await h({keyId:e._id})}catch(e){_.error(Ye(),e)}finally{W(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}),(0,J.jsxs)(ot,{q:n,onQChange:s,searchPlaceholder:Re(),onReset:b,canReset:y,children:[(0,J.jsxs)(L,{value:a,onValueChange:o,children:[(0,J.jsx)(M,{size:`sm`,className:`w-40`,children:(0,J.jsx)(V,{placeholder:Ve()})}),(0,J.jsxs)(R,{children:[(0,J.jsx)(F,{value:X,children:Ne()}),(u??[]).map(e=>(0,J.jsx)(F,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(L,{value:r,onValueChange:Te,children:[(0,J.jsx)(M,{size:`sm`,className:`w-36`,children:(0,J.jsx)(V,{})}),(0,J.jsxs)(R,{children:[(0,J.jsx)(F,{value:X,children:je()}),(0,J.jsx)(F,{value:`active`,children:k()}),(0,J.jsx)(F,{value:`disabled`,children:v()})]})]})]}),(0,J.jsx)(st,{title:Ae(),rows:De,addLabel:Ge(),onAdd:()=>{T(Z),O(null),C(!0)},emptyHint:Be(),isExpanded:e=>A.has(e._id),renderExpanded:e=>(0,J.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:H}),rowActions:e=>[...(e.managedBy??null)===null?[{label:ze(),onSelect:()=>pt(e)},{label:Oe(),onSelect:()=>void mt(e)}]:[],{label:A.has(e._id)?Fe():We(),onSelect:()=>Q(e._id)},...(e.managedBy??null)===null?[{label:Ke(),variant:`destructive`,onSelect:()=>void $(e)}]:[]],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":A.has(e._id)?Me():i(),onClick:()=>Q(e._id),children:A.has(e._id)?(0,J.jsx)(et,{}):(0,J.jsx)(Ze,{})})},{header:ge(),sort:e=>e.name,cell:e=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{children:e.name}),e.description?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:Ee(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(N,{variant:`secondary`,children:e.roleKey})},{header:Ce(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(N,{variant:`destructive`,children:v()}):(0,J.jsx)(N,{variant:`outline`,children:k()})},{header:we(),cell:e=>(0,J.jsxs)(L,{value:G[e._id]??`never`,onValueChange:t=>it(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(M,{size:`sm`,className:`w-32`,children:(0,J.jsx)(V,{})}),(0,J.jsx)(R,{children:lt.map(e=>(0,J.jsx)(F,{value:e.value,children:e.label()},e.value))})]})},{header:le(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:I===e._id?He():ue({count:t})})}}]}),(0,J.jsx)(rt,{open:S,onOpenChange:e=>{C(e),e||O(null)},title:D?oe():se(),description:D?Se():xe(),canSubmit:!!(w.name&&w.roleKey),onSubmit:ft,submitLabel:D?be():te(),children:(0,J.jsxs)(`div`,{className:`oc-form`,children:[(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:Xe()}),(0,J.jsx)(U,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:_e()}),(0,J.jsxs)(L,{value:w.roleKey||void 0,onValueChange:e=>T({...w,roleKey:e}),children:[(0,J.jsx)(M,{className:`w-full`,children:(0,J.jsx)(V,{placeholder:de()})}),(0,J.jsx)(R,{children:(u??[]).map(e=>(0,J.jsxs)(F,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(u??[]).find(e=>e.key===w.roleKey),t=e?ct(e):null;return t?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:ce()}),(0,J.jsx)(U,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})}),(0,J.jsx)(dt,{minted:at,onClose:()=>K(null)})]})}function ut({account:e,keys:t,onRevoke:n,revoking:r}){return(0,J.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,J.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[A(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:De()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:m()}),(0,J.jsx)(`th`,{children:h()}),(0,J.jsx)(`th`,{children:y()}),(0,J.jsx)(`th`,{children:C()}),(0,J.jsx)(`th`,{children:p()}),(0,J.jsx)(`th`,{children:d()}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:t.map(t=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(N,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:B(t.createdAt)}),(0,J.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:mt(t.expiresAt)}),(0,J.jsx)(`td`,{children:$(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:!t.disabled&&(e.managedBy??null)===null?(0,J.jsx)(j,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?O():_()}):null})]},t._id))})]})]})}function dt({minted:e,onClose:t}){let[n,r]=(0,q.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,J.jsx)(K,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(W,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(G,{children:u()}),(0,J.jsx)(it,{children:T({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:S()}),(0,J.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,J.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,J.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":l(),children:[n?(0,J.jsx)(I,{}):(0,J.jsx)(P,{}),n?g():w()]})]}),(0,J.jsx)(H,{children:(0,J.jsx)(j,{onClick:()=>{r(!1),t()},children:b()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?a():B(e)}function mt(e){return e===null?`—`:at(e)}function $(e){return e.disabled?(0,J.jsx)(N,{variant:`destructive`,children:Te()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(N,{variant:`outline`,children:o()}):(0,J.jsx)(N,{variant:`outline`,children:s()})}export{Q as ServiceAccountsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,$N as i,AN as ee,BN as te,CN as ne,DN as re,EN as ie,FN as ae,GN as oe,HN as se,IN as ce,JN as le,KN as ue,LN as de,MN as fe,NN as pe,ON as me,PN as he,QM as a,QN as ge,RN as _e,SN as ve,TN as ye,UN as be,VN as xe,WN as Se,XM as o,XN as Ce,YM as s,YN as we,ZM as Te,ZN as Ee,_N as De,aB as c,aN as l,aP as Oe,bN as ke,cN as u,cP as Ae,dN as d,dP as je,eN as f,eP as Me,fN as p,fP as Ne,gN as m,hN as h,hP as Pe,iN as g,iP as Fe,jN as Ie,kN as Le,lN as _,lP as v,mN as y,mP as Re,nN as b,nP as ze,oB as x,oN as S,oP as Be,pN as C,pP as Ve,qN as He,rB as Ue,rN as w,rP as We,sN as T,sP as Ge,t as E,tN as D,tP as Ke,uN as O,uP as k,vN as A,wN as qe,xN as Je,yN as Ye,zN as Xe}from"./api-Borb_oKz.js";import{t as j}from"./button-Bcf40mKN.js";import{$ as M,Bn as Ze,Dt as Qe,Et as N,Gn as $e,Hn as et,In as P,Kn as tt,Q as F,U as nt,Un as I,X as L,Z as R,_ as rt,at as z,ct as B,et as V,it as H,jt as U,nt as W,ot as G,rt as it,st as at,tt as K}from"./index-lMzb_P_p.js";import{t as ot}from"./FilterBar-D8d3TG3L.js";import{t as st}from"./DataTableShell-CR2Pxo32.js";import{t as ct}from"./roleDescriptions-xzqDDCcp.js";var q=t(e(),1),J=n(),lt=[{value:`never`,label:()=>D(),days:null},{value:`30`,label:()=>f(),days:30},{value:`90`,label:()=>r(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=tt({from:`/settings/serviceAccounts`}),t=$e({from:`/settings/serviceAccounts`}),n=e.q??``,r=e.status??X,[a,o]=(0,q.useState)(X),s=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),Te=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),De=x(E.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===X?void 0:a,disabled:r===X?void 0:r===`disabled`}}),l=x(E.apiKeys.listKeys,{}),u=x(E.apiKeys.listRoles,{}),d=c(E.apiKeys.createServiceAccount),f=c(E.apiKeys.updateServiceAccount),p=c(E.apiKeys.deleteServiceAccount),m=Ue(E.apiKeys.mintApiKey),h=c(E.apiKeys.revokeApiKey),g=nt(),_=Qe(),y=n!==``||a!==X||r!==X;function b(){o(X),t({search:{},replace:!0})}let[S,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(Z),[D,O]=(0,q.useState)(null),[A,P]=(0,q.useState)(new Set),[I,z]=(0,q.useState)(null),B=(0,q.useRef)(!1),[H,W]=(0,q.useState)(new Set),[G,it]=(0,q.useState)({}),[at,K]=(0,q.useState)(null),Y=(0,q.useMemo)(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[l]);function Q(e){P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ft(){try{D?(await f({serviceAccountId:D,name:w.name,roleKey:w.roleKey,description:w.description}),_.success(pe())):await d({name:w.name,roleKey:w.roleKey,description:w.description||void 0}),T(Z),O(null),C(!1)}catch(e){_.error(D?he():ae(),e)}}function pt(e){T({name:e.name,roleKey:e.roleKey,description:e.description??``}),O(e._id),C(!0)}async function mt(e){if(B.current)return;B.current=!0;let t=G[e._id]??`never`,n=lt.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;z(e._id);try{let t=await m({serviceAccountId:e._id,expiresAt:r});K({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){_.error(fe(),e)}finally{B.current=!1,z(null)}}async function $(e){if(await g({title:Ie(),description:(0,J.jsxs)(J.Fragment,{children:[ee(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Le(),` `,(0,J.jsx)(`strong`,{children:me()}),` `,re()]}),confirmWord:e.name,confirmLabel:ie(),destructive:!0}))try{await p({serviceAccountId:e._id}),_.success(ye(),e.name)}catch(e){_.error(qe(),e)}}async function ht(e){if(await g({title:ne(),description:(0,J.jsxs)(J.Fragment,{children:[ve(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Je()]}),confirmLabel:ke(),destructive:!0})&&!H.has(e._id)){W(t=>new Set(t).add(e._id));try{await h({keyId:e._id})}catch(e){_.error(Ye(),e)}finally{W(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}),(0,J.jsxs)(ot,{q:n,onQChange:s,searchPlaceholder:Re(),onReset:b,canReset:y,children:[(0,J.jsxs)(L,{value:a,onValueChange:o,children:[(0,J.jsx)(M,{size:`sm`,className:`w-40`,children:(0,J.jsx)(V,{placeholder:Ve()})}),(0,J.jsxs)(R,{children:[(0,J.jsx)(F,{value:X,children:Ne()}),(u??[]).map(e=>(0,J.jsx)(F,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(L,{value:r,onValueChange:Te,children:[(0,J.jsx)(M,{size:`sm`,className:`w-36`,children:(0,J.jsx)(V,{})}),(0,J.jsxs)(R,{children:[(0,J.jsx)(F,{value:X,children:je()}),(0,J.jsx)(F,{value:`active`,children:k()}),(0,J.jsx)(F,{value:`disabled`,children:v()})]})]})]}),(0,J.jsx)(st,{title:Ae(),rows:De,addLabel:Ge(),onAdd:()=>{T(Z),O(null),C(!0)},emptyHint:Be(),isExpanded:e=>A.has(e._id),renderExpanded:e=>(0,J.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:H}),rowActions:e=>[...(e.managedBy??null)===null?[{label:ze(),onSelect:()=>pt(e)},{label:Oe(),onSelect:()=>void mt(e)}]:[],{label:A.has(e._id)?Fe():We(),onSelect:()=>Q(e._id)},...(e.managedBy??null)===null?[{label:Ke(),variant:`destructive`,onSelect:()=>void $(e)}]:[]],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":A.has(e._id)?Me():i(),onClick:()=>Q(e._id),children:A.has(e._id)?(0,J.jsx)(et,{}):(0,J.jsx)(Ze,{})})},{header:ge(),sort:e=>e.name,cell:e=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{children:e.name}),e.description?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:Ee(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(N,{variant:`secondary`,children:e.roleKey})},{header:Ce(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(N,{variant:`destructive`,children:v()}):(0,J.jsx)(N,{variant:`outline`,children:k()})},{header:we(),cell:e=>(0,J.jsxs)(L,{value:G[e._id]??`never`,onValueChange:t=>it(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(M,{size:`sm`,className:`w-32`,children:(0,J.jsx)(V,{})}),(0,J.jsx)(R,{children:lt.map(e=>(0,J.jsx)(F,{value:e.value,children:e.label()},e.value))})]})},{header:le(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:I===e._id?He():ue({count:t})})}}]}),(0,J.jsx)(rt,{open:S,onOpenChange:e=>{C(e),e||O(null)},title:D?oe():se(),description:D?Se():xe(),canSubmit:!!(w.name&&w.roleKey),onSubmit:ft,submitLabel:D?be():te(),children:(0,J.jsxs)(`div`,{className:`oc-form`,children:[(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:Xe()}),(0,J.jsx)(U,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:_e()}),(0,J.jsxs)(L,{value:w.roleKey||void 0,onValueChange:e=>T({...w,roleKey:e}),children:[(0,J.jsx)(M,{className:`w-full`,children:(0,J.jsx)(V,{placeholder:de()})}),(0,J.jsx)(R,{children:(u??[]).map(e=>(0,J.jsxs)(F,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(u??[]).find(e=>e.key===w.roleKey),t=e?ct(e):null;return t?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:ce()}),(0,J.jsx)(U,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})}),(0,J.jsx)(dt,{minted:at,onClose:()=>K(null)})]})}function ut({account:e,keys:t,onRevoke:n,revoking:r}){return(0,J.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,J.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[A(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:De()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:m()}),(0,J.jsx)(`th`,{children:h()}),(0,J.jsx)(`th`,{children:y()}),(0,J.jsx)(`th`,{children:C()}),(0,J.jsx)(`th`,{children:p()}),(0,J.jsx)(`th`,{children:d()}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:t.map(t=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(N,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:B(t.createdAt)}),(0,J.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:mt(t.expiresAt)}),(0,J.jsx)(`td`,{children:$(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:!t.disabled&&(e.managedBy??null)===null?(0,J.jsx)(j,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?O():_()}):null})]},t._id))})]})]})}function dt({minted:e,onClose:t}){let[n,r]=(0,q.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,J.jsx)(K,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(W,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(G,{children:u()}),(0,J.jsx)(it,{children:T({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:S()}),(0,J.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,J.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,J.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":l(),children:[n?(0,J.jsx)(I,{}):(0,J.jsx)(P,{}),n?g():w()]})]}),(0,J.jsx)(H,{children:(0,J.jsx)(j,{onClick:()=>{r(!1),t()},children:b()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?a():B(e)}function mt(e){return e===null?`—`:at(e)}function $(e){return e.disabled?(0,J.jsx)(N,{variant:`destructive`,children:Te()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(N,{variant:`outline`,children:o()}):(0,J.jsx)(N,{variant:`outline`,children:s()})}export{Q as ServiceAccountsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$c as r,Ac as i,Bc as a,Cc as o,Dc as s,Ec as c,Fc as l,Gc as u,Hc as d,Ic as f,Jc as p,Kc as m,Lc as h,Mc as g,Nc as _,Oc as v,Pc as y,Qc as b,Rc as x,Sc as S,Tc as C,Uc as w,Vc as T,Wc as E,Xc as D,Yc as O,Zc as k,_c as A,aB as j,bc as M,el as N,gc as P,jc as F,kc as I,oB as ee,qc as L,t as R,vc as z,wc as B,xc as V,yc as H,zc as U}from"./api-CCk5U5gB.js";import{t as W}from"./button-CbUSFbZL.js";import{U as G,ct as K}from"./index-DY7zoioz.js";import{t as q}from"./DataTableShell-BWoSBli_.js";var J=t(e(),1),Y=n(),X={hung:()=>h(),wrong_result:()=>f(),error:()=>l(),other:()=>y()},Z=e=>(e&&X[e]?.())??e??`—`;function Q(e){let t=e.slice(e.lastIndexOf(`:`)+1)||e;return t.length>12?`${t.slice(0,12)}…`:t}function $({data:e}){let t=e.snapshot,n=j(R.subAgentReports.respondToReport),[r,a]=(0,J.useState)(e.thread),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1);async function p(){let t=l.trim();if(!(!t||d)){f(!0);try{await n({reportId:e._id,text:t}),a(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),u(``)}finally{f(!1)}}}return(0,Y.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,children:(0,Y.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Z(e.category),` · `,_({failed:t.failedCount,total:t.totalCount}),t.openclawModel?` · ${t.openclawModel}`:``,t.openclawRuntime?` (${t.openclawRuntime})`:``]})}),e.comment?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:F()}),r.length>0?(0,Y.jsx)(`div`,{className:`oc-fbadmin__thread`,children:r.map((e,t)=>(0,Y.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Y.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?i():I()}),(0,Y.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Y.jsx)(`p`,{className:`oc-fbadmin__meta`,children:v()}),(0,Y.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:s(),value:l,maxLength:2e3,rows:3,onChange:e=>u(e.target.value.slice(0,2e3))}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Y.jsx)(W,{size:`sm`,onClick:()=>void p(),disabled:!l.trim()||d,children:d?C():c()})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`oc-fbadmin__h`,children:[B({count:t.children.length}),t.childrenTruncated?` ${o()}`:``,t.textTruncated?` ${S()}`:``]}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:t.children.map((e,n)=>(0,Y.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Y.jsxs)(`span`,{className:`oc-fbadmin__ctx-role`,children:[(e.taskName?.trim()||Q(e.childSessionKey))+` · ${e.status}`,e.phase?` · ${e.phase}`:``,e.childSessionKey===t.flaggedChildSessionKey?` · ${V()}`:``]}),e.errorMessage?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.errorMessage}):null,e.resultText?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.resultText}):null]},n))})]}),t.parentText?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:M()}),(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:t.parentText})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:H()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__env`,children:[t.parentStatus?`status: ${t.parentStatus}`:null,t.parentErrorCode?`code: ${t.parentErrorCode}`:null,t.parentRunId?`run ${t.parentRunId.slice(0,12)}…`:null,e.correlationId?`corr ${e.correlationId.slice(0,16)}…`:null,t.openclawProvider].filter(Boolean).join(` · `)||`—`})]})]})}function te(){let e=ee(R.subAgentReports.listForAdmin,{}),t=j(R.subAgentReports.readReport),n=j(R.subAgentReports.deleteReport),i=G(),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)({});async function f(e){if(o===e._id){s(null);return}if(!c[e._id]){let n=await t({reportId:e._id});l(t=>({...t,[e._id]:n}))}s(e._id)}async function h(e){await i({title:z(),description:A(),confirmLabel:P(),destructive:!0})&&(await n({reportId:e._id}),o===e._id&&s(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[b(),` `,(0,Y.jsx)(`strong`,{children:k()}),` `,D()]}),(0,Y.jsx)(q,{title:N(),rows:e,emptyHint:r(),isExpanded:e=>o===e._id&&!!c[e._id],renderExpanded:e=>c[e._id]?(0,Y.jsx)($,{data:c[e._id]}):null,columns:[{header:O(),cell:e=>K(e.at),sort:e=>e.at},{header:p(),cell:e=>Z(e.category),sort:e=>Z(e.category)},{header:L(),cell:e=>`${e.failedCount}/${e.totalCount}`,sort:e=>e.failedCount},{header:m(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${w({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:u(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:E(),cell:e=>e.answered?(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:d()}):(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill`,children:T()}),sort:e=>+!!e.answered}],rowActions:e=>[{label:o===e._id?U():a(),onSelect:()=>void f(e)},{label:x(),onSelect:()=>void h(e),variant:`destructive`}]})]})}export{te as SubAgentReportsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$c as r,Ac as i,Bc as a,Cc as o,Dc as s,Ec as c,Fc as l,Gc as u,Hc as d,Ic as f,Jc as p,Kc as m,Lc as h,Mc as g,Nc as _,Oc as v,Pc as y,Qc as b,Rc as x,Sc as S,Tc as C,Uc as w,Vc as T,Wc as E,Xc as D,Yc as O,Zc as k,_c as A,aB as j,bc as M,el as N,gc as P,jc as F,kc as I,oB as ee,qc as L,t as R,vc as z,wc as B,xc as V,yc as H,zc as U}from"./api-Borb_oKz.js";import{t as W}from"./button-Bcf40mKN.js";import{U as G,ct as K}from"./index-lMzb_P_p.js";import{t as q}from"./DataTableShell-CR2Pxo32.js";var J=t(e(),1),Y=n(),X={hung:()=>h(),wrong_result:()=>f(),error:()=>l(),other:()=>y()},Z=e=>(e&&X[e]?.())??e??`—`;function Q(e){let t=e.slice(e.lastIndexOf(`:`)+1)||e;return t.length>12?`${t.slice(0,12)}…`:t}function $({data:e}){let t=e.snapshot,n=j(R.subAgentReports.respondToReport),[r,a]=(0,J.useState)(e.thread),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1);async function p(){let t=l.trim();if(!(!t||d)){f(!0);try{await n({reportId:e._id,text:t}),a(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),u(``)}finally{f(!1)}}}return(0,Y.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,children:(0,Y.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Z(e.category),` · `,_({failed:t.failedCount,total:t.totalCount}),t.openclawModel?` · ${t.openclawModel}`:``,t.openclawRuntime?` (${t.openclawRuntime})`:``]})}),e.comment?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:F()}),r.length>0?(0,Y.jsx)(`div`,{className:`oc-fbadmin__thread`,children:r.map((e,t)=>(0,Y.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Y.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?i():I()}),(0,Y.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Y.jsx)(`p`,{className:`oc-fbadmin__meta`,children:v()}),(0,Y.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:s(),value:l,maxLength:2e3,rows:3,onChange:e=>u(e.target.value.slice(0,2e3))}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Y.jsx)(W,{size:`sm`,onClick:()=>void p(),disabled:!l.trim()||d,children:d?C():c()})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`oc-fbadmin__h`,children:[B({count:t.children.length}),t.childrenTruncated?` ${o()}`:``,t.textTruncated?` ${S()}`:``]}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:t.children.map((e,n)=>(0,Y.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Y.jsxs)(`span`,{className:`oc-fbadmin__ctx-role`,children:[(e.taskName?.trim()||Q(e.childSessionKey))+` · ${e.status}`,e.phase?` · ${e.phase}`:``,e.childSessionKey===t.flaggedChildSessionKey?` · ${V()}`:``]}),e.errorMessage?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.errorMessage}):null,e.resultText?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.resultText}):null]},n))})]}),t.parentText?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:M()}),(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:t.parentText})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:H()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__env`,children:[t.parentStatus?`status: ${t.parentStatus}`:null,t.parentErrorCode?`code: ${t.parentErrorCode}`:null,t.parentRunId?`run ${t.parentRunId.slice(0,12)}…`:null,e.correlationId?`corr ${e.correlationId.slice(0,16)}…`:null,t.openclawProvider].filter(Boolean).join(` · `)||`—`})]})]})}function te(){let e=ee(R.subAgentReports.listForAdmin,{}),t=j(R.subAgentReports.readReport),n=j(R.subAgentReports.deleteReport),i=G(),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)({});async function f(e){if(o===e._id){s(null);return}if(!c[e._id]){let n=await t({reportId:e._id});l(t=>({...t,[e._id]:n}))}s(e._id)}async function h(e){await i({title:z(),description:A(),confirmLabel:P(),destructive:!0})&&(await n({reportId:e._id}),o===e._id&&s(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[b(),` `,(0,Y.jsx)(`strong`,{children:k()}),` `,D()]}),(0,Y.jsx)(q,{title:N(),rows:e,emptyHint:r(),isExpanded:e=>o===e._id&&!!c[e._id],renderExpanded:e=>c[e._id]?(0,Y.jsx)($,{data:c[e._id]}):null,columns:[{header:O(),cell:e=>K(e.at),sort:e=>e.at},{header:p(),cell:e=>Z(e.category),sort:e=>Z(e.category)},{header:L(),cell:e=>`${e.failedCount}/${e.totalCount}`,sort:e=>e.failedCount},{header:m(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${w({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:u(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:E(),cell:e=>e.answered?(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:d()}):(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill`,children:T()}),sort:e=>+!!e.answered}],rowActions:e=>[{label:o===e._id?U():a(),onSelect:()=>void f(e)},{label:x(),onSelect:()=>void h(e),variant:`destructive`}]})]})}export{te as SubAgentReportsTab};