@lacneu/atrium 0.103.3 → 0.103.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.
- package/dist/assets/{AccessTab-DIDDsgPT.js → AccessTab-DmfPezpr.js} +1 -1
- package/dist/assets/{AdminSettings-RN5-vhFB.js → AdminSettings-DJrTOlAw.js} +1 -1
- package/dist/assets/{AdvancedFilter-D14bDnZM.js → AdvancedFilter-D4ja71eC.js} +1 -1
- package/dist/assets/{AgentFilesTab-CzlG0CZI.js → AgentFilesTab-DsXOfdpT.js} +1 -1
- package/dist/assets/{AnomaliesTab-DI6_13hV.js → AnomaliesTab-B1KVrvF9.js} +1 -1
- package/dist/assets/{AuditTab-CtudlEKL.js → AuditTab-BsxWGDzT.js} +1 -1
- package/dist/assets/{BridgeTab-D7vwrcIC.js → BridgeTab-CBhC6xPF.js} +1 -1
- package/dist/assets/{ChatDefaultsTab-C29wKwC9.js → ChatDefaultsTab-D84PkwGg.js} +1 -1
- package/dist/assets/{ConfirmDialog-DUn2vS3y.js → ConfirmDialog-BTkA9EEC.js} +1 -1
- package/dist/assets/{DataTableShell-DlkJe0in.js → DataTableShell-PyJIukLO.js} +1 -1
- package/dist/assets/{DeletedChatsTab-fwnKocED.js → DeletedChatsTab-CGzdG-VS.js} +1 -1
- package/dist/assets/{DetailChips-CYx7WQ4_.js → DetailChips-DJDPdjC6.js} +1 -1
- package/dist/assets/{EntitySheet-BHlTwSgy.js → EntitySheet-DZaO__IZ.js} +1 -1
- package/dist/assets/{FeedbacksTab-B6yZLeCu.js → FeedbacksTab-C56lOjnO.js} +1 -1
- package/dist/assets/{FieldLabel-rU6Ua6ki.js → FieldLabel-BW2ofPSg.js} +1 -1
- package/dist/assets/{FilesTab-CX2DlSAl.js → FilesTab-Bo8GHHoP.js} +1 -1
- package/dist/assets/{FilterBar-1CED41DE.js → FilterBar-vkX3BGGz.js} +1 -1
- package/dist/assets/{GroupsTab-XqYgSNbn.js → GroupsTab-UPA0jBCI.js} +1 -1
- package/dist/assets/{InstancesTab-k_xDuLN5.js → InstancesTab-Cz8ZV2Yl.js} +1 -1
- package/dist/assets/{IntegrationsTab-wQIr0NRQ.js → IntegrationsTab-DLf771n0.js} +1 -1
- package/dist/assets/{KnobRow-GQ-yjRd-.js → KnobRow-NCREweI3.js} +1 -1
- package/dist/assets/{KpiTab-Bqw-Ktyf.js → KpiTab-CKvYVEzA.js} +1 -1
- package/dist/assets/{PreferencesTab-B3IgHTIx.js → PreferencesTab-CCwKgY4H.js} +1 -1
- package/dist/assets/{ProjectPage-3f1bBxNm.js → ProjectPage-CVFZP9wJ.js} +1 -1
- package/dist/assets/{PromptInjectionsTab-C_NJLRVi.js → PromptInjectionsTab-BVyjgCHZ.js} +1 -1
- package/dist/assets/{RolesTab-BH7cwUSl.js → RolesTab-D2iPXBrM.js} +1 -1
- package/dist/assets/{ScheduledTab-DEPYdnlj.js → ScheduledTab-Cl9WgL-w.js} +1 -1
- package/dist/assets/{ServiceAccountsTab-BW_IZtpv.js → ServiceAccountsTab-B0XVQpdC.js} +1 -1
- package/dist/assets/{SubAgentReportsTab-tnmtmSGh.js → SubAgentReportsTab-xU0OVWGk.js} +1 -1
- package/dist/assets/{ThemeShowroom-CXAiw6jt.js → ThemeShowroom-D_wDwAQt.js} +1 -1
- package/dist/assets/{TimeRangePicker-DGRmfXqe.js → TimeRangePicker-B3Jl2mvx.js} +1 -1
- package/dist/assets/{TimezoneCombobox-DAhFeIgd.js → TimezoneCombobox-CWbHKOiS.js} +1 -1
- package/dist/assets/{TracesTab-peFnZ-Tw.js → TracesTab-DOy5oUHa.js} +1 -1
- package/dist/assets/{TrashTab-Hd_LRcrR.js → TrashTab-DFi1o7_K.js} +1 -1
- package/dist/assets/{UsersTab-CYiw3R0P.js → UsersTab-CIC9NMtm.js} +1 -1
- package/dist/assets/{VoiceTab-BIJNy57E.js → VoiceTab-DD0Y1Cqz.js} +1 -1
- package/dist/assets/{alert-dialog-BdTFPzVf.js → alert-dialog-D8JROLng.js} +1 -1
- package/dist/assets/{api-DNOgniXv.js → api-C9TZ4xjz.js} +1 -1
- package/dist/assets/{badge-D7TV9F5d.js → badge-UrSDbO1c.js} +1 -1
- package/dist/assets/{button-2XjWVeWK.js → button-DEKA-XdT.js} +1 -1
- package/dist/assets/{card-CB4fBpkx.js → card-CoPKGkaG.js} +1 -1
- package/dist/assets/check-DLsNvgAq.js +1 -0
- package/dist/assets/{checkbox-kFoJxcMJ.js → checkbox-Bbl8iiIs.js} +1 -1
- package/dist/assets/chevron-left-PEVM2kG9.js +1 -0
- package/dist/assets/chevron-right-DrdFABbO.js +1 -0
- package/dist/assets/chevron-up-DpsXK7Un.js +1 -0
- package/dist/assets/chevrons-up-down-roy0B5KU.js +1 -0
- package/dist/assets/{compatView-BsJMEfMH.js → compatView-DCGywg8d.js} +1 -1
- package/dist/assets/convexApi-D2VdPGGW.js +1 -0
- package/dist/assets/{copy-uA2kyeTq.js → copy-BzGjJBzv.js} +1 -1
- package/dist/assets/{cronDescribe-CWrWu4NY.js → cronDescribe-BP6ZrZEc.js} +1 -1
- package/dist/assets/{deliveryRecorder-D2L37goZ.js → deliveryRecorder-B3Trh8JA.js} +1 -1
- package/dist/assets/{dialog-Cw-buQuR.js → dialog-CHpclz_0.js} +1 -1
- package/dist/assets/{dispatchErrorInfo-rA4PAW2w.js → dispatchErrorInfo-B-CAt7GQ.js} +1 -1
- package/dist/assets/{dist-s7OhF_Fl.js → dist-B12lxLhp.js} +1 -1
- package/dist/assets/{dist-BuPfsZqj.js → dist-BwFz2rDM.js} +1 -1
- package/dist/assets/{dist-yuq8NbqZ.js → dist-CMQ8ZmbJ.js} +1 -1
- package/dist/assets/{dist-whjwthuB.js → dist-CQTmJUEo.js} +1 -1
- package/dist/assets/{dist-CjNu_N10.js → dist-CT8KFZnw.js} +1 -1
- package/dist/assets/{dist-vqdeesMI.js → dist-Col6E8px.js} +1 -1
- package/dist/assets/{download-7V52FIS0.js → download-C_249zkC.js} +1 -1
- package/dist/assets/{dropdown-menu-BaUA_yBi.js → dropdown-menu-DhetHpBb.js} +1 -1
- package/dist/assets/{eye-Dj_nvUMH.js → eye-0fRXv2uN.js} +1 -1
- package/dist/assets/{format-Dmvblmga.js → format-CE4Tb-R7.js} +1 -1
- package/dist/assets/{groupManageView-B0Fd_T1s.js → groupManageView-9KcuSXgR.js} +1 -1
- package/dist/assets/{index-C5sCqQtj.js → index-DT3YA902.js} +21 -21
- package/dist/assets/{input-BOl1ZpD6.js → input-BW0GOs_g.js} +1 -1
- package/dist/assets/{list-CgDCvRps.js → list-DJaWqeCP.js} +1 -1
- package/dist/assets/loader-circle-D_v0YERy.js +1 -0
- package/dist/assets/{lock-BlAOODxr.js → lock-Cai4iWP-.js} +1 -1
- package/dist/assets/{pencil-C9Bd090l.js → pencil-DPtIvpHp.js} +1 -1
- package/dist/assets/plus-DYL_4aqG.js +1 -0
- package/dist/assets/{popover-BHbAt2S-.js → popover-rh1_TqjX.js} +1 -1
- package/dist/assets/roleDescriptions-heGPDkTY.js +1 -0
- package/dist/assets/rotate-ccw-Bs40VcST.js +1 -0
- package/dist/assets/{search-CU2PGfXc.js → search-B-R9kd8o.js} +1 -1
- package/dist/assets/{select-CYo6IZR2.js → select-CeQpPnet.js} +1 -1
- package/dist/assets/{server-BJJ3cVit.js → server-D8sEPnaP.js} +1 -1
- package/dist/assets/{speech-DCWd2QRW.js → speech-C9rnmV3n.js} +1 -1
- package/dist/assets/{star-DBwak3-9.js → star-DgW-1Cj9.js} +1 -1
- package/dist/assets/{switch-B0io8PF7.js → switch-BZom6_SV.js} +1 -1
- package/dist/assets/{table-C6NnEhxy.js → table-CGUWJWZI.js} +1 -1
- package/dist/assets/{tabs-DiirWTCN.js → tabs-xefd1SeB.js} +1 -1
- package/dist/assets/{toast-DN6P_at0.js → toast-pKIYRpST.js} +1 -1
- package/dist/assets/{tooltip-6h3mm-V5.js → tooltip-B27138uH.js} +1 -1
- package/dist/assets/{trash-2-BmifkPwA.js → trash-2-B3-1X1oZ.js} +1 -1
- package/dist/assets/{trashPage-DsBekB4q.js → trashPage-BNLG_tTi.js} +1 -1
- package/dist/assets/{trashView-Cd0pvgnM.js → trashView-CcPdpr1y.js} +1 -1
- package/dist/assets/{triangle-alert-DjNOW8SM.js → triangle-alert-uaH9SXmM.js} +1 -1
- package/dist/assets/{usageView-DsAOFF89.js → usageView-DIbIuJOR.js} +1 -1
- package/dist/assets/{useChart-CvUnULHg.js → useChart-DLAE1JpY.js} +1 -1
- package/dist/assets/{useFontScale-T-slFQPF.js → useFontScale-CWLfjbAm.js} +1 -1
- package/dist/assets/{useStartNewChat-Bg4hLp3d.js → useStartNewChat-BxlZDRnF.js} +1 -1
- package/dist/assets/{use_paginated_query-CrHKVq5I.js → use_paginated_query-DVbu_Fe7.js} +1 -1
- package/dist/assets/{users-4cOOjyOf.js → users-BUeuEf6k.js} +1 -1
- package/dist/assets/x-E03nFsG9.js +1 -0
- package/dist/index.html +54 -54
- package/package.json +1 -1
- package/dist/assets/check-ByAmVIRT.js +0 -1
- package/dist/assets/chevron-left-SzhbAbEJ.js +0 -1
- package/dist/assets/chevron-right-9DjIYDNR.js +0 -1
- package/dist/assets/chevron-up-uykFYjFv.js +0 -1
- package/dist/assets/chevrons-up-down-C45M3ZYP.js +0 -1
- package/dist/assets/convexApi-4XI9Ua6G.js +0 -1
- package/dist/assets/loader-circle-D-oC88g9.js +0 -1
- package/dist/assets/plus-1T1-a2EN.js +0 -1
- package/dist/assets/roleDescriptions-DIDUvLuU.js +0 -1
- package/dist/assets/rotate-ccw-WHZ3xMbc.js +0 -1
- package/dist/assets/x-xmpoCnTJ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AX as r,BX as ee,Bp as i,CX as te,DX as ne,EX as re,EZ as ie,FX as a,FZ as ae,GX as oe,HX as se,IX as o,IZ as s,KX as c,LH as l,LX as ce,MX as u,NX as d,OX as le,OZ as ue,PX as f,RX as de,SX as fe,TX as pe,UX as p,VX as me,Vp as m,WX as h,_X as he,bX as g,fX as ge,gX as _e,hX as ve,jX as _,kX as ye,mX as be,pX as xe,qX as v,t as y,vX as b,wX as x,xX as S,yX as C,zX as w}from"./api-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AX as r,BX as ee,Bp as i,CX as te,DX as ne,EX as re,EZ as ie,FX as a,FZ as ae,GX as oe,HX as se,IX as o,IZ as s,KX as c,LH as l,LX as ce,MX as u,NX as d,OX as le,OZ as ue,PX as f,RX as de,SX as fe,TX as pe,UX as p,VX as me,Vp as m,WX as h,_X as he,bX as g,fX as ge,gX as _e,hX as ve,jX as _,kX as ye,mX as be,pX as xe,qX as v,t as y,vX as b,wX as x,xX as S,yX as C,zX as w}from"./api-C9TZ4xjz.js";import{c as T,g as E,n as D,r as O,t as k}from"./dropdown-menu-DhetHpBb.js";import{t as A}from"./download-C_249zkC.js";import{t as j}from"./checkbox-Bbl8iiIs.js";import{t as M}from"./rotate-ccw-Bs40VcST.js";import{t as Se}from"./trash-2-B3-1X1oZ.js";import{a as N,i as P,n as F,r as I,t as L}from"./select-CeQpPnet.js";import{a as Ce,c as we,i as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae}from"./alert-dialog-D8JROLng.js";import{t as R}from"./button-DEKA-XdT.js";import"./convexApi-D2VdPGGW.js";import{r as je}from"./toast-pKIYRpST.js";import{t as z}from"./badge-UrSDbO1c.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-CGUWJWZI.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return o();case`audio`:return a();case`video`:return f();case`pdf`:return d();case`document`:return u();case`archive`:return _();default:return r()}}function q(){let[e,t]=(0,U.useState)(G),[n,r]=(0,U.useState)(G),[a,o]=(0,U.useState)(G),[u,d]=(0,U.useState)(G),[f,_]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=ae(y.files.softDelete),Y=je();function Ie(){t(G),r(G),o(G),d(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(C())}catch(e){Y.error(b(),e)}}let X=s(y.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:a===G?void 0:a,category:u===G?void 0:u,includeAutoGenerated:f||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(ue(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:ie()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||a!==G||u!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:v()}),(0,W.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,W.jsxs)(L,{value:e,onValueChange:t,children:[(0,W.jsx)(P,{size:`sm`,"aria-label":c(),children:(0,W.jsx)(N,{})}),(0,W.jsxs)(F,{children:[(0,W.jsx)(I,{value:G,children:oe()}),(0,W.jsx)(I,{value:`inbound`,children:h()}),(0,W.jsx)(I,{value:`outbound`,children:p()})]})]}),(0,W.jsxs)(L,{value:n,onValueChange:r,children:[(0,W.jsx)(P,{size:`sm`,"aria-label":se(),children:(0,W.jsx)(N,{})}),(0,W.jsxs)(F,{children:[(0,W.jsx)(I,{value:G,children:me()}),Q.chats.map(e=>(0,W.jsx)(I,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(L,{value:a,onValueChange:o,children:[(0,W.jsx)(P,{size:`sm`,"aria-label":ee(),children:(0,W.jsx)(N,{})}),(0,W.jsxs)(F,{children:[(0,W.jsx)(I,{value:G,children:w()}),Q.instances.map(e=>(0,W.jsx)(I,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(L,{value:u,onValueChange:d,children:[(0,W.jsx)(P,{size:`sm`,"aria-label":de(),children:(0,W.jsx)(N,{})}),(0,W.jsxs)(F,{children:[(0,W.jsx)(I,{value:G,children:ce()}),Q.categories.map(e=>(0,W.jsx)(I,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(j,{checked:f,onCheckedChange:e=>_(e===!0),"aria-label":m()}),(0,W.jsx)(`span`,{children:m()})]}),$?(0,W.jsxs)(R,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,W.jsx)(M,{size:14,"aria-hidden":!0}),fe()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?xe():be()}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Pe,{children:[(0,W.jsx)(Me,{children:(0,W.jsxs)(V,{children:[(0,W.jsx)(B,{children:ye()}),(0,W.jsx)(B,{children:le()}),(0,W.jsx)(B,{children:ne()}),(0,W.jsx)(B,{children:re()}),(0,W.jsx)(B,{children:pe()}),(0,W.jsx)(B,{className:`text-right`,children:x()})]})}),(0,W.jsx)(Ne,{children:Z.map(e=>(0,W.jsxs)(V,{children:[(0,W.jsxs)(H,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,W.jsx)(z,{variant:`outline`,style:{marginLeft:6},children:i()}):null]}),(0,W.jsx)(H,{title:e.mimeType,children:K(e.category)}),(0,W.jsx)(H,{children:(0,W.jsx)(z,{variant:`secondary`,children:e.direction===`inbound`?h():p()})}),(0,W.jsx)(H,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,W.jsx)(H,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,W.jsx)(H,{className:`text-right`,children:(0,W.jsxs)(k,{children:[(0,W.jsx)(T,{asChild:!0,children:(0,W.jsx)(R,{variant:`ghost`,size:`icon`,"aria-label":S(),children:(0,W.jsx)(E,{size:16})})}),(0,W.jsxs)(D,{align:`end`,children:[e.url?(0,W.jsx)(O,{asChild:!0,children:(0,W.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(A,{size:14}),te()]})}):(0,W.jsxs)(O,{disabled:!0,children:[(0,W.jsx)(A,{size:14}),ve()]}),(0,W.jsxs)(O,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(Se,{size:14}),g()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:ge({cap:Be})}):null]}),(0,W.jsx)(Ae,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(Te,{children:[(0,W.jsxs)(ke,{children:[(0,W.jsx)(we,{children:he()}),(0,W.jsx)(Ce,{children:_e()})]}),(0,W.jsxs)(De,{children:[(0,W.jsx)(Oe,{children:l()}),(0,W.jsx)(Ee,{onClick:()=>void Le(),children:g()})]})]})})]})}export{q as FilesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{_w as r,gw as i}from"./api-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{_w as r,gw as i}from"./api-C9TZ4xjz.js";import{t as a}from"./search-B-R9kd8o.js";import{t as o}from"./rotate-ccw-Bs40VcST.js";import{t as s}from"./button-DEKA-XdT.js";import{t as c}from"./input-BW0GOs_g.js";import{t as l}from"./TimeRangePicker-B3Jl2mvx.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{$x as r,Ab as i,Ax as a,Bb as o,Bx as s,Cb as c,Cx as l,Db as u,Dx as d,E as f,Eb as p,Ex as m,FZ as h,Fb as g,Fx as _,Gb as v,Gx as y,Hb as b,Hx as x,IZ as S,Ib as C,Jb as w,Jx as ee,Kb as T,Kx as E,Lb as D,Mb as te,Mx as ne,Nb as O,Nx as k,Ob as re,Ox as A,Pb as ie,Px as ae,Qx as j,Rb as M,Sb as oe,Sx as se,Tb as N,Tx as ce,Ub as P,Ux as le,Vb as F,Vx as ue,Wb as de,Wx as fe,Xb as I,Xx as L,Yb as pe,Yx as me,Zx as R,_S as he,_b as z,_x as ge,aS as _e,ab as ve,ax as ye,bb as be,bx as xe,cS as Se,cx as Ce,dS as we,dx as Te,eS as Ee,ex as De,fS as Oe,fx as ke,gS as Ae,gb as je,gx as Me,hS as Ne,hb as Pe,hx as Fe,iS as Ie,ib as Le,ix as Re,jb as ze,jx as Be,kb as Ve,kx as He,lS as Ue,lx as We,mS as Ge,mb as Ke,mx as qe,nS as Je,nx as Ye,oS as Xe,ob as Ze,ox as Qe,pS as $e,pb as et,px as B,qb as tt,qx as nt,rS as rt,rx as it,sS as at,sb as ot,sx as st,t as V,tS as ct,tx as lt,uS as ut,ux as dt,vb as ft,vx as pt,wb as mt,wx as ht,xb as gt,xx as _t,yb as vt,yx as yt,zb as bt,zx as xt}from"./api-DNOgniXv.js";import{t as St}from"./chevron-left-SzhbAbEJ.js";import{t as Ct}from"./chevron-right-9DjIYDNR.js";import{t as H}from"./checkbox-kFoJxcMJ.js";import{t as wt}from"./server-BJJ3cVit.js";import{i as Tt,n as Et,r as Dt,t as Ot}from"./users-4cOOjyOf.js";import{t as U}from"./star-DBwak3-9.js";import{t as kt}from"./x-xmpoCnTJ.js";import{a as At,i as jt,n as Mt,r as Nt,t as Pt}from"./select-CYo6IZR2.js";import{i as Ft,n as It,r as Lt,t as Rt}from"./tabs-DiirWTCN.js";import{t as W}from"./button-2XjWVeWK.js";import{t as G}from"./input-BOl1ZpD6.js";import"./convexApi-4XI9Ua6G.js";import{r as K}from"./toast-DN6P_at0.js";import{t as q}from"./badge-D7TV9F5d.js";import{a as zt,n as Bt,o as Vt,r as Ht,t as Ut}from"./dialog-Cw-buQuR.js";import{t as Wt}from"./appHost-CH3EGcJw.js";import{n as Gt}from"./ConfirmDialog-DUn2vS3y.js";import{t as Kt}from"./EntitySheet-BHlTwSgy.js";import{a as J,c as qt,d as Jt,f as Yt,i as Xt,l as Zt,n as Qt,o as $t,r as en,t as Y,u as tn}from"./groupManageView-B0Fd_T1s.js";import{t as nn}from"./FilterBar-1CED41DE.js";import{t as rn}from"./DataTableShell-DlkJe0in.js";import{t as X}from"./DetailChips-CYx7WQ4_.js";var an=f(`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`}]]),Z=t(e(),1),Q=n(),on={name:``,description:``};function sn(){let e=S(V.groups.listGroups,{}),t=S(V.me.getMe,{host:Wt})?.role===`admin`,n=h(V.groups.createGroup),i=h(V.groups.updateGroup),a=h(V.groups.deleteGroup),o=Gt(),s=K(),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(on),[m,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(``),y=(0,Z.useMemo)(()=>{if(!e)return e;let t=_.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,_]);function b(){d(null),p(on),l(!0)}function x(e){d(e),p({name:e.name,description:e.description??``}),l(!0)}async function C(){try{u?await i({groupId:u._id,name:f.name,description:f.description}):await n({name:f.name,description:f.description||void 0}),p(on),d(null),l(!1)}catch(e){s.error(ke(),e)}}async function w(e){if(await o({title:j({name:e.name}),description:R(),confirmWord:e.name,confirmLabel:L(),cancelLabel:Ie(),destructive:!0}))try{await a({groupId:e._id})}catch(e){s.error(Te(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Ae()}),t?(0,Q.jsx)(pn,{}):null,(0,Q.jsx)(nn,{q:_,onQChange:v,onReset:()=>v(``),canReset:_!==``,searchPlaceholder:Ue()}),(0,Q.jsx)(rn,{title:he(),rows:y,addLabel:Ne(),onAdd:t?b:void 0,emptyHint:Ge(),columns:[{header:$e(),cell:e=>e.name,sort:e=>e.name},{header:Oe(),cell:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ot,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,Q.jsx)(Tt,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),e.pendingInviteCount>0?(0,Q.jsx)(q,{variant:`secondary`,children:De({count:String(e.pendingInviteCount)})}):null]}),sort:e=>e.memberCount},{header:we(),cell:e=>(0,Q.jsx)(X,{icon:(0,Q.jsx)(wt,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:ut(),cell:e=>(0,Q.jsx)(X,{icon:(0,Q.jsx)(an,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,Q.jsx)(U,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:Se(),onSelect:()=>g({groupId:e._id,name:e.name})},...t?[{label:at(),onSelect:()=>x(e)},{label:Xe(),variant:`destructive`,onSelect:()=>void w(e)}]:[]]}),(0,Q.jsx)(Kt,{open:c,onOpenChange:l,title:u?Je():rt(),description:ct(),canSubmit:!!f.name.trim(),onSubmit:C,submitLabel:_e(),children:(0,Q.jsxs)(`div`,{className:`oc-form`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:Ee()}),(0,Q.jsx)(G,{value:f.name,onChange:e=>p({...f,name:e.target.value})})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:r()}),(0,Q.jsx)(G,{value:f.description,onChange:e=>p({...f,description:e.target.value})})]})]})}),(0,Q.jsx)(ln,{groupId:m?.groupId??null,groupName:m?.name??``,open:m!==null,onOpenChange:e=>{e||g(null)}})]})}var cn=8;function $({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,Q.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,Q.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,Q.jsx)(St,{size:14,"aria-hidden":!0}),ue()]}),(0,Q.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":xt({page:e,pages:t}),children:[e,` / `,t]}),(0,Q.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[s(),(0,Q.jsx)(Ct,{size:14,"aria-hidden":!0})]})]})}function ln({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=S(V.groups.getGroup,n&&e?{groupId:e}:`skip`),o=i?.viewerIsAdmin===!0,s=S(V.groups.listAssignableInstances,n&&e?{groupId:e}:`skip`),c=S(V.groups.listAssignableUsers,n&&o?{}:`skip`),l=h(V.groups.addMember),u=h(V.groups.removeMember),d=h(V.groups.bulkSetMembers),f=h(V.groups.setGroupManager),p=K(),[m,b]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),[D,te]=(0,Z.useState)(`members`),[ne,O]=(0,Z.useState)(1),[re,A]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(new Set),j=(0,Z.useRef)(null),M=(0,Z.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),oe=(0,Z.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),se=(0,Z.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.restricted).map(e=>e.userId)),[i]),N=(0,Z.useMemo)(()=>new Set((i?.agents??[]).map(e=>Y(e.instanceName,e.agentId))),[i]),P=(0,Z.useMemo)(()=>{let e=(i?.agents??[]).find(e=>e.isDefault);return e?Y(e.instanceName,e.agentId):null},[i]);(0,Z.useEffect)(()=>{b(``),w(``),te(`members`),O(1),A(null),j.current=null},[n,e]),(0,Z.useEffect)(()=>{O(1)},[m]),(0,Z.useEffect)(()=>{n&&i&&e&&j.current!==e&&(j.current=e,ae(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let F=(0,Z.useMemo)(()=>c?Xt(c,m,ie):[],[c,m,ie]);async function ue(t,n){if(e)try{n?await u({groupId:e,userId:t}):await l({groupId:e,userId:t})}catch(e){p.error(dt(),J(e))}}async function I(t,n){if(e)try{await f({groupId:e,userId:t,manager:!n})}catch(e){p.error(qe(),e)}}let L=Jt(F,e=>M.has(e.userId)),pe=F.filter(e=>M.has(e.userId)).length,R=Zt(F,ne,cn);async function he(){if(!e||F.length===0)return;let t=F.map(e=>e.userId);try{await d({groupId:e,userIds:t,member:L!==`all`})}catch(e){p.error(dt(),J(e))}}let z=(e,t)=>(0,Q.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7`,"aria-label":v({user:t}),title:v({user:t}),onClick:()=>A({userId:e,label:t}),children:[(0,Q.jsx)(Dt,{size:13,"aria-hidden":!0}),T()]});return(0,Q.jsx)(Ut,{open:n,onOpenChange:r,children:(0,Q.jsxs)(Bt,{className:`oc-access`,children:[(0,Q.jsxs)(zt,{children:[(0,Q.jsx)(Vt,{children:me({name:t})}),(0,Q.jsx)(Ht,{children:i&&!o?Ce():ee()})]}),(0,Q.jsxs)(Rt,{value:D,onValueChange:te,className:`oc-access__tabs`,children:[(0,Q.jsxs)(Lt,{className:`w-full`,children:[(0,Q.jsxs)(Ft,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Ot,{size:13,"aria-hidden":!0}),nt(),i?(0,Q.jsx)(q,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,Q.jsxs)(Ft,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(wt,{size:13,"aria-hidden":!0}),y(),i?(0,Q.jsx)(q,{variant:`secondary`,className:`oc-access__tabcount`,children:N.size}):null]}),(0,Q.jsxs)(Ft,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(an,{size:13,"aria-hidden":!0}),ce(),i?(0,Q.jsx)(q,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,Q.jsx)(It,{value:`members`,children:i===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:k()}):o?c===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:k()}):c.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Be()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(G,{value:m,onChange:e=>b(e.target.value),placeholder:E(),className:`oc-access__search`}),F.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:le()}):(0,Q.jsxs)(Q.Fragment,{children:[F.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(H,{checked:L===`all`||L===`some`&&`indeterminate`,onCheckedChange:()=>void he(),"aria-label":x()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:x()}),(0,Q.jsxs)(q,{variant:`outline`,className:`oc-access__count`,children:[pe,` / `,F.length]})]}):null,(0,Q.jsx)(`div`,{className:`oc-access__list`,children:R.pageItems.map(e=>{let t=M.has(e.userId),n=Yt(e),r=oe.has(e.userId);return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(H,{checked:t,onCheckedChange:()=>void ue(e.userId,t),"aria-label":_({user:n.primary})}),(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,Q.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),t&&se.has(e.userId)?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:de()}):null,(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:tn(e.role)}),t?z(e.userId,n.primary):null,(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:t?(0,Q.jsx)(W,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?Fe():Me(),title:r?Fe():Me(),onClick:()=>void I(e.userId,r),children:(0,Q.jsx)(Tt,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,Q.jsx)($,{page:R.page,pageCount:R.pageCount,onPage:O})]})]}):e?(0,Q.jsx)(un,{groupId:e,members:i.members,agentsButton:z}):null}),(0,Q.jsxs)(It,{value:`agents`,children:[i&&!o?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:g()}):null,s===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:k()}):s.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:a()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(G,{value:C,onChange:e=>w(e.target.value),placeholder:fe(),className:`oc-access__search`}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:s.map(t=>(0,Q.jsx)(fn,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:N,defaultKey:P,viewerIsAdmin:o,query:C},`${e}-${t._id}`))})]})]}),(0,Q.jsx)(It,{value:`charts`,children:(0,Q.jsx)(mn,{groupId:e})})]}),(0,Q.jsx)(dn,{groupId:e,member:re,onOpenChange:e=>{e||A(null)}})]})})}function un({groupId:e,members:t,agentsButton:n}){let r=S(V.groupInvites.listGroupInviteRequests,{groupId:e}),i=h(V.groupInvites.requestGroupInvite),a=h(V.groups.removeMember),o=Gt(),s=K(),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(1),f=Zt(t,u,cn);async function p(t){t.preventDefault();let n=c.trim();if(n)try{await i({groupId:e,email:n}),l(``),s.success(it())}catch(e){s.error(Ye(),e)}}async function m(t,n){if(await o({title:I({user:n}),description:w({user:n}),confirmLabel:tt(),cancelLabel:Ie(),destructive:!0}))try{await a({groupId:e,userId:t})}catch(e){s.error(dt(),J(e))}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`form`,{className:`oc-access__invite`,onSubmit:e=>void p(e),children:[(0,Q.jsx)(G,{type:`email`,value:c,onChange:e=>l(e.target.value),placeholder:ye(),"aria-label":st()}),(0,Q.jsxs)(W,{type:`submit`,size:`sm`,disabled:!c.trim(),children:[(0,Q.jsx)(Et,{size:14,"aria-hidden":!0}),Re()]})]}),(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Qe()}),t.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:P()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:f.pageItems.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.label,children:e.label}),e.restricted?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:de()}):null,n(e.userId,e.label),(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:e.manager?(0,Q.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":ge(),title:ge(),children:(0,Q.jsx)(Tt,{size:15,"aria-hidden":!0})}):null}),(0,Q.jsx)(W,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.manager||e.lastGroup,"aria-label":I({user:e.label}),title:e.manager?pe():e.lastGroup?et():I({user:e.label}),onClick:()=>void m(e.userId,e.label),children:(0,Q.jsx)(kt,{size:14,"aria-hidden":!0})})]},e.userId))}),(0,Q.jsx)($,{page:f.page,pageCount:f.pageCount,onPage:d})]}),r!==void 0&&r.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-access__subhead`,children:lt()}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:r.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,Q.jsx)(q,{variant:e.status===`pending`?`secondary`:`outline`,className:`oc-access__role`,children:$t(e.status)})]},e._id))})]}):null]})}function dn({groupId:e,member:t,onOpenChange:n}){let r=S(V.groups.getMemberAgentSettings,e&&t?{groupId:e,userId:t.userId}:`skip`),i=h(V.groups.setMemberAgents),a=h(V.groups.setMemberDefaultAgent),o=K();async function s(e){try{await e()}catch(e){o.error(Ke(),e)}}let l=r?.agents??[],u=new Map(l.map(e=>[Y(e.instanceName,e.agentId),e])),d=[...u.keys()],f=new Set(l.filter(e=>e.allowed).map(e=>Y(e.instanceName,e.agentId)));function p(n){if(!e||!t||!r)return;let a=qt(d,f,r.restricted,n).map(e=>{let t=u.get(e);return{instanceName:t.instanceName,agentId:t.agentId}});s(()=>i({groupId:e,userId:t.userId,agents:a}))}return(0,Q.jsx)(Ut,{open:t!==null,onOpenChange:n,children:(0,Q.jsxs)(Bt,{className:`oc-access`,children:[(0,Q.jsxs)(zt,{children:[(0,Q.jsx)(Vt,{children:c({user:t?.label??``})}),(0,Q.jsx)(Ht,{children:oe()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:k()}):r===null||l.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Pe()}):(0,Q.jsxs)(Q.Fragment,{children:[r.settable?null:(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Le()}),r.adminNarrowed?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ot()}):null,r.restrictedByAdmin&&!r.viewerIsAdmin?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ve()}):null,(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,children:r.restricted?be():gt()}),r.restricted?(0,Q.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,disabled:!r.settable||r.restrictedByAdmin&&!r.viewerIsAdmin,onClick:()=>e&&t?void s(()=>i({groupId:e,userId:t.userId,agents:null})):void 0,children:vt()}):null]}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:l.map(n=>{let i=Y(n.instanceName,n.agentId),o=n.displayName??n.agentId;return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(H,{checked:n.allowed,disabled:!r.settable||r.restrictedByAdmin&&!r.viewerIsAdmin&&!n.allowed,onCheckedChange:()=>p(i),"aria-label":ft({name:o})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:o,children:o}),n.limitedByAdmin?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:Ze()}):null,n.state===`deleted`?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__gone`,children:m()}):null,n.allowed?n.isMemberDefault?(0,Q.jsx)(W,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,disabled:!r.settable,"aria-label":z(),title:z(),onClick:()=>e&&t?void s(()=>a({groupId:e,userId:t.userId,agent:null})):void 0,children:(0,Q.jsx)(U,{size:14,fill:`currentColor`})}):(0,Q.jsx)(W,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,disabled:!r.settable,"aria-label":je(),title:je(),onClick:()=>e&&t?void s(()=>a({groupId:e,userId:t.userId,agent:{instanceName:n.instanceName,agentId:n.agentId}})):void 0,children:(0,Q.jsx)(U,{size:14})}):null]},i)})})]})]})})}function fn({groupId:e,instanceName:t,kind:n,assigned:r,defaultKey:a,viewerIsAdmin:o,query:s}){let c=S(V.groups.listAssignableAgents,e?{instanceName:t,groupId:e}:`skip`),l=h(V.groups.assignAgentToGroup),f=h(V.groups.removeAgentFromGroup),g=h(V.groups.bulkSetGroupAgents),_=h(V.groups.claimAgentForGroup),v=h(V.groups.setGroupDefaultAgent),y=K(),[b,C]=(0,Z.useState)(1);if((0,Z.useEffect)(()=>{C(1)},[s]),!e)return null;let w=en(c?.agents??[],s),ee=c?.discovery&&!c.discovery.lastPollOk,T=e=>Qt({assigned:r.has(Y(t,e.agentId)),claimable:e.claimable,reservedForGroup:e.reservedForGroup,enabled:e.enabled,present:e.presentInLastOk!==!1},o),E=w.filter(e=>T(e)!==`claim`),D=w.filter(e=>T(e)===`claim`);if(s.trim()&&w.length===0)return null;let k=E.filter(e=>T(e)===`toggle`&&e.presentInLastOk!==!1&&e.enabled!==!1),j=Jt(k,e=>r.has(Y(t,e.agentId))),M=Zt(E,b,cn);async function oe(n,r){try{r?await f({groupId:e,instanceName:t,agentId:n}):await l({groupId:e,instanceName:t,agentId:n})}catch(e){y.error(We(),J(e))}}async function se(){if(k.length===0)return;let n=k.map(e=>e.agentId);try{await g({groupId:e,instanceName:t,agentIds:n,assigned:j!==`all`})}catch(e){y.error(We(),J(e))}}async function ce(n){try{await _({groupId:e,instanceName:t,agentId:n})}catch(e){y.error(i(),e)}}async function P(n){try{await v({groupId:e,agent:n===null?null:{instanceName:t,agentId:n}})}catch(e){y.error(mt(),e)}}let le=e=>e.reservedForGroup?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:Ve()}):e.reserved?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:e.reservedGroupName===null?u():re({group:e.reservedGroupName})}):null;return(0,Q.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Q.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Q.jsx)(wt,{size:13,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__kind`,children:n}),ee?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__stale`,children:d()}):null]}),c===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ne()}):w.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ee?A():He()}):(0,Q.jsxs)(Q.Fragment,{children:[k.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(H,{checked:j===`all`||j===`some`&&`indeterminate`,onCheckedChange:()=>void se(),"aria-label":x()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:x()})]}):null,M.pageItems.map(e=>{let n=Y(t,e.agentId),i=r.has(n),o=e.presentInLastOk===!1,s=T(e)===`locked`;return(0,Q.jsxs)(`div`,{className:`oc-access__row${s?` is-disabled`:``}`,children:[(0,Q.jsx)(H,{checked:i,disabled:s&&!i,onCheckedChange:()=>void oe(e.agentId,i),"aria-label":ae({name:e.displayName??e.agentId})}),(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,le(e),o?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__gone`,children:m()}):null,i?a===n?(0,Q.jsx)(W,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,"aria-label":p(),title:p(),onClick:()=>void P(null),children:(0,Q.jsx)(U,{size:14,fill:`currentColor`})}):(0,Q.jsx)(W,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":N(),title:N(),onClick:()=>void P(e.agentId),children:(0,Q.jsx)(U,{size:14})}):null]},e.agentId)}),(0,Q.jsx)($,{page:M.page,pageCount:M.pageCount,onPage:C}),D.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-access__subhead`,children:ie()}),(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:O()}),D.map(e=>{let t=e.displayName??e.agentId;return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:t,children:[e.emoji?`${e.emoji} `:``,t]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,(0,Q.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,"aria-label":ze({name:t}),onClick:()=>void ce(e.agentId),children:te()})]},e.agentId)})]}):null]})]})}function pn(){let e=S(V.groupInvites.listPendingInviteRequests,{}),t=h(V.groupInvites.decideGroupInvite),n=K();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(C(),e)}}return(0,Q.jsxs)(`section`,{className:`oc-invites`,"aria-label":b(),children:[(0,Q.jsxs)(`h3`,{className:`oc-invites__title`,children:[(0,Q.jsx)(Et,{size:14,"aria-hidden":!0}),b(),(0,Q.jsx)(q,{variant:`secondary`,children:e.length})]}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,Q.jsxs)(`span`,{className:`oc-access__sub`,children:[e.groupName??`?`,` ·`,` `,F({by:e.requestedBy})]})]}),e.account===`ready`?null:(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:e.account===`none`?M():D()}),(0,Q.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,disabled:e.account!==`ready`,onClick:()=>void r(e._id,!0),children:o()}),(0,Q.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>void r(e._id,!1),children:bt()})]},e._id))})]})}function mn({groupId:e}){let t=S(V.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=h(V.charts.assignChartToGroup),r=h(V.charts.removeChartFromGroup),i=h(V.charts.setGroupDefaultChart),a=h(V.charts.addChartToGroupPool),o=h(V.charts.removeChartFromGroupPool),s=K();if(!e)return null;if(t===void 0)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:k()});let{pool:c,addable:u,canManagePool:d}=t;if(c.length===0&&!d)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ht()});async function f(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function p(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function m(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function g(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:c.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(H,{checked:e.selected,onCheckedChange:()=>void f(e.chartKey,e.selected),"aria-label":xe({name:e.name})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":yt(),title:yt(),children:(0,Q.jsx)(U,{size:14,fill:`currentColor`})}):(0,Q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void p(e.chartKey),children:pt()}):null,d?(0,Q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":_t({name:e.name}),title:_t({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,Q.jsx)(kt,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),d?u.length>0?(0,Q.jsxs)(Pt,{value:``,onValueChange:e=>void m(e),children:[(0,Q.jsx)(jt,{size:`sm`,className:`oc-access__search`,children:(0,Q.jsx)(At,{placeholder:se()})}),(0,Q.jsx)(Mt,{children:u.map(e=>(0,Q.jsx)(Nt,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:l()}):null:null]})}export{sn as GroupsTab};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$x as r,Ab as i,Ax as a,Bb as o,Bx as s,Cb as c,Cx as l,Db as u,Dx as d,E as f,Eb as p,Ex as m,FZ as h,Fb as g,Fx as _,Gb as v,Gx as y,Hb as b,Hx as x,IZ as S,Ib as C,Jb as w,Jx as ee,Kb as T,Kx as E,Lb as D,Mb as te,Mx as ne,Nb as O,Nx as k,Ob as re,Ox as A,Pb as ie,Px as ae,Qx as j,Rb as M,Sb as oe,Sx as se,Tb as N,Tx as ce,Ub as P,Ux as le,Vb as F,Vx as ue,Wb as de,Wx as fe,Xb as I,Xx as L,Yb as pe,Yx as me,Zx as R,_S as he,_b as z,_x as ge,aS as _e,ab as ve,ax as ye,bb as be,bx as xe,cS as Se,cx as Ce,dS as we,dx as Te,eS as Ee,ex as De,fS as Oe,fx as ke,gS as Ae,gb as je,gx as Me,hS as Ne,hb as Pe,hx as Fe,iS as Ie,ib as Le,ix as Re,jb as ze,jx as Be,kb as Ve,kx as He,lS as Ue,lx as We,mS as Ge,mb as Ke,mx as qe,nS as Je,nx as Ye,oS as Xe,ob as Ze,ox as Qe,pS as $e,pb as et,px as B,qb as tt,qx as nt,rS as rt,rx as it,sS as at,sb as ot,sx as st,t as V,tS as ct,tx as lt,uS as ut,ux as dt,vb as ft,vx as pt,wb as mt,wx as ht,xb as gt,xx as _t,yb as vt,yx as yt,zb as bt,zx as xt}from"./api-C9TZ4xjz.js";import{t as St}from"./chevron-left-PEVM2kG9.js";import{t as Ct}from"./chevron-right-DrdFABbO.js";import{t as H}from"./checkbox-Bbl8iiIs.js";import{t as wt}from"./server-D8sEPnaP.js";import{i as Tt,n as Et,r as Dt,t as Ot}from"./users-BUeuEf6k.js";import{t as U}from"./star-DgW-1Cj9.js";import{t as kt}from"./x-E03nFsG9.js";import{a as At,i as jt,n as Mt,r as Nt,t as Pt}from"./select-CeQpPnet.js";import{i as Ft,n as It,r as Lt,t as Rt}from"./tabs-xefd1SeB.js";import{t as W}from"./button-DEKA-XdT.js";import{t as G}from"./input-BW0GOs_g.js";import"./convexApi-D2VdPGGW.js";import{r as K}from"./toast-pKIYRpST.js";import{t as q}from"./badge-UrSDbO1c.js";import{a as zt,n as Bt,o as Vt,r as Ht,t as Ut}from"./dialog-CHpclz_0.js";import{t as Wt}from"./appHost-CH3EGcJw.js";import{n as Gt}from"./ConfirmDialog-BTkA9EEC.js";import{t as Kt}from"./EntitySheet-DZaO__IZ.js";import{a as J,c as qt,d as Jt,f as Yt,i as Xt,l as Zt,n as Qt,o as $t,r as en,t as Y,u as tn}from"./groupManageView-9KcuSXgR.js";import{t as nn}from"./FilterBar-vkX3BGGz.js";import{t as rn}from"./DataTableShell-PyJIukLO.js";import{t as X}from"./DetailChips-DJDPdjC6.js";var an=f(`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`}]]),Z=t(e(),1),Q=n(),on={name:``,description:``};function sn(){let e=S(V.groups.listGroups,{}),t=S(V.me.getMe,{host:Wt})?.role===`admin`,n=h(V.groups.createGroup),i=h(V.groups.updateGroup),a=h(V.groups.deleteGroup),o=Gt(),s=K(),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(on),[m,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(``),y=(0,Z.useMemo)(()=>{if(!e)return e;let t=_.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,_]);function b(){d(null),p(on),l(!0)}function x(e){d(e),p({name:e.name,description:e.description??``}),l(!0)}async function C(){try{u?await i({groupId:u._id,name:f.name,description:f.description}):await n({name:f.name,description:f.description||void 0}),p(on),d(null),l(!1)}catch(e){s.error(ke(),e)}}async function w(e){if(await o({title:j({name:e.name}),description:R(),confirmWord:e.name,confirmLabel:L(),cancelLabel:Ie(),destructive:!0}))try{await a({groupId:e._id})}catch(e){s.error(Te(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Ae()}),t?(0,Q.jsx)(pn,{}):null,(0,Q.jsx)(nn,{q:_,onQChange:v,onReset:()=>v(``),canReset:_!==``,searchPlaceholder:Ue()}),(0,Q.jsx)(rn,{title:he(),rows:y,addLabel:Ne(),onAdd:t?b:void 0,emptyHint:Ge(),columns:[{header:$e(),cell:e=>e.name,sort:e=>e.name},{header:Oe(),cell:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ot,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,Q.jsx)(Tt,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),e.pendingInviteCount>0?(0,Q.jsx)(q,{variant:`secondary`,children:De({count:String(e.pendingInviteCount)})}):null]}),sort:e=>e.memberCount},{header:we(),cell:e=>(0,Q.jsx)(X,{icon:(0,Q.jsx)(wt,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:ut(),cell:e=>(0,Q.jsx)(X,{icon:(0,Q.jsx)(an,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,Q.jsx)(U,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:Se(),onSelect:()=>g({groupId:e._id,name:e.name})},...t?[{label:at(),onSelect:()=>x(e)},{label:Xe(),variant:`destructive`,onSelect:()=>void w(e)}]:[]]}),(0,Q.jsx)(Kt,{open:c,onOpenChange:l,title:u?Je():rt(),description:ct(),canSubmit:!!f.name.trim(),onSubmit:C,submitLabel:_e(),children:(0,Q.jsxs)(`div`,{className:`oc-form`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:Ee()}),(0,Q.jsx)(G,{value:f.name,onChange:e=>p({...f,name:e.target.value})})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:r()}),(0,Q.jsx)(G,{value:f.description,onChange:e=>p({...f,description:e.target.value})})]})]})}),(0,Q.jsx)(ln,{groupId:m?.groupId??null,groupName:m?.name??``,open:m!==null,onOpenChange:e=>{e||g(null)}})]})}var cn=8;function $({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,Q.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,Q.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,Q.jsx)(St,{size:14,"aria-hidden":!0}),ue()]}),(0,Q.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":xt({page:e,pages:t}),children:[e,` / `,t]}),(0,Q.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[s(),(0,Q.jsx)(Ct,{size:14,"aria-hidden":!0})]})]})}function ln({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=S(V.groups.getGroup,n&&e?{groupId:e}:`skip`),o=i?.viewerIsAdmin===!0,s=S(V.groups.listAssignableInstances,n&&e?{groupId:e}:`skip`),c=S(V.groups.listAssignableUsers,n&&o?{}:`skip`),l=h(V.groups.addMember),u=h(V.groups.removeMember),d=h(V.groups.bulkSetMembers),f=h(V.groups.setGroupManager),p=K(),[m,b]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),[D,te]=(0,Z.useState)(`members`),[ne,O]=(0,Z.useState)(1),[re,A]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(new Set),j=(0,Z.useRef)(null),M=(0,Z.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),oe=(0,Z.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),se=(0,Z.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.restricted).map(e=>e.userId)),[i]),N=(0,Z.useMemo)(()=>new Set((i?.agents??[]).map(e=>Y(e.instanceName,e.agentId))),[i]),P=(0,Z.useMemo)(()=>{let e=(i?.agents??[]).find(e=>e.isDefault);return e?Y(e.instanceName,e.agentId):null},[i]);(0,Z.useEffect)(()=>{b(``),w(``),te(`members`),O(1),A(null),j.current=null},[n,e]),(0,Z.useEffect)(()=>{O(1)},[m]),(0,Z.useEffect)(()=>{n&&i&&e&&j.current!==e&&(j.current=e,ae(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let F=(0,Z.useMemo)(()=>c?Xt(c,m,ie):[],[c,m,ie]);async function ue(t,n){if(e)try{n?await u({groupId:e,userId:t}):await l({groupId:e,userId:t})}catch(e){p.error(dt(),J(e))}}async function I(t,n){if(e)try{await f({groupId:e,userId:t,manager:!n})}catch(e){p.error(qe(),e)}}let L=Jt(F,e=>M.has(e.userId)),pe=F.filter(e=>M.has(e.userId)).length,R=Zt(F,ne,cn);async function he(){if(!e||F.length===0)return;let t=F.map(e=>e.userId);try{await d({groupId:e,userIds:t,member:L!==`all`})}catch(e){p.error(dt(),J(e))}}let z=(e,t)=>(0,Q.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7`,"aria-label":v({user:t}),title:v({user:t}),onClick:()=>A({userId:e,label:t}),children:[(0,Q.jsx)(Dt,{size:13,"aria-hidden":!0}),T()]});return(0,Q.jsx)(Ut,{open:n,onOpenChange:r,children:(0,Q.jsxs)(Bt,{className:`oc-access`,children:[(0,Q.jsxs)(zt,{children:[(0,Q.jsx)(Vt,{children:me({name:t})}),(0,Q.jsx)(Ht,{children:i&&!o?Ce():ee()})]}),(0,Q.jsxs)(Rt,{value:D,onValueChange:te,className:`oc-access__tabs`,children:[(0,Q.jsxs)(Lt,{className:`w-full`,children:[(0,Q.jsxs)(Ft,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Ot,{size:13,"aria-hidden":!0}),nt(),i?(0,Q.jsx)(q,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,Q.jsxs)(Ft,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(wt,{size:13,"aria-hidden":!0}),y(),i?(0,Q.jsx)(q,{variant:`secondary`,className:`oc-access__tabcount`,children:N.size}):null]}),(0,Q.jsxs)(Ft,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(an,{size:13,"aria-hidden":!0}),ce(),i?(0,Q.jsx)(q,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,Q.jsx)(It,{value:`members`,children:i===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:k()}):o?c===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:k()}):c.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Be()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(G,{value:m,onChange:e=>b(e.target.value),placeholder:E(),className:`oc-access__search`}),F.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:le()}):(0,Q.jsxs)(Q.Fragment,{children:[F.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(H,{checked:L===`all`||L===`some`&&`indeterminate`,onCheckedChange:()=>void he(),"aria-label":x()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:x()}),(0,Q.jsxs)(q,{variant:`outline`,className:`oc-access__count`,children:[pe,` / `,F.length]})]}):null,(0,Q.jsx)(`div`,{className:`oc-access__list`,children:R.pageItems.map(e=>{let t=M.has(e.userId),n=Yt(e),r=oe.has(e.userId);return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(H,{checked:t,onCheckedChange:()=>void ue(e.userId,t),"aria-label":_({user:n.primary})}),(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,Q.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),t&&se.has(e.userId)?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:de()}):null,(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:tn(e.role)}),t?z(e.userId,n.primary):null,(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:t?(0,Q.jsx)(W,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?Fe():Me(),title:r?Fe():Me(),onClick:()=>void I(e.userId,r),children:(0,Q.jsx)(Tt,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,Q.jsx)($,{page:R.page,pageCount:R.pageCount,onPage:O})]})]}):e?(0,Q.jsx)(un,{groupId:e,members:i.members,agentsButton:z}):null}),(0,Q.jsxs)(It,{value:`agents`,children:[i&&!o?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:g()}):null,s===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:k()}):s.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:a()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(G,{value:C,onChange:e=>w(e.target.value),placeholder:fe(),className:`oc-access__search`}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:s.map(t=>(0,Q.jsx)(fn,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:N,defaultKey:P,viewerIsAdmin:o,query:C},`${e}-${t._id}`))})]})]}),(0,Q.jsx)(It,{value:`charts`,children:(0,Q.jsx)(mn,{groupId:e})})]}),(0,Q.jsx)(dn,{groupId:e,member:re,onOpenChange:e=>{e||A(null)}})]})})}function un({groupId:e,members:t,agentsButton:n}){let r=S(V.groupInvites.listGroupInviteRequests,{groupId:e}),i=h(V.groupInvites.requestGroupInvite),a=h(V.groups.removeMember),o=Gt(),s=K(),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(1),f=Zt(t,u,cn);async function p(t){t.preventDefault();let n=c.trim();if(n)try{await i({groupId:e,email:n}),l(``),s.success(it())}catch(e){s.error(Ye(),e)}}async function m(t,n){if(await o({title:I({user:n}),description:w({user:n}),confirmLabel:tt(),cancelLabel:Ie(),destructive:!0}))try{await a({groupId:e,userId:t})}catch(e){s.error(dt(),J(e))}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`form`,{className:`oc-access__invite`,onSubmit:e=>void p(e),children:[(0,Q.jsx)(G,{type:`email`,value:c,onChange:e=>l(e.target.value),placeholder:ye(),"aria-label":st()}),(0,Q.jsxs)(W,{type:`submit`,size:`sm`,disabled:!c.trim(),children:[(0,Q.jsx)(Et,{size:14,"aria-hidden":!0}),Re()]})]}),(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Qe()}),t.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:P()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:f.pageItems.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.label,children:e.label}),e.restricted?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:de()}):null,n(e.userId,e.label),(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:e.manager?(0,Q.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":ge(),title:ge(),children:(0,Q.jsx)(Tt,{size:15,"aria-hidden":!0})}):null}),(0,Q.jsx)(W,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.manager||e.lastGroup,"aria-label":I({user:e.label}),title:e.manager?pe():e.lastGroup?et():I({user:e.label}),onClick:()=>void m(e.userId,e.label),children:(0,Q.jsx)(kt,{size:14,"aria-hidden":!0})})]},e.userId))}),(0,Q.jsx)($,{page:f.page,pageCount:f.pageCount,onPage:d})]}),r!==void 0&&r.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-access__subhead`,children:lt()}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:r.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,Q.jsx)(q,{variant:e.status===`pending`?`secondary`:`outline`,className:`oc-access__role`,children:$t(e.status)})]},e._id))})]}):null]})}function dn({groupId:e,member:t,onOpenChange:n}){let r=S(V.groups.getMemberAgentSettings,e&&t?{groupId:e,userId:t.userId}:`skip`),i=h(V.groups.setMemberAgents),a=h(V.groups.setMemberDefaultAgent),o=K();async function s(e){try{await e()}catch(e){o.error(Ke(),e)}}let l=r?.agents??[],u=new Map(l.map(e=>[Y(e.instanceName,e.agentId),e])),d=[...u.keys()],f=new Set(l.filter(e=>e.allowed).map(e=>Y(e.instanceName,e.agentId)));function p(n){if(!e||!t||!r)return;let a=qt(d,f,r.restricted,n).map(e=>{let t=u.get(e);return{instanceName:t.instanceName,agentId:t.agentId}});s(()=>i({groupId:e,userId:t.userId,agents:a}))}return(0,Q.jsx)(Ut,{open:t!==null,onOpenChange:n,children:(0,Q.jsxs)(Bt,{className:`oc-access`,children:[(0,Q.jsxs)(zt,{children:[(0,Q.jsx)(Vt,{children:c({user:t?.label??``})}),(0,Q.jsx)(Ht,{children:oe()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:k()}):r===null||l.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Pe()}):(0,Q.jsxs)(Q.Fragment,{children:[r.settable?null:(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Le()}),r.adminNarrowed?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ot()}):null,r.restrictedByAdmin&&!r.viewerIsAdmin?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ve()}):null,(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,children:r.restricted?be():gt()}),r.restricted?(0,Q.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,disabled:!r.settable||r.restrictedByAdmin&&!r.viewerIsAdmin,onClick:()=>e&&t?void s(()=>i({groupId:e,userId:t.userId,agents:null})):void 0,children:vt()}):null]}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:l.map(n=>{let i=Y(n.instanceName,n.agentId),o=n.displayName??n.agentId;return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(H,{checked:n.allowed,disabled:!r.settable||r.restrictedByAdmin&&!r.viewerIsAdmin&&!n.allowed,onCheckedChange:()=>p(i),"aria-label":ft({name:o})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:o,children:o}),n.limitedByAdmin?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:Ze()}):null,n.state===`deleted`?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__gone`,children:m()}):null,n.allowed?n.isMemberDefault?(0,Q.jsx)(W,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,disabled:!r.settable,"aria-label":z(),title:z(),onClick:()=>e&&t?void s(()=>a({groupId:e,userId:t.userId,agent:null})):void 0,children:(0,Q.jsx)(U,{size:14,fill:`currentColor`})}):(0,Q.jsx)(W,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,disabled:!r.settable,"aria-label":je(),title:je(),onClick:()=>e&&t?void s(()=>a({groupId:e,userId:t.userId,agent:{instanceName:n.instanceName,agentId:n.agentId}})):void 0,children:(0,Q.jsx)(U,{size:14})}):null]},i)})})]})]})})}function fn({groupId:e,instanceName:t,kind:n,assigned:r,defaultKey:a,viewerIsAdmin:o,query:s}){let c=S(V.groups.listAssignableAgents,e?{instanceName:t,groupId:e}:`skip`),l=h(V.groups.assignAgentToGroup),f=h(V.groups.removeAgentFromGroup),g=h(V.groups.bulkSetGroupAgents),_=h(V.groups.claimAgentForGroup),v=h(V.groups.setGroupDefaultAgent),y=K(),[b,C]=(0,Z.useState)(1);if((0,Z.useEffect)(()=>{C(1)},[s]),!e)return null;let w=en(c?.agents??[],s),ee=c?.discovery&&!c.discovery.lastPollOk,T=e=>Qt({assigned:r.has(Y(t,e.agentId)),claimable:e.claimable,reservedForGroup:e.reservedForGroup,enabled:e.enabled,present:e.presentInLastOk!==!1},o),E=w.filter(e=>T(e)!==`claim`),D=w.filter(e=>T(e)===`claim`);if(s.trim()&&w.length===0)return null;let k=E.filter(e=>T(e)===`toggle`&&e.presentInLastOk!==!1&&e.enabled!==!1),j=Jt(k,e=>r.has(Y(t,e.agentId))),M=Zt(E,b,cn);async function oe(n,r){try{r?await f({groupId:e,instanceName:t,agentId:n}):await l({groupId:e,instanceName:t,agentId:n})}catch(e){y.error(We(),J(e))}}async function se(){if(k.length===0)return;let n=k.map(e=>e.agentId);try{await g({groupId:e,instanceName:t,agentIds:n,assigned:j!==`all`})}catch(e){y.error(We(),J(e))}}async function ce(n){try{await _({groupId:e,instanceName:t,agentId:n})}catch(e){y.error(i(),e)}}async function P(n){try{await v({groupId:e,agent:n===null?null:{instanceName:t,agentId:n}})}catch(e){y.error(mt(),e)}}let le=e=>e.reservedForGroup?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:Ve()}):e.reserved?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:e.reservedGroupName===null?u():re({group:e.reservedGroupName})}):null;return(0,Q.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Q.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Q.jsx)(wt,{size:13,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__kind`,children:n}),ee?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__stale`,children:d()}):null]}),c===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ne()}):w.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ee?A():He()}):(0,Q.jsxs)(Q.Fragment,{children:[k.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(H,{checked:j===`all`||j===`some`&&`indeterminate`,onCheckedChange:()=>void se(),"aria-label":x()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:x()})]}):null,M.pageItems.map(e=>{let n=Y(t,e.agentId),i=r.has(n),o=e.presentInLastOk===!1,s=T(e)===`locked`;return(0,Q.jsxs)(`div`,{className:`oc-access__row${s?` is-disabled`:``}`,children:[(0,Q.jsx)(H,{checked:i,disabled:s&&!i,onCheckedChange:()=>void oe(e.agentId,i),"aria-label":ae({name:e.displayName??e.agentId})}),(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,le(e),o?(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__gone`,children:m()}):null,i?a===n?(0,Q.jsx)(W,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,"aria-label":p(),title:p(),onClick:()=>void P(null),children:(0,Q.jsx)(U,{size:14,fill:`currentColor`})}):(0,Q.jsx)(W,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":N(),title:N(),onClick:()=>void P(e.agentId),children:(0,Q.jsx)(U,{size:14})}):null]},e.agentId)}),(0,Q.jsx)($,{page:M.page,pageCount:M.pageCount,onPage:C}),D.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-access__subhead`,children:ie()}),(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:O()}),D.map(e=>{let t=e.displayName??e.agentId;return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:t,children:[e.emoji?`${e.emoji} `:``,t]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,(0,Q.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,"aria-label":ze({name:t}),onClick:()=>void ce(e.agentId),children:te()})]},e.agentId)})]}):null]})]})}function pn(){let e=S(V.groupInvites.listPendingInviteRequests,{}),t=h(V.groupInvites.decideGroupInvite),n=K();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(C(),e)}}return(0,Q.jsxs)(`section`,{className:`oc-invites`,"aria-label":b(),children:[(0,Q.jsxs)(`h3`,{className:`oc-invites__title`,children:[(0,Q.jsx)(Et,{size:14,"aria-hidden":!0}),b(),(0,Q.jsx)(q,{variant:`secondary`,children:e.length})]}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,Q.jsxs)(`span`,{className:`oc-access__sub`,children:[e.groupName??`?`,` ·`,` `,F({by:e.requestedBy})]})]}),e.account===`ready`?null:(0,Q.jsx)(q,{variant:`outline`,className:`oc-access__role`,children:e.account===`none`?M():D()}),(0,Q.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,disabled:e.account!==`ready`,onClick:()=>void r(e._id,!0),children:o()}),(0,Q.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>void r(e._id,!1),children:bt()})]},e._id))})]})}function mn({groupId:e}){let t=S(V.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=h(V.charts.assignChartToGroup),r=h(V.charts.removeChartFromGroup),i=h(V.charts.setGroupDefaultChart),a=h(V.charts.addChartToGroupPool),o=h(V.charts.removeChartFromGroupPool),s=K();if(!e)return null;if(t===void 0)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:k()});let{pool:c,addable:u,canManagePool:d}=t;if(c.length===0&&!d)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ht()});async function f(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function p(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function m(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function g(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:c.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(H,{checked:e.selected,onCheckedChange:()=>void f(e.chartKey,e.selected),"aria-label":xe({name:e.name})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":yt(),title:yt(),children:(0,Q.jsx)(U,{size:14,fill:`currentColor`})}):(0,Q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void p(e.chartKey),children:pt()}):null,d?(0,Q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":_t({name:e.name}),title:_t({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,Q.jsx)(kt,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),d?u.length>0?(0,Q.jsxs)(Pt,{value:``,onValueChange:e=>void m(e),children:[(0,Q.jsx)(jt,{size:`sm`,className:`oc-access__search`,children:(0,Q.jsx)(At,{placeholder:se()})}),(0,Q.jsx)(Mt,{children:u.map(e=>(0,Q.jsx)(Nt,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:l()}):null:null]})}export{sn as GroupsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$F as r,$I as i,AF as a,AI as o,BF as s,BI as c,CF as l,CI as u,DF as d,DI as f,EF as p,EI as m,FF as h,FI as g,FZ as _,Ft as v,GF as y,GI as b,HF as x,HI as S,IF as C,II as w,IZ as T,It as E,JF as D,JI as O,Jm as k,KF as ee,KI as te,LF as ne,LI as re,Lt as ie,MF as ae,MI as A,MW as j,Mt as oe,NF as se,NI as M,NZ as N,Nt as ce,OF as P,OI as le,PF as ue,PI as de,Pt as fe,QF as pe,QI as me,RF as he,RI as ge,Rt as _e,SF as ve,SI as ye,TF as be,TI as xe,UF as Se,UI as Ce,VF as we,VI as Te,WF as Ee,WI as De,XI as Oe,Xm as ke,YF as Ae,YI as je,Ym as Me,ZF as F,ZI as Ne,Zm as Pe,_I as Fe,_r as Ie,_s as Le,aI as Re,aL as ze,aj as Be,as as Ve,bI as He,br as Ue,bs as We,cI as Ge,cL as Ke,cs as qe,dI as Je,dL as Ye,dd as Xe,dr as Ze,ds as Qe,eI as $e,eL as et,fI as tt,fL as nt,fd as rt,fr as it,fs as at,gI as ot,gL as st,gr as ct,gs as lt,hI as ut,hL as dt,hr as ft,hs as pt,iI as mt,iL as ht,ij as gt,is as _t,jF as vt,jI as yt,jW as bt,jt as xt,kF as St,kI as Ct,lI as wt,lL as Tt,ls as Et,mI as Dt,mL as Ot,mr as kt,ms as At,nI as I,nL as L,nb as jt,oI as Mt,oL as Nt,os as Pt,pI as Ft,pL as It,pr as Lt,ps as Rt,qF as zt,qI as Bt,rI as Vt,rL as Ht,rb as Ut,sI as Wt,sL as Gt,ss as Kt,t as R,tI as qt,tL as Jt,tb as Yt,uI as Xt,uL as Zt,ud as Qt,us as $t,vI as en,vr as tn,vs as nn,wF as rn,wI as an,xF as on,xI as sn,yI as cn,yr as ln,ys as un,zF as dn,zI as fn,zt as pn}from"./api-DNOgniXv.js";import{a as mn,c as hn}from"./FieldLabel-rU6Ua6ki.js";import{t as z}from"./checkbox-kFoJxcMJ.js";import{a as B,i as V,n as H,r as U,t as W}from"./select-CYo6IZR2.js";import{n as gn,r as _n,t as vn}from"./popover-BHbAt2S-.js";import{t as G}from"./button-2XjWVeWK.js";import{t as K}from"./input-BOl1ZpD6.js";import"./convexApi-4XI9Ua6G.js";import{r as q}from"./toast-DN6P_at0.js";import{t as J}from"./badge-D7TV9F5d.js";import{a as yn,n as bn,o as xn,r as Sn,t as Cn}from"./dialog-Cw-buQuR.js";import{n as wn}from"./ConfirmDialog-DUn2vS3y.js";import{t as Tn}from"./EntitySheet-BHlTwSgy.js";import{a as En}from"./groupManageView-B0Fd_T1s.js";import{t as Dn}from"./DataTableShell-DlkJe0in.js";import{InstanceConfigDialog as On}from"./BridgeTab-D7vwrcIC.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],kn=new Set(X),An=`conversational`;function jn(e){let t=new Set((e??[]).filter(e=>kn.has(e)));return t.size===0?[An]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,participantIdentity:`owner`,managePermissionModes:!1,systemIdentity:``,streamTransport:mn,widgetsEnabled:!0,widgetPromptConfirm:!1},Mn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Nn(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 Pn(){let e=T(R.admin.listInstances,{}),t=T(R.agents.listAllInstanceAgents,{}),n=_(R.admin.upsertInstance),r=_(R.widgets.setInstanceWidgets),a=_(R.admin.deleteInstance),o=q(),[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(Q),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),[g,y]=(0,Y.useState)(null),[x,C]=(0,Y.useState)(null);async function w(){try{let t=await n({instanceId:x??void 0,name:u.name,gatewayUrl:u.gatewayUrl,bridgeUrl:u.bridgeUrl||void 0,displayName:u.displayName||void 0,kind:u.kind,transport:u.kind===`hermes`?u.transport:void 0,gatewayVersion:u.gatewayVersion||void 0,gatewayHttpUrl:u.gatewayHttpUrl||void 0,...u.kind===`openclaw`?{authMode:u.authMode,personScopes:u.personScopes,identitySource:u.identitySource,participantIdentity:u.participantIdentity,managePermissionModes:u.managePermissionModes,systemIdentity:u.systemIdentity||void 0}:{},streamTransport:u.streamTransport}),i=x===null?null:e?.find(e=>e._id===x),a=i?.config?.widgetsEnabled!==!1,o=i?.config?.widgetPromptConfirm===!0;u.kind===`openclaw`&&(u.widgetsEnabled!==a||u.widgetPromptConfirm!==o)&&await r({instanceId:t,enabled:u.widgetsEnabled,promptConfirm:u.widgetPromptConfirm}),d(Q),C(null),l(!1)}catch(e){o.error(Ot(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[It(),(0,Z.jsx)(`strong`,{children:nt()}),Ye()]}),(0,Z.jsx)(Dn,{title:Zt(),rows:e,addLabel:Tt(),onAdd:()=>{C(null),d(Q),l(!0)},emptyHint:Ke(),columns:[{header:Gt(),cell:e=>e.name,sort:e=>e.name},{header:Nt(),cell:e=>(0,Z.jsx)(J,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:ze(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:ht(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:st(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(J,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?P():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:et(),onSelect:()=>{C(e._id),d(Nn(e)),l(!0)}},{label:dt(),onSelect:()=>p(e.name)},{label:fn(),onSelect:()=>y(e)},{label:Ht(),onSelect:()=>h(e)},{label:L(),variant:`destructive`,onSelect:()=>void a({instanceId:e._id})}],bulkActions:[{label:L(),variant:`destructive`,onSelect:e=>e.forEach(e=>void a({instanceId:e}))}]}),(0,Z.jsx)(Tn,{open:s,onOpenChange:l,title:x?i():Jt(),description:Ne(),canSubmit:!!(u.name&&u.gatewayUrl),onSubmit:w,submitLabel:Oe(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:je(),children:[(0,Z.jsx)(K,{value:u.name,disabled:x!==null,onChange:e=>d({...u,name:e.target.value})}),x?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:me()}):null]}),(0,Z.jsx)($,{label:O(),children:(0,Z.jsxs)(W,{value:u.kind,onValueChange:e=>d({...u,kind:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(U,{value:`hermes`,children:`Hermes`})]})]})}),u.kind===`hermes`?(0,Z.jsx)($,{label:rt(),children:(0,Z.jsxs)(W,{value:u.transport,onValueChange:e=>d({...u,transport:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`ws`,children:Xe()}),(0,Z.jsx)(U,{value:`rest`,children:Qt()})]})]})}):null,(0,Z.jsx)($,{label:Bt(),children:(0,Z.jsx)(K,{value:u.gatewayUrl,onChange:e=>d({...u,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:te(),children:(0,Z.jsx)(K,{value:u.bridgeUrl,placeholder:b(),onChange:e=>d({...u,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:De(),children:(0,Z.jsx)(K,{value:u.displayName,onChange:e=>d({...u,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:Be(),children:[(0,Z.jsxs)(W,{value:u.streamTransport,onValueChange:e=>d({...u,streamTransport:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsx)(H,{children:hn.map(e=>(0,Z.jsx)(U,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:gt()})]}),(0,Z.jsx)($,{label:Ce(),children:(0,Z.jsx)(K,{value:u.gatewayVersion,placeholder:S(),onChange:e=>d({...u,gatewayVersion:e.target.value})})}),u.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:$t(),children:[(0,Z.jsxs)(W,{value:u.authMode,onValueChange:e=>d({...u,authMode:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`token`,children:Et()}),(0,Z.jsx)(U,{value:`trusted-proxy`,children:qe()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.authMode===`trusted-proxy`?Pt():Kt()})]}),u.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:We(),children:[(0,Z.jsxs)(W,{value:u.personScopes,onValueChange:e=>d({...u,personScopes:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`capped`,children:un()}),(0,Z.jsx)(U,{value:`full`,children:nn()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.personScopes===`full`?lt():Le()})]}):null,u.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:pt(),children:[(0,Z.jsxs)(W,{value:u.identitySource,onValueChange:e=>d({...u,identitySource:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`canonical`,children:At()}),(0,Z.jsx)(U,{value:`email`,children:Rt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.identitySource===`email`?Qe():at()})]}):null,u.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Ue(),children:[(0,Z.jsxs)(W,{value:u.participantIdentity,onValueChange:e=>d({...u,participantIdentity:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`owner`,children:ln()}),(0,Z.jsx)(U,{value:`self`,children:tn()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.participantIdentity===`self`?Ze():Ie()})]}):null,u.kind===`openclaw`?(0,Z.jsxs)($,{label:ct(),children:[(0,Z.jsxs)(W,{value:u.managePermissionModes?`on`:`off`,onValueChange:e=>d({...u,managePermissionModes:e===`on`}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`off`,children:ft()}),(0,Z.jsx)(U,{value:`on`,children:kt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.managePermissionModes?it():Lt()})]}):null,u.kind===`openclaw`?(0,Z.jsxs)($,{label:pn(),children:[(0,Z.jsxs)(W,{value:u.widgetsEnabled?`on`:`off`,onValueChange:e=>d({...u,widgetsEnabled:e===`on`}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`on`,children:_e()}),(0,Z.jsx)(U,{value:`off`,children:ie()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.widgetsEnabled?E():v()})]}):null,u.kind===`openclaw`&&u.widgetsEnabled?(0,Z.jsxs)($,{label:fe(),children:[(0,Z.jsxs)(W,{value:u.widgetPromptConfirm?`on`:`off`,onValueChange:e=>d({...u,widgetPromptConfirm:e===`on`}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`off`,children:ce()}),(0,Z.jsx)(U,{value:`on`,children:oe()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:xt()})]}):null,u.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:Ve(),children:(0,Z.jsx)(K,{value:u.systemIdentity,placeholder:_t(),onChange:e=>d({...u,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:Te(),children:(0,Z.jsx)(K,{value:u.gatewayHttpUrl,placeholder:c(),onChange:e=>d({...u,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Wn,{instanceName:f,open:f!==null,onOpenChange:e=>{e||p(null)}}),m?(0,Z.jsx)(On,{instance:m,onClose:()=>h(null)},m._id):null,g?(0,Z.jsx)(Fn,{instance:g,onClose:()=>y(null)},g._id):null]})}function Fn({instance:e,onClose:t}){let n=T(R.instanceSecrets.listInstanceSecretStatus,{}),r=Mn[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(Cn,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(bn,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(xn,{children:ge({instance:e.displayName??e.name})}),(0,Z.jsx)(Sn,{children:re()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Rn,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Ln,{instance:e})}),(0,Z.jsx)(In,{instance:e})]})})}function In({instance:e}){let t=N(R.instanceSync.forceInstanceSync),n=q(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(Fe());break;case`no_agents`:n.success(ut());break;case`no_bridge_url`:n.error(Dt());break;case`deploy_misconfigured`:n.error(Ft());break;case`unauthorized`:n.error(Je());break;case`not_served`:n.error(Xt());break;default:n.error(tt());break}}catch(e){n.error(ot(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:wt()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?en():cn()})})]})}function Ln({instance:e}){let t=T(R.bridgeAuth.listBridgeAuthStatus,{}),n=N(R.bridgeAuth.mintBridgeSecret),r=_(R.bridgeAuth.revokeBridgeSecret),i=q(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),d=(t??[]).find(t=>t.instanceId===e._id),f=d!==void 0;async function p(){if(!a){o(!0);try{let t=await n({instanceId:e._id});c(t.plaintext),u(!1)}catch(e){i.error(I(),e)}finally{o(!1)}}}async function m(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(Vt())}catch(e){i.error(I(),e)}finally{o(!1)}}}async function h(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:Ge(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Wt()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(J,{variant:f?`outline`:`secondary`,children:f?`${M()} · ${d.prefix}…${d.lastFour}`:A()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(G,{size:`sm`,onClick:()=>void p(),disabled:a,children:f?Re():Mt()}),f?(0,Z.jsx)(G,{size:`sm`,variant:`destructive`,onClick:()=>void m(),disabled:a,children:mt()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:qt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(G,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:l?j():bt()})]}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:$e()})]}):null]})}function Rn({instanceId:e,field:t,updatedAt:n}){let r=N(R.instanceSecrets.setInstanceSecret),i=_(R.instanceSecrets.clearInstanceSecret),a=N(R.deviceIdentity.generateDeviceIdentity),s=q(),[c,l]=(0,Y.useState)(``),[d,p]=(0,Y.useState)(!1),[h,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(!1),x=n!==null,S=t===`deviceIdentity`,C=t===`token`?w():t===`deviceIdentity`?g():de();async function T(){if(!(!c.trim()||d)){p(!0);try{await r({instanceId:e,field:t,plaintext:c}),l(``),v(null),b(!1),s.success(f())}catch(e){s.error(m(),e)}finally{p(!1)}}}async function E(){if(!d){p(!0);try{await i({instanceId:e,field:t}),v(null),b(!1),s.success(xe())}catch(e){s.error(m(),e)}finally{p(!1)}}}async function D(){if(!d){p(!0);try{let t=await a({instanceId:e});v(t),b(!1),s.success(ye())}catch(e){s.error(He(),e)}finally{p(!1)}}}let O=h?`openclaw devices approve ${h.id}`:``;async function k(){if(O)try{await navigator.clipboard.writeText(O),b(!0)}catch{}}return(0,Z.jsxs)($,{label:C,children:[S?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(J,{variant:x?`outline`:`secondary`,children:x?M():A()}),(0,Z.jsx)(K,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:x?o():yt(),onChange:e=>l(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(G,{size:`sm`,onClick:()=>void T(),disabled:d||c.trim().length===0,children:Ct()}),S?(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>void D(),disabled:d,children:an()}):null,x?(0,Z.jsx)(G,{size:`sm`,variant:`destructive`,onClick:()=>void E(),disabled:d,children:le()}):null]})]}),h?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:ye()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:sn()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:O}),(0,Z.jsx)(G,{variant:`outline`,size:`sm`,onClick:()=>void k(),children:y?j():bt()})]}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>{v(null),b(!1)},children:$e()})]}):null]})}var zn={conversational:Se,documentary:we,summarizer:Pe,curator:Me},Bn={conversational:x,documentary:s,summarizer:ke,curator:k},Vn=e=>(zn[e]??(()=>e))(),Hn=e=>(Bn[e]??(()=>``))();function Un({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:zt()}),t.map(e=>(0,Z.jsx)(J,{variant:`secondary`,className:`oc-agenttype__chip`,title:Hn(e),children:Vn(e)},e)),(0,Z.jsxs)(vn,{children:[(0,Z.jsx)(_n,{asChild:!0,children:(0,Z.jsx)(G,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:ee()})}),(0,Z.jsxs)(gn,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:y()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Ee()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(z,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Vn(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Hn(r)})]})]},r)})})]})]})]})}function Wn({instanceName:e,open:t,onOpenChange:n}){let i=T(R.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),o=_(R.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(R.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(R.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),s=_(R.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(R.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(R.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),c=_(R.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(R.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=jn(r);e.setQuery(R.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),u=_(R.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(R.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(R.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),f=_(R.agents.removeInstanceAgent),m=_(R.agents.setAgentReservation),g=T(R.groups.listGroupLabels,t?{}:`skip`),v=wn(),y=q();async function b(t,n){if(e&&await v({title:rn({name:n}),description:l(),confirmLabel:be()}))try{await m({instanceName:e,agentId:t,groupId:null})}catch(e){y.error(F(),En(e))}}async function x(t,n,r){if(!e)return;let i=(g??[]).find(e=>e._id===r)?.name??`?`;if(await v({title:Ut({name:n,group:i}),description:jt({group:i}),confirmLabel:Yt()}))try{await m({instanceName:e,agentId:t,groupId:r})}catch(e){y.error(F(),En(e))}}async function S(t,n){if(e)try{await o({instanceName:e,agentId:t,enabled:n})}catch(e){y.error(F(),e)}}async function w(t){if(e)try{await s({instanceName:e,agentId:t})}catch(e){y.error(F(),e)}}async function E(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await c({instanceName:e,agentId:t,types:i})}catch(e){y.error(F(),e)}}async function D(t,n){if(e&&await v({title:ne({name:n}),description:C(),confirmLabel:h(),destructive:!0}))try{await f({instanceName:e,agentId:t}),y.success(ue())}catch(e){y.error(F(),e)}}return(0,Z.jsx)(Cn,{open:t,onOpenChange:n,children:(0,Z.jsxs)(bn,{className:`oc-access`,children:[(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(xn,{children:r({name:e??``})}),(0,Z.jsx)(Sn,{children:pe()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:se()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?ae():i.discovery.lastPollOk?vt():a({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:St()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i.agents.map(t=>{let n=t.presentInLastOk===!1,r=i.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(z,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void S(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,t.reserved?(0,Z.jsx)(J,{variant:`outline`,children:t.reserved.groupName===null?p():d({group:t.reserved.groupName})}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(J,{variant:`outline`,className:`oc-access__gone`,children:on()}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void D(t.agentId,a),children:he()})]}):r?(0,Z.jsx)(J,{variant:`default`,children:P()}):(0,Z.jsx)(G,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled||t.reserved!==null,onClick:()=>void w(t.agentId),children:dn()})]}),t.reserved?(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(G,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>void b(t.agentId,a),children:be()}),(0,Z.jsxs)(W,{value:``,onValueChange:e=>void x(t.agentId,a,e),children:[(0,Z.jsx)(V,{size:`sm`,className:`h-7`,children:(0,Z.jsx)(B,{placeholder:ve()})}),(0,Z.jsx)(H,{children:(g??[]).filter(e=>e._id!==t.reserved?.groupId).map(e=>(0,Z.jsx)(U,{value:e._id,children:e.name},e._id))})]})]}):null,t.enabled?(0,Z.jsx)(Un,{agentId:t.agentId,types:o,onToggle:e=>void E(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Gn,{value:t.description??``,onSave:async n=>{if(e)try{await u({instanceName:e,agentId:t.agentId,description:n})}catch(e){y.error(F(),e)}}}):null]},t.agentId)})})]})]})})}function Gn({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(K,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Ae(),"aria-label":D(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Pn as InstancesTab};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$F as r,$I as i,AF as a,AI as o,BF as s,BI as c,CF as l,CI as u,DF as d,DI as f,EF as p,EI as m,FF as h,FI as g,FZ as _,Ft as v,GF as y,GI as b,HF as x,HI as S,IF as C,II as w,IZ as T,It as E,JF as D,JI as O,Jm as k,KF as ee,KI as te,LF as ne,LI as re,Lt as ie,MF as ae,MI as A,MW as j,Mt as oe,NF as se,NI as M,NZ as N,Nt as ce,OF as P,OI as le,PF as ue,PI as de,Pt as fe,QF as pe,QI as me,RF as he,RI as ge,Rt as _e,SF as ve,SI as ye,TF as be,TI as xe,UF as Se,UI as Ce,VF as we,VI as Te,WF as Ee,WI as De,XI as Oe,Xm as ke,YF as Ae,YI as je,Ym as Me,ZF as F,ZI as Ne,Zm as Pe,_I as Fe,_r as Ie,_s as Le,aI as Re,aL as ze,aj as Be,as as Ve,bI as He,br as Ue,bs as We,cI as Ge,cL as Ke,cs as qe,dI as Je,dL as Ye,dd as Xe,dr as Ze,ds as Qe,eI as $e,eL as et,fI as tt,fL as nt,fd as rt,fr as it,fs as at,gI as ot,gL as st,gr as ct,gs as lt,hI as ut,hL as dt,hr as ft,hs as pt,iI as mt,iL as ht,ij as gt,is as _t,jF as vt,jI as yt,jW as bt,jt as xt,kF as St,kI as Ct,lI as wt,lL as Tt,ls as Et,mI as Dt,mL as Ot,mr as kt,ms as At,nI as I,nL as L,nb as jt,oI as Mt,oL as Nt,os as Pt,pI as Ft,pL as It,pr as Lt,ps as Rt,qF as zt,qI as Bt,rI as Vt,rL as Ht,rb as Ut,sI as Wt,sL as Gt,ss as Kt,t as R,tI as qt,tL as Jt,tb as Yt,uI as Xt,uL as Zt,ud as Qt,us as $t,vI as en,vr as tn,vs as nn,wF as rn,wI as an,xF as on,xI as sn,yI as cn,yr as ln,ys as un,zF as dn,zI as fn,zt as pn}from"./api-C9TZ4xjz.js";import{a as mn,c as hn}from"./FieldLabel-BW2ofPSg.js";import{t as z}from"./checkbox-Bbl8iiIs.js";import{a as B,i as V,n as H,r as U,t as W}from"./select-CeQpPnet.js";import{n as gn,r as _n,t as vn}from"./popover-rh1_TqjX.js";import{t as G}from"./button-DEKA-XdT.js";import{t as K}from"./input-BW0GOs_g.js";import"./convexApi-D2VdPGGW.js";import{r as q}from"./toast-pKIYRpST.js";import{t as J}from"./badge-UrSDbO1c.js";import{a as yn,n as bn,o as xn,r as Sn,t as Cn}from"./dialog-CHpclz_0.js";import{n as wn}from"./ConfirmDialog-BTkA9EEC.js";import{t as Tn}from"./EntitySheet-DZaO__IZ.js";import{a as En}from"./groupManageView-9KcuSXgR.js";import{t as Dn}from"./DataTableShell-PyJIukLO.js";import{InstanceConfigDialog as On}from"./BridgeTab-CBhC6xPF.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],kn=new Set(X),An=`conversational`;function jn(e){let t=new Set((e??[]).filter(e=>kn.has(e)));return t.size===0?[An]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,participantIdentity:`owner`,managePermissionModes:!1,systemIdentity:``,streamTransport:mn,widgetsEnabled:!0,widgetPromptConfirm:!1},Mn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Nn(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 Pn(){let e=T(R.admin.listInstances,{}),t=T(R.agents.listAllInstanceAgents,{}),n=_(R.admin.upsertInstance),r=_(R.widgets.setInstanceWidgets),a=_(R.admin.deleteInstance),o=q(),[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(Q),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),[g,y]=(0,Y.useState)(null),[x,C]=(0,Y.useState)(null);async function w(){try{let t=await n({instanceId:x??void 0,name:u.name,gatewayUrl:u.gatewayUrl,bridgeUrl:u.bridgeUrl||void 0,displayName:u.displayName||void 0,kind:u.kind,transport:u.kind===`hermes`?u.transport:void 0,gatewayVersion:u.gatewayVersion||void 0,gatewayHttpUrl:u.gatewayHttpUrl||void 0,...u.kind===`openclaw`?{authMode:u.authMode,personScopes:u.personScopes,identitySource:u.identitySource,participantIdentity:u.participantIdentity,managePermissionModes:u.managePermissionModes,systemIdentity:u.systemIdentity||void 0}:{},streamTransport:u.streamTransport}),i=x===null?null:e?.find(e=>e._id===x),a=i?.config?.widgetsEnabled!==!1,o=i?.config?.widgetPromptConfirm===!0;u.kind===`openclaw`&&(u.widgetsEnabled!==a||u.widgetPromptConfirm!==o)&&await r({instanceId:t,enabled:u.widgetsEnabled,promptConfirm:u.widgetPromptConfirm}),d(Q),C(null),l(!1)}catch(e){o.error(Ot(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[It(),(0,Z.jsx)(`strong`,{children:nt()}),Ye()]}),(0,Z.jsx)(Dn,{title:Zt(),rows:e,addLabel:Tt(),onAdd:()=>{C(null),d(Q),l(!0)},emptyHint:Ke(),columns:[{header:Gt(),cell:e=>e.name,sort:e=>e.name},{header:Nt(),cell:e=>(0,Z.jsx)(J,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:ze(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:ht(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:st(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(J,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?P():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:et(),onSelect:()=>{C(e._id),d(Nn(e)),l(!0)}},{label:dt(),onSelect:()=>p(e.name)},{label:fn(),onSelect:()=>y(e)},{label:Ht(),onSelect:()=>h(e)},{label:L(),variant:`destructive`,onSelect:()=>void a({instanceId:e._id})}],bulkActions:[{label:L(),variant:`destructive`,onSelect:e=>e.forEach(e=>void a({instanceId:e}))}]}),(0,Z.jsx)(Tn,{open:s,onOpenChange:l,title:x?i():Jt(),description:Ne(),canSubmit:!!(u.name&&u.gatewayUrl),onSubmit:w,submitLabel:Oe(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:je(),children:[(0,Z.jsx)(K,{value:u.name,disabled:x!==null,onChange:e=>d({...u,name:e.target.value})}),x?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:me()}):null]}),(0,Z.jsx)($,{label:O(),children:(0,Z.jsxs)(W,{value:u.kind,onValueChange:e=>d({...u,kind:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(U,{value:`hermes`,children:`Hermes`})]})]})}),u.kind===`hermes`?(0,Z.jsx)($,{label:rt(),children:(0,Z.jsxs)(W,{value:u.transport,onValueChange:e=>d({...u,transport:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`ws`,children:Xe()}),(0,Z.jsx)(U,{value:`rest`,children:Qt()})]})]})}):null,(0,Z.jsx)($,{label:Bt(),children:(0,Z.jsx)(K,{value:u.gatewayUrl,onChange:e=>d({...u,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:te(),children:(0,Z.jsx)(K,{value:u.bridgeUrl,placeholder:b(),onChange:e=>d({...u,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:De(),children:(0,Z.jsx)(K,{value:u.displayName,onChange:e=>d({...u,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:Be(),children:[(0,Z.jsxs)(W,{value:u.streamTransport,onValueChange:e=>d({...u,streamTransport:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsx)(H,{children:hn.map(e=>(0,Z.jsx)(U,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:gt()})]}),(0,Z.jsx)($,{label:Ce(),children:(0,Z.jsx)(K,{value:u.gatewayVersion,placeholder:S(),onChange:e=>d({...u,gatewayVersion:e.target.value})})}),u.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:$t(),children:[(0,Z.jsxs)(W,{value:u.authMode,onValueChange:e=>d({...u,authMode:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`token`,children:Et()}),(0,Z.jsx)(U,{value:`trusted-proxy`,children:qe()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.authMode===`trusted-proxy`?Pt():Kt()})]}),u.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:We(),children:[(0,Z.jsxs)(W,{value:u.personScopes,onValueChange:e=>d({...u,personScopes:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`capped`,children:un()}),(0,Z.jsx)(U,{value:`full`,children:nn()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.personScopes===`full`?lt():Le()})]}):null,u.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:pt(),children:[(0,Z.jsxs)(W,{value:u.identitySource,onValueChange:e=>d({...u,identitySource:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`canonical`,children:At()}),(0,Z.jsx)(U,{value:`email`,children:Rt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.identitySource===`email`?Qe():at()})]}):null,u.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Ue(),children:[(0,Z.jsxs)(W,{value:u.participantIdentity,onValueChange:e=>d({...u,participantIdentity:e}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`owner`,children:ln()}),(0,Z.jsx)(U,{value:`self`,children:tn()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.participantIdentity===`self`?Ze():Ie()})]}):null,u.kind===`openclaw`?(0,Z.jsxs)($,{label:ct(),children:[(0,Z.jsxs)(W,{value:u.managePermissionModes?`on`:`off`,onValueChange:e=>d({...u,managePermissionModes:e===`on`}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`off`,children:ft()}),(0,Z.jsx)(U,{value:`on`,children:kt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.managePermissionModes?it():Lt()})]}):null,u.kind===`openclaw`?(0,Z.jsxs)($,{label:pn(),children:[(0,Z.jsxs)(W,{value:u.widgetsEnabled?`on`:`off`,onValueChange:e=>d({...u,widgetsEnabled:e===`on`}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`on`,children:_e()}),(0,Z.jsx)(U,{value:`off`,children:ie()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:u.widgetsEnabled?E():v()})]}):null,u.kind===`openclaw`&&u.widgetsEnabled?(0,Z.jsxs)($,{label:fe(),children:[(0,Z.jsxs)(W,{value:u.widgetPromptConfirm?`on`:`off`,onValueChange:e=>d({...u,widgetPromptConfirm:e===`on`}),children:[(0,Z.jsx)(V,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(B,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{value:`off`,children:ce()}),(0,Z.jsx)(U,{value:`on`,children:oe()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:xt()})]}):null,u.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:Ve(),children:(0,Z.jsx)(K,{value:u.systemIdentity,placeholder:_t(),onChange:e=>d({...u,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:Te(),children:(0,Z.jsx)(K,{value:u.gatewayHttpUrl,placeholder:c(),onChange:e=>d({...u,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Wn,{instanceName:f,open:f!==null,onOpenChange:e=>{e||p(null)}}),m?(0,Z.jsx)(On,{instance:m,onClose:()=>h(null)},m._id):null,g?(0,Z.jsx)(Fn,{instance:g,onClose:()=>y(null)},g._id):null]})}function Fn({instance:e,onClose:t}){let n=T(R.instanceSecrets.listInstanceSecretStatus,{}),r=Mn[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(Cn,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(bn,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(xn,{children:ge({instance:e.displayName??e.name})}),(0,Z.jsx)(Sn,{children:re()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Rn,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Ln,{instance:e})}),(0,Z.jsx)(In,{instance:e})]})})}function In({instance:e}){let t=N(R.instanceSync.forceInstanceSync),n=q(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(Fe());break;case`no_agents`:n.success(ut());break;case`no_bridge_url`:n.error(Dt());break;case`deploy_misconfigured`:n.error(Ft());break;case`unauthorized`:n.error(Je());break;case`not_served`:n.error(Xt());break;default:n.error(tt());break}}catch(e){n.error(ot(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:wt()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?en():cn()})})]})}function Ln({instance:e}){let t=T(R.bridgeAuth.listBridgeAuthStatus,{}),n=N(R.bridgeAuth.mintBridgeSecret),r=_(R.bridgeAuth.revokeBridgeSecret),i=q(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),d=(t??[]).find(t=>t.instanceId===e._id),f=d!==void 0;async function p(){if(!a){o(!0);try{let t=await n({instanceId:e._id});c(t.plaintext),u(!1)}catch(e){i.error(I(),e)}finally{o(!1)}}}async function m(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(Vt())}catch(e){i.error(I(),e)}finally{o(!1)}}}async function h(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:Ge(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Wt()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(J,{variant:f?`outline`:`secondary`,children:f?`${M()} · ${d.prefix}…${d.lastFour}`:A()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(G,{size:`sm`,onClick:()=>void p(),disabled:a,children:f?Re():Mt()}),f?(0,Z.jsx)(G,{size:`sm`,variant:`destructive`,onClick:()=>void m(),disabled:a,children:mt()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:qt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(G,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:l?j():bt()})]}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:$e()})]}):null]})}function Rn({instanceId:e,field:t,updatedAt:n}){let r=N(R.instanceSecrets.setInstanceSecret),i=_(R.instanceSecrets.clearInstanceSecret),a=N(R.deviceIdentity.generateDeviceIdentity),s=q(),[c,l]=(0,Y.useState)(``),[d,p]=(0,Y.useState)(!1),[h,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(!1),x=n!==null,S=t===`deviceIdentity`,C=t===`token`?w():t===`deviceIdentity`?g():de();async function T(){if(!(!c.trim()||d)){p(!0);try{await r({instanceId:e,field:t,plaintext:c}),l(``),v(null),b(!1),s.success(f())}catch(e){s.error(m(),e)}finally{p(!1)}}}async function E(){if(!d){p(!0);try{await i({instanceId:e,field:t}),v(null),b(!1),s.success(xe())}catch(e){s.error(m(),e)}finally{p(!1)}}}async function D(){if(!d){p(!0);try{let t=await a({instanceId:e});v(t),b(!1),s.success(ye())}catch(e){s.error(He(),e)}finally{p(!1)}}}let O=h?`openclaw devices approve ${h.id}`:``;async function k(){if(O)try{await navigator.clipboard.writeText(O),b(!0)}catch{}}return(0,Z.jsxs)($,{label:C,children:[S?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(J,{variant:x?`outline`:`secondary`,children:x?M():A()}),(0,Z.jsx)(K,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:x?o():yt(),onChange:e=>l(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(G,{size:`sm`,onClick:()=>void T(),disabled:d||c.trim().length===0,children:Ct()}),S?(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>void D(),disabled:d,children:an()}):null,x?(0,Z.jsx)(G,{size:`sm`,variant:`destructive`,onClick:()=>void E(),disabled:d,children:le()}):null]})]}),h?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:ye()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:sn()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:O}),(0,Z.jsx)(G,{variant:`outline`,size:`sm`,onClick:()=>void k(),children:y?j():bt()})]}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>{v(null),b(!1)},children:$e()})]}):null]})}var zn={conversational:Se,documentary:we,summarizer:Pe,curator:Me},Bn={conversational:x,documentary:s,summarizer:ke,curator:k},Vn=e=>(zn[e]??(()=>e))(),Hn=e=>(Bn[e]??(()=>``))();function Un({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:zt()}),t.map(e=>(0,Z.jsx)(J,{variant:`secondary`,className:`oc-agenttype__chip`,title:Hn(e),children:Vn(e)},e)),(0,Z.jsxs)(vn,{children:[(0,Z.jsx)(_n,{asChild:!0,children:(0,Z.jsx)(G,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:ee()})}),(0,Z.jsxs)(gn,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:y()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Ee()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(z,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Vn(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Hn(r)})]})]},r)})})]})]})]})}function Wn({instanceName:e,open:t,onOpenChange:n}){let i=T(R.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),o=_(R.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(R.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(R.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),s=_(R.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(R.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(R.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),c=_(R.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(R.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=jn(r);e.setQuery(R.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),u=_(R.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(R.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(R.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),f=_(R.agents.removeInstanceAgent),m=_(R.agents.setAgentReservation),g=T(R.groups.listGroupLabels,t?{}:`skip`),v=wn(),y=q();async function b(t,n){if(e&&await v({title:rn({name:n}),description:l(),confirmLabel:be()}))try{await m({instanceName:e,agentId:t,groupId:null})}catch(e){y.error(F(),En(e))}}async function x(t,n,r){if(!e)return;let i=(g??[]).find(e=>e._id===r)?.name??`?`;if(await v({title:Ut({name:n,group:i}),description:jt({group:i}),confirmLabel:Yt()}))try{await m({instanceName:e,agentId:t,groupId:r})}catch(e){y.error(F(),En(e))}}async function S(t,n){if(e)try{await o({instanceName:e,agentId:t,enabled:n})}catch(e){y.error(F(),e)}}async function w(t){if(e)try{await s({instanceName:e,agentId:t})}catch(e){y.error(F(),e)}}async function E(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await c({instanceName:e,agentId:t,types:i})}catch(e){y.error(F(),e)}}async function D(t,n){if(e&&await v({title:ne({name:n}),description:C(),confirmLabel:h(),destructive:!0}))try{await f({instanceName:e,agentId:t}),y.success(ue())}catch(e){y.error(F(),e)}}return(0,Z.jsx)(Cn,{open:t,onOpenChange:n,children:(0,Z.jsxs)(bn,{className:`oc-access`,children:[(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(xn,{children:r({name:e??``})}),(0,Z.jsx)(Sn,{children:pe()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:se()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?ae():i.discovery.lastPollOk?vt():a({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:St()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i.agents.map(t=>{let n=t.presentInLastOk===!1,r=i.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(z,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void S(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,t.reserved?(0,Z.jsx)(J,{variant:`outline`,children:t.reserved.groupName===null?p():d({group:t.reserved.groupName})}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(J,{variant:`outline`,className:`oc-access__gone`,children:on()}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void D(t.agentId,a),children:he()})]}):r?(0,Z.jsx)(J,{variant:`default`,children:P()}):(0,Z.jsx)(G,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled||t.reserved!==null,onClick:()=>void w(t.agentId),children:dn()})]}),t.reserved?(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(G,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>void b(t.agentId,a),children:be()}),(0,Z.jsxs)(W,{value:``,onValueChange:e=>void x(t.agentId,a,e),children:[(0,Z.jsx)(V,{size:`sm`,className:`h-7`,children:(0,Z.jsx)(B,{placeholder:ve()})}),(0,Z.jsx)(H,{children:(g??[]).filter(e=>e._id!==t.reserved?.groupId).map(e=>(0,Z.jsx)(U,{value:e._id,children:e.name},e._id))})]})]}):null,t.enabled?(0,Z.jsx)(Un,{agentId:t.agentId,types:o,onToggle:e=>void E(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Gn,{value:t.description??``,onSave:async n=>{if(e)try{await u({instanceName:e,agentId:t.agentId,description:n})}catch(e){y.error(F(),e)}}}):null]},t.agentId)})})]})]})})}function Gn({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(K,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Ae(),"aria-label":D(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Pn as InstancesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$R as r,FZ as i,IZ as a,JR as o,NZ as s,QR as c,XR as l,YR as u,ZR as d,_g as f,az as p,dg as m,ez as h,fg as g,gg as _,hg as v,iz as y,mg as b,nz as x,oz as S,pg as C,rz as w,sz as T,t as E,tz as D,ug as O,vg as k}from"./api-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$R as r,FZ as i,IZ as a,JR as o,NZ as s,QR as c,XR as l,YR as u,ZR as d,_g as f,az as p,dg as m,ez as h,fg as g,gg as _,hg as v,iz as y,mg as b,nz as x,oz as S,pg as C,rz as w,sz as T,t as E,tz as D,ug as O,vg as k}from"./api-C9TZ4xjz.js";import{t as A}from"./checkbox-Bbl8iiIs.js";import"./select-CeQpPnet.js";import{t as j}from"./button-DEKA-XdT.js";import{t as M}from"./input-BW0GOs_g.js";import"./convexApi-D2VdPGGW.js";import{t as N}from"./badge-UrSDbO1c.js";var P=t(e(),1),F=n();function I(){let e=a(E.integrations.status.status,{}),t=i(E.admin.setIntegrationConfig),[n,s]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&s(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:T()});let m=n,g=(e,t,n)=>s({...m,[e]:{...m[e],[t]:n}}),v=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[S(),` `,(0,F.jsx)(`strong`,{children:p()}),` `,y()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(N,{variant:`secondary`,children:w()}):(0,F.jsx)(N,{variant:`outline`,children:x()}):(0,F.jsx)(N,{variant:`outline`,children:D()}),note:h(),children:[(0,F.jsx)(R,{label:c(),children:(0,F.jsx)(M,{value:m.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>g(`langfuse`,`host`,e.target.value),onBlur:()=>v(`langfuse`,{host:m.langfuse.host??``})})}),(0,F.jsx)(z,{label:o(),checked:m.langfuse.enabled??!0,onChange:e=>{g(`langfuse`,`enabled`,e),v(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(N,{variant:`secondary`,children:w()}):(0,F.jsx)(N,{variant:`outline`,children:x()}):(0,F.jsx)(N,{variant:`outline`,children:D()}),note:r(),children:[(0,F.jsx)(R,{label:d(),children:(0,F.jsx)(M,{value:m.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>g(`opik`,`baseUrl`,e.target.value),onBlur:()=>v(`opik`,{baseUrl:m.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:l(),children:(0,F.jsx)(M,{value:m.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||u(),onChange:e=>g(`opik`,`workspace`,e.target.value),onBlur:()=>v(`opik`,{workspace:m.opik.workspace??``})})}),(0,F.jsx)(z,{label:o(),checked:m.opik.enabled??!0,onChange:e=>{g(`opik`,`enabled`,e),v(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(N,{variant:`secondary`,children:w()}):(0,F.jsx)(N,{variant:`outline`,children:x()}):(0,F.jsx)(N,{variant:`outline`,children:k()}),note:f(),children:[(0,F.jsx)(R,{label:_(),children:(0,F.jsx)(M,{value:m.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>g(`otlp`,`endpoint`,e.target.value),onBlur:()=>v(`otlp`,{endpoint:m.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:o(),checked:m.otlp.enabled??!0,onChange:e=>{g(`otlp`,`enabled`,e),v(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(A,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=s(E.integrations.otlpSecret.setOtlpHeaders),n=i(E.integrations.otlpSecret.clearOtlpHeaders),[r,a]=(0,P.useState)(``),[o,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),d=async()=>{u(!0),c(null);try{await t({headersJson:r}),a(``)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,F.jsxs)(R,{label:v(),children:[(0,F.jsx)(M,{value:r,placeholder:e?b():C(),onChange:e=>a(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 d(),children:g()}),e?(0,F.jsx)(j,{variant:`ghost`,size:`sm`,disabled:l,onClick:()=>void n({}),children:m()}):null]}),o?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:o}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:O()})]})}export{I as IntegrationsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$ as r,A as i,By as a,Cy as o,D as s,FZ as c,Gy as l,Hy as u,IZ as d,Iy as f,Ly as p,O as ee,Q as m,Ry as h,Uy as g,Vy as _,Wy as v,_y as y,aW as b,et as x,gy as S,k as C,t as w,tt as T,vy as E,xy as te,zy as D}from"./api-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$ as r,A as i,By as a,Cy as o,D as s,FZ as c,Gy as l,Hy as u,IZ as d,Iy as f,Ly as p,O as ee,Q as m,Ry as h,Uy as g,Vy as _,Wy as v,_y as y,aW as b,et as x,gy as S,k as C,t as w,tt as T,vy as E,xy as te,zy as D}from"./api-C9TZ4xjz.js";import{t as ne}from"./loader-circle-D_v0YERy.js";import{t as re}from"./rotate-ccw-Bs40VcST.js";import"./convexApi-D2VdPGGW.js";import{r as ie,t as O}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`?h():e===`fast`?p():f()}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 ae(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 W(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:o({pct:n,used:L(e),total:L(t)})}function q(e){return te({level:e??`full`})}function J(e,t){let n=typeof e==`number`,r=typeof t==`number`;return n&&r?E({cost:e.toFixed(2),tokens:L(t)}):n?y({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?x():r();return e===`agent`?{inheritedLabel:i(),resetLabel:ee({value:n})}:e===`instance`?{inheritedLabel:C(),resetLabel:s({value:n})}:{}}function Y(e,t){let n=d(w.compat.forChat,e===null?`skip`:{chatId:e,...t?{routedAgent:t}:{}}),r=n==null?null:n.capabilities;return{can:(0,k.useCallback)(e=>O(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=c(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:d,resetLabel:f}){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)(ne,{size:13,className:`oc-spanel__spin`,"aria-label":g()}):t?c?(0,X.jsx)(`button`,{type:`button`,className:`oc-spanel__reset`,title:f??v(),"aria-label":f??v(),onClick:n,children:(0,X.jsx)(re,{size:12,"aria-hidden":!0})}):null:(0,X.jsx)(`span`,{className:`oc-spanel__badge`,children:d??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:[u(),(0,X.jsx)(`button`,{type:`button`,className:`oc-spanel__retry`,onClick:a,children:_()})]}):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:i,error:o}=Z(e),{can:s}=Y(e),c=i!==null,l=(0,k.useCallback)(()=>{o&&r(o.field,o.value)},[r,o]),u=t?.thinkingLevels??[],d=t?.availableModels??[],f=P(n),p=ie(s,{hasModels:d.length>0,hasLevels:u.length>0,described:t!==null});return(0,X.jsxs)(X.Fragment,{children:[p.model?(0,X.jsx)(Q,{label:b(),overridden:M(n,`model`),onReset:()=>void r(`model`,null),pending:i===`model`,error:o?.field===`model`,onRetry:l,resettable:p.reset,children:(0,X.jsx)($,{field:`model`,options:d,value:t?.model??null,onChange:e=>void r(`model`,e),disabled:c,ariaLabel:b()})}):null,p.thinking?(0,X.jsx)(Q,{label:a(),overridden:M(n,`thinkingLevel`),onReset:()=>void r(`thinkingLevel`,null),pending:i===`thinkingLevel`,error:o?.field===`thinkingLevel`,onRetry:l,resettable:p.reset,children:(0,X.jsx)($,{field:`thinkingLevel`,ariaLabel:a(),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:i===`showReasoning`,error:o?.field===`showReasoning`,onRetry:l,disabled:c}),p.speed?(0,X.jsx)(Q,{label:D(),overridden:M(n,`fastMode`),onReset:()=>void r(`fastMode`,null),pending:i===`fastMode`,error:o?.field===`fastMode`,onRetry:l,resettable:p.reset,children:(0,X.jsx)($,{field:`fastMode`,ariaLabel:D(),options:N.map(e=>({id:e,label:F(e)})),value:f,onChange:e=>void r(`fastMode`,I(e)),disabled:c})}):null]})}function fe({chatId:e,overridden:t,onApply:n,pending:i,error:a,onRetry:o,disabled:s}){let c=d(w.messages.getSessionMeta,{chatId:e}),l=c?.showReasoning===!0,{inheritedLabel:u,resetLabel:f}=ce(c?.showReasoningDefaultSource,c?.showReasoningDefault===!0);return(0,X.jsx)(Q,{label:T(),overridden:t,inheritedLabel:u,resetLabel:f,onReset:()=>n(null),pending:i,error:a,onRetry:o,help:m(),children:(0,X.jsx)($,{field:`showReasoning`,ariaLabel:T(),options:[{id:`on`,label:x()},{id:`off`,label:r()}],value:c==null?null:l?`on`:`off`,onChange:e=>n(e===`on`),disabled:s})})}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,ae as s,$ as t,W as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$z as r,FB as i,IZ as a,Sk as o,_k as s,bk as c,cB as l,ck as u,dk as d,eB as f,fk as p,gk as m,hk as h,lB as g,lk as ee,mk as te,pk as _,sB as v,t as y,uB as b,uk as x,vk as S,xk as C,yk as w}from"./api-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$z as r,FB as i,IZ as a,Sk as o,_k as s,bk as c,cB as l,ck as u,dk as d,eB as f,fk as p,gk as m,hk as h,lB as g,lk as ee,mk as te,pk as _,sB as v,t as y,uB as b,uk as x,vk as S,xk as C,yk as w}from"./api-C9TZ4xjz.js";import{n as T,t as E}from"./useNavigate-D3GIoxyW.js";import"./convexApi-D2VdPGGW.js";import{c as D,n as ne,o as re}from"./searchSchemas-Dm-Qg010.js";import{t as O}from"./appHost-CH3EGcJw.js";import{a as k,n as A,o as j,r as M,t as N}from"./card-CoPKGkaG.js";import{n as P,t as F}from"./TimeRangePicker-B3Jl2mvx.js";var I=t(e(),1),L={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`},R=Object.keys(L).length,z=n(),B=15,V=e=>String(Math.round(e));function H(){let e=a(y.me.getMe,{host:O})?.permissions?.includes(`traces.read`)??!1,t=a(y.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,I.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,B).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:i()}),(0,z.jsxs)(N,{children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{children:b()}),(0,z.jsx)(M,{children:l()})]}),(0,z.jsx)(A,{children:n.length<2?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):(0,z.jsx)(U,{series:n})})]})]})}function U({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),i=Math.max(1,...t,...n),a=t=>6+t*468/(e.length-1),o=e=>74-e*68/i,s=e=>e.map((e,t)=>`${t===0?`M`:`L`}${a(t).toFixed(1)},${o(e).toFixed(1)}`).join(` `),c=e[e.length-1];return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{style:{color:`var(--primary)`},children:[r(),` p50 `,V(c.cP50),` `,g()]}),(0,z.jsxs)(`span`,{children:[f(),` p50 `,V(c.aP50),` `,g()]})]}),(0,z.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":b(),children:[(0,z.jsx)(`path`,{d:s(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,z.jsx)(`path`,{d:s(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var W=[{metric:`api.calls`,label:o(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:C(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:c(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:w(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:S(),unit:`/h`,group:`Chat`,isError:!1},{metric:L.ASSISTANT_STREAM_ERRORS,label:s(),unit:`/h`,group:`Assistant`,isError:!0},{metric:L.ASSISTANT_ANNOUNCE_ERRORS,label:m(),unit:`/h`,group:`Assistant`,isError:!0}],G=R,K=[`API`,`OpenClaw`,`Chat`,`Assistant`],q=1e3,J=36e5;function Y(e,t){let n=Math.max(1,Math.ceil((t-e)/J)),r=Math.min(n*G,q);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/G))}}function ie(){let e=T({from:`/settings/kpi`}),t=E({from:`/settings/kpi`}),n=re(e.from,e.to,ne,`now`),r=e=>void t({search:t=>({...t,...D(e)})}),{from:i,to:o}=P(n),{rowLimit:s,buckets:c}=Y(i,o),l=a(y.kpi.listKpis,{limit:s,filter:{from:i,to:o}}),u=(0,I.useMemo)(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>c&&e.set(t,n.slice(n.length-c));return e},[l,c]),d=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`p`,{className:`oc-admin__hint`,children:[h(),` `,(0,z.jsx)(`span`,{className:`oc-filter__window`,children:te()})]}),(0,z.jsx)(ae,{value:n,onChange:r})]});return l===void 0?(0,z.jsxs)(z.Fragment,{children:[d,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:_()})]}):l.length===0?(0,z.jsxs)(z.Fragment,{children:[d,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:p()})]}):(0,z.jsxs)(z.Fragment,{children:[d,(0,z.jsx)(H,{}),K.map(e=>{let t=W.filter(t=>t.group===e);return t.some(e=>(u.get(e.metric)??[]).length>0)?(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,z.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,z.jsx)(oe,{config:e,series:u.get(e.metric)??[]},e.metric))})]},e):null})]})}function ae({value:e,onChange:t}){return(0,z.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,z.jsx)(F,{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,z.jsxs)(N,{size:`sm`,className:`oc-kpi__card`,children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{className:`oc-kpi__card-title`,children:e.label}),(0,z.jsx)(M,{className:`oc-kpi__card-metric`,children:(0,z.jsx)(`code`,{children:e.metric})})]}),(0,z.jsxs)(A,{className:`oc-kpi__card-body`,children:[(0,z.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,z.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,z.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,z.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,z.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,z.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:d({value:$(n.bucket)})}):(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:x()}),(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:ee({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,z.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,z.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":u({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,z.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,z.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{ie as KpiTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$G as r,$X as i,CK as a,DK as o,EK as s,EZ as c,FZ as l,GG as u,IZ as d,JG as f,KG as p,OK as m,QG as h,QX as ee,SK as te,TK as ne,Tl as re,WG as ie,XG as ae,XI as oe,XX as se,YG as ce,YX as le,ZG as g,ZX as ue,_K as de,_Z as fe,aK as pe,aZ as me,al as he,bK as _,cK as v,cZ as y,cl as b,dK as x,dZ as S,dl as C,eK as w,eZ as T,fK as E,fZ as D,gK as O,gZ as k,hK as A,hZ as j,iK as M,iZ as N,il as P,kK as F,lK as I,lZ as L,ll as R,mK as ge,mZ as _e,nK as ve,nZ as ye,oK as be,oZ as xe,ol as Se,pK as Ce,pZ as we,qG as Te,rK as z,rZ as Ee,sK as De,sZ as Oe,sl as ke,t as B,tK as Ae,tZ as je,uK as Me,uZ as Ne,ul as Pe,vK as Fe,vZ as Ie,wK as Le,wl as Re,xK as ze,xZ as Be,yK as Ve,yl as He}from"./api-DNOgniXv.js";import{t as V}from"./checkbox-kFoJxcMJ.js";import{a as Ue,i as We,n as Ge,r as H,t as Ke}from"./select-CYo6IZR2.js";import{t as U}from"./button-2XjWVeWK.js";import{t as W}from"./input-BOl1ZpD6.js";import"./convexApi-4XI9Ua6G.js";import{c as qe,d as Je,r as Ye,t as Xe,u as Ze}from"./useFontScale-T-slFQPF.js";import{r as Qe}from"./toast-DN6P_at0.js";import{t as G}from"./badge-D7TV9F5d.js";import{t as K}from"./appHost-CH3EGcJw.js";import{t as $e}from"./localePickerView-C2RmOS86.js";import{t as et}from"./switch-B0io8PF7.js";import{t as tt}from"./TimezoneCombobox-DAhFeIgd.js";var q=t(e(),1),J=[{id:`messages`,label:()=>F()},{id:`composer`,label:()=>m()},{id:`sidebar`,label:()=>o()},{id:`notifications`,label:()=>Me()},{id:`other`,label:()=>s()}],Y={showSource:{category:`messages`,label:()=>ne(),help:()=>Le()},showReport:{category:`messages`,label:()=>a(),help:()=>te()},copyAssistant:{category:`messages`,label:()=>ze()},copyUser:{category:`messages`,label:()=>_()},showDelete:{category:`messages`,label:()=>Ve()},showTools:{category:`messages`,label:()=>Fe(),help:()=>de()},voiceInput:{category:`composer`,label:()=>O(),help:()=>A()},showUsage:{category:`composer`,label:()=>ge(),help:()=>Ce()},autoReadAloud:{category:`composer`,label:()=>re(),help:()=>Re()},showChatAge:{category:`sidebar`,label:()=>E(),help:()=>x()},notifSound:{category:`notifications`,label:()=>I(),help:()=>v()},notifSystem:{category:`notifications`,label:()=>De(),help:()=>be()},replySound:{category:`notifications`,label:()=>pe(),help:()=>M()}};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:()=>f()};function lt({prefKey:e,ui:t}){let n=l(B.admin.setUiPrefDefault),r=l(B.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:h()}),(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:p()}),(0,$.jsx)(H,{value:`off`,children:u()}),(0,$.jsx)(H,{value:`inherit`,children:ie()})]})]}),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=l(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=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:[C(),e?(0,$.jsx)(G,{variant:`secondary`,children:Je(e,qe())}):null]}),(0,$.jsx)(`span`,{className:`oc-prefs__help`,children:a?b():r?R():Pe()})]}),(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:P()}):null,(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?he():e?Se():ke()})]})]})}function dt(){let[e,t]=(0,q.useState)(``),[n,i]=(0,q.useState)(!1),a=d(B.me.getMe,{host:K}),o=a?.ui,s=Z(a?.role)&&n,u=l(B.me.setUiPref).withOptimisticUpdate(Ye),f=(0,q.useMemo)(()=>o?nt(Object.keys(o.effective),e):[],[o,e]);return o?(0,$.jsxs)(`div`,{className:`oc-prefs-panel`,children:[Z(a?.role)?(0,$.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,$.jsx)(V,{checked:n,onCheckedChange:e=>i(e===!0),"aria-label":r()}),r()]}):null,s?(0,$.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,$.jsx)(`p`,{children:ae()}),(0,$.jsx)(`p`,{children:ce()}),(0,$.jsx)(`p`,{children:Te()})]}):null,(0,$.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:z(),"aria-label":z(),className:`mb-2`}),f.length===0?(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:ve()}):(0,$.jsx)(`div`,{className:`oc-prefs`,children:f.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],c=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:Ae()}):c?(0,$.jsx)(G,{variant:`secondary`,children:He()}):null]}),r?(0,$.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,$.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&c?(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void u({key:e,value:null}),children:w()}):null,(0,$.jsx)(et,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),u({key:e,value:t})},"aria-label":n})]}),s?(0,$.jsx)(lt,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,$.jsx)(ut,{current:a?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:c()})}var ft={sm:()=>xe(),md:()=>me(),lg:()=>N(),xl:()=>Ee(),"2xl":()=>ye(),"3xl":()=>je()};function pt(){let e=d(B.me.getMe,{host:K}),t=l(B.me.setLocale),n=l(B.me.setTimezone),r=l(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:K});n&&e.setQuery(B.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),a=l(B.me.setMyName),o=Qe(),s=e?.locale??`default`,c=e?.name??``,[u,f]=(0,q.useState)(null),p=u??c,m=p.trim()!==c.trim();async function h(){try{await a({name:p}),f(null),o.success(_e())}catch(e){o.error(we(),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:fe()})]}),(0,$.jsxs)(`div`,{className:`oc-show__row`,children:[(0,$.jsx)(W,{className:`max-w-xs`,value:p,maxLength:120,placeholder:k(),onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m&&(e.preventDefault(),h())}}),(0,$.jsx)(U,{size:`sm`,disabled:!m,onClick:()=>void h(),children:oe()})]}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:j()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:D()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:S()})]}),(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:Be()})]}),(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:T()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:i()})]}),(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:ue()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:L()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:y()})]}),(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:Oe()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:se()}),(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{$G as r,$X as i,CK as a,DK as o,EK as s,EZ as c,FZ as l,GG as u,IZ as d,JG as f,KG as p,OK as m,QG as h,QX as ee,SK as te,TK as ne,Tl as re,WG as ie,XG as ae,XI as oe,XX as se,YG as ce,YX as le,ZG as g,ZX as ue,_K as de,_Z as fe,aK as pe,aZ as me,al as he,bK as _,cK as v,cZ as y,cl as b,dK as x,dZ as S,dl as C,eK as w,eZ as T,fK as E,fZ as D,gK as O,gZ as k,hK as A,hZ as j,iK as M,iZ as N,il as P,kK as F,lK as I,lZ as L,ll as R,mK as ge,mZ as _e,nK as ve,nZ as ye,oK as be,oZ as xe,ol as Se,pK as Ce,pZ as we,qG as Te,rK as z,rZ as Ee,sK as De,sZ as Oe,sl as ke,t as B,tK as Ae,tZ as je,uK as Me,uZ as Ne,ul as Pe,vK as Fe,vZ as Ie,wK as Le,wl as Re,xK as ze,xZ as Be,yK as Ve,yl as He}from"./api-C9TZ4xjz.js";import{t as V}from"./checkbox-Bbl8iiIs.js";import{a as Ue,i as We,n as Ge,r as H,t as Ke}from"./select-CeQpPnet.js";import{t as U}from"./button-DEKA-XdT.js";import{t as W}from"./input-BW0GOs_g.js";import"./convexApi-D2VdPGGW.js";import{c as qe,d as Je,r as Ye,t as Xe,u as Ze}from"./useFontScale-CWLfjbAm.js";import{r as Qe}from"./toast-pKIYRpST.js";import{t as G}from"./badge-UrSDbO1c.js";import{t as K}from"./appHost-CH3EGcJw.js";import{t as $e}from"./localePickerView-C2RmOS86.js";import{t as et}from"./switch-BZom6_SV.js";import{t as tt}from"./TimezoneCombobox-CWbHKOiS.js";var q=t(e(),1),J=[{id:`messages`,label:()=>F()},{id:`composer`,label:()=>m()},{id:`sidebar`,label:()=>o()},{id:`notifications`,label:()=>Me()},{id:`other`,label:()=>s()}],Y={showSource:{category:`messages`,label:()=>ne(),help:()=>Le()},showReport:{category:`messages`,label:()=>a(),help:()=>te()},copyAssistant:{category:`messages`,label:()=>ze()},copyUser:{category:`messages`,label:()=>_()},showDelete:{category:`messages`,label:()=>Ve()},showTools:{category:`messages`,label:()=>Fe(),help:()=>de()},voiceInput:{category:`composer`,label:()=>O(),help:()=>A()},showUsage:{category:`composer`,label:()=>ge(),help:()=>Ce()},autoReadAloud:{category:`composer`,label:()=>re(),help:()=>Re()},showChatAge:{category:`sidebar`,label:()=>E(),help:()=>x()},notifSound:{category:`notifications`,label:()=>I(),help:()=>v()},notifSystem:{category:`notifications`,label:()=>De(),help:()=>be()},replySound:{category:`notifications`,label:()=>pe(),help:()=>M()}};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:()=>f()};function lt({prefKey:e,ui:t}){let n=l(B.admin.setUiPrefDefault),r=l(B.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:h()}),(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:p()}),(0,$.jsx)(H,{value:`off`,children:u()}),(0,$.jsx)(H,{value:`inherit`,children:ie()})]})]}),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=l(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=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:[C(),e?(0,$.jsx)(G,{variant:`secondary`,children:Je(e,qe())}):null]}),(0,$.jsx)(`span`,{className:`oc-prefs__help`,children:a?b():r?R():Pe()})]}),(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:P()}):null,(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?he():e?Se():ke()})]})]})}function dt(){let[e,t]=(0,q.useState)(``),[n,i]=(0,q.useState)(!1),a=d(B.me.getMe,{host:K}),o=a?.ui,s=Z(a?.role)&&n,u=l(B.me.setUiPref).withOptimisticUpdate(Ye),f=(0,q.useMemo)(()=>o?nt(Object.keys(o.effective),e):[],[o,e]);return o?(0,$.jsxs)(`div`,{className:`oc-prefs-panel`,children:[Z(a?.role)?(0,$.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,$.jsx)(V,{checked:n,onCheckedChange:e=>i(e===!0),"aria-label":r()}),r()]}):null,s?(0,$.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,$.jsx)(`p`,{children:ae()}),(0,$.jsx)(`p`,{children:ce()}),(0,$.jsx)(`p`,{children:Te()})]}):null,(0,$.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:z(),"aria-label":z(),className:`mb-2`}),f.length===0?(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:ve()}):(0,$.jsx)(`div`,{className:`oc-prefs`,children:f.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],c=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:Ae()}):c?(0,$.jsx)(G,{variant:`secondary`,children:He()}):null]}),r?(0,$.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,$.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&c?(0,$.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void u({key:e,value:null}),children:w()}):null,(0,$.jsx)(et,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),u({key:e,value:t})},"aria-label":n})]}),s?(0,$.jsx)(lt,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,$.jsx)(ut,{current:a?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,$.jsx)(`div`,{className:`oc-prefs__empty`,children:c()})}var ft={sm:()=>xe(),md:()=>me(),lg:()=>N(),xl:()=>Ee(),"2xl":()=>ye(),"3xl":()=>je()};function pt(){let e=d(B.me.getMe,{host:K}),t=l(B.me.setLocale),n=l(B.me.setTimezone),r=l(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:K});n&&e.setQuery(B.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),a=l(B.me.setMyName),o=Qe(),s=e?.locale??`default`,c=e?.name??``,[u,f]=(0,q.useState)(null),p=u??c,m=p.trim()!==c.trim();async function h(){try{await a({name:p}),f(null),o.success(_e())}catch(e){o.error(we(),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:fe()})]}),(0,$.jsxs)(`div`,{className:`oc-show__row`,children:[(0,$.jsx)(W,{className:`max-w-xs`,value:p,maxLength:120,placeholder:k(),onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m&&(e.preventDefault(),h())}}),(0,$.jsx)(U,{size:`sm`,disabled:!m,onClick:()=>void h(),children:oe()})]}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:j()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:D()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:S()})]}),(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:Be()})]}),(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:T()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:i()})]}),(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:ue()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:L()}),(0,$.jsx)(`p`,{className:`oc-show__desc`,children:y()})]}),(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:Oe()})]}),(0,$.jsxs)(`section`,{className:`oc-show__section`,children:[(0,$.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,$.jsx)(`h2`,{className:`oc-show__title`,children:se()}),(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{$D as r,AO as i,BD as a,CO as o,E as s,EO as c,EZ as l,FO as u,FZ as d,GD as f,GO as ee,HD as p,ID as m,IO as te,IZ as h,LD as ne,MO as g,Ms as _,Mw as re,QD as ie,RD as ae,RO as v,SO as y,UD as b,UO as oe,VD as x,WO as se,ZD as ce,_O as S,aO as C,bO as w,cO as le,dO as T,eO as E,fO as ue,gO as de,hO as D,iO as O,js as fe,kO as pe,lO as me,mO as he,nD as ge,nO as _e,oO as ve,pO as ye,qD as be,rO as xe,sO as Se,t as k,uO as Ce,vO as we,wO as A,xO as Te,zD as Ee,zO as De}from"./api-DNOgniXv.js";import{n as Oe,t as j}from"./useNavigate-D3GIoxyW.js";import{A as ke,B as Ae,C as M,D as je,E as N,F as P,G as Me,H as Ne,I as F,J as Pe,K as I,R as Fe,S as L,T as Ie,U as Le,V as Re,W as R,_ as ze,a as z,f as B,h as Be,i as Ve,j as He,m as Ue,n as V,o as H,p as U,r as We,s as W,t as Ge,u as Ke,w as qe,x as Je,y as Ye,z as Xe}from"./useStartNewChat-Bg4hLp3d.js";import{r as Ze}from"./dist-vqdeesMI.js";import{t as Qe}from"./chevron-right-9DjIYDNR.js";import{c as $e,g as et,i as tt,n as nt,r as G,s as rt,t as it}from"./dropdown-menu-BaUA_yBi.js";import{n as at,t as ot}from"./eye-Dj_nvUMH.js";import{t as st}from"./list-CgDCvRps.js";import{t as ct}from"./pencil-C9Bd090l.js";import{t as lt}from"./trash-2-BmifkPwA.js";import{t as K}from"./button-2XjWVeWK.js";import{t as ut}from"./input-BOl1ZpD6.js";import"./convexApi-4XI9Ua6G.js";import{r as dt}from"./toast-DN6P_at0.js";import{n as ft,r as pt}from"./ConfirmDialog-DUn2vS3y.js";import{t as mt}from"./EntitySheet-BHlTwSgy.js";import{r as ht,t as gt}from"./trashView-Cd0pvgnM.js";var _t=s(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),vt=s(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),yt=s(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),q=s(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),J=t(e(),1),Y=n();function bt({className:e}){return(0,Y.jsx)($e,{asChild:!0,children:(0,Y.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":b(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Y.jsx)(et,{})})})}function X({folderId:e,name:t,color:n,currentParentId:a,className:o,onOpen:s}){let l=d(k.projects.renameProject),m=d(k.projects.setProjectColor),te=d(k.projects.moveProject),ne=d(k.projects.deleteProject),g=d(k.projects.createProject),_=ft(),re=ht(),ie=pt(),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(t),[C,w]=(0,J.useState)(!1),[le,T]=(0,J.useState)(!1),E=h(k.projects.projectTreeCount,le?{projectId:e}:`skip`);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(it,{onOpenChange:e=>e&&T(!0),children:[(0,Y.jsx)(bt,{className:o}),(0,Y.jsxs)(nt,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(G,{onSelect:()=>s(),children:[(0,Y.jsx)(I,{}),` `,c()]}),(0,Y.jsxs)(G,{onSelect:()=>{x(t),y(!0)},children:[(0,Y.jsx)(ct,{}),` `,p()]}),(0,Y.jsxs)(G,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await ie({title:S(),label:ee(),placeholder:se(),confirmLabel:oe()});t&&await g({name:t,parentId:e})})},children:[(0,Y.jsx)(Me,{}),` `,S()]}),(0,Y.jsxs)(G,{onSelect:()=>w(!0),children:[(0,Y.jsx)(vt,{}),` `,r()]}),(0,Y.jsx)(tt,{children:Ee()}),(0,Y.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void m({projectId:e,color:null}),"aria-label":ae(),children:`✕`}),Ve.map(t=>(0,Y.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void m({projectId:e,color:t.value})},t.value))]}),(0,Y.jsx)(rt,{}),(0,Y.jsxs)(G,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=E?.folders??0,r=E?.chats??0;await _({title:pe({name:t}),description:gt({folders:n,chats:r,days:re}),confirmWord:f(),confirmLabel:i(),destructive:!0})&&await ne({projectId:e})})},children:[(0,Y.jsx)(lt,{}),` `,f()]})]})]}),(0,Y.jsx)(mt,{open:v,onOpenChange:y,title:u(),canSubmit:b.trim().length>0,onSubmit:async()=>{await l({projectId:e,name:b.trim()}),y(!1)},submitLabel:p(),children:(0,Y.jsx)(ut,{value:b,onChange:e=>x(e.target.value),autoFocus:!0})}),C?(0,Y.jsx)(We,{open:C,onOpenChange:w,title:ce(),movingFolderId:e,currentId:a,onPick:t=>void te({projectId:e,parentId:t})}):null]})}function xt({chat:e,currentFolderId:t,className:n}){let r=d(k.chats.pinChat),i=d(k.chats.deleteChat),s=d(k.chats.renameChat),c=d(k.chats.setChatSidebar),l=d(k.chats.moveChatToProject),u=ft(),ee=ht(),[te,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(e.title??``),[re,ae]=(0,J.useState)(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(it,{children:[(0,Y.jsx)(bt,{className:n}),(0,Y.jsxs)(nt,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(G,{onSelect:()=>{_(e.title??``),h(!0)},children:[(0,Y.jsx)(ct,{}),` `,p()]}),(0,Y.jsxs)(G,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Y.jsx)(Xe,{}):(0,Y.jsx)(Ae,{}),e.pinned?x():a()]}),(0,Y.jsxs)(G,{onSelect:()=>ae(!0),children:[(0,Y.jsx)(vt,{}),` `,E()]}),e.pinned&&e.inSidebar?null:(0,Y.jsxs)(G,{onSelect:()=>void c({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Y.jsx)(Re,{}):(0,Y.jsx)(q,{}),e.inSidebar?o():A()]}),(0,Y.jsx)(rt,{}),(0,Y.jsxs)(G,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await u({title:ne(),description:m({days:ee}),confirmLabel:f(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Y.jsx)(lt,{}),` `,f()]})]})]}),(0,Y.jsx)(mt,{open:te,onOpenChange:h,title:ge(),canSubmit:g.trim().length>0,onSubmit:async()=>{await s({chatId:e._id,title:g.trim()}),h(!1)},submitLabel:p(),children:(0,Y.jsx)(ut,{value:g,onChange:e=>_(e.target.value),autoFocus:!0})}),re?(0,Y.jsx)(We,{open:re,onOpenChange:ae,title:ie(),currentId:t,onPick:t=>void l({chatId:e._id,projectId:t})}):null]})}function St(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function Ct(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 wt(e,t){let n=new Map(t.map(e=>[e.chatId,e.lastSeenAt])),r=new Set;for(let t of e){let e=n.get(t._id);e!==void 0&&t.lastAssistantAt!==null&&t.lastAssistantAt>e&&r.add(t._id)}return r}var Tt=`oc.projpage.view`;function Et(){let e=localStorage.getItem(Tt);return e===`cards`||e===`list`?e:`columns`}var Z=e=>`into:${e}`,Dt=e=>`col:${e??`null`}`,Q=e=>`crumb:${e}`;function Ot(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 kt(){let{projectId:e}=Pe({from:`/project/$projectId`}),t=j(),n=h(k.projects.projectPage,{projectId:e});return(0,Y.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:l()}):n===null?(0,Y.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Y.jsx)(`h2`,{children:C()}),(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:O()}),(0,Y.jsx)(K,{variant:`outline`,onClick:()=>void t({to:`/`}),children:xe()})]}):(0,Y.jsx)(At,{page:n})})}function At({page:e}){let t=j(),n=ft(),a=ht(),o=pt(),s=dt(),c=d(k.projects.renameProject),l=d(k.projects.setProjectColor),m=d(k.projects.deleteProject),ne=d(k.projects.createProject),g=d(k.projects.moveProject),ie=d(k.projects.setProjectSidebar),v=d(k.chats.moveChatToProject),b=d(k.chats.reorderChat),x=d(k.projects.reorderProject),C=h(k.projects.projectTreeCount,{projectId:e.project._id}),[T,E]=(0,J.useState)(Et),de=e=>{localStorage.setItem(Tt,e),E(e)},D=h(k.projects.folderColumns,T===`columns`?{projectId:e.project._id}:`skip`),O=h(k.projects.projectTreeList,T===`list`?{projectId:e.project._id}:`skip`),{c:ge}=Oe({from:`/project/$projectId`}),xe=h(k.projects.listProjects,{}),Ce=h(k.chatReads.myBusyChats,{}),A=(0,J.useMemo)(()=>new Set(Ce??[]),[Ce]),{byChat:Ae}=Fe(Ce??null),M=h(k.chatReads.myChatReads,{}),N=(0,J.useMemo)(()=>wt(e.chats,M??[]),[e.chats,M]),{startNewChat:F,picker:Pe}=Ge(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[I,Re]=(0,J.useState)(``),[z,B]=(0,J.useState)(!1),[V,Xe]=(0,J.useState)(e.project.name),[Ze,Qe]=(0,J.useState)(!1),[q,bt]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=setTimeout(()=>bt(I.trim()),180);return()=>clearTimeout(e)},[I]);let X=h(k.search.searchConversations,q.length>=2?{query:q,projectId:e.project._id}:`skip`),xt=Ie(qe(ze,{activationConstraint:{distance:4}}),qe(Ye,{activationConstraint:{delay:250,tolerance:8}})),Z=(0,J.useRef)(!1),Dt=()=>{Z.current=!0,setTimeout(()=>{Z.current=!1},0)},[Q,kt]=(0,J.useState)(null),At=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=D?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||De()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(xe??[]).find(t=>t._id===e)?.name??``}}return null},Nt=e=>kt(At(String(e.active.id))),$=(0,J.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=L(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=L(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=L(n(`crumb:`));if(a.length>0)return a;let o=L(n(`col:`));return o.length>0?o:Je(n(t?`folder:`:`chat:`))},[]),It=t=>{if(T===`columns`){for(let e of D?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(T===`list`){let e=O?.chats.find(e=>e._id===t);return e?{list:O.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},Lt=t=>{if(T===`columns`){for(let e of D?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(T===`list`){let e=O?.folders.find(e=>e._id===t);if(!e||!O)return null;let n=e.parentId??O.rootId;return{list:He(O.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},zt=async e=>{kt(null),Dt();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=Ot(r);if(e!==void 0){if(a){let t=i.slice(5);await v({chatId:t,projectId:e})}else{let t=i.slice(7);if(t===e)return;if(!ke(xe??[],t,e)){s.error(we());return}await g({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=It(t);if(!n)return;n.list.some(t=>t._id===e)||await v({chatId:e,projectId:n.folderId});let a=Ct(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await b({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Lt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!ke(xe??[],e,n.parentId)){s.error(we());return}await g({projectId:e,parentId:n.parentId})}let a=Ct(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await x({projectId:e,...a});return}}catch{s.error(we())}},[,Bt]=(0,J.useState)(0);(0,J.useEffect)(()=>{let e=window.setInterval(()=>Bt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Vt=Date.now(),Ht=H(e.project),Ut=St(e.chats,I),Wt=e.breadcrumb.slice(0,-1),Gt=e=>()=>{Z.current||e()};return(0,Y.jsx)(P.Provider,{value:Ae,children:(0,Y.jsxs)(Ue,{sensors:xt,collisionDetection:$,onDragStart:Nt,onDragEnd:zt,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Ht},children:[(0,Y.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":_e(),children:[Wt.map(e=>(0,Y.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Y.jsx)(jt,{folderId:e._id,children:(0,Y.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Gt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Y.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Y.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Y.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Y.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Y.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,Y.jsxs)(K,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:_(),onClick:()=>{ie({projectId:e.project._id,hidden:!1})},children:[(0,Y.jsx)(at,{"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:fe()}),(0,Y.jsx)(ot,{"aria-hidden":!0})]}):null,(0,Y.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":y(),children:[(0,Y.jsx)(K,{variant:T===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":y(),title:y(),"aria-pressed":T===`cards`,onClick:()=>de(`cards`),children:(0,Y.jsx)(yt,{})}),(0,Y.jsx)(K,{variant:T===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Te(),title:Te(),"aria-pressed":T===`columns`,onClick:()=>de(`columns`),children:(0,Y.jsx)(_t,{})}),(0,Y.jsx)(K,{variant:T===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":w(),title:w(),"aria-pressed":T===`list`,onClick:()=>de(`list`),children:(0,Y.jsx)(st,{})})]}),(0,Y.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>void F({projectId:e.project._id}),children:[(0,Y.jsx)(Le,{}),ue()]}),(0,Y.jsxs)(K,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await o({title:S(),label:ee(),placeholder:se(),confirmLabel:oe()});t&&await ne({name:t,parentId:e.project._id})},children:[(0,Y.jsx)(Me,{}),S()]}),(0,Y.jsxs)(it,{children:[(0,Y.jsx)($e,{asChild:!0,children:(0,Y.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":te(),children:(0,Y.jsx)(et,{})})}),(0,Y.jsxs)(nt,{align:`end`,className:`w-48`,children:[(0,Y.jsxs)(G,{onSelect:()=>{Xe(e.project.name),B(!0)},children:[(0,Y.jsx)(ct,{}),` `,p()]}),(0,Y.jsxs)(G,{onSelect:()=>Qe(!0),children:[(0,Y.jsx)(vt,{}),` `,r()]}),(0,Y.jsx)(tt,{children:Ee()}),(0,Y.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Y.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e.project._id,color:null}),"aria-label":ae(),children:`✕`}),Ve.map(t=>(0,Y.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e.project._id,color:t.value})},t.value))]}),(0,Y.jsx)(rt,{}),(0,Y.jsxs)(G,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let o=C?.folders??0,s=C?.chats??0;await n({title:pe({name:e.project.name}),description:gt({folders:o,chats:s,days:a}),confirmWord:f(),confirmLabel:i(),destructive:!0})&&(await m({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Y.jsx)(lt,{}),` `,f()]})]})]})]})]}),T===`columns`?(0,Y.jsx)(Rt,{data:D,currentId:e.project._id,busyIds:A,suppressClick:Z,locateChatId:ge??null}):T===`list`?(0,Y.jsx)(Ft,{data:O,busyIds:A,suppressClick:Z,locateChatId:ge??null}):(0,Y.jsxs)(Y.Fragment,{children:[e.children.length>0?(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:he()}),(0,Y.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Y.jsx)(W,{items:e.children.map(e=>`folder:${e._id}`),strategy:Ke,children:e.children.map(t=>(0,Y.jsx)(Mt,{child:t,parentId:e.project._id,now:Vt,suppressClick:Z},t._id))})})]}):null,(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ye()}),e.chats.length>0?(0,Y.jsx)(ut,{value:I,onChange:e=>Re(e.target.value),placeholder:me(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?Se():ve()}):Ut.length===0&&(X??[]).length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:le({term:I.trim()})}):(0,Y.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Y.jsx)(W,{items:Ut.map(e=>`chat:${e._id}`),strategy:U,children:Ut.map(t=>(0,Y.jsx)(Pt,{chat:t,currentFolderId:e.project._id,now:Vt,busy:A.has(t._id),unread:N.has(t._id),locate:t._id===ge,suppressClick:Z},t._id))})})]}),q.length>=2&&X!==void 0?(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:be()}),X.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:le({term:q})}):(0,Y.jsx)(`ul`,{className:`oc-projpage__chats`,children:X.map(e=>(0,Y.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&q&&je(e.messageId,q),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Y.jsx)(Ne,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Y.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Y.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||re()}),e.projectPath&&e.projectPath.length>1?(0,Y.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Y.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Y.jsx)(mt,{open:z,onOpenChange:B,title:u(),canSubmit:V.trim().length>0,onSubmit:async()=>{await c({projectId:e.project._id,name:V.trim()}),B(!1)},submitLabel:p(),children:(0,Y.jsx)(ut,{value:V,onChange:e=>Xe(e.target.value),autoFocus:!0})}),Ze?(0,Y.jsx)(We,{open:Ze,onOpenChange:Qe,title:ce(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void g({projectId:e.project._id,parentId:t})}):null,Pe]}),(0,Y.jsx)(Be,{children:Q?(0,Y.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Q.kind===`folder`?(0,Y.jsx)(R,{size:13,"aria-hidden":!0}):(0,Y.jsx)(Ne,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:Q.label})]}):null})]})})}function jt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=M({id:Q(e)});return(0,Y.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Mt({child:e,parentId:t,now:n,suppressClick:r}){let i=j(),a=B({id:`folder:${e._id}`}),o=M({id:Z(e._id)});return(0,Y.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:N.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,Y.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Y.jsx)(R,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Y.jsx)(X,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,Y.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?T({count:e.folderCount})+` · `:``,Ce({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Y.jsx)(`span`,{className:`oc-projpage__cardage`,children:V(e.lastActivityAt,n)})]})}function Nt({chat:e}){let t=d(k.chats.setChatSidebar),n=e.inSidebar?o():A();return(0,Y.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Y.jsx)(Re,{}):(0,Y.jsx)(q,{})})}function Pt({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=(0,J.useContext)(P).get(e._id),c=j(),l=z(e.color),u=B({id:`chat:${e._id}`}),d=$(a);return(0,Y.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow`+(u.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:N.Transform.toString(u.transform),transition:u.transition},children:[(0,Y.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,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||De()}),e.pinned?(0,Y.jsx)(Ae,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Y.jsx)(`span`,{className:`oc-projpage__chatage`,children:V(e.updatedAt,n)}),r?(0,Y.jsx)(`span`,{className:F(s,v()).className,title:F(s,v()).label,"aria-label":F(s,v()).label}):null,i&&!r?(0,Y.jsx)(`span`,{className:`oc-chatitem__unread`,title:g(),"aria-label":g()}):null]}),(0,Y.jsx)(Nt,{chat:e}),(0,Y.jsx)(xt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function $(e){let t=(0,J.useRef)(null);return(0,J.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ft({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,J.useState)(new Set),o=(0,J.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,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:l()});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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{items:u.map(e=>`chat:${e._id}`),strategy:U,children:u.map(e=>(0,Y.jsx)(Lt,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Y.jsx)(W,{items:d.map(e=>`folder:${e._id}`),strategy:U,children:d.map(t=>(0,Y.jsx)(It,{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,Y.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&He(e.folders,null).length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:Se()}):c(null,0)})}function It({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=j(),c=B({id:`folder:${e._id}`}),l=M({id:Z(e._id)});return(0,Y.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Y.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":H(e),transform:N.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,Y.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?de():D(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Y.jsx)(Qe,{size:13}):(0,Y.jsx)(Ze,{size:13})}),(0,Y.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Y.jsx)(X,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function Lt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=(0,J.useContext)(P).get(e._id),o=j(),s=B({id:`chat:${e._id}`}),c=$(r),l=z(e.color);return(0,Y.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:N.Transform.toString(s.transform),transition:s.transition},children:[(0,Y.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,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||De()}),n?(0,Y.jsx)(`span`,{className:F(a,``).className,"aria-hidden":!0}):null]}),(0,Y.jsx)(xt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Y.jsx)(Nt,{chat:e})]})}function Rt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:l()}):(0,Y.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Y.jsx)(zt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function zt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=j(),s=M({id:Dt(e.folderId)});return(0,Y.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Y.jsx)(W,{items:e.folders.map(e=>`folder:${e._id}`),strategy:U,children:e.folders.map(t=>(0,Y.jsx)(Bt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Y.jsx)(W,{items:e.chats.map(e=>`chat:${e._id}`),strategy:U,children:e.chats.map(t=>(0,Y.jsx)(Vt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__colempty`,children:ve()}):null]})}function Bt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=M({id:Z(e._id)});return(0,Y.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:N.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,Y.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Y.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Y.jsx)(X,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Vt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=(0,J.useContext)(P).get(e._id),s=B({id:`chat:${e._id}`}),c=$(r),l=z(e.color);return(0,Y.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:N.Transform.toString(s.transform),transition:s.transition},children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...s.listeners,...s.attributes,children:[l?(0,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||De()}),n?(0,Y.jsx)(`span`,{className:F(o,``).className,"aria-hidden":!0}):null]}),(0,Y.jsx)(xt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Y.jsx)(Nt,{chat:e})]})}export{kt as ProjectPage};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$D as r,AO as i,BD as a,CO as o,E as s,EO as c,EZ as l,FO as u,FZ as d,GD as f,GO as ee,HD as p,ID as m,IO as te,IZ as h,LD as ne,MO as g,Ms as _,Mw as re,QD as ie,RD as ae,RO as v,SO as y,UD as b,UO as oe,VD as x,WO as se,ZD as ce,_O as S,aO as C,bO as w,cO as le,dO as T,eO as E,fO as ue,gO as de,hO as D,iO as O,js as fe,kO as pe,lO as me,mO as he,nD as ge,nO as _e,oO as ve,pO as ye,qD as be,rO as xe,sO as Se,t as k,uO as Ce,vO as we,wO as A,xO as Te,zD as Ee,zO as De}from"./api-C9TZ4xjz.js";import{n as Oe,t as j}from"./useNavigate-D3GIoxyW.js";import{A as ke,B as Ae,C as M,D as je,E as N,F as P,G as Me,H as Ne,I as F,J as Pe,K as I,R as Fe,S as L,T as Ie,U as Le,V as Re,W as R,_ as ze,a as z,f as B,h as Be,i as Ve,j as He,m as Ue,n as V,o as H,p as U,r as We,s as W,t as Ge,u as Ke,w as qe,x as Je,y as Ye,z as Xe}from"./useStartNewChat-BxlZDRnF.js";import{r as Ze}from"./dist-Col6E8px.js";import{t as Qe}from"./chevron-right-DrdFABbO.js";import{c as $e,g as et,i as tt,n as nt,r as G,s as rt,t as it}from"./dropdown-menu-DhetHpBb.js";import{n as at,t as ot}from"./eye-0fRXv2uN.js";import{t as st}from"./list-DJaWqeCP.js";import{t as ct}from"./pencil-DPtIvpHp.js";import{t as lt}from"./trash-2-B3-1X1oZ.js";import{t as K}from"./button-DEKA-XdT.js";import{t as ut}from"./input-BW0GOs_g.js";import"./convexApi-D2VdPGGW.js";import{r as dt}from"./toast-pKIYRpST.js";import{n as ft,r as pt}from"./ConfirmDialog-BTkA9EEC.js";import{t as mt}from"./EntitySheet-DZaO__IZ.js";import{r as ht,t as gt}from"./trashView-CcPdpr1y.js";var _t=s(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),vt=s(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),yt=s(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),q=s(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),J=t(e(),1),Y=n();function bt({className:e}){return(0,Y.jsx)($e,{asChild:!0,children:(0,Y.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":b(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Y.jsx)(et,{})})})}function X({folderId:e,name:t,color:n,currentParentId:a,className:o,onOpen:s}){let l=d(k.projects.renameProject),m=d(k.projects.setProjectColor),te=d(k.projects.moveProject),ne=d(k.projects.deleteProject),g=d(k.projects.createProject),_=ft(),re=ht(),ie=pt(),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(t),[C,w]=(0,J.useState)(!1),[le,T]=(0,J.useState)(!1),E=h(k.projects.projectTreeCount,le?{projectId:e}:`skip`);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(it,{onOpenChange:e=>e&&T(!0),children:[(0,Y.jsx)(bt,{className:o}),(0,Y.jsxs)(nt,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(G,{onSelect:()=>s(),children:[(0,Y.jsx)(I,{}),` `,c()]}),(0,Y.jsxs)(G,{onSelect:()=>{x(t),y(!0)},children:[(0,Y.jsx)(ct,{}),` `,p()]}),(0,Y.jsxs)(G,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await ie({title:S(),label:ee(),placeholder:se(),confirmLabel:oe()});t&&await g({name:t,parentId:e})})},children:[(0,Y.jsx)(Me,{}),` `,S()]}),(0,Y.jsxs)(G,{onSelect:()=>w(!0),children:[(0,Y.jsx)(vt,{}),` `,r()]}),(0,Y.jsx)(tt,{children:Ee()}),(0,Y.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void m({projectId:e,color:null}),"aria-label":ae(),children:`✕`}),Ve.map(t=>(0,Y.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void m({projectId:e,color:t.value})},t.value))]}),(0,Y.jsx)(rt,{}),(0,Y.jsxs)(G,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=E?.folders??0,r=E?.chats??0;await _({title:pe({name:t}),description:gt({folders:n,chats:r,days:re}),confirmWord:f(),confirmLabel:i(),destructive:!0})&&await ne({projectId:e})})},children:[(0,Y.jsx)(lt,{}),` `,f()]})]})]}),(0,Y.jsx)(mt,{open:v,onOpenChange:y,title:u(),canSubmit:b.trim().length>0,onSubmit:async()=>{await l({projectId:e,name:b.trim()}),y(!1)},submitLabel:p(),children:(0,Y.jsx)(ut,{value:b,onChange:e=>x(e.target.value),autoFocus:!0})}),C?(0,Y.jsx)(We,{open:C,onOpenChange:w,title:ce(),movingFolderId:e,currentId:a,onPick:t=>void te({projectId:e,parentId:t})}):null]})}function xt({chat:e,currentFolderId:t,className:n}){let r=d(k.chats.pinChat),i=d(k.chats.deleteChat),s=d(k.chats.renameChat),c=d(k.chats.setChatSidebar),l=d(k.chats.moveChatToProject),u=ft(),ee=ht(),[te,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(e.title??``),[re,ae]=(0,J.useState)(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(it,{children:[(0,Y.jsx)(bt,{className:n}),(0,Y.jsxs)(nt,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(G,{onSelect:()=>{_(e.title??``),h(!0)},children:[(0,Y.jsx)(ct,{}),` `,p()]}),(0,Y.jsxs)(G,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Y.jsx)(Xe,{}):(0,Y.jsx)(Ae,{}),e.pinned?x():a()]}),(0,Y.jsxs)(G,{onSelect:()=>ae(!0),children:[(0,Y.jsx)(vt,{}),` `,E()]}),e.pinned&&e.inSidebar?null:(0,Y.jsxs)(G,{onSelect:()=>void c({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Y.jsx)(Re,{}):(0,Y.jsx)(q,{}),e.inSidebar?o():A()]}),(0,Y.jsx)(rt,{}),(0,Y.jsxs)(G,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await u({title:ne(),description:m({days:ee}),confirmLabel:f(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Y.jsx)(lt,{}),` `,f()]})]})]}),(0,Y.jsx)(mt,{open:te,onOpenChange:h,title:ge(),canSubmit:g.trim().length>0,onSubmit:async()=>{await s({chatId:e._id,title:g.trim()}),h(!1)},submitLabel:p(),children:(0,Y.jsx)(ut,{value:g,onChange:e=>_(e.target.value),autoFocus:!0})}),re?(0,Y.jsx)(We,{open:re,onOpenChange:ae,title:ie(),currentId:t,onPick:t=>void l({chatId:e._id,projectId:t})}):null]})}function St(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function Ct(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 wt(e,t){let n=new Map(t.map(e=>[e.chatId,e.lastSeenAt])),r=new Set;for(let t of e){let e=n.get(t._id);e!==void 0&&t.lastAssistantAt!==null&&t.lastAssistantAt>e&&r.add(t._id)}return r}var Tt=`oc.projpage.view`;function Et(){let e=localStorage.getItem(Tt);return e===`cards`||e===`list`?e:`columns`}var Z=e=>`into:${e}`,Dt=e=>`col:${e??`null`}`,Q=e=>`crumb:${e}`;function Ot(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 kt(){let{projectId:e}=Pe({from:`/project/$projectId`}),t=j(),n=h(k.projects.projectPage,{projectId:e});return(0,Y.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:l()}):n===null?(0,Y.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Y.jsx)(`h2`,{children:C()}),(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:O()}),(0,Y.jsx)(K,{variant:`outline`,onClick:()=>void t({to:`/`}),children:xe()})]}):(0,Y.jsx)(At,{page:n})})}function At({page:e}){let t=j(),n=ft(),a=ht(),o=pt(),s=dt(),c=d(k.projects.renameProject),l=d(k.projects.setProjectColor),m=d(k.projects.deleteProject),ne=d(k.projects.createProject),g=d(k.projects.moveProject),ie=d(k.projects.setProjectSidebar),v=d(k.chats.moveChatToProject),b=d(k.chats.reorderChat),x=d(k.projects.reorderProject),C=h(k.projects.projectTreeCount,{projectId:e.project._id}),[T,E]=(0,J.useState)(Et),de=e=>{localStorage.setItem(Tt,e),E(e)},D=h(k.projects.folderColumns,T===`columns`?{projectId:e.project._id}:`skip`),O=h(k.projects.projectTreeList,T===`list`?{projectId:e.project._id}:`skip`),{c:ge}=Oe({from:`/project/$projectId`}),xe=h(k.projects.listProjects,{}),Ce=h(k.chatReads.myBusyChats,{}),A=(0,J.useMemo)(()=>new Set(Ce??[]),[Ce]),{byChat:Ae}=Fe(Ce??null),M=h(k.chatReads.myChatReads,{}),N=(0,J.useMemo)(()=>wt(e.chats,M??[]),[e.chats,M]),{startNewChat:F,picker:Pe}=Ge(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[I,Re]=(0,J.useState)(``),[z,B]=(0,J.useState)(!1),[V,Xe]=(0,J.useState)(e.project.name),[Ze,Qe]=(0,J.useState)(!1),[q,bt]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=setTimeout(()=>bt(I.trim()),180);return()=>clearTimeout(e)},[I]);let X=h(k.search.searchConversations,q.length>=2?{query:q,projectId:e.project._id}:`skip`),xt=Ie(qe(ze,{activationConstraint:{distance:4}}),qe(Ye,{activationConstraint:{delay:250,tolerance:8}})),Z=(0,J.useRef)(!1),Dt=()=>{Z.current=!0,setTimeout(()=>{Z.current=!1},0)},[Q,kt]=(0,J.useState)(null),At=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=D?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||De()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(xe??[]).find(t=>t._id===e)?.name??``}}return null},Nt=e=>kt(At(String(e.active.id))),$=(0,J.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=L(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=L(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=L(n(`crumb:`));if(a.length>0)return a;let o=L(n(`col:`));return o.length>0?o:Je(n(t?`folder:`:`chat:`))},[]),It=t=>{if(T===`columns`){for(let e of D?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(T===`list`){let e=O?.chats.find(e=>e._id===t);return e?{list:O.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},Lt=t=>{if(T===`columns`){for(let e of D?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(T===`list`){let e=O?.folders.find(e=>e._id===t);if(!e||!O)return null;let n=e.parentId??O.rootId;return{list:He(O.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},zt=async e=>{kt(null),Dt();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=Ot(r);if(e!==void 0){if(a){let t=i.slice(5);await v({chatId:t,projectId:e})}else{let t=i.slice(7);if(t===e)return;if(!ke(xe??[],t,e)){s.error(we());return}await g({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=It(t);if(!n)return;n.list.some(t=>t._id===e)||await v({chatId:e,projectId:n.folderId});let a=Ct(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await b({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Lt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!ke(xe??[],e,n.parentId)){s.error(we());return}await g({projectId:e,parentId:n.parentId})}let a=Ct(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await x({projectId:e,...a});return}}catch{s.error(we())}},[,Bt]=(0,J.useState)(0);(0,J.useEffect)(()=>{let e=window.setInterval(()=>Bt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Vt=Date.now(),Ht=H(e.project),Ut=St(e.chats,I),Wt=e.breadcrumb.slice(0,-1),Gt=e=>()=>{Z.current||e()};return(0,Y.jsx)(P.Provider,{value:Ae,children:(0,Y.jsxs)(Ue,{sensors:xt,collisionDetection:$,onDragStart:Nt,onDragEnd:zt,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Ht},children:[(0,Y.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":_e(),children:[Wt.map(e=>(0,Y.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Y.jsx)(jt,{folderId:e._id,children:(0,Y.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Gt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Y.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Y.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Y.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Y.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Y.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,Y.jsxs)(K,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:_(),onClick:()=>{ie({projectId:e.project._id,hidden:!1})},children:[(0,Y.jsx)(at,{"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:fe()}),(0,Y.jsx)(ot,{"aria-hidden":!0})]}):null,(0,Y.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":y(),children:[(0,Y.jsx)(K,{variant:T===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":y(),title:y(),"aria-pressed":T===`cards`,onClick:()=>de(`cards`),children:(0,Y.jsx)(yt,{})}),(0,Y.jsx)(K,{variant:T===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Te(),title:Te(),"aria-pressed":T===`columns`,onClick:()=>de(`columns`),children:(0,Y.jsx)(_t,{})}),(0,Y.jsx)(K,{variant:T===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":w(),title:w(),"aria-pressed":T===`list`,onClick:()=>de(`list`),children:(0,Y.jsx)(st,{})})]}),(0,Y.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>void F({projectId:e.project._id}),children:[(0,Y.jsx)(Le,{}),ue()]}),(0,Y.jsxs)(K,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await o({title:S(),label:ee(),placeholder:se(),confirmLabel:oe()});t&&await ne({name:t,parentId:e.project._id})},children:[(0,Y.jsx)(Me,{}),S()]}),(0,Y.jsxs)(it,{children:[(0,Y.jsx)($e,{asChild:!0,children:(0,Y.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":te(),children:(0,Y.jsx)(et,{})})}),(0,Y.jsxs)(nt,{align:`end`,className:`w-48`,children:[(0,Y.jsxs)(G,{onSelect:()=>{Xe(e.project.name),B(!0)},children:[(0,Y.jsx)(ct,{}),` `,p()]}),(0,Y.jsxs)(G,{onSelect:()=>Qe(!0),children:[(0,Y.jsx)(vt,{}),` `,r()]}),(0,Y.jsx)(tt,{children:Ee()}),(0,Y.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Y.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e.project._id,color:null}),"aria-label":ae(),children:`✕`}),Ve.map(t=>(0,Y.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e.project._id,color:t.value})},t.value))]}),(0,Y.jsx)(rt,{}),(0,Y.jsxs)(G,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let o=C?.folders??0,s=C?.chats??0;await n({title:pe({name:e.project.name}),description:gt({folders:o,chats:s,days:a}),confirmWord:f(),confirmLabel:i(),destructive:!0})&&(await m({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Y.jsx)(lt,{}),` `,f()]})]})]})]})]}),T===`columns`?(0,Y.jsx)(Rt,{data:D,currentId:e.project._id,busyIds:A,suppressClick:Z,locateChatId:ge??null}):T===`list`?(0,Y.jsx)(Ft,{data:O,busyIds:A,suppressClick:Z,locateChatId:ge??null}):(0,Y.jsxs)(Y.Fragment,{children:[e.children.length>0?(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:he()}),(0,Y.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Y.jsx)(W,{items:e.children.map(e=>`folder:${e._id}`),strategy:Ke,children:e.children.map(t=>(0,Y.jsx)(Mt,{child:t,parentId:e.project._id,now:Vt,suppressClick:Z},t._id))})})]}):null,(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ye()}),e.chats.length>0?(0,Y.jsx)(ut,{value:I,onChange:e=>Re(e.target.value),placeholder:me(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?Se():ve()}):Ut.length===0&&(X??[]).length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:le({term:I.trim()})}):(0,Y.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Y.jsx)(W,{items:Ut.map(e=>`chat:${e._id}`),strategy:U,children:Ut.map(t=>(0,Y.jsx)(Pt,{chat:t,currentFolderId:e.project._id,now:Vt,busy:A.has(t._id),unread:N.has(t._id),locate:t._id===ge,suppressClick:Z},t._id))})})]}),q.length>=2&&X!==void 0?(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:be()}),X.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:le({term:q})}):(0,Y.jsx)(`ul`,{className:`oc-projpage__chats`,children:X.map(e=>(0,Y.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&q&&je(e.messageId,q),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Y.jsx)(Ne,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Y.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Y.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||re()}),e.projectPath&&e.projectPath.length>1?(0,Y.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Y.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Y.jsx)(mt,{open:z,onOpenChange:B,title:u(),canSubmit:V.trim().length>0,onSubmit:async()=>{await c({projectId:e.project._id,name:V.trim()}),B(!1)},submitLabel:p(),children:(0,Y.jsx)(ut,{value:V,onChange:e=>Xe(e.target.value),autoFocus:!0})}),Ze?(0,Y.jsx)(We,{open:Ze,onOpenChange:Qe,title:ce(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void g({projectId:e.project._id,parentId:t})}):null,Pe]}),(0,Y.jsx)(Be,{children:Q?(0,Y.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Q.kind===`folder`?(0,Y.jsx)(R,{size:13,"aria-hidden":!0}):(0,Y.jsx)(Ne,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:Q.label})]}):null})]})})}function jt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=M({id:Q(e)});return(0,Y.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Mt({child:e,parentId:t,now:n,suppressClick:r}){let i=j(),a=B({id:`folder:${e._id}`}),o=M({id:Z(e._id)});return(0,Y.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:N.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,Y.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Y.jsx)(R,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Y.jsx)(X,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,Y.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?T({count:e.folderCount})+` · `:``,Ce({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Y.jsx)(`span`,{className:`oc-projpage__cardage`,children:V(e.lastActivityAt,n)})]})}function Nt({chat:e}){let t=d(k.chats.setChatSidebar),n=e.inSidebar?o():A();return(0,Y.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Y.jsx)(Re,{}):(0,Y.jsx)(q,{})})}function Pt({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=(0,J.useContext)(P).get(e._id),c=j(),l=z(e.color),u=B({id:`chat:${e._id}`}),d=$(a);return(0,Y.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow`+(u.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:N.Transform.toString(u.transform),transition:u.transition},children:[(0,Y.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,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||De()}),e.pinned?(0,Y.jsx)(Ae,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Y.jsx)(`span`,{className:`oc-projpage__chatage`,children:V(e.updatedAt,n)}),r?(0,Y.jsx)(`span`,{className:F(s,v()).className,title:F(s,v()).label,"aria-label":F(s,v()).label}):null,i&&!r?(0,Y.jsx)(`span`,{className:`oc-chatitem__unread`,title:g(),"aria-label":g()}):null]}),(0,Y.jsx)(Nt,{chat:e}),(0,Y.jsx)(xt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function $(e){let t=(0,J.useRef)(null);return(0,J.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ft({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,J.useState)(new Set),o=(0,J.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,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:l()});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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W,{items:u.map(e=>`chat:${e._id}`),strategy:U,children:u.map(e=>(0,Y.jsx)(Lt,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Y.jsx)(W,{items:d.map(e=>`folder:${e._id}`),strategy:U,children:d.map(t=>(0,Y.jsx)(It,{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,Y.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&He(e.folders,null).length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:Se()}):c(null,0)})}function It({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=j(),c=B({id:`folder:${e._id}`}),l=M({id:Z(e._id)});return(0,Y.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Y.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":H(e),transform:N.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,Y.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?de():D(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Y.jsx)(Qe,{size:13}):(0,Y.jsx)(Ze,{size:13})}),(0,Y.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Y.jsx)(X,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function Lt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=(0,J.useContext)(P).get(e._id),o=j(),s=B({id:`chat:${e._id}`}),c=$(r),l=z(e.color);return(0,Y.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:N.Transform.toString(s.transform),transition:s.transition},children:[(0,Y.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,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||De()}),n?(0,Y.jsx)(`span`,{className:F(a,``).className,"aria-hidden":!0}):null]}),(0,Y.jsx)(xt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Y.jsx)(Nt,{chat:e})]})}function Rt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:l()}):(0,Y.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Y.jsx)(zt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function zt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=j(),s=M({id:Dt(e.folderId)});return(0,Y.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Y.jsx)(W,{items:e.folders.map(e=>`folder:${e._id}`),strategy:U,children:e.folders.map(t=>(0,Y.jsx)(Bt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Y.jsx)(W,{items:e.chats.map(e=>`chat:${e._id}`),strategy:U,children:e.chats.map(t=>(0,Y.jsx)(Vt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__colempty`,children:ve()}):null]})}function Bt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=M({id:Z(e._id)});return(0,Y.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:N.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,Y.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Y.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Y.jsx)(X,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Vt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=(0,J.useContext)(P).get(e._id),s=B({id:`chat:${e._id}`}),c=$(r),l=z(e.color);return(0,Y.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:N.Transform.toString(s.transform),transition:s.transition},children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...s.listeners,...s.attributes,children:[l?(0,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||De()}),n?(0,Y.jsx)(`span`,{className:F(o,``).className,"aria-hidden":!0}):null]}),(0,Y.jsx)(xt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Y.jsx)(Nt,{chat:e})]})}export{kt as ProjectPage};
|