@rubytech/create-maxy-code 0.1.536 → 0.1.537
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/package.json +1 -1
- package/payload/platform/plugins/admin/hooks/__tests__/mailbox-inject.test.sh +11 -5
- package/payload/platform/plugins/admin/hooks/mailbox-inject.sh +12 -7
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +47 -4
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +5 -0
- package/payload/platform/plugins/docs/references/admin-ui.md +46 -3
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js +6 -6
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +67 -4
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/index.js +23 -2
- package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts +6 -0
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +7 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/public-agent-reachability.d.ts +8 -2
- package/payload/platform/services/claude-session-manager/dist/public-agent-reachability.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/public-agent-reachability.js +32 -27
- package/payload/platform/services/claude-session-manager/dist/public-agent-reachability.js.map +1 -1
- package/payload/server/public/activity.html +5 -5
- package/payload/server/public/agents.html +4 -4
- package/payload/server/public/assets/{AdminLoginScreens-BpHVvUsH.js → AdminLoginScreens-CYFf2awh.js} +1 -1
- package/payload/server/public/assets/AdminLoginScreens-CYFf2awh.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-CYFf2awh.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js +2 -0
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js.br +0 -0
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js.gz +0 -0
- package/payload/server/public/assets/{activity-B3WEyiTh.js → activity-BH65sm9Q.js} +1 -1
- package/payload/server/public/assets/activity-BH65sm9Q.js.br +0 -0
- package/payload/server/public/assets/activity-BH65sm9Q.js.gz +0 -0
- package/payload/server/public/assets/admin-CQtEjRGU.js +1 -0
- package/payload/server/public/assets/admin-CQtEjRGU.js.br +0 -0
- package/payload/server/public/assets/admin-CQtEjRGU.js.gz +0 -0
- package/payload/server/public/assets/{agents-CmYDQbdM.js → agents-CjhOWwl5.js} +1 -1
- package/payload/server/public/assets/agents-CjhOWwl5.js.br +0 -0
- package/payload/server/public/assets/agents-CjhOWwl5.js.gz +0 -0
- package/payload/server/public/assets/{browser-CP8TnIUm.js → browser-DGXpfL99.js} +1 -1
- package/payload/server/public/assets/browser-DGXpfL99.js.br +0 -0
- package/payload/server/public/assets/browser-DGXpfL99.js.gz +0 -0
- package/payload/server/public/assets/calendar-Cu4yjEuX.js +1 -0
- package/payload/server/public/assets/calendar-Cu4yjEuX.js.br +0 -0
- package/payload/server/public/assets/calendar-Cu4yjEuX.js.gz +0 -0
- package/payload/server/public/assets/chat-0na4XVZC.js +1 -0
- package/payload/server/public/assets/chat-0na4XVZC.js.br +0 -0
- package/payload/server/public/assets/chat-0na4XVZC.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-DHzJobWp.js +1 -0
- package/payload/server/public/assets/chevron-left-DHzJobWp.js.br +0 -0
- package/payload/server/public/assets/chevron-right-yg4DMfLT.js +1 -0
- package/payload/server/public/assets/chevron-right-yg4DMfLT.js.br +0 -0
- package/payload/server/public/assets/clock-BIDzihvp.js +1 -0
- package/payload/server/public/assets/clock-BIDzihvp.js.br +0 -0
- package/payload/server/public/assets/clock-BIDzihvp.js.gz +0 -0
- package/payload/server/public/assets/data-Ql9qG3YO.js +1 -0
- package/payload/server/public/assets/data-Ql9qG3YO.js.br +0 -0
- package/payload/server/public/assets/data-Ql9qG3YO.js.gz +0 -0
- package/payload/server/public/assets/{file-text-lsHlk4lR.js → file-text-CbQoZfJD.js} +1 -1
- package/payload/server/public/assets/file-text-CbQoZfJD.js.br +0 -0
- package/payload/server/public/assets/file-text-CbQoZfJD.js.gz +0 -0
- package/payload/server/public/assets/{graph-B0awsgVj.js → graph-7414Kjn9.js} +3 -3
- package/payload/server/public/assets/graph-7414Kjn9.js.br +0 -0
- package/payload/server/public/assets/graph-7414Kjn9.js.gz +0 -0
- package/payload/server/public/assets/{graph-labels-Ci5Jz1oY.js → graph-labels-D695CsC9.js} +1 -1
- package/payload/server/public/assets/graph-labels-D695CsC9.js.br +0 -0
- package/payload/server/public/assets/graph-labels-D695CsC9.js.gz +0 -0
- package/payload/server/public/assets/{maximize-2-DRndYysc.js → maximize-2-CD0gTjW_.js} +1 -1
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js.br +0 -0
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js.gz +0 -0
- package/payload/server/public/assets/operator-CLw4PZs5.js +1 -0
- package/payload/server/public/assets/operator-CLw4PZs5.js.br +0 -0
- package/payload/server/public/assets/operator-CLw4PZs5.js.gz +0 -0
- package/payload/server/public/assets/{page-RkwjxAgF.js → page-BNRFmFc-.js} +5 -5
- package/payload/server/public/assets/page-BNRFmFc-.js.br +0 -0
- package/payload/server/public/assets/page-BNRFmFc-.js.gz +0 -0
- package/payload/server/public/assets/page-BRr295G2.js +1 -0
- package/payload/server/public/assets/page-BRr295G2.js.br +0 -0
- package/payload/server/public/assets/page-BRr295G2.js.gz +0 -0
- package/payload/server/public/assets/play-CbRU6q0T.js +1 -0
- package/payload/server/public/assets/play-CbRU6q0T.js.br +0 -0
- package/payload/server/public/assets/play-CbRU6q0T.js.gz +0 -0
- package/payload/server/public/assets/{public-BNAVdC2B.js → public-CqbKJ-Q3.js} +1 -1
- package/payload/server/public/assets/public-CqbKJ-Q3.js.br +0 -0
- package/payload/server/public/assets/public-CqbKJ-Q3.js.gz +0 -0
- package/payload/server/public/assets/{rotate-ccw-D6DZb7tR.js → rotate-ccw-CjliWBou.js} +1 -1
- package/payload/server/public/assets/rotate-ccw-CjliWBou.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-CjliWBou.js.gz +0 -0
- package/payload/server/public/assets/routines-yJuRuBfn.js +2 -0
- package/payload/server/public/assets/routines-yJuRuBfn.js.br +0 -0
- package/payload/server/public/assets/routines-yJuRuBfn.js.gz +0 -0
- package/payload/server/public/assets/{skills-9S_nNIpO.js → skills-ipK9BJFb.js} +1 -1
- package/payload/server/public/assets/skills-ipK9BJFb.js.br +0 -0
- package/payload/server/public/assets/skills-ipK9BJFb.js.gz +0 -0
- package/payload/server/public/assets/tasks-CGcJHQ3X.js +3 -0
- package/payload/server/public/assets/tasks-CGcJHQ3X.js.br +0 -0
- package/payload/server/public/assets/tasks-CGcJHQ3X.js.gz +0 -0
- package/payload/server/public/assets/{triangle-alert-BcpCZDHe.js → triangle-alert-CjsLPsBD.js} +1 -1
- package/payload/server/public/assets/triangle-alert-CjsLPsBD.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-CjsLPsBD.js.gz +0 -0
- package/payload/server/public/assets/{useCopyFeedback-DqTnYnz5.js → useCopyFeedback-umIgCxI_.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-umIgCxI_.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-umIgCxI_.js.gz +0 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-CYEDydoq.css → useSubAccountSwitcher-D8jXV7R5.css} +1 -1
- package/payload/server/public/assets/useSubAccountSwitcher-D8jXV7R5.css.br +0 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-CYEDydoq.css.gz → useSubAccountSwitcher-D8jXV7R5.css.gz} +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js +14 -0
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js.gz +0 -0
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js +2 -0
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js.gz +0 -0
- package/payload/server/public/assets/{wrench-DvUj2R3p.js → wrench-DtfKfR4s.js} +1 -1
- package/payload/server/public/assets/wrench-DtfKfR4s.js.br +0 -0
- package/payload/server/public/assets/wrench-DtfKfR4s.js.gz +0 -0
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +7 -7
- package/payload/server/public/chat.html +13 -13
- package/payload/server/public/data.html +11 -11
- package/payload/server/public/graph.html +9 -9
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +14 -14
- package/payload/server/public/public.html +13 -13
- package/payload/server/public/routines.html +6 -6
- package/payload/server/public/skills.html +5 -5
- package/payload/server/public/tasks.html +6 -6
- package/payload/server/server.js +692 -439
- package/payload/server/public/assets/AdminLoginScreens-BpHVvUsH.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-BpHVvUsH.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-BT7VQIu7.js +0 -2
- package/payload/server/public/assets/AdminShell-BT7VQIu7.js.br +0 -0
- package/payload/server/public/assets/AdminShell-BT7VQIu7.js.gz +0 -0
- package/payload/server/public/assets/activity-B3WEyiTh.js.br +0 -0
- package/payload/server/public/assets/activity-B3WEyiTh.js.gz +0 -0
- package/payload/server/public/assets/admin-BEKL9Bq_.js +0 -1
- package/payload/server/public/assets/admin-BEKL9Bq_.js.br +0 -0
- package/payload/server/public/assets/admin-BEKL9Bq_.js.gz +0 -0
- package/payload/server/public/assets/agents-CmYDQbdM.js.br +0 -0
- package/payload/server/public/assets/agents-CmYDQbdM.js.gz +0 -0
- package/payload/server/public/assets/browser-CP8TnIUm.js.br +0 -0
- package/payload/server/public/assets/browser-CP8TnIUm.js.gz +0 -0
- package/payload/server/public/assets/calendar-DM6Bl8Ra.js +0 -1
- package/payload/server/public/assets/calendar-DM6Bl8Ra.js.br +0 -0
- package/payload/server/public/assets/calendar-DM6Bl8Ra.js.gz +0 -0
- package/payload/server/public/assets/chat-BJWdNwCN.js +0 -1
- package/payload/server/public/assets/chat-BJWdNwCN.js.br +0 -2
- package/payload/server/public/assets/chat-BJWdNwCN.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-DU8Es8Xq.js +0 -1
- package/payload/server/public/assets/chevron-right-D8HTOkyy.js +0 -1
- package/payload/server/public/assets/chevron-right-D8HTOkyy.js.br +0 -0
- package/payload/server/public/assets/clock-BdNuUyUU.js +0 -1
- package/payload/server/public/assets/clock-BdNuUyUU.js.br +0 -0
- package/payload/server/public/assets/clock-BdNuUyUU.js.gz +0 -0
- package/payload/server/public/assets/data-EjLIuy-W.js +0 -1
- package/payload/server/public/assets/data-EjLIuy-W.js.br +0 -0
- package/payload/server/public/assets/data-EjLIuy-W.js.gz +0 -0
- package/payload/server/public/assets/file-text-lsHlk4lR.js.br +0 -0
- package/payload/server/public/assets/file-text-lsHlk4lR.js.gz +0 -0
- package/payload/server/public/assets/graph-B0awsgVj.js.br +0 -0
- package/payload/server/public/assets/graph-B0awsgVj.js.gz +0 -0
- package/payload/server/public/assets/graph-labels-Ci5Jz1oY.js.br +0 -0
- package/payload/server/public/assets/graph-labels-Ci5Jz1oY.js.gz +0 -0
- package/payload/server/public/assets/maximize-2-DRndYysc.js.br +0 -0
- package/payload/server/public/assets/maximize-2-DRndYysc.js.gz +0 -0
- package/payload/server/public/assets/operator-tiI-kz6v.js +0 -1
- package/payload/server/public/assets/operator-tiI-kz6v.js.br +0 -0
- package/payload/server/public/assets/operator-tiI-kz6v.js.gz +0 -0
- package/payload/server/public/assets/page-RkwjxAgF.js.br +0 -0
- package/payload/server/public/assets/page-RkwjxAgF.js.gz +0 -0
- package/payload/server/public/assets/page-ZG7SXMO0.js +0 -1
- package/payload/server/public/assets/page-ZG7SXMO0.js.br +0 -0
- package/payload/server/public/assets/page-ZG7SXMO0.js.gz +0 -0
- package/payload/server/public/assets/public-BNAVdC2B.js.br +0 -0
- package/payload/server/public/assets/public-BNAVdC2B.js.gz +0 -0
- package/payload/server/public/assets/rotate-ccw-D6DZb7tR.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-D6DZb7tR.js.gz +0 -0
- package/payload/server/public/assets/routines-BVcPovu-.js +0 -2
- package/payload/server/public/assets/routines-BVcPovu-.js.br +0 -0
- package/payload/server/public/assets/routines-BVcPovu-.js.gz +0 -0
- package/payload/server/public/assets/skills-9S_nNIpO.js.br +0 -0
- package/payload/server/public/assets/skills-9S_nNIpO.js.gz +0 -0
- package/payload/server/public/assets/tasks-D-D2efaL.js +0 -3
- package/payload/server/public/assets/tasks-D-D2efaL.js.br +0 -0
- package/payload/server/public/assets/tasks-D-D2efaL.js.gz +0 -0
- package/payload/server/public/assets/time-entry-format-CKpHcWWs.js +0 -1
- package/payload/server/public/assets/time-entry-format-CKpHcWWs.js.br +0 -0
- package/payload/server/public/assets/time-entry-format-CKpHcWWs.js.gz +0 -0
- package/payload/server/public/assets/triangle-alert-BcpCZDHe.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-BcpCZDHe.js.gz +0 -0
- package/payload/server/public/assets/useCopyFeedback-DqTnYnz5.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-DqTnYnz5.js.gz +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-CYEDydoq.css.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-ny9tP8am.js +0 -14
- package/payload/server/public/assets/useSubAccountSwitcher-ny9tP8am.js.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-ny9tP8am.js.gz +0 -0
- package/payload/server/public/assets/useVoiceRecorder-DcgtZl-4.js +0 -2
- package/payload/server/public/assets/useVoiceRecorder-DcgtZl-4.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-DcgtZl-4.js.gz +0 -0
- package/payload/server/public/assets/wrench-DvUj2R3p.js.br +0 -2
- package/payload/server/public/assets/wrench-DvUj2R3p.js.gz +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,B as n,C as r,D as i,E as a,F as o,H as s,I as c,J as l,L as u,M as d,N as f,O as p,R as m,T as h,U as g,W as _,Y as v,a as y,b,f as x,g as S,h as ee,j as te,k as C,m as w,o as ne,p as re,r as T,t as ie,v as ae,w as oe,x as se,y as ce,z as le}from"./useSubAccountSwitcher-ny9tP8am.js";async function ue(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var E=g();function de({checked:e,onChange:t,label:n,disabled:r,ariaLabel:i=n}){return(0,E.jsxs)(`label`,{className:`maxy-checkbox${r?` maxy-checkbox--disabled`:``}`,children:[(0,E.jsx)(`input`,{type:`checkbox`,"aria-label":i,checked:e,onChange:e=>t(e.target.checked),disabled:r}),(0,E.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),n&&(0,E.jsx)(`span`,{className:`maxy-checkbox__label`,children:n})]})}var D=e(v(),1),fe={sm:14,md:16,lg:18},O={sm:30,md:38,lg:46};function k({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,"aria-pressed":u,style:d,className:f,children:p}){let m=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,f].filter(Boolean).join(` `),h=fe[t],g={...e===`send`?{width:O[t],height:O[t]}:{},...d},_=Object.keys(g).length>0;return(0,E.jsxs)(`button`,{type:s,className:m,disabled:i||o,onClick:c,"aria-label":l,"aria-pressed":u,style:_?g:void 0,children:[(0,E.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,E.jsx)(n,{size:h}),p,n&&r===`trailing`&&(0,E.jsx)(n,{size:h})]}),i&&(0,E.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var pe=m(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),me=m(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),he=m(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),A=m(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ge=m(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),_e=m(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ve=m(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),j=m(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),M=m(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),ye=m(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),be=m(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),xe=m(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),N=m(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),Se=m(`waypoints`,[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]),Ce=m(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),P=`/cdp-screencast`;function we(){return{format:`jpeg`,quality:60,maxWidth:1280,maxHeight:800,everyNthFrame:1}}function Te(e,t,n,r){return n.width<=0||n.height<=0?{x:0,y:0}:{x:e/n.width*r.deviceWidth,y:t/n.height*r.deviceHeight}}function F(e){return e===0?`left`:e===1?`middle`:e===2?`right`:`none`}function Ee(e,t){let n=F(t.button);return{type:e,x:t.x,y:t.y,button:n,buttons:t.buttons,clickCount:e===`mouseMoved`?0:1,modifiers:t.modifiers}}function De(e){return{type:`mouseWheel`,x:e.x,y:e.y,button:`none`,buttons:0,clickCount:0,modifiers:e.modifiers,deltaX:e.deltaX,deltaY:e.deltaY}}var Oe={Backspace:8,Tab:9,Enter:13,Escape:27,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,Delete:46},ke={Enter:`\r`,Tab:` `};function Ae(e,t){let n=t.key.length===1,r=n&&/[a-z0-9]/i.test(t.key)?t.key.toUpperCase().charCodeAt(0):Oe[t.key]??0,i={type:e,key:t.key,code:t.code,modifiers:t.modifiers,windowsVirtualKeyCode:r,nativeVirtualKeyCode:r};if(e===`keyDown`){let e=n?t.key:ke[t.key];e!==void 0&&(i.text=e,i.unmodifiedText=e)}return i}function je(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:/i.test(t)?t:`https://${t}`:``}function Me(e){try{return new URL(je(e)).host}catch{return``}}function Ne(e,t,n){return`${e.protocol===`https:`?`wss`:`ws`}://${e.host}${P}?targetId=${encodeURIComponent(t)}&sid=${encodeURIComponent(n)}`}var Pe=class{nextId=1;startId=null;frames=0;stopped=!1;lastMetadata=null;lastInputLogAtMs=null;inputsSinceLog=0;pending=new Map;constructor(e,t){this.ws=e,this.opts=t}frameCount(){return this.frames}start(){this.send(`Page.enable`,{});let e=we();this.startId=this.send(`Page.startScreencast`,e)}stop(){if(this.stopped)return;this.stopped=!0;let e=this.send(`Page.stopScreencast`,{})!==null;this.opts.onLog(`teardown`,{stopSent:e})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t.id==`number`){let e=this.pending.get(t.id);if(e){this.pending.delete(t.id),e(t.error?null:t.result);return}}if(typeof t.id==`number`&&t.id===this.startId){if(t.error)this.opts.onLog(`start-failed`,{err:t.error.message??`unknown`});else{let e=we();this.opts.onLog(`screencast-started`,{format:e.format,everyNthFrame:e.everyNthFrame})}return}if(t.method===`Page.frameNavigated`){let e=t.params?.frame;e&&e.parentId===void 0&&typeof e.url==`string`&&this.opts.onUrlChange?.(e.url);return}if(t.method!==`Page.screencastFrame`||this.stopped)return;let n=t.params;if(typeof n?.data!=`string`||typeof n?.metadata!=`object`||n.metadata===null)return;let r=n.metadata;typeof n.sessionId==`number`&&this.send(`Page.screencastFrameAck`,{sessionId:n.sessionId}),this.frames+=1,this.lastMetadata=r,this.frames%30==0&&this.opts.onLog(`frame`,{seq:this.frames}),this.opts.onFrame({data:n.data,metadata:r})}dispatchMouse(e,t){let n=this.lastMetadata;if(!n)return;let r=Te(t.canvasX,t.canvasY,t.rendered,n);this.send(`Input.dispatchMouseEvent`,Ee(e,{x:r.x,y:r.y,button:t.button,buttons:t.buttons,modifiers:t.modifiers})),this.logInput(`mouse`)}dispatchWheel(e){let t=this.lastMetadata;if(!t)return;let n=Te(e.canvasX,e.canvasY,e.rendered,t);this.send(`Input.dispatchMouseEvent`,De({x:n.x,y:n.y,deltaX:e.deltaX,deltaY:e.deltaY,modifiers:e.modifiers})),this.logInput(`wheel`)}dispatchKey(e,t){this.send(`Input.dispatchKeyEvent`,Ae(e,t)),this.logInput(`key`)}insertText(e){e&&(this.send(`Input.insertText`,{text:e}),this.logInput(`paste`))}navigate(e){let t=je(e);t&&(this.send(`Page.navigate`,{url:t}),this.opts.onLog(`navigate`,{host:Me(t)}))}async goHistory(e){let t=e<0?`back`:`forward`,n=await this.command(`Page.getNavigationHistory`,{});if(!n){this.opts.onLog(`history`,{dir:t,outcome:`no-result`});return}let{currentIndex:r,entries:i}=n,a=typeof r==`number`?i?.[r+e]:void 0;if(!a||typeof a.id!=`number`){this.opts.onLog(`history`,{dir:t,outcome:`no-entry`});return}this.send(`Page.navigateToHistoryEntry`,{entryId:a.id}),this.opts.onLog(`history`,{dir:t})}command(e,t){let n=this.send(e,t);return n===null?Promise.resolve(null):new Promise(e=>this.pending.set(n,e))}logInput(e){this.inputsSinceLog+=1;let t=(this.opts.now??Date.now)();if(this.lastInputLogAtMs!==null&&t-this.lastInputLogAtMs<1e3)return;this.lastInputLogAtMs=t;let n=this.inputsSinceLog;this.inputsSinceLog=0,this.opts.onLog(`input`,{kind:e,count:n})}send(e,t){let n=this.nextId++;try{return this.ws.send(JSON.stringify({id:n,method:e,params:t})),n}catch(t){return this.opts.onLog(`send-failed`,{method:e,err:t instanceof Error?t.message:String(t)}),null}}};function Fe(e){let{targets:t,activeId:n,url:r,busy:i}=e,[a,o]=(0,D.useState)(r),s=(0,D.useRef)(null);return(0,D.useEffect)(()=>{s.current&&document.activeElement===s.current||o(r)},[r]),(0,D.useEffect)(()=>{o(e.url)},[n]),(0,E.jsxs)(`div`,{className:`browser-chrome`,children:[(0,E.jsxs)(`div`,{className:`browser-chrome__tabs`,role:`tablist`,children:[t.map(t=>(0,E.jsxs)(`div`,{className:t.id===n?`browser-chrome__tab is-active`:`browser-chrome__tab`,role:`tab`,"aria-selected":t.id===n,children:[(0,E.jsx)(`button`,{type:`button`,className:`browser-chrome__tab-label`,onClick:()=>e.onSelect(t.id),title:t.url,children:t.title}),(0,E.jsx)(`button`,{type:`button`,className:`browser-chrome__tab-close`,"aria-label":`Close ${t.title}`,onClick:()=>e.onClose(t.id),disabled:i,children:(0,E.jsx)(ce,{size:12,strokeWidth:2})})]},t.id)),(0,E.jsx)(`button`,{type:`button`,className:`browser-chrome__new`,"aria-label":`New tab`,title:`New tab`,onClick:e.onNew,disabled:i,children:(0,E.jsx)(oe,{size:14,strokeWidth:2})})]}),(0,E.jsxs)(`form`,{className:`browser-chrome__bar`,onSubmit:t=>{t.preventDefault(),e.onNavigate(a)},children:[(0,E.jsx)(`button`,{type:`button`,className:`browser-chrome__nav`,"aria-label":`Back`,title:`Back`,onClick:e.onBack,children:(0,E.jsx)(c,{size:16,strokeWidth:1.75})}),(0,E.jsx)(`button`,{type:`button`,className:`browser-chrome__nav`,"aria-label":`Forward`,title:`Forward`,onClick:e.onForward,children:(0,E.jsx)(he,{size:16,strokeWidth:1.75})}),(0,E.jsx)(`input`,{ref:s,className:`browser-chrome__url`,"aria-label":`Address`,placeholder:`Type a URL`,value:a,onChange:e=>o(e.target.value)})]})]})}function I(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function Ie({preferTargetId:e=null,cacheKey:n=null,chrome:r=!0,surface:i=`browser`}={}){let[a,o]=(0,D.useState)(`probing`),[s,c]=(0,D.useState)([]),[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)(!1),[m,h]=(0,D.useState)(null),[g,_]=(0,D.useState)(!1),[v,y]=(0,D.useState)(``),b=ae(n),x=(0,D.useRef)(null),S=(0,D.useRef)(null),ee=(0,D.useRef)(``),te=(0,D.useRef)(e);te.current=e,ee.current||=`sc-${Math.random().toString(36).slice(2,10)}`;let C=(0,D.useCallback)((e,t={})=>{b(`/api/admin/browser/screencast-event`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sid:ee.current,op:e,...t})}).catch(()=>{})},[b]),w=(0,D.useCallback)(async()=>{try{let e=await b(`/api/admin/browser/screencast-targets`);if(!e.ok){o(`unavailable`);return}let t=await e.json().catch(()=>({})),n=Array.isArray(t.targets)?t.targets:[];if(c(n),n.length===0){u(null),o(`no-tabs`);return}let r=te.current;u(e=>r&&n.some(e=>e.id===r)?r:e&&n.some(t=>t.id===e)?e:n[0].id),o(`live`)}catch{o(`unavailable`)}},[b]);(0,D.useEffect)(()=>{C(`request`),w()},[w,C]),(0,D.useEffect)(()=>{r&&C(`chrome-mounted`,{surface:i,chrome:`v1`})},[r,i,C]),(0,D.useEffect)(()=>{y(s.find(e=>e.id===l)?.url??``)},[s,l]);let ne=(0,D.useRef)(null);(0,D.useEffect)(()=>{if(e){if(s.some(t=>t.id===e)){u(e);return}ne.current!==e&&(ne.current=e,w())}},[e,s,w]);let re=(0,D.useCallback)(e=>{let t=x.current;if(!t)return;let n=new Image;n.onload=()=>{t.width=n.naturalWidth,t.height=n.naturalHeight,t.getContext(`2d`)?.drawImage(n,0,0)},n.src=`data:image/jpeg;base64,${e.data}`},[]);(0,D.useEffect)(()=>{if(a!==`live`||!l)return;let e=Ne({protocol:window.location.protocol,host:window.location.host},l,ee.current),t=new WebSocket(e),n=new Pe(t,{onFrame:re,onLog:C,onUrlChange:y});return S.current=n,t.addEventListener(`open`,()=>n.start()),t.addEventListener(`message`,e=>{typeof e.data==`string`&&n.handleMessage(e.data)}),()=>{n.stop(),t.close(),S.current=null}},[a,l,re,C]);let T=(0,D.useCallback)(e=>t=>{let n=x.current;if(!n)return;let r=n.getBoundingClientRect();S.current?.dispatchMouse(e,{canvasX:t.clientX-r.left,canvasY:t.clientY-r.top,rendered:{width:r.width,height:r.height},button:e===`mouseMoved`?-1:t.button,buttons:t.buttons,modifiers:I(t)})},[]);(0,D.useEffect)(()=>{let e=x.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect();S.current?.dispatchWheel({canvasX:t.clientX-n.left,canvasY:t.clientY-n.top,rendered:{width:n.width,height:n.height},deltaX:t.deltaX,deltaY:t.deltaY,modifiers:I(t)})};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[a]);let ie=(0,D.useCallback)(e=>t=>{t.preventDefault(),S.current?.dispatchKey(e,{key:t.key,code:t.code,modifiers:I(t)})},[]),oe=(0,D.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text`);t&&S.current?.insertText(t)},[]),se=(0,D.useCallback)(async()=>{f(!0),h(null);try{let e=await b(`/api/admin/browser/launch`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Launch failed (${e.status})`)}await w()}catch(e){h(e instanceof Error?e.message:String(e))}finally{f(!1)}},[b,w]),ce=(0,D.useCallback)(async()=>{_(!0),h(null);try{a===`no-tabs`&&await b(`/api/admin/browser/launch`,{method:`POST`});let e=await b(`/api/admin/browser/tabs`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`New tab failed (${e.status})`)}let t=await e.json().catch(()=>({}));await w(),t.id&&u(t.id)}catch(e){h(e instanceof Error?e.message:String(e))}finally{_(!1)}},[b,w,a]),le=(0,D.useCallback)(async e=>{_(!0),h(null);try{let t=await b(`/api/admin/browser/tabs/${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Close failed (${t.status})`)}await w()}catch(e){h(e instanceof Error?e.message:String(e))}finally{_(!1)}},[b,w]),ue=(0,D.useCallback)(e=>{S.current?.navigate(e)},[]),de=(0,D.useCallback)(e=>{S.current?.goHistory(e)},[]);return a===`probing`?(0,E.jsx)(`div`,{className:`cdp-screencast`,children:(0,E.jsxs)(`div`,{className:`data-loading`,children:[(0,E.jsx)(p,{size:18,className:`spin`}),` Connecting to the device browser…`]})}):a===`unavailable`?(0,E.jsx)(`div`,{className:`cdp-screencast`,children:(0,E.jsxs)(`div`,{className:`cdp-screencast__unavailable`,children:[(0,E.jsx)(t,{size:28,strokeWidth:1.75}),(0,E.jsx)(`p`,{children:`The device browser is not reachable.`})]})}):(0,E.jsxs)(`div`,{className:`cdp-screencast`,children:[r&&(0,E.jsx)(Fe,{targets:s,activeId:l,url:v,busy:g,onSelect:u,onClose:le,onNew:ce,onBack:()=>de(-1),onForward:()=>de(1),onNavigate:ue}),m&&(0,E.jsx)(`div`,{className:`cdp-screencast__toolbar`,children:(0,E.jsx)(`span`,{className:`cdp-screencast__error`,children:m})}),a===`no-tabs`?(0,E.jsxs)(`div`,{className:`cdp-screencast__unavailable`,children:[(0,E.jsx)(t,{size:28,strokeWidth:1.75}),(0,E.jsx)(`p`,{children:`No open tabs on the device browser.`}),(0,E.jsxs)(`button`,{type:`button`,className:`cdp-screencast__btn`,onClick:se,disabled:d,children:[d?(0,E.jsx)(p,{size:14,className:`spin`}):(0,E.jsx)(t,{size:14}),` Launch browser`]})]}):(0,E.jsxs)(E.Fragment,{children:[!r&&(0,E.jsx)(`div`,{className:`cdp-screencast__tabs`,children:s.map(e=>(0,E.jsx)(`button`,{type:`button`,className:e.id===l?`cdp-screencast__tab is-active`:`cdp-screencast__tab`,onClick:()=>u(e.id),title:e.url,children:e.title},e.id))}),(0,E.jsx)(`div`,{className:`cdp-screencast__viewport`,children:(0,E.jsx)(`canvas`,{ref:x,className:`cdp-screencast__canvas`,tabIndex:0,onMouseDown:T(`mousePressed`),onMouseUp:T(`mouseReleased`),onMouseMove:T(`mouseMoved`),onKeyDown:ie(`keyDown`),onKeyUp:ie(`keyUp`),onPaste:oe})})]})]})}var Le=5e3,Re=1200;function ze(e){return Math.max(Re,Math.round(Le/(e<1?1:e)))}var L=500,R=new Set;function z(e,t,n){let r=n??(typeof globalThis.fetch==`function`?globalThis.fetch:void 0);if(R.has(e)||!r)return!1;if(R.size>=L){for(let e of R)if(R.delete(e),R.size<L)break}R.add(e);try{Promise.resolve(r(`/api/admin/events`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:`wa-notify:rendered`,fields:{msgId:e,senderType:t}})})).catch(()=>{})}catch{}return!0}function Be({type:e}){return e===`admin`?(0,E.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M8 1.5 13 3.5v4c0 3-2.1 5.8-5 7-2.9-1.2-5-4-5-7v-4z`})}):e===`manager-active`?(0,E.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M2 5.5h9l-2.5-2.5 1-1L14 6l-4.5 4-1-1L11 6.5H2zM14 10.5H5l2.5 2.5-1 1L2 10l4.5-4 1 1L5 9.5h9z`})}):e===`manager-passive`?(0,E.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M8 3C4.5 3 1.7 5.4 1 8c.7 2.6 3.5 5 7 5s6.3-2.4 7-5c-.7-2.6-3.5-5-7-5m0 8a3 3 0 1 1 0-6 3 3 0 0 1 0 6`})}):(0,E.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6m0 1.5c-3 0-5.5 1.6-5.5 3.5v1h11v-1c0-1.9-2.5-3.5-5.5-3.5`})})}function Ve({frames:e,onExpire:t}){let n=(0,D.useRef)(new Map),r=(0,D.useRef)(new Map);return(0,D.useEffect)(()=>{let i=Date.now(),a=ze(e.length),o=new Set(e.map(e=>e.waMessageId));for(let e of[...n.current.keys()])o.has(e)||(n.current.delete(e),r.current.delete(e));let s=[];for(let o of e){let e=o.waMessageId;n.current.has(e)||(n.current.set(e,i),z(e,o.senderType));let c=r.current.get(e),l=c===void 0?a:Math.min(c,a);r.current.set(e,l);let u=i-(n.current.get(e)??i);s.push(setTimeout(()=>t(e),Math.max(0,l-u)))}return()=>{for(let e of s)clearTimeout(e)}},[e,t]),e.length===0?null:(0,E.jsx)(`div`,{className:`wa-notify-host`,children:[...e].reverse().map(e=>(0,E.jsxs)(`div`,{className:`wa-notify-card`,role:`status`,children:[(0,E.jsxs)(`div`,{className:`wa-notify-head`,children:[(0,E.jsx)(`span`,{className:`wa-notify-pill wa-notify-pill-${e.senderType}`,children:(0,E.jsx)(Be,{type:e.senderType})}),(0,E.jsx)(`span`,{className:`wa-notify-account`,children:e.accountName})]}),(0,E.jsx)(`div`,{className:`wa-notify-sender`,children:e.senderDisplay}),(0,E.jsxs)(`div`,{className:`wa-notify-body`,children:[e.body,e.truncated?`…`:``]})]},e.waMessageId))})}var B=`wa-notify`;function He({connected:e,onConnectClaude:t}){return e?(0,E.jsxs)(`span`,{className:`claude-status-pill`,"data-connected":`true`,title:`Claude is connected`,children:[(0,E.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`claude-status-pill__mark`}),(0,E.jsx)(`span`,{className:`claude-status-pill__label`,children:`Connected`}),(0,E.jsx)(`span`,{className:`claude-status-pill__dot claude-status-pill__dot--live`,"aria-hidden":`true`})]}):(0,E.jsxs)(`button`,{type:`button`,className:`claude-status-pill claude-status-pill--action`,"data-connected":`false`,onClick:t,title:`Connect Claude`,children:[(0,E.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`claude-status-pill__mark`}),(0,E.jsx)(`span`,{className:`claude-status-pill__label`,children:`Connect`}),(0,E.jsx)(`span`,{className:`claude-status-pill__dot claude-status-pill__dot--down`,"aria-hidden":`true`})]})}function Ue(e){return e===`/`||e===``?`Dashboard`:e.startsWith(`/chat`)?`Chat`:e.startsWith(`/tasks`)?`Tasks`:e.startsWith(`/data`)?`Data`:e.startsWith(`/calendar`)?`Calendar`:e.startsWith(`/graph`)?`Graph`:e.startsWith(`/activity`)?`Activity`:e.startsWith(`/browser`)?`Browser`:e.startsWith(`/routines`)?`Routines`:e.startsWith(`/skills`)?`Skills`:e.startsWith(`/agents`)?`Agents`:`Dashboard`}function We({title:e,sidebarOpen:n,onToggleSidebar:r,claudeConnected:a,onConnectClaude:o,browserOpen:s,onToggleBrowser:c}){let l=e??Ue(typeof window<`u`?window.location.pathname:`/`),u=a!==void 0&&o!==void 0,d=s!==void 0&&c!==void 0;return(0,E.jsxs)(`header`,{className:`admin-page-header`,children:[(0,E.jsxs)(`button`,{type:`button`,className:`admin-page-header__toggle`,"aria-label":n?`Hide sidebar`:`Show sidebar`,title:n?`Hide sidebar`:`Show sidebar`,"aria-expanded":n,onClick:r,children:[(0,E.jsx)(be,{className:`admin-page-header__toggle-desktop`,size:18,strokeWidth:1.75}),(0,E.jsx)(i,{className:`admin-page-header__toggle-mobile`,size:22,strokeWidth:1.75})]}),(0,E.jsx)(`h1`,{className:`admin-page-header__title`,children:l}),(u||d)&&(0,E.jsxs)(`div`,{className:`admin-page-header__right`,children:[d&&(0,E.jsx)(`button`,{type:`button`,className:s?`admin-page-header__icon is-active`:`admin-page-header__icon`,"aria-label":s?`Hide browser`:`Show browser`,title:s?`Hide browser`:`Show browser`,"aria-pressed":s,onClick:c,children:(0,E.jsx)(t,{size:18,strokeWidth:1.75})}),u&&(0,E.jsx)(He,{connected:a,onConnectClaude:o})]})]})}var Ge=[{label:`Home`,href:`/`,Icon:C,match:e=>e===`/`||e===``},{label:`Chat`,href:`/chat`,Icon:a,match:e=>e.startsWith(`/chat`)},{label:`Tasks`,href:`/tasks`,Icon:M,match:e=>e.startsWith(`/tasks`)},{label:`Data`,href:`/data`,Icon:f,match:e=>e.startsWith(`/data`)},{label:`Calendar`,href:`/calendar`,Icon:o,match:e=>e.startsWith(`/calendar`)}],Ke=[{label:`Chat`,href:`/`,Icon:a,match:e=>e===`/`||e===``||e.startsWith(`/chat`)},{label:`Data`,href:`/data`,Icon:f,match:e=>e.startsWith(`/data`)}];function qe(e){let t=Ge.find(t=>t.match(e));return t?t.href:`/`}function Je({variant:e=`admin`,onOpenConversations:t}={}){let n=typeof window<`u`?window.location.pathname:`/`,r=e===`operator`?Ke:Ge,i=e===`operator`?Ke.find(e=>e.match(n))?.href??`/`:qe(n),o=e=>{let t=e.href===i,{Icon:n}=e;return(0,E.jsxs)(`a`,{href:e.href,className:`bottom-tab${t?` is-active`:``}`,"aria-current":t?`page`:void 0,children:[(0,E.jsx)(n,{size:19,strokeWidth:1.75}),(0,E.jsx)(`span`,{className:`bottom-tab__label`,children:e.label})]},e.href)};return(0,E.jsxs)(`nav`,{className:`bottom-tab-bar`,"aria-label":`Primary`,children:[r.slice(0,1).map(o),e===`operator`&&t&&(0,E.jsxs)(`button`,{type:`button`,className:`bottom-tab`,onClick:t,children:[(0,E.jsx)(a,{size:19,strokeWidth:1.75}),(0,E.jsx)(`span`,{className:`bottom-tab__label`,children:`Conversations`})]}),r.slice(1).map(o)]})}var Ye=`maxy-shell-side-px`;function Xe(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function Ze(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-Xe());return Math.min(Math.max(e,248),n)}function Qe(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(Ye);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return Ze(t)}catch{}return 264}function $e({targetSelector:e=`.platform`}){let t=(0,D.useRef)(null),[n,r]=(0,D.useState)(()=>Qe()),i=(0,D.useRef)(n);(0,D.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,D.useCallback)(()=>{r(e=>{let t=Ze(e);return t===e?e:t})},[]);(0,D.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(Ze(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(Ye,String(t))}catch{}};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{r(Ze(264));try{window.localStorage.removeItem(Ye)}catch{}};return(0,E.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var et=l();function tt(e){return Math.max(14,e/2-386)}function nt(e){return e.left===0&&e.top===0&&e.width===0&&e.height===0}var rt={position:`fixed`,visibility:`hidden`};function V({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,anchorId:a,children:o}){let s=(0,D.useRef)(null),[c,l]=(0,D.useState)(rt),u=(0,D.useCallback)(()=>{let t=s.current;if(!t)return;let r=e.current,i=[n,a].filter(Boolean).join(`:`)||`unknown`,o=t.getBoundingClientRect(),c=window.innerWidth,u=window.innerHeight,d=o.width>0&&o.height>0,f=r?r.getBoundingClientRect():null,p=(e,t)=>console.error(`[anchored-popover] op=offscreen id=${i} left=${e} top=${t} w=${o.width} h=${o.height} viewport=${c},${u}`);if(!f){l({position:`fixed`,left:Math.max(4,c-o.width-tt(c)),top:Math.max(4,u-o.height-14),visibility:`visible`});return}if(d&&nt(f)){l(rt),p(f.left,f.top);return}let m=f.right-o.width,h=c-o.width-4;m>h&&(m=h),m<4&&(m=4);let g=u-f.bottom-4,_=f.top-4,v=o.height+8<=g?!1:o.height+8<=_?!0:_>g,y=Math.max(0,v?_:g),b=v?Math.max(4,f.top-Math.min(o.height,y)):f.bottom;l({position:`fixed`,left:m,top:b,maxHeight:y,visibility:`visible`});let x=Math.min(o.height,y);d&&(m+o.width<=0||m>=c||b+x<=0||b>=u)&&p(m,b)},[e,a,n]);return(0,D.useLayoutEffect)(()=>{if(u(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>u());return s.current&&e.observe(s.current),()=>e.disconnect()},[u]),(0,D.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||s.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,et.createPortal)((0,E.jsx)(`div`,{ref:s,className:n,role:r,"aria-label":i,style:c,children:o}),document.body)}function it({actions:e,disabled:t}){let[n,r]=(0,D.useState)(!1),[a,o]=(0,D.useState)(null),s=(0,D.useRef)(null),c=(0,D.useCallback)(()=>{r(!1),o(null)},[]);return(0,E.jsxs)(`div`,{className:`conv-actions`,children:[(0,E.jsx)(`button`,{ref:s,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>r(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Session actions`,title:`Session actions`,children:(0,E.jsx)(i,{size:12})}),n&&(0,E.jsx)(V,{anchorRef:s,onClose:c,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,E.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,E.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":a===e.key,disabled:t,onClick:()=>o(t=>t===e.key?null:e.key),children:[e.icon,(0,E.jsx)(`span`,{children:e.menuLabel})]}),a===e.key&&(0,E.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,E.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),c()},children:[e.icon,(0,E.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var H=`claude-opus-5[1m]`,U=`claude-sonnet-5`,W=`claude-haiku-4-5`,at={[H]:`Opus 5 (1M context)`,[U]:`Sonnet 5`,[W]:`Haiku 4.5`};function ot(e){return at[e]??e}var st=[H,U,W];function G(e){return e.replace(/\[1m\]$/,``)}function ct(e){return st.find(t=>G(t)===G(e))??e}var lt=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],ut=[`low`,`medium`,`high`,`xhigh`];[...lt],[...ut],[...ut];var dt=[H,U,W],ft={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},pt=lt.map(e=>({value:e,label:ft[e]??e})),mt={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},ht=ut.map(e=>({value:e,label:mt[e]??e}));function K(e){if(e){let t=dt.find(t=>G(t)===G(e));if(t)return t}return H}function gt({row:e,adminFetch:t,onError:n}){let[r,i]=(0,D.useState)(()=>K(e.model)),[a,o]=(0,D.useState)(``),[s,c]=(0,D.useState)(``),[l,u]=(0,D.useState)(!1),d=(0,D.useRef)(!1);(0,D.useEffect)(()=>{i(K(e.model))},[e.model]);let f=async()=>{if(!d.current){d.current=!0,u(!0);try{let i=await t(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:r,...a?{permissionMode:a}:{},...s?{effort:s}:{}})});if(!i.ok){n(`Could not reset ${e.title} (status ${i.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${i.status}`),d.current=!1,u(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),d.current=!1,u(!1))}catch(t){n(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),d.current=!1,u(!1)}}};return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`label`,{className:`reseat-field`,children:[(0,E.jsx)(`span`,{children:`Model`}),(0,E.jsx)(`select`,{"data-kind":`model`,value:r,disabled:l,onChange:e=>i(e.target.value),children:dt.map(e=>(0,E.jsx)(`option`,{value:e,children:ot(e)},e))})]}),(0,E.jsxs)(`label`,{className:`reseat-field`,children:[(0,E.jsx)(`span`,{children:`Mode`}),(0,E.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:l,onChange:e=>o(e.target.value),children:[(0,E.jsx)(`option`,{value:``,children:`Keep current`}),pt.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,E.jsxs)(`label`,{className:`reseat-field`,children:[(0,E.jsx)(`span`,{children:`Effort`}),(0,E.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:l,onChange:e=>c(e.target.value),children:[(0,E.jsx)(`option`,{value:``,children:`Keep current`}),ht.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,E.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:l,"aria-busy":l,onClick:()=>void f(),children:l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(p,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function _t(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function q(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function vt({target:e,anchorEl:t,onConfirm:n,onCancel:r}){let i=(0,D.useRef)(null);return i.current=t,e?(0,E.jsxs)(V,{anchorRef:i,onClose:r,className:`conv-delete-confirm`,role:`alertdialog`,ariaLabel:`Confirm delete session`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`span`,{children:`Delete this conversation?`}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:r,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[(0,E.jsxs)(`div`,{className:`conv-delete-target`,children:[(0,E.jsx)(`span`,{className:`conv-delete-label`,title:e.title,children:e.title||`Untitled session`}),(0,E.jsx)(`code`,{className:`conv-delete-id`,title:e.sessionId,children:e.sessionId.slice(0,8)})]}),(0,E.jsx)(`div`,{style:{marginTop:`8px`},children:`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`}),e.live&&(0,E.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,E.jsx)(k,{variant:`danger`,size:`sm`,style:{flex:1},onClick:n,children:`Delete`}),(0,E.jsx)(k,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:r,children:`Cancel`})]})]}):null}function yt({open:e,count:t,liveCount:n,onConfirm:r,onCancel:i}){if(!e)return null;let a=t===1?``:`s`;return(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:i,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete sessions`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsxs)(`span`,{children:[`Delete `,t,` conversation`,a,`?`]}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes `,t,` transcript`,a,`. `,t===1?`It is`:`They are`,` not moved to Archive and cannot be recovered.`,n>0&&(0,E.jsxs)(`div`,{style:{marginTop:`8px`},children:[n,` `,n===1?`is`:`are`,` running and will be stopped first.`]})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,E.jsxs)(k,{variant:`danger`,size:`sm`,style:{flex:1},onClick:r,children:[`Delete `,t]}),(0,E.jsx)(k,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:i,children:`Cancel`})]})]})})}function bt(e){return`New session: ${e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}`}function xt({open:e,pending:t,onConfirm:n,onCancel:r,now:i}){let[a,o]=(0,D.useState)(``),s=(0,D.useRef)(null),c=(0,D.useRef)(null),l=(0,D.useRef)(!1);if((0,D.useEffect)(()=>{if(!e){c.current=null,l.current=!1;return}if(c.current!==null)return;let t=bt(i?i():new Date);c.current=t,o(t)},[e,i]),(0,D.useEffect)(()=>{if(!e||l.current||c.current===null||a!==c.current)return;let t=s.current;t&&(l.current=!0,t.focus(),t.setSelectionRange(0,t.value.length))},[e,a]),!e)return null;let u=a.trim(),d=u.length>0&&u.length<=200,f=()=>{d&&!t&&n(u)},p=e=>{t||r(e)};return(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>p(`backdrop`),children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Name this session`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`span`,{children:`Name this session`}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:()=>p(`cancel`),"aria-label":`Close`,disabled:t,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`},children:[(0,E.jsx)(`input`,{ref:s,className:`new-session-name-input`,"aria-label":`Session name`,value:a,disabled:t,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f()),e.key===`Escape`&&(e.preventDefault(),p(`escape`))}}),(0,E.jsx)(`div`,{className:`new-session-name-hint`,children:u.length>200?`Too long by ${u.length-200}`:`You can rename it later from the session menu.`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,E.jsx)(k,{variant:`primary`,size:`sm`,style:{flex:1},disabled:!d||t,onClick:f,children:t?`Starting…`:`Start session`}),(0,E.jsx)(k,{variant:`secondary`,size:`sm`,style:{flex:1},disabled:t,onClick:()=>p(`cancel`),children:`Cancel`})]})]})})}var St=`auth-refresh-failed`;function Ct({error:e,onClose:t}){if(!e)return null;let n=e.reason===St,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`span`,{children:r}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,E.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,E.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function wt(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,D.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,_=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,E.jsx)(`span`,{children:`Claude Code`}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,children:[(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,E.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,E.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,E.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,E.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,children:[(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:p>0?q(p):`—`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:_t(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,E.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await T(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function Tt({open:e,onConnect:t,onClose:n}){return e?(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`span`,{children:`Claude isn’t connected`}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,E.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,E.jsx)(k,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,E.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function Et(e){let t=Math.round(e/6e4),n=Math.floor(t/60),r=t%60;return`${n}h ${String(r).padStart(2,`0`)}m`}function Dt(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function J(e){return e.toLocaleString(`en-GB`)}function Ot(e){return`£${e.toFixed(2)}`}function kt(e){let t=[`Day`,`Active`,`Output tokens`,`Input tokens`,`Cache write`,`Cache read`,`Opus 5 (GBP)`,`Sonnet 5 (GBP)`],n=(e,t)=>[e,Et(Dt(t)),String(t.tokens.output),String(t.tokens.input),String(t.tokens.cacheWrite),String(t.tokens.cacheRead),t.costGBP.opus.toFixed(2),t.costGBP.sonnet.toFixed(2)];return[t,...e.days.map(e=>n(e.date,e)),n(`TOTAL (${e.days.length} d)`,e.totals)].map(e=>e.join(`,`)).join(`
|
|
2
|
-
`)}function At({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,E.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,E.jsx)(r,{className:`usage-day`,children:e}),(0,E.jsx)(r,{children:Et(Dt(t))}),(0,E.jsx)(r,{children:J(t.tokens.output)}),(0,E.jsx)(r,{children:J(t.tokens.input)}),(0,E.jsx)(r,{children:J(t.tokens.cacheWrite)}),(0,E.jsx)(r,{children:J(t.tokens.cacheRead)}),(0,E.jsx)(r,{children:Ot(t.costGBP.opus)}),(0,E.jsx)(r,{children:Ot(t.costGBP.sonnet)})]})}function jt({show:e,onClose:t,anchorEl:n,sessionId:r,summary:i,loading:a,error:o}){let s=(0,D.useRef)(null);if(s.current=n,!e)return null;let c=!!i&&i.days.length>0;return(0,E.jsxs)(V,{anchorRef:s,onClose:t,className:`usage-popover`,role:`dialog`,ariaLabel:`Session usage and cost`,anchorId:r??void 0,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsxs)(`span`,{children:[`Usage & cost`,r?` · ${r.slice(0,8)}`:``]}),c&&(0,E.jsx)(`button`,{className:`usage-download`,onClick:()=>{if(!i)return;let e=new Blob([kt(i)],{type:`text/csv;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usage-${r?r.slice(0,8):`session`}.csv`,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(t)},"aria-label":`Download as CSV`,title:`Download as CSV`,children:(0,E.jsx)(d,{size:14})}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,E.jsx)(ce,{size:14})})]}),(0,E.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[a&&(0,E.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!a&&o&&(0,E.jsx)(`div`,{className:`usage-note usage-error`,children:o}),!a&&!o&&i&&i.days.length===0&&(0,E.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!a&&!o&&i&&i.days.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`usage-table-scroll`,children:(0,E.jsxs)(`table`,{className:`usage-table`,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,E.jsx)(`th`,{children:`Active`}),(0,E.jsx)(`th`,{children:`Output tok`}),(0,E.jsx)(`th`,{children:`Input tok`}),(0,E.jsx)(`th`,{children:`Cache write`}),(0,E.jsx)(`th`,{children:`Cache read`}),(0,E.jsx)(`th`,{children:`Opus 5 (£)`}),(0,E.jsx)(`th`,{children:`Sonnet 5 (£)`})]})}),(0,E.jsxs)(`tbody`,{children:[i.days.map(e=>(0,E.jsx)(At,{label:e.date,d:e},e.date)),(0,E.jsx)(At,{label:`TOTAL (${i.days.length} d)`,d:i.totals,bold:!0})]})]})}),(0,E.jsxs)(`div`,{className:`usage-note usage-caveats`,children:[`Prices dated `,i.pricing.opusPriceDate,` · £/$ `,i.pricing.usdPerGbp,` · Sonnet tokenizer factor `,i.pricing.tokenizerFactor,`. Idle human-wait dominates the calendar span; cache-read tokens dominate cost.`]})]})]})]})}var Mt=`https://claude.ai/code`,Nt=200,Pt=[500,1e3,1500,2e3,2500,3e3,3e3];function Ft(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${Mt}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function It(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Y(e){let{businessName:i,cacheKey:c,onConnectClaude:l,role:d,userName:m,userAvatar:g,onSelectProjects:_,onSelectTasks:v,onCloseMobileDrawer:S,collapsed:re,onSelectData:T,initialDataSurface:ie=!1,onLogout:ce,onDisconnect:ue,disconnecting:fe,claudeConnected:O=!0,subAccounts:k,activeAccountId:he,switchingAccount:be,onSwitchAccount:P,refreshAccounts:we,onOpenConversations:Te}=e,F=ae(c),Ee=(0,D.useCallback)(e=>({key:`reseat`,label:`Reset session ${e.title} (model, mode, effort)`,menuLabel:`Reset`,title:`Reset — move this session onto a chosen model, mode, and effort`,icon:(0,E.jsx)(xe,{size:12}),panel:()=>(0,E.jsx)(gt,{row:e,adminFetch:F,onError:e=>L({message:e,failed:!0})})}),[F]),De=le.productName,Oe=i||De,ke=typeof m==`string`?m:m===null?`name unavailable`:Oe,Ae=(ke.trim().charAt(0)||`?`).toUpperCase(),[je,Me]=(0,D.useState)(ie?`data`:`sessions`),[Ne,Pe]=(0,D.useState)(!1),[Fe,I]=(0,D.useState)(!1),Ie=!re&&(k?.length??0)>1&&!!P,Le=k?.find(e=>e.isHouse)??null,Re=(0,D.useCallback)(()=>{Le&&Le.accountId!==he&&(I(!1),P?.(Le.accountId,`/`))},[Le,he,P]),[ze,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(null),[Be,Ve]=(0,D.useState)(!1),[B,He]=(0,D.useState)([]),[Ue]=(0,D.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`session`)),[We,Ge]=(0,D.useState)(!1),[Ke,qe]=(0,D.useState)(null),[Je,Ye]=(0,D.useState)(!1),[Xe,Ze]=(0,D.useState)(!1),[Qe,$e]=(0,D.useState)(!1),[et,tt]=(0,D.useState)(null),[nt,rt]=(0,D.useState)(new Set),V=(0,D.useRef)(new Map),[H,U]=(0,D.useState)(!1),[W,at]=(0,D.useState)(new Set),[ot,st]=(0,D.useState)(!1),[G,ct]=(0,D.useState)(null),[lt,ut]=(0,D.useState)(new Set),[dt,ft]=(0,D.useState)(new Set),[pt,mt]=(0,D.useState)(new Set),[ht,K]=(0,D.useState)(null),[_t,q]=(0,D.useState)(``),[bt,St]=(0,D.useState)(!1),[wt,Et]=(0,D.useState)(null),[Dt,J]=(0,D.useState)(null),[Ot,kt]=(0,D.useState)(!1),[At,Mt]=(0,D.useState)(null),[Y,Lt]=(0,D.useState)(!1),[Bt,X]=(0,D.useState)(!1),Vt=(0,D.useRef)(0);(0,D.useEffect)(()=>{if(!ze)return;let e=setTimeout(()=>L(null),2500);return()=>clearTimeout(e)},[ze]);let Z=(0,D.useCallback)(async()=>{if(!c)return null;let e=++Vt.current;Ye(!0),qe(null);try{let t=await F(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===Vt.current?(He(r),tt(n.accountId??null),Ge(!0),r):r}catch(t){let n=t instanceof Error?t.message:String(t);return e===Vt.current&&qe(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===Vt.current&&Ye(!1)}},[c,F]);(0,D.useEffect)(()=>{!c||We||Z()},[c,We,Z]),(0,D.useEffect)(()=>{if(!c)return;let e=null;function t(){Z()}function n(){e===null&&(e=setInterval(t,Rt))}function r(){e!==null&&(clearInterval(e),e=null)}function i(){document.hidden?r():(t(),n())}return document.hidden||n(),document.addEventListener(`visibilitychange`,i),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[c,Z]);let Ht=()=>{Z()},Ut=()=>{Me(`data`),T(),S()},Q=typeof window<`u`&&window.location?.pathname||`/`,Wt=je===`data`,Gt=typeof window<`u`&&window.location?.search||``,Kt=new URLSearchParams(Gt),qt=Kt.has(`label`)&&!Kt.has(`nodeId`),$=e=>{S(),window.location.href=e},Jt=[{key:`dashboard`,label:`Dashboard`,icon:(0,E.jsx)(C,{size:17,strokeWidth:1.75}),active:Q===`/`&&!Wt,onClick:()=>$(`/`)},{key:`chat`,label:`Chat`,icon:(0,E.jsx)(a,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/chat`),onClick:()=>$(`/chat`)},{key:`tasks`,label:`Tasks`,icon:(0,E.jsx)(M,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/tasks`),onClick:()=>{v(),S()}},{key:`calendar`,label:`Calendar`,icon:(0,E.jsx)(o,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/calendar`),onClick:()=>$(`/calendar`)},{key:`routines`,label:`Routines`,icon:(0,E.jsx)(Ce,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/routines`),onClick:()=>$(`/routines`)},{key:`skills`,label:`Skills`,icon:(0,E.jsx)(N,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/skills`),onClick:()=>$(`/skills`)},{key:`agents`,label:`Agents`,icon:(0,E.jsx)(A,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/agents`),onClick:()=>$(`/agents`)},{key:`data`,label:`Data`,icon:(0,E.jsx)(f,{size:17,strokeWidth:1.75}),active:Wt,onClick:Ut},{key:`container`,label:s().term,icon:(0,E.jsx)(te,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/graph`)&&qt,onClick:()=>{_(),S()}},{key:`graph`,label:`Graph`,icon:(0,E.jsx)(Se,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/graph`)&&!qt,onClick:()=>$(`/graph`)},{key:`activity`,label:`Activity`,icon:(0,E.jsx)(u,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/activity`),onClick:()=>$(`/activity`)},{key:`browser`,label:`Browser`,icon:(0,E.jsx)(t,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/browser`),onClick:()=>$(`/browser`)}],Yt=(0,D.useCallback)(async e=>{if(lt.has(e.sessionId))return;ut(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await F(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=Ft(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});i.kind===`navigate`?(S(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),z(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),z({sessionId:e.sessionId,reason:r})}finally{ut(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[F,S,lt]),Xt=(0,D.useCallback)(async e=>{let t=e.slice(0,8);for(let t=1;t<=Pt.length;t++){await new Promise(e=>setTimeout(e,Pt[t-1]));let n=await Z();if(n&&n.some(t=>t.sessionId===e))return}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Z]),Zt=(0,D.useCallback)(async e=>{if(!Y){Lt(!0);try{let t=await F(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:e})}),n=await t.json().catch(()=>({})),r=Ft(t.ok,t.status,n);r.kind===`navigate`?r.sameOrigin?window.location.assign(r.url):(window.open(r.url,`_blank`),n.sessionId?Xt(n.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):t.status===503||r.reason===`claude-auth-dead`?(X(!1),Ve(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${t.status} reason=${r.reason}`),X(!1),z(r))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),X(!1),z({sessionId:null,reason:t})}finally{Lt(!1)}}},[F,Y,Xt]),Qt=(0,D.useCallback)((e,t)=>{e.stopPropagation(),ct(t)},[]),$t=(0,D.useCallback)(async(e,t)=>{e.stopPropagation(),Et(t),J(null),Mt(null),kt(!0);try{let e=await F(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?J(n):Mt(n.error??`status ${e.status}`)}catch(e){Mt(e instanceof Error?e.message:String(e))}finally{kt(!1)}},[F]),en=(0,D.useCallback)(async(e,t={})=>{let n=t.refresh??!0;if(nt.has(e.sessionId))return!1;rt(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await F(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));return console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),L({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0}),!1}return await t.json(),He(t=>t.filter(t=>t.sessionId!==e.sessionId)),n&&Z(),!0}catch(t){let n=t instanceof Error?t.message:String(t);return console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),L({message:`Delete failed: ${n}`,failed:!0}),!1}finally{rt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[F,nt,Z]),tn=(0,D.useCallback)(e=>{at(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),nn=(0,D.useCallback)(()=>{U(!1),at(new Set)},[]),rn=(0,D.useCallback)(async()=>{let e=[...W].map(e=>B.find(t=>t.sessionId===e)).filter(e=>!!e),t=(await Promise.all(e.map(e=>en(e,{refresh:!1})))).filter(Boolean).length,n=e.length-t;n>0&&console.warn(`[admin-ui] sidebar-bulk-delete op=done requested=${e.length} ok=${t} failed=${n}`),Z(),nn()},[W,B,en,Z,nn]),an=(0,D.useCallback)(async(e,t)=>{if(e.stopPropagation(),!dt.has(t.sessionId)){ft(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await F(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),L({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}Z()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),L({message:`Stop failed: ${n}`,failed:!0})}finally{ft(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[F,dt,Z]),on=(0,D.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!pt.has(t.sessionId)){mt(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await F(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),L({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}Z()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),L({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{mt(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[F,pt,Z]),sn=(0,D.useCallback)(async e=>{let t=_t.trim();if(!t){L({message:`Title can’t be empty`,failed:!0});return}if(t.length>Nt){L({message:`Title too long (max ${Nt})`,failed:!0});return}St(!0);try{let n=await F(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),L({message:`Rename failed: ${r}`,failed:!0});return}K(null),q(``),Z()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),L({message:`Rename failed: ${n}`,failed:!0})}finally{St(!1)}},[F,_t,Z]);return(0,E.jsxs)(`aside`,{className:`side`,children:[(0,E.jsxs)(`div`,{className:`side-brand`,children:[Ie?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{type:`button`,className:`side-brand-icon-btn`,"aria-label":`Switch to house account`,disabled:!Le,onClick:Re,children:(0,E.jsx)(`img`,{className:`side-brand-icon`,src:n,alt:``,"aria-hidden":`true`})}),(0,E.jsxs)(`button`,{type:`button`,className:`side-brand-trigger`,"aria-haspopup":`menu`,"aria-expanded":Fe,"aria-label":`Switch sub-account`,onClick:()=>{let e=!Fe;I(e),e&&we?.()},children:[(0,E.jsxs)(`span`,{className:`side-brand-lockup`,children:[(0,E.jsx)(`span`,{className:`side-brand-business`,children:Oe}),(0,E.jsx)(`span`,{className:`side-brand-product`,children:le.productName})]}),(0,E.jsx)(ge,{size:14,className:`side-brand-caret`,"aria-hidden":`true`})]})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`img`,{className:`side-brand-icon`,src:n,alt:``,"aria-hidden":`true`}),(0,E.jsxs)(`span`,{className:`side-brand-lockup`,children:[(0,E.jsx)(`span`,{className:`side-brand-business`,children:Oe}),(0,E.jsx)(`span`,{className:`side-brand-product`,children:le.productName})]})]}),Fe&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`side-brand-scrim`,"aria-hidden":`true`,onClick:()=>I(!1)}),(0,E.jsx)(ee,{open:Fe,accounts:k??[],activeAccountId:he??null,switching:be??!1,onSelect:e=>P?.(e),onClose:()=>I(!1)})]})]}),(0,E.jsx)(`nav`,{className:`side-nav`,children:Jt.map(e=>(0,E.jsxs)(`button`,{type:`button`,className:`admin-row nav-row${e.active?` active`:``}`,"aria-current":e.active?`page`:void 0,onClick:e.onClick,children:[e.icon,(0,E.jsx)(`span`,{className:`label`,children:e.label}),(0,E.jsx)(`span`,{className:`kbd`})]},e.key))}),(()=>{let e=B.filter(e=>Xe?!0:!e.isSubagent).filter(e=>Qe?!0:!e.archived),t=B.some(e=>e.isSubagent),n=B.some(e=>e.archived);return(0,E.jsx)(`div`,{className:`side-sessions`,children:(0,E.jsxs)(`div`,{className:`side-list`,children:[(0,E.jsxs)(`div`,{className:`group-head`,children:[(0,E.jsx)(`span`,{children:`Sessions`}),(0,E.jsxs)(`span`,{className:`group-head-meta`,children:[(0,E.jsx)(`button`,{type:`button`,className:`group-head-select${H?` active`:``}`,"aria-pressed":H,title:H?`Exit select mode`:`Select multiple sessions to delete`,onClick:()=>{U(e=>!e),at(new Set),K(null),q(``)},children:`Select`}),(0,E.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Ht,disabled:Je,children:(0,E.jsx)(r,{size:12,className:Je?`spinning`:void 0})}),(0,E.jsx)(`span`,{children:Je?`…`:String(e.length)}),(0,E.jsxs)(`button`,{type:`button`,className:`admin-btn-cta side-sessions-new`,onClick:()=>{X(!0)},disabled:Y,"aria-busy":Y,"aria-label":Y?`Spawning session`:`New session`,title:Y?`Spawning session`:`New session`,children:[Y?(0,E.jsx)(p,{size:13,className:`spinning`}):(0,E.jsx)(oe,{size:13}),(0,E.jsx)(`span`,{children:Y?`Spawning…`:`New session`})]})]})]}),H&&(0,E.jsxs)(`div`,{className:`session-select-bar`,children:[(0,E.jsxs)(`span`,{className:`session-select-count`,children:[W.size,` selected`]}),(0,E.jsxs)(`button`,{type:`button`,className:`session-select-delete`,disabled:W.size===0,onClick:()=>st(!0),children:[`Delete `,W.size]}),(0,E.jsx)(`button`,{type:`button`,className:`session-select-cancel`,onClick:nn,children:`Cancel`})]}),et&&(0,E.jsx)(`div`,{className:`side-account-id`,title:`This install's accountId. The first 8 characters match the truncated UUID label on the live Remote Control daemon entry in claude.ai/code.`,children:(0,E.jsx)(`code`,{children:et})}),(t||n)&&(0,E.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,E.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${Xe?` active`:``}`,"aria-pressed":Xe,onClick:()=>Ze(e=>!e),title:Xe?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),n&&(0,E.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${Qe?` active`:``}`,"aria-pressed":Qe,onClick:()=>$e(e=>!e),title:Qe?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),Ke&&(0,E.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:Ke}),We&&!Ke&&e.length===0&&(0,E.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=It(e.startedAt),n=lt.has(e.sessionId),r=nt.has(e.sessionId),i=dt.has(e.sessionId),a=pt.has(e.sessionId),o=n||r||i||a,s=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},c=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,E.jsx)(ve,{size:12}),busy:n,onClick:()=>{Yt(e)}},{key:`message`,label:`Open session ${e.title} in admin webchat`,menuLabel:`Open in webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,icon:(0,E.jsx)(ye,{size:12}),onClick:()=>{s()}},{key:`usage`,label:`Usage and cost for session ${e.title}`,menuLabel:`Usage & cost`,title:`Per-day active time, tokens, and estimated GBP cost`,icon:(0,E.jsx)(j,{size:12}),onClick:t=>{$t(t,e)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,E.jsx)(se,{size:12}),busy:i,onClick:t=>{an(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,E.jsx)(pe,{size:12}),busy:a,onClick:t=>{on(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,E.jsx)(me,{size:12}),busy:a,onClick:t=>{on(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,E.jsx)(h,{size:12}),busy:bt&&ht===e.sessionId,onClick:t=>{t.stopPropagation(),K(e.sessionId),q(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,E.jsx)(b,{size:12}),danger:!0,busy:r,onClick:t=>{Qt(t,e)}},Ee({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})],l=e.channel===`whatsapp`?` conv-channel-whatsapp`:e.channel===`telegram`?` conv-channel-telegram`:``,u=e.channel===`whatsapp`||e.channel===`telegram`||e.channel===`webchat`,d=ne.includes(e.channel??``)&&e.senderId&&e.titleSource===`prefix`?y({operatorName:e.personName??null,whatsappName:e.whatsappName??null,senderId:e.senderId,title:e.title,channel:e.channel}):e.personName??e.title;return(0,E.jsxs)(`div`,{ref:t=>{let n=V.current;t?n.set(e.sessionId,t):n.delete(e.sessionId)},className:`conv conv-with-actions${l}${e.sessionId===Ue?` active`:``}`,children:[(0,E.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${d} in webchat`,onClick:()=>{if(ht!==e.sessionId){if(H){tn(e.sessionId);return}s()}},onKeyDown:t=>{ht!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),H?tn(e.sessionId):s())},children:[H&&(0,E.jsx)(`span`,{className:`conv-select-check`,onClick:e=>e.stopPropagation(),children:(0,E.jsx)(de,{checked:W.has(e.sessionId),ariaLabel:`Select ${d}`,onChange:()=>tn(e.sessionId)})}),(0,E.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"data-archived":e.archived?`1`:`0`,"aria-label":e.archived?`archived session`:e.live?`live session`:`ended session`}),(0,E.jsxs)(`span`,{className:`conv-stack`,children:[(0,E.jsxs)(`span`,{className:`conv-name-line`,children:[u&&(0,E.jsx)(x,{channel:e.channel,size:13}),ht===e.sessionId?(0,E.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,onFocus:e=>e.currentTarget.select(),value:_t,disabled:bt,"aria-label":`New title for session ${e.title}`,onChange:e=>q(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),sn(e)):t.key===`Escape`&&(t.preventDefault(),K(null),q(``))},onBlur:()=>{ht===e.sessionId&&!bt&&(K(null),q(``))}}):(0,E.jsx)(`span`,{className:`conv-name`,title:d,children:d})]}),(0,E.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,E.jsx)(`code`,{className:`conv-session-id`,title:`First 8 characters of this session's id — distinguishes rows with identical auto-titles. The resume/delete buttons act on the full id.`,children:e.sessionId.slice(0,8)}),t&&(0,E.jsxs)(`span`,{children:[` · `,t]})]})]})]}),!H&&(0,E.jsx)(it,{actions:c,disabled:o})]},e.sessionId)})]})})})(),(0,E.jsxs)(`div`,{className:`side-foot`,children:[(0,E.jsx)(`div`,{className:`avatar`,children:g?(0,E.jsx)(`img`,{src:g,alt:ke}):Ae}),(0,E.jsxs)(`div`,{className:`who`,children:[(0,E.jsx)(`span`,{className:`name`,children:ke}),(0,E.jsx)(zt,{})]}),(0,E.jsx)(`button`,{type:`button`,className:`side-foot-kebab`,"aria-label":`Account menu`,"aria-haspopup":`menu`,"aria-expanded":Ne,onClick:()=>Pe(e=>!e),children:(0,E.jsx)(_e,{size:16})}),Ne&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`side-foot-menu-scrim`,"aria-hidden":`true`,onClick:()=>Pe(!1)}),(0,E.jsx)(`div`,{className:`side-foot-menu`,role:`menu`,children:(0,E.jsx)(w,{variant:`admin`,onCloseMenu:()=>Pe(!1),onLogout:ce??(()=>{}),onDisconnect:ue,disconnecting:fe,claudeConnected:O,onConnectClaude:l,cacheKey:c,onOpenConversations:Te})})]})]}),ze&&(0,E.jsx)(`div`,{className:`copy-toast${ze.failed?` copy-toast-failed`:``}`,role:`status`,children:ze.message}),(0,E.jsx)(xt,{open:Bt,pending:Y,onConfirm:e=>{Zt(e)},onCancel:e=>{X(!1)}}),(0,E.jsx)(Ct,{error:R,onClose:()=>z(null)}),(0,E.jsx)(Tt,{open:Be,onConnect:()=>{Ve(!1),l?.()},onClose:()=>Ve(!1)}),(0,E.jsx)(vt,{target:G,anchorEl:G?V.current.get(G.sessionId)??null:null,onCancel:()=>ct(null),onConfirm:()=>{let e=G;ct(null),e&&en(e)}},G?.sessionId??`none`),(0,E.jsx)(yt,{open:ot,count:W.size,liveCount:B.filter(e=>W.has(e.sessionId)&&e.live).length,onConfirm:()=>{st(!1),rn()},onCancel:()=>st(!1)}),(0,E.jsx)(jt,{show:wt!==null,onClose:()=>{Et(null),J(null),Mt(null)},anchorEl:wt?V.current.get(wt.sessionId)??null:null,sessionId:wt?.sessionId??null,summary:Dt,loading:Ot,error:At},wt?.sessionId??`none`)]})}var Lt=5e3,Rt=3e4;function zt(){let[e,t]=(0,D.useState)(null);if((0,D.useEffect)(()=>{let e=!1,n=null;async function r(){try{let n=await fetch(`/api/admin/system-stats`);if(!n.ok){console.error(`[admin-ui] system-stats-fetch-failed status=${n.status}`);return}let r=await n.json();e||t(r)}catch(e){console.error(`[admin-ui] system-stats-fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}}function i(){n===null&&(r(),n=setInterval(()=>{r()},Lt))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=[`system-stats`];return c&&d.push(`system-stats--warn`),l&&d.push(`system-stats--crit`),(0,E.jsxs)(`span`,{className:d.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,E.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),` · `,(0,E.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]})]})}function Bt(e){return e.supported?e.secureContext?e.permission===`denied`?{show:!1,reason:`permission-denied`}:e.permission===`granted`?e.focused?{show:!1,reason:`focused`}:{show:!0}:{show:!1,reason:`permission-default`}:{show:!1,reason:`insecure-context`}:{show:!1,reason:`unsupported`}}function X(){let e=typeof window<`u`&&`Notification`in window;return{supported:e,secureContext:typeof window<`u`&&window.isSecureContext===!0,permission:e?Notification.permission:`default`,focused:typeof document<`u`&&typeof document.hasFocus==`function`?document.hasFocus():!0}}var Vt=500,Z=new Set,Ht=new Set;function Ut(e,t){if(e.size>=Vt){for(let t of e)if(e.delete(t),e.size<Vt)break}e.add(t)}function Q(e){return e??(typeof globalThis.fetch==`function`?globalThis.fetch:void 0)}function Wt(e,t,n){try{Promise.resolve(e(`/api/admin/events`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:t,fields:n})})).catch(()=>{})}catch{}}function Gt(e,t){let n=Q(t);return n?(Wt(n,`wa-notify:desktop-capability`,{supported:e.supported,secure:e.secureContext,permission:e.permission}),!0):!1}function Kt(e,t,n,r){if(Z.has(e))return!1;let i=Q(r);return i?(Ut(Z,e),Wt(i,`wa-notify:desktop-outcome`,{msgId:e,senderType:t,reason:n}),!0):!1}function qt(e,t,n){try{if(Ht.has(e.waMessageId))return;Ut(Ht,e.waMessageId);let r=Bt(X());if(!r.show){Kt(e.waMessageId,e.senderType,r.reason,n);return}new Notification(`${e.accountName} · ${e.senderDisplay}`,{body:e.body+(e.truncated?`…`:``),icon:t,tag:e.waMessageId}),Kt(e.waMessageId,e.senderType,`shown`,n)}catch{Kt(e.waMessageId,e.senderType,`construct-failed`,n)}}var $=`admin-sidebar-collapsed`,Jt=`admin-sidebar-drawer-open`,Yt=1080;function Xt(){if(typeof window>`u`)return!1;let e=null;try{e=window.sessionStorage.getItem($)}catch{e=null}return e===null?typeof window.matchMedia==`function`?window.matchMedia(`(min-width: 721px) and (max-width: ${Yt}px)`).matches:!1:e===`1`}function Zt(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem($,`1`):window.sessionStorage.removeItem($)}catch{}}function Qt(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Jt)===`1`}catch{return!1}}function $t(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Jt,`1`):window.sessionStorage.removeItem(Jt)}catch{}}function en(e){let[t,n]=(0,D.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,D.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var tn=720;function nn(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function rn(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function an(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`acct`);return!r||!i?null:{sessionId:``,projectDir:``,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`public`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null,source:`store`,accountId:i,remoteJid:r}}function on(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function sn(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:e===`activity`?`/activity`:`/browser`}var cn=`maxy-webchat-browser-open`;function ln(){return typeof window<`u`&&window.location.pathname.startsWith(`/chat`)}function un(e){let{cacheKey:t,businessName:r,variant:i=`admin`,onLogout:a,onDisconnect:o,disconnecting:c,claudeConnected:l,onConnectClaude:u,userName:d,userAvatar:f,role:p,onOpenConversations:m,children:h,footer:g}=e,{subAccounts:v,activeAccountId:y,switching:b,switchAccount:x,refreshAccounts:ee}=ie(t),[te,C]=(0,D.useState)([]),[w,ne]=(0,D.useState)(!1),[T,ae]=(0,D.useState)(!1);(0,D.useEffect)(()=>{let e=ln();if(ne(e),e)try{ae(window.localStorage.getItem(cn)===`1`)}catch{}},[]);let oe=(0,D.useCallback)(()=>{ae(e=>{let t=!e;try{window.localStorage.setItem(cn,t?`1`:`0`)}catch{}return t})},[]),se=w&&T,ce=(0,D.useCallback)(e=>{C(t=>t.filter(t=>t.waMessageId!==e))},[]);(0,D.useEffect)(()=>{if(!t)return;let e=null;try{e=new EventSource(_(`/api/admin/events`,t)),e.addEventListener(B,e=>{try{let t=JSON.parse(e.data);if(!t||typeof t.waMessageId!=`string`)return;C(e=>e.some(e=>e.waMessageId===t.waMessageId)?e:[...e,t]),qt(t,n)}catch{}}),e.onerror=()=>{console.error(`[admin-ui] wa-notify stream error`)}}catch(e){console.error(`[admin-ui] wa-notify unavailable reason=${e instanceof Error?e.message:String(e)}`)}return()=>{e?.close()}},[t]),(0,D.useEffect)(()=>{Gt(X())},[]);let[le,ue]=(0,D.useState)(!0);(0,D.useEffect)(()=>{if(l!==void 0||i!==`admin`)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||ue(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[l,i]);let de=l??le,fe=u??(()=>{window.location.assign(`/?connect=claude`)}),[O,k]=(0,D.useState)(()=>Xt()),[pe,me]=(0,D.useState)(!1),he=(0,D.useRef)(!0);(0,D.useEffect)(()=>{if(he.current){he.current=!1;return}me(!0);let e=setTimeout(()=>me(!1),260);return()=>clearTimeout(e)},[O]);let[A,ge]=(0,D.useState)(()=>Qt()),_e=en(`(max-width: ${tn}px)`),[ve,j]=(0,D.useState)(()=>typeof window>`u`||on(window.location.pathname,window.location.search)?null:an(window.location.pathname,window.location.search)),[M,ye]=(0,D.useState)(()=>typeof window>`u`?!1:on(window.location.pathname,window.location.search)),[be]=(0,D.useState)(()=>M),xe=(0,D.useCallback)(e=>{Zt(e),k(e)},[]),N=(0,D.useCallback)(e=>{$t(e),ge(e)},[]);(0,D.useEffect)(()=>{typeof window>`u`||window.location?.pathname},[]),(0,D.useEffect)(()=>{typeof window>`u`||!ve||window.history.replaceState(null,``,`/`)},[]),(0,D.useEffect)(()=>{typeof window>`u`||!M||window.history.replaceState(null,``,`/`)},[]);let Se=(0,D.useCallback)(e=>{if(ye(!1),e===null){j(null);return}let t=nn(typeof window<`u`?window.location.pathname:`/`,e);t.via===`in-place`?j(e):window.location.href=t.href},[]),Ce=(0,D.useCallback)(()=>{let e=rn(typeof window<`u`?window.location.pathname:`/`);if(e.via===`navigate`){window.location.href=e.href;return}j(null),ye(!0)},[]),P=_e?A:!O,we=(0,D.useCallback)(()=>{typeof window>`u`||(window.matchMedia(`(max-width: ${tn}px)`).matches?N(!A):xe(!O))},[O,A,xe,N]),Te=(0,D.useCallback)(e=>{let t=sn(e,i);window.location.href=t},[i]),F={collapsed:O,mobileDrawerOpen:A,sidebarOpen:P,onToggleSidebar:we,setMobileDrawerOpen:N,selectedWhatsapp:ve,onClearWhatsapp:()=>j(null),onSelectWhatsappConversation:Se,dataOpen:M};return i===`operator`?(0,E.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[b&&(0,E.jsx)(S,{surface:`switch`}),(0,E.jsx)(re,{businessName:r,variant:i,onNavigate:Te,onOpenConversations:m,onToggleSidebar:we,sidebarOpen:P,onLogout:a,onDisconnect:o,disconnecting:c,cacheKey:t,subAccounts:v,activeAccountId:y,switchingAccount:b,onSwitchAccount:x,refreshAccounts:ee}),(0,E.jsx)(`div`,{className:`platform platform-operator`,children:typeof h==`function`?h(F):h}),(0,E.jsx)(Je,{variant:`operator`,onOpenConversations:m}),g,(0,E.jsx)(Ve,{frames:te,onExpire:ce})]}):(0,E.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[b&&(0,E.jsx)(S,{surface:`switch`}),(0,E.jsxs)(`div`,{className:`platform${A?` menu-open`:``}${!_e&&O?` sidebar-collapsed`:``}${pe?` sidebar-animating`:``}`,"data-artefact":se?`browser`:`closed`,children:[(0,E.jsx)(Y,{businessName:r,cacheKey:t,onConnectClaude:fe,role:p??null,userName:d,userAvatar:f??null,onSelectProjects:()=>{window.location.href=`/graph?label=${s().label}`},onSelectTasks:()=>{window.location.href=`/tasks`},onCloseMobileDrawer:()=>N(!1),collapsed:O,mobileDrawerOpen:A,onSelectData:Ce,onCloseData:()=>ye(!1),initialDataSurface:be,onLogout:a,onDisconnect:o,disconnecting:c,claudeConnected:de,subAccounts:v,activeAccountId:y,switchingAccount:b,onSwitchAccount:x,refreshAccounts:ee,onOpenConversations:m}),!_e&&(0,E.jsx)($e,{}),(0,E.jsx)(We,{sidebarOpen:P,onToggleSidebar:we,claudeConnected:de,onConnectClaude:fe,browserOpen:w?T:void 0,onToggleBrowser:w?oe:void 0}),typeof h==`function`?h(F):h,se&&(0,E.jsx)(`div`,{className:`webchat-browser-pane`,children:(0,E.jsx)(Ie,{cacheKey:e.cacheKey,surface:`webchat`})})]}),A&&(0,E.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>N(!1)}),(0,E.jsx)(Je,{}),g,(0,E.jsx)(Ve,{frames:te,onExpire:ce})]})}export{me as C,ue as D,de as E,A as S,k as T,M as _,wt as a,_e as b,H as c,ot as d,Ie as f,ye as g,xe as h,Tt as i,U as l,N as m,en as n,xt as o,Ce as p,Ft as r,W as s,un as t,ct as u,j as v,pe as w,ge as x,ve as y};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,U as n,W as r,Y as i,_ as a,a as o,d as s,q as c,s as l,u,v as ee,x as te}from"./useSubAccountSwitcher-ny9tP8am.js";import{n as d,t as f}from"./AdminLoginScreens-BpHVvUsH.js";import{f as ne,s as p,x as m}from"./useVoiceRecorder-DcgtZl-4.js";import{S as re,a as h,m as ie,t as g,x as ae,y as _}from"./AdminShell-BT7VQIu7.js";import{t as v}from"./chevron-left-DU8Es8Xq.js";import{t as y}from"./chevron-right-D8HTOkyy.js";import{n as b,r as x}from"./page-ZG7SXMO0.js";import{t as oe}from"./file-text-lsHlk4lR.js";import"./graph-labels-Ci5Jz1oY.js";import{n as se}from"./file-download-DbNIjWiK.js";var S=c(),C=e(i(),1),w=n();function T({onOpen:e}){return(0,w.jsx)(`footer`,{className:`admin-footer`,children:(0,w.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,w.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,w.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function E({sessionId:e,projectDir:t,sessionKey:n,contactName:r,onBack:i}){return(0,w.jsxs)(`div`,{className:`wa-web`,children:[(0,w.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,w.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,w.jsx)(v,{size:20})}),(0,w.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,w.jsx)(m,{size:20})}),(0,w.jsx)(`div`,{className:`wa-web-titles`,children:(0,w.jsx)(`span`,{className:`wa-web-name`,children:r})})]}),(0,w.jsx)(`div`,{className:`wa-web-body`,children:(0,w.jsx)(p,{sessionId:e,projectDir:t,sessionKey:n,forceDeliveredOnly:!0})})]})}var D=6e4,O=60*D,k=24*O,A=D,j=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],M=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function N(e){return e<10?`0${e}`:String(e)}function P(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function F(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return`—`;let n=t-e;if(n<-A)return`—`;let r=n<0?0:n;if(r<D)return`just now`;if(r<O)return`${Math.floor(r/D)}m`;if(r<k)return`${Math.floor(r/O)}h`;let i=new Date(t),a=new Date(e),o=Math.round((P(i)-P(a))/k);if(o===1)return`yesterday`;if(o>=2&&o<=6)return M[a.getDay()];let s=N(a.getDate()),c=j[a.getMonth()];return a.getFullYear()===i.getFullYear()?`${s} ${c}`:`${s} ${c} ${a.getFullYear()}`}function I({variant:e=`row`,count:t=1}){return(0,w.jsx)(w.Fragment,{children:Array.from({length:t},(t,n)=>(0,w.jsx)(`span`,{className:`dashboard-skeleton dashboard-skeleton--${e}`,"data-testid":`dashboard-skeleton`,"aria-hidden":`true`},n))})}var ce=6e4;function le(e){return e<12?`morning`:e<18?`afternoon`:`evening`}function L(e){return e&&e.trim().split(/\s+/)[0]||`there`}function ue(e){if(!e)return`everything is running normally.`;let t=e.cpuPct,n=e.memUsedPct;return t!==null&&t>=.98||n!==null&&n>=.98?`system load is critical.`:t!==null&&t>=.9||n!==null&&n>=.9?`system load is high.`:`everything is running normally.`}function R(e){return e==null?`—`:`${Math.round(e*100)}%`}function de(e){return e.isGroup===!0?e.chatName??e.title:e.operatorName??e.chatName??e.whatsappName??e.senderId??e.title}function z(e,t){if(!e)return!1;let n=Date.parse(e);if(!Number.isFinite(n))return!1;let r=new Date(n),i=new Date(t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()}function fe(e){return e?e.replace(/^claude-/,``):null}var B=new Set([`sessions`,`conversations`,`tasks`,`artefacts`,`skills`,`stats`]),V=!1;function pe(e,t,n,r){let i=e=>t.get(e)??null,a=r?r.getEntriesByType(`navigation`)[0]:void 0,o=r?r.getEntriesByType(`resource`).filter(e=>new URL(e.name,`http://x`).pathname.startsWith(`/assets/`)):[],s=e=>e===void 0||!Number.isFinite(e)?null:Math.round(e),c=e=>e?s(e):null;return{batchMs:e,sessionsMs:i(`sessions`),conversationsMs:i(`conversations`),tasksMs:i(`tasks`),artefactsMs:i(`artefacts`),skillsMs:i(`skills`),statsMs:i(`stats`),failed:[...B].filter(e=>n.has(e)).join(`,`)||`none`,ttfbMs:s(a?.responseStart),domContentLoadedMs:c(a?.domContentLoadedEventEnd),loadMs:c(a?.loadEventEnd),assetCount:o.length,assetBytes:o.reduce((e,t)=>e+(t.transferSize||0),0),assetMs:o.length?s(Math.max(...o.map(e=>e.responseEnd))):null}}function H({cacheKey:e,userName:n,onSelectWhatsappConversation:i}){let a=ee(e),[c,d]=(0,C.useState)(null),[f,p]=(0,C.useState)(null),[m,h]=(0,C.useState)(null),g=(0,C.useRef)(!1),[v,b]=(0,C.useState)(null),[x,S]=(0,C.useState)(null),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(null),[k,A]=(0,C.useState)(null),[j,M]=(0,C.useState)(null),[N,P]=(0,C.useState)(new Set),[B,H]=(0,C.useState)(()=>new Set),U=(0,C.useCallback)(e=>{H(t=>t.has(e)?t:new Set(t).add(e))},[]),W=Date.now(),G=(0,C.useRef)(!1),K=(0,C.useRef)(new Map),q=(0,C.useRef)(new Set),J=(0,C.useRef)(null);(0,C.useEffect)(()=>{if(!e)return;let t=!1;async function n(e,n,r,i){let o=Date.now(),s=typeof n==`string`?n:`unresolved`;try{typeof n!=`string`&&(s=await n());let e=await a(s);if(!e.ok)throw Error(`status ${e.status}`);let o=await e.json();t||i(r(o))}catch(t){q.current.add(e),console.error(`[admin-ui] dashboard-fetch-failed slice=${e} url=${s} ms=${Date.now()-o} reason=${t instanceof Error?t.message:String(t)}`)}finally{K.current.set(e,Date.now()-o),U(e)}}async function i(){if(!J.current){let e=await a(`/api/admin/accounts`);if(!e.ok)throw Error(`accounts status ${e.status}`);let t=await e.json(),n=t.accounts??[],r=t.activeAccountId??null,i=n.find(e=>e.accountId===r);if(!i)throw Error(`accounts: active ${r??`none`} absent from list of ${n.length}`);let o=i.isHouse||n.length===1;J.current={accountId:i.accountId,isHouse:o}}let{accountId:e,isHouse:t}=J.current;return t?`/api/operator-conversations/conversations-all`:`/api/operator-conversations/conversations`}let o={"sidebar-sessions":()=>n(`sessions`,`/api/admin/sidebar-sessions`,e=>e.sessions??[],d),"conversations-all":()=>n(`conversations`,i,e=>e.conversations??[],p),"tasks-list":()=>n(`tasks`,`/api/admin/tasks-list`,e=>e,S),"sidebar-artefacts":()=>n(`artefacts`,`/api/admin/sidebar-artefacts`,e=>e.artefacts??[],E),skills:()=>n(`skills`,`/api/admin/skills`,e=>e.skills??[],O)};async function s(){if(G.current)return;G.current=!0;let e=Date.now();try{await Promise.all([...Object.values(o).map(e=>e()),n(`stats`,`/api/admin/system-stats`,e=>e,b),n(`bookingLink`,`/api/admin/calendar/booking-link`,e=>e.bookingDomain??null,A),n(`portalLink`,`/api/admin/data-portal/portal-link`,e=>e.portalDomain??null,M)])}finally{G.current=!1;let t=Date.now()-e;if(!V){V=!0;try{let e=pe(t,K.current,q.current,typeof performance>`u`?null:performance);fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`dashboard-load`,...e}),keepalive:!0}).catch(()=>{})}catch{}}}}s();let c=null;try{c=new EventSource(r(`/api/admin/events`,e)),c.onmessage=e=>{if(document.visibilityState===`visible`)try{let{resource:t}=JSON.parse(e.data),n=t?o[t]:void 0;n&&n()}catch{}},c.onerror=()=>{console.error(`[admin-ui] dashboard-events stream error`)}}catch(e){console.error(`[admin-ui] dashboard-events unavailable reason=${e instanceof Error?e.message:String(e)}`)}let l=setInterval(()=>{document.visibilityState===`visible`&&s()},ce),u=()=>{document.visibilityState===`visible`&&s()};return document.addEventListener(`visibilitychange`,u),()=>{t=!0,G.current=!1,clearInterval(l),c?.close(),document.removeEventListener(`visibilitychange`,u)}},[e,a]);let Y=(0,C.useMemo)(()=>(c??[]).filter(e=>!e.isSubagent),[c]),X=(0,C.useMemo)(()=>Y.filter(e=>e.live),[Y]),me=(0,C.useMemo)(()=>(f??[]).filter(e=>z(e.lastMessageAt,W)).length,[f,W]),he=x?.open.length??0,Z=(0,C.useMemo)(()=>{let e=new Map;for(let t of f??[]){let n=e.get(t.channel)??[];n.push(t),e.set(t.channel,n)}return[...e.entries()].map(([e,t])=>{let n=t.reduce((e,t)=>t.lastMessageAt&&(!e||Date.parse(t.lastMessageAt)>Date.parse(e.lastMessageAt??``))?t:e,null);return{channel:e,count:t.length,preview:n?de(n):``,rows:t}})},[f]);(0,C.useEffect)(()=>{g.current||Z.length!==0&&(g.current=!0,h(Z[0].channel))},[Z]);let Q=(0,C.useRef)(!1);(0,C.useEffect)(()=>{Q.current||!B.has(`bookingLink`)||!B.has(`portalLink`)||(Q.current=!0)},[B,k,j]);let ge=(0,C.useCallback)(async e=>{if(!N.has(e)){P(t=>new Set(t).add(e));try{let t=await a(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e})});if(!t.ok){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} status=${t.status}`);return}d(t=>(t??[]).map(t=>t.sessionId===e?{...t,live:!1}:t))}catch(t){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} reason=${t instanceof Error?t.message:String(t)}`)}finally{P(t=>{let n=new Set(t);return n.delete(e),n})}}},[a,N]),_e=(0,C.useCallback)(t=>{if(!e||!t.downloadPath){console.error(`[admin-ui] dashboard-artefact-download-blocked id=${t.id} reason=${e?`not-downloadable`:`no-cache-key`}`);return}se(e,t.downloadPath,t.downloadRoot??`data`)},[e]),$=le(new Date(W).getHours());return(0,w.jsxs)(`div`,{className:`ui-page ui-page--full dashboard-home`,children:[(0,w.jsx)(`p`,{className:`dashboard-greeting`,children:B.has(`stats`)?`Good ${$}, ${L(n)} — ${ue(v)}`:`Good ${$}, ${L(n)}`}),(0,w.jsxs)(`div`,{className:`dashboard-stats`,children:[(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Live sessions`}),B.has(`sessions`)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:X.length}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`of `,Y.length,` total`]})]}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Messages today`}),B.has(`conversations`)?(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:me}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`a`,{className:`admin-stat-card dashboard-stat-card dashboard-stat-card--link`,href:`/tasks`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Open tasks`}),B.has(`tasks`)?(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:he}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Host CPU`}),B.has(`stats`)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:R(v?.cpuPct??null)}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`RAM `,R(v?.memUsedPct??null)]})]}):(0,w.jsx)(I,{variant:`value`})]})]}),(0,w.jsxs)(`div`,{className:`dashboard-columns`,children:[(0,w.jsxs)(`div`,{className:`dashboard-col`,children:[(k||j)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Public pages`}),(0,w.jsxs)(`div`,{className:`admin-card dashboard-public-pages`,children:[k&&(0,w.jsxs)(`a`,{className:`admin-row dashboard-public-row`,href:`https://${k}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,w.jsx)(`span`,{className:`dashboard-public-icon`,children:(0,w.jsx)(_,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-public-name`,children:`Booking page`})]}),j&&(0,w.jsxs)(`a`,{className:`admin-row dashboard-public-row`,href:`https://${j}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,w.jsx)(`span`,{className:`dashboard-public-icon`,children:(0,w.jsx)(_,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-public-name`,children:`File drop`})]})]})]}),(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Live now`}),B.has(`sessions`)?X.length===0?(0,w.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No live sessions right now.`}):X.map(e=>{let t=[e.sessionId.slice(0,8),fe(e.model),F(Date.parse(e.startedAt),W)].filter(Boolean).join(` · `);return(0,w.jsxs)(`div`,{className:`admin-card dashboard-live-card`,children:[(0,w.jsx)(`span`,{className:`admin-status-dot is-live`}),(0,w.jsxs)(`div`,{className:`dashboard-live-main`,children:[(0,w.jsx)(`span`,{className:`dashboard-live-name`,children:e.title}),(0,w.jsx)(`span`,{className:`dashboard-live-meta`,children:t})]}),(0,w.jsx)(`a`,{className:`admin-btn-cta dashboard-open-btn`,href:`/chat?session=${encodeURIComponent(e.sessionId)}`,children:`Open`}),(0,w.jsx)(`button`,{type:`button`,className:`dashboard-stop-btn`,"aria-label":`Stop ${e.title}`,disabled:N.has(e.sessionId),onClick:()=>void ge(e.sessionId),children:(0,w.jsx)(te,{size:12})})]},e.sessionId)}):(0,w.jsx)(I,{variant:`card`,count:2}),(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Recent artefacts`}),(0,w.jsx)(`div`,{className:`admin-card dashboard-artefacts`,children:B.has(`artefacts`)?(T??[]).length===0?(0,w.jsx)(`div`,{className:`dashboard-empty`,children:`No recent artefacts.`}):(T??[]).slice(0,6).map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-artefact-row`,onClick:()=>_e(e),children:[(0,w.jsx)(`span`,{className:`dashboard-artefact-icon`,children:e.kind===`agent-template`?(0,w.jsx)(re,{size:16}):(0,w.jsx)(oe,{size:16})}),(0,w.jsx)(`div`,{className:`dashboard-artefact-body`,children:(0,w.jsx)(`span`,{className:`dashboard-artefact-name`,children:e.name})}),(0,w.jsx)(`span`,{className:`dashboard-artefact-time`,children:F(Date.parse(e.updatedAt),W)})]},e.id)):(0,w.jsx)(I,{count:3})}),(0,w.jsx)(`a`,{className:`admin-section-label dashboard-col-label dashboard-skills-label`,href:`/skills`,children:`Skills`}),(0,w.jsx)(`div`,{className:`admin-card dashboard-skills`,children:B.has(`skills`)?(D??[]).length===0?(0,w.jsx)(`div`,{className:`dashboard-empty`,children:`No skills yet.`}):(D??[]).map(e=>(0,w.jsxs)(`a`,{className:`admin-row dashboard-skill-row`,href:`/skills`,children:[(0,w.jsx)(`span`,{className:`dashboard-skill-icon`,children:(0,w.jsx)(ie,{size:16})}),(0,w.jsxs)(`div`,{className:`dashboard-skill-body`,children:[(0,w.jsx)(`span`,{className:`dashboard-skill-name`,children:e.skill}),(0,w.jsx)(`span`,{className:`dashboard-skill-plugin`,children:e.plugin})]})]},`${e.plugin}/${e.skill}`)):(0,w.jsx)(I,{count:2})})]}),(0,w.jsxs)(`div`,{className:`dashboard-col`,children:[(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Channels`}),B.has(`conversations`)?Z.length===0?(0,w.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No channel activity.`}):Z.map(n=>{let r=m===n.channel;return(0,w.jsxs)(`div`,{className:`admin-card dashboard-channel-card`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`dashboard-channel-head`,"aria-expanded":r,onClick:()=>h(e=>e===n.channel?null:n.channel),children:[(0,w.jsx)(`span`,{className:`dashboard-channel-glyph`,children:n.channel===`whatsapp`||n.channel===`telegram`?(0,w.jsx)(s,{channel:n.channel,size:16}):(0,w.jsx)(t,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-channel-name`,children:u[n.channel]??n.channel}),(0,w.jsx)(`span`,{className:`dashboard-channel-badge`,children:n.count}),(0,w.jsx)(`span`,{className:`dashboard-channel-chevron`,children:r?(0,w.jsx)(ae,{size:14}):(0,w.jsx)(y,{size:14})})]}),r?(0,w.jsx)(`div`,{className:`dashboard-channel-convs`,children:n.rows.map(t=>(0,w.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-channel-conv-row`,onClick:()=>i(t),title:t.title,children:[(0,w.jsxs)(`span`,{className:`dashboard-channel-conv-line`,children:[(0,w.jsx)(ne,{accountId:t.accountId??``,jid:t.remoteJid,sessionKey:e??``,className:`dashboard-channel-conv-avatar`,size:16}),(0,w.jsx)(`span`,{className:`dashboard-channel-conv-name`,children:o(t)}),t.isGroup===!0&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag is-group`,children:`Group`}),t.role===`public`&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag is-public`,children:`Public`}),(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag`,children:t.isHouse?`House`:`Client`}),!t.preview&&t.lastMessageAt&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:F(Date.parse(t.lastMessageAt),W)})]}),t.preview?(0,w.jsxs)(`span`,{className:`dashboard-channel-conv-sub`,children:[(0,w.jsx)(`span`,{className:`dashboard-channel-conv-preview`,children:t.preview}),t.lastMessageAt&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:F(Date.parse(t.lastMessageAt),W)})]}):null]},l(t)))}):n.preview&&(0,w.jsx)(`span`,{className:`dashboard-channel-preview`,children:n.preview})]},n.channel)}):(0,w.jsx)(I,{variant:`card`,count:2})]})]})]})}function U(){let e=d(),[t,n]=(0,C.useState)(!1);(0,C.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,C.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t)return;let r=Date.now();if(!e.cacheKey){console.error(`[admin-ui] claude-info-fetch-skipped reason=no-session-key`);return}try{let t=await fetch(`/api/admin/claude-info?session_key=${encodeURIComponent(e.cacheKey)}`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),i=(0,C.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,w.jsx)(a,{cacheKey:e.cacheKey,onSessionExpired:i,surface:`chat`,children:(0,w.jsx)(g,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,claudeConnected:e.claudeConnected,onConnectClaude:()=>e.setAppState(`connect-claude`),userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(T,{onOpen:r}),(0,w.jsx)(h,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,w.jsx)(w.Fragment,{children:t.dataOpen&&e.cacheKey?(0,w.jsx)(b,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?t.selectedWhatsapp.source===`store`&&t.selectedWhatsapp.remoteJid&&t.selectedWhatsapp.accountId?(0,w.jsx)(x,{accountId:t.selectedWhatsapp.accountId,remoteJid:t.selectedWhatsapp.remoteJid,contactName:o(t.selectedWhatsapp),sessionKey:e.cacheKey,onBack:t.onClearWhatsapp},l(t.selectedWhatsapp)):(0,w.jsx)(E,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,contactName:o(t.selectedWhatsapp),onBack:t.onClearWhatsapp},l(t.selectedWhatsapp)):(0,w.jsx)(H,{cacheKey:e.cacheKey,userName:e.userName,onSelectWhatsappConversation:t.onSelectWhatsappConversation})})})}):(0,w.jsx)(f,{auth:e})}(0,S.createRoot)(document.getElementById(`root`)).render((0,w.jsx)(U,{}));
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{K as t,M as n,O as r,R as i,T as a,U as o,Y as s,_ as c,b as l,g as u,q as d,w as f,y as p}from"./useSubAccountSwitcher-ny9tP8am.js";import{D as m,t as h,y as g}from"./AdminShell-BT7VQIu7.js";import{t as _}from"./chevron-left-DU8Es8Xq.js";import{t as v}from"./chevron-right-D8HTOkyy.js";import{t as y}from"./clock-BdNuUyUU.js";var b=i(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),x=i(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),S=i(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),C=i(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),w=i(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),T=d(),E=e(s(),1);function D(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function O(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function k(e){let t=D(e),n=t.getDay();return O(t,n===0?-6:1-n)}function A(e,t){switch(e){case`day`:{let e=D(t);return{from:e,to:O(e,1)}}case`week`:{let e=k(t);return{from:e,to:O(e,7)}}case`month`:return{from:new Date(t.getFullYear(),t.getMonth(),1),to:new Date(t.getFullYear(),t.getMonth()+1,1)};case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function j(e,t,n){switch(e){case`day`:return O(t,n);case`week`:return O(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function M(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}var ee=[`day`,`week`,`month`,`year`],N=`month`;function P(e){return e.toLocaleDateString([],{day:`numeric`,month:`short`})}function F(e){return e.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}function te(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=A(`week`,t);return`${P(e)} – ${F(new Date(n.getTime()-1))}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function I(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var L=o(),R={meeting:`Meeting`,event:`Event`,task:`Task`};function z(e){return R[e.kind??`meeting`]}function B(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function V(e){if(e.isAllDay)return`All day`;let t=B(new Date(e.startsAt));return e.endsAt?`${t} – ${B(new Date(e.endsAt))}`:t}function H(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ne(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=B(t);return e.endsAt?`${n} · ${r} – ${B(new Date(e.endsAt))}`:`${n} · ${r}`}function U(e,t){return e.email??`${e.name??`unknown`}-${t}`}function W(e){return e.map(e=>e.name||e.email||`Unknown`).join(`, `)}function G({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,L.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,L.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,L.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function K(e){let t=[...e].sort((e,t)=>e.start.localeCompare(t.start)),n=[];for(let e of t){let t=n[n.length-1];t&&t.end===e.start?(t.end=e.end,t.slots+=1):n.push({start:e.start,end:e.end,slots:1})}return n}function q(e){let t=e.slots===1?`slot`:`slots`;return`free ${B(new Date(e.start))} – ${B(new Date(e.end))} · ${e.slots} ${t}`}function J(e,t,n,r=[]){let i=D(t),a=[];for(let t=0;t<n;t++){let n=O(i,t),o=e.filter(e=>M(new Date(e.startsAt),n)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),s=r.some(e=>M(new Date(e.start),n));(o.length>0||s)&&a.push({day:n,meetings:o})}return a}function Y(e,t){return Math.round((D(t).getTime()-D(e).getTime())/864e5)}function X(e,t){let n=e.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`});return M(e,t)?`${n} · today`:n}function re({from:e,to:t,meetings:n,stretches:r,gapSource:i,showAllKinds:a,onToggleKinds:o,onSelect:s,onAddAt:c}){let l=a?n:n.filter(e=>(e.kind??`meeting`)===`meeting`),u=n.length-l.length,d=J(l,e,Y(e,t),r),f=new Date,p=(0,L.jsxs)(`div`,{className:`cal-list-controls`,children:[(0,L.jsx)(`button`,{type:`button`,className:`cal-kind-toggle${a?` cal-kind-toggle-on`:``}`,onClick:o,"aria-pressed":a,children:a?`Meetings only`:`Show reminders and tasks`}),u>0&&(0,L.jsxs)(`span`,{className:`cal-hidden-count`,children:[u,` hidden`]}),i===`none`&&(0,L.jsx)(`span`,{className:`cal-no-hours`,children:`Free time is not shown: working hours are not set.`})]});return d.length===0?(0,L.jsxs)(`div`,{className:`cal-schedule`,children:[p,(0,L.jsx)(`div`,{className:`cal-schedule-empty`,children:`No events in this period.`})]}):(0,L.jsxs)(`div`,{className:`cal-schedule`,children:[p,d.map(e=>{let t=r.filter(t=>M(new Date(t.start),e.day));return(0,L.jsxs)(`section`,{className:`cal-sched-group`,children:[(0,L.jsx)(`h3`,{className:`cal-sched-day${M(e.day,f)?` cal-sched-day-today`:``}`,children:X(e.day,f)}),e.meetings.map(e=>{let t=[e.location,W(e.attendees)||null,z(e)].filter(Boolean);return(0,L.jsxs)(`div`,{className:`cal-sched-row`,"data-testid":`row-${e.meetingId}`,"data-meeting-id":e.meetingId,"data-kind":e.kind??`meeting`,...I(e,s),children:[(0,L.jsx)(`span`,{className:`cal-sched-time`,children:V(e)}),(0,L.jsxs)(`span`,{className:`cal-sched-detail`,children:[(0,L.jsx)(`span`,{className:`cal-sched-title`,children:e.title??`Untitled`}),(0,L.jsx)(`span`,{className:`cal-sched-meta`,children:t.join(` · `)})]})]},e.meetingId)}),t.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`cal-gap`,"data-gap-start":e.start,onClick:()=>c(e.start,e.end),children:q(e)},e.start))]},e.day.toISOString())})]})}function Z({initialStart:e,initialEnd:t,adminFetch:n,onClose:i,onCreated:a}){let[o,s]=(0,E.useState)(``),[c,l]=(0,E.useState)(e),[u,d]=(0,E.useState)(t),[f,m]=(0,E.useState)(``),[h,g]=(0,E.useState)(``),[_,v]=(0,E.useState)(!1),[y,b]=(0,E.useState)(null),x=(0,E.useCallback)(async()=>{if(!o.trim()){b(`Title is required`);return}if(!c){b(`Start time is required`);return}v(!0),b(null);try{let e=await n(`/api/admin/calendar/meetings`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:o.trim(),startsAt:new Date(c).toISOString(),endsAt:u?new Date(u).toISOString():null,location:f.trim()||null,privateNote:h.trim()||null})}),t=await e.json();if(!e.ok){b(t.error??`Create failed (HTTP ${e.status})`);return}t.meeting&&a(t.meeting)}catch(e){b(e instanceof Error?e.message:`Create failed`)}finally{v(!1)}},[o,c,u,f,h,n,a]);return(0,L.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{_||i()},children:(0,L.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add meeting`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,L.jsx)(`span`,{className:`cal-modal-kind`,children:`New meeting`}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,disabled:_,children:(0,L.jsx)(p,{size:16})})]}),(0,L.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Title`}),(0,L.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),disabled:_,autoFocus:!0})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Starts`}),(0,L.jsx)(`input`,{type:`datetime-local`,value:c,onChange:e=>l(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Ends`}),(0,L.jsx)(`input`,{type:`datetime-local`,value:u,onChange:e=>d(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Location`}),(0,L.jsx)(`input`,{type:`text`,value:f,onChange:e=>m(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Private note`}),(0,L.jsx)(`textarea`,{value:h,onChange:e=>g(e.target.value),disabled:_,rows:2})]}),y&&(0,L.jsx)(`div`,{className:`cal-modal-error`,children:y})]}),(0,L.jsxs)(`div`,{className:`cal-modal-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:i,disabled:_,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:x,disabled:_,children:[_?(0,L.jsx)(r,{size:14,className:`spin`}):null,` Create`]})]})]})})}function ie(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function ae(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function oe({meeting:e,adminFetch:t,onClose:i,onSaved:o,onDeleted:s}){let c=e.kind===`meeting`,[u,d]=(0,E.useState)(!1),[f,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)(!1),[_,v]=(0,E.useState)(!1),[T,D]=(0,E.useState)(null),[O,k]=(0,E.useState)(e),[A,j]=(0,E.useState)(e.title??``),[M,ee]=(0,E.useState)(H(e.startsAt)),[N,P]=(0,E.useState)(e.endsAt?H(e.endsAt):``),[F,te]=(0,E.useState)(e.location??``),[I,z]=(0,E.useState)(e.privateNote??``),[B,V]=(0,E.useState)(``),[W,K]=(0,E.useState)(``);(0,E.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!_&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,i]);let q=(0,E.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=ie(M);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=N?ie(N):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=F.trim()||null;i!==(O.location??null)&&(e.location=i);let a=I.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,M,N,F,I,O]),J=(0,E.useCallback)(async()=>{let n=q();if(Object.keys(n).length===0){d(!1);return}v(!0),D(null);try{let r=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();k(i.meeting),o(i.meeting),d(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{v(!1)}},[t,q,e.meetingId,o]),Y=(0,E.useCallback)(async()=>{let n=B.trim(),r=W.trim();if(!(!n&&!r)){v(!0),D(null);try{let i=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n||void 0,email:r||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();k(a.meeting),o(a.meeting),V(``),K(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{v(!1)}}},[t,B,W,e.meetingId,o]),X=(0,E.useCallback)(async n=>{let r=n.email?{email:n.email}:{name:n.name};v(!0),D(null);try{let n=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();k(i.meeting),o(i.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{v(!1)}},[t,e.meetingId,o]),re=(0,E.useCallback)(async()=>{v(!0),D(null);try{let n=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!n.ok)throw Error(`HTTP ${n.status}`);s(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),v(!1)}},[t,e.meetingId,s]),Z=(0,E.useCallback)(async n=>{g(!1),v(!0),D(null);try{let r=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${n?`1`:`0`}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=ae(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){D(e instanceof Error?e.message:`Download failed`)}finally{v(!1)}},[t,e.meetingId]),oe=R[e.kind??`meeting`],se=B.trim().length>0||W.trim().length>0;return(0,L.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{_||i()},children:(0,L.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":u?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,L.jsx)(`span`,{className:`cal-modal-kind`,children:oe}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:_,children:(0,L.jsx)(p,{size:16})})]}),!u&&(0,L.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,L.jsx)(`div`,{className:`cal-modal-title`,children:O.title??`Untitled`}),(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(y,{size:14}),(0,L.jsx)(`span`,{children:ne(O)})]}),O.location&&(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(x,{size:14}),(0,L.jsx)(`span`,{children:O.location})]}),O.attendees.length>0&&(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,L.jsx)(w,{size:14}),(0,L.jsx)(`div`,{className:`cal-modal-attendees`,children:O.attendees.map((e,t)=>(0,L.jsx)(`div`,{className:`cal-attendee-row`,children:(0,L.jsx)(G,{a:e})},U(e,t)))})]}),O.privateNote&&(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,L.jsx)(S,{size:14}),(0,L.jsx)(`span`,{className:`cal-modal-note`,children:O.privateNote})]}),(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,L.jsx)(b,{size:14}),(0,L.jsx)(`span`,{children:oe})]})]}),u&&(0,L.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Title`}),(0,L.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Start`}),(0,L.jsx)(`input`,{type:`datetime-local`,value:M,onChange:e=>ee(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`End`}),(0,L.jsx)(`input`,{type:`datetime-local`,value:N,onChange:e=>P(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Location`}),(0,L.jsx)(`input`,{type:`text`,value:F,onChange:e=>te(e.target.value),disabled:_})]}),(0,L.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Attendees`}),(0,L.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[O.attendees.length===0&&(0,L.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),O.attendees.map((e,t)=>(0,L.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,L.jsx)(G,{a:e}),(0,L.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>X(e),disabled:_,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,L.jsx)(p,{size:13})})]},U(e,t)))]}),(0,L.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,L.jsx)(`input`,{type:`text`,placeholder:`Name`,value:B,onChange:e=>V(e.target.value),disabled:_,"aria-label":`Attendee name`}),(0,L.jsx)(`input`,{type:`email`,placeholder:`Email`,value:W,onChange:e=>K(e.target.value),disabled:_,"aria-label":`Attendee email`}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:Y,disabled:_||!se,"aria-label":`Add attendee`,children:_?(0,L.jsx)(r,{size:13,className:`spin`}):(0,L.jsx)(C,{size:13})})]})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Private note`}),(0,L.jsx)(`textarea`,{className:`cal-modal-textarea`,value:I,onChange:e=>z(e.target.value),disabled:_,rows:3,placeholder:`Only you and your team can see this.`})]})]}),T&&(0,L.jsx)(`div`,{className:`cal-modal-error`,children:T}),c&&(0,L.jsxs)(`div`,{className:`cal-modal-actions`,children:[!u&&!f&&!h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>d(!0),disabled:_,children:[(0,L.jsx)(a,{size:14}),` Edit`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:_,children:[(0,L.jsx)(l,{size:14}),` Delete`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?g(!0):Z(!1)},disabled:_,children:[_?(0,L.jsx)(r,{size:14,className:`spin`}):(0,L.jsx)(n,{size:14}),` Download`]})]}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>Z(!0),disabled:_,children:[_?(0,L.jsx)(r,{size:14,className:`spin`}):null,` Yes`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>Z(!1),disabled:_,children:`No`}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>g(!1),disabled:_,children:`Cancel`})]}),u&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:J,disabled:_,children:[_?(0,L.jsx)(r,{size:14,className:`spin`}):null,` Save`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{d(!1),D(null)},disabled:_,children:`Cancel`})]}),f&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:re,disabled:_,children:[_?(0,L.jsx)(r,{size:14,className:`spin`}):null,` Delete`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:_,children:`Cancel`})]})]})]})})}var se=8;function ce(e,t){return t?{op:`view-census`,range:e,nodes:t.nodes.length,clippedV:t.nodes.filter(e=>e.clippedV).length,clippedH:t.nodes.filter(e=>e.clippedH).length,hidden:t.hidden,fields:t.fields.length>0?t.fields.join(`,`):`-`,minBlockPx:t.minBlockPx??`-`,lineBoxPx:t.lineBoxPx??`-`,gapSource:t.gapSource??`-`,gaps:t.gaps??`-`,shownKinds:t.shownKinds??`-`,hiddenKinds:t.hiddenKinds??`-`,source:`measured`}:{op:`view-census`,range:e,nodes:`-`,clippedV:`-`,clippedH:`-`,hidden:`-`,fields:`-`,minBlockPx:`-`,lineBoxPx:`-`,gapSource:`-`,gaps:`-`,shownKinds:`-`,hiddenKinds:`-`,source:`unavailable`}}var le=5;function ue(e,t){if(!t)return[];let n=[];for(let r of t.nodes)for(let t of[`v`,`h`])(t===`v`?r.clippedV:r.clippedH)&&n.push({op:`node-clipped`,view:e,meetingId:r.meetingId,axis:t,renderedPx:r.renderedPx,neededPx:r.neededPx,durationMin:r.durationMin??`-`});if(n.length<=le)return n;let r=n.slice(0,le);return r[r.length-1]={...r[r.length-1],truncated:n.length-le},r}function de(e){let t=(e.textContent??``).length;if(t===0||e.scrollWidth===0||e.clientWidth>=e.scrollWidth-1)return!0;let n=e.scrollWidth/t;return e.clientWidth/n>=se}function fe(e){if(!e||typeof window>`u`||typeof window.getComputedStyle!=`function`)return null;let t=Array.from(e.querySelectorAll(`[data-meeting-id]`)),n=t.map(e=>e.getBoundingClientRect());if(t.length>0&&n.every(e=>e.height===0&&e.width===0))return null;let r=t.length>0?parseFloat(window.getComputedStyle(t[0]).lineHeight):null,i=t.map((e,t)=>{let r=e.querySelector(`.cal-sched-title`),i=e.querySelector(`.cal-event-title`)??r??e,a=i.scrollWidth>i.clientWidth+1,o=e.getAttribute(`data-duration-min`);return{meetingId:e.getAttribute(`data-meeting-id`)??`unknown`,clippedV:e.scrollHeight>e.clientHeight+1,clippedH:r?a:a&&!de(i),durationMin:o?Number(o):null,renderedPx:Math.round(n[t].height*10)/10,neededPx:Math.round(e.scrollHeight*10)/10}}),a=[];e.querySelector(`.cal-event-title, .cal-chip, .cal-sched-title`)&&a.push(`title`),e.querySelector(`.cal-event-time, .cal-sched-time`)&&a.push(`time`),e.querySelector(`.cal-sched-meta`)&&a.push(`meta`);let o=0;for(let t of Array.from(e.querySelectorAll(`.cal-more`)))o+=Number(t.getAttribute(`data-hidden-count`)??0);return{nodes:i,hidden:o,fields:a,minBlockPx:i.length>0?Math.min(...i.map(e=>e.renderedPx)):null,lineBoxPx:Number.isFinite(r)?r:null}}function pe(e,t){for(let n of[ce(e,t),...ue(e,t)])try{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`calendar-legibility`,...n}),keepalive:!0}).catch(()=>{})}catch{}}var $=`maxy-admin-session-key`,me=`maxy-calendar-show-all-kinds`;function he(){let[e,t]=(0,E.useState)(null),[n,r]=(0,E.useState)(!1),[i,a]=(0,E.useState)(void 0),[o,s]=(0,E.useState)(null),[l,d]=(0,E.useState)(void 0),[f,p]=(0,E.useState)(null),[g,_]=(0,E.useState)(null);(0,E.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&s(e.sessionId??null),_(e.role??null),d(e.userName===void 0?null:e.userName),p(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,E.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,E.useState)(!1),x=(0,E.useCallback)(async()=>{b(!0);try{let e=await m();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,L.jsx)(c,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,L.jsx)(h,{cacheKey:e,businessName:i,sessionId:o,onLogout:v,onDisconnect:x,disconnecting:y,userName:l,userAvatar:f,role:g,children:(0,L.jsx)(ge,{cacheKey:e})})}):(0,L.jsx)(`div`,{className:`cal-page`,children:(0,L.jsxs)(`div`,{className:`cal-empty`,children:[(0,L.jsx)(`p`,{children:`You are not signed in.`}),(0,L.jsxs)(`p`,{children:[`Open the `,(0,L.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,L.jsx)(u,{surface:`gate`})}function ge({cacheKey:e}){let{adminFetch:n,sessionRefetchNonce:i}=t({initialCacheKey:e,surface:`calendar`}),[a,o]=(0,E.useState)(N),[s,c]=(0,E.useState)(()=>new Date),[l,d]=(0,E.useState)([]),[p,m]=(0,E.useState)(!1),[h,y]=(0,E.useState)(!1),[b,x]=(0,E.useState)(null),[S,C]=(0,E.useState)(null),[w,T]=(0,E.useState)([]),[D,O]=(0,E.useState)(`none`),[k,M]=(0,E.useState)(()=>{try{return sessionStorage.getItem(me)===`1`}catch{return!1}}),[P,F]=(0,E.useState)(null),[I,R]=(0,E.useState)(0),[z,B]=(0,E.useState)(null);(0,E.useEffect)(()=>{let e=!1;return n(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&B(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[n]),(0,E.useEffect)(()=>{let e=!1,{from:t,to:r}=A(a,s);return m(!0),x(null),n(`/api/admin/calendar/meetings?from=${encodeURIComponent(t.toISOString())}&to=${encodeURIComponent(r.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();d(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(x(t instanceof Error?t.message:`Failed to load`),d([]))}).finally(()=>{e||(m(!1),y(!0))}),()=>{e=!0}},[a,s,i,n]),(0,E.useEffect)(()=>{let e=!1,{from:t,to:r}=A(a,s);return n(`/api/admin/calendar/free-busy?from=${encodeURIComponent(t.toISOString())}&to=${encodeURIComponent(r.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();T(K(Array.isArray(n.slots)?n.slots:[])),O(n.gapSource===`config`?`config`:`none`)}).catch(()=>{e||(T([]),O(`none`))}),()=>{e=!0}},[a,s,i,n,I]);let V=(0,E.useCallback)(()=>c(new Date),[]),ne=(0,E.useCallback)(()=>c(e=>j(a,e,-1)),[a]),U=(0,E.useCallback)(()=>c(e=>j(a,e,1)),[a]),W=(0,E.useCallback)(()=>{M(e=>{let t=!e;try{sessionStorage.setItem(me,t?`1`:`0`)}catch{}return t})},[]),G=(0,E.useCallback)((e,t)=>F({startsAt:H(e),endsAt:H(t)}),[]),q=(0,E.useCallback)(e=>{d(t=>[...t,e]),R(e=>e+1),F(null)},[]);(0,E.useEffect)(()=>{C(null)},[a,s]);let J=(0,E.useRef)(null);(0,E.useEffect)(()=>{if(p)return;let e=requestAnimationFrame(()=>{let e=fe(J.current);pe(a,e&&{...e,gapSource:D,gaps:w.length,shownKinds:k?`meeting,event,task`:`meeting`,hiddenKinds:k?0:l.filter(e=>(e.kind??`meeting`)!==`meeting`).length})});return()=>cancelAnimationFrame(e)},[a,l,p,D,w,k]);let Y=(0,E.useCallback)(e=>{d(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),C(e)},[]),X=(0,E.useCallback)(e=>{d(t=>t.filter(t=>t.meetingId!==e)),C(null)},[]);return h?(0,L.jsxs)(`div`,{className:`cal-page`,children:[(0,L.jsxs)(`header`,{className:`cal-header`,children:[(0,L.jsxs)(`div`,{className:`cal-nav`,children:[(0,L.jsx)(`span`,{className:`cal-range-label`,children:te(a,s)}),(0,L.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:ne,"aria-label":`Previous`,children:(0,L.jsx)(_,{size:18})}),(0,L.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:U,"aria-label":`Next`,children:(0,L.jsx)(v,{size:18})}),(0,L.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:V,children:`Today`}),p&&(0,L.jsx)(r,{size:16,className:`spin`})]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-add-btn`,onClick:()=>F({startsAt:``,endsAt:``}),children:[(0,L.jsx)(f,{size:14}),` Add`]}),(0,L.jsx)(`div`,{className:`cal-views`,children:ee.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===a?` cal-view-btn-active`:``}`,onClick:()=>o(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),z&&(0,L.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${z}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,L.jsx)(g,{size:14}),` Booking page`]})]}),(0,L.jsxs)(`div`,{className:`cal-body`,ref:J,children:[b&&(0,L.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,b]}),(0,L.jsx)(re,{from:A(a,s).from,to:A(a,s).to,meetings:l,stretches:w,gapSource:D,showAllKinds:k,onToggleKinds:W,onSelect:C,onAddAt:G})]}),P&&(0,L.jsx)(Z,{initialStart:P.startsAt,initialEnd:P.endsAt,adminFetch:n,onClose:()=>F(null),onCreated:q}),S&&(0,L.jsx)(oe,{meeting:S,adminFetch:n,onClose:()=>C(null),onSaved:Y,onDeleted:X})]}):(0,L.jsx)(u,{surface:`gate`})}(0,T.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(he,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{U as e,q as t}from"./useSubAccountSwitcher-ny9tP8am.js";import"./useVoiceRecorder-DcgtZl-4.js";import"./AdminShell-BT7VQIu7.js";import{n}from"./page-RkwjxAgF.js";import"./useCopyFeedback-DqTnYnz5.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as e}from"./useSubAccountSwitcher-ny9tP8am.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as e}from"./useSubAccountSwitcher-ny9tP8am.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as e}from"./useSubAccountSwitcher-ny9tP8am.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{U as e,q as t}from"./useSubAccountSwitcher-ny9tP8am.js";import"./useVoiceRecorder-DcgtZl-4.js";import{t as n}from"./page-ZG7SXMO0.js";import"./graph-labels-Ci5Jz1oY.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{U as t,Y as n,q as r}from"./useSubAccountSwitcher-ny9tP8am.js";import{n as i,t as a}from"./AdminLoginScreens-BpHVvUsH.js";import"./useVoiceRecorder-DcgtZl-4.js";import"./AdminShell-BT7VQIu7.js";import{t as o}from"./page-RkwjxAgF.js";import"./useCopyFeedback-DqTnYnz5.js";var s=r(),c=e(n(),1),l=t();function u(){let e=i(`operator`),t=(0,c.useRef)(null);return(0,c.useEffect)(()=>{e.appState!==`chat`&&t.current!==e.appState&&(t.current=e.appState)},[e.appState]),e.appState===`chat`?(0,l.jsx)(o,{variant:`operator`,forceCanonicalSession:window.location.pathname!==`/chat`}):(0,l.jsx)(a,{auth:e})}(0,s.createRoot)(document.getElementById(`root`)).render((0,l.jsx)(u,{}));
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{C as t,I as n,K as r,M as i,O as a,R as o,S as s,T as c,U as l,Y as u,_ as d,a as f,b as p,c as m,f as h,g,i as _,j as v,p as ee,s as y,t as b,w as te,x as ne,y as x}from"./useSubAccountSwitcher-ny9tP8am.js";import{D as S,O as C,T as re,f as w,n as ie,r as T,s as E,w as D}from"./useVoiceRecorder-DcgtZl-4.js";import{t as O}from"./chevron-left-DU8Es8Xq.js";import{t as k}from"./file-text-lsHlk4lR.js";import{i as ae,t as A}from"./graph-labels-Ci5Jz1oY.js";import{t as oe}from"./triangle-alert-BcpCZDHe.js";import{i as se,n as ce,t as le}from"./file-download-DbNIjWiK.js";var ue=o(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),de=o(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),j=o(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),fe=o(`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`}]]),pe=o(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),me=o(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),he=o(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),ge=o(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),_e=o(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),M=e(u(),1);function ve(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),o=(0,M.useRef)(null),s=(0,M.useCallback)(e=>{a(null);let n=e.find(e=>!T(e.type,C));if(n){a(`Unsupported file type: "${n.type}". Supported: images, PDF, plain text, markdown, CSV, calendar, zip, voice notes.`);return}let r=e.find(e=>e.size>S);if(r){a(`"${r.name}" exceeds the 50 MB limit.`);return}t(t=>[...t,...e].slice(0,5))},[]);return{pendingFiles:e,setPendingFiles:t,isDragOver:n,attachError:i,setAttachError:a,fileInputRef:o,addFiles:s,clearFiles:(0,M.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,M.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,M.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,M.useCallback)(()=>{r(!1)},[]),onDrop:(0,M.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var N=[[128512],[128515],[128516],[128513],[128518],[128517],[128514],[129315],[128578],[128579],[128521],[128522],[128519],[128525],[128536],[128535],[128540],[128541],[129303],[129300],[128528],[128566],[128564],[128526],[129395],[128546],[128557],[128548],[128544],[128533],[128556],[129393],[128077],[128078],[128076],[128591],[128079],[128588],[128170],[128075],[129309],[10084,65039],[128293],[11088],[127881],[10024],[128175],[128064]].map(e=>String.fromCodePoint(...e));function ye(e,t,n,r){let i=e.length,a=Math.max(0,Math.min(n??i,i)),o=Math.max(a,Math.min(r??a,i));return{value:e.slice(0,a)+t+e.slice(o),caret:a+t.length}}var P=l();function F({onSelect:e}){return(0,P.jsx)(`div`,{className:`wa-emoji-popover`,role:`menu`,"aria-label":`Emoji picker`,children:N.map((t,n)=>(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`wa-emoji-item`,onClick:()=>e(t),children:t},n))})}function be({sessionKey:e,onPick:t,onClose:n}){let[r,i]=(0,M.useState)(``),[a,o]=(0,M.useState)(null),[s,c]=(0,M.useState)(null),[l,u]=(0,M.useState)(!1),d=(0,M.useCallback)(t=>{u(!0),c(null),fetch(`/api/admin/files?path=${encodeURIComponent(t)}&session_key=${encodeURIComponent(e)}`).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`Could not list files`);return t}).then(e=>{o(e),i(e.path===`.`?``:e.path)}).catch(e=>c(e instanceof Error?e.message:String(e))).finally(()=>u(!1))},[e]);(0,M.useEffect)(()=>{d(``)},[d]);let f=e=>d(r?`${r}/${e}`:e),p=()=>{let e=r.split(`/`).filter(Boolean);e.pop(),d(e.join(`/`))},m=e=>{let n=e.entryPath??e.name;t({path:r?`${r}/${n}`:n,name:e.displayName??e.name})};return(0,P.jsx)(`div`,{className:`wa-picker-backdrop`,role:`dialog`,"aria-label":`Choose a device file`,onClick:n,children:(0,P.jsxs)(`div`,{className:`wa-picker`,onClick:e=>e.stopPropagation(),children:[(0,P.jsxs)(`div`,{className:`wa-picker-head`,children:[r&&(0,P.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:p,"aria-label":`Up one folder`,children:(0,P.jsx)(O,{size:18})}),(0,P.jsx)(`span`,{className:`wa-picker-title`,children:r||`Device storage`}),(0,P.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:n,"aria-label":`Close file picker`,children:(0,P.jsx)(x,{size:18})})]}),s&&(0,P.jsx)(`p`,{className:`wa-picker-error`,role:`alert`,children:s}),l&&(0,P.jsx)(`p`,{className:`wa-picker-empty`,children:`Loading…`}),a&&!l&&(0,P.jsxs)(`ul`,{className:`wa-picker-list`,children:[a.entries.length===0&&(0,P.jsx)(`li`,{className:`wa-picker-empty`,children:`This folder is empty.`}),a.entries.map(e=>(0,P.jsx)(`li`,{children:e.kind===`directory`?(0,P.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>f(e.name),children:[(0,P.jsx)(v,{size:16,"aria-hidden":!0}),(0,P.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):e.kind===`file`?(0,P.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>m(e),children:[(0,P.jsx)(k,{size:16,"aria-hidden":!0}),(0,P.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):null},e.name))]})]})})}function xe(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function Se({accountId:e,remoteJid:t,sessionKey:n,replyTo:r,onClearReply:i}){let[a,o]=(0,M.useState)(``),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(!1),[m,h]=(0,M.useState)(!1),[g,_]=(0,M.useState)(!1),[v,ee]=(0,M.useState)([]),y=(0,M.useRef)(null),{pendingFiles:b,attachError:S,addFiles:C,removeFile:w,clearFiles:T}=ve(),{state:E,elapsedSeconds:O,errorMessage:ae,start:A,send:oe,discard:se}=ie(),ce=E===`recording`||E===`paused`,le=(0,M.useCallback)(()=>{A()},[A]),ue=(0,M.useCallback)(async()=>{let e=await oe();if(e){let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`;C([new File([e],`voice-note${t}`,{type:e.type})])}},[O,oe,C]),de=(0,M.useCallback)(()=>{se()},[O,se]),fe=(0,M.useRef)(!1),pe=()=>Math.round((typeof window>`u`?900:window.innerHeight)/3),[me,_e]=(0,M.useState)(null),[N,Se]=(0,M.useState)(null),I=(0,M.useRef)(null),Ce=(0,M.useCallback)(e=>{let t=I.current;t&&_e(Math.min(pe(),Math.max(44,t.startH+(t.startY-e.clientY))))},[]),we=(0,M.useCallback)(()=>{I.current=null,window.removeEventListener(`pointermove`,Ce),window.removeEventListener(`pointerup`,we)},[Ce]),Te=(0,M.useCallback)(e=>{I.current={startY:e.clientY,startH:y.current?.offsetHeight??44},window.addEventListener(`pointermove`,Ce),window.addEventListener(`pointerup`,we),e.preventDefault()},[Ce,we]),Ee=(0,M.useCallback)(e=>{let t=me??y.current?.offsetHeight??44,n=null;e.key===`ArrowUp`?(e.preventDefault(),n=Math.min(pe(),t+24)):e.key===`ArrowDown`&&(e.preventDefault(),n=Math.max(44,t-24)),n!==null&&_e(n)},[me]),De=(0,M.useRef)(``);(0,M.useEffect)(()=>{let e=y.current;if(!e)return;let t=De.current!==``&&a===``;if(De.current=a,me!==null){t&&_e(null);return}let n=e.style.height;e.style.height=`auto`;let r=Math.min(pe(),Math.max(44,e.scrollHeight));e.style.height=n,Se(r)},[a,me]);let L=(a.trim().length>0||b.length>0||v.length>0)&&!s,Oe=(0,M.useCallback)(async()=>{if(!fe.current&&!(a.trim().length===0&&b.length===0&&v.length===0)){fe.current=!0,c(!0),u(null);try{let s=`/api/whatsapp-reader/reply?session_key=${encodeURIComponent(n)}`,c;if(b.length>0||v.length>0){let n=new FormData;n.append(`accountId`,e),n.append(`remoteJid`,t),a.trim()&&n.append(`text`,a);for(let e of b)n.append(`files`,e);for(let e of v)n.append(`fileRefs`,e.path);r&&n.append(`quotedId`,r.msgKeyId),c=await fetch(s,{method:`POST`,body:n})}else c=await fetch(s,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accountId:e,remoteJid:t,text:a,...r?{quotedId:r.msgKeyId}:{}})});let l=await c.json().catch(()=>({}));if(!c.ok){u(l.error??`Send failed.`),console.warn(`[operator-ui] op=reply-fail remoteJid=${t} error=${l.error??`unknown`}`);return}o(``),T(),ee([]),i?.()}catch(e){u(`Could not reach the server. Try again.`),console.warn(`[operator-ui] op=reply-fail remoteJid=${t} error=${String(e)}`)}finally{fe.current=!1,c(!1)}}},[a,b,v,r,i,e,t,n,T]),ke=(0,M.useCallback)(e=>{let t=y.current,{value:n,caret:r}=ye(a,e,t?t.selectionStart:null,t?t.selectionEnd:null);o(n),f(!1),requestAnimationFrame(()=>{let e=y.current;e&&(e.focus(),e.setSelectionRange(r,r))})},[a]),Ae=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),L&&Oe())},je=e=>e.dataTransfer.types.includes(`Files`),R=(0,M.useCallback)(e=>{je(e)&&(e.preventDefault(),_(!0))},[]),z=(0,M.useCallback)(()=>_(!1),[]),Me=(0,M.useCallback)(e=>{if(!je(e))return;e.preventDefault(),_(!1);let t=[...e.dataTransfer.files];t.length!==0&&(Math.max(0,b.length+t.length-5),C(t))},[b.length,C]),Ne=e=>e.startsWith(`image/`)?(0,P.jsx)(j,{size:14}):e===`application/pdf`?(0,P.jsx)(k,{size:14}):(0,P.jsx)(re,{size:14});return(0,P.jsxs)(`div`,{className:`wa-reply${g?` wa-reply-drag-over`:``}`,onDragOver:R,onDragLeave:z,onDrop:Me,children:[m&&(0,P.jsx)(be,{sessionKey:n,onPick:e=>{ee(t=>[...t,e].slice(0,5)),h(!1)},onClose:()=>h(!1)}),d&&(0,P.jsx)(F,{onSelect:ke}),l&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:l}),S&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:S}),E===`error`&&ae&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:ae}),(b.length>0||v.length>0)&&(0,P.jsxs)(`div`,{className:`wa-reply-attachments`,children:[b.map((e,t)=>(0,P.jsxs)(`div`,{className:`wa-reply-chip`,children:[Ne(e.type),(0,P.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>w(t),"aria-label":`Remove ${e.name}`,children:(0,P.jsx)(x,{size:12})})]},`f-${t}`)),v.map((e,t)=>(0,P.jsxs)(`div`,{className:`wa-reply-chip wa-reply-chip-ref`,children:[(0,P.jsx)(k,{size:14}),(0,P.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ee(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove ${e.name}`,children:(0,P.jsx)(x,{size:12})})]},`r-${t}`))]}),r&&(0,P.jsxs)(`div`,{className:`wa-reply-quote`,children:[(0,P.jsxs)(`div`,{className:`wa-reply-quote-body`,children:[(0,P.jsx)(`span`,{className:`wa-reply-quote-who`,children:r.fromMe?`You`:r.senderName??`Contact`}),(0,P.jsx)(`span`,{className:`wa-reply-quote-text`,children:r.body||`Message`})]}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-quote-cancel`,onClick:()=>i?.(),"aria-label":`Cancel reply`,children:(0,P.jsx)(x,{size:14})})]}),!ce&&(0,P.jsx)(`div`,{className:`wa-reply-resize-handle`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize input — drag up to enlarge`,tabIndex:0,onPointerDown:Te,onKeyDown:Ee}),(0,P.jsx)(`div`,{className:`wa-reply-row`,children:ce?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:de,"aria-label":`Cancel recording`,children:(0,P.jsx)(p,{size:20})}),(0,P.jsxs)(`span`,{className:`wa-rec-live`,role:`status`,children:[(0,P.jsx)(`span`,{className:`wa-rec-dot`,"aria-hidden":!0}),xe(O)]}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void ue(),"aria-label":`Stop recording`,children:(0,P.jsx)(ne,{size:20})})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-emoji`,onClick:()=>f(e=>!e),disabled:s,"aria-label":`Emoji`,"aria-expanded":d,children:(0,P.jsx)(ge,{size:22})}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:()=>h(!0),disabled:s,"aria-label":`Attach files`,children:(0,P.jsx)(te,{size:22})}),(0,P.jsx)(`textarea`,{ref:y,className:`wa-reply-input`,value:a,rows:1,style:{height:`${me??N??44}px`},placeholder:`Type a message`,disabled:s,onChange:e=>o(e.target.value),onKeyDown:Ae}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-mic`,onClick:()=>void le(),disabled:s,"aria-label":`Record voice note`,children:(0,P.jsx)(D,{size:22})}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void Oe(),disabled:!L,"aria-label":`Send`,children:(0,P.jsx)(he,{size:20})})]})})]})}function I({accountId:e,remoteJid:t,contactName:n,sessionKey:r,onBack:i}){let a=m(t),o=t.split(`@`)[0],s=a?`Group`:n===`+${o}`?void 0:`+${o}`,[c,l]=(0,M.useState)(!1),[u,d]=(0,M.useState)(``),f=()=>{l(!1),d(``)},[p,h]=(0,M.useState)(null);return(0,P.jsxs)(`div`,{className:`wa-web`,children:[(0,P.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,P.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,P.jsx)(O,{size:20})}),(0,P.jsx)(w,{accountId:e,jid:t,sessionKey:r}),c?(0,P.jsxs)(`div`,{className:`wa-web-search`,children:[(0,P.jsx)(ae,{size:18,"aria-hidden":!0}),(0,P.jsx)(`input`,{className:`wa-web-search-input`,type:`text`,autoFocus:!0,placeholder:`Search messages`,"aria-label":`Search messages`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&f()}}),(0,P.jsx)(`button`,{type:`button`,className:`wa-web-search-close`,onClick:f,"aria-label":`Close search`,children:(0,P.jsx)(x,{size:18})})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`wa-web-titles`,children:[(0,P.jsx)(`span`,{className:`wa-web-name`,children:n}),s&&(0,P.jsx)(`span`,{className:`wa-web-subtitle`,children:s})]}),(0,P.jsx)(`button`,{type:`button`,className:`wa-web-search-toggle`,onClick:()=>l(!0),"aria-label":`Search messages`,children:(0,P.jsx)(ae,{size:20})})]})]}),(0,P.jsx)(`div`,{className:`wa-web-body`,children:(0,P.jsx)(E,{sessionId:``,projectDir:``,sessionKey:r,forceDeliveredOnly:!0,suppressDirectives:!0,store:{accountId:e,remoteJid:t},search:c?u:void 0,onReplyTo:h,groupThread:a})}),(0,P.jsx)(Se,{accountId:e,remoteJid:t,sessionKey:r,replyTo:p,onClearReply:()=>h(null)})]})}function Ce(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||A.has(e)&&(t.add(e),n.push(e)));return n}function we(e){if(!e)return``;let t=new Date(e).getTime();return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Te({conversations:e,sessionKey:t,onBack:n}){let[r,i]=(0,M.useState)(null),a=_(e);return r?r.source===`store`&&r.accountId&&r.remoteJid?(0,P.jsx)(I,{accountId:r.accountId,remoteJid:r.remoteJid,contactName:f(r),sessionKey:t,onBack:()=>i(null)},y(r)):(0,P.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,P.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>i(null),"aria-label":`Back to conversations`,children:[(0,P.jsx)(O,{size:16}),` Back`]}),(0,P.jsx)(`span`,{className:`op-conv-title`,children:f(r)})]}),(0,P.jsx)(E,{sessionId:r.sessionId,projectDir:r.projectDir,sessionKey:t,forceDeliveredOnly:!0,suppressDirectives:r.source===`store`,store:r.source===`store`?{accountId:r.accountId,remoteJid:r.remoteJid}:void 0},y(r))]}):(0,P.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,P.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,P.jsx)(O,{size:16}),` Chat`]}),(0,P.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),a.map(e=>(0,P.jsxs)(`div`,{className:`op-conv-group`,children:[(0,P.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,P.jsx)(h,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{i(e)},children:[e.source===`store`&&e.accountId&&e.remoteJid&&(0,P.jsx)(w,{accountId:e.accountId,jid:e.remoteJid,sessionKey:t,className:`op-conv-avatar`,size:16}),(0,P.jsx)(`span`,{className:`op-conv-name`,children:f(e)}),e.modelGated&&(0,P.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,P.jsx)(oe,{size:13})}),(0,P.jsx)(`span`,{className:`op-conv-when`,children:we(e.lastMessageAt)})]},y(e)))]},e.channel))]})}var Ee=/\.(png|jpe?g|gif|webp|svg)$/i;function De(e){return Ee.test(e)}function L(e){return e.entryPath??e.name}var Oe=`maxy-data-view`,ke=95*1024*1024,Ae=48*1024*1024;function je(){return typeof window>`u`?`list`:window.localStorage.getItem(Oe)===`grid`?`grid`:`list`}function R(){let[e,t]=(0,M.useState)(null),[n,r]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,P.jsx)(d,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,P.jsx)(`div`,{className:`data-page data-page-full`,children:(0,P.jsx)(z,{cacheKey:e})})}):(0,P.jsx)(`div`,{className:`data-page`,children:(0,P.jsxs)(`div`,{className:`data-empty`,children:[(0,P.jsx)(`p`,{children:`You are not signed in.`}),(0,P.jsxs)(`p`,{children:[`Open the `,(0,P.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,P.jsx)(g,{surface:`gate`})}function z({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:i}=r({initialCacheKey:e,surface:`data`});return(0,P.jsx)(Le,{adminFetch:t,cacheKey:n,sessionRefetchNonce:i})}function Me(){if(typeof window>`u`)return`@home`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`@home`}function Ne(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`||e===`@home`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function B(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function V(e){return new Promise((t,n)=>e.file(t,n))}async function Pe(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await V(r),relpath:e});else if(r.isDirectory){let t=await B(r.createReader());n.push(...await Pe(t,e))}}return n}function Fe(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function Ie({adminFetch:e,cacheKey:r,sessionRefetchNonce:o}){let[l,u]=(0,M.useState)(``),d=(0,M.useRef)(null),[f,m]=(0,M.useState)(``),[h,_]=(0,M.useState)(null),[ee,y]=(0,M.useState)(`hybrid`),[b,te]=(0,M.useState)(!1),[ne,S]=(0,M.useState)(null),[C,re]=(0,M.useState)(null),[w,ie]=(0,M.useState)(0),[T,E]=(0,M.useState)(!1),[D,O]=(0,M.useState)(()=>Me()),[A,oe]=(0,M.useState)(null),[j,he]=(0,M.useState)(()=>je()),[ge,ve]=(0,M.useState)(null),[N,ye]=(0,M.useState)([]),[F,be]=(0,M.useState)(null),[xe,Se]=(0,M.useState)(0),[I,we]=(0,M.useState)(null),Te=(0,M.useRef)(null),Ee=N.slice(0,-1).map(e=>e.name).join(`/`),R=(()=>{let e=N.map(e=>e.name);return e.length>=2&&e[0]===`accounts`?`${e[0]}/${e[1]}`:null})(),z=F?Ee:D,B=(0,M.useCallback)(e=>z===`.`||z===``?e:`${z}/${e}`,[z]),[V,Ie]=(0,M.useState)(!1),[Le,Re]=(0,M.useState)(!1),[Ve,He]=(0,M.useState)(null),[Ue,Ke]=(0,M.useState)(!1),[H,U]=(0,M.useState)(null),[qe,Je]=(0,M.useState)(null),[Ye,Xe]=(0,M.useState)(null),[Ze,Qe]=(0,M.useState)(!1),[$e,et]=(0,M.useState)(null),tt=(0,M.useRef)(null),[nt,W]=(0,M.useState)(0),[rt,it]=(0,M.useState)(!1),[at,ot]=(0,M.useState)(``),[st,ct]=(0,M.useState)(null),[lt,ut]=(0,M.useState)(``),[dt,ft]=(0,M.useState)(null),G=(()=>{let e=D===`.`?[]:D.split(`/`).filter(Boolean);return e.some(e=>e.startsWith(`@`))?!1:e.length>=2&&e[0]===`accounts`})(),[pt,mt]=(0,M.useState)(!1),ht=(0,M.useRef)(null),[gt,K]=(0,M.useState)(!1),_t=(0,M.useRef)(null);(0,M.useEffect)(()=>{let e=l.trim();if(!e){m(``),_(null),S(null);return}E(!1);let t=setTimeout(()=>m(e),300);return()=>clearTimeout(t)},[l]),(0,M.useEffect)(()=>{if(!f){te(!1);return}let t=!1;return te(!0),S(null),e(`/api/admin/graph-search?q=${encodeURIComponent(f)}&labels=FileArtifact&limit=20${T?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(_(e.results),y(e.mode??`hybrid`),ie(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||S(e instanceof Error?e.message:String(e))}).finally(()=>{t||te(!1)}),()=>{t=!0}},[f,e,o,T]);let vt=(0,M.useMemo)(()=>h?Ce(h):[],[h]),q=C&&vt.includes(C)?C:null,yt=(0,M.useMemo)(()=>h?q?h.filter(e=>e.labels.includes(q)):h:null,[h,q]),bt=(0,M.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=document.createElement(`a`);i.href=n,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[r]);(0,M.useEffect)(()=>{if(!h)return;let e=h.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[h]),(0,M.useEffect)(()=>{let t=!1;return Ie(!0),He(null),e(`/api/admin/files?path=${encodeURIComponent(D===`.`?``:D)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(oe(e.entries),ye(e.displayPath??[]),be(e.view??null),Se(typeof e.systemCount==`number`?e.systemCount:0))}).catch(e=>{t||(oe([]),ye([]),be(null),Se(0),He(e instanceof Error?e.message:String(e)))}).finally(()=>{t||(Ie(!1),Re(!0))}),()=>{t=!0}},[e,D,nt,o]),(0,M.useEffect)(()=>{if(F!==null||!R||Te.current===R)return;Te.current=R;let t=!1;return e(`/api/admin/files?path=${encodeURIComponent(`${R}/@home`)}`).then(e=>e.ok?e.json():null).then(e=>{t||!e||we((e.entries??[]).map(e=>e.name))}).catch(e=>{console.warn(`[data-ui] op=rail-buckets status=error reason="${e instanceof Error?e.message:String(e)}"`)}),()=>{t=!0}},[e,F,R]),(0,M.useEffect)(()=>{Ne(D)},[D]);let xt=(0,M.useCallback)(()=>{W(e=>e+1)},[]),J=(0,M.useCallback)(e=>{mt(!1),O(e)},[]),St=(0,M.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);u(``),S(null),re(null),J(r)},[J]),Ct=(0,M.useCallback)(()=>{if(!D.split(`/`).some(e=>e.startsWith(`@`))){if(D===`.`||D===``)return;let e=D.split(`/`).filter(Boolean);e.pop(),O(e.length===0?`.`:e.join(`/`));return}N.length!==0&&O(N.length>=2?N.slice(0,N.length-1).map(e=>e.name).join(`/`):`.`)},[D,N]),wt=(0,M.useCallback)(e=>{ce(r,B(L(e)))},[B,r]),[Y,Tt]=(0,M.useState)(!1),[X,Et]=(0,M.useState)(new Set),Dt=(0,M.useRef)(null),Z=(0,M.useRef)(!1),Ot=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,kt=(0,M.useCallback)(e=>{Tt(!0),Et(new Set([e]))},[]),Q=(0,M.useCallback)(e=>{Tt(!1),Et(new Set)},[]),At=(0,M.useCallback)(e=>{Et(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),jt=(0,M.useCallback)(e=>{Z.current=!1,Dt.current=setTimeout(()=>{Z.current=!0,kt(e)},500)},[kt]),$=(0,M.useCallback)(()=>{Dt.current&&=(clearTimeout(Dt.current),null)},[]),Mt=(0,M.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){At(e.name);return}wt(e)},[Y,At,wt]),Nt=(0,M.useCallback)(e=>{he(e),typeof window<`u`&&window.localStorage.setItem(Oe,e)},[]),Pt=(0,M.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){At(e.name);return}ve({src:le(r,B(L(e))),alt:e.displayName??e.name})},[Y,At,B,r]),Ft=(0,M.useCallback)(()=>(A??[]).filter(e=>e.kind===`file`&&X.has(e.name)),[A,X]),It=(0,M.useCallback)(()=>{if(X.size!==1)return null;let e=(A??[]).find(e=>X.has(e.name));return e&&!e.entryPath?e:null},[A,X]),Lt=(0,M.useCallback)(()=>(A??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&X.has(e.name)),[A,X]),Rt=(0,M.useCallback)(()=>{let e=Lt(),t=e.some(e=>e.kind===`directory`);e.length===1&&!t?wt(e[0]):e.length>=1&&se(r,e.map(e=>B(L(e)))),Q(`action`)},[Lt,wt,B,r,Q]),zt=(0,M.useCallback)(async()=>{let t=Ft(),n=t.filter(e=>!e.protected),r=t.length-n.length;et(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=B(L(t));try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`)}catch(e){et(e instanceof Error?e.message:String(e))}}W(e=>e+1),Q(`action`)},[Ft,B,e,Q]),Bt=(0,M.useCallback)(async()=>{let e=Ft();if(Ot)try{let t=await Promise.all(e.map(async e=>{let t=B(L(e)),n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=await(await fetch(n)).blob();return new File([i],e.displayName??e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:t})&&await navigator.share({files:t})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[Ft,Ot,B,r]),Vt=(0,M.useCallback)(()=>{tt.current?.click()},[]),Ht=(0,M.useCallback)((e,t={})=>{let n=(n,i,a)=>{let o=new URLSearchParams({session_key:r,path:D===`.`?``:D,filename:e.name});t.relpath&&o.set(`relpath`,t.relpath),t.token&&o.set(`token`,t.token);for(let[e,t]of Object.entries(i))o.set(e,t);return new Promise(t=>{let r=new XMLHttpRequest;r.open(`POST`,`/api/admin/files/upload?${o.toString()}`),r.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(r.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),r.onload=()=>{let e={};try{e=JSON.parse(r.responseText)}catch{}t({status:r.status,data:e})},r.onerror=()=>t({status:0,data:{}}),r.onabort=()=>t({status:0,data:{error:`aborted`}}),r.send(n)})};if(e.size<=ke)return n(e,{},n=>t.onProgress?.(n,e.size));let i=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/Ae);return(async()=>{let r={status:0,data:{}};for(let o=0;o<a;o++){let s=o*Ae;if(r=await n(e.slice(s,Math.min(s+Ae,e.size)),{uploadId:i,seq:String(o),total:String(a)},n=>t.onProgress?.(s+n,e.size)),!(r.status>=200&&r.status<300))return r}return r})()},[r,D]),Ut=(0,M.useCallback)(async e=>{Je(null),Ke(!0),U({loaded:0,total:e.size});try{let{status:t,data:n}=await Ht(e,{onProgress:(e,t)=>U({loaded:e,total:t})});t>=200&&t<300&&n.path?(O(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),W(e=>e+1)):Je(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{Ke(!1),U(null),tt.current&&(tt.current.value=``)}},[Ht]),Wt=(0,M.useCallback)(e=>{G&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Qe(!0))},[G]),Gt=(0,M.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Qe(!1)},[]),Kt=(0,M.useCallback)(async e=>{e.preventDefault(),Qe(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(n.length===0)return;if(!G){Je(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);Ke(!0),Je(null),Xe(null);try{let e=await Pe(r),n=0,i=[];for(let r=0;r<e.length;r++){let{file:a,relpath:o}=e[r];U({loaded:0,total:a.size});let{status:s,data:c}=await Ht(a,{relpath:o,token:t,onProgress:(e,t)=>U({loaded:e,total:t})});if(s>=200&&s<300)n++;else{let e=s===0?`http=0`:Fe(s,c.error);i.push(`${o} (${e})`)}}Xe(`Uploaded ${n}, skipped ${i.length}${i.length?`: ${i.join(`, `)}`:``}`),W(e=>e+1)}catch(e){Je(e instanceof Error?e.message:String(e))}finally{Ke(!1),U(null)}},[G,Ht]),qt=(0,M.useCallback)(async()=>{let t=at.trim();if(t){ft(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:D===`.`?``:D,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);it(!1),ot(``),W(e=>e+1)}catch(e){ft(e instanceof Error?e.message:String(e))}}},[e,at,D]),Jt=(0,M.useCallback)(async()=>{if(!st)return;let t=lt.trim();if(!t)return;ft(null);let n=B(st);try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);ct(null),ut(``),Q(`action`),W(e=>e+1)}catch(e){ft(e instanceof Error?e.message:String(e))}},[e,lt,st,B,Q]);(0,M.useEffect)(()=>{if(!pt)return;let e=e=>{ht.current&&!ht.current.contains(e.target)&&mt(!1)},t=e=>{e.key===`Escape`&&mt(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[pt]),(0,M.useEffect)(()=>{if(!gt)return;let e=e=>{_t.current&&!_t.current.contains(e.target)&&K(!1)},t=e=>{e.key===`Escape`&&K(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[gt]);let Yt=(0,M.useCallback)(e=>N.slice(0,e+1).map(e=>e.name).join(`/`),[N]),Xt=N.length>=2,Zt=Xt?[{name:`.`,label:`data`},...N.slice(0,N.length-2).map((e,t)=>({name:Yt(t),label:e.displayName??e.name}))]:[];return Le?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`data-toolbar`,children:[Y?(0,P.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>Q(`cancel`),"aria-label":`Cancel selection`,children:[(0,P.jsx)(x,{size:14}),` Cancel`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`data-search-input`,children:[l===``&&(0,P.jsx)(ae,{size:14}),(0,P.jsx)(`input`,{ref:d,type:`text`,value:l,onChange:e=>u(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),b&&(0,P.jsx)(a,{size:14,className:`spin`}),l!==``&&(0,P.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{u(``),d.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,P.jsx)(x,{size:14})})]}),(0,P.jsxs)(`div`,{className:`data-toolbar-actions`,ref:_t,children:[(0,P.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>K(e=>!e),"aria-haspopup":`menu`,"aria-expanded":gt,"aria-label":`File actions`,title:`File actions`,children:(0,P.jsx)(ue,{size:16})}),(0,P.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":gt?`true`:void 0,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{xt(),K(!1)},disabled:V,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[V?(0,P.jsx)(a,{size:16,className:`spin`}):(0,P.jsx)(t,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn admin-btn-cta`,onClick:()=>{Vt(),K(!1)},disabled:Ue||!G,title:G?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Ue?H&&H.total>0?(0,P.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(H.loaded/H.total*100),`%`]}):(0,P.jsx)(a,{size:16,className:`spin`}):(0,P.jsx)(_e,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{it(e=>!e),ot(``),ft(null),K(!1)},disabled:Ue||!G,title:G?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,P.jsx)(de,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Nt(j===`grid`?`list`:`grid`),K(!1)},title:j===`grid`?`List view`:`Grid view`,"aria-label":j===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":j===`grid`,children:[j===`grid`?(0,P.jsx)(pe,{size:16}):(0,P.jsx)(fe,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:j===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,P.jsxs)(`div`,{className:`data-breadcrumbs`,children:[D!==`.`&&(0,P.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:Ct,title:`Up one level`,"aria-label":`Up one level`,children:(0,P.jsx)(n,{size:14})}),Xt?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`span`,{className:`data-crumb-wrap`,ref:ht,children:[(0,P.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>mt(e=>!e),"aria-haspopup":`menu`,"aria-expanded":pt,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),pt&&(0,P.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Zt.map(e=>(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>J(e.name),title:e.label,children:e.label},e.name))})]}),[N.length-2,N.length-1].map(e=>{let t=N[e];return(0,P.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,P.jsx)(`span`,{className:`data-crumb-sep`,children:`›`}),(0,P.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(Yt(e)),title:t.name,children:t.displayName??t.name})]},Yt(e))})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(`.`),children:`data`}),N.map((e,t)=>(0,P.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,P.jsx)(`span`,{className:`data-crumb-sep`,children:`›`}),(0,P.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(Yt(t)),title:e.name,children:e.displayName??e.name})]},Yt(t)))]})]}),rt&&(0,P.jsxs)(`div`,{className:`data-inline-form`,children:[(0,P.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:at,autoFocus:!0,onChange:e=>ot(e.target.value),onKeyDown:e=>{e.key===`Enter`&&qt(),e.key===`Escape`&&it(!1)}}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:qt,children:`Create`}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>it(!1),children:`Cancel`})]}),st&&(0,P.jsxs)(`div`,{className:`data-inline-form`,children:[(0,P.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:lt,autoFocus:!0,onChange:e=>ut(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Jt(),e.key===`Escape`&&ct(null)}}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Jt,children:`Rename`}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>ct(null),children:`Cancel`})]}),dt&&(0,P.jsx)(`div`,{className:`data-error`,children:dt}),(0,P.jsx)(`input`,{type:`file`,ref:tt,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Ut(t)}})]}),(0,P.jsxs)(`div`,{className:`data-body`,"data-drag-active":Ze?`true`:void 0,onDragEnter:Wt,onDragOver:Wt,onDragLeave:Gt,onDrop:Kt,children:[F===null&&R&&I&&I.length>0&&(0,P.jsxs)(`aside`,{className:`data-rail`,"aria-label":`Folders`,children:[(0,P.jsx)(`span`,{className:`data-rail-label`,children:`Folders`}),(0,P.jsx)(`ul`,{className:`data-rail-list`,children:I.map(e=>{let t=`${R}/${e}`,n=D===t||D.startsWith(`${t}/`);return(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,className:`data-rail-item`,"aria-current":n?`true`:void 0,onClick:()=>J(t),children:[(0,P.jsx)(v,{size:13}),(0,P.jsx)(`span`,{className:`data-rail-item-name`,children:e})]})},e)})})]}),(0,P.jsxs)(`div`,{className:`data-content`,children:[(ne!==null||h!==null)&&(0,P.jsxs)(`section`,{className:`data-panel admin-card`,children:[ne&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,ne]}),vt.length>0&&(0,P.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:vt.map(e=>{let t=e===q;return(0,P.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>re(t?null:e),children:Be([e])??e},e)})}),h&&!b&&(0,P.jsxs)(`div`,{className:`data-results-meta`,children:[yt.length,` of `,h.length,` result`,h.length===1?``:`s`]}),h&&!b&&!q&&w>0&&!T&&(0,P.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>E(!0),children:[w,` low-confidence result`,w===1?``:`s`,` hidden — show all`]}),h&&!b&&!q&&T&&(0,P.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>E(!1),children:`Showing all results — hide low-confidence`}),h&&h.length===0&&!b&&(0,P.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),yt&&yt.length>0&&(0,P.jsx)(`ul`,{className:`data-results`,children:yt.map(e=>(0,P.jsx)(ze,{hit:e,mode:ee,onDownload:bt,onLocate:St},e.nodeId))})]}),(0,P.jsxs)(`section`,{className:`data-panel data-panel--wide admin-card`,children:[H&&(0,P.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":H.total>0?Math.round(H.loaded/H.total*100):void 0,children:[(0,P.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,P.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${H.total>0?Math.round(H.loaded/H.total*100):0}%`}})}),(0,P.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,H.total>0?`${Math.round(H.loaded/H.total*100)}%`:``]})]}),qe&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,qe]}),Ye&&(0,P.jsx)(`div`,{className:`data-status`,children:Ye}),$e&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,$e]}),Ve&&(0,P.jsx)(`div`,{className:`data-error`,children:Ve}),V&&(0,P.jsxs)(`div`,{className:`data-loading`,children:[(0,P.jsx)(a,{size:14,className:`spin`}),` Loading…`]}),!Y&&!V&&F!==`home`&&A&&A.length>0&&(0,P.jsxs)(`div`,{className:`data-select-hint`,children:[(0,P.jsx)(me,{size:13}),(0,P.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!V&&F!==`home`&&A&&A.length===0&&!Ve&&(0,P.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!V&&F===`home`&&A&&(0,P.jsxs)(`ul`,{className:`routine-list data-home-list`,children:[A.map(e=>(0,P.jsxs)(`li`,{className:`data-home-card`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-home-card-head`,onClick:()=>J(B(e.name)),children:[(0,P.jsx)(`span`,{className:`data-home-card-title`,children:e.name}),(0,P.jsx)(`span`,{className:`data-home-card-count`,children:e.childCount===null||e.childCount===void 0?`—`:`${e.childCount} ${e.childCount===1?`item`:`items`}`})]}),(0,P.jsxs)(`ul`,{className:`data-home-card-children`,children:[e.childCount===null&&(0,P.jsx)(`li`,{className:`data-home-card-error`,children:`Could not read this folder.`}),e.childCount===0&&(0,P.jsx)(`li`,{className:`data-home-card-empty`,children:`Empty.`}),(e.children??[]).map(e=>(0,P.jsxs)(`li`,{className:`data-home-card-child`,children:[e.kind===`directory`?(0,P.jsx)(v,{size:12}):(0,P.jsx)(k,{size:12}),(0,P.jsx)(`span`,{className:`data-home-card-child-name`,children:e.name})]},e.name)),typeof e.childCount==`number`&&e.childCount>(e.children?.length??0)&&(0,P.jsxs)(`li`,{className:`data-home-card-more`,children:[`+`,e.childCount-(e.children?.length??0),` more`]})]})]},e.name)),(0,P.jsxs)(`li`,{className:`data-home-card`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-home-card-head`,onClick:()=>J(B(`@system`)),children:[(0,P.jsx)(`span`,{className:`data-home-card-title`,children:`system`}),(0,P.jsxs)(`span`,{className:`data-home-card-count`,children:[xe,` `,xe===1?`item`:`items`]})]}),(0,P.jsx)(`ul`,{className:`data-home-card-children`,children:(0,P.jsx)(`li`,{className:`data-home-card-empty`,children:`Platform and plugin folders.`})})]})]}),!V&&F!==`home`&&A&&A.length>0&&j===`grid`&&(0,P.jsx)(`ul`,{className:`data-grid`,children:A.map(e=>{let t=e.displayName??e.name,n=Y&&X.has(e.name);if(e.kind===`directory`)return(0,P.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>jt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(Z.current){Z.current=!1;return}if(Y){At(e.name);return}J(B(e.name))},children:[Y&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsx)(v,{size:28,className:`data-grid-glyph`}),(0,P.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t})]})},e.name);if(e.kind===`file`){let i=De(L(e)),a=B(L(e));return(0,P.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>jt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>i?Pt(e):Mt(e),title:Y?void 0:i?`Preview ${t}`:`Download ${t}`,children:[Y&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,P.jsx)(`img`,{className:`data-grid-thumb`,src:le(r,a),alt:t,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,P.jsx)(k,{size:28,className:`data-grid-glyph`}),(0,P.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t}),!i&&(0,P.jsx)(`span`,{className:`data-grid-sub`,children:We(e.sizeBytes)})]})},e.name)}return(0,P.jsx)(`li`,{className:`data-grid-cell`,children:(0,P.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,P.jsx)(k,{size:28,className:`data-grid-glyph`}),(0,P.jsx)(`span`,{className:`data-grid-label`,children:t}),(0,P.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!V&&F!==`home`&&A&&A.length>0&&j===`list`&&(0,P.jsx)(`ul`,{className:`data-entries`,children:A.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=Y&&X.has(e.name);return(0,P.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>jt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(Z.current){Z.current=!1;return}if(Y){At(e.name);return}J(B(e.name))},children:[Y&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsx)(v,{size:14}),(0,P.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=Y&&X.has(e.name);return(0,P.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>jt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>Mt(e),title:Y?void 0:`Download ${t}`,children:[Y&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsxs)(`span`,{className:`data-entry-text`,children:[(0,P.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,P.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${Ge(e.modifiedAt)}`,children:[We(e.sizeBytes),` · `,Ge(e.modifiedAt)]})]})]})},e.name)}return(0,P.jsx)(`li`,{className:`data-entry`,children:(0,P.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,P.jsxs)(`span`,{className:`data-entry-text`,children:[(0,P.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,P.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]})]}),Y&&(0,P.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,P.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Bt,disabled:!Ot||X.size===0,title:Ot?`Share selected files`:`Sharing is not supported on this device`,children:[(0,P.jsx)(s,{size:16}),` Share`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Rt,disabled:X.size===0,children:[(0,P.jsx)(i,{size:16}),` Download`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=It();e&&(ct(e.name),ut(e.name))},disabled:!It(),children:[(0,P.jsx)(c,{size:16}),` Rename`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:zt,disabled:X.size===0,children:[(0,P.jsx)(p,{size:16}),` Delete`]})]})}),ge&&(0,P.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":ge.alt,onClick:()=>ve(null),children:(0,P.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:ge.src,alt:ge.alt})})]}):(0,P.jsx)(g,{surface:`gate`})}function Le({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){let r=(0,M.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),i=(0,M.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[a,o]=(0,M.useState)([]),[s,c]=(0,M.useState)(`files`),{subAccounts:l,activeAccountId:u,switching:d,switchAccount:f}=b(t);return(0,M.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`/api/operator-conversations/conversations?session_key=${encodeURIComponent(t)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||o(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]),(0,P.jsxs)(`main`,{className:`data-main`,children:[(0,P.jsx)(ee,{variant:`operator`,onNavigate:i,onOpenConversations:a.length>0?()=>c(`conversations`):void 0,onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:l,activeAccountId:u,switchingAccount:d,onSwitchAccount:f}),s===`conversations`?(0,P.jsx)(Te,{conversations:a,sessionKey:t,onBack:()=>c(`files`)}):(0,P.jsx)(Ie,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function Re({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:i}=r({initialCacheKey:e,surface:`data`});return(0,P.jsx)(`div`,{className:`data-page`,children:(0,P.jsx)(`main`,{className:`data-main`,children:(0,P.jsx)(Ie,{adminFetch:t,cacheKey:n,sessionRefetchNonce:i})})})}function ze({hit:e,mode:t,onDownload:n,onLocate:r}){let i=Ve(e.properties),a=He(e.properties),o=Be(e.labels),s=Ue(e.properties),[c,l]=(0,M.useState)(!1),u=a&&a.length>280,d=c||!u?a:a?.slice(0,280)+`…`,f=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,p=e.properties.relativePath,m=typeof p==`string`&&p.length>0,h=m?p.lastIndexOf(`/`):-1,g=m?h===-1?`data`:p.slice(0,h):null;return(0,P.jsxs)(`li`,{className:`data-result`,children:[(0,P.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Download ${i??o??`file`}`,children:[o&&(0,P.jsx)(`div`,{className:`data-result-header`,children:(0,P.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,P.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,P.jsx)(`pre`,{className:`data-result-body`,children:d}),(0,P.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,P.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Ge(s),` · `]}),f]})]}),m&&(0,P.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${g}`,"aria-label":`Locate in ${g}`,children:[(0,P.jsx)(v,{size:12}),g]}),u&&(0,P.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>l(e=>!e),children:c?`Show less`:`Show more`})]})}function Be(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function Ve(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function He(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function Ue(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function We(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function Ge(e){try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=typeof navigator<`u`?navigator.languages&&navigator.languages.length>0?[...navigator.languages]:[navigator.language]:void 0;return t.toLocaleString(n,{dateStyle:`medium`,timeStyle:`short`})}catch{return`—`}}export{Re as n,I as r,R as t};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|