@lacneu/atrium 0.104.2 → 0.104.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/assets/{AccessTab-D8xdWzT5.js → AccessTab-B2bpNynj.js} +1 -1
  2. package/dist/assets/{AdminSettings-CtNcFhMz.js → AdminSettings-C2bsOn0u.js} +1 -1
  3. package/dist/assets/{AdvancedFilter-Cod8SSd6.js → AdvancedFilter-DYTsdqhC.js} +1 -1
  4. package/dist/assets/{AgentFilesTab-Dfkkm3Fw.js → AgentFilesTab-BM2NUWub.js} +1 -1
  5. package/dist/assets/{AnomaliesTab-DlZ5M2UC.js → AnomaliesTab-BWiKxnXQ.js} +1 -1
  6. package/dist/assets/{AuditTab-Dh6gO6j5.js → AuditTab-CqpDXgVz.js} +1 -1
  7. package/dist/assets/{BridgeTab-Bnu9R5N4.js → BridgeTab-Cv2Co6h7.js} +1 -1
  8. package/dist/assets/{ChatDefaultsTab-CxmayDqi.js → ChatDefaultsTab-Dr-czhQm.js} +1 -1
  9. package/dist/assets/{ConfirmDialog-B7k0wvSi.js → ConfirmDialog-Bfi4_Ti8.js} +1 -1
  10. package/dist/assets/{DataTableShell-DvtkASQG.js → DataTableShell-1ZsZ0a2J.js} +1 -1
  11. package/dist/assets/{DeletedChatsTab-CnaK-AH0.js → DeletedChatsTab-By_xLvEC.js} +1 -1
  12. package/dist/assets/{DetailChips-DDAtgnjA.js → DetailChips-DkRU5HQ5.js} +1 -1
  13. package/dist/assets/{EntitySheet-DRzkWKlH.js → EntitySheet-D8Vdib4B.js} +1 -1
  14. package/dist/assets/{FeedbacksTab-D4LKaB_2.js → FeedbacksTab-YFBk45oU.js} +1 -1
  15. package/dist/assets/{FieldLabel-imj_Z0rZ.js → FieldLabel-Ce8urE01.js} +1 -1
  16. package/dist/assets/{FilesTab-D3XWSI2t.js → FilesTab-DL27Krkt.js} +1 -1
  17. package/dist/assets/{FilterBar-DCCuFxDn.js → FilterBar-DtNuk6dI.js} +1 -1
  18. package/dist/assets/{GroupsTab-DbayDYbZ.js → GroupsTab-CQrEUZSF.js} +1 -1
  19. package/dist/assets/{InstancesTab-031fn2Jt.js → InstancesTab-DiW-4KlM.js} +1 -1
  20. package/dist/assets/{IntegrationsTab-1whhDsmk.js → IntegrationsTab-DqWlrC3M.js} +1 -1
  21. package/dist/assets/{KnobRow-D6kXWvVI.js → KnobRow-4WODwFrS.js} +1 -1
  22. package/dist/assets/{KpiTab-2Vk6EtCf.js → KpiTab-BXC9YG9_.js} +1 -1
  23. package/dist/assets/{PreferencesTab-B5h49bYq.js → PreferencesTab-DarNzYdF.js} +1 -1
  24. package/dist/assets/{ProjectPage-BNKL-iOz.js → ProjectPage-BbYuFPDW.js} +1 -1
  25. package/dist/assets/{PromptInjectionsTab-Bmn1iSpB.js → PromptInjectionsTab-KMsWE-dW.js} +1 -1
  26. package/dist/assets/{RolesTab-DHxLatAl.js → RolesTab-DpN3MOih.js} +1 -1
  27. package/dist/assets/{ScheduledTab-NHSyQ677.js → ScheduledTab-BBofaJj5.js} +1 -1
  28. package/dist/assets/{ServiceAccountsTab-CKV8crhK.js → ServiceAccountsTab-CSIwvppo.js} +1 -1
  29. package/dist/assets/{SubAgentReportsTab-BWfXOTck.js → SubAgentReportsTab-BoNbdt38.js} +1 -1
  30. package/dist/assets/{ThemeShowroom-Do9I3hrR.js → ThemeShowroom-DdUZV2nA.js} +1 -1
  31. package/dist/assets/{TimeRangePicker-BZtw1JkM.js → TimeRangePicker-jsNw51TL.js} +1 -1
  32. package/dist/assets/{TimezoneCombobox-CeRN4N3z.js → TimezoneCombobox-zOqV7dxe.js} +1 -1
  33. package/dist/assets/{TracesTab-BNWFPad2.js → TracesTab-Dg_eyLYF.js} +1 -1
  34. package/dist/assets/{TrashTab-D5irFeF0.js → TrashTab-Dwjjxu8X.js} +1 -1
  35. package/dist/assets/{UsersTab-CHs3CRev.js → UsersTab-eQY9UCh5.js} +1 -1
  36. package/dist/assets/{VoiceTab-DRvjgMdZ.js → VoiceTab-BFVfbSld.js} +1 -1
  37. package/dist/assets/{alert-dialog-BcJMHbhI.js → alert-dialog-C6NSAwQv.js} +1 -1
  38. package/dist/assets/{api-CWqdeSbN.js → api-D64JTta1.js} +1 -1
  39. package/dist/assets/{badge-ChMMFtuW.js → badge-DwWXPxwl.js} +1 -1
  40. package/dist/assets/{button-C_rIPtCv.js → button-DeHzYOzP.js} +1 -1
  41. package/dist/assets/{card-BV8NO76j.js → card-WAOfM0PL.js} +1 -1
  42. package/dist/assets/check-pVsND9oZ.js +1 -0
  43. package/dist/assets/{checkbox-DPxJTQjc.js → checkbox-BuTZzFvU.js} +1 -1
  44. package/dist/assets/chevron-left-CjQ1kn0w.js +1 -0
  45. package/dist/assets/chevron-right-DkaFdk2G.js +1 -0
  46. package/dist/assets/chevron-up-s_deZUWR.js +1 -0
  47. package/dist/assets/chevrons-up-down-uk0IvxY8.js +1 -0
  48. package/dist/assets/{compatView-Cz5KNXa-.js → compatView-Db657dNx.js} +1 -1
  49. package/dist/assets/convexApi-DxRiI80M.js +1 -0
  50. package/dist/assets/{copy-DbstFM9Q.js → copy-4wREwP-V.js} +1 -1
  51. package/dist/assets/{cronDescribe-CkiSvbCK.js → cronDescribe-B-ifUeLg.js} +1 -1
  52. package/dist/assets/{deliveryRecorder-B_kVKMkR.js → deliveryRecorder-owdOglrQ.js} +1 -1
  53. package/dist/assets/{dialog-CPAskUwF.js → dialog-awuZdW9M.js} +1 -1
  54. package/dist/assets/{dispatchErrorInfo-7H2cJGwt.js → dispatchErrorInfo-C4Qh_2oR.js} +1 -1
  55. package/dist/assets/{dist-Bu9sqVcp.js → dist-B4zBnzNF.js} +1 -1
  56. package/dist/assets/{dist-BjZo0sql.js → dist-BtzRSR0_.js} +1 -1
  57. package/dist/assets/{dist-CzmY6YrA.js → dist-C0V3m4aH.js} +1 -1
  58. package/dist/assets/{dist-Uf18yR_a.js → dist-D4a9D7kU.js} +1 -1
  59. package/dist/assets/{dist-CYh9BuQS.js → dist-mViq22LZ.js} +1 -1
  60. package/dist/assets/{download-BaebAe6Z.js → download-BUlwPQI8.js} +1 -1
  61. package/dist/assets/{dropdown-menu-BVKVjups.js → dropdown-menu-C5VrCGFe.js} +1 -1
  62. package/dist/assets/{eye-LggiM6Z5.js → eye-BU60QIdS.js} +1 -1
  63. package/dist/assets/{format-AQELUhPa.js → format-g5Z3Txjl.js} +1 -1
  64. package/dist/assets/{groupManageView-DC3eSLA1.js → groupManageView-CKEYC6zY.js} +1 -1
  65. package/dist/assets/index-DLjKxzJ_.css +1 -0
  66. package/dist/assets/index-MNxzNMLb.js +158 -0
  67. package/dist/assets/{input-CSZu-bVE.js → input-CZ0jp9Rx.js} +1 -1
  68. package/dist/assets/{list-obbqPBzD.js → list-Bb0MIh_I.js} +1 -1
  69. package/dist/assets/loader-circle-1XN8tjq6.js +1 -0
  70. package/dist/assets/{lock-BlVhOk85.js → lock-xfEfLa2G.js} +1 -1
  71. package/dist/assets/{pencil-K7SBkvHL.js → pencil-CHRZ3__S.js} +1 -1
  72. package/dist/assets/plus-DrzxZ4iS.js +1 -0
  73. package/dist/assets/{popover-C-Y_Yoco.js → popover-UJtu3EZ6.js} +1 -1
  74. package/dist/assets/roleDescriptions-BW3e0J2_.js +1 -0
  75. package/dist/assets/rotate-ccw-CiOuaG2h.js +1 -0
  76. package/dist/assets/{search-Dz6sLH0-.js → search-NOJ0tWl2.js} +1 -1
  77. package/dist/assets/{select-CjcMQhwm.js → select-wXM6h61N.js} +1 -1
  78. package/dist/assets/{server-DcInl3Nh.js → server-C5TTb6-A.js} +1 -1
  79. package/dist/assets/{speech-ehUcmGCg.js → speech-BPCrvnrE.js} +1 -1
  80. package/dist/assets/{star-5ysDlx3k.js → star-N2N0cbAA.js} +1 -1
  81. package/dist/assets/{switch--NPD3Vp0.js → switch-Beq0wUQ_.js} +1 -1
  82. package/dist/assets/{table-rRR3TpMc.js → table-CegX53gV.js} +1 -1
  83. package/dist/assets/{tabs-B8emuY1B.js → tabs-CfQK0-wk.js} +1 -1
  84. package/dist/assets/{toast-C_YfUacM.js → toast-DtA87VYn.js} +1 -1
  85. package/dist/assets/{tooltip-Ct0TGxtk.js → tooltip-Dpar43UD.js} +1 -1
  86. package/dist/assets/{trash-2-xhtrhYsd.js → trash-2-CqKGt3lC.js} +1 -1
  87. package/dist/assets/{trashPage-3suR6eIy.js → trashPage-D9B1uAuS.js} +1 -1
  88. package/dist/assets/{trashView-CwUC01r_.js → trashView-TIQT30u4.js} +1 -1
  89. package/dist/assets/{triangle-alert-DoL9TI6v.js → triangle-alert-nUld87-H.js} +1 -1
  90. package/dist/assets/{usageView-BuRtXekW.js → usageView-DIPUGYx9.js} +1 -1
  91. package/dist/assets/{useChart-bV4rotdu.js → useChart-BTVKxdLu.js} +1 -1
  92. package/dist/assets/{useFontScale-DiSkEM6I.js → useFontScale-P_rNok04.js} +1 -1
  93. package/dist/assets/{useStartNewChat-8wVLrYnZ.js → useStartNewChat-GAbwTTkG.js} +1 -1
  94. package/dist/assets/{use_paginated_query-CebdO_HQ.js → use_paginated_query-C-Aw4n8b.js} +1 -1
  95. package/dist/assets/{users-CRbE186D.js → users-BUu1wJNm.js} +1 -1
  96. package/dist/assets/x-BNU-sWkh.js +1 -0
  97. package/dist/index.html +54 -54
  98. package/package.json +1 -1
  99. package/dist/assets/check-DdmANHSb.js +0 -1
  100. package/dist/assets/chevron-left-ByEQraEh.js +0 -1
  101. package/dist/assets/chevron-right-DMqzlhWH.js +0 -1
  102. package/dist/assets/chevron-up-B3KYmtzo.js +0 -1
  103. package/dist/assets/chevrons-up-down-CITEfz7_.js +0 -1
  104. package/dist/assets/convexApi-G20_TNBS.js +0 -1
  105. package/dist/assets/index-2h5cvmc2.css +0 -1
  106. package/dist/assets/index-CzYLP7A2.js +0 -158
  107. package/dist/assets/loader-circle-BqKiW3X9.js +0 -1
  108. package/dist/assets/plus-DTL4K-j9.js +0 -1
  109. package/dist/assets/roleDescriptions-DHny6e80.js +0 -1
  110. package/dist/assets/rotate-ccw-CvefWwHW.js +0 -1
  111. package/dist/assets/x-CcIT4ync.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$X as ee,AZ as te,CZ as r,DZ as i,EZ as a,OZ as ne,QX as re,SZ as ie,TZ as ae,XX as oe,YX as o,ZX as s,_Z as c,aZ as l,bQ as se,bZ as ce,cZ as le,cm as ue,dZ as de,eZ as fe,fQ as pe,fZ as me,gZ as u,hZ as d,iZ as he,kZ as ge,lQ as _e,lZ as ve,lm as f,mZ as p,nZ as ye,oZ as be,pZ as m,rZ as h,sZ as xe,t as g,tZ as Se,uZ as _,vU as v,vZ as y,wZ as b,xZ as x,yQ as S,yZ as C}from"./api-CWqdeSbN.js";import{c as w,g as T,n as E,r as D,t as O}from"./dropdown-menu-BVKVjups.js";import{t as k}from"./download-BaebAe6Z.js";import{t as A}from"./checkbox-DPxJTQjc.js";import{t as j}from"./rotate-ccw-CvefWwHW.js";import{t as Ce}from"./trash-2-xhtrhYsd.js";import{a as M,i as N,n as P,r as F,t as I}from"./select-CjcMQhwm.js";import{a as we,c as Te,i as Ee,n as De,o as Oe,r as ke,s as Ae,t as je}from"./alert-dialog-BcJMHbhI.js";import{t as L}from"./button-C_rIPtCv.js";import"./convexApi-G20_TNBS.js";import{r as Me}from"./toast-C_YfUacM.js";import{t as R}from"./badge-ChMMFtuW.js";import{a as Ne,i as z,n as Pe,o as B,r as V,t as Fe}from"./table-rRR3TpMc.js";var H=t(e(),1),U=n(),W=`all`;function G(e){switch(e){case`image`:return C();case`audio`:return y();case`video`:return c();case`pdf`:return u();case`document`:return d();case`archive`:return p();default:return m()}}function K(){let[e,t]=(0,H.useState)(W),[n,c]=(0,H.useState)(W),[u,d]=(0,H.useState)(W),[p,m]=(0,H.useState)(W),[y,C]=(0,H.useState)(!1),[K,q]=(0,H.useState)(null),J=S(g.files.softDelete),Y=Me();function Ie(){t(W),c(W),d(W),m(W)}async function Le(){let e=K;if(q(null),e)try{await J({fileId:e.id}),Y.success(ye())}catch(e){Y.error(Se(),e)}}let X=se(g.files.listMine,{direction:e===W?void 0:e,chatId:n===W?void 0:n,instanceName:u===W?void 0:u,category:p===W?void 0:p,includeAutoGenerated:y||void 0}),Re=(0,H.useMemo)(()=>new Intl.DateTimeFormat(pe(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:_e()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==W||n!==W||u!==W||p!==W;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:te()}),(0,U.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,U.jsxs)(I,{value:e,onValueChange:t,children:[(0,U.jsx)(N,{size:`sm`,"aria-label":ge(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(P,{children:[(0,U.jsx)(F,{value:W,children:ne()}),(0,U.jsx)(F,{value:`inbound`,children:i()}),(0,U.jsx)(F,{value:`outbound`,children:a()})]})]}),(0,U.jsxs)(I,{value:n,onValueChange:c,children:[(0,U.jsx)(N,{size:`sm`,"aria-label":ae(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(P,{children:[(0,U.jsx)(F,{value:W,children:b()}),Q.chats.map(e=>(0,U.jsx)(F,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,U.jsxs)(I,{value:u,onValueChange:d,children:[(0,U.jsx)(N,{size:`sm`,"aria-label":r(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(P,{children:[(0,U.jsx)(F,{value:W,children:ie()}),Q.instances.map(e=>(0,U.jsx)(F,{value:e,children:e},e))]})]}):null,(0,U.jsxs)(I,{value:p,onValueChange:m,children:[(0,U.jsx)(N,{size:`sm`,"aria-label":x(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(P,{children:[(0,U.jsx)(F,{value:W,children:ce()}),Q.categories.map(e=>(0,U.jsx)(F,{value:e,children:G(e)},e))]})]}),(0,U.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,U.jsx)(A,{checked:y,onCheckedChange:e=>C(e===!0),"aria-label":f()}),(0,U.jsx)(`span`,{children:f()})]}),$?(0,U.jsxs)(L,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,U.jsx)(j,{size:14,"aria-hidden":!0}),l()]}):null]}),Z.length===0?(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:$?oe():s()}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Ne,{children:(0,U.jsxs)(B,{children:[(0,U.jsx)(z,{children:me()}),(0,U.jsx)(z,{children:de()}),(0,U.jsx)(z,{children:_()}),(0,U.jsx)(z,{children:ve()}),(0,U.jsx)(z,{children:le()}),(0,U.jsx)(z,{className:`text-right`,children:xe()})]})}),(0,U.jsx)(Pe,{children:Z.map(e=>(0,U.jsxs)(B,{children:[(0,U.jsxs)(V,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,U.jsx)(R,{variant:`outline`,style:{marginLeft:6},children:ue()}):null]}),(0,U.jsx)(V,{title:e.mimeType,children:G(e.category)}),(0,U.jsx)(V,{children:(0,U.jsx)(R,{variant:`secondary`,children:e.direction===`inbound`?i():a()})}),(0,U.jsx)(V,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,U.jsx)(V,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,U.jsx)(V,{className:`text-right`,children:(0,U.jsxs)(O,{children:[(0,U.jsx)(w,{asChild:!0,children:(0,U.jsx)(L,{variant:`ghost`,size:`icon`,"aria-label":he(),children:(0,U.jsx)(T,{size:16})})}),(0,U.jsxs)(E,{align:`end`,children:[e.url?(0,U.jsx)(D,{asChild:!0,children:(0,U.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,U.jsx)(k,{size:14}),be()]})}):(0,U.jsxs)(D,{disabled:!0,children:[(0,U.jsx)(k,{size:14}),re()]}),(0,U.jsxs)(D,{variant:`destructive`,onSelect:()=>q({id:e._id,filename:e.filename}),children:[(0,U.jsx)(Ce,{size:14}),h()]})]})]})})]},e._id))})]}),ze?(0,U.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:o({cap:Be})}):null]}),(0,U.jsx)(je,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,U.jsxs)(Ee,{children:[(0,U.jsxs)(Ae,{children:[(0,U.jsx)(Te,{children:fe()}),(0,U.jsx)(we,{children:ee()})]}),(0,U.jsxs)(Oe,{children:[(0,U.jsx)(ke,{children:v()}),(0,U.jsx)(De,{onClick:()=>void Le(),children:h()})]})]})})]})}export{K as FilesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$X as ee,AZ as te,CZ as r,DZ as i,EZ as a,OZ as ne,QX as re,SZ as ie,TZ as ae,XX as oe,YX as o,ZX as s,_Z as c,aZ as l,bQ as se,bZ as ce,cZ as le,cm as ue,dZ as de,eZ as fe,fQ as pe,fZ as me,gZ as u,hZ as d,iZ as he,kZ as ge,lQ as _e,lZ as ve,lm as f,mZ as p,nZ as ye,oZ as be,pZ as m,rZ as h,sZ as xe,t as g,tZ as Se,uZ as _,vU as v,vZ as y,wZ as b,xZ as x,yQ as S,yZ as C}from"./api-D64JTta1.js";import{c as w,g as T,n as E,r as D,t as O}from"./dropdown-menu-C5VrCGFe.js";import{t as k}from"./download-BUlwPQI8.js";import{t as A}from"./checkbox-BuTZzFvU.js";import{t as j}from"./rotate-ccw-CiOuaG2h.js";import{t as Ce}from"./trash-2-CqKGt3lC.js";import{a as M,i as N,n as P,r as F,t as I}from"./select-wXM6h61N.js";import{a as we,c as Te,i as Ee,n as De,o as Oe,r as ke,s as Ae,t as je}from"./alert-dialog-C6NSAwQv.js";import{t as L}from"./button-DeHzYOzP.js";import"./convexApi-DxRiI80M.js";import{r as Me}from"./toast-DtA87VYn.js";import{t as R}from"./badge-DwWXPxwl.js";import{a as Ne,i as z,n as Pe,o as B,r as V,t as Fe}from"./table-CegX53gV.js";var H=t(e(),1),U=n(),W=`all`;function G(e){switch(e){case`image`:return C();case`audio`:return y();case`video`:return c();case`pdf`:return u();case`document`:return d();case`archive`:return p();default:return m()}}function K(){let[e,t]=(0,H.useState)(W),[n,c]=(0,H.useState)(W),[u,d]=(0,H.useState)(W),[p,m]=(0,H.useState)(W),[y,C]=(0,H.useState)(!1),[K,q]=(0,H.useState)(null),J=S(g.files.softDelete),Y=Me();function Ie(){t(W),c(W),d(W),m(W)}async function Le(){let e=K;if(q(null),e)try{await J({fileId:e.id}),Y.success(ye())}catch(e){Y.error(Se(),e)}}let X=se(g.files.listMine,{direction:e===W?void 0:e,chatId:n===W?void 0:n,instanceName:u===W?void 0:u,category:p===W?void 0:p,includeAutoGenerated:y||void 0}),Re=(0,H.useMemo)(()=>new Intl.DateTimeFormat(pe(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:_e()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==W||n!==W||u!==W||p!==W;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:te()}),(0,U.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,U.jsxs)(I,{value:e,onValueChange:t,children:[(0,U.jsx)(N,{size:`sm`,"aria-label":ge(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(P,{children:[(0,U.jsx)(F,{value:W,children:ne()}),(0,U.jsx)(F,{value:`inbound`,children:i()}),(0,U.jsx)(F,{value:`outbound`,children:a()})]})]}),(0,U.jsxs)(I,{value:n,onValueChange:c,children:[(0,U.jsx)(N,{size:`sm`,"aria-label":ae(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(P,{children:[(0,U.jsx)(F,{value:W,children:b()}),Q.chats.map(e=>(0,U.jsx)(F,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,U.jsxs)(I,{value:u,onValueChange:d,children:[(0,U.jsx)(N,{size:`sm`,"aria-label":r(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(P,{children:[(0,U.jsx)(F,{value:W,children:ie()}),Q.instances.map(e=>(0,U.jsx)(F,{value:e,children:e},e))]})]}):null,(0,U.jsxs)(I,{value:p,onValueChange:m,children:[(0,U.jsx)(N,{size:`sm`,"aria-label":x(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(P,{children:[(0,U.jsx)(F,{value:W,children:ce()}),Q.categories.map(e=>(0,U.jsx)(F,{value:e,children:G(e)},e))]})]}),(0,U.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,U.jsx)(A,{checked:y,onCheckedChange:e=>C(e===!0),"aria-label":f()}),(0,U.jsx)(`span`,{children:f()})]}),$?(0,U.jsxs)(L,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,U.jsx)(j,{size:14,"aria-hidden":!0}),l()]}):null]}),Z.length===0?(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:$?oe():s()}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Ne,{children:(0,U.jsxs)(B,{children:[(0,U.jsx)(z,{children:me()}),(0,U.jsx)(z,{children:de()}),(0,U.jsx)(z,{children:_()}),(0,U.jsx)(z,{children:ve()}),(0,U.jsx)(z,{children:le()}),(0,U.jsx)(z,{className:`text-right`,children:xe()})]})}),(0,U.jsx)(Pe,{children:Z.map(e=>(0,U.jsxs)(B,{children:[(0,U.jsxs)(V,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,U.jsx)(R,{variant:`outline`,style:{marginLeft:6},children:ue()}):null]}),(0,U.jsx)(V,{title:e.mimeType,children:G(e.category)}),(0,U.jsx)(V,{children:(0,U.jsx)(R,{variant:`secondary`,children:e.direction===`inbound`?i():a()})}),(0,U.jsx)(V,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,U.jsx)(V,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,U.jsx)(V,{className:`text-right`,children:(0,U.jsxs)(O,{children:[(0,U.jsx)(w,{asChild:!0,children:(0,U.jsx)(L,{variant:`ghost`,size:`icon`,"aria-label":he(),children:(0,U.jsx)(T,{size:16})})}),(0,U.jsxs)(E,{align:`end`,children:[e.url?(0,U.jsx)(D,{asChild:!0,children:(0,U.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,U.jsx)(k,{size:14}),be()]})}):(0,U.jsxs)(D,{disabled:!0,children:[(0,U.jsx)(k,{size:14}),re()]}),(0,U.jsxs)(D,{variant:`destructive`,onSelect:()=>q({id:e._id,filename:e.filename}),children:[(0,U.jsx)(Ce,{size:14}),h()]})]})]})})]},e._id))})]}),ze?(0,U.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:o({cap:Be})}):null]}),(0,U.jsx)(je,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,U.jsxs)(Ee,{children:[(0,U.jsxs)(Ae,{children:[(0,U.jsx)(Te,{children:fe()}),(0,U.jsx)(we,{children:ee()})]}),(0,U.jsxs)(Oe,{children:[(0,U.jsx)(ke,{children:v()}),(0,U.jsx)(De,{onClick:()=>void Le(),children:h()})]})]})})]})}export{K as FilesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Xw as r,Yw as i}from"./api-CWqdeSbN.js";import{t as a}from"./search-Dz6sLH0-.js";import{t as o}from"./rotate-ccw-CvefWwHW.js";import{t as s}from"./button-C_rIPtCv.js";import{t as c}from"./input-CSZu-bVE.js";import{t as l}from"./TimeRangePicker-BZtw1JkM.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=r(),children:p,timeRange:m,onTimeRangeChange:h,onReset:g,canReset:_=!0}){let[v,y]=(0,u.useState)(e);(0,u.useEffect)(()=>{y(e)},[e]);let b=(0,u.useRef)(null);function x(e){y(e),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>t(e),f)}(0,u.useEffect)(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function S(){b.current!==null&&window.clearTimeout(b.current),g()}return(0,d.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,d.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,d.jsx)(a,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(c,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(s,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(o,{}),i()]})]})}export{p as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Xw as r,Yw as i}from"./api-D64JTta1.js";import{t as a}from"./search-NOJ0tWl2.js";import{t as o}from"./rotate-ccw-CiOuaG2h.js";import{t as s}from"./button-DeHzYOzP.js";import{t as c}from"./input-CZ0jp9Rx.js";import{t as l}from"./TimeRangePicker-jsNw51TL.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=r(),children:p,timeRange:m,onTimeRangeChange:h,onReset:g,canReset:_=!0}){let[v,y]=(0,u.useState)(e);(0,u.useEffect)(()=>{y(e)},[e]);let b=(0,u.useRef)(null);function x(e){y(e),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>t(e),f)}(0,u.useEffect)(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function S(){b.current!==null&&window.clearTimeout(b.current),g()}return(0,d.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,d.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,d.jsx)(a,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(c,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(s,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(o,{}),i()]})]})}export{p as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$b as r,$x as i,AS as a,BS as o,Bx as s,CS as c,Cx as l,DS as u,Dx as d,ES as f,Ex as p,FS as m,Fb as h,Fx as g,GS as _,Gb as v,Gx as y,HS as b,Hx as x,IS as S,Ib as C,Ix as w,JS as T,Jb as E,Jx as D,KS as O,Kb as k,Kx as A,LS as j,Lb as ee,Lx as te,MS as M,Mx as ne,NS as N,Nx as re,OS as ie,PS as P,Px as ae,Qb as F,Qx as oe,RS as se,Rb as ce,Rx as le,SS as ue,Sx as de,TS as fe,Tx as pe,US as me,Ux as he,VS as ge,Vx as I,WS as _e,Wb as ve,Wx as L,Xb as ye,Xx as be,Yb as xe,Yx as Se,Zb as Ce,Zx as we,_S as Te,_x as Ee,aS as De,ax as Oe,bQ as R,bS as ke,bx as Ae,cS as je,cx as Me,dS as Ne,dx as Pe,eS as Fe,ex as Ie,fS as Le,fx as Re,gS as ze,gx as Be,hx as Ve,iS as He,ix as Ue,jS as We,jx as Ge,k as Ke,kS as qe,lS as Je,lx as Ye,mx as Xe,nS as Ze,nx as Qe,oS as $e,ox as et,px as tt,qS as nt,qb as rt,qx as it,rS as at,rx as ot,sS as st,sx as ct,t as z,tS as lt,tx as ut,uS as B,ux as dt,vS as ft,vx as pt,wS as mt,wx as ht,xS as gt,xx as _t,yQ as V,yS as H,yx as vt,zS as yt,zx as bt}from"./api-CWqdeSbN.js";import{t as xt}from"./chevron-left-ByEQraEh.js";import{t as St}from"./chevron-right-DMqzlhWH.js";import{t as U}from"./checkbox-DPxJTQjc.js";import{t as Ct}from"./server-DcInl3Nh.js";import{i as wt,n as Tt,r as Et,t as Dt}from"./users-CRbE186D.js";import{t as W}from"./star-5ysDlx3k.js";import{t as Ot}from"./x-CcIT4ync.js";import{a as kt,i as At,n as jt,r as Mt,t as Nt}from"./select-CjcMQhwm.js";import{i as Pt,n as Ft,r as It,t as Lt}from"./tabs-B8emuY1B.js";import{t as G}from"./button-C_rIPtCv.js";import{t as K}from"./input-CSZu-bVE.js";import"./convexApi-G20_TNBS.js";import{r as q}from"./toast-C_YfUacM.js";import{t as J}from"./badge-ChMMFtuW.js";import{a as Rt,n as zt,o as Bt,r as Vt,t as Ht}from"./dialog-CPAskUwF.js";import{t as Ut}from"./appHost-CH3EGcJw.js";import{n as Wt}from"./ConfirmDialog-B7k0wvSi.js";import{t as Gt}from"./EntitySheet-DRzkWKlH.js";import{a as Y,c as Kt,d as qt,f as Jt,i as Yt,l as Xt,n as Zt,o as Qt,r as $t,t as X,u as en}from"./groupManageView-DC3eSLA1.js";import{t as tn}from"./FilterBar-DCCuFxDn.js";import{t as nn}from"./DataTableShell-DvtkASQG.js";import{t as Z}from"./DetailChips-DDAtgnjA.js";var rn=Ke(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Q=t(e(),1),$=n(),an={name:``,description:``};function on(){let e=R(z.groups.listGroups,{}),t=R(z.me.getMe,{host:Ut})?.role===`admin`,n=V(z.groups.createGroup),r=V(z.groups.updateGroup),i=V(z.groups.deleteGroup),s=Wt(),c=q(),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(an),[v,y]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(``),E=(0,Q.useMemo)(()=>{if(!e)return e;let t=C.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,C]);function D(){p(null),g(an),d(!0)}function k(e){p(e),g({name:e.name,description:e.description??``}),d(!0)}async function A(){try{f?await r({groupId:f._id,name:h.name,description:h.description}):await n({name:h.name,description:h.description||void 0}),g(an),p(null),d(!1)}catch(e){c.error(he(),e)}}async function ee(e){if(await s({title:qe({name:e.name}),description:ie(),confirmWord:e.name,confirmLabel:u(),cancelLabel:m(),destructive:!0}))try{await i({groupId:e._id})}catch(e){c.error(x(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:nt()}),t?(0,$.jsx)(pn,{}):null,(0,$.jsx)(tn,{q:C,onQChange:w,onReset:()=>w(``),canReset:C!==``,searchPlaceholder:o()}),(0,$.jsx)(nn,{title:T(),rows:E,addLabel:O(),onAdd:t?D:void 0,emptyHint:_(),columns:[{header:_e(),cell:e=>e.name,sort:e=>e.name},{header:me(),cell:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{icon:(0,$.jsx)(Dt,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(wt,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),e.pendingInviteCount>0?(0,$.jsx)(J,{variant:`secondary`,children:Ge({count:String(e.pendingInviteCount)})}):null]}),sort:e=>e.memberCount},{header:b(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(Ct,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:ge(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(rn,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,$.jsx)(W,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:yt(),onSelect:()=>y({groupId:e._id,name:e.name})},...t?[{label:se(),onSelect:()=>k(e)},{label:j(),variant:`destructive`,onSelect:()=>void ee(e)}]:[]]}),(0,$.jsx)(Gt,{open:l,onOpenChange:d,title:f?N():P(),description:M(),canSubmit:!!h.name.trim(),onSubmit:A,submitLabel:S(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:We()}),(0,$.jsx)(K,{value:h.name,onChange:e=>g({...h,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:a()}),(0,$.jsx)(K,{value:h.description,onChange:e=>g({...h,description:e.target.value})})]})]})}),(0,$.jsx)(ln,{groupId:v?.groupId??null,groupName:v?.name??``,open:v!==null,onOpenChange:e=>{e||y(null)}})]})}var sn=8;function cn({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,$.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,$.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(xt,{size:14,"aria-hidden":!0}),ft()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":ze({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[Te(),(0,$.jsx)(St,{size:14,"aria-hidden":!0})]})]})}function ln({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=R(z.groups.getGroup,n&&e?{groupId:e}:`skip`),a=i?.viewerIsAdmin===!0,o=R(z.groups.listAssignableInstances,n&&e?{groupId:e}:`skip`),s=R(z.groups.listAssignableUsers,n&&a?{}:`skip`),u=V(z.groups.addMember),d=V(z.groups.removeMember),p=V(z.groups.bulkSetMembers),m=V(z.groups.setGroupManager),h=q(),[g,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(`members`),[C,w]=(0,Q.useState)(1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(new Set),k=(0,Q.useRef)(null),j=(0,Q.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),ee=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),te=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.restricted).map(e=>e.userId)),[i]),M=(0,Q.useMemo)(()=>new Set((i?.agents??[]).map(e=>X(e.instanceName,e.agentId))),[i]),ne=(0,Q.useMemo)(()=>{let e=(i?.agents??[]).find(e=>e.isDefault);return e?X(e.instanceName,e.agentId):null},[i]);(0,Q.useEffect)(()=>{_(``),b(``),S(`members`),w(1),E(null),k.current=null},[n,e]),(0,Q.useEffect)(()=>{w(1)},[g]),(0,Q.useEffect)(()=>{n&&i&&e&&k.current!==e&&(k.current=e,O(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let N=(0,Q.useMemo)(()=>s?Yt(s,g,D):[],[s,g,D]);async function re(t,n){if(e)try{n?await d({groupId:e,userId:t}):await u({groupId:e,userId:t})}catch(e){h.error(I(),Y(e))}}async function ie(t,n){if(e)try{await m({groupId:e,userId:t,manager:!n})}catch(e){h.error(y(),e)}}let P=qt(N,e=>j.has(e.userId)),ae=N.filter(e=>j.has(e.userId)).length,F=Xt(N,C,sn);async function oe(){if(!e||N.length===0)return;let t=N.map(e=>e.userId);try{await p({groupId:e,userIds:t,member:P!==`all`})}catch(e){h.error(I(),Y(e))}}let se=(e,t)=>(0,$.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7`,"aria-label":de({user:t}),title:de({user:t}),onClick:()=>E({userId:e,label:t}),children:[(0,$.jsx)(Et,{size:13,"aria-hidden":!0}),l()]});return(0,$.jsx)(Ht,{open:n,onOpenChange:r,children:(0,$.jsxs)(zt,{className:`oc-access`,children:[(0,$.jsxs)(Rt,{children:[(0,$.jsx)(Bt,{children:f({name:t})}),(0,$.jsx)(Vt,{children:i&&!a?bt():fe()})]}),(0,$.jsxs)(Lt,{value:x,onValueChange:S,className:`oc-access__tabs`,children:[(0,$.jsxs)(It,{className:`w-full`,children:[(0,$.jsxs)(Pt,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Dt,{size:13,"aria-hidden":!0}),mt(),i?(0,$.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:j.size}):null]}),(0,$.jsxs)(Pt,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ct,{size:13,"aria-hidden":!0}),ue(),i?(0,$.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,$.jsxs)(Pt,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(rn,{size:13,"aria-hidden":!0}),Ze(),i?(0,$.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,$.jsx)(Ft,{value:`members`,children:i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):a?s===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):s.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:je()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{value:g,onChange:e=>_(e.target.value),placeholder:c(),className:`oc-access__search`}),N.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ke()}):(0,$.jsxs)($.Fragment,{children:[N.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(U,{checked:P===`all`||P===`some`&&`indeterminate`,onCheckedChange:()=>void oe(),"aria-label":H()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:H()}),(0,$.jsxs)(J,{variant:`outline`,className:`oc-access__count`,children:[ae,` / `,N.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:F.pageItems.map(e=>{let t=j.has(e.userId),n=Jt(e),r=ee.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(U,{checked:t,onCheckedChange:()=>void re(e.userId,t),"aria-label":Le({user:n.primary})}),(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,$.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),t&&te.has(e.userId)?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:_t()}):null,(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:en(e.role)}),t?se(e.userId,n.primary):null,(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?A():it(),title:r?A():it(),onClick:()=>void ie(e.userId,r),children:(0,$.jsx)(wt,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(cn,{page:F.page,pageCount:F.pageCount,onPage:w})]})]}):e?(0,$.jsx)(un,{groupId:e,members:i.members,agentsButton:se}):null}),(0,$.jsxs)(Ft,{value:`agents`,children:[i&&!a?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Re()}):null,o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):o.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:st()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{value:v,onChange:e=>b(e.target.value),placeholder:gt(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:o.map(t=>(0,$.jsx)(fn,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:M,defaultKey:ne,viewerIsAdmin:a,query:v},`${e}-${t._id}`))})]})]}),(0,$.jsx)(Ft,{value:`charts`,children:(0,$.jsx)(mn,{groupId:e})})]}),(0,$.jsx)(dn,{groupId:e,member:T,onOpenChange:e=>{e||E(null)}})]})})}function un({groupId:e,members:t,agentsButton:n}){let r=R(z.groupInvites.listGroupInviteRequests,{groupId:e}),i=V(z.groupInvites.requestGroupInvite),a=V(z.groups.removeMember),o=Wt(),s=q(),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(1),h=Xt(t,u,sn);async function _(t){t.preventDefault();let n=c.trim();if(n)try{await i({groupId:e,email:n}),l(``),s.success(ae())}catch(e){s.error(re(),e)}}async function v(t,n){if(await o({title:d({user:n}),description:pe({user:n}),confirmLabel:ht(),cancelLabel:m(),destructive:!0}))try{await a({groupId:e,userId:t})}catch(e){s.error(I(),Y(e))}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`form`,{className:`oc-access__invite`,onSubmit:e=>void _(e),children:[(0,$.jsx)(K,{type:`email`,value:c,onChange:e=>l(e.target.value),placeholder:w(),"aria-label":le()}),(0,$.jsxs)(G,{type:`submit`,size:`sm`,disabled:!c.trim(),children:[(0,$.jsx)(Tt,{size:14,"aria-hidden":!0}),g()]})]}),(0,$.jsx)(`p`,{className:`oc-access__hint`,children:te()}),t.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Ae()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:h.pageItems.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.label,children:e.label}),e.restricted?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:_t()}):null,n(e.userId,e.label),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:e.manager?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":D(),title:D(),children:(0,$.jsx)(wt,{size:15,"aria-hidden":!0})}):null}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.manager||e.lastGroup,"aria-label":d({user:e.label}),title:e.manager?p():e.lastGroup?ve():d({user:e.label}),onClick:()=>void v(e.userId,e.label),children:(0,$.jsx)(Ot,{size:14,"aria-hidden":!0})})]},e.userId))}),(0,$.jsx)(cn,{page:h.page,pageCount:h.pageCount,onPage:f})]}),r!==void 0&&r.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-access__subhead`,children:ne()}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,$.jsx)(J,{variant:e.status===`pending`?`secondary`:`outline`,className:`oc-access__role`,children:Qt(e.status)})]},e._id))})]}):null]})}function dn({groupId:e,member:t,onOpenChange:n}){let i=R(z.groups.getMemberAgentSettings,e&&t?{groupId:e,userId:t.userId}:`skip`),a=V(z.groups.setMemberAgents),o=V(z.groups.setMemberDefaultAgent),s=q();async function c(e){try{await e()}catch(e){s.error(v(),e)}}let l=i?.agents??[],u=new Map(l.map(e=>[X(e.instanceName,e.agentId),e])),d=[...u.keys()],f=new Set(l.filter(e=>e.allowed).map(e=>X(e.instanceName,e.agentId)));function p(n){if(!e||!t||!i)return;let r=Kt(d,f,i.restricted,n).map(e=>{let t=u.get(e);return{instanceName:t.instanceName,agentId:t.agentId}});c(()=>a({groupId:e,userId:t.userId,agents:r}))}return(0,$.jsx)(Ht,{open:t!==null,onOpenChange:n,children:(0,$.jsxs)(zt,{className:`oc-access`,children:[(0,$.jsxs)(Rt,{children:[(0,$.jsx)(Bt,{children:Ie({user:t?.label??``})}),(0,$.jsx)(Vt,{children:r()})]}),i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):i===null||l.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:k()}):(0,$.jsxs)($.Fragment,{children:[i.settable?null:(0,$.jsx)(`p`,{className:`oc-access__hint`,children:h()}),i.adminNarrowed?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ce()}):null,i.restrictedByAdmin&&!i.viewerIsAdmin?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:C()}):null,(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,children:i.restricted?Ce():F()}),i.restricted?(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin,onClick:()=>e&&t?void c(()=>a({groupId:e,userId:t.userId,agents:null})):void 0,children:ye()}):null]}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:l.map(n=>{let r=X(n.instanceName,n.agentId),a=n.displayName??n.agentId;return(0,$.jsxs)(`div`,{className:`oc-access__row oc-reveal-host`,children:[(0,$.jsx)(U,{checked:n.allowed,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin&&!n.allowed,onCheckedChange:()=>p(r),"aria-label":xe({name:a})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:a,children:a}),n.limitedByAdmin?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:ee()}):null,n.state===`deleted`?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__gone`,children:at()}):null,n.allowed?n.isMemberDefault?(0,$.jsx)(G,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,disabled:!i.settable,"aria-label":E(),title:E(),onClick:()=>e&&t?void c(()=>o({groupId:e,userId:t.userId,agent:null})):void 0,children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):(0,$.jsx)(G,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault oc-reveal oc-hit`,disabled:!i.settable,"aria-label":rt(),title:rt(),onClick:()=>e&&t?void c(()=>o({groupId:e,userId:t.userId,agent:{instanceName:n.instanceName,agentId:n.agentId}})):void 0,children:(0,$.jsx)(W,{size:14})}):null]},r)})})]})]})})}function fn({groupId:e,instanceName:t,kind:n,assigned:r,defaultKey:i,viewerIsAdmin:a,query:o}){let c=R(z.groups.listAssignableAgents,e?{instanceName:t,groupId:e}:`skip`),l=V(z.groups.assignAgentToGroup),u=V(z.groups.removeAgentFromGroup),d=V(z.groups.bulkSetGroupAgents),f=V(z.groups.claimAgentForGroup),p=V(z.groups.setGroupDefaultAgent),m=q(),[h,g]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{g(1)},[o]),!e)return null;let _=$t(c?.agents??[],o),v=c?.discovery&&!c.discovery.lastPollOk,y=e=>Zt({assigned:r.has(X(t,e.agentId)),claimable:e.claimable,reservedForGroup:e.reservedForGroup,enabled:e.enabled,present:e.presentInLastOk!==!1},a),b=_.filter(e=>y(e)!==`claim`),x=_.filter(e=>y(e)===`claim`);if(o.trim()&&_.length===0)return null;let S=b.filter(e=>y(e)===`toggle`&&e.presentInLastOk!==!1&&e.enabled!==!1),C=qt(S,e=>r.has(X(t,e.agentId))),w=Xt(b,h,sn);async function T(n,r){try{r?await u({groupId:e,instanceName:t,agentId:n}):await l({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(s(),Y(e))}}async function E(){if(S.length===0)return;let n=S.map(e=>e.agentId);try{await d({groupId:e,instanceName:t,agentIds:n,assigned:C!==`all`})}catch(e){m.error(s(),Y(e))}}async function D(n){try{await f({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(ct(),e)}}async function O(n){try{await p({groupId:e,agent:n===null?null:{instanceName:t,agentId:n}})}catch(e){m.error(ut(),e)}}let k=e=>e.reservedForGroup?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:et()}):e.reserved?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:e.reservedGroupName===null?Ue():Oe({group:e.reservedGroupName})}):null;return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(Ct,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(J,{variant:`outline`,className:`oc-access__kind`,children:n}),v?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__stale`,children:He()}):null]}),c===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Je()}):_.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:v?De():$e()}):(0,$.jsxs)($.Fragment,{children:[S.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(U,{checked:C===`all`||C===`some`&&`indeterminate`,onCheckedChange:()=>void E(),"aria-label":H()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:H()})]}):null,w.pageItems.map(e=>{let n=X(t,e.agentId),a=r.has(n),o=e.presentInLastOk===!1,s=y(e)===`locked`;return(0,$.jsxs)(`div`,{className:`oc-access__row oc-reveal-host${s?` is-disabled`:``}`,children:[(0,$.jsx)(U,{checked:a,disabled:s&&!a,onCheckedChange:()=>void T(e.agentId,a),"aria-label":Ne({name:e.displayName??e.agentId})}),(0,$.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,k(e),o?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__gone`,children:at()}):null,a?i===n?(0,$.jsx)(G,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,"aria-label":ot(),title:ot(),onClick:()=>void O(null),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):(0,$.jsx)(G,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault oc-reveal oc-hit`,"aria-label":Qe(),title:Qe(),onClick:()=>void O(e.agentId),children:(0,$.jsx)(W,{size:14})}):null]},e.agentId)}),(0,$.jsx)(cn,{page:w.page,pageCount:w.pageCount,onPage:g}),x.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-access__subhead`,children:Pe()}),(0,$.jsx)(`p`,{className:`oc-access__hint`,children:dt()}),x.map(e=>{let t=e.displayName??e.agentId;return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsxs)(`span`,{className:`oc-access__label`,title:t,children:[e.emoji?`${e.emoji} `:``,t]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,"aria-label":Me({name:t}),onClick:()=>void D(e.agentId),children:Ye()})]},e.agentId)})]}):null]})]})}function pn(){let e=R(z.groupInvites.listPendingInviteRequests,{}),t=V(z.groupInvites.decideGroupInvite),n=q();if(e===void 0||e.length===0)return null;async function r(e,r){try{await t({requestId:e,approve:r})}catch(e){n.error(tt(),e)}}return(0,$.jsxs)(`section`,{className:`oc-invites`,"aria-label":vt(),children:[(0,$.jsxs)(`h3`,{className:`oc-invites__title`,children:[(0,$.jsx)(Tt,{size:14,"aria-hidden":!0}),vt(),(0,$.jsx)(J,{variant:`secondary`,children:e.length})]}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,$.jsxs)(`span`,{className:`oc-access__sub`,children:[e.groupName??`?`,` ·`,` `,pt({by:e.requestedBy})]})]}),e.account===`ready`?null:(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:e.account===`none`?Ve():Xe()}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,disabled:e.account!==`ready`,onClick:()=>void r(e._id,!0),children:Ee()}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>void r(e._id,!1),children:Be()})]},e._id))})]})}function mn({groupId:e}){let t=R(z.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=V(z.charts.assignChartToGroup),r=V(z.charts.removeChartFromGroup),a=V(z.charts.setGroupDefaultChart),o=V(z.charts.addChartToGroupPool),s=V(z.charts.removeChartFromGroupPool),c=q();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()});let{pool:l,addable:u,canManagePool:d}=t;if(l.length===0&&!d)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:lt()});async function f(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){c.error(L(),e)}}async function p(t){try{await a({groupId:e,chartKey:t})}catch(e){c.error(L(),e)}}async function m(t){try{await o({groupId:e,chartKey:t})}catch(e){c.error(L(),e)}}async function h(t){try{await s({groupId:e,chartKey:t})}catch(e){c.error(L(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:l.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(U,{checked:e.selected,onCheckedChange:()=>void f(e.chartKey,e.selected),"aria-label":we({name:e.name})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":be(),title:be(),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void p(e.chartKey),children:Se()}):null,d?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":oe({name:e.name}),title:oe({name:e.name}),onClick:()=>void h(e.chartKey),children:(0,$.jsx)(Ot,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),d?u.length>0?(0,$.jsxs)(Nt,{value:``,onValueChange:e=>void m(e),children:[(0,$.jsx)(At,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(kt,{placeholder:i()})}),(0,$.jsx)(jt,{children:u.map(e=>(0,$.jsx)(Mt,{value:e.chartKey,children:e.name},e.chartKey))})]}):l.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Fe()}):null:null]})}export{on as GroupsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$b as r,$x as i,AS as a,BS as o,Bx as s,CS as c,Cx as l,DS as u,Dx as d,ES as f,Ex as p,FS as m,Fb as h,Fx as g,GS as _,Gb as v,Gx as y,HS as b,Hx as x,IS as S,Ib as C,Ix as w,JS as T,Jb as E,Jx as D,KS as O,Kb as k,Kx as A,LS as j,Lb as ee,Lx as te,MS as M,Mx as ne,NS as N,Nx as re,OS as ie,PS as P,Px as ae,Qb as F,Qx as oe,RS as se,Rb as ce,Rx as le,SS as ue,Sx as de,TS as fe,Tx as pe,US as me,Ux as he,VS as ge,Vx as I,WS as _e,Wb as ve,Wx as L,Xb as ye,Xx as be,Yb as xe,Yx as Se,Zb as Ce,Zx as we,_S as Te,_x as Ee,aS as De,ax as Oe,bQ as R,bS as ke,bx as Ae,cS as je,cx as Me,dS as Ne,dx as Pe,eS as Fe,ex as Ie,fS as Le,fx as Re,gS as ze,gx as Be,hx as Ve,iS as He,ix as Ue,jS as We,jx as Ge,k as Ke,kS as qe,lS as Je,lx as Ye,mx as Xe,nS as Ze,nx as Qe,oS as $e,ox as et,px as tt,qS as nt,qb as rt,qx as it,rS as at,rx as ot,sS as st,sx as ct,t as z,tS as lt,tx as ut,uS as B,ux as dt,vS as ft,vx as pt,wS as mt,wx as ht,xS as gt,xx as _t,yQ as V,yS as H,yx as vt,zS as yt,zx as bt}from"./api-D64JTta1.js";import{t as xt}from"./chevron-left-CjQ1kn0w.js";import{t as St}from"./chevron-right-DkaFdk2G.js";import{t as U}from"./checkbox-BuTZzFvU.js";import{t as Ct}from"./server-C5TTb6-A.js";import{i as wt,n as Tt,r as Et,t as Dt}from"./users-BUu1wJNm.js";import{t as W}from"./star-N2N0cbAA.js";import{t as Ot}from"./x-BNU-sWkh.js";import{a as kt,i as At,n as jt,r as Mt,t as Nt}from"./select-wXM6h61N.js";import{i as Pt,n as Ft,r as It,t as Lt}from"./tabs-CfQK0-wk.js";import{t as G}from"./button-DeHzYOzP.js";import{t as K}from"./input-CZ0jp9Rx.js";import"./convexApi-DxRiI80M.js";import{r as q}from"./toast-DtA87VYn.js";import{t as J}from"./badge-DwWXPxwl.js";import{a as Rt,n as zt,o as Bt,r as Vt,t as Ht}from"./dialog-awuZdW9M.js";import{t as Ut}from"./appHost-CH3EGcJw.js";import{n as Wt}from"./ConfirmDialog-Bfi4_Ti8.js";import{t as Gt}from"./EntitySheet-D8Vdib4B.js";import{a as Y,c as Kt,d as qt,f as Jt,i as Yt,l as Xt,n as Zt,o as Qt,r as $t,t as X,u as en}from"./groupManageView-CKEYC6zY.js";import{t as tn}from"./FilterBar-DtNuk6dI.js";import{t as nn}from"./DataTableShell-1ZsZ0a2J.js";import{t as Z}from"./DetailChips-DkRU5HQ5.js";var rn=Ke(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Q=t(e(),1),$=n(),an={name:``,description:``};function on(){let e=R(z.groups.listGroups,{}),t=R(z.me.getMe,{host:Ut})?.role===`admin`,n=V(z.groups.createGroup),r=V(z.groups.updateGroup),i=V(z.groups.deleteGroup),s=Wt(),c=q(),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(an),[v,y]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(``),E=(0,Q.useMemo)(()=>{if(!e)return e;let t=C.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,C]);function D(){p(null),g(an),d(!0)}function k(e){p(e),g({name:e.name,description:e.description??``}),d(!0)}async function A(){try{f?await r({groupId:f._id,name:h.name,description:h.description}):await n({name:h.name,description:h.description||void 0}),g(an),p(null),d(!1)}catch(e){c.error(he(),e)}}async function ee(e){if(await s({title:qe({name:e.name}),description:ie(),confirmWord:e.name,confirmLabel:u(),cancelLabel:m(),destructive:!0}))try{await i({groupId:e._id})}catch(e){c.error(x(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:nt()}),t?(0,$.jsx)(pn,{}):null,(0,$.jsx)(tn,{q:C,onQChange:w,onReset:()=>w(``),canReset:C!==``,searchPlaceholder:o()}),(0,$.jsx)(nn,{title:T(),rows:E,addLabel:O(),onAdd:t?D:void 0,emptyHint:_(),columns:[{header:_e(),cell:e=>e.name,sort:e=>e.name},{header:me(),cell:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{icon:(0,$.jsx)(Dt,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(wt,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),e.pendingInviteCount>0?(0,$.jsx)(J,{variant:`secondary`,children:Ge({count:String(e.pendingInviteCount)})}):null]}),sort:e=>e.memberCount},{header:b(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(Ct,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:ge(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(rn,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,$.jsx)(W,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:yt(),onSelect:()=>y({groupId:e._id,name:e.name})},...t?[{label:se(),onSelect:()=>k(e)},{label:j(),variant:`destructive`,onSelect:()=>void ee(e)}]:[]]}),(0,$.jsx)(Gt,{open:l,onOpenChange:d,title:f?N():P(),description:M(),canSubmit:!!h.name.trim(),onSubmit:A,submitLabel:S(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:We()}),(0,$.jsx)(K,{value:h.name,onChange:e=>g({...h,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:a()}),(0,$.jsx)(K,{value:h.description,onChange:e=>g({...h,description:e.target.value})})]})]})}),(0,$.jsx)(ln,{groupId:v?.groupId??null,groupName:v?.name??``,open:v!==null,onOpenChange:e=>{e||y(null)}})]})}var sn=8;function cn({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,$.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,$.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(xt,{size:14,"aria-hidden":!0}),ft()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":ze({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[Te(),(0,$.jsx)(St,{size:14,"aria-hidden":!0})]})]})}function ln({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=R(z.groups.getGroup,n&&e?{groupId:e}:`skip`),a=i?.viewerIsAdmin===!0,o=R(z.groups.listAssignableInstances,n&&e?{groupId:e}:`skip`),s=R(z.groups.listAssignableUsers,n&&a?{}:`skip`),u=V(z.groups.addMember),d=V(z.groups.removeMember),p=V(z.groups.bulkSetMembers),m=V(z.groups.setGroupManager),h=q(),[g,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(`members`),[C,w]=(0,Q.useState)(1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(new Set),k=(0,Q.useRef)(null),j=(0,Q.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),ee=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),te=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.restricted).map(e=>e.userId)),[i]),M=(0,Q.useMemo)(()=>new Set((i?.agents??[]).map(e=>X(e.instanceName,e.agentId))),[i]),ne=(0,Q.useMemo)(()=>{let e=(i?.agents??[]).find(e=>e.isDefault);return e?X(e.instanceName,e.agentId):null},[i]);(0,Q.useEffect)(()=>{_(``),b(``),S(`members`),w(1),E(null),k.current=null},[n,e]),(0,Q.useEffect)(()=>{w(1)},[g]),(0,Q.useEffect)(()=>{n&&i&&e&&k.current!==e&&(k.current=e,O(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let N=(0,Q.useMemo)(()=>s?Yt(s,g,D):[],[s,g,D]);async function re(t,n){if(e)try{n?await d({groupId:e,userId:t}):await u({groupId:e,userId:t})}catch(e){h.error(I(),Y(e))}}async function ie(t,n){if(e)try{await m({groupId:e,userId:t,manager:!n})}catch(e){h.error(y(),e)}}let P=qt(N,e=>j.has(e.userId)),ae=N.filter(e=>j.has(e.userId)).length,F=Xt(N,C,sn);async function oe(){if(!e||N.length===0)return;let t=N.map(e=>e.userId);try{await p({groupId:e,userIds:t,member:P!==`all`})}catch(e){h.error(I(),Y(e))}}let se=(e,t)=>(0,$.jsxs)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7`,"aria-label":de({user:t}),title:de({user:t}),onClick:()=>E({userId:e,label:t}),children:[(0,$.jsx)(Et,{size:13,"aria-hidden":!0}),l()]});return(0,$.jsx)(Ht,{open:n,onOpenChange:r,children:(0,$.jsxs)(zt,{className:`oc-access`,children:[(0,$.jsxs)(Rt,{children:[(0,$.jsx)(Bt,{children:f({name:t})}),(0,$.jsx)(Vt,{children:i&&!a?bt():fe()})]}),(0,$.jsxs)(Lt,{value:x,onValueChange:S,className:`oc-access__tabs`,children:[(0,$.jsxs)(It,{className:`w-full`,children:[(0,$.jsxs)(Pt,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Dt,{size:13,"aria-hidden":!0}),mt(),i?(0,$.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:j.size}):null]}),(0,$.jsxs)(Pt,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ct,{size:13,"aria-hidden":!0}),ue(),i?(0,$.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,$.jsxs)(Pt,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(rn,{size:13,"aria-hidden":!0}),Ze(),i?(0,$.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,$.jsx)(Ft,{value:`members`,children:i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):a?s===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):s.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:je()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{value:g,onChange:e=>_(e.target.value),placeholder:c(),className:`oc-access__search`}),N.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ke()}):(0,$.jsxs)($.Fragment,{children:[N.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(U,{checked:P===`all`||P===`some`&&`indeterminate`,onCheckedChange:()=>void oe(),"aria-label":H()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:H()}),(0,$.jsxs)(J,{variant:`outline`,className:`oc-access__count`,children:[ae,` / `,N.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:F.pageItems.map(e=>{let t=j.has(e.userId),n=Jt(e),r=ee.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(U,{checked:t,onCheckedChange:()=>void re(e.userId,t),"aria-label":Le({user:n.primary})}),(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,$.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),t&&te.has(e.userId)?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:_t()}):null,(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:en(e.role)}),t?se(e.userId,n.primary):null,(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?A():it(),title:r?A():it(),onClick:()=>void ie(e.userId,r),children:(0,$.jsx)(wt,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(cn,{page:F.page,pageCount:F.pageCount,onPage:w})]})]}):e?(0,$.jsx)(un,{groupId:e,members:i.members,agentsButton:se}):null}),(0,$.jsxs)(Ft,{value:`agents`,children:[i&&!a?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Re()}):null,o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):o.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:st()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{value:v,onChange:e=>b(e.target.value),placeholder:gt(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:o.map(t=>(0,$.jsx)(fn,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:M,defaultKey:ne,viewerIsAdmin:a,query:v},`${e}-${t._id}`))})]})]}),(0,$.jsx)(Ft,{value:`charts`,children:(0,$.jsx)(mn,{groupId:e})})]}),(0,$.jsx)(dn,{groupId:e,member:T,onOpenChange:e=>{e||E(null)}})]})})}function un({groupId:e,members:t,agentsButton:n}){let r=R(z.groupInvites.listGroupInviteRequests,{groupId:e}),i=V(z.groupInvites.requestGroupInvite),a=V(z.groups.removeMember),o=Wt(),s=q(),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(1),h=Xt(t,u,sn);async function _(t){t.preventDefault();let n=c.trim();if(n)try{await i({groupId:e,email:n}),l(``),s.success(ae())}catch(e){s.error(re(),e)}}async function v(t,n){if(await o({title:d({user:n}),description:pe({user:n}),confirmLabel:ht(),cancelLabel:m(),destructive:!0}))try{await a({groupId:e,userId:t})}catch(e){s.error(I(),Y(e))}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`form`,{className:`oc-access__invite`,onSubmit:e=>void _(e),children:[(0,$.jsx)(K,{type:`email`,value:c,onChange:e=>l(e.target.value),placeholder:w(),"aria-label":le()}),(0,$.jsxs)(G,{type:`submit`,size:`sm`,disabled:!c.trim(),children:[(0,$.jsx)(Tt,{size:14,"aria-hidden":!0}),g()]})]}),(0,$.jsx)(`p`,{className:`oc-access__hint`,children:te()}),t.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Ae()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:h.pageItems.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.label,children:e.label}),e.restricted?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:_t()}):null,n(e.userId,e.label),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:e.manager?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":D(),title:D(),children:(0,$.jsx)(wt,{size:15,"aria-hidden":!0})}):null}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.manager||e.lastGroup,"aria-label":d({user:e.label}),title:e.manager?p():e.lastGroup?ve():d({user:e.label}),onClick:()=>void v(e.userId,e.label),children:(0,$.jsx)(Ot,{size:14,"aria-hidden":!0})})]},e.userId))}),(0,$.jsx)(cn,{page:h.page,pageCount:h.pageCount,onPage:f})]}),r!==void 0&&r.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-access__subhead`,children:ne()}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,$.jsx)(J,{variant:e.status===`pending`?`secondary`:`outline`,className:`oc-access__role`,children:Qt(e.status)})]},e._id))})]}):null]})}function dn({groupId:e,member:t,onOpenChange:n}){let i=R(z.groups.getMemberAgentSettings,e&&t?{groupId:e,userId:t.userId}:`skip`),a=V(z.groups.setMemberAgents),o=V(z.groups.setMemberDefaultAgent),s=q();async function c(e){try{await e()}catch(e){s.error(v(),e)}}let l=i?.agents??[],u=new Map(l.map(e=>[X(e.instanceName,e.agentId),e])),d=[...u.keys()],f=new Set(l.filter(e=>e.allowed).map(e=>X(e.instanceName,e.agentId)));function p(n){if(!e||!t||!i)return;let r=Kt(d,f,i.restricted,n).map(e=>{let t=u.get(e);return{instanceName:t.instanceName,agentId:t.agentId}});c(()=>a({groupId:e,userId:t.userId,agents:r}))}return(0,$.jsx)(Ht,{open:t!==null,onOpenChange:n,children:(0,$.jsxs)(zt,{className:`oc-access`,children:[(0,$.jsxs)(Rt,{children:[(0,$.jsx)(Bt,{children:Ie({user:t?.label??``})}),(0,$.jsx)(Vt,{children:r()})]}),i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):i===null||l.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:k()}):(0,$.jsxs)($.Fragment,{children:[i.settable?null:(0,$.jsx)(`p`,{className:`oc-access__hint`,children:h()}),i.adminNarrowed?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ce()}):null,i.restrictedByAdmin&&!i.viewerIsAdmin?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:C()}):null,(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,children:i.restricted?Ce():F()}),i.restricted?(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin,onClick:()=>e&&t?void c(()=>a({groupId:e,userId:t.userId,agents:null})):void 0,children:ye()}):null]}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:l.map(n=>{let r=X(n.instanceName,n.agentId),a=n.displayName??n.agentId;return(0,$.jsxs)(`div`,{className:`oc-access__row oc-reveal-host`,children:[(0,$.jsx)(U,{checked:n.allowed,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin&&!n.allowed,onCheckedChange:()=>p(r),"aria-label":xe({name:a})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:a,children:a}),n.limitedByAdmin?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:ee()}):null,n.state===`deleted`?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__gone`,children:at()}):null,n.allowed?n.isMemberDefault?(0,$.jsx)(G,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,disabled:!i.settable,"aria-label":E(),title:E(),onClick:()=>e&&t?void c(()=>o({groupId:e,userId:t.userId,agent:null})):void 0,children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):(0,$.jsx)(G,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault oc-reveal oc-hit`,disabled:!i.settable,"aria-label":rt(),title:rt(),onClick:()=>e&&t?void c(()=>o({groupId:e,userId:t.userId,agent:{instanceName:n.instanceName,agentId:n.agentId}})):void 0,children:(0,$.jsx)(W,{size:14})}):null]},r)})})]})]})})}function fn({groupId:e,instanceName:t,kind:n,assigned:r,defaultKey:i,viewerIsAdmin:a,query:o}){let c=R(z.groups.listAssignableAgents,e?{instanceName:t,groupId:e}:`skip`),l=V(z.groups.assignAgentToGroup),u=V(z.groups.removeAgentFromGroup),d=V(z.groups.bulkSetGroupAgents),f=V(z.groups.claimAgentForGroup),p=V(z.groups.setGroupDefaultAgent),m=q(),[h,g]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{g(1)},[o]),!e)return null;let _=$t(c?.agents??[],o),v=c?.discovery&&!c.discovery.lastPollOk,y=e=>Zt({assigned:r.has(X(t,e.agentId)),claimable:e.claimable,reservedForGroup:e.reservedForGroup,enabled:e.enabled,present:e.presentInLastOk!==!1},a),b=_.filter(e=>y(e)!==`claim`),x=_.filter(e=>y(e)===`claim`);if(o.trim()&&_.length===0)return null;let S=b.filter(e=>y(e)===`toggle`&&e.presentInLastOk!==!1&&e.enabled!==!1),C=qt(S,e=>r.has(X(t,e.agentId))),w=Xt(b,h,sn);async function T(n,r){try{r?await u({groupId:e,instanceName:t,agentId:n}):await l({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(s(),Y(e))}}async function E(){if(S.length===0)return;let n=S.map(e=>e.agentId);try{await d({groupId:e,instanceName:t,agentIds:n,assigned:C!==`all`})}catch(e){m.error(s(),Y(e))}}async function D(n){try{await f({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(ct(),e)}}async function O(n){try{await p({groupId:e,agent:n===null?null:{instanceName:t,agentId:n}})}catch(e){m.error(ut(),e)}}let k=e=>e.reservedForGroup?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:et()}):e.reserved?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:e.reservedGroupName===null?Ue():Oe({group:e.reservedGroupName})}):null;return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(Ct,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(J,{variant:`outline`,className:`oc-access__kind`,children:n}),v?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__stale`,children:He()}):null]}),c===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Je()}):_.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:v?De():$e()}):(0,$.jsxs)($.Fragment,{children:[S.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(U,{checked:C===`all`||C===`some`&&`indeterminate`,onCheckedChange:()=>void E(),"aria-label":H()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:H()})]}):null,w.pageItems.map(e=>{let n=X(t,e.agentId),a=r.has(n),o=e.presentInLastOk===!1,s=y(e)===`locked`;return(0,$.jsxs)(`div`,{className:`oc-access__row oc-reveal-host${s?` is-disabled`:``}`,children:[(0,$.jsx)(U,{checked:a,disabled:s&&!a,onCheckedChange:()=>void T(e.agentId,a),"aria-label":Ne({name:e.displayName??e.agentId})}),(0,$.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,k(e),o?(0,$.jsx)(J,{variant:`outline`,className:`oc-access__gone`,children:at()}):null,a?i===n?(0,$.jsx)(G,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,"aria-label":ot(),title:ot(),onClick:()=>void O(null),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):(0,$.jsx)(G,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault oc-reveal oc-hit`,"aria-label":Qe(),title:Qe(),onClick:()=>void O(e.agentId),children:(0,$.jsx)(W,{size:14})}):null]},e.agentId)}),(0,$.jsx)(cn,{page:w.page,pageCount:w.pageCount,onPage:g}),x.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-access__subhead`,children:Pe()}),(0,$.jsx)(`p`,{className:`oc-access__hint`,children:dt()}),x.map(e=>{let t=e.displayName??e.agentId;return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsxs)(`span`,{className:`oc-access__label`,title:t,children:[e.emoji?`${e.emoji} `:``,t]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,"aria-label":Me({name:t}),onClick:()=>void D(e.agentId),children:Ye()})]},e.agentId)})]}):null]})]})}function pn(){let e=R(z.groupInvites.listPendingInviteRequests,{}),t=V(z.groupInvites.decideGroupInvite),n=q();if(e===void 0||e.length===0)return null;async function r(e,r){try{await t({requestId:e,approve:r})}catch(e){n.error(tt(),e)}}return(0,$.jsxs)(`section`,{className:`oc-invites`,"aria-label":vt(),children:[(0,$.jsxs)(`h3`,{className:`oc-invites__title`,children:[(0,$.jsx)(Tt,{size:14,"aria-hidden":!0}),vt(),(0,$.jsx)(J,{variant:`secondary`,children:e.length})]}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,$.jsxs)(`span`,{className:`oc-access__sub`,children:[e.groupName??`?`,` ·`,` `,pt({by:e.requestedBy})]})]}),e.account===`ready`?null:(0,$.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:e.account===`none`?Ve():Xe()}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,disabled:e.account!==`ready`,onClick:()=>void r(e._id,!0),children:Ee()}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>void r(e._id,!1),children:Be()})]},e._id))})]})}function mn({groupId:e}){let t=R(z.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=V(z.charts.assignChartToGroup),r=V(z.charts.removeChartFromGroup),a=V(z.charts.setGroupDefaultChart),o=V(z.charts.addChartToGroupPool),s=V(z.charts.removeChartFromGroupPool),c=q();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()});let{pool:l,addable:u,canManagePool:d}=t;if(l.length===0&&!d)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:lt()});async function f(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){c.error(L(),e)}}async function p(t){try{await a({groupId:e,chartKey:t})}catch(e){c.error(L(),e)}}async function m(t){try{await o({groupId:e,chartKey:t})}catch(e){c.error(L(),e)}}async function h(t){try{await s({groupId:e,chartKey:t})}catch(e){c.error(L(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:l.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(U,{checked:e.selected,onCheckedChange:()=>void f(e.chartKey,e.selected),"aria-label":we({name:e.name})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":be(),title:be(),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void p(e.chartKey),children:Se()}):null,d?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":oe({name:e.name}),title:oe({name:e.name}),onClick:()=>void h(e.chartKey),children:(0,$.jsx)(Ot,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),d?u.length>0?(0,$.jsxs)(Nt,{value:``,onValueChange:e=>void m(e),children:[(0,$.jsx)(At,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(kt,{placeholder:i()})}),(0,$.jsx)(jt,{children:u.map(e=>(0,$.jsx)(Mt,{value:e.chartKey,children:e.name},e.chartKey))})]}):l.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Fe()}):null:null]})}export{on as GroupsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$I as r,AI as i,AL as a,BI as o,BL as s,Bt as c,CI as l,CL as u,Cr as d,Cs as f,DI as p,DL as m,Dh as h,EI as g,EL as _,Eh as v,FI as y,FL as ee,GI as b,GL as x,HI as S,HL as te,Ht as ne,II as C,IL as re,It as ie,JI as w,JL as ae,KI as T,KL as oe,LI as E,LL as D,Lt as se,MI as O,ML as ce,Mb as le,NI as ue,NL as de,Nb as fe,OI as pe,OL as me,Oh as he,PI as ge,PL as _e,Pb as ve,QI as ye,RI as be,RL as xe,Rj as Se,Rt as Ce,SI as we,SL as Te,Sr as Ee,Ss as De,TI as Oe,TL as ke,Th as Ae,Tr as je,Ts as Me,UI as Ne,UL as Pe,Ut as Fe,VI as Ie,VL as Le,Vt as Re,WI as ze,WL as Be,Wt as Ve,XI as He,XL as Ue,YI as We,YL as Ge,ZI as Ke,ZL as qe,_I as Je,_L as Ye,_Q as k,_r as Xe,_s as Ze,aI as Qe,aL as $e,bI as et,bL as tt,bQ as A,bd as nt,br as rt,bs as it,cI as at,cL as ot,dI as st,dL as ct,ds as lt,eL as ut,fG as dt,fI as ft,fL as pt,fs as mt,gI as ht,gL as gt,gr as _t,gs as vt,hI as yt,hL as bt,hs as xt,iI as St,iL as Ct,jL as wt,kI as Tt,kL as Et,lI as Dt,lL as Ot,ls as kt,mI as At,mL as jt,ms as Mt,nI as Nt,nL as Pt,oI as Ft,oL as It,pG as Lt,pI as Rt,pL as j,ps as zt,qI as Bt,qL as Vt,rI as Ht,rL as M,sI as Ut,sL as N,t as P,tL as Wt,uI as Gt,uL as Kt,us as qt,vI as Jt,vL as Yt,vr as Xt,vs as Zt,wI as Qt,wL as $t,wr as en,ws as tn,xI as nn,xL as rn,xd as an,xr as on,xs as sn,yI as cn,yL as ln,yQ as F,yd as un,yr as dn,ys as fn,zI as pn,zL as mn,zj as hn,zt as gn}from"./api-CWqdeSbN.js";import{a as _n,c as vn}from"./FieldLabel-imj_Z0rZ.js";import{t as yn}from"./checkbox-DPxJTQjc.js";import{a as I,i as L,n as R,r as z,t as B}from"./select-CjcMQhwm.js";import{n as bn,r as xn,t as Sn}from"./popover-C-Y_Yoco.js";import{t as V}from"./button-C_rIPtCv.js";import{t as H}from"./input-CSZu-bVE.js";import"./convexApi-G20_TNBS.js";import{r as U}from"./toast-C_YfUacM.js";import{t as W}from"./badge-ChMMFtuW.js";import{a as G,n as K,o as q,r as Cn,t as wn}from"./dialog-CPAskUwF.js";import{n as Tn}from"./ConfirmDialog-B7k0wvSi.js";import{t as En}from"./EntitySheet-DRzkWKlH.js";import{a as Dn}from"./groupManageView-DC3eSLA1.js";import{t as On}from"./DataTableShell-DvtkASQG.js";import{InstanceConfigDialog as kn}from"./BridgeTab-Bnu9R5N4.js";var J=t(e(),1),Y=[`conversational`,`documentary`,`summarizer`,`curator`],An=new Set(Y),jn=`conversational`;function Mn(e){let t=new Set((e??[]).filter(e=>An.has(e)));return t.size===0?[jn]:Y.filter(e=>t.has(e))}var X=n(),Z={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,participantIdentity:`owner`,managePermissionModes:!1,systemIdentity:``,streamTransport:_n,widgetsEnabled:!0,widgetPromptConfirm:!1},Nn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Pn(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,authMode:e.authMode??`token`,personScopes:e.personScopes??`capped`,identitySource:e.identitySource??`canonical`,participantIdentity:e.participantIdentity??`owner`,managePermissionModes:e.managePermissionModes===!0,systemIdentity:e.systemIdentity??``,streamTransport:e.streamTransport??`reactive`,widgetsEnabled:e.config?.widgetsEnabled!==!1,widgetPromptConfirm:e.config?.widgetPromptConfirm===!0}}function Fn(){let e=A(P.admin.listInstances,{}),t=A(P.agents.listAllInstanceAgents,{}),n=F(P.admin.upsertInstance),r=F(P.widgets.setInstanceWidgets),i=F(P.admin.deleteInstance),o=U(),[l,p]=(0,J.useState)(!1),[h,g]=(0,J.useState)(Z),[v,y]=(0,J.useState)(null),[b,S]=(0,J.useState)(null),[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(null);async function O(){try{let t=await n({instanceId:T??void 0,name:h.name,gatewayUrl:h.gatewayUrl,bridgeUrl:h.bridgeUrl||void 0,displayName:h.displayName||void 0,kind:h.kind,transport:h.kind===`hermes`?h.transport:void 0,gatewayVersion:h.gatewayVersion||void 0,gatewayHttpUrl:h.gatewayHttpUrl||void 0,...h.kind===`openclaw`?{authMode:h.authMode,personScopes:h.personScopes,identitySource:h.identitySource,participantIdentity:h.participantIdentity,managePermissionModes:h.managePermissionModes,systemIdentity:h.systemIdentity||void 0}:{},streamTransport:h.streamTransport}),i=T===null?null:e?.find(e=>e._id===T),a=i?.config?.widgetsEnabled!==!1,o=i?.config?.widgetPromptConfirm===!0;h.kind===`openclaw`&&(h.widgetsEnabled!==a||h.widgetPromptConfirm!==o)&&await r({instanceId:t,enabled:h.widgetsEnabled,promptConfirm:h.widgetPromptConfirm}),g(Z),E(null),p(!1)}catch(e){o.error(Ge(),e)}}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[ae(),(0,X.jsx)(`strong`,{children:Vt()}),oe()]}),(0,X.jsx)(On,{title:x(),rows:e,addLabel:Be(),onAdd:()=>{E(null),g(Z),p(!0)},emptyHint:Pe(),columns:[{header:te(),cell:e=>e.name,sort:e=>e.name},{header:Le(),cell:e=>(0,X.jsx)(W,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:s(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:mn(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:qe(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,X.jsxs)(W,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?Dt():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:ee(),onSelect:()=>{E(e._id),g(Pn(e)),p(!0)}},{label:Ue(),onSelect:()=>y(e.name)},{label:tt(),onSelect:()=>w(e)},{label:xe(),onSelect:()=>S(e)},{label:D(),variant:`destructive`,onSelect:()=>void i({instanceId:e._id})}],bulkActions:[{label:D(),variant:`destructive`,onSelect:e=>e.forEach(e=>void i({instanceId:e}))}]}),(0,X.jsx)(En,{open:l,onOpenChange:p,title:T?_e():re(),description:ce(),canSubmit:!!(h.name&&h.gatewayUrl),onSubmit:O,submitLabel:wt(),children:(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsxs)($,{label:a(),children:[(0,X.jsx)(H,{value:h.name,disabled:T!==null,onChange:e=>g({...h,name:e.target.value})}),T?(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:de()}):null]}),(0,X.jsx)($,{label:Et(),children:(0,X.jsxs)(B,{value:h.kind,onValueChange:e=>g({...h,kind:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`openclaw`,children:`OpenClaw`}),(0,X.jsx)(z,{value:`hermes`,children:`Hermes`})]})]})}),h.kind===`hermes`?(0,X.jsx)($,{label:an(),children:(0,X.jsxs)(B,{value:h.transport,onValueChange:e=>g({...h,transport:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`ws`,children:nt()}),(0,X.jsx)(z,{value:`rest`,children:un()})]})]})}):null,(0,X.jsx)($,{label:me(),children:(0,X.jsx)(H,{value:h.gatewayUrl,onChange:e=>g({...h,gatewayUrl:e.target.value})})}),(0,X.jsx)($,{label:m(),children:(0,X.jsx)(H,{value:h.bridgeUrl,placeholder:_(),onChange:e=>g({...h,bridgeUrl:e.target.value})})}),(0,X.jsx)($,{label:ke(),children:(0,X.jsx)(H,{value:h.displayName,onChange:e=>g({...h,displayName:e.target.value})})}),(0,X.jsxs)($,{label:hn(),children:[(0,X.jsxs)(B,{value:h.streamTransport,onValueChange:e=>g({...h,streamTransport:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsx)(R,{children:vn.map(e=>(0,X.jsx)(z,{value:e,children:e},e))})]}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Se()})]}),(0,X.jsx)($,{label:$t(),children:(0,X.jsx)(H,{value:h.gatewayVersion,placeholder:u(),onChange:e=>g({...h,gatewayVersion:e.target.value})})}),h.kind===`openclaw`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)($,{label:xt(),children:[(0,X.jsxs)(B,{value:h.authMode,onValueChange:e=>g({...h,authMode:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`token`,children:Mt()}),(0,X.jsx)(z,{value:`trusted-proxy`,children:zt()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.authMode===`trusted-proxy`?lt():mt()})]}),h.authMode===`trusted-proxy`?(0,X.jsxs)($,{label:Me(),children:[(0,X.jsxs)(B,{value:h.personScopes,onValueChange:e=>g({...h,personScopes:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`capped`,children:tn()}),(0,X.jsx)(z,{value:`full`,children:f()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.personScopes===`full`?sn():De()})]}):null,h.authMode===`trusted-proxy`?(0,X.jsxs)($,{label:it(),children:[(0,X.jsxs)(B,{value:h.identitySource,onValueChange:e=>g({...h,identitySource:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`canonical`,children:fn()}),(0,X.jsx)(z,{value:`email`,children:Zt()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.identitySource===`email`?vt():Ze()})]}):null,h.authMode===`trusted-proxy`?(0,X.jsxs)($,{label:je(),children:[(0,X.jsxs)(B,{value:h.participantIdentity,onValueChange:e=>g({...h,participantIdentity:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`owner`,children:en()}),(0,X.jsx)(z,{value:`self`,children:d()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.participantIdentity===`self`?_t():Ee()})]}):null,h.kind===`openclaw`?(0,X.jsxs)($,{label:on(),children:[(0,X.jsxs)(B,{value:h.managePermissionModes?`on`:`off`,onValueChange:e=>g({...h,managePermissionModes:e===`on`}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`off`,children:rt()}),(0,X.jsx)(z,{value:`on`,children:dn()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.managePermissionModes?Xe():Xt()})]}):null,h.kind===`openclaw`?(0,X.jsxs)($,{label:Ve(),children:[(0,X.jsxs)(B,{value:h.widgetsEnabled?`on`:`off`,onValueChange:e=>g({...h,widgetsEnabled:e===`on`}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`on`,children:Fe()}),(0,X.jsx)(z,{value:`off`,children:ne()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.widgetsEnabled?Re():c()})]}):null,h.kind===`openclaw`&&h.widgetsEnabled?(0,X.jsxs)($,{label:gn(),children:[(0,X.jsxs)(B,{value:h.widgetPromptConfirm?`on`:`off`,onValueChange:e=>g({...h,widgetPromptConfirm:e===`on`}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`off`,children:Ce()}),(0,X.jsx)(z,{value:`on`,children:se()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:ie()})]}):null,h.authMode===`trusted-proxy`?(0,X.jsx)($,{label:qt(),children:(0,X.jsx)(H,{value:h.systemIdentity,placeholder:kt(),onChange:e=>g({...h,systemIdentity:e.target.value})})}):null]}):null,(0,X.jsx)($,{label:Te(),children:(0,X.jsx)(H,{value:h.gatewayHttpUrl,placeholder:rn(),onChange:e=>g({...h,gatewayHttpUrl:e.target.value})})})]})}),(0,X.jsx)(Wn,{instanceName:v,open:v!==null,onOpenChange:e=>{e||y(null)}}),b?(0,X.jsx)(kn,{instance:b,onClose:()=>S(null)},b._id):null,C?(0,X.jsx)(In,{instance:C,onClose:()=>w(null)},C._id):null]})}function In({instance:e,onClose:t}){let n=A(P.instanceSecrets.listInstanceSecretStatus,{}),r=Nn[e.kind??`openclaw`],i=(0,J.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,X.jsx)(wn,{open:!0,onOpenChange:e=>!e&&t(),children:(0,X.jsxs)(K,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(q,{children:ln({instance:e.displayName??e.name})}),(0,X.jsx)(Cn,{children:Yt()})]}),(0,X.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,X.jsx)(zn,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,X.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,X.jsx)(Rn,{instance:e})}),(0,X.jsx)(Ln,{instance:e})]})})}function Ln({instance:e}){let t=k(P.instanceSync.forceInstanceSync),n=U(),[i,a]=(0,J.useState)(!1);async function o(){if(!i){a(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(ye());break;case`no_agents`:n.success(He());break;case`no_bridge_url`:n.error(We());break;case`deploy_misconfigured`:n.error(w());break;case`unauthorized`:n.error(T());break;case`not_served`:n.error(b());break;default:n.error(Bt());break}}catch(e){n.error(Ke(),e)}finally{a(!1)}}}return(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}),(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsx)(V,{size:`sm`,variant:`outline`,onClick:()=>void o(),disabled:i,children:i?r():ut()})})]})}function Rn({instance:e}){let t=A(P.bridgeAuth.listBridgeAuthStatus,{}),n=k(P.bridgeAuth.mintBridgeSecret),r=F(P.bridgeAuth.revokeBridgeSecret),i=U(),[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),p=f!==void 0;async function m(){if(!a){s(!0);try{let t=await n({instanceId:e._id});l(t.plaintext),d(!1)}catch(e){i.error(E(),e)}finally{s(!1)}}}async function h(){if(!a){s(!0);try{await r({instanceId:e._id}),l(null),i.success(be())}catch(e){i.error(E(),e)}finally{s(!1)}}}async function g(){if(c)try{await navigator.clipboard.writeText(c),d(!0)}catch{}}return(0,X.jsxs)($,{label:Ne(),children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:S()}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(W,{variant:p?`outline`:`secondary`,children:p?`${jt()} · ${f.prefix}…${f.lastFour}`:j()}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(V,{size:`sm`,onClick:()=>void m(),disabled:a,children:p?o():Ie()}),p?(0,X.jsx)(V,{size:`sm`,variant:`destructive`,onClick:()=>void h(),disabled:a,children:pn()}):null]})]}),c?(0,X.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,X.jsx)(`p`,{className:`oc-sa__minted-warning`,children:C()}),(0,X.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,X.jsx)(`code`,{className:`oc-sa__minted-plain`,children:c}),(0,X.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>void g(),children:u?Lt():dt()})]}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),d(!1)},children:y()})]}):null]})}function zn({instanceId:e,field:t,updatedAt:n}){let r=k(P.instanceSecrets.setInstanceSecret),i=F(P.instanceSecrets.clearInstanceSecret),a=k(P.deviceIdentity.generateDeviceIdentity),o=U(),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(!1),h=n!==null,g=t===`deviceIdentity`,_=t===`token`?Ye():t===`deviceIdentity`?gt():bt();async function v(){if(!(!s.trim()||l)){u(!0);try{await r({instanceId:e,field:t,plaintext:s}),c(``),f(null),m(!1),o.success(ot())}catch(e){o.error(N(),e)}finally{u(!1)}}}async function ee(){if(!l){u(!0);try{await i({instanceId:e,field:t}),f(null),m(!1),o.success(It())}catch(e){o.error(N(),e)}finally{u(!1)}}}async function b(){if(!l){u(!0);try{let t=await a({instanceId:e});f(t),m(!1),o.success(M())}catch(e){o.error(Wt(),e)}finally{u(!1)}}}let x=d?`openclaw devices approve ${d.id}`:``;async function S(){if(x)try{await navigator.clipboard.writeText(x),m(!0)}catch{}}return(0,X.jsxs)($,{label:_,children:[g?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:Ct()}):null,(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(W,{variant:h?`outline`:`secondary`,children:h?jt():j()}),(0,X.jsx)(H,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:h?ct():pt(),onChange:e=>c(e.target.value)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(V,{size:`sm`,onClick:()=>void v(),disabled:l||s.trim().length===0,children:Kt()}),g?(0,X.jsx)(V,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:l,children:$e()}):null,h?(0,X.jsx)(V,{size:`sm`,variant:`destructive`,onClick:()=>void ee(),disabled:l,children:Ot()}):null]})]}),d?(0,X.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:M()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:Pt()}),(0,X.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,X.jsx)(`code`,{className:`oc-sa__minted-plain`,children:x}),(0,X.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:p?Lt():dt()})]}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>{f(null),m(!1)},children:y()})]}):null]})}var Bn={conversational:Qt,documentary:we,summarizer:he,curator:v},Vn={conversational:l,documentary:nn,summarizer:h,curator:Ae},Hn=e=>(Bn[e]??(()=>e))(),Q=e=>(Vn[e]??(()=>``))();function Un({agentId:e,types:t,onToggle:n}){return(0,X.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,X.jsx)(`span`,{className:`oc-agentcard__types-label`,children:pe()}),t.map(e=>(0,X.jsx)(W,{variant:`secondary`,className:`oc-agenttype__chip`,title:Q(e),children:(0,X.jsx)(`span`,{className:`oc-agenttype__label`,children:Hn(e)})},e)),(0,X.jsxs)(Sn,{children:[(0,X.jsx)(xn,{asChild:!0,children:(0,X.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:p()})}),(0,X.jsxs)(bn,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,X.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:g()}),(0,X.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Oe()}),(0,X.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:Y.map(r=>{let i=`agtype-${e}-${r}`;return(0,X.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,X.jsx)(yn,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,X.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,X.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Hn(r)}),(0,X.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Q(r)})]})]},r)})})]})]})]})}function Wn({instanceName:e,open:t,onOpenChange:n}){let r=A(P.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=F(P.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=F(P.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=F(P.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Mn(r);e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),s=F(P.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),c=F(P.agents.removeInstanceAgent),l=F(P.agents.setAgentReservation),u=A(P.groups.listGroupLabels,t?{}:`skip`),d=Tn(),f=U();async function p(t,n){if(e&&await d({title:Qe({name:n}),description:St(),confirmLabel:Ft()}))try{await l({instanceName:e,agentId:t,groupId:null})}catch(e){f.error(O(),Dn(e))}}async function m(t,n,r){if(!e)return;let i=(u??[]).find(e=>e._id===r)?.name??`?`;if(await d({title:ve({name:n,group:i}),description:fe({group:i}),confirmLabel:le()}))try{await l({instanceName:e,agentId:t,groupId:r})}catch(e){f.error(O(),Dn(e))}}async function h(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){f.error(O(),e)}}async function g(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){f.error(O(),e)}}async function _(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){f.error(O(),e)}}async function v(t,n){if(e&&await d({title:Jt({name:n}),description:Je(),confirmLabel:ht(),destructive:!0}))try{await c({instanceName:e,agentId:t}),f.success(yt())}catch(e){f.error(O(),e)}}return(0,X.jsx)(wn,{open:t,onOpenChange:n,children:(0,X.jsxs)(K,{className:`oc-access`,children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(q,{children:ge({name:e??``})}),(0,X.jsx)(Cn,{children:ue()})]}),r===void 0?(0,X.jsx)(`p`,{className:`oc-access__hint`,children:At()}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?Rt():r.discovery.lastPollOk?ft():st({error:r.discovery.error??`?`})}),r.agents.length===0?(0,X.jsx)(`p`,{className:`oc-access__hint`,children:Gt()}):(0,X.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,i=r.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,X.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,X.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,X.jsx)(yn,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void h(t.agentId,e===!0)}),(0,X.jsxs)(`div`,{className:`oc-agentcard__main`,children:[(0,X.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,X.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,t.reserved?(0,X.jsx)(W,{variant:`outline`,children:t.reserved.groupName===null?Ut():at({group:t.reserved.groupName})}):null,n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:Nt()}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void v(t.agentId,a),children:cn()})]}):i?(0,X.jsx)(W,{variant:`default`,children:Dt()}):(0,X.jsx)(V,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled||t.reserved!==null,onClick:()=>void g(t.agentId),children:et()})]})]}),t.reserved?(0,X.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,X.jsx)(V,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>void p(t.agentId,a),children:Ft()}),(0,X.jsxs)(B,{value:``,onValueChange:e=>void m(t.agentId,a,e),children:[(0,X.jsx)(L,{size:`sm`,className:`h-7`,children:(0,X.jsx)(I,{placeholder:Ht()})}),(0,X.jsx)(R,{children:(u??[]).filter(e=>e._id!==t.reserved?.groupId).map(e=>(0,X.jsx)(z,{value:e._id,children:e.name},e._id))})]})]}):null,t.enabled?(0,X.jsx)(Un,{agentId:t.agentId,types:o,onToggle:e=>void _(t.agentId,e,o)}):null,t.enabled?(0,X.jsx)(Gn,{value:t.description??``,onSave:async n=>{if(e)try{await s({instanceName:e,agentId:t.agentId,description:n})}catch(e){f.error(O(),e)}}}):null]},t.agentId)})})]})]})})}function Gn({value:e,onSave:t}){let[n,r]=(0,J.useState)(e);(0,J.useEffect)(()=>{r(e)},[e]);let a=()=>{n.trim()!==e.trim()&&t(n)};return(0,X.jsx)(H,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:i(),"aria-label":Tt(),onChange:e=>r(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),a())}})}function $({label:e,children:t}){return(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Fn as InstancesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$I as r,AI as i,AL as a,BI as o,BL as s,Bt as c,CI as l,CL as u,Cr as d,Cs as f,DI as p,DL as m,Dh as h,EI as g,EL as _,Eh as v,FI as y,FL as ee,GI as b,GL as x,HI as S,HL as te,Ht as ne,II as C,IL as re,It as ie,JI as w,JL as ae,KI as T,KL as oe,LI as E,LL as D,Lt as se,MI as O,ML as ce,Mb as le,NI as ue,NL as de,Nb as fe,OI as pe,OL as me,Oh as he,PI as ge,PL as _e,Pb as ve,QI as ye,RI as be,RL as xe,Rj as Se,Rt as Ce,SI as we,SL as Te,Sr as Ee,Ss as De,TI as Oe,TL as ke,Th as Ae,Tr as je,Ts as Me,UI as Ne,UL as Pe,Ut as Fe,VI as Ie,VL as Le,Vt as Re,WI as ze,WL as Be,Wt as Ve,XI as He,XL as Ue,YI as We,YL as Ge,ZI as Ke,ZL as qe,_I as Je,_L as Ye,_Q as k,_r as Xe,_s as Ze,aI as Qe,aL as $e,bI as et,bL as tt,bQ as A,bd as nt,br as rt,bs as it,cI as at,cL as ot,dI as st,dL as ct,ds as lt,eL as ut,fG as dt,fI as ft,fL as pt,fs as mt,gI as ht,gL as gt,gr as _t,gs as vt,hI as yt,hL as bt,hs as xt,iI as St,iL as Ct,jL as wt,kI as Tt,kL as Et,lI as Dt,lL as Ot,ls as kt,mI as At,mL as jt,ms as Mt,nI as Nt,nL as Pt,oI as Ft,oL as It,pG as Lt,pI as Rt,pL as j,ps as zt,qI as Bt,qL as Vt,rI as Ht,rL as M,sI as Ut,sL as N,t as P,tL as Wt,uI as Gt,uL as Kt,us as qt,vI as Jt,vL as Yt,vr as Xt,vs as Zt,wI as Qt,wL as $t,wr as en,ws as tn,xI as nn,xL as rn,xd as an,xr as on,xs as sn,yI as cn,yL as ln,yQ as F,yd as un,yr as dn,ys as fn,zI as pn,zL as mn,zj as hn,zt as gn}from"./api-D64JTta1.js";import{a as _n,c as vn}from"./FieldLabel-Ce8urE01.js";import{t as yn}from"./checkbox-BuTZzFvU.js";import{a as I,i as L,n as R,r as z,t as B}from"./select-wXM6h61N.js";import{n as bn,r as xn,t as Sn}from"./popover-UJtu3EZ6.js";import{t as V}from"./button-DeHzYOzP.js";import{t as H}from"./input-CZ0jp9Rx.js";import"./convexApi-DxRiI80M.js";import{r as U}from"./toast-DtA87VYn.js";import{t as W}from"./badge-DwWXPxwl.js";import{a as G,n as K,o as q,r as Cn,t as wn}from"./dialog-awuZdW9M.js";import{n as Tn}from"./ConfirmDialog-Bfi4_Ti8.js";import{t as En}from"./EntitySheet-D8Vdib4B.js";import{a as Dn}from"./groupManageView-CKEYC6zY.js";import{t as On}from"./DataTableShell-1ZsZ0a2J.js";import{InstanceConfigDialog as kn}from"./BridgeTab-Cv2Co6h7.js";var J=t(e(),1),Y=[`conversational`,`documentary`,`summarizer`,`curator`],An=new Set(Y),jn=`conversational`;function Mn(e){let t=new Set((e??[]).filter(e=>An.has(e)));return t.size===0?[jn]:Y.filter(e=>t.has(e))}var X=n(),Z={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,participantIdentity:`owner`,managePermissionModes:!1,systemIdentity:``,streamTransport:_n,widgetsEnabled:!0,widgetPromptConfirm:!1},Nn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Pn(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,authMode:e.authMode??`token`,personScopes:e.personScopes??`capped`,identitySource:e.identitySource??`canonical`,participantIdentity:e.participantIdentity??`owner`,managePermissionModes:e.managePermissionModes===!0,systemIdentity:e.systemIdentity??``,streamTransport:e.streamTransport??`reactive`,widgetsEnabled:e.config?.widgetsEnabled!==!1,widgetPromptConfirm:e.config?.widgetPromptConfirm===!0}}function Fn(){let e=A(P.admin.listInstances,{}),t=A(P.agents.listAllInstanceAgents,{}),n=F(P.admin.upsertInstance),r=F(P.widgets.setInstanceWidgets),i=F(P.admin.deleteInstance),o=U(),[l,p]=(0,J.useState)(!1),[h,g]=(0,J.useState)(Z),[v,y]=(0,J.useState)(null),[b,S]=(0,J.useState)(null),[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(null);async function O(){try{let t=await n({instanceId:T??void 0,name:h.name,gatewayUrl:h.gatewayUrl,bridgeUrl:h.bridgeUrl||void 0,displayName:h.displayName||void 0,kind:h.kind,transport:h.kind===`hermes`?h.transport:void 0,gatewayVersion:h.gatewayVersion||void 0,gatewayHttpUrl:h.gatewayHttpUrl||void 0,...h.kind===`openclaw`?{authMode:h.authMode,personScopes:h.personScopes,identitySource:h.identitySource,participantIdentity:h.participantIdentity,managePermissionModes:h.managePermissionModes,systemIdentity:h.systemIdentity||void 0}:{},streamTransport:h.streamTransport}),i=T===null?null:e?.find(e=>e._id===T),a=i?.config?.widgetsEnabled!==!1,o=i?.config?.widgetPromptConfirm===!0;h.kind===`openclaw`&&(h.widgetsEnabled!==a||h.widgetPromptConfirm!==o)&&await r({instanceId:t,enabled:h.widgetsEnabled,promptConfirm:h.widgetPromptConfirm}),g(Z),E(null),p(!1)}catch(e){o.error(Ge(),e)}}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[ae(),(0,X.jsx)(`strong`,{children:Vt()}),oe()]}),(0,X.jsx)(On,{title:x(),rows:e,addLabel:Be(),onAdd:()=>{E(null),g(Z),p(!0)},emptyHint:Pe(),columns:[{header:te(),cell:e=>e.name,sort:e=>e.name},{header:Le(),cell:e=>(0,X.jsx)(W,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:s(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:mn(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:qe(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,X.jsxs)(W,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?Dt():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:ee(),onSelect:()=>{E(e._id),g(Pn(e)),p(!0)}},{label:Ue(),onSelect:()=>y(e.name)},{label:tt(),onSelect:()=>w(e)},{label:xe(),onSelect:()=>S(e)},{label:D(),variant:`destructive`,onSelect:()=>void i({instanceId:e._id})}],bulkActions:[{label:D(),variant:`destructive`,onSelect:e=>e.forEach(e=>void i({instanceId:e}))}]}),(0,X.jsx)(En,{open:l,onOpenChange:p,title:T?_e():re(),description:ce(),canSubmit:!!(h.name&&h.gatewayUrl),onSubmit:O,submitLabel:wt(),children:(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsxs)($,{label:a(),children:[(0,X.jsx)(H,{value:h.name,disabled:T!==null,onChange:e=>g({...h,name:e.target.value})}),T?(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:de()}):null]}),(0,X.jsx)($,{label:Et(),children:(0,X.jsxs)(B,{value:h.kind,onValueChange:e=>g({...h,kind:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`openclaw`,children:`OpenClaw`}),(0,X.jsx)(z,{value:`hermes`,children:`Hermes`})]})]})}),h.kind===`hermes`?(0,X.jsx)($,{label:an(),children:(0,X.jsxs)(B,{value:h.transport,onValueChange:e=>g({...h,transport:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`ws`,children:nt()}),(0,X.jsx)(z,{value:`rest`,children:un()})]})]})}):null,(0,X.jsx)($,{label:me(),children:(0,X.jsx)(H,{value:h.gatewayUrl,onChange:e=>g({...h,gatewayUrl:e.target.value})})}),(0,X.jsx)($,{label:m(),children:(0,X.jsx)(H,{value:h.bridgeUrl,placeholder:_(),onChange:e=>g({...h,bridgeUrl:e.target.value})})}),(0,X.jsx)($,{label:ke(),children:(0,X.jsx)(H,{value:h.displayName,onChange:e=>g({...h,displayName:e.target.value})})}),(0,X.jsxs)($,{label:hn(),children:[(0,X.jsxs)(B,{value:h.streamTransport,onValueChange:e=>g({...h,streamTransport:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsx)(R,{children:vn.map(e=>(0,X.jsx)(z,{value:e,children:e},e))})]}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Se()})]}),(0,X.jsx)($,{label:$t(),children:(0,X.jsx)(H,{value:h.gatewayVersion,placeholder:u(),onChange:e=>g({...h,gatewayVersion:e.target.value})})}),h.kind===`openclaw`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)($,{label:xt(),children:[(0,X.jsxs)(B,{value:h.authMode,onValueChange:e=>g({...h,authMode:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`token`,children:Mt()}),(0,X.jsx)(z,{value:`trusted-proxy`,children:zt()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.authMode===`trusted-proxy`?lt():mt()})]}),h.authMode===`trusted-proxy`?(0,X.jsxs)($,{label:Me(),children:[(0,X.jsxs)(B,{value:h.personScopes,onValueChange:e=>g({...h,personScopes:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`capped`,children:tn()}),(0,X.jsx)(z,{value:`full`,children:f()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.personScopes===`full`?sn():De()})]}):null,h.authMode===`trusted-proxy`?(0,X.jsxs)($,{label:it(),children:[(0,X.jsxs)(B,{value:h.identitySource,onValueChange:e=>g({...h,identitySource:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`canonical`,children:fn()}),(0,X.jsx)(z,{value:`email`,children:Zt()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.identitySource===`email`?vt():Ze()})]}):null,h.authMode===`trusted-proxy`?(0,X.jsxs)($,{label:je(),children:[(0,X.jsxs)(B,{value:h.participantIdentity,onValueChange:e=>g({...h,participantIdentity:e}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`owner`,children:en()}),(0,X.jsx)(z,{value:`self`,children:d()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.participantIdentity===`self`?_t():Ee()})]}):null,h.kind===`openclaw`?(0,X.jsxs)($,{label:on(),children:[(0,X.jsxs)(B,{value:h.managePermissionModes?`on`:`off`,onValueChange:e=>g({...h,managePermissionModes:e===`on`}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`off`,children:rt()}),(0,X.jsx)(z,{value:`on`,children:dn()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.managePermissionModes?Xe():Xt()})]}):null,h.kind===`openclaw`?(0,X.jsxs)($,{label:Ve(),children:[(0,X.jsxs)(B,{value:h.widgetsEnabled?`on`:`off`,onValueChange:e=>g({...h,widgetsEnabled:e===`on`}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`on`,children:Fe()}),(0,X.jsx)(z,{value:`off`,children:ne()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:h.widgetsEnabled?Re():c()})]}):null,h.kind===`openclaw`&&h.widgetsEnabled?(0,X.jsxs)($,{label:gn(),children:[(0,X.jsxs)(B,{value:h.widgetPromptConfirm?`on`:`off`,onValueChange:e=>g({...h,widgetPromptConfirm:e===`on`}),children:[(0,X.jsx)(L,{size:`sm`,className:`w-full`,children:(0,X.jsx)(I,{})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:`off`,children:Ce()}),(0,X.jsx)(z,{value:`on`,children:se()})]})]}),(0,X.jsx)(`p`,{className:`oc-field__hint`,children:ie()})]}):null,h.authMode===`trusted-proxy`?(0,X.jsx)($,{label:qt(),children:(0,X.jsx)(H,{value:h.systemIdentity,placeholder:kt(),onChange:e=>g({...h,systemIdentity:e.target.value})})}):null]}):null,(0,X.jsx)($,{label:Te(),children:(0,X.jsx)(H,{value:h.gatewayHttpUrl,placeholder:rn(),onChange:e=>g({...h,gatewayHttpUrl:e.target.value})})})]})}),(0,X.jsx)(Wn,{instanceName:v,open:v!==null,onOpenChange:e=>{e||y(null)}}),b?(0,X.jsx)(kn,{instance:b,onClose:()=>S(null)},b._id):null,C?(0,X.jsx)(In,{instance:C,onClose:()=>w(null)},C._id):null]})}function In({instance:e,onClose:t}){let n=A(P.instanceSecrets.listInstanceSecretStatus,{}),r=Nn[e.kind??`openclaw`],i=(0,J.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,X.jsx)(wn,{open:!0,onOpenChange:e=>!e&&t(),children:(0,X.jsxs)(K,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(q,{children:ln({instance:e.displayName??e.name})}),(0,X.jsx)(Cn,{children:Yt()})]}),(0,X.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,X.jsx)(zn,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,X.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,X.jsx)(Rn,{instance:e})}),(0,X.jsx)(Ln,{instance:e})]})})}function Ln({instance:e}){let t=k(P.instanceSync.forceInstanceSync),n=U(),[i,a]=(0,J.useState)(!1);async function o(){if(!i){a(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(ye());break;case`no_agents`:n.success(He());break;case`no_bridge_url`:n.error(We());break;case`deploy_misconfigured`:n.error(w());break;case`unauthorized`:n.error(T());break;case`not_served`:n.error(b());break;default:n.error(Bt());break}}catch(e){n.error(Ke(),e)}finally{a(!1)}}}return(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}),(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsx)(V,{size:`sm`,variant:`outline`,onClick:()=>void o(),disabled:i,children:i?r():ut()})})]})}function Rn({instance:e}){let t=A(P.bridgeAuth.listBridgeAuthStatus,{}),n=k(P.bridgeAuth.mintBridgeSecret),r=F(P.bridgeAuth.revokeBridgeSecret),i=U(),[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),p=f!==void 0;async function m(){if(!a){s(!0);try{let t=await n({instanceId:e._id});l(t.plaintext),d(!1)}catch(e){i.error(E(),e)}finally{s(!1)}}}async function h(){if(!a){s(!0);try{await r({instanceId:e._id}),l(null),i.success(be())}catch(e){i.error(E(),e)}finally{s(!1)}}}async function g(){if(c)try{await navigator.clipboard.writeText(c),d(!0)}catch{}}return(0,X.jsxs)($,{label:Ne(),children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:S()}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(W,{variant:p?`outline`:`secondary`,children:p?`${jt()} · ${f.prefix}…${f.lastFour}`:j()}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(V,{size:`sm`,onClick:()=>void m(),disabled:a,children:p?o():Ie()}),p?(0,X.jsx)(V,{size:`sm`,variant:`destructive`,onClick:()=>void h(),disabled:a,children:pn()}):null]})]}),c?(0,X.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,X.jsx)(`p`,{className:`oc-sa__minted-warning`,children:C()}),(0,X.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,X.jsx)(`code`,{className:`oc-sa__minted-plain`,children:c}),(0,X.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>void g(),children:u?Lt():dt()})]}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),d(!1)},children:y()})]}):null]})}function zn({instanceId:e,field:t,updatedAt:n}){let r=k(P.instanceSecrets.setInstanceSecret),i=F(P.instanceSecrets.clearInstanceSecret),a=k(P.deviceIdentity.generateDeviceIdentity),o=U(),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(!1),h=n!==null,g=t===`deviceIdentity`,_=t===`token`?Ye():t===`deviceIdentity`?gt():bt();async function v(){if(!(!s.trim()||l)){u(!0);try{await r({instanceId:e,field:t,plaintext:s}),c(``),f(null),m(!1),o.success(ot())}catch(e){o.error(N(),e)}finally{u(!1)}}}async function ee(){if(!l){u(!0);try{await i({instanceId:e,field:t}),f(null),m(!1),o.success(It())}catch(e){o.error(N(),e)}finally{u(!1)}}}async function b(){if(!l){u(!0);try{let t=await a({instanceId:e});f(t),m(!1),o.success(M())}catch(e){o.error(Wt(),e)}finally{u(!1)}}}let x=d?`openclaw devices approve ${d.id}`:``;async function S(){if(x)try{await navigator.clipboard.writeText(x),m(!0)}catch{}}return(0,X.jsxs)($,{label:_,children:[g?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:Ct()}):null,(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(W,{variant:h?`outline`:`secondary`,children:h?jt():j()}),(0,X.jsx)(H,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:h?ct():pt(),onChange:e=>c(e.target.value)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(V,{size:`sm`,onClick:()=>void v(),disabled:l||s.trim().length===0,children:Kt()}),g?(0,X.jsx)(V,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:l,children:$e()}):null,h?(0,X.jsx)(V,{size:`sm`,variant:`destructive`,onClick:()=>void ee(),disabled:l,children:Ot()}):null]})]}),d?(0,X.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:M()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:Pt()}),(0,X.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,X.jsx)(`code`,{className:`oc-sa__minted-plain`,children:x}),(0,X.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:p?Lt():dt()})]}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>{f(null),m(!1)},children:y()})]}):null]})}var Bn={conversational:Qt,documentary:we,summarizer:he,curator:v},Vn={conversational:l,documentary:nn,summarizer:h,curator:Ae},Hn=e=>(Bn[e]??(()=>e))(),Q=e=>(Vn[e]??(()=>``))();function Un({agentId:e,types:t,onToggle:n}){return(0,X.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,X.jsx)(`span`,{className:`oc-agentcard__types-label`,children:pe()}),t.map(e=>(0,X.jsx)(W,{variant:`secondary`,className:`oc-agenttype__chip`,title:Q(e),children:(0,X.jsx)(`span`,{className:`oc-agenttype__label`,children:Hn(e)})},e)),(0,X.jsxs)(Sn,{children:[(0,X.jsx)(xn,{asChild:!0,children:(0,X.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:p()})}),(0,X.jsxs)(bn,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,X.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:g()}),(0,X.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Oe()}),(0,X.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:Y.map(r=>{let i=`agtype-${e}-${r}`;return(0,X.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,X.jsx)(yn,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,X.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,X.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Hn(r)}),(0,X.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Q(r)})]})]},r)})})]})]})]})}function Wn({instanceName:e,open:t,onOpenChange:n}){let r=A(P.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=F(P.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=F(P.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=F(P.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Mn(r);e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),s=F(P.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),c=F(P.agents.removeInstanceAgent),l=F(P.agents.setAgentReservation),u=A(P.groups.listGroupLabels,t?{}:`skip`),d=Tn(),f=U();async function p(t,n){if(e&&await d({title:Qe({name:n}),description:St(),confirmLabel:Ft()}))try{await l({instanceName:e,agentId:t,groupId:null})}catch(e){f.error(O(),Dn(e))}}async function m(t,n,r){if(!e)return;let i=(u??[]).find(e=>e._id===r)?.name??`?`;if(await d({title:ve({name:n,group:i}),description:fe({group:i}),confirmLabel:le()}))try{await l({instanceName:e,agentId:t,groupId:r})}catch(e){f.error(O(),Dn(e))}}async function h(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){f.error(O(),e)}}async function g(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){f.error(O(),e)}}async function _(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){f.error(O(),e)}}async function v(t,n){if(e&&await d({title:Jt({name:n}),description:Je(),confirmLabel:ht(),destructive:!0}))try{await c({instanceName:e,agentId:t}),f.success(yt())}catch(e){f.error(O(),e)}}return(0,X.jsx)(wn,{open:t,onOpenChange:n,children:(0,X.jsxs)(K,{className:`oc-access`,children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(q,{children:ge({name:e??``})}),(0,X.jsx)(Cn,{children:ue()})]}),r===void 0?(0,X.jsx)(`p`,{className:`oc-access__hint`,children:At()}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?Rt():r.discovery.lastPollOk?ft():st({error:r.discovery.error??`?`})}),r.agents.length===0?(0,X.jsx)(`p`,{className:`oc-access__hint`,children:Gt()}):(0,X.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,i=r.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,X.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,X.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,X.jsx)(yn,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void h(t.agentId,e===!0)}),(0,X.jsxs)(`div`,{className:`oc-agentcard__main`,children:[(0,X.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,X.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,t.reserved?(0,X.jsx)(W,{variant:`outline`,children:t.reserved.groupName===null?Ut():at({group:t.reserved.groupName})}):null,n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:Nt()}),(0,X.jsx)(V,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void v(t.agentId,a),children:cn()})]}):i?(0,X.jsx)(W,{variant:`default`,children:Dt()}):(0,X.jsx)(V,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled||t.reserved!==null,onClick:()=>void g(t.agentId),children:et()})]})]}),t.reserved?(0,X.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,X.jsx)(V,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>void p(t.agentId,a),children:Ft()}),(0,X.jsxs)(B,{value:``,onValueChange:e=>void m(t.agentId,a,e),children:[(0,X.jsx)(L,{size:`sm`,className:`h-7`,children:(0,X.jsx)(I,{placeholder:Ht()})}),(0,X.jsx)(R,{children:(u??[]).filter(e=>e._id!==t.reserved?.groupId).map(e=>(0,X.jsx)(z,{value:e._id,children:e.name},e._id))})]})]}):null,t.enabled?(0,X.jsx)(Un,{agentId:t.agentId,types:o,onToggle:e=>void _(t.agentId,e,o)}):null,t.enabled?(0,X.jsx)(Gn,{value:t.description??``,onSave:async n=>{if(e)try{await s({instanceName:e,agentId:t.agentId,description:n})}catch(e){f.error(O(),e)}}}):null]},t.agentId)})})]})]})})}function Gn({value:e,onSave:t}){let[n,r]=(0,J.useState)(e);(0,J.useEffect)(()=>{r(e)},[e]);let a=()=>{n.trim()!==e.trim()&&t(n)};return(0,X.jsx)(H,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:i(),"aria-label":Tt(),onChange:e=>r(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),a())}})}function $({label:e,children:t}){return(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Fn as InstancesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Az as r,Bz as i,Fz as a,Gg as o,Hg as s,Hz as c,Iz as l,Jg as u,Kg as d,Lz as f,Mz as p,Nz as m,Pz as h,Rz as g,Ug as _,Vg as v,Vz as y,Wg as b,Yg as x,_Q as S,bQ as C,jz as w,kz as T,qg as E,t as D,yQ as O,zz as k}from"./api-CWqdeSbN.js";import{t as A}from"./checkbox-DPxJTQjc.js";import"./select-CjcMQhwm.js";import{t as j}from"./button-C_rIPtCv.js";import{t as M}from"./input-CSZu-bVE.js";import"./convexApi-G20_TNBS.js";import{t as N}from"./badge-ChMMFtuW.js";var P=t(e(),1),F=n();function I(){let e=C(D.integrations.status.status,{}),t=O(D.admin.setIntegrationConfig),[n,o]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&o(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:c()});let s=n,d=(e,t,n)=>o({...s,[e]:{...s[e],[t]:n}}),_=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[y(),` `,(0,F.jsx)(`strong`,{children:i()}),` `,k()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(N,{variant:`secondary`,children:g()}):(0,F.jsx)(N,{variant:`outline`,children:f()}):(0,F.jsx)(N,{variant:`outline`,children:l()}),note:a(),children:[(0,F.jsx)(R,{label:m(),children:(0,F.jsx)(M,{value:s.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>d(`langfuse`,`host`,e.target.value),onBlur:()=>_(`langfuse`,{host:s.langfuse.host??``})})}),(0,F.jsx)(z,{label:T(),checked:s.langfuse.enabled??!0,onChange:e=>{d(`langfuse`,`enabled`,e),_(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(N,{variant:`secondary`,children:g()}):(0,F.jsx)(N,{variant:`outline`,children:f()}):(0,F.jsx)(N,{variant:`outline`,children:l()}),note:h(),children:[(0,F.jsx)(R,{label:p(),children:(0,F.jsx)(M,{value:s.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>d(`opik`,`baseUrl`,e.target.value),onBlur:()=>_(`opik`,{baseUrl:s.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:w(),children:(0,F.jsx)(M,{value:s.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||r(),onChange:e=>d(`opik`,`workspace`,e.target.value),onBlur:()=>_(`opik`,{workspace:s.opik.workspace??``})})}),(0,F.jsx)(z,{label:T(),checked:s.opik.enabled??!0,onChange:e=>{d(`opik`,`enabled`,e),_(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(N,{variant:`secondary`,children:g()}):(0,F.jsx)(N,{variant:`outline`,children:f()}):(0,F.jsx)(N,{variant:`outline`,children:x()}),note:u(),children:[(0,F.jsx)(R,{label:E(),children:(0,F.jsx)(M,{value:s.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>d(`otlp`,`endpoint`,e.target.value),onBlur:()=>_(`otlp`,{endpoint:s.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:T(),checked:s.otlp.enabled??!0,onChange:e=>{d(`otlp`,`enabled`,e),_(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(A,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=S(D.integrations.otlpSecret.setOtlpHeaders),n=O(D.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[a,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),f=async()=>{u(!0),c(null);try{await t({headersJson:r}),i(``)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,F.jsxs)(R,{label:d(),children:[(0,F.jsx)(M,{value:r,placeholder:e?o():b(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(j,{size:`sm`,disabled:l||r.trim().length===0,onClick:()=>void f(),children:_()}),e?(0,F.jsx)(j,{variant:`ghost`,size:`sm`,disabled:l,onClick:()=>void n({}),children:s()}):null]}),a?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:a}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:v()})]})}export{I as IntegrationsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Az as r,Bz as i,Fz as a,Gg as o,Hg as s,Hz as c,Iz as l,Jg as u,Kg as d,Lz as f,Mz as p,Nz as m,Pz as h,Rz as g,Ug as _,Vg as v,Vz as y,Wg as b,Yg as x,_Q as S,bQ as C,jz as w,kz as T,qg as E,t as D,yQ as O,zz as k}from"./api-D64JTta1.js";import{t as A}from"./checkbox-BuTZzFvU.js";import"./select-wXM6h61N.js";import{t as j}from"./button-DeHzYOzP.js";import{t as M}from"./input-CZ0jp9Rx.js";import"./convexApi-DxRiI80M.js";import{t as N}from"./badge-DwWXPxwl.js";var P=t(e(),1),F=n();function I(){let e=C(D.integrations.status.status,{}),t=O(D.admin.setIntegrationConfig),[n,o]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&o(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:c()});let s=n,d=(e,t,n)=>o({...s,[e]:{...s[e],[t]:n}}),_=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[y(),` `,(0,F.jsx)(`strong`,{children:i()}),` `,k()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(N,{variant:`secondary`,children:g()}):(0,F.jsx)(N,{variant:`outline`,children:f()}):(0,F.jsx)(N,{variant:`outline`,children:l()}),note:a(),children:[(0,F.jsx)(R,{label:m(),children:(0,F.jsx)(M,{value:s.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>d(`langfuse`,`host`,e.target.value),onBlur:()=>_(`langfuse`,{host:s.langfuse.host??``})})}),(0,F.jsx)(z,{label:T(),checked:s.langfuse.enabled??!0,onChange:e=>{d(`langfuse`,`enabled`,e),_(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(N,{variant:`secondary`,children:g()}):(0,F.jsx)(N,{variant:`outline`,children:f()}):(0,F.jsx)(N,{variant:`outline`,children:l()}),note:h(),children:[(0,F.jsx)(R,{label:p(),children:(0,F.jsx)(M,{value:s.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>d(`opik`,`baseUrl`,e.target.value),onBlur:()=>_(`opik`,{baseUrl:s.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:w(),children:(0,F.jsx)(M,{value:s.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||r(),onChange:e=>d(`opik`,`workspace`,e.target.value),onBlur:()=>_(`opik`,{workspace:s.opik.workspace??``})})}),(0,F.jsx)(z,{label:T(),checked:s.opik.enabled??!0,onChange:e=>{d(`opik`,`enabled`,e),_(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(N,{variant:`secondary`,children:g()}):(0,F.jsx)(N,{variant:`outline`,children:f()}):(0,F.jsx)(N,{variant:`outline`,children:x()}),note:u(),children:[(0,F.jsx)(R,{label:E(),children:(0,F.jsx)(M,{value:s.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>d(`otlp`,`endpoint`,e.target.value),onBlur:()=>_(`otlp`,{endpoint:s.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:T(),checked:s.otlp.enabled??!0,onChange:e=>{d(`otlp`,`enabled`,e),_(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(A,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=S(D.integrations.otlpSecret.setOtlpHeaders),n=O(D.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[a,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),f=async()=>{u(!0),c(null);try{await t({headersJson:r}),i(``)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,F.jsxs)(R,{label:d(),children:[(0,F.jsx)(M,{value:r,placeholder:e?o():b(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(j,{size:`sm`,disabled:l||r.trim().length===0,onClick:()=>void f(),children:_()}),e?(0,F.jsx)(j,{variant:`ghost`,size:`sm`,disabled:l,onClick:()=>void n({}),children:s()}):null]}),a?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:a}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:v()})]})}export{I as IntegrationsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{A as r,BW as i,Jy as a,M as o,N as s,Qy as c,Sb as l,Yy as u,_b as d,bQ as f,bb as p,eb as m,gb as h,hb as g,it as _,j as v,mb as y,nt as b,pb as x,qy as S,rt as C,t as w,tt as T,vb as E,xb as D,yQ as O,yb as ee}from"./api-CWqdeSbN.js";import{t as te}from"./loader-circle-BqKiW3X9.js";import{t as ne}from"./rotate-ccw-CvefWwHW.js";import"./convexApi-G20_TNBS.js";import{r as re,t as ie}from"./capabilities-CASxhKEd.js";var k=t(e(),1),A={thinkingLevel:`segmented`,model:`list`,fastMode:`segmented`,showReasoning:`segmented`};function j(e,t){return A[e]===`segmented`&&t<=5?`segmented`:`list`}function M(e,t){return e!=null&&e[t]!==void 0}var N=[`inherit`,`fast`,`standard`];function P(e){return e==null||e.fastMode===void 0?`inherit`:e.fastMode?`fast`:`standard`}function F(e){return e===`inherit`?g():e===`fast`?y():x()}function I(e){return e===`inherit`?null:e===`fast`}function L(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function R(e){return e.length?e[0].toUpperCase()+e.slice(1):e}var z={off:`Off`,minimal:`Min`,low:`Low`,medium:`Med`,high:`High`,xhigh:`XHigh`};function B(e,t){return z[e]??t}function V(e){return H(e).used}function H(e){if(!e)return{used:null,source:`unknown`};let t=e.contextTokens,n=e=>e==null||t&&e>t?null:e;if(e.estimatedPromptTokens!=null)return{used:e.estimatedPromptTokens,source:`budget_estimate`};let r=n(e.activeTokens);if(r!=null)return{used:r,source:`last_call_usage`};if(e.totalTokensFresh===!1)return{used:null,source:`unknown`};let i=n(e.totalTokens);return i==null?{used:null,source:`unknown`}:{used:i,source:`last_call_usage`}}function U(e){return e?e.promptBudgetBeforeReserve!=null&&e.promptBudgetBeforeReserve>0?e.promptBudgetBeforeReserve:e.contextTokens!=null&&e.contextTokens>0?e.contextTokens:null:null}function W(e){if(!e)return null;if(e.sessionOverfull===!0)return`compaction_failed`;let t=V(e),n=U(e);return t!=null&&n!=null&&t>n?`estimate_exceeds_budget`:null}function ae(e){return H(e).source}function G(e,t){return e==null||!t||t<=0?null:Math.round(e/t*100)}function K(e,t){let n=G(e,t);return n===null?null:m({pct:n,used:L(e),total:L(t)})}function q(e){return c({level:e??`full`})}function J(e,t){let n=typeof e==`number`,r=typeof t==`number`;return n&&r?u({cost:e.toFixed(2),tokens:L(t)}):n?a({cost:e.toFixed(2)}):r?S({tokens:L(t)}):null}function oe(e){let t=e.filter(e=>typeof e==`string`&&e.length>0);return t.length>0?t.join(` · `):null}function se(e,t=5){let n=e?.contextPercent;if(typeof n!=`number`||!Number.isFinite(n))return null;let r=V(e),i=U(e);if(r===null||i===null)return null;let a=G(r,i);if(a===null)return null;let o=Math.abs(n-a);return o<=t?null:{gateway:n,derived:a,delta:o}}function ce(e,t){let n=t?C():b();return e===`agent`?{inheritedLabel:s(),resetLabel:v({value:n})}:e===`instance`?{inheritedLabel:o(),resetLabel:r({value:n})}:{}}function Y(e,t){let n=f(w.compat.forChat,e===null?`skip`:{chatId:e,...t?{routedAgent:t}:{}}),r=n==null?null:n.capabilities;return{can:(0,k.useCallback)(e=>ie(r,e),[r]),resolved:r!==null,loading:n===void 0,gatewayVersion:n?.gatewayVersion??null,provider:n?.provider??null,beyondValidated:n?.versionBeyondValidated===!0}}var X=n();function Z(e){let t=O(w.chats.setSessionKnob),[n,r]=(0,k.useState)(null),[i,a]=(0,k.useState)(null);return{apply:(0,k.useCallback)(async(n,i)=>{r(n),a(null);let o={chatId:e};n===`fastMode`?o.fastMode=i:n===`showReasoning`?o.showReasoning=i:o[n]=i;try{await t(o)}catch{a({field:n,value:i})}finally{r(null)}},[e,t]),pending:n,error:i}}function Q({label:e,overridden:t,onReset:n,pending:r,error:i,onRetry:a,help:o,children:s,resettable:c=!0,inheritedLabel:u,resetLabel:d}){return(0,X.jsxs)(`div`,{className:`oc-spanel__row${t?` is-overridden`:``}`,children:[(0,X.jsxs)(`div`,{className:`oc-spanel__rowhead`,children:[(0,X.jsx)(`span`,{className:`oc-spanel__label`,children:e}),r?(0,X.jsx)(te,{size:13,className:`oc-spanel__spin`,"aria-label":p()}):t?c?(0,X.jsx)(`button`,{type:`button`,className:`oc-spanel__reset`,title:d??D(),"aria-label":d??D(),onClick:n,children:(0,X.jsx)(ne,{size:12,"aria-hidden":!0})}):null:(0,X.jsx)(`span`,{className:`oc-spanel__badge`,children:u??l()})]}),(0,X.jsx)(`div`,{className:`oc-spanel__ctl`,children:s}),o?(0,X.jsx)(`p`,{className:`oc-spanel__help`,children:o}):null,i?(0,X.jsxs)(`p`,{className:`oc-spanel__error`,role:`alert`,children:[ee(),(0,X.jsx)(`button`,{type:`button`,className:`oc-spanel__retry`,onClick:a,children:E()})]}):null]})}function le({options:e,value:t,onChange:n,ariaLabel:r,disabled:i}){return(0,X.jsx)(`div`,{className:`oc-spanel__seg`,role:`group`,"aria-label":r,children:e.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`oc-spanel__seg-btn${t===e.id?` is-active`:``}`,"aria-pressed":t===e.id,title:e.title??e.label,"aria-label":e.title??e.label,disabled:i,onClick:()=>{e.id!==t&&n(e.id)},children:e.label},e.id))})}function ue({options:e,value:t,onChange:n,disabled:r,ariaLabel:i}){let a=t===null||e.some(e=>e.id===t);return(0,X.jsxs)(`select`,{className:`oc-spanel__select`,value:t??``,disabled:r,"aria-label":i,onChange:e=>{e.target.value&&e.target.value!==t&&n(e.target.value)},children:[t===null?(0,X.jsx)(`option`,{value:``,disabled:!0,children:`—`}):null,a?null:(0,X.jsx)(`option`,{value:t,children:t}),e.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.label},e.id))]})}function $({field:e,options:t,value:n,onChange:r,disabled:i,ariaLabel:a}){return j(e,t.length)===`list`?(0,X.jsx)(ue,{options:t,value:n,onChange:r,disabled:i,ariaLabel:a}):(0,X.jsx)(le,{options:t,value:n,onChange:r,disabled:i,ariaLabel:a})}function de({chatId:e,sm:t,settings:n}){let{apply:r,pending:a,error:o}=Z(e),{can:s}=Y(e),c=a!==null,l=(0,k.useCallback)(()=>{o&&r(o.field,o.value)},[r,o]),u=t?.thinkingLevels??[],f=t?.availableModels??[],p=P(n),m=re(s,{hasModels:f.length>0,hasLevels:u.length>0,described:t!==null});return(0,X.jsxs)(X.Fragment,{children:[m.model?(0,X.jsx)(Q,{label:i(),overridden:M(n,`model`),onReset:()=>void r(`model`,null),pending:a===`model`,error:o?.field===`model`,onRetry:l,resettable:m.reset,children:(0,X.jsx)($,{field:`model`,options:f,value:t?.model??null,onChange:e=>void r(`model`,e),disabled:c,ariaLabel:i()})}):null,m.thinking?(0,X.jsx)(Q,{label:d(),overridden:M(n,`thinkingLevel`),onReset:()=>void r(`thinkingLevel`,null),pending:a===`thinkingLevel`,error:o?.field===`thinkingLevel`,onRetry:l,resettable:m.reset,children:(0,X.jsx)($,{field:`thinkingLevel`,ariaLabel:d(),options:u.map(e=>({id:e.id,label:B(e.id,R(e.label)),title:R(e.label)})),value:t?.thinkingLevel??null,onChange:e=>void r(`thinkingLevel`,e),disabled:c})}):null,(0,X.jsx)(fe,{chatId:e,overridden:M(n,`showReasoning`),onApply:e=>void r(`showReasoning`,e),pending:a===`showReasoning`,error:o?.field===`showReasoning`,onRetry:l,disabled:c}),m.speed?(0,X.jsx)(Q,{label:h(),overridden:M(n,`fastMode`),onReset:()=>void r(`fastMode`,null),pending:a===`fastMode`,error:o?.field===`fastMode`,onRetry:l,resettable:m.reset,children:(0,X.jsx)($,{field:`fastMode`,ariaLabel:h(),options:N.map(e=>({id:e,label:F(e)})),value:p,onChange:e=>void r(`fastMode`,I(e)),disabled:c})}):null]})}function fe({chatId:e,overridden:t,onApply:n,pending:r,error:i,onRetry:a,disabled:o}){let s=f(w.messages.getSessionMeta,{chatId:e}),c=s?.showReasoning===!0,{inheritedLabel:l,resetLabel:u}=ce(s?.showReasoningDefaultSource,s?.showReasoningDefault===!0);return(0,X.jsx)(Q,{label:_(),overridden:t,inheritedLabel:l,resetLabel:u,onReset:()=>n(null),pending:r,error:i,onRetry:a,help:T(),children:(0,X.jsx)($,{field:`showReasoning`,ariaLabel:_(),options:[{id:`on`,label:C()},{id:`off`,label:b()}],value:s==null?null:c?`on`:`off`,onChange:e=>n(e===`on`),disabled:o})})}export{R as a,G as c,J as d,V as f,q as g,M as h,oe as i,se as l,L as m,de as n,K as o,U as p,Y as r,W as s,$ as t,ae as u};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{A as r,BW as i,Jy as a,M as o,N as s,Qy as c,Sb as l,Yy as u,_b as d,bQ as f,bb as p,eb as m,gb as h,hb as g,it as _,j as v,mb as y,nt as b,pb as x,qy as S,rt as C,t as w,tt as T,vb as E,xb as D,yQ as O,yb as ee}from"./api-D64JTta1.js";import{t as te}from"./loader-circle-1XN8tjq6.js";import{t as ne}from"./rotate-ccw-CiOuaG2h.js";import"./convexApi-DxRiI80M.js";import{r as re,t as ie}from"./capabilities-CASxhKEd.js";var k=t(e(),1),A={thinkingLevel:`segmented`,model:`list`,fastMode:`segmented`,showReasoning:`segmented`};function j(e,t){return A[e]===`segmented`&&t<=5?`segmented`:`list`}function M(e,t){return e!=null&&e[t]!==void 0}var N=[`inherit`,`fast`,`standard`];function P(e){return e==null||e.fastMode===void 0?`inherit`:e.fastMode?`fast`:`standard`}function F(e){return e===`inherit`?g():e===`fast`?y():x()}function I(e){return e===`inherit`?null:e===`fast`}function L(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function R(e){return e.length?e[0].toUpperCase()+e.slice(1):e}var z={off:`Off`,minimal:`Min`,low:`Low`,medium:`Med`,high:`High`,xhigh:`XHigh`};function B(e,t){return z[e]??t}function V(e){return H(e).used}function H(e){if(!e)return{used:null,source:`unknown`};let t=e.contextTokens,n=e=>e==null||t&&e>t?null:e;if(e.estimatedPromptTokens!=null)return{used:e.estimatedPromptTokens,source:`budget_estimate`};let r=n(e.activeTokens);if(r!=null)return{used:r,source:`last_call_usage`};if(e.totalTokensFresh===!1)return{used:null,source:`unknown`};let i=n(e.totalTokens);return i==null?{used:null,source:`unknown`}:{used:i,source:`last_call_usage`}}function U(e){return e?e.promptBudgetBeforeReserve!=null&&e.promptBudgetBeforeReserve>0?e.promptBudgetBeforeReserve:e.contextTokens!=null&&e.contextTokens>0?e.contextTokens:null:null}function W(e){if(!e)return null;if(e.sessionOverfull===!0)return`compaction_failed`;let t=V(e),n=U(e);return t!=null&&n!=null&&t>n?`estimate_exceeds_budget`:null}function ae(e){return H(e).source}function G(e,t){return e==null||!t||t<=0?null:Math.round(e/t*100)}function K(e,t){let n=G(e,t);return n===null?null:m({pct:n,used:L(e),total:L(t)})}function q(e){return c({level:e??`full`})}function J(e,t){let n=typeof e==`number`,r=typeof t==`number`;return n&&r?u({cost:e.toFixed(2),tokens:L(t)}):n?a({cost:e.toFixed(2)}):r?S({tokens:L(t)}):null}function oe(e){let t=e.filter(e=>typeof e==`string`&&e.length>0);return t.length>0?t.join(` · `):null}function se(e,t=5){let n=e?.contextPercent;if(typeof n!=`number`||!Number.isFinite(n))return null;let r=V(e),i=U(e);if(r===null||i===null)return null;let a=G(r,i);if(a===null)return null;let o=Math.abs(n-a);return o<=t?null:{gateway:n,derived:a,delta:o}}function ce(e,t){let n=t?C():b();return e===`agent`?{inheritedLabel:s(),resetLabel:v({value:n})}:e===`instance`?{inheritedLabel:o(),resetLabel:r({value:n})}:{}}function Y(e,t){let n=f(w.compat.forChat,e===null?`skip`:{chatId:e,...t?{routedAgent:t}:{}}),r=n==null?null:n.capabilities;return{can:(0,k.useCallback)(e=>ie(r,e),[r]),resolved:r!==null,loading:n===void 0,gatewayVersion:n?.gatewayVersion??null,provider:n?.provider??null,beyondValidated:n?.versionBeyondValidated===!0}}var X=n();function Z(e){let t=O(w.chats.setSessionKnob),[n,r]=(0,k.useState)(null),[i,a]=(0,k.useState)(null);return{apply:(0,k.useCallback)(async(n,i)=>{r(n),a(null);let o={chatId:e};n===`fastMode`?o.fastMode=i:n===`showReasoning`?o.showReasoning=i:o[n]=i;try{await t(o)}catch{a({field:n,value:i})}finally{r(null)}},[e,t]),pending:n,error:i}}function Q({label:e,overridden:t,onReset:n,pending:r,error:i,onRetry:a,help:o,children:s,resettable:c=!0,inheritedLabel:u,resetLabel:d}){return(0,X.jsxs)(`div`,{className:`oc-spanel__row${t?` is-overridden`:``}`,children:[(0,X.jsxs)(`div`,{className:`oc-spanel__rowhead`,children:[(0,X.jsx)(`span`,{className:`oc-spanel__label`,children:e}),r?(0,X.jsx)(te,{size:13,className:`oc-spanel__spin`,"aria-label":p()}):t?c?(0,X.jsx)(`button`,{type:`button`,className:`oc-spanel__reset`,title:d??D(),"aria-label":d??D(),onClick:n,children:(0,X.jsx)(ne,{size:12,"aria-hidden":!0})}):null:(0,X.jsx)(`span`,{className:`oc-spanel__badge`,children:u??l()})]}),(0,X.jsx)(`div`,{className:`oc-spanel__ctl`,children:s}),o?(0,X.jsx)(`p`,{className:`oc-spanel__help`,children:o}):null,i?(0,X.jsxs)(`p`,{className:`oc-spanel__error`,role:`alert`,children:[ee(),(0,X.jsx)(`button`,{type:`button`,className:`oc-spanel__retry`,onClick:a,children:E()})]}):null]})}function le({options:e,value:t,onChange:n,ariaLabel:r,disabled:i}){return(0,X.jsx)(`div`,{className:`oc-spanel__seg`,role:`group`,"aria-label":r,children:e.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`oc-spanel__seg-btn${t===e.id?` is-active`:``}`,"aria-pressed":t===e.id,title:e.title??e.label,"aria-label":e.title??e.label,disabled:i,onClick:()=>{e.id!==t&&n(e.id)},children:e.label},e.id))})}function ue({options:e,value:t,onChange:n,disabled:r,ariaLabel:i}){let a=t===null||e.some(e=>e.id===t);return(0,X.jsxs)(`select`,{className:`oc-spanel__select`,value:t??``,disabled:r,"aria-label":i,onChange:e=>{e.target.value&&e.target.value!==t&&n(e.target.value)},children:[t===null?(0,X.jsx)(`option`,{value:``,disabled:!0,children:`—`}):null,a?null:(0,X.jsx)(`option`,{value:t,children:t}),e.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.label},e.id))]})}function $({field:e,options:t,value:n,onChange:r,disabled:i,ariaLabel:a}){return j(e,t.length)===`list`?(0,X.jsx)(ue,{options:t,value:n,onChange:r,disabled:i,ariaLabel:a}):(0,X.jsx)(le,{options:t,value:n,onChange:r,disabled:i,ariaLabel:a})}function de({chatId:e,sm:t,settings:n}){let{apply:r,pending:a,error:o}=Z(e),{can:s}=Y(e),c=a!==null,l=(0,k.useCallback)(()=>{o&&r(o.field,o.value)},[r,o]),u=t?.thinkingLevels??[],f=t?.availableModels??[],p=P(n),m=re(s,{hasModels:f.length>0,hasLevels:u.length>0,described:t!==null});return(0,X.jsxs)(X.Fragment,{children:[m.model?(0,X.jsx)(Q,{label:i(),overridden:M(n,`model`),onReset:()=>void r(`model`,null),pending:a===`model`,error:o?.field===`model`,onRetry:l,resettable:m.reset,children:(0,X.jsx)($,{field:`model`,options:f,value:t?.model??null,onChange:e=>void r(`model`,e),disabled:c,ariaLabel:i()})}):null,m.thinking?(0,X.jsx)(Q,{label:d(),overridden:M(n,`thinkingLevel`),onReset:()=>void r(`thinkingLevel`,null),pending:a===`thinkingLevel`,error:o?.field===`thinkingLevel`,onRetry:l,resettable:m.reset,children:(0,X.jsx)($,{field:`thinkingLevel`,ariaLabel:d(),options:u.map(e=>({id:e.id,label:B(e.id,R(e.label)),title:R(e.label)})),value:t?.thinkingLevel??null,onChange:e=>void r(`thinkingLevel`,e),disabled:c})}):null,(0,X.jsx)(fe,{chatId:e,overridden:M(n,`showReasoning`),onApply:e=>void r(`showReasoning`,e),pending:a===`showReasoning`,error:o?.field===`showReasoning`,onRetry:l,disabled:c}),m.speed?(0,X.jsx)(Q,{label:h(),overridden:M(n,`fastMode`),onReset:()=>void r(`fastMode`,null),pending:a===`fastMode`,error:o?.field===`fastMode`,onRetry:l,resettable:m.reset,children:(0,X.jsx)($,{field:`fastMode`,ariaLabel:h(),options:N.map(e=>({id:e,label:F(e)})),value:p,onChange:e=>void r(`fastMode`,I(e)),disabled:c})}):null]})}function fe({chatId:e,overridden:t,onApply:n,pending:r,error:i,onRetry:a,disabled:o}){let s=f(w.messages.getSessionMeta,{chatId:e}),c=s?.showReasoning===!0,{inheritedLabel:l,resetLabel:u}=ce(s?.showReasoningDefaultSource,s?.showReasoningDefault===!0);return(0,X.jsx)(Q,{label:_(),overridden:t,inheritedLabel:l,resetLabel:u,onReset:()=>n(null),pending:r,error:i,onRetry:a,help:T(),children:(0,X.jsx)($,{field:`showReasoning`,ariaLabel:_(),options:[{id:`on`,label:C()},{id:`off`,label:b()}],value:s==null?null:c?`on`:`off`,onChange:e=>n(e===`on`),disabled:o})})}export{R as a,G as c,J as d,V as f,q as g,M as h,oe as i,se as l,L as m,de as n,K as o,U as p,Y as r,W as s,$ as t,ae as u};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$k as r,FB as i,GB as a,Gk as o,HB as s,Hk as c,Jk as l,Kk as ee,PB as u,Qk as d,UB as f,Uk as p,WB as m,Wk as h,Xk as g,Yk as te,Zk as ne,bQ as _,eA as v,gV as y,nA as b,qk as x,t as S,tA as C}from"./api-CWqdeSbN.js";import{n as w,t as T}from"./useNavigate-D3GIoxyW.js";import"./convexApi-G20_TNBS.js";import{c as E,n as re,o as ie}from"./searchSchemas-Dm-Qg010.js";import{t as D}from"./appHost-CH3EGcJw.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-BV8NO76j.js";import{n as N,t as P}from"./TimeRangePicker-BZtw1JkM.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=_(S.me.getMe,{host:D})?.permissions?.includes(`traces.read`)??!1,t=_(S.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:y()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:a()}),(0,R.jsx)(j,{children:f()})]}),(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),o=t=>6+t*468/(e.length-1),s=e=>74-e*68/r,c=e=>e.map((e,t)=>`${t===0?`M`:`L`}${o(t).toFixed(1)},${s(e).toFixed(1)}`).join(` `),l=e[e.length-1];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{style:{color:`var(--primary)`},children:[u(),` p50 `,B(l.cP50),` `,m()]}),(0,R.jsxs)(`span`,{children:[i(),` p50 `,B(l.aP50),` `,m()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":a(),children:[(0,R.jsx)(`path`,{d:c(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:c(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:b(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:C(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:v(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:r(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:d(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:ne(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:g(),unit:`/h`,group:`Assistant`,isError:!0}],W=L,G=[`API`,`OpenClaw`,`Chat`,`Assistant`],K=1e3,q=36e5;function J(e,t){let n=Math.max(1,Math.ceil((t-e)/q)),r=Math.min(n*W,K);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/W))}}function ae(){let e=w({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=ie(e.from,e.to,re,`now`),r=e=>void t({search:t=>({...t,...E(e)})}),{from:i,to:a}=N(n),{rowLimit:o,buckets:s}=J(i,a),c=_(S.kpi.listKpis,{limit:o,filter:{from:i,to:a}}),u=(0,F.useMemo)(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>s&&e.set(t,n.slice(n.length-s));return e},[c,s]),d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[te(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:l()})]}),(0,R.jsx)(Y,{value:n,onChange:r})]});return c===void 0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:x()})]}):c.length===0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:ee()})]}):(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:o({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:h()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:p({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":c({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{$k as r,FB as i,GB as a,Gk as o,HB as s,Hk as c,Jk as l,Kk as ee,PB as u,Qk as d,UB as f,Uk as p,WB as m,Wk as h,Xk as g,Yk as te,Zk as ne,bQ as _,eA as v,gV as y,nA as b,qk as x,t as S,tA as C}from"./api-D64JTta1.js";import{n as w,t as T}from"./useNavigate-D3GIoxyW.js";import"./convexApi-DxRiI80M.js";import{c as E,n as re,o as ie}from"./searchSchemas-Dm-Qg010.js";import{t as D}from"./appHost-CH3EGcJw.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-WAOfM0PL.js";import{n as N,t as P}from"./TimeRangePicker-jsNw51TL.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=_(S.me.getMe,{host:D})?.permissions?.includes(`traces.read`)??!1,t=_(S.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:y()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:a()}),(0,R.jsx)(j,{children:f()})]}),(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),o=t=>6+t*468/(e.length-1),s=e=>74-e*68/r,c=e=>e.map((e,t)=>`${t===0?`M`:`L`}${o(t).toFixed(1)},${s(e).toFixed(1)}`).join(` `),l=e[e.length-1];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{style:{color:`var(--primary)`},children:[u(),` p50 `,B(l.cP50),` `,m()]}),(0,R.jsxs)(`span`,{children:[i(),` p50 `,B(l.aP50),` `,m()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":a(),children:[(0,R.jsx)(`path`,{d:c(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:c(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:b(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:C(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:v(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:r(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:d(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:ne(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:g(),unit:`/h`,group:`Assistant`,isError:!0}],W=L,G=[`API`,`OpenClaw`,`Chat`,`Assistant`],K=1e3,q=36e5;function J(e,t){let n=Math.max(1,Math.ceil((t-e)/q)),r=Math.min(n*W,K);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/W))}}function ae(){let e=w({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=ie(e.from,e.to,re,`now`),r=e=>void t({search:t=>({...t,...E(e)})}),{from:i,to:a}=N(n),{rowLimit:o,buckets:s}=J(i,a),c=_(S.kpi.listKpis,{limit:o,filter:{from:i,to:a}}),u=(0,F.useMemo)(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>s&&e.set(t,n.slice(n.length-s));return e},[c,s]),d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[te(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:l()})]}),(0,R.jsx)(Y,{value:n,onChange:r})]});return c===void 0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:x()})]}):c.length===0?(0,R.jsxs)(R.Fragment,{children:[d,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:ee()})]}):(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:o({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:h()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:p({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":c({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{$K as r,$Z as i,AK as a,Al as o,BK as s,BZ as c,DK as l,EK as u,FK as d,FZ as ee,GK as f,GZ as te,HK as p,HZ as m,IK as h,IZ as ne,JK as re,JZ as ie,KK as ae,KZ as oe,LK as se,LZ as ce,MK as g,MZ as le,NK as ue,NZ as de,OK as fe,PK as _,PZ as pe,QK as me,QZ as he,RK as v,RZ as y,TK as b,UK as x,UZ as S,VK as C,VZ as w,WK as T,WZ as E,XK as D,XZ as O,YK as k,YZ as A,ZK as j,ZZ as M,aq as N,bQ as P,cq as F,dl as I,eQ as L,eq as R,fl as ge,gl as _e,hl as ve,iQ as ye,iq as be,jK as xe,jL as Se,kK as Ce,kl as we,lQ as Te,ll as Ee,lq as De,ml as Oe,nq as ke,oq as Ae,pl as je,qK as Me,qZ as Ne,rq as Pe,sq as Fe,t as z,tQ as Ie,tq as Le,ul as Re,uq as ze,wl as Be,yQ as B,zK as Ve,zZ as He}from"./api-CWqdeSbN.js";import{t as V}from"./checkbox-DPxJTQjc.js";import{a as Ue,i as We,n as Ge,r as H,t as Ke}from"./select-CjcMQhwm.js";import{t as U}from"./button-C_rIPtCv.js";import{t as W}from"./input-CSZu-bVE.js";import"./convexApi-G20_TNBS.js";import{c as qe,d as Je,r as Ye,t as Xe,u as Ze}from"./useFontScale-DiSkEM6I.js";import{r as Qe}from"./toast-C_YfUacM.js";import{t as G}from"./badge-ChMMFtuW.js";import{t as K}from"./appHost-CH3EGcJw.js";import{t as $e}from"./localePickerView-C2RmOS86.js";import{t as et}from"./switch--NPD3Vp0.js";import{t as tt}from"./TimezoneCombobox-CeRN4N3z.js";var q=t(e(),1),J=[{id:`messages`,label:()=>ze()},{id:`composer`,label:()=>De()},{id:`sidebar`,label:()=>F()},{id:`notifications`,label:()=>f()},{id:`other`,label:()=>Fe()}],Y={showSource:{category:`messages`,label:()=>Ae(),help:()=>N()},showReport:{category:`messages`,label:()=>be(),help:()=>Pe()},copyAssistant:{category:`messages`,label:()=>ke()},copyUser:{category:`messages`,label:()=>Le()},showDelete:{category:`messages`,label:()=>R()},showTools:{category:`messages`,label:()=>r(),help:()=>me()},voiceInput:{category:`composer`,label:()=>j(),help:()=>D()},showUsage:{category:`composer`,label:()=>k(),help:()=>re()},autoReadAloud:{category:`composer`,label:()=>o(),help:()=>we()},showChatAge:{category:`sidebar`,label:()=>Me(),help:()=>ae()},notifSound:{category:`notifications`,label:()=>T(),help:()=>x()},notifSystem:{category:`notifications`,label:()=>p(),help:()=>C()},replySound:{category:`notifications`,label:()=>s(),help:()=>Ve()}};function X(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function nt(e,t){let n=X(t.trim()),r=new Map(J.map(e=>[e.id,e.label()])),i=new Map(J.map(e=>[e.id,[]]));for(let t of e){let e=Y[t],a=e?.category??`other`;n&&!X(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return J.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var 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 Z(e){return e===`admin`}function Q(e){return e===!0?`on`:e===!1?`off`:`inherit`}function ot(e){return e===`on`||e!==`off`&&null}function st(e){return at(e)?it[e]:void 0}var $=n(),ct={voiceInput:()=>Ce()};function lt({prefKey:e,ui:t}){let n=B(z.admin.setUiPrefDefault),r=B(z.admin.setFeatureEnabled),i=st(e),a=i?ct[e]?.():void 0;return(0,$.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,$.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,$.jsx)(`span`,{className:`oc-prefs__gov-label`,children:ue()}),(0,$.jsxs)(Ke,{value:Q(t.defaults[e]),onValueChange:t=>void n({key:e,value:ot(t)}),children:[(0,$.jsx)(We,{size:`sm`,className:`w-36`,children:(0,$.jsx)(Ue,{})}),(0,$.jsxs)(Ge,{children:[(0,$.jsx)(H,{value:`on`,children:l()}),(0,$.jsx)(H,{value:`off`,children:u()}),(0,$.jsx)(H,{value:`inherit`,children:b()})]})]}),i?(0,$.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,$.jsx)(V,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":g()}),g()]}):null]}),a?(0,$.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function ut({current:e,enabled:t}){let n=B(z.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Ze(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,$.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,$.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,$.jsxs)(`span`,{className:`oc-prefs__label`,children:[_e(),e?(0,$.jsx)(G,{variant:`secondary`,children:Je(e,qe())}):null]}),(0,$.jsx)(`span`,{className:`oc-prefs__help`,children:a?je():r?Oe():ve()})]}),(0,$.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:Ee()}):null,(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?Re():e?I():ge()})]})]})}function dt(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=P(z.me.getMe,{host:K}),o=i?.ui,s=Z(i?.role)&&n,c=B(z.me.setUiPref).withOptimisticUpdate(Ye),l=(0,q.useMemo)(()=>o?nt(Object.keys(o.effective),e):[],[o,e]);return o?(0,$.jsxs)(`div`,{className:`oc-prefs-panel`,children:[Z(i?.role)?(0,$.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,$.jsx)(V,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":_()}),_()]}):null,s?(0,$.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,$.jsx)(`p`,{children:xe()}),(0,$.jsx)(`p`,{children:a()}),(0,$.jsx)(`p`,{children:fe()})]}):null,(0,$.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:v(),"aria-label":v(),className:`mb-2`}),l.length===0?(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:se()}):(0,$.jsx)(`div`,{className:`oc-prefs`,children:l.map(e=>(0,$.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,$.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=Y[e],n=t?t.label():e,r=t?.help?.(),i=o.locked[e],a=o.effective[e],l=o.userOverrides[e]!==void 0;return(0,$.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,$.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,$.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,$.jsx)(G,{variant:`outline`,children:h()}):l?(0,$.jsx)(G,{variant:`secondary`,children:Be()}):null]}),r?(0,$.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,$.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void c({key:e,value:null}),children:d()}):null,(0,$.jsx)(et,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),c({key:e,value:t})},"aria-label":n})]}),s?(0,$.jsx)(lt,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,$.jsx)(ut,{current:i?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:Te()})}var ft={sm:()=>S(),md:()=>m(),lg:()=>w(),xl:()=>c(),"2xl":()=>He(),"3xl":()=>y()};function pt(){let e=P(z.me.getMe,{host:K}),t=B(z.me.setLocale),n=B(z.me.setTimezone),r=B(z.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(z.me.getMe,{host:K});n&&e.setQuery(z.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),a=B(z.me.setMyName),o=Qe(),s=e?.locale??`default`,c=e?.name??``,[l,u]=(0,q.useState)(null),d=l??c,f=d.trim()!==c.trim();async function p(){try{await a({name:d}),u(null),o.success(M())}catch(e){o.error(O(),e)}}return(0,$.jsxs)(`div`,{className:`oc-appearance`,children:[(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:Ie()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:L()})]}),(0,$.jsxs)(`div`,{className:`oc-show__row`,children:[(0,$.jsx)(W,{className:`max-w-xs`,value:d,maxLength:120,placeholder:i(),onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f&&(e.preventDefault(),p())}}),(0,$.jsx)(U,{size:`sm`,disabled:!f,onClick:()=>void p(),children:Se()})]}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:he()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:A()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:ie()})]}),(0,$.jsxs)(`div`,{className:`oc-show__row`,children:[$e().map(e=>(0,$.jsx)(U,{variant:s===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,$.jsx)(U,{variant:s==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:ye()})]}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:Ne()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:ce()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:ne()})]}),(0,$.jsxs)(`div`,{className:`oc-show__row`,children:[(0,$.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,$.jsx)(U,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:ee()})]}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:pe()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:oe()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:te()})]}),(0,$.jsx)(`div`,{className:`oc-show__row`,children:Xe.map(t=>(0,$.jsx)(U,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void r({scale:t}),children:ft[t]()},t))}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:E()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:de()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:le()})]}),(0,$.jsx)(dt,{})]})]})}export{pt as PreferencesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$K as r,$Z as i,AK as a,Al as o,BK as s,BZ as c,DK as l,EK as u,FK as d,FZ as ee,GK as f,GZ as te,HK as p,HZ as m,IK as h,IZ as ne,JK as re,JZ as ie,KK as ae,KZ as oe,LK as se,LZ as ce,MK as g,MZ as le,NK as ue,NZ as de,OK as fe,PK as _,PZ as pe,QK as me,QZ as he,RK as v,RZ as y,TK as b,UK as x,UZ as S,VK as C,VZ as w,WK as T,WZ as E,XK as D,XZ as O,YK as k,YZ as A,ZK as j,ZZ as M,aq as N,bQ as P,cq as F,dl as I,eQ as L,eq as R,fl as ge,gl as _e,hl as ve,iQ as ye,iq as be,jK as xe,jL as Se,kK as Ce,kl as we,lQ as Te,ll as Ee,lq as De,ml as Oe,nq as ke,oq as Ae,pl as je,qK as Me,qZ as Ne,rq as Pe,sq as Fe,t as z,tQ as Ie,tq as Le,ul as Re,uq as ze,wl as Be,yQ as B,zK as Ve,zZ as He}from"./api-D64JTta1.js";import{t as V}from"./checkbox-BuTZzFvU.js";import{a as Ue,i as We,n as Ge,r as H,t as Ke}from"./select-wXM6h61N.js";import{t as U}from"./button-DeHzYOzP.js";import{t as W}from"./input-CZ0jp9Rx.js";import"./convexApi-DxRiI80M.js";import{c as qe,d as Je,r as Ye,t as Xe,u as Ze}from"./useFontScale-P_rNok04.js";import{r as Qe}from"./toast-DtA87VYn.js";import{t as G}from"./badge-DwWXPxwl.js";import{t as K}from"./appHost-CH3EGcJw.js";import{t as $e}from"./localePickerView-C2RmOS86.js";import{t as et}from"./switch-Beq0wUQ_.js";import{t as tt}from"./TimezoneCombobox-zOqV7dxe.js";var q=t(e(),1),J=[{id:`messages`,label:()=>ze()},{id:`composer`,label:()=>De()},{id:`sidebar`,label:()=>F()},{id:`notifications`,label:()=>f()},{id:`other`,label:()=>Fe()}],Y={showSource:{category:`messages`,label:()=>Ae(),help:()=>N()},showReport:{category:`messages`,label:()=>be(),help:()=>Pe()},copyAssistant:{category:`messages`,label:()=>ke()},copyUser:{category:`messages`,label:()=>Le()},showDelete:{category:`messages`,label:()=>R()},showTools:{category:`messages`,label:()=>r(),help:()=>me()},voiceInput:{category:`composer`,label:()=>j(),help:()=>D()},showUsage:{category:`composer`,label:()=>k(),help:()=>re()},autoReadAloud:{category:`composer`,label:()=>o(),help:()=>we()},showChatAge:{category:`sidebar`,label:()=>Me(),help:()=>ae()},notifSound:{category:`notifications`,label:()=>T(),help:()=>x()},notifSystem:{category:`notifications`,label:()=>p(),help:()=>C()},replySound:{category:`notifications`,label:()=>s(),help:()=>Ve()}};function X(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function nt(e,t){let n=X(t.trim()),r=new Map(J.map(e=>[e.id,e.label()])),i=new Map(J.map(e=>[e.id,[]]));for(let t of e){let e=Y[t],a=e?.category??`other`;n&&!X(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return J.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var 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 Z(e){return e===`admin`}function Q(e){return e===!0?`on`:e===!1?`off`:`inherit`}function ot(e){return e===`on`||e!==`off`&&null}function st(e){return at(e)?it[e]:void 0}var $=n(),ct={voiceInput:()=>Ce()};function lt({prefKey:e,ui:t}){let n=B(z.admin.setUiPrefDefault),r=B(z.admin.setFeatureEnabled),i=st(e),a=i?ct[e]?.():void 0;return(0,$.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,$.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,$.jsx)(`span`,{className:`oc-prefs__gov-label`,children:ue()}),(0,$.jsxs)(Ke,{value:Q(t.defaults[e]),onValueChange:t=>void n({key:e,value:ot(t)}),children:[(0,$.jsx)(We,{size:`sm`,className:`w-36`,children:(0,$.jsx)(Ue,{})}),(0,$.jsxs)(Ge,{children:[(0,$.jsx)(H,{value:`on`,children:l()}),(0,$.jsx)(H,{value:`off`,children:u()}),(0,$.jsx)(H,{value:`inherit`,children:b()})]})]}),i?(0,$.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,$.jsx)(V,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":g()}),g()]}):null]}),a?(0,$.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function ut({current:e,enabled:t}){let n=B(z.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Ze(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,$.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,$.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,$.jsxs)(`span`,{className:`oc-prefs__label`,children:[_e(),e?(0,$.jsx)(G,{variant:`secondary`,children:Je(e,qe())}):null]}),(0,$.jsx)(`span`,{className:`oc-prefs__help`,children:a?je():r?Oe():ve()})]}),(0,$.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:Ee()}):null,(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?Re():e?I():ge()})]})]})}function dt(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=P(z.me.getMe,{host:K}),o=i?.ui,s=Z(i?.role)&&n,c=B(z.me.setUiPref).withOptimisticUpdate(Ye),l=(0,q.useMemo)(()=>o?nt(Object.keys(o.effective),e):[],[o,e]);return o?(0,$.jsxs)(`div`,{className:`oc-prefs-panel`,children:[Z(i?.role)?(0,$.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,$.jsx)(V,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":_()}),_()]}):null,s?(0,$.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,$.jsx)(`p`,{children:xe()}),(0,$.jsx)(`p`,{children:a()}),(0,$.jsx)(`p`,{children:fe()})]}):null,(0,$.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:v(),"aria-label":v(),className:`mb-2`}),l.length===0?(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:se()}):(0,$.jsx)(`div`,{className:`oc-prefs`,children:l.map(e=>(0,$.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,$.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=Y[e],n=t?t.label():e,r=t?.help?.(),i=o.locked[e],a=o.effective[e],l=o.userOverrides[e]!==void 0;return(0,$.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,$.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,$.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,$.jsx)(G,{variant:`outline`,children:h()}):l?(0,$.jsx)(G,{variant:`secondary`,children:Be()}):null]}),r?(0,$.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,$.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void c({key:e,value:null}),children:d()}):null,(0,$.jsx)(et,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),c({key:e,value:t})},"aria-label":n})]}),s?(0,$.jsx)(lt,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,$.jsx)(ut,{current:i?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:Te()})}var ft={sm:()=>S(),md:()=>m(),lg:()=>w(),xl:()=>c(),"2xl":()=>He(),"3xl":()=>y()};function pt(){let e=P(z.me.getMe,{host:K}),t=B(z.me.setLocale),n=B(z.me.setTimezone),r=B(z.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(z.me.getMe,{host:K});n&&e.setQuery(z.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),a=B(z.me.setMyName),o=Qe(),s=e?.locale??`default`,c=e?.name??``,[l,u]=(0,q.useState)(null),d=l??c,f=d.trim()!==c.trim();async function p(){try{await a({name:d}),u(null),o.success(M())}catch(e){o.error(O(),e)}}return(0,$.jsxs)(`div`,{className:`oc-appearance`,children:[(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:Ie()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:L()})]}),(0,$.jsxs)(`div`,{className:`oc-show__row`,children:[(0,$.jsx)(W,{className:`max-w-xs`,value:d,maxLength:120,placeholder:i(),onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f&&(e.preventDefault(),p())}}),(0,$.jsx)(U,{size:`sm`,disabled:!f,onClick:()=>void p(),children:Se()})]}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:he()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:A()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:ie()})]}),(0,$.jsxs)(`div`,{className:`oc-show__row`,children:[$e().map(e=>(0,$.jsx)(U,{variant:s===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,$.jsx)(U,{variant:s==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:ye()})]}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:Ne()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:ce()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:ne()})]}),(0,$.jsxs)(`div`,{className:`oc-show__row`,children:[(0,$.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,$.jsx)(U,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:ee()})]}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:pe()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:oe()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:te()})]}),(0,$.jsx)(`div`,{className:`oc-show__row`,children:Xe.map(t=>(0,$.jsx)(U,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void r({scale:t}),children:ft[t]()},t))}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:E()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:de()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:le()})]}),(0,$.jsx)(dt,{})]})]})}export{pt as PreferencesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{BO as r,CO as i,Ck as a,DO as o,GO as s,HO as c,ID as l,IO as u,Is as d,JO as f,KO as p,LO as m,Ls as h,MO as g,NO as ee,PO as _,QO as v,RO as y,SO as b,TO as x,Tk as te,UO as ne,VO as re,WO as S,XO as ie,YO as ae,ZO as C,_O as oe,bO as se,bQ as w,dT as ce,ek as le,fQ as ue,fk as de,gO as T,gk as fe,hk as pe,ik as me,jO as he,k as E,lQ as D,lk as ge,nk as _e,ok as ve,qO as ye,rk as O,t as k,tk as be,uk as xe,vO as Se,vk as A,wk as Ce,xO as j,yO as we,yQ as M,yk as N,zO as P}from"./api-CWqdeSbN.js";import{n as Te,t as F}from"./useNavigate-D3GIoxyW.js";import{A as Ee,B as I,C as L,D as De,E as R,F as Oe,G as ke,H as Ae,I as z,J as je,K as Me,R as Ne,S as Pe,T as Fe,U as Ie,V as Le,W as Re,_ as ze,a as B,f as V,h as Be,i as Ve,j as He,m as Ue,n as We,o as Ge,p as H,r as Ke,s as U,t as qe,u as Je,w as Ye,x as Xe,y as Ze,z as Qe}from"./useStartNewChat-8wVLrYnZ.js";import{r as $e}from"./dist-CzmY6YrA.js";import{t as et}from"./chevron-right-DMqzlhWH.js";import{c as tt,g as nt,i as rt,n as it,r as W,s as at,t as ot}from"./dropdown-menu-BVKVjups.js";import{n as st,t as ct}from"./eye-LggiM6Z5.js";import{t as lt}from"./list-obbqPBzD.js";import{t as ut}from"./pencil-K7SBkvHL.js";import{t as dt}from"./trash-2-xhtrhYsd.js";import{t as G}from"./button-C_rIPtCv.js";import{t as ft}from"./input-CSZu-bVE.js";import"./convexApi-G20_TNBS.js";import{r as pt}from"./toast-C_YfUacM.js";import{n as mt,r as ht}from"./ConfirmDialog-B7k0wvSi.js";import{t as gt}from"./EntitySheet-DRzkWKlH.js";import{r as _t,t as vt}from"./measureClone-CHN0WNEY.js";import{r as yt,t as bt}from"./trashView-CwUC01r_.js";var xt=E(`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`}]]),St=E(`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`}]]),Ct=E(`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`}]]),K=E(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),q=t(e(),1),J=n();function wt({className:e}){return(0,J.jsx)(tt,{asChild:!0,children:(0,J.jsx)(G,{variant:`ghost`,size:`icon-xs`,"aria-label":i(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,J.jsx)(nt,{})})})}function Tt({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:o}){let s=M(k.projects.renameProject),c=M(k.projects.setProjectColor),l=M(k.projects.moveProject),u=M(k.projects.deleteProject),d=M(k.projects.createProject),f=mt(),p=yt(),m=ht(),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(t),[y,ne]=(0,q.useState)(!1),[re,S]=(0,q.useState)(!1),ie=w(k.projects.projectTreeCount,re?{projectId:e}:`skip`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(ot,{onOpenChange:e=>e&&S(!0),children:[(0,J.jsx)(wt,{className:i}),(0,J.jsxs)(it,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(W,{onSelect:()=>o(),children:[(0,J.jsx)(Me,{}),` `,ve()]}),(0,J.jsxs)(W,{onSelect:()=>{v(t),g(!0)},children:[(0,J.jsx)(ut,{}),` `,b()]}),(0,J.jsxs)(W,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await m({title:C(),label:te(),placeholder:Ce(),confirmLabel:a()});t&&await d({name:t,parentId:e})})},children:[(0,J.jsx)(ke,{}),` `,C()]}),(0,J.jsxs)(W,{onSelect:()=>ne(!0),children:[(0,J.jsx)(St,{}),` `,ee()]}),(0,J.jsx)(rt,{children:we()}),(0,J.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void c({projectId:e,color:null}),"aria-label":Se(),children:`✕`}),Ve.map(t=>(0,J.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void c({projectId:e,color:t.value})},t.value))]}),(0,J.jsx)(at,{}),(0,J.jsxs)(W,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=ie?.folders??0,r=ie?.chats??0;await f({title:ge({name:t}),description:bt({folders:n,chats:r,days:p}),confirmWord:x(),confirmLabel:xe(),destructive:!0})&&await u({projectId:e})})},children:[(0,J.jsx)(dt,{}),` `,x()]})]})]}),(0,J.jsx)(gt,{open:h,onOpenChange:g,title:pe(),canSubmit:_.trim().length>0,onSubmit:async()=>{await s({projectId:e,name:_.trim()}),g(!1)},submitLabel:b(),children:(0,J.jsx)(ft,{value:_,onChange:e=>v(e.target.value),autoFocus:!0})}),y?(0,J.jsx)(Ke,{open:y,onOpenChange:ne,title:he(),movingFolderId:e,currentId:r,onPick:t=>void l({projectId:e,parentId:t})}):null]})}function Y({chat:e,currentFolderId:t,className:n}){let r=M(k.chats.pinChat),i=M(k.chats.deleteChat),a=M(k.chats.renameChat),o=M(k.chats.setChatSidebar),s=M(k.chats.moveChatToProject),c=mt(),u=yt(),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(e.title??``),[h,ee]=(0,q.useState)(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(ot,{children:[(0,J.jsx)(wt,{className:n}),(0,J.jsxs)(it,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(W,{onSelect:()=>{m(e.title??``),f(!0)},children:[(0,J.jsx)(ut,{}),` `,b()]}),(0,J.jsxs)(W,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,J.jsx)(Qe,{}):(0,J.jsx)(I,{}),e.pinned?j():se()]}),(0,J.jsxs)(W,{onSelect:()=>ee(!0),children:[(0,J.jsx)(St,{}),` `,_()]}),e.pinned&&e.inSidebar?null:(0,J.jsxs)(W,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,J.jsx)(Le,{}):(0,J.jsx)(K,{}),e.inSidebar?O():me()]}),(0,J.jsx)(at,{}),(0,J.jsxs)(W,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await c({title:oe(),description:T({days:u}),confirmLabel:x(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,J.jsx)(dt,{}),` `,x()]})]})]}),(0,J.jsx)(gt,{open:d,onOpenChange:f,title:l(),canSubmit:p.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:b(),children:(0,J.jsx)(ft,{value:p,onChange:e=>m(e.target.value),autoFocus:!0})}),h?(0,J.jsx)(Ke,{open:h,onOpenChange:ee,title:g(),currentId:t,onPick:t=>void s({chatId:e._id,projectId:t})}):null]})}function Et(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function Dt(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 Ot(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}function kt(e,t){return{available:e,required:[t]}}function At(e){return{labels:e===0,moved:e>=2}}var jt=`oc.projpage.view`;function Mt(){let e=localStorage.getItem(jt);return e===`cards`||e===`list`?e:`columns`}var X=e=>`into:${e}`,Nt=e=>`col:${e??`null`}`,Pt=e=>`crumb:${e}`;function Ft(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 Z(){let{projectId:e}=je({from:`/project/$projectId`}),t=F(),n=w(k.projects.projectPage,{projectId:e});return(0,J.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:D()}):n===null?(0,J.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,J.jsx)(`h2`,{children:P()}),(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:y()}),(0,J.jsx)(G,{variant:`outline`,onClick:()=>void t({to:`/`}),children:m()})]}):(0,J.jsx)(It,{page:n})})}function It({page:e}){let t=F(),n=mt(),i=yt(),s=ht(),l=pt(),m=M(k.projects.renameProject),g=M(k.projects.setProjectColor),_=M(k.projects.deleteProject),y=M(k.projects.createProject),S=M(k.projects.moveProject),ie=M(k.projects.setProjectSidebar),ae=M(k.chats.moveChatToProject),oe=M(k.chats.reorderChat),se=M(k.projects.reorderProject),de=w(k.projects.projectTreeCount,{projectId:e.project._id}),[T,me]=(0,q.useState)(Mt),E=(0,q.useRef)(null),D=(0,q.useRef)(null),ve=At(_t(()=>{let e=E.current,t=D.current;if(e===null||t===null)return null;let n=vt(t,[e=>{e.setAttribute(`data-labels`,`on`),e.setAttribute(`data-moved`,`off`)},e=>{e.setAttribute(`data-labels`,`off`),e.setAttribute(`data-moved`,`off`)}],`oc-projpage__actions--measure`);return{available:e.clientWidth,required:n}},()=>[E.current],[ue(),e.project.sidebarHidden],{hysteresis:24})),O=ve.moved,A=e=>{localStorage.setItem(jt,e),me(e)},j=w(k.projects.folderColumns,T===`columns`?{projectId:e.project._id}:`skip`),P=w(k.projects.projectTreeList,T===`list`?{projectId:e.project._id}:`skip`),{c:I}=Te({from:`/project/$projectId`}),L=w(k.projects.listProjects,{}),R=w(k.chatReads.myBusyChats,{}),z=(0,q.useMemo)(()=>new Set(R??[]),[R]),{byChat:je}=Ne(R??null),Me=w(k.chatReads.myChatReads,{}),Le=(0,q.useMemo)(()=>Ot(e.chats,Me??[]),[e.chats,Me]),B=(0,q.useRef)(null),V=()=>[B.current],{startNewChat:We,picker:Qe}=qe(e=>void t({to:`/chat/$chatId`,params:{chatId:e}}),V),$e=()=>void We({projectId:e.project._id}),et=async()=>{let t=await s({title:C(),label:te(),placeholder:Ce(),confirmLabel:a(),returnFocus:V});t&&await y({name:t,parentId:e.project._id})},[K,wt]=(0,q.useState)(``),[Tt,Y]=(0,q.useState)(!1),[kt,X]=(0,q.useState)(e.project.name),[Nt,Pt]=(0,q.useState)(!1),[Z,It]=(0,q.useState)(``);(0,q.useEffect)(()=>{let e=setTimeout(()=>It(K.trim()),180);return()=>clearTimeout(e)},[K]);let Q=w(k.search.searchConversations,Z.length>=2?{query:Z,projectId:e.project._id}:`skip`),Bt=Fe(Ye(ze,{activationConstraint:{distance:4}}),Ye(Ze,{activationConstraint:{delay:250,tolerance:8}})),$=(0,q.useRef)(!1),Ht=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[Wt,Gt]=(0,q.useState)(null),Kt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=j?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||N()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(L??[]).find(t=>t._id===e)?.name??``}}return null},qt=e=>Gt(Kt(String(e.active.id))),Jt=(0,q.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=Pe(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=Pe(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=Pe(n(`crumb:`));if(a.length>0)return a;let o=Pe(n(`col:`));return o.length>0?o:Xe(n(t?`folder:`:`chat:`))},[]),Yt=t=>{if(T===`columns`){for(let e of j?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(T===`list`){let e=P?.chats.find(e=>e._id===t);return e?{list:P.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},Xt=t=>{if(T===`columns`){for(let e of j?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(T===`list`){let e=P?.folders.find(e=>e._id===t);if(!e||!P)return null;let n=e.parentId??P.rootId;return{list:He(P.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},Zt=async e=>{Gt(null),Ht();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),i=String(t.id),a=i.startsWith(`chat:`);try{let e=Ft(r);if(e!==void 0){if(a){let t=i.slice(5);await ae({chatId:t,projectId:e})}else{let t=i.slice(7);if(t===e)return;if(!Ee(L??[],t,e)){l.error(v());return}await S({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=Yt(t);if(!n)return;n.list.some(t=>t._id===e)||await ae({chatId:e,projectId:n.folderId});let a=Dt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await oe({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Xt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Ee(L??[],e,n.parentId)){l.error(v());return}await S({projectId:e,parentId:n.parentId})}let a=Dt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await se({projectId:e,...a});return}}catch{l.error(v())}},[,Qt]=(0,q.useState)(0);(0,q.useEffect)(()=>{let e=window.setInterval(()=>Qt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let $t=Date.now(),en=Ge(e.project),tn=Et(e.chats,K),nn=e.breadcrumb.slice(0,-1),rn=e=>()=>{$.current||e()};return(0,J.jsx)(Oe.Provider,{value:je,children:(0,J.jsxs)(Ue,{sensors:Bt,collisionDetection:Jt,onDragStart:qt,onDragEnd:Zt,children:[(0,J.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":en},children:[(0,J.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":u(),children:[nn.map(e=>(0,J.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,J.jsx)(Lt,{folderId:e._id,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:rn(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,J.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,J.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,J.jsxs)(`header`,{ref:E,className:`oc-projpage__head`,children:[(0,J.jsxs)(`div`,{className:`oc-projpage__titlebox`,children:[(0,J.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,J.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name})]}),e.project.sidebarHidden?(0,J.jsxs)(G,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:h(),onClick:()=>{ie({projectId:e.project._id,hidden:!1})},children:[(0,J.jsx)(st,{"aria-hidden":!0}),(0,J.jsx)(`span`,{children:d()}),(0,J.jsx)(ct,{"aria-hidden":!0})]}):null,(0,J.jsxs)(`div`,{ref:D,className:`oc-projpage__actions`,"data-labels":ve.labels?`on`:`off`,"data-moved":O?`on`:`off`,children:[(0,J.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":_e(),children:[(0,J.jsx)(G,{variant:T===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":_e(),title:_e(),"aria-pressed":T===`cards`,onClick:()=>A(`cards`),children:(0,J.jsx)(Ct,{})}),(0,J.jsx)(G,{variant:T===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":be(),title:be(),"aria-pressed":T===`columns`,onClick:()=>A(`columns`),children:(0,J.jsx)(xt,{})}),(0,J.jsx)(G,{variant:T===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":le(),title:le(),"aria-pressed":T===`list`,onClick:()=>A(`list`),children:(0,J.jsx)(lt,{})})]}),(0,J.jsxs)(G,{variant:`outline`,size:`sm`,className:`oc-projpage__actbtn`,"aria-label":p(),title:p(),onClick:$e,children:[(0,J.jsx)(Ie,{}),(0,J.jsx)(`span`,{className:`oc-projpage__actlabel`,children:p()})]}),(0,J.jsxs)(G,{variant:`outline`,size:`sm`,className:`oc-projpage__actbtn`,"aria-label":C(),title:C(),onClick:()=>void et(),children:[(0,J.jsx)(ke,{}),(0,J.jsx)(`span`,{className:`oc-projpage__actlabel`,children:C()})]}),(0,J.jsxs)(ot,{children:[(0,J.jsx)(tt,{asChild:!0,children:(0,J.jsx)(G,{ref:B,variant:`ghost`,size:`icon-sm`,"aria-label":fe(),children:(0,J.jsx)(nt,{})})}),(0,J.jsxs)(it,{align:`end`,className:`w-48`,children:[O?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(W,{onSelect:$e,children:[(0,J.jsx)(Ie,{}),` `,p()]}),(0,J.jsxs)(W,{onSelect:()=>void et(),children:[(0,J.jsx)(ke,{}),` `,C()]}),(0,J.jsx)(at,{})]}):null,(0,J.jsxs)(W,{onSelect:()=>{X(e.project.name),Y(!0)},children:[(0,J.jsx)(ut,{}),` `,b()]}),(0,J.jsxs)(W,{onSelect:()=>Pt(!0),children:[(0,J.jsx)(St,{}),` `,ee()]}),(0,J.jsx)(rt,{children:we()}),(0,J.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,J.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void g({projectId:e.project._id,color:null}),"aria-label":Se(),children:`✕`}),Ve.map(t=>(0,J.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void g({projectId:e.project._id,color:t.value})},t.value))]}),(0,J.jsx)(at,{}),(0,J.jsxs)(W,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let a=de?.folders??0,o=de?.chats??0;await n({title:ge({name:e.project.name}),description:bt({folders:a,chats:o,days:i}),confirmWord:x(),confirmLabel:xe(),destructive:!0})&&(await _({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,J.jsx)(dt,{}),` `,x()]})]})]})]})]}),T===`columns`?(0,J.jsx)(Ut,{data:j,currentId:e.project._id,busyIds:z,suppressClick:$,locateChatId:I??null}):T===`list`?(0,J.jsx)(Vt,{data:P,busyIds:z,suppressClick:$,locateChatId:I??null}):(0,J.jsxs)(J.Fragment,{children:[e.children.length>0?(0,J.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,J.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:f()}),(0,J.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,J.jsx)(U,{items:e.children.map(e=>`folder:${e._id}`),strategy:Je,children:e.children.map(t=>(0,J.jsx)(Rt,{child:t,parentId:e.project._id,now:$t,suppressClick:$},t._id))})})]}):null,(0,J.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,J.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,J.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ye()}),e.chats.length>0?(0,J.jsx)(ft,{value:K,onChange:e=>wt(e.target.value),placeholder:ne(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?re():r()}):tn.length===0&&(Q??[]).length===0?(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:c({term:K.trim()})}):(0,J.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,J.jsx)(U,{items:tn.map(e=>`chat:${e._id}`),strategy:H,children:tn.map(t=>(0,J.jsx)(zt,{chat:t,currentFolderId:e.project._id,now:$t,busy:z.has(t._id),unread:Le.has(t._id),locate:t._id===I,suppressClick:$},t._id))})})]}),Z.length>=2&&Q!==void 0?(0,J.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,J.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:o()}),Q.length===0?(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:c({term:Z})}):(0,J.jsx)(`ul`,{className:`oc-projpage__chats`,children:Q.map(e=>(0,J.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&Z&&De(e.messageId,Z),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,J.jsx)(Ae,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,J.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,J.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||ce()}),e.projectPath&&e.projectPath.length>1?(0,J.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,J.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,J.jsx)(gt,{open:Tt,onOpenChange:Y,title:pe(),canSubmit:kt.trim().length>0,onSubmit:async()=>{await m({projectId:e.project._id,name:kt.trim()}),Y(!1)},submitLabel:b(),children:(0,J.jsx)(ft,{value:kt,onChange:e=>X(e.target.value),autoFocus:!0})}),Nt?(0,J.jsx)(Ke,{open:Nt,onOpenChange:Pt,title:he(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void S({projectId:e.project._id,parentId:t})}):null,Qe]}),(0,J.jsx)(Be,{children:Wt?(0,J.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Wt.kind===`folder`?(0,J.jsx)(Re,{size:13,"aria-hidden":!0}):(0,J.jsx)(Ae,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:Wt.label})]}):null})]})})}function Lt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=L({id:Pt(e)});return(0,J.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Rt({child:e,parentId:t,now:n,suppressClick:r}){let i=F(),a=V({id:`folder:${e._id}`}),o=L({id:X(e._id)});return(0,J.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card oc-reveal-host`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":Ge(e),transform:R.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,J.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,J.jsx)(Re,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,J.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,J.jsx)(Tt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu oc-reveal oc-hit`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,J.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?s({count:e.folderCount})+` · `:``,S({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,J.jsx)(`span`,{className:`oc-projpage__cardage`,children:We(e.lastActivityAt,n)})]})}function Q({chat:e}){let t=M(k.chats.setChatSidebar),n=e.inSidebar?O():me();return(0,J.jsx)(G,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn oc-hit`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,J.jsx)(Le,{}):(0,J.jsx)(K,{})})}function zt({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=(0,q.useContext)(Oe).get(e._id),c=F(),l=B(e.color),u=V({id:`chat:${e._id}`}),d=Bt(a);return(0,J.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow oc-reveal-host`+(u.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:R.Transform.toString(u.transform),transition:u.transition},children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||c({to:`/chat/$chatId`,params:{chatId:e._id}})},...u.listeners,...u.attributes,children:[l?(0,J.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,J.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,J.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||N()}),e.pinned?(0,J.jsx)(I,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,J.jsx)(`span`,{className:`oc-projpage__chatage`,children:We(e.updatedAt,n)}),r?(0,J.jsx)(`span`,{className:z(s,A()).className,title:z(s,A()).label,"aria-label":z(s,A()).label}):null,i&&!r?(0,J.jsx)(`span`,{className:`oc-chatitem__unread`,title:de(),"aria-label":de()}):null]}),(0,J.jsx)(Q,{chat:e}),(0,J.jsx)(Y,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu oc-reveal oc-hit`})]})}function Bt(e){let t=(0,q.useRef)(null);return(0,q.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Vt({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,q.useState)(new Set),o=(0,q.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,J.jsx)(`p`,{className:`oc-projpage__hint`,children:D()});if(e===null)return null;let s=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),c=(a,l)=>{let u=o.get(a??e.rootId)??[],d=He(e.folders,a);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{items:u.map(e=>`chat:${e._id}`),strategy:H,children:u.map(e=>(0,J.jsx)(Ht,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,J.jsx)(U,{items:d.map(e=>`folder:${e._id}`),strategy:H,children:d.map(t=>(0,J.jsx)($,{folder:t,parentId:a??e.rootId,depth:l,folded:i.has(t._id),onToggle:()=>s(t._id),suppressClick:n,children:i.has(t._id)?null:c(t._id,l+1)},t._id))})]})};return(0,J.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&He(e.folders,null).length===0?(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:re()}):c(null,0)})}function $({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=F(),c=V({id:`folder:${e._id}`}),l=L({id:X(e._id)});return(0,J.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,J.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder oc-reveal-host`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":Ge(e),transform:R.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,J.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?ie():ae(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,J.jsx)(et,{size:13}):(0,J.jsx)($e,{size:13})}),(0,J.jsx)(Re,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,J.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,J.jsx)(Tt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu oc-reveal oc-hit`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function Ht({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=(0,q.useContext)(Oe).get(e._id),o=F(),s=V({id:`chat:${e._id}`}),c=Bt(r),l=B(e.color);return(0,J.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat oc-reveal-host`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:R.Transform.toString(s.transform),transition:s.transition},children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||o({to:`/chat/$chatId`,params:{chatId:e._id}})},...s.listeners,...s.attributes,children:[l?(0,J.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,J.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,J.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||N()}),n?(0,J.jsx)(`span`,{className:z(a,``).className,"aria-hidden":!0}):null]}),(0,J.jsx)(Y,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu oc-reveal oc-hit`}),(0,J.jsx)(Q,{chat:e})]})}function Ut({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]);let o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=_t(()=>{let e=o.current,t=s.current;return e===null||t===null?null:kt(e.clientWidth,t.getBoundingClientRect().width)},()=>[o.current],[e===void 0],{hysteresis:24})>0;if(e===void 0)return(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:D()});let l=c?e.columns.slice(-1):e.columns;return(0,J.jsxs)(`div`,{ref:o,className:`oc-projpage__colswrap`,children:[(0,J.jsxs)(`div`,{ref:s,className:`oc-projpage__colprobes`,"aria-hidden":!0,children:[(0,J.jsx)(`div`,{className:`oc-projpage__col`}),(0,J.jsx)(`div`,{className:`oc-projpage__col is-last`})]}),(0,J.jsx)(`div`,{className:`oc-projpage__cols`+(c?` oc-projpage__cols--one`:``),"data-layout":c?`one-level`:`columns`,ref:a,children:l.map(a=>(0,J.jsx)(Wt,{col:a,isLast:a===e.columns[e.columns.length-1],currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})]})}function Wt({col:e,isLast:t,currentId:n,busyIds:i,suppressClick:a,locateChatId:o}){let s=F(),c=L({id:Nt(e.folderId)});return(0,J.jsxs)(`div`,{ref:c.setNodeRef,className:`oc-projpage__col`+(c.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,J.jsx)(U,{items:e.folders.map(e=>`folder:${e._id}`),strategy:H,children:e.folders.map(t=>(0,J.jsx)(Gt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:a,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,J.jsx)(U,{items:e.chats.map(e=>`chat:${e._id}`),strategy:H,children:e.chats.map(t=>(0,J.jsx)(Kt,{chat:t,folderId:e.folderId,busy:i.has(t._id),locate:t._id===o,suppressClick:a,onOpen:()=>void s({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,J.jsx)(`p`,{className:`oc-projpage__colempty`,children:r()}):null]})}function Gt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=V({id:`folder:${e._id}`}),o=L({id:X(e._id)});return(0,J.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder oc-reveal-host`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":Ge(e),transform:R.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,J.jsx)(Re,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,J.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,J.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,J.jsx)(Tt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu oc-reveal oc-hit`,onOpen:i})]})}function Kt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=(0,q.useContext)(Oe).get(e._id),s=V({id:`chat:${e._id}`}),c=Bt(r),l=B(e.color);return(0,J.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat oc-reveal-host`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:R.Transform.toString(s.transform),transition:s.transition},children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...s.listeners,...s.attributes,children:[l?(0,J.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,J.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,J.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||N()}),n?(0,J.jsx)(`span`,{className:z(o,``).className,"aria-hidden":!0}):null]}),(0,J.jsx)(Y,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat oc-reveal oc-hit`}),(0,J.jsx)(Q,{chat:e})]})}export{Z as ProjectPage};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{BO as r,CO as i,Ck as a,DO as o,GO as s,HO as c,ID as l,IO as u,Is as d,JO as f,KO as p,LO as m,Ls as h,MO as g,NO as ee,PO as _,QO as v,RO as y,SO as b,TO as x,Tk as te,UO as ne,VO as re,WO as S,XO as ie,YO as ae,ZO as C,_O as oe,bO as se,bQ as w,dT as ce,ek as le,fQ as ue,fk as de,gO as T,gk as fe,hk as pe,ik as me,jO as he,k as E,lQ as D,lk as ge,nk as _e,ok as ve,qO as ye,rk as O,t as k,tk as be,uk as xe,vO as Se,vk as A,wk as Ce,xO as j,yO as we,yQ as M,yk as N,zO as P}from"./api-D64JTta1.js";import{n as Te,t as F}from"./useNavigate-D3GIoxyW.js";import{A as Ee,B as I,C as L,D as De,E as R,F as Oe,G as ke,H as Ae,I as z,J as je,K as Me,R as Ne,S as Pe,T as Fe,U as Ie,V as Le,W as Re,_ as ze,a as B,f as V,h as Be,i as Ve,j as He,m as Ue,n as We,o as Ge,p as H,r as Ke,s as U,t as qe,u as Je,w as Ye,x as Xe,y as Ze,z as Qe}from"./useStartNewChat-GAbwTTkG.js";import{r as $e}from"./dist-C0V3m4aH.js";import{t as et}from"./chevron-right-DkaFdk2G.js";import{c as tt,g as nt,i as rt,n as it,r as W,s as at,t as ot}from"./dropdown-menu-C5VrCGFe.js";import{n as st,t as ct}from"./eye-BU60QIdS.js";import{t as lt}from"./list-Bb0MIh_I.js";import{t as ut}from"./pencil-CHRZ3__S.js";import{t as dt}from"./trash-2-CqKGt3lC.js";import{t as G}from"./button-DeHzYOzP.js";import{t as ft}from"./input-CZ0jp9Rx.js";import"./convexApi-DxRiI80M.js";import{r as pt}from"./toast-DtA87VYn.js";import{n as mt,r as ht}from"./ConfirmDialog-Bfi4_Ti8.js";import{t as gt}from"./EntitySheet-D8Vdib4B.js";import{r as _t,t as vt}from"./measureClone-CHN0WNEY.js";import{r as yt,t as bt}from"./trashView-TIQT30u4.js";var xt=E(`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`}]]),St=E(`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`}]]),Ct=E(`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`}]]),K=E(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),q=t(e(),1),J=n();function wt({className:e}){return(0,J.jsx)(tt,{asChild:!0,children:(0,J.jsx)(G,{variant:`ghost`,size:`icon-xs`,"aria-label":i(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,J.jsx)(nt,{})})})}function Tt({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:o}){let s=M(k.projects.renameProject),c=M(k.projects.setProjectColor),l=M(k.projects.moveProject),u=M(k.projects.deleteProject),d=M(k.projects.createProject),f=mt(),p=yt(),m=ht(),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(t),[y,ne]=(0,q.useState)(!1),[re,S]=(0,q.useState)(!1),ie=w(k.projects.projectTreeCount,re?{projectId:e}:`skip`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(ot,{onOpenChange:e=>e&&S(!0),children:[(0,J.jsx)(wt,{className:i}),(0,J.jsxs)(it,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(W,{onSelect:()=>o(),children:[(0,J.jsx)(Me,{}),` `,ve()]}),(0,J.jsxs)(W,{onSelect:()=>{v(t),g(!0)},children:[(0,J.jsx)(ut,{}),` `,b()]}),(0,J.jsxs)(W,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await m({title:C(),label:te(),placeholder:Ce(),confirmLabel:a()});t&&await d({name:t,parentId:e})})},children:[(0,J.jsx)(ke,{}),` `,C()]}),(0,J.jsxs)(W,{onSelect:()=>ne(!0),children:[(0,J.jsx)(St,{}),` `,ee()]}),(0,J.jsx)(rt,{children:we()}),(0,J.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void c({projectId:e,color:null}),"aria-label":Se(),children:`✕`}),Ve.map(t=>(0,J.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void c({projectId:e,color:t.value})},t.value))]}),(0,J.jsx)(at,{}),(0,J.jsxs)(W,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=ie?.folders??0,r=ie?.chats??0;await f({title:ge({name:t}),description:bt({folders:n,chats:r,days:p}),confirmWord:x(),confirmLabel:xe(),destructive:!0})&&await u({projectId:e})})},children:[(0,J.jsx)(dt,{}),` `,x()]})]})]}),(0,J.jsx)(gt,{open:h,onOpenChange:g,title:pe(),canSubmit:_.trim().length>0,onSubmit:async()=>{await s({projectId:e,name:_.trim()}),g(!1)},submitLabel:b(),children:(0,J.jsx)(ft,{value:_,onChange:e=>v(e.target.value),autoFocus:!0})}),y?(0,J.jsx)(Ke,{open:y,onOpenChange:ne,title:he(),movingFolderId:e,currentId:r,onPick:t=>void l({projectId:e,parentId:t})}):null]})}function Y({chat:e,currentFolderId:t,className:n}){let r=M(k.chats.pinChat),i=M(k.chats.deleteChat),a=M(k.chats.renameChat),o=M(k.chats.setChatSidebar),s=M(k.chats.moveChatToProject),c=mt(),u=yt(),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(e.title??``),[h,ee]=(0,q.useState)(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(ot,{children:[(0,J.jsx)(wt,{className:n}),(0,J.jsxs)(it,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(W,{onSelect:()=>{m(e.title??``),f(!0)},children:[(0,J.jsx)(ut,{}),` `,b()]}),(0,J.jsxs)(W,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,J.jsx)(Qe,{}):(0,J.jsx)(I,{}),e.pinned?j():se()]}),(0,J.jsxs)(W,{onSelect:()=>ee(!0),children:[(0,J.jsx)(St,{}),` `,_()]}),e.pinned&&e.inSidebar?null:(0,J.jsxs)(W,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,J.jsx)(Le,{}):(0,J.jsx)(K,{}),e.inSidebar?O():me()]}),(0,J.jsx)(at,{}),(0,J.jsxs)(W,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await c({title:oe(),description:T({days:u}),confirmLabel:x(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,J.jsx)(dt,{}),` `,x()]})]})]}),(0,J.jsx)(gt,{open:d,onOpenChange:f,title:l(),canSubmit:p.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:b(),children:(0,J.jsx)(ft,{value:p,onChange:e=>m(e.target.value),autoFocus:!0})}),h?(0,J.jsx)(Ke,{open:h,onOpenChange:ee,title:g(),currentId:t,onPick:t=>void s({chatId:e._id,projectId:t})}):null]})}function Et(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function Dt(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 Ot(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}function kt(e,t){return{available:e,required:[t]}}function At(e){return{labels:e===0,moved:e>=2}}var jt=`oc.projpage.view`;function Mt(){let e=localStorage.getItem(jt);return e===`cards`||e===`list`?e:`columns`}var X=e=>`into:${e}`,Nt=e=>`col:${e??`null`}`,Pt=e=>`crumb:${e}`;function Ft(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 Z(){let{projectId:e}=je({from:`/project/$projectId`}),t=F(),n=w(k.projects.projectPage,{projectId:e});return(0,J.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:D()}):n===null?(0,J.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,J.jsx)(`h2`,{children:P()}),(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:y()}),(0,J.jsx)(G,{variant:`outline`,onClick:()=>void t({to:`/`}),children:m()})]}):(0,J.jsx)(It,{page:n})})}function It({page:e}){let t=F(),n=mt(),i=yt(),s=ht(),l=pt(),m=M(k.projects.renameProject),g=M(k.projects.setProjectColor),_=M(k.projects.deleteProject),y=M(k.projects.createProject),S=M(k.projects.moveProject),ie=M(k.projects.setProjectSidebar),ae=M(k.chats.moveChatToProject),oe=M(k.chats.reorderChat),se=M(k.projects.reorderProject),de=w(k.projects.projectTreeCount,{projectId:e.project._id}),[T,me]=(0,q.useState)(Mt),E=(0,q.useRef)(null),D=(0,q.useRef)(null),ve=At(_t(()=>{let e=E.current,t=D.current;if(e===null||t===null)return null;let n=vt(t,[e=>{e.setAttribute(`data-labels`,`on`),e.setAttribute(`data-moved`,`off`)},e=>{e.setAttribute(`data-labels`,`off`),e.setAttribute(`data-moved`,`off`)}],`oc-projpage__actions--measure`);return{available:e.clientWidth,required:n}},()=>[E.current],[ue(),e.project.sidebarHidden],{hysteresis:24})),O=ve.moved,A=e=>{localStorage.setItem(jt,e),me(e)},j=w(k.projects.folderColumns,T===`columns`?{projectId:e.project._id}:`skip`),P=w(k.projects.projectTreeList,T===`list`?{projectId:e.project._id}:`skip`),{c:I}=Te({from:`/project/$projectId`}),L=w(k.projects.listProjects,{}),R=w(k.chatReads.myBusyChats,{}),z=(0,q.useMemo)(()=>new Set(R??[]),[R]),{byChat:je}=Ne(R??null),Me=w(k.chatReads.myChatReads,{}),Le=(0,q.useMemo)(()=>Ot(e.chats,Me??[]),[e.chats,Me]),B=(0,q.useRef)(null),V=()=>[B.current],{startNewChat:We,picker:Qe}=qe(e=>void t({to:`/chat/$chatId`,params:{chatId:e}}),V),$e=()=>void We({projectId:e.project._id}),et=async()=>{let t=await s({title:C(),label:te(),placeholder:Ce(),confirmLabel:a(),returnFocus:V});t&&await y({name:t,parentId:e.project._id})},[K,wt]=(0,q.useState)(``),[Tt,Y]=(0,q.useState)(!1),[kt,X]=(0,q.useState)(e.project.name),[Nt,Pt]=(0,q.useState)(!1),[Z,It]=(0,q.useState)(``);(0,q.useEffect)(()=>{let e=setTimeout(()=>It(K.trim()),180);return()=>clearTimeout(e)},[K]);let Q=w(k.search.searchConversations,Z.length>=2?{query:Z,projectId:e.project._id}:`skip`),Bt=Fe(Ye(ze,{activationConstraint:{distance:4}}),Ye(Ze,{activationConstraint:{delay:250,tolerance:8}})),$=(0,q.useRef)(!1),Ht=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[Wt,Gt]=(0,q.useState)(null),Kt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=j?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||N()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(L??[]).find(t=>t._id===e)?.name??``}}return null},qt=e=>Gt(Kt(String(e.active.id))),Jt=(0,q.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=Pe(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=Pe(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=Pe(n(`crumb:`));if(a.length>0)return a;let o=Pe(n(`col:`));return o.length>0?o:Xe(n(t?`folder:`:`chat:`))},[]),Yt=t=>{if(T===`columns`){for(let e of j?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(T===`list`){let e=P?.chats.find(e=>e._id===t);return e?{list:P.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},Xt=t=>{if(T===`columns`){for(let e of j?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(T===`list`){let e=P?.folders.find(e=>e._id===t);if(!e||!P)return null;let n=e.parentId??P.rootId;return{list:He(P.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},Zt=async e=>{Gt(null),Ht();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),i=String(t.id),a=i.startsWith(`chat:`);try{let e=Ft(r);if(e!==void 0){if(a){let t=i.slice(5);await ae({chatId:t,projectId:e})}else{let t=i.slice(7);if(t===e)return;if(!Ee(L??[],t,e)){l.error(v());return}await S({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=Yt(t);if(!n)return;n.list.some(t=>t._id===e)||await ae({chatId:e,projectId:n.folderId});let a=Dt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await oe({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Xt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Ee(L??[],e,n.parentId)){l.error(v());return}await S({projectId:e,parentId:n.parentId})}let a=Dt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await se({projectId:e,...a});return}}catch{l.error(v())}},[,Qt]=(0,q.useState)(0);(0,q.useEffect)(()=>{let e=window.setInterval(()=>Qt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let $t=Date.now(),en=Ge(e.project),tn=Et(e.chats,K),nn=e.breadcrumb.slice(0,-1),rn=e=>()=>{$.current||e()};return(0,J.jsx)(Oe.Provider,{value:je,children:(0,J.jsxs)(Ue,{sensors:Bt,collisionDetection:Jt,onDragStart:qt,onDragEnd:Zt,children:[(0,J.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":en},children:[(0,J.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":u(),children:[nn.map(e=>(0,J.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,J.jsx)(Lt,{folderId:e._id,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:rn(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,J.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,J.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,J.jsxs)(`header`,{ref:E,className:`oc-projpage__head`,children:[(0,J.jsxs)(`div`,{className:`oc-projpage__titlebox`,children:[(0,J.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,J.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name})]}),e.project.sidebarHidden?(0,J.jsxs)(G,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:h(),onClick:()=>{ie({projectId:e.project._id,hidden:!1})},children:[(0,J.jsx)(st,{"aria-hidden":!0}),(0,J.jsx)(`span`,{children:d()}),(0,J.jsx)(ct,{"aria-hidden":!0})]}):null,(0,J.jsxs)(`div`,{ref:D,className:`oc-projpage__actions`,"data-labels":ve.labels?`on`:`off`,"data-moved":O?`on`:`off`,children:[(0,J.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":_e(),children:[(0,J.jsx)(G,{variant:T===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":_e(),title:_e(),"aria-pressed":T===`cards`,onClick:()=>A(`cards`),children:(0,J.jsx)(Ct,{})}),(0,J.jsx)(G,{variant:T===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":be(),title:be(),"aria-pressed":T===`columns`,onClick:()=>A(`columns`),children:(0,J.jsx)(xt,{})}),(0,J.jsx)(G,{variant:T===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":le(),title:le(),"aria-pressed":T===`list`,onClick:()=>A(`list`),children:(0,J.jsx)(lt,{})})]}),(0,J.jsxs)(G,{variant:`outline`,size:`sm`,className:`oc-projpage__actbtn`,"aria-label":p(),title:p(),onClick:$e,children:[(0,J.jsx)(Ie,{}),(0,J.jsx)(`span`,{className:`oc-projpage__actlabel`,children:p()})]}),(0,J.jsxs)(G,{variant:`outline`,size:`sm`,className:`oc-projpage__actbtn`,"aria-label":C(),title:C(),onClick:()=>void et(),children:[(0,J.jsx)(ke,{}),(0,J.jsx)(`span`,{className:`oc-projpage__actlabel`,children:C()})]}),(0,J.jsxs)(ot,{children:[(0,J.jsx)(tt,{asChild:!0,children:(0,J.jsx)(G,{ref:B,variant:`ghost`,size:`icon-sm`,"aria-label":fe(),children:(0,J.jsx)(nt,{})})}),(0,J.jsxs)(it,{align:`end`,className:`w-48`,children:[O?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(W,{onSelect:$e,children:[(0,J.jsx)(Ie,{}),` `,p()]}),(0,J.jsxs)(W,{onSelect:()=>void et(),children:[(0,J.jsx)(ke,{}),` `,C()]}),(0,J.jsx)(at,{})]}):null,(0,J.jsxs)(W,{onSelect:()=>{X(e.project.name),Y(!0)},children:[(0,J.jsx)(ut,{}),` `,b()]}),(0,J.jsxs)(W,{onSelect:()=>Pt(!0),children:[(0,J.jsx)(St,{}),` `,ee()]}),(0,J.jsx)(rt,{children:we()}),(0,J.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,J.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void g({projectId:e.project._id,color:null}),"aria-label":Se(),children:`✕`}),Ve.map(t=>(0,J.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void g({projectId:e.project._id,color:t.value})},t.value))]}),(0,J.jsx)(at,{}),(0,J.jsxs)(W,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let a=de?.folders??0,o=de?.chats??0;await n({title:ge({name:e.project.name}),description:bt({folders:a,chats:o,days:i}),confirmWord:x(),confirmLabel:xe(),destructive:!0})&&(await _({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,J.jsx)(dt,{}),` `,x()]})]})]})]})]}),T===`columns`?(0,J.jsx)(Ut,{data:j,currentId:e.project._id,busyIds:z,suppressClick:$,locateChatId:I??null}):T===`list`?(0,J.jsx)(Vt,{data:P,busyIds:z,suppressClick:$,locateChatId:I??null}):(0,J.jsxs)(J.Fragment,{children:[e.children.length>0?(0,J.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,J.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:f()}),(0,J.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,J.jsx)(U,{items:e.children.map(e=>`folder:${e._id}`),strategy:Je,children:e.children.map(t=>(0,J.jsx)(Rt,{child:t,parentId:e.project._id,now:$t,suppressClick:$},t._id))})})]}):null,(0,J.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,J.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,J.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ye()}),e.chats.length>0?(0,J.jsx)(ft,{value:K,onChange:e=>wt(e.target.value),placeholder:ne(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?re():r()}):tn.length===0&&(Q??[]).length===0?(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:c({term:K.trim()})}):(0,J.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,J.jsx)(U,{items:tn.map(e=>`chat:${e._id}`),strategy:H,children:tn.map(t=>(0,J.jsx)(zt,{chat:t,currentFolderId:e.project._id,now:$t,busy:z.has(t._id),unread:Le.has(t._id),locate:t._id===I,suppressClick:$},t._id))})})]}),Z.length>=2&&Q!==void 0?(0,J.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,J.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:o()}),Q.length===0?(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:c({term:Z})}):(0,J.jsx)(`ul`,{className:`oc-projpage__chats`,children:Q.map(e=>(0,J.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&Z&&De(e.messageId,Z),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,J.jsx)(Ae,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,J.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,J.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||ce()}),e.projectPath&&e.projectPath.length>1?(0,J.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,J.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,J.jsx)(gt,{open:Tt,onOpenChange:Y,title:pe(),canSubmit:kt.trim().length>0,onSubmit:async()=>{await m({projectId:e.project._id,name:kt.trim()}),Y(!1)},submitLabel:b(),children:(0,J.jsx)(ft,{value:kt,onChange:e=>X(e.target.value),autoFocus:!0})}),Nt?(0,J.jsx)(Ke,{open:Nt,onOpenChange:Pt,title:he(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void S({projectId:e.project._id,parentId:t})}):null,Qe]}),(0,J.jsx)(Be,{children:Wt?(0,J.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Wt.kind===`folder`?(0,J.jsx)(Re,{size:13,"aria-hidden":!0}):(0,J.jsx)(Ae,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:Wt.label})]}):null})]})})}function Lt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=L({id:Pt(e)});return(0,J.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Rt({child:e,parentId:t,now:n,suppressClick:r}){let i=F(),a=V({id:`folder:${e._id}`}),o=L({id:X(e._id)});return(0,J.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card oc-reveal-host`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":Ge(e),transform:R.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,J.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,J.jsx)(Re,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,J.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,J.jsx)(Tt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu oc-reveal oc-hit`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,J.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?s({count:e.folderCount})+` · `:``,S({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,J.jsx)(`span`,{className:`oc-projpage__cardage`,children:We(e.lastActivityAt,n)})]})}function Q({chat:e}){let t=M(k.chats.setChatSidebar),n=e.inSidebar?O():me();return(0,J.jsx)(G,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn oc-hit`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,J.jsx)(Le,{}):(0,J.jsx)(K,{})})}function zt({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=(0,q.useContext)(Oe).get(e._id),c=F(),l=B(e.color),u=V({id:`chat:${e._id}`}),d=Bt(a);return(0,J.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow oc-reveal-host`+(u.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:R.Transform.toString(u.transform),transition:u.transition},children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||c({to:`/chat/$chatId`,params:{chatId:e._id}})},...u.listeners,...u.attributes,children:[l?(0,J.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,J.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,J.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||N()}),e.pinned?(0,J.jsx)(I,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,J.jsx)(`span`,{className:`oc-projpage__chatage`,children:We(e.updatedAt,n)}),r?(0,J.jsx)(`span`,{className:z(s,A()).className,title:z(s,A()).label,"aria-label":z(s,A()).label}):null,i&&!r?(0,J.jsx)(`span`,{className:`oc-chatitem__unread`,title:de(),"aria-label":de()}):null]}),(0,J.jsx)(Q,{chat:e}),(0,J.jsx)(Y,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu oc-reveal oc-hit`})]})}function Bt(e){let t=(0,q.useRef)(null);return(0,q.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Vt({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,q.useState)(new Set),o=(0,q.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,J.jsx)(`p`,{className:`oc-projpage__hint`,children:D()});if(e===null)return null;let s=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),c=(a,l)=>{let u=o.get(a??e.rootId)??[],d=He(e.folders,a);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{items:u.map(e=>`chat:${e._id}`),strategy:H,children:u.map(e=>(0,J.jsx)(Ht,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,J.jsx)(U,{items:d.map(e=>`folder:${e._id}`),strategy:H,children:d.map(t=>(0,J.jsx)($,{folder:t,parentId:a??e.rootId,depth:l,folded:i.has(t._id),onToggle:()=>s(t._id),suppressClick:n,children:i.has(t._id)?null:c(t._id,l+1)},t._id))})]})};return(0,J.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&He(e.folders,null).length===0?(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:re()}):c(null,0)})}function $({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=F(),c=V({id:`folder:${e._id}`}),l=L({id:X(e._id)});return(0,J.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,J.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder oc-reveal-host`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":Ge(e),transform:R.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,J.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?ie():ae(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,J.jsx)(et,{size:13}):(0,J.jsx)($e,{size:13})}),(0,J.jsx)(Re,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,J.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,J.jsx)(Tt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu oc-reveal oc-hit`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function Ht({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=(0,q.useContext)(Oe).get(e._id),o=F(),s=V({id:`chat:${e._id}`}),c=Bt(r),l=B(e.color);return(0,J.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat oc-reveal-host`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:R.Transform.toString(s.transform),transition:s.transition},children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||o({to:`/chat/$chatId`,params:{chatId:e._id}})},...s.listeners,...s.attributes,children:[l?(0,J.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,J.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,J.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||N()}),n?(0,J.jsx)(`span`,{className:z(a,``).className,"aria-hidden":!0}):null]}),(0,J.jsx)(Y,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu oc-reveal oc-hit`}),(0,J.jsx)(Q,{chat:e})]})}function Ut({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]);let o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=_t(()=>{let e=o.current,t=s.current;return e===null||t===null?null:kt(e.clientWidth,t.getBoundingClientRect().width)},()=>[o.current],[e===void 0],{hysteresis:24})>0;if(e===void 0)return(0,J.jsx)(`p`,{className:`oc-projpage__hint`,children:D()});let l=c?e.columns.slice(-1):e.columns;return(0,J.jsxs)(`div`,{ref:o,className:`oc-projpage__colswrap`,children:[(0,J.jsxs)(`div`,{ref:s,className:`oc-projpage__colprobes`,"aria-hidden":!0,children:[(0,J.jsx)(`div`,{className:`oc-projpage__col`}),(0,J.jsx)(`div`,{className:`oc-projpage__col is-last`})]}),(0,J.jsx)(`div`,{className:`oc-projpage__cols`+(c?` oc-projpage__cols--one`:``),"data-layout":c?`one-level`:`columns`,ref:a,children:l.map(a=>(0,J.jsx)(Wt,{col:a,isLast:a===e.columns[e.columns.length-1],currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})]})}function Wt({col:e,isLast:t,currentId:n,busyIds:i,suppressClick:a,locateChatId:o}){let s=F(),c=L({id:Nt(e.folderId)});return(0,J.jsxs)(`div`,{ref:c.setNodeRef,className:`oc-projpage__col`+(c.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,J.jsx)(U,{items:e.folders.map(e=>`folder:${e._id}`),strategy:H,children:e.folders.map(t=>(0,J.jsx)(Gt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:a,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,J.jsx)(U,{items:e.chats.map(e=>`chat:${e._id}`),strategy:H,children:e.chats.map(t=>(0,J.jsx)(Kt,{chat:t,folderId:e.folderId,busy:i.has(t._id),locate:t._id===o,suppressClick:a,onOpen:()=>void s({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,J.jsx)(`p`,{className:`oc-projpage__colempty`,children:r()}):null]})}function Gt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=V({id:`folder:${e._id}`}),o=L({id:X(e._id)});return(0,J.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder oc-reveal-host`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":Ge(e),transform:R.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,J.jsx)(Re,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,J.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,J.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,J.jsx)(Tt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu oc-reveal oc-hit`,onOpen:i})]})}function Kt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=(0,q.useContext)(Oe).get(e._id),s=V({id:`chat:${e._id}`}),c=Bt(r),l=B(e.color);return(0,J.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat oc-reveal-host`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:R.Transform.toString(s.transform),transition:s.transition},children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...s.listeners,...s.attributes,children:[l?(0,J.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,J.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,J.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||N()}),n?(0,J.jsx)(`span`,{className:z(o,``).className,"aria-hidden":!0}):null]}),(0,J.jsx)(Y,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat oc-reveal oc-hit`}),(0,J.jsx)(Q,{chat:e})]})}export{Z as ProjectPage};