@rubytech/create-realagent-code 0.1.532 → 0.1.534

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +12 -7
  3. package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +15 -0
  4. package/payload/platform/plugins/docs/references/admin-ui.md +2 -0
  5. package/payload/platform/plugins/docs/references/calendar-booking.md +9 -6
  6. package/payload/platform/plugins/email/mcp/dist/__tests__/signature.test.js +40 -1
  7. package/payload/platform/plugins/email/mcp/dist/__tests__/signature.test.js.map +1 -1
  8. package/payload/platform/plugins/email/mcp/dist/lib/compose.d.ts.map +1 -1
  9. package/payload/platform/plugins/email/mcp/dist/lib/compose.js +4 -1
  10. package/payload/platform/plugins/email/mcp/dist/lib/compose.js.map +1 -1
  11. package/payload/platform/plugins/email/mcp/dist/lib/signature.d.ts +27 -0
  12. package/payload/platform/plugins/email/mcp/dist/lib/signature.d.ts.map +1 -1
  13. package/payload/platform/plugins/email/mcp/dist/lib/signature.js +62 -2
  14. package/payload/platform/plugins/email/mcp/dist/lib/signature.js.map +1 -1
  15. package/payload/platform/plugins/memory/skills/preference-audit/SKILL.md +11 -1
  16. package/payload/platform/plugins/whatsapp/PLUGIN.md +12 -2
  17. package/payload/platform/plugins/whatsapp/mcp/dist/index.js +73 -6
  18. package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
  19. package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +9 -1
  20. package/payload/platform/plugins/whatsapp/skills/manage-whatsapp-config/SKILL.md +27 -1
  21. package/payload/platform/scripts/__tests__/vnc-cdp-liveness.test.sh +14 -12
  22. package/payload/platform/scripts/vnc.sh +24 -19
  23. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  24. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +1 -0
  25. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  26. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
  27. package/payload/platform/services/claude-session-manager/dist/http-server.js +35 -1
  28. package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
  29. package/payload/platform/services/claude-session-manager/dist/index.js +13 -4
  30. package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
  31. package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.d.ts +1 -1
  32. package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.d.ts.map +1 -1
  33. package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.js +46 -3
  34. package/payload/platform/services/claude-session-manager/dist/preference-reconciliation-audit.js.map +1 -1
  35. package/payload/platform/services/claude-session-manager/dist/rc-daemon.d.ts +9 -0
  36. package/payload/platform/services/claude-session-manager/dist/rc-daemon.d.ts.map +1 -1
  37. package/payload/platform/services/claude-session-manager/dist/rc-daemon.js +7 -0
  38. package/payload/platform/services/claude-session-manager/dist/rc-daemon.js.map +1 -1
  39. package/payload/platform/services/claude-session-manager/dist/specialist-roster.d.ts +12 -0
  40. package/payload/platform/services/claude-session-manager/dist/specialist-roster.d.ts.map +1 -0
  41. package/payload/platform/services/claude-session-manager/dist/specialist-roster.js +75 -0
  42. package/payload/platform/services/claude-session-manager/dist/specialist-roster.js.map +1 -0
  43. package/payload/platform/services/claude-session-manager/dist/system-prompt.d.ts +5 -0
  44. package/payload/platform/services/claude-session-manager/dist/system-prompt.d.ts.map +1 -1
  45. package/payload/platform/services/claude-session-manager/dist/system-prompt.js +10 -2
  46. package/payload/platform/services/claude-session-manager/dist/system-prompt.js.map +1 -1
  47. package/payload/server/{chunk-UH6GCQO4.js → chunk-4QCYFTAI.js} +276 -19
  48. package/payload/server/{manager-H34562SN.js → manager-ZNHQQCED.js} +1 -1
  49. package/payload/server/public/activity.html +5 -5
  50. package/payload/server/public/agents.html +4 -4
  51. package/payload/server/public/assets/AdminLoginScreens-gvOpxnO4.js +1 -0
  52. package/payload/server/public/assets/AdminLoginScreens-gvOpxnO4.js.br +0 -0
  53. package/payload/server/public/assets/AdminLoginScreens-gvOpxnO4.js.gz +0 -0
  54. package/payload/server/public/assets/AdminShell-CMZZr5Oz.js +2 -0
  55. package/payload/server/public/assets/AdminShell-CMZZr5Oz.js.br +0 -0
  56. package/payload/server/public/assets/AdminShell-CMZZr5Oz.js.gz +0 -0
  57. package/payload/server/public/assets/{CdpScreencastSurface-BbekDUFw.js → CdpScreencastSurface-erS6iQci.js} +1 -1
  58. package/payload/server/public/assets/CdpScreencastSurface-erS6iQci.js.br +0 -0
  59. package/payload/server/public/assets/CdpScreencastSurface-erS6iQci.js.gz +0 -0
  60. package/payload/server/public/assets/{activity-ClI-RgJu.js → activity-Di0Rg9lb.js} +1 -1
  61. package/payload/server/public/assets/activity-Di0Rg9lb.js.br +0 -0
  62. package/payload/server/public/assets/activity-Di0Rg9lb.js.gz +0 -0
  63. package/payload/server/public/assets/admin-BVt8IN2Y.js +1 -0
  64. package/payload/server/public/assets/admin-BVt8IN2Y.js.br +0 -0
  65. package/payload/server/public/assets/admin-BVt8IN2Y.js.gz +0 -0
  66. package/payload/server/public/assets/{agents-BO8YBj8d.js → agents-CZTshBkV.js} +1 -1
  67. package/payload/server/public/assets/agents-CZTshBkV.js.br +0 -0
  68. package/payload/server/public/assets/agents-CZTshBkV.js.gz +0 -0
  69. package/payload/server/public/assets/{browser-Bj8oTG5R.js → browser-D9s49CKQ.js} +1 -1
  70. package/payload/server/public/assets/browser-D9s49CKQ.js.br +0 -0
  71. package/payload/server/public/assets/browser-D9s49CKQ.js.gz +0 -0
  72. package/payload/server/public/assets/calendar-BkZcebIa.js +1 -0
  73. package/payload/server/public/assets/calendar-BkZcebIa.js.br +0 -0
  74. package/payload/server/public/assets/calendar-BkZcebIa.js.gz +0 -0
  75. package/payload/server/public/assets/chat-C6EOth0E.js +1 -0
  76. package/payload/server/public/assets/chat-C6EOth0E.js.br +1 -0
  77. package/payload/server/public/assets/chat-C6EOth0E.js.gz +0 -0
  78. package/payload/server/public/assets/chevron-left-DiJkQOqd.js +1 -0
  79. package/payload/server/public/assets/chevron-right-DOO-559P.js +1 -0
  80. package/payload/server/public/assets/chevron-right-DOO-559P.js.br +0 -0
  81. package/payload/server/public/assets/clock-D-z9DPIi.js +1 -0
  82. package/payload/server/public/assets/clock-D-z9DPIi.js.br +0 -0
  83. package/payload/server/public/assets/clock-D-z9DPIi.js.gz +0 -0
  84. package/payload/server/public/assets/data-2fHKgEQR.js +1 -0
  85. package/payload/server/public/assets/data-2fHKgEQR.js.br +0 -0
  86. package/payload/server/public/assets/data-2fHKgEQR.js.gz +0 -0
  87. package/payload/server/public/assets/{file-download-Di_s0_4w.js → file-download-CKfAhT9F.js} +1 -1
  88. package/payload/server/public/assets/file-download-CKfAhT9F.js.br +0 -0
  89. package/payload/server/public/assets/file-download-CKfAhT9F.js.gz +0 -0
  90. package/payload/server/public/assets/{file-text-CP1KIrJV.js → file-text-BdMnzZ8u.js} +1 -1
  91. package/payload/server/public/assets/file-text-BdMnzZ8u.js.br +0 -0
  92. package/payload/server/public/assets/file-text-BdMnzZ8u.js.gz +0 -0
  93. package/payload/server/public/assets/{graph-BCMscnCV.js → graph-DzB4KiCO.js} +2 -2
  94. package/payload/server/public/assets/graph-DzB4KiCO.js.br +0 -0
  95. package/payload/server/public/assets/graph-DzB4KiCO.js.gz +0 -0
  96. package/payload/server/public/assets/{graph-labels-CgP17xHK.js → graph-labels-CMlGzab-.js} +1 -1
  97. package/payload/server/public/assets/graph-labels-CMlGzab-.js.br +0 -0
  98. package/payload/server/public/assets/graph-labels-CMlGzab-.js.gz +0 -0
  99. package/payload/server/public/assets/{maximize-2-DkQzDv-g.js → maximize-2-Cw95Fq0m.js} +1 -1
  100. package/payload/server/public/assets/maximize-2-Cw95Fq0m.js.br +0 -0
  101. package/payload/server/public/assets/maximize-2-Cw95Fq0m.js.gz +0 -0
  102. package/payload/server/public/assets/operator-DzWQapvw.js +1 -0
  103. package/payload/server/public/assets/operator-DzWQapvw.js.br +0 -0
  104. package/payload/server/public/assets/operator-DzWQapvw.js.gz +0 -0
  105. package/payload/server/public/assets/page-DRipsKnx.js +32 -0
  106. package/payload/server/public/assets/page-DRipsKnx.js.br +0 -0
  107. package/payload/server/public/assets/page-DRipsKnx.js.gz +0 -0
  108. package/payload/server/public/assets/page-iEvYrvW4.js +1 -0
  109. package/payload/server/public/assets/page-iEvYrvW4.js.br +0 -0
  110. package/payload/server/public/assets/page-iEvYrvW4.js.gz +0 -0
  111. package/payload/server/public/assets/public-wBScNSFk.js +1 -0
  112. package/payload/server/public/assets/public-wBScNSFk.js.br +0 -0
  113. package/payload/server/public/assets/public-wBScNSFk.js.gz +0 -0
  114. package/payload/server/public/assets/{rotate-ccw-DPw0vXC0.js → rotate-ccw-BjIYVGss.js} +1 -1
  115. package/payload/server/public/assets/rotate-ccw-BjIYVGss.js.br +0 -0
  116. package/payload/server/public/assets/rotate-ccw-BjIYVGss.js.gz +0 -0
  117. package/payload/server/public/assets/{routines-CwiiYpfK.js → routines-DP0XOp9h.js} +1 -1
  118. package/payload/server/public/assets/routines-DP0XOp9h.js.br +0 -0
  119. package/payload/server/public/assets/routines-DP0XOp9h.js.gz +0 -0
  120. package/payload/server/public/assets/{skills-0FOjKUM-.js → skills-B6e7L3GG.js} +1 -1
  121. package/payload/server/public/assets/skills-B6e7L3GG.js.br +0 -0
  122. package/payload/server/public/assets/skills-B6e7L3GG.js.gz +0 -0
  123. package/payload/server/public/assets/tasks-CRoG5MpL.js +3 -0
  124. package/payload/server/public/assets/tasks-CRoG5MpL.js.br +0 -0
  125. package/payload/server/public/assets/tasks-CRoG5MpL.js.gz +0 -0
  126. package/payload/server/public/assets/{time-entry-format-B6fX_19a.js → time-entry-format-C9clyq98.js} +1 -1
  127. package/payload/server/public/assets/time-entry-format-C9clyq98.js.br +0 -0
  128. package/payload/server/public/assets/time-entry-format-C9clyq98.js.gz +0 -0
  129. package/payload/server/public/assets/{triangle-alert-vAaSDhVq.js → triangle-alert-CZlka7Nl.js} +1 -1
  130. package/payload/server/public/assets/triangle-alert-CZlka7Nl.js.br +0 -0
  131. package/payload/server/public/assets/triangle-alert-CZlka7Nl.js.gz +0 -0
  132. package/payload/server/public/assets/{useCopyFeedback-BvIRgs7W.js → useCopyFeedback-DoQhfr0S.js} +1 -1
  133. package/payload/server/public/assets/useCopyFeedback-DoQhfr0S.js.br +0 -0
  134. package/payload/server/public/assets/useCopyFeedback-DoQhfr0S.js.gz +0 -0
  135. package/payload/server/public/assets/{useSubAccountSwitcher-DM5Y9eio.css → useSubAccountSwitcher-BDQ8Wsdt.css} +1 -1
  136. package/payload/server/public/assets/useSubAccountSwitcher-BDQ8Wsdt.css.br +0 -0
  137. package/payload/server/public/assets/{useSubAccountSwitcher-DM5Y9eio.css.gz → useSubAccountSwitcher-BDQ8Wsdt.css.gz} +0 -0
  138. package/payload/server/public/assets/{useSubAccountSwitcher-BEwQMRMo.js → useSubAccountSwitcher-DOo5uRtZ.js} +2 -2
  139. package/payload/server/public/assets/useSubAccountSwitcher-DOo5uRtZ.js.br +0 -0
  140. package/payload/server/public/assets/{useSubAccountSwitcher-BEwQMRMo.js.gz → useSubAccountSwitcher-DOo5uRtZ.js.gz} +0 -0
  141. package/payload/server/public/assets/useVoiceRecorder-Cei46RSJ.js +2 -0
  142. package/payload/server/public/assets/useVoiceRecorder-Cei46RSJ.js.br +0 -0
  143. package/payload/server/public/assets/useVoiceRecorder-Cei46RSJ.js.gz +0 -0
  144. package/payload/server/public/assets/{wrench-BNBtwT2p.js → wrench-DCIBZT1Z.js} +1 -1
  145. package/payload/server/public/assets/wrench-DCIBZT1Z.js.br +2 -0
  146. package/payload/server/public/assets/wrench-DCIBZT1Z.js.gz +0 -0
  147. package/payload/server/public/browser.html +5 -5
  148. package/payload/server/public/calendar.html +7 -7
  149. package/payload/server/public/chat.html +13 -13
  150. package/payload/server/public/data.html +12 -12
  151. package/payload/server/public/graph.html +9 -9
  152. package/payload/server/public/index.html +16 -16
  153. package/payload/server/public/operator.html +15 -15
  154. package/payload/server/public/public.html +13 -13
  155. package/payload/server/public/routines.html +7 -7
  156. package/payload/server/public/skills.html +5 -5
  157. package/payload/server/public/tasks.html +6 -6
  158. package/payload/server/server.js +1612 -883
  159. package/payload/server/public/assets/AdminLoginScreens-7Czw3MAC.js +0 -1
  160. package/payload/server/public/assets/AdminLoginScreens-7Czw3MAC.js.br +0 -0
  161. package/payload/server/public/assets/AdminLoginScreens-7Czw3MAC.js.gz +0 -0
  162. package/payload/server/public/assets/AdminShell-D5GApZ_n.js +0 -2
  163. package/payload/server/public/assets/AdminShell-D5GApZ_n.js.br +0 -0
  164. package/payload/server/public/assets/AdminShell-D5GApZ_n.js.gz +0 -0
  165. package/payload/server/public/assets/CdpScreencastSurface-BbekDUFw.js.br +0 -0
  166. package/payload/server/public/assets/CdpScreencastSurface-BbekDUFw.js.gz +0 -0
  167. package/payload/server/public/assets/activity-ClI-RgJu.js.br +0 -0
  168. package/payload/server/public/assets/activity-ClI-RgJu.js.gz +0 -0
  169. package/payload/server/public/assets/admin-svtCmBPk.js +0 -1
  170. package/payload/server/public/assets/admin-svtCmBPk.js.br +0 -0
  171. package/payload/server/public/assets/admin-svtCmBPk.js.gz +0 -0
  172. package/payload/server/public/assets/agents-BO8YBj8d.js.br +0 -0
  173. package/payload/server/public/assets/agents-BO8YBj8d.js.gz +0 -0
  174. package/payload/server/public/assets/browser-Bj8oTG5R.js.br +0 -0
  175. package/payload/server/public/assets/browser-Bj8oTG5R.js.gz +0 -0
  176. package/payload/server/public/assets/calendar-CrkSY8U7.js +0 -1
  177. package/payload/server/public/assets/calendar-CrkSY8U7.js.br +0 -0
  178. package/payload/server/public/assets/calendar-CrkSY8U7.js.gz +0 -0
  179. package/payload/server/public/assets/chat-Bvxoni2e.js +0 -1
  180. package/payload/server/public/assets/chat-Bvxoni2e.js.br +0 -0
  181. package/payload/server/public/assets/chat-Bvxoni2e.js.gz +0 -0
  182. package/payload/server/public/assets/chevron-left-CdUzxzeB.js +0 -1
  183. package/payload/server/public/assets/chevron-left-CdUzxzeB.js.br +0 -0
  184. package/payload/server/public/assets/chevron-right-CKGwd-M0.js +0 -1
  185. package/payload/server/public/assets/chevron-right-CKGwd-M0.js.br +0 -0
  186. package/payload/server/public/assets/clock-Cf8Oe9qi.js +0 -1
  187. package/payload/server/public/assets/clock-Cf8Oe9qi.js.br +0 -0
  188. package/payload/server/public/assets/clock-Cf8Oe9qi.js.gz +0 -0
  189. package/payload/server/public/assets/data-DF0Pstdp.js +0 -1
  190. package/payload/server/public/assets/data-DF0Pstdp.js.br +0 -1
  191. package/payload/server/public/assets/data-DF0Pstdp.js.gz +0 -0
  192. package/payload/server/public/assets/file-download-Di_s0_4w.js.br +0 -0
  193. package/payload/server/public/assets/file-download-Di_s0_4w.js.gz +0 -0
  194. package/payload/server/public/assets/file-text-CP1KIrJV.js.br +0 -1
  195. package/payload/server/public/assets/file-text-CP1KIrJV.js.gz +0 -0
  196. package/payload/server/public/assets/graph-BCMscnCV.js.br +0 -0
  197. package/payload/server/public/assets/graph-BCMscnCV.js.gz +0 -0
  198. package/payload/server/public/assets/graph-labels-CgP17xHK.js.br +0 -0
  199. package/payload/server/public/assets/graph-labels-CgP17xHK.js.gz +0 -0
  200. package/payload/server/public/assets/maximize-2-DkQzDv-g.js.br +0 -0
  201. package/payload/server/public/assets/maximize-2-DkQzDv-g.js.gz +0 -0
  202. package/payload/server/public/assets/operator-CLbCar9e.js +0 -1
  203. package/payload/server/public/assets/operator-CLbCar9e.js.br +0 -0
  204. package/payload/server/public/assets/operator-CLbCar9e.js.gz +0 -0
  205. package/payload/server/public/assets/page-CNJl3tWT.js +0 -1
  206. package/payload/server/public/assets/page-CNJl3tWT.js.br +0 -0
  207. package/payload/server/public/assets/page-CNJl3tWT.js.gz +0 -0
  208. package/payload/server/public/assets/page-CPVUAwb8.js +0 -32
  209. package/payload/server/public/assets/page-CPVUAwb8.js.br +0 -0
  210. package/payload/server/public/assets/page-CPVUAwb8.js.gz +0 -0
  211. package/payload/server/public/assets/public-DQea3Ybz.js +0 -1
  212. package/payload/server/public/assets/public-DQea3Ybz.js.br +0 -0
  213. package/payload/server/public/assets/public-DQea3Ybz.js.gz +0 -0
  214. package/payload/server/public/assets/rotate-ccw-DPw0vXC0.js.br +0 -0
  215. package/payload/server/public/assets/rotate-ccw-DPw0vXC0.js.gz +0 -0
  216. package/payload/server/public/assets/routines-CwiiYpfK.js.br +0 -0
  217. package/payload/server/public/assets/routines-CwiiYpfK.js.gz +0 -0
  218. package/payload/server/public/assets/skills-0FOjKUM-.js.br +0 -0
  219. package/payload/server/public/assets/skills-0FOjKUM-.js.gz +0 -0
  220. package/payload/server/public/assets/tasks-BUVsPEGm.js +0 -3
  221. package/payload/server/public/assets/tasks-BUVsPEGm.js.br +0 -0
  222. package/payload/server/public/assets/tasks-BUVsPEGm.js.gz +0 -0
  223. package/payload/server/public/assets/time-entry-format-B6fX_19a.js.br +0 -0
  224. package/payload/server/public/assets/time-entry-format-B6fX_19a.js.gz +0 -0
  225. package/payload/server/public/assets/triangle-alert-vAaSDhVq.js.br +0 -0
  226. package/payload/server/public/assets/triangle-alert-vAaSDhVq.js.gz +0 -0
  227. package/payload/server/public/assets/useCopyFeedback-BvIRgs7W.js.br +0 -0
  228. package/payload/server/public/assets/useCopyFeedback-BvIRgs7W.js.gz +0 -0
  229. package/payload/server/public/assets/useSubAccountSwitcher-BEwQMRMo.js.br +0 -0
  230. package/payload/server/public/assets/useSubAccountSwitcher-DM5Y9eio.css.br +0 -0
  231. package/payload/server/public/assets/useVoiceRecorder-CiDOh8PG.js +0 -2
  232. package/payload/server/public/assets/useVoiceRecorder-CiDOh8PG.js.br +0 -0
  233. package/payload/server/public/assets/useVoiceRecorder-CiDOh8PG.js.gz +0 -0
  234. package/payload/server/public/assets/wrench-BNBtwT2p.js.br +0 -0
  235. package/payload/server/public/assets/wrench-BNBtwT2p.js.gz +0 -0
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,H as n,J as r,R as i,W as a,g as o}from"./useSubAccountSwitcher-BEwQMRMo.js";import{k as s}from"./useVoiceRecorder-CiDOh8PG.js";import{D as c,E as l,O as u}from"./AdminShell-D5GApZ_n.js";import{t as d}from"./CdpScreencastSurface-BbekDUFw.js";var f=e(r(),1);function p(e=`admin`){let[t,n]=(0,f.useState)(`loading`),[r,i]=(0,f.useState)(``),[o,c]=(0,f.useState)(``),[l,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(void 0),[k,A]=(0,f.useState)(null),[j,M]=(0,f.useState)(void 0),[N,P]=(0,f.useState)(null),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(void 0),z=(0,f.useRef)(void 0),[B,V]=(0,f.useState)(!1),[H,U]=(0,f.useState)(!0);(0,f.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&V(!0)}).catch(()=>{})},[]);let W=(0,f.useRef)(null),G=(0,f.useRef)(null);(0,f.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();w(r.session_key),I(r.sessionId??null),O(r.businessName),A(r.role??null),M(r.userName===void 0?null:r.userName),P(r.avatar??null);let i=s(r.thinkingView);return z.current=i,R(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}U(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){n(`connect-claude`);return}}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,f.useEffect)(()=>{t===`chat`&&C&&fetch(`/api/admin/claude-info?session_key=${encodeURIComponent(C)}`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&E(e)}).catch(()=>{})},[t,C]);let K=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();U(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(C)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(C)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){a(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),K.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,C]),(0,f.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(U(!0),n(`enter-pin`))}).catch(()=>{})},[t]);async function q(e,t){g(!0);try{let r=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!r.ok){let e=await r.json().catch(()=>({}));if(r.status===401&&e?.code===`remote-auth-required`){a(`enter-pin`,`/api/admin/session`);return}d(e.error||`Invalid PIN`);return}let o=await r.json();w(o.session_key),I(o.sessionId??null),O(o.businessName),A(o.role??null),M(o.userName===void 0?null:o.userName),P(o.avatar??null);let c=s(o.thinkingView);z.current=c,R(c);try{sessionStorage.setItem(`maxy-admin-session-key`,o.session_key)}catch{}i(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),d(`Could not connect.`)}finally{g(!1)}}let J=(0,f.useCallback)(async e=>{if(e.preventDefault(),h)return;d(``);let t=o.trim();if(!t){d(`Please enter your name.`);return}if(r.length<4){d(`PIN must be at least 4 characters.`);return}let s=r;g(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:s,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){a(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):d(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}d(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await q(s);return}i(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),d(`Could not connect.`)}finally{g(!1)}},[r,h,o]),Y=(0,f.useCallback)(async e=>{e.preventDefault(),d(``),await q(r)},[r]),X=(0,f.useCallback)(async()=>{S(!0);try{if(!await u())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;U(!1),w(null),A(null),M(void 0),P(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return n(`connect-claude`),!0}finally{S(!1)}},[]),Z=(0,f.useCallback)(()=>{w(null),A(null),M(void 0),P(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}i(``),d(``),n(`enter-pin`)},[]);return(0,f.useEffect)(()=>{K.current=Z},[Z]),{appState:t,setAppState:n,pin:r,setPin:i,operatorName:o,setOperatorName:c,pinError:l,setPinError:d,showPin:p,setShowPin:m,pinLoading:h,authPolling:_,setAuthPolling:v,authLoading:y,setAuthLoading:b,disconnecting:x,cacheKey:C,setCacheKey:w,claudeInfo:T,setClaudeInfo:E,businessName:D,role:k,userName:j,userAvatar:N,sessionId:F,setSessionId:I,expandAll:L,setExpandAll:R,expandAllDefaultRef:z,remoteAuthEnabled:B,claudeConnected:H,pinInputRef:W,setPinFormRef:G,handleSetPin:J,handleLogin:Y,handleDisconnect:X,handleLogout:Z}}var m=n();function h({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,f.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,m.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,m.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function g(e){let{pin:n,setPin:r,showPin:a,setShowPin:o,pinLoading:s,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:g,setOperatorName:_}=e;return(0,m.jsx)(`div`,{className:`connect-page`,children:(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsx)(`img`,{src:t,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,m.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,i.productName]}),(0,m.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,i.productName,` who you are, then choose a PIN.`]}),(0,m.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:g,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,m.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(h,{inputRef:d,value:n,onChange:r,onComplete:()=>{},showPin:a}),(0,m.jsx)(l,{variant:`send`,type:`submit`,disabled:!n||!g.trim(),loading:s,"aria-label":`Set PIN`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,m.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,m.jsx)(c,{checked:a,onChange:()=>o(e=>!e),label:`Show PIN`})]}),u&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function _(e){let{pin:n,setPin:r,showPin:a,setShowPin:o,pinLoading:s,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:g}=e;return(0,m.jsxs)(`div`,{className:`connect-page`,children:[p&&g&&(0,m.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:g,children:`Sign out`}),(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsx)(`img`,{src:t,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,m.jsx)(`h1`,{className:`connect-title`,children:i.productName}),(0,m.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(h,{inputRef:d,value:n,onChange:r,onComplete:()=>{},showPin:a,autoFocus:!0}),(0,m.jsx)(l,{variant:`send`,type:`submit`,disabled:!n,loading:s,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,m.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,m.jsx)(`div`,{className:`pin-options`,children:(0,m.jsx)(c,{checked:a,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),u&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function v(e){let{authPolling:n,setAuthPolling:r,authLoading:a,setAuthLoading:o,pinError:s,setPinError:c,setAppState:u}=e,[p,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(``),[b,x]=(0,f.useState)(``),[S,C]=(0,f.useState)(``),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(!1);(0,f.useEffect)(()=>{try{D(sessionStorage.getItem(`maxy-admin-session-key`))}catch{}k(!0)},[]);async function A(){C(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:b})})).json();e.accepted?(C(`Code submitted. Finishing sign-in…`),x(``)):C(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),C(`Could not submit code.`)}}async function j(){_(!0),c(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?h(!0):e.error&&c(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),c(`Could not launch browser.`)}_(!1)}async function M(){o(!0),c(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){r(!0),h(!0),o(!1),y(e.transport||``);for(let e=0;e<120;e++){await new Promise(e=>setTimeout(e,2e3));let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json();if(typeof e.authTargetId==`string`&&T(e.authTargetId),e.authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}}c(`Timed out waiting for sign-in. Try again.`),r(!1)}else e.error&&c(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),c(`Could not start auth flow.`)}o(!1)}async function N(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),r(!1),c(``)}return n||p?(0,m.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,m.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[n?(0,m.jsx)(`button`,{onClick:N,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,m.jsx)(`button`,{onClick:()=>h(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,m.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,m.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,m.jsx)(`p`,{className:`chat-intro`,children:n?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!n&&(0,m.jsx)(`div`,{style:{marginTop:`12px`},children:(0,m.jsx)(l,{variant:`primary`,onClick:M,disabled:a,children:a?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),n&&v===`native`&&(0,m.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,m.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,m.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,m.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,m.jsx)(l,{variant:`primary`,onClick:A,disabled:!b.trim(),children:`Submit`})]}),S&&(0,m.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:S})]})]}),(0,m.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:O&&(0,m.jsx)(d,{preferTargetId:w,cacheKey:E})}),s&&(0,m.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,m.jsx)(`div`,{className:`connect-page`,children:(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsxs)(`div`,{className:`connect-logos`,children:[(0,m.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,m.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,m.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,m.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,m.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,m.jsx)(`img`,{src:t,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,m.jsx)(`span`,{className:`connect-logo-label`,children:i.productName})]})]}),(0,m.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,i.productName]}),(0,m.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,m.jsx)(l,{variant:`primary`,onClick:M,disabled:a,children:a?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,m.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,m.jsx)(`button`,{onClick:j,disabled:g,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:g?`Launching…`:`Open browser first`}),s&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function y({auth:e}){return e.appState===`loading`?(0,m.jsx)(o,{surface:`gate`}):e.appState===`set-pin`?(0,m.jsx)(g,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,m.jsx)(v,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,m.jsx)(_,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):null}export{p as n,y as t};
@@ -1,2 +0,0 @@
1
- import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,C as n,D as r,E as i,F as a,H as o,I as s,J as c,L as l,M as u,N as d,O as f,R as p,T as m,U as h,V as g,a as _,b as ee,f as v,g as y,h as te,j as b,k as x,m as S,o as ne,p as re,q as C,r as ie,t as ae,v as oe,w as se,x as w,y as ce,z as le}from"./useSubAccountSwitcher-BEwQMRMo.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 T=o();function de({checked:e,onChange:t,label:n,disabled:r,ariaLabel:i=n}){return(0,T.jsxs)(`label`,{className:`maxy-checkbox${r?` maxy-checkbox--disabled`:``}`,children:[(0,T.jsx)(`input`,{type:`checkbox`,"aria-label":i,checked:e,onChange:e=>t(e.target.checked),disabled:r}),(0,T.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),n&&(0,T.jsx)(`span`,{className:`maxy-checkbox__label`,children:n})]})}var E=e(c(),1),D={sm:14,md:16,lg:18},fe={sm:30,md:38,lg:46};function O({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=D[t],g={...e===`send`?{width:fe[t],height:fe[t]}:{},...d},_=Object.keys(g).length>0;return(0,T.jsxs)(`button`,{type:s,className:m,disabled:i||o,onClick:c,"aria-label":l,"aria-pressed":u,style:_?g:void 0,children:[(0,T.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,T.jsx)(n,{size:h}),p,n&&r===`trailing`&&(0,T.jsx)(n,{size:h})]}),i&&(0,T.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var pe=l(`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=l(`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=l(`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=l(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),_e=l(`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=l(`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`}]]),k=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),ye=l(`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`}]]),be=l(`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`}]]),A=l(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),xe=l(`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`}]]),Se=l(`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`}]]),Ce=l(`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`}]]),we=l(`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`}]]),Te=5e3,Ee=1200;function De(e){return Math.max(Ee,Math.round(Te/(e<1?1:e)))}var Oe=500,j=new Set;function M(e,t,n){let r=n??(typeof globalThis.fetch==`function`?globalThis.fetch:void 0);if(j.has(e)||!r)return!1;if(j.size>=Oe){for(let e of j)if(j.delete(e),j.size<Oe)break}j.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 ke({type:e}){return e===`admin`?(0,T.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,T.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,T.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,T.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,T.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,T.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,T.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,T.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 Ae({frames:e,onExpire:t}){let n=(0,E.useRef)(new Map),r=(0,E.useRef)(new Map);return(0,E.useEffect)(()=>{let i=Date.now(),a=De(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),M(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,T.jsx)(`div`,{className:`wa-notify-host`,children:[...e].reverse().map(e=>(0,T.jsxs)(`div`,{className:`wa-notify-card`,role:`status`,children:[(0,T.jsxs)(`div`,{className:`wa-notify-head`,children:[(0,T.jsx)(`span`,{className:`wa-notify-pill wa-notify-pill-${e.senderType}`,children:(0,T.jsx)(ke,{type:e.senderType})}),(0,T.jsx)(`span`,{className:`wa-notify-account`,children:e.accountName})]}),(0,T.jsx)(`div`,{className:`wa-notify-sender`,children:e.senderDisplay}),(0,T.jsxs)(`div`,{className:`wa-notify-body`,children:[e.body,e.truncated?`…`:``]})]},e.waMessageId))})}var je=`wa-notify`;function Me({connected:e,onConnectClaude:t}){return e?(0,T.jsxs)(`span`,{className:`claude-status-pill`,"data-connected":`true`,title:`Claude is connected`,children:[(0,T.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`claude-status-pill__mark`}),(0,T.jsx)(`span`,{className:`claude-status-pill__label`,children:`Connected`}),(0,T.jsx)(`span`,{className:`claude-status-pill__dot claude-status-pill__dot--live`,"aria-hidden":`true`})]}):(0,T.jsxs)(`button`,{type:`button`,className:`claude-status-pill claude-status-pill--action`,"data-connected":`false`,onClick:t,title:`Connect Claude`,children:[(0,T.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`claude-status-pill__mark`}),(0,T.jsx)(`span`,{className:`claude-status-pill__label`,children:`Connect`}),(0,T.jsx)(`span`,{className:`claude-status-pill__dot claude-status-pill__dot--down`,"aria-hidden":`true`})]})}function Ne(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 Pe({title:e,sidebarOpen:t,onToggleSidebar:n,claudeConnected:i,onConnectClaude:a}){let o=e??Ne(typeof window<`u`?window.location.pathname:`/`),s=i!==void 0&&a!==void 0;return(0,T.jsxs)(`header`,{className:`admin-page-header`,children:[(0,T.jsxs)(`button`,{type:`button`,className:`admin-page-header__toggle`,"aria-label":t?`Hide sidebar`:`Show sidebar`,title:t?`Hide sidebar`:`Show sidebar`,"aria-expanded":t,onClick:n,children:[(0,T.jsx)(A,{className:`admin-page-header__toggle-desktop`,size:18,strokeWidth:1.75}),(0,T.jsx)(r,{className:`admin-page-header__toggle-mobile`,size:22,strokeWidth:1.75})]}),(0,T.jsx)(`h1`,{className:`admin-page-header__title`,children:o}),s&&(0,T.jsx)(`div`,{className:`admin-page-header__right`,children:(0,T.jsx)(Me,{connected:i,onConnectClaude:a})})]})}var Fe=[{label:`Home`,href:`/`,Icon:x,match:e=>e===`/`||e===``},{label:`Chat`,href:`/chat`,Icon:i,match:e=>e.startsWith(`/chat`)},{label:`Tasks`,href:`/tasks`,Icon:ye,match:e=>e.startsWith(`/tasks`)},{label:`Data`,href:`/data`,Icon:d,match:e=>e.startsWith(`/data`)},{label:`Calendar`,href:`/calendar`,Icon:a,match:e=>e.startsWith(`/calendar`)}],Ie=[{label:`Chat`,href:`/`,Icon:i,match:e=>e===`/`||e===``||e.startsWith(`/chat`)},{label:`Data`,href:`/data`,Icon:d,match:e=>e.startsWith(`/data`)}];function Le(e){let t=Fe.find(t=>t.match(e));return t?t.href:`/`}function N({variant:e=`admin`,onOpenConversations:t}={}){let n=typeof window<`u`?window.location.pathname:`/`,r=e===`operator`?Ie:Fe,a=e===`operator`?Ie.find(e=>e.match(n))?.href??`/`:Le(n),o=e=>{let t=e.href===a,{Icon:n}=e;return(0,T.jsxs)(`a`,{href:e.href,className:`bottom-tab${t?` is-active`:``}`,"aria-current":t?`page`:void 0,children:[(0,T.jsx)(n,{size:19,strokeWidth:1.75}),(0,T.jsx)(`span`,{className:`bottom-tab__label`,children:e.label})]},e.href)};return(0,T.jsxs)(`nav`,{className:`bottom-tab-bar`,"aria-label":`Primary`,children:[r.slice(0,1).map(o),e===`operator`&&t&&(0,T.jsxs)(`button`,{type:`button`,className:`bottom-tab`,onClick:t,children:[(0,T.jsx)(i,{size:19,strokeWidth:1.75}),(0,T.jsx)(`span`,{className:`bottom-tab__label`,children:`Conversations`})]}),r.slice(1).map(o)]})}var P=`thicknessPx=- lengthPx=- color=- opacity=- boxPx=- painted=false source=unavailable`;function Re(e){let t=parseFloat(e);return Number.isFinite(t)?t:null}function F(e,t,n,r){return e<=0||t<=0||r<=0||n===`transparent`?!1:!/rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*0\s*\)/.test(n)}function ze(e,t){let n=`[admin-ui] op=resize-grip-audit surface=${e}`;if(!t)return`${n} ${P}`;let r=Re(t.width),i=Re(t.height),a=Re(t.hostOpacity),o=Re(t.pillOpacity);if(r===null||i===null||a===null||o===null||!t.backgroundColor)return`${n} ${P}`;let s=Math.round(a*o*1e3)/1e3,c=F(r,i,t.backgroundColor,s);return`${n} thicknessPx=${r} lengthPx=${i} color=${t.backgroundColor} opacity=${s} boxPx=${t.boxPx} painted=${c}`}function I(e){if(typeof window>`u`||typeof window.getComputedStyle!=`function`)return null;let t=window.getComputedStyle(e,`::before`);return!t||!t.width||!t.height?null:{width:t.width,height:t.height,backgroundColor:t.backgroundColor,hostOpacity:window.getComputedStyle(e).opacity,pillOpacity:t.opacity,boxPx:Math.round(e.getBoundingClientRect().width)}}var L=`maxy-shell-side-px`;function Be(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function R(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-Be());return Math.min(Math.max(e,248),n)}function Ve(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(L);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 R(t)}catch{}return 264}function He({targetSelector:e=`.platform`}){let t=(0,E.useRef)(null),[n,r]=(0,E.useState)(()=>Ve()),i=(0,E.useRef)(n);(0,E.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,E.useCallback)(()=>{r(e=>{let t=R(e);return t===e?e:t})},[]);(0,E.useEffect)(()=>{a(),t.current&&console.info(ze(`sidebar`,I(t.current))),window.addEventListener(`resize`,a);let n=document.querySelector(e),r=null;return n instanceof HTMLElement&&(r=new MutationObserver(a),r.observe(n,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),r?.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(R(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(L,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=R(264);r(e);try{window.localStorage.removeItem(L)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,T.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var z=C();function Ue(e){return Math.max(14,e/2-386)}function B(e){return e.left===0&&e.top===0&&e.width===0&&e.height===0}var V={position:`fixed`,visibility:`hidden`};function We({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,anchorId:a,children:o}){let s=(0,E.useRef)(null),[c,l]=(0,E.useState)(V),u=(0,E.useRef)(null),d=(0,E.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,d=window.innerHeight,f=o.width>0&&o.height>0,p=r?r.getBoundingClientRect():null,m=(e,t)=>console.error(`[anchored-popover] op=offscreen id=${i} left=${e} top=${t} w=${o.width} h=${o.height} viewport=${c},${d}`),h=e=>{e!==u.current&&(u.current=e,console.log(e))};if(h(`[anchored-popover] op=anchor id=${i} present=${!!r} rect=${p?`${p.left},${p.top},${p.width},${p.height}`:`none`}`),!p){let e=Math.max(4,c-o.width-Ue(c)),t=Math.max(4,d-o.height-14);l({position:`fixed`,left:e,top:t,visibility:`visible`}),h(`[anchored-popover] op=placed id=${i} left=${e} top=${t} w=${o.width} h=${o.height} flipped=false clampedLeft=false clampedRight=false`);return}if(f&&B(p)){l(V),m(p.left,p.top);return}let g=p.right-o.width,_=c-o.width-4,ee=!1,v=!1;g>_&&(g=_,ee=!0),g<4&&(g=4,v=!0);let y=d-p.bottom-4,te=p.top-4,b=o.height+8<=y?!1:o.height+8<=te?!0:te>y,x=Math.max(0,b?te:y),S=b?Math.max(4,p.top-Math.min(o.height,x)):p.bottom;l({position:`fixed`,left:g,top:S,maxHeight:x,visibility:`visible`}),h(`[anchored-popover] op=placed id=${i} left=${g} top=${S} w=${o.width} h=${o.height} maxH=${x} flipped=${b} clampedLeft=${v} clampedRight=${ee}`);let ne=Math.min(o.height,x);f&&(g+o.width<=0||g>=c||S+ne<=0||S>=d)&&m(g,S)},[e,a,n]);return(0,E.useLayoutEffect)(()=>{if(d(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>d());return s.current&&e.observe(s.current),()=>e.disconnect()},[d]),(0,E.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,z.createPortal)((0,T.jsx)(`div`,{ref:s,className:n,role:r,"aria-label":i,style:c,children:o}),document.body)}function Ge({actions:e,disabled:t}){let[n,i]=(0,E.useState)(!1),[a,o]=(0,E.useState)(null),s=(0,E.useRef)(null),c=(0,E.useCallback)(()=>{i(!1),o(null)},[]);return(0,T.jsxs)(`div`,{className:`conv-actions`,children:[(0,T.jsx)(`button`,{ref:s,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>i(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Session actions`,title:`Session actions`,children:(0,T.jsx)(r,{size:12})}),n&&(0,T.jsx)(We,{anchorRef:s,onClose:c,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,T.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,T.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,T.jsx)(`span`,{children:e.menuLabel})]}),a===e.key&&(0,T.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,T.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,T.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var H=`claude-opus-5[1m]`,Ke=`claude-sonnet-5`,U=`claude-haiku-4-5`,qe={[H]:`Opus 5 (1M context)`,[Ke]:`Sonnet 5`,[U]:`Haiku 4.5`};function W(e){return qe[e]??e}var Je=[H,Ke,U];function G(e){return e.replace(/\[1m\]$/,``)}function Ye(e){return Je.find(t=>G(t)===G(e))??e}var Xe=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],Ze=[`low`,`medium`,`high`,`xhigh`];[...Xe],[...Ze],[...Ze];var Qe=[H,Ke,U],$e={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},et=Xe.map(e=>({value:e,label:$e[e]??e})),K={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},tt=Ze.map(e=>({value:e,label:K[e]??e}));function q(e){if(e){let t=Qe.find(t=>G(t)===G(e));if(t)return t}return H}function nt({row:e,adminFetch:t,onError:n}){let[r,i]=(0,E.useState)(()=>q(e.model)),[a,o]=(0,E.useState)(``),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(!1),d=(0,E.useRef)(!1);(0,E.useEffect)(()=>{i(q(e.model))},[e.model]);let p=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,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`label`,{className:`reseat-field`,children:[(0,T.jsx)(`span`,{children:`Model`}),(0,T.jsx)(`select`,{"data-kind":`model`,value:r,disabled:l,onChange:e=>i(e.target.value),children:Qe.map(e=>(0,T.jsx)(`option`,{value:e,children:W(e)},e))})]}),(0,T.jsxs)(`label`,{className:`reseat-field`,children:[(0,T.jsx)(`span`,{children:`Mode`}),(0,T.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:l,onChange:e=>o(e.target.value),children:[(0,T.jsx)(`option`,{value:``,children:`Keep current`}),et.map(e=>(0,T.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,T.jsxs)(`label`,{className:`reseat-field`,children:[(0,T.jsx)(`span`,{children:`Effort`}),(0,T.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:l,onChange:e=>c(e.target.value),children:[(0,T.jsx)(`option`,{value:``,children:`Keep current`}),tt.map(e=>(0,T.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,T.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:l,"aria-busy":l,onClick:()=>void p(),children:l?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(f,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function rt(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 it(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function at({target:e,anchorEl:t,onConfirm:n,onCancel:r}){let i=(0,E.useRef)(null);return i.current=t,e?(0,T.jsxs)(We,{anchorRef:i,onClose:r,className:`conv-delete-confirm`,role:`alertdialog`,ariaLabel:`Confirm delete session`,children:[(0,T.jsxs)(`div`,{className:`claude-info-header`,children:[(0,T.jsx)(`span`,{children:`Delete this conversation?`}),(0,T.jsx)(`button`,{className:`claude-info-close`,onClick:r,"aria-label":`Close`,children:`✕`})]}),(0,T.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[(0,T.jsxs)(`div`,{className:`conv-delete-target`,children:[(0,T.jsx)(`span`,{className:`conv-delete-label`,title:e.title,children:e.title||`Untitled session`}),(0,T.jsx)(`code`,{className:`conv-delete-id`,title:e.sessionId,children:e.sessionId.slice(0,8)})]}),(0,T.jsx)(`div`,{style:{marginTop:`8px`},children:`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`}),e.live&&(0,T.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,T.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,T.jsx)(O,{variant:`danger`,size:`sm`,style:{flex:1},onClick:n,children:`Delete`}),(0,T.jsx)(O,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:r,children:`Cancel`})]})]}):null}function ot({open:e,count:t,liveCount:n,onConfirm:r,onCancel:i}){if(!e)return null;let a=t===1?``:`s`;return(0,T.jsx)(`div`,{className:`claude-info-overlay`,onClick:i,children:(0,T.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete sessions`,children:[(0,T.jsxs)(`div`,{className:`claude-info-header`,children:[(0,T.jsxs)(`span`,{children:[`Delete `,t,` conversation`,a,`?`]}),(0,T.jsx)(`button`,{className:`claude-info-close`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,T.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,T.jsxs)(`div`,{style:{marginTop:`8px`},children:[n,` `,n===1?`is`:`are`,` running and will be stopped first.`]})]}),(0,T.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,T.jsxs)(O,{variant:`danger`,size:`sm`,style:{flex:1},onClick:r,children:[`Delete `,t]}),(0,T.jsx)(O,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:i,children:`Cancel`})]})]})})}function st(e){return`New session: ${e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}`}function ct({open:e,pending:t,onConfirm:n,onCancel:r,now:i}){let[a,o]=(0,E.useState)(``),s=(0,E.useRef)(null),c=(0,E.useRef)(null),l=(0,E.useRef)(!1);if((0,E.useEffect)(()=>{if(!e){c.current=null,l.current=!1;return}if(c.current!==null)return;let t=st(i?i():new Date);c.current=t,o(t)},[e,i]),(0,E.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,T.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>p(`backdrop`),children:(0,T.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Name this session`,children:[(0,T.jsxs)(`div`,{className:`claude-info-header`,children:[(0,T.jsx)(`span`,{children:`Name this session`}),(0,T.jsx)(`button`,{className:`claude-info-close`,onClick:()=>p(`cancel`),"aria-label":`Close`,disabled:t,children:`✕`})]}),(0,T.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`},children:[(0,T.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,T.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,T.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,T.jsx)(O,{variant:`primary`,size:`sm`,style:{flex:1},disabled:!d||t,onClick:f,children:t?`Starting…`:`Start session`}),(0,T.jsx)(O,{variant:`secondary`,size:`sm`,style:{flex:1},disabled:t,onClick:()=>p(`cancel`),children:`Cancel`})]})]})})}var lt=`auth-refresh-failed`;function ut({error:e,onClose:t}){if(!e)return null;let n=e.reason===lt,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,T.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,T.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,T.jsxs)(`div`,{className:`claude-info-header`,children:[(0,T.jsx)(`span`,{children:r}),(0,T.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,T.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,T.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,T.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,T.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function dt(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,E.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,T.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,T.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,T.jsxs)(`div`,{className:`claude-info-header`,children:[(0,T.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,T.jsx)(`span`,{children:`Claude Code`}),(0,T.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,T.jsxs)(`div`,{className:`claude-info-section`,children:[(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,T.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,T.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,T.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,T.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,T.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,T.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,T.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,T.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,T.jsxs)(`div`,{className:`claude-info-section`,children:[(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,T.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,T.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,T.jsx)(`span`,{className:`claude-info-value`,children:p>0?it(p):`—`})]}),(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,T.jsx)(`span`,{className:`claude-info-value`,children:rt(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,T.jsxs)(`div`,{className:`claude-info-row`,children:[(0,T.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,T.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 ie(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function ft({open:e,onConnect:t,onClose:n}){return e?(0,T.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,T.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,T.jsxs)(`div`,{className:`claude-info-header`,children:[(0,T.jsx)(`span`,{children:`Claude isn’t connected`}),(0,T.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,T.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,T.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,T.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,T.jsx)(O,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,T.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function pt(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 mt(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function J(e){return e.toLocaleString(`en-GB`)}function ht(e){return`£${e.toFixed(2)}`}function gt(e){let t=[`Day`,`Active`,`Output tokens`,`Input tokens`,`Cache write`,`Cache read`,`Opus 5 (GBP)`,`Sonnet 5 (GBP)`],n=(e,t)=>[e,pt(mt(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 _t({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,T.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,T.jsx)(r,{className:`usage-day`,children:e}),(0,T.jsx)(r,{children:pt(mt(t))}),(0,T.jsx)(r,{children:J(t.tokens.output)}),(0,T.jsx)(r,{children:J(t.tokens.input)}),(0,T.jsx)(r,{children:J(t.tokens.cacheWrite)}),(0,T.jsx)(r,{children:J(t.tokens.cacheRead)}),(0,T.jsx)(r,{children:ht(t.costGBP.opus)}),(0,T.jsx)(r,{children:ht(t.costGBP.sonnet)})]})}function vt({show:e,onClose:t,anchorEl:n,sessionId:r,summary:i,loading:a,error:o}){let s=(0,E.useRef)(null);if(s.current=n,!e)return null;let c=!!i&&i.days.length>0;return(0,T.jsxs)(We,{anchorRef:s,onClose:t,className:`usage-popover`,role:`dialog`,ariaLabel:`Session usage and cost`,anchorId:r??void 0,children:[(0,T.jsxs)(`div`,{className:`claude-info-header`,children:[(0,T.jsxs)(`span`,{children:[`Usage & cost`,r?` · ${r.slice(0,8)}`:``]}),c&&(0,T.jsx)(`button`,{className:`usage-download`,onClick:()=>{if(!i)return;let e=new Blob([gt(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,T.jsx)(u,{size:14})}),(0,T.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,T.jsx)(ce,{size:14})})]}),(0,T.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[a&&(0,T.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!a&&o&&(0,T.jsx)(`div`,{className:`usage-note usage-error`,children:o}),!a&&!o&&i&&i.days.length===0&&(0,T.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!a&&!o&&i&&i.days.length>0&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`usage-table-scroll`,children:(0,T.jsxs)(`table`,{className:`usage-table`,children:[(0,T.jsx)(`thead`,{children:(0,T.jsxs)(`tr`,{children:[(0,T.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,T.jsx)(`th`,{children:`Active`}),(0,T.jsx)(`th`,{children:`Output tok`}),(0,T.jsx)(`th`,{children:`Input tok`}),(0,T.jsx)(`th`,{children:`Cache write`}),(0,T.jsx)(`th`,{children:`Cache read`}),(0,T.jsx)(`th`,{children:`Opus 5 (£)`}),(0,T.jsx)(`th`,{children:`Sonnet 5 (£)`})]})}),(0,T.jsxs)(`tbody`,{children:[i.days.map(e=>(0,T.jsx)(_t,{label:e.date,d:e},e.date)),(0,T.jsx)(_t,{label:`TOTAL (${i.days.length} d)`,d:i.totals,bold:!0})]})]})}),(0,T.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 yt=`https://claude.ai/code`,bt=200,xt=[500,1e3,1500,2e3,2500,3e3,3e3];function St(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:`${yt}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function Ct(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function wt(e){let{businessName:r,cacheKey:o,onConnectClaude:c,role:l,userName:u,userAvatar:h,onSelectProjects:y,onSelectTasks:re,onCloseMobileDrawer:C,collapsed:ie,onSelectData:ae,initialDataSurface:ce=!1,onLogout:ue,onDisconnect:D,disconnecting:fe,claudeConnected:O=!0,subAccounts:A,activeAccountId:Te,switchingAccount:Ee,onSwitchAccount:De,refreshAccounts:Oe,onOpenConversations:j}=e,M=oe(o),ke=(0,E.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,T.jsx)(xe,{size:12}),panel:()=>(0,T.jsx)(nt,{row:e,adminFetch:M,onError:e=>L({message:e,failed:!0})})}),[M]),Ae=p.productName,je=r||Ae,Me=typeof u==`string`?u:u===null?`name unavailable`:je,Ne=(Me.trim().charAt(0)||`?`).toUpperCase(),[Pe,Fe]=(0,E.useState)(ce?`data`:`sessions`),[Ie,Le]=(0,E.useState)(!1),[N,P]=(0,E.useState)(!1),Re=!ie&&(A?.length??0)>1&&!!De,F=A?.find(e=>e.isHouse)??null,ze=(0,E.useCallback)(()=>{if(F){if(F.accountId===Te){console.info(`[admin-ui] op=subaccount-switch-house anchor=brand-icon accountId=${F.accountId.slice(0,8)} switched=false reason=already-house`);return}console.info(`[admin-ui] op=subaccount-switch-house anchor=brand-icon accountId=${F.accountId.slice(0,8)} switched=true`),P(!1),De?.(F.accountId,`/`)}},[F,Te,De]),[I,L]=(0,E.useState)(null),[Be,R]=(0,E.useState)(null),[Ve,He]=(0,E.useState)(!1),[z,Ue]=(0,E.useState)([]),[B]=(0,E.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`session`)),[V,We]=(0,E.useState)(!1),[H,Ke]=(0,E.useState)(null),[U,qe]=(0,E.useState)(!1),[W,Je]=(0,E.useState)(!1),[G,Ye]=(0,E.useState)(!1),[Xe,Ze]=(0,E.useState)(null),[Qe,$e]=(0,E.useState)(new Set),et=(0,E.useRef)(new Map),[K,tt]=(0,E.useState)(!1),[q,rt]=(0,E.useState)(new Set),[it,st]=(0,E.useState)(!1),[lt,dt]=(0,E.useState)(null),[pt,mt]=(0,E.useState)(new Set),[J,ht]=(0,E.useState)(new Set),[gt,_t]=(0,E.useState)(new Set),[yt,wt]=(0,E.useState)(null),[Tt,Y]=(0,E.useState)(``),[Ot,kt]=(0,E.useState)(!1),[At,jt]=(0,E.useState)(null),[Mt,Nt]=(0,E.useState)(null),[Pt,Ft]=(0,E.useState)(!1),[It,Lt]=(0,E.useState)(null),[X,Rt]=(0,E.useState)(!1),[zt,Bt]=(0,E.useState)(!1),Vt=(0,E.useRef)(0);(0,E.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>L(null),2500);return()=>clearTimeout(e)},[I]);let Ht=B!=null&&z.some(e=>e.sessionId===B);(0,E.useEffect)(()=>{B==null||!V||console.info(`[sidebar-sessions] op=select-highlight session=${B.slice(0,8)} matched=${Ht}`)},[B,Ht,V]);let Z=(0,E.useCallback)(async()=>{if(!o)return null;let e=++Vt.current;qe(!0),Ke(null);try{let t=await M(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===Vt.current?(Ue(r),Ze(n.accountId??null),We(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===Vt.current&&Ke(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===Vt.current&&qe(!1)}},[o,M]);(0,E.useEffect)(()=>{!o||V||Z()},[o,V,Z]),(0,E.useEffect)(()=>{if(!o)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Z()}function n(){e===null&&(e=setInterval(t,Et))}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)}},[o,Z]);let Ut=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Z()},Wt=()=>{Fe(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${ie}`),ae(),C()},Q=typeof window<`u`&&window.location?.pathname||`/`,Gt=Pe===`data`,Kt=typeof window<`u`&&window.location?.search||``,qt=new URLSearchParams(Kt),Jt=qt.has(`label`)&&!qt.has(`nodeId`),$=e=>{C(),window.location.href=e},Yt=[{key:`dashboard`,label:`Dashboard`,icon:(0,T.jsx)(x,{size:17,strokeWidth:1.75}),active:Q===`/`&&!Gt,onClick:()=>$(`/`)},{key:`chat`,label:`Chat`,icon:(0,T.jsx)(i,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/chat`),onClick:()=>$(`/chat`)},{key:`tasks`,label:`Tasks`,icon:(0,T.jsx)(ye,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/tasks`),onClick:()=>{re(),C()}},{key:`calendar`,label:`Calendar`,icon:(0,T.jsx)(a,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/calendar`),onClick:()=>$(`/calendar`)},{key:`routines`,label:`Routines`,icon:(0,T.jsx)(we,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/routines`),onClick:()=>$(`/routines`)},{key:`skills`,label:`Skills`,icon:(0,T.jsx)(Se,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/skills`),onClick:()=>$(`/skills`)},{key:`agents`,label:`Agents`,icon:(0,T.jsx)(he,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/agents`),onClick:()=>$(`/agents`)},{key:`data`,label:`Data`,icon:(0,T.jsx)(d,{size:17,strokeWidth:1.75}),active:Gt,onClick:Wt},{key:`container`,label:g().term,icon:(0,T.jsx)(b,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/graph`)&&Jt,onClick:()=>{y(),C()}},{key:`graph`,label:`Graph`,icon:(0,T.jsx)(Ce,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/graph`)&&!Jt,onClick:()=>$(`/graph`)},{key:`activity`,label:`Activity`,icon:(0,T.jsx)(s,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/activity`),onClick:()=>$(`/activity`)},{key:`browser`,label:`Browser`,icon:(0,T.jsx)(t,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/browser`),onClick:()=>$(`/browser`)}],Xt=(0,E.useCallback)(async e=>{if(pt.has(e.sessionId))return;mt(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await M(`/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=St(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(C(),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}`),R(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}`),R({sessionId:e.sessionId,reason:r})}finally{mt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[M,C,pt]),Zt=(0,E.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=xt.length;n++){await new Promise(e=>setTimeout(e,xt[n-1]));let r=await Z();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Z]),Qt=(0,E.useCallback)(async e=>{if(!X){Rt(!0),console.info(`[admin-ui] new-session-modal op=submit surface=sidebar titleLen=${e.length}`);try{let t=await M(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:e})}),n=await t.json().catch(()=>({})),r=St(t.ok,t.status,n);console.info(`[admin-ui] sidebar-new-session-spawned status=${t.status} outcome=${r.kind} slug=${n.slug??n.bridgeSessionId??`none`}`),r.kind===`navigate`?r.sameOrigin?(console.info(`[admin-ui] new-session-modal op=navigate surface=sidebar sessionId=${(n.sessionId??``).slice(0,8)} titleSource=${n.titleSource??`none`}`),window.location.assign(r.url)):(window.open(r.url,`_blank`),n.sessionId?Zt(n.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):t.status===503||r.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),Bt(!1),He(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${t.status} reason=${r.reason}`),Bt(!1),R(r))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),Bt(!1),R({sessionId:null,reason:t})}finally{Rt(!1)}}},[M,X,Zt]),$t=(0,E.useCallback)((e,t)=>{e.stopPropagation(),dt(t)},[]),en=(0,E.useCallback)(async(e,t)=>{e.stopPropagation(),jt(t),Nt(null),Lt(null),Ft(!0);try{let e=await M(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?Nt(n):Lt(n.error??`status ${e.status}`)}catch(e){Lt(e instanceof Error?e.message:String(e))}finally{Ft(!1)}},[M]),tn=(0,E.useCallback)(async(e,t={})=>{let n=t.refresh??!0;if(Qe.has(e.sessionId))return!1;$e(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await M(`/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}let r=await t.json();return console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${r.pidKilled??`?`} deleted=${r.deleted??`?`}`),Ue(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{$e(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[M,Qe,Z]),nn=(0,E.useCallback)(e=>{rt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),rn=(0,E.useCallback)(()=>{tt(!1),rt(new Set)},[]),an=(0,E.useCallback)(async()=>{let e=[...q].map(e=>z.find(t=>t.sessionId===e)).filter(e=>!!e),t=e.filter(e=>e.live).length;console.info(`[admin-ui] sidebar-bulk-delete op=start count=${e.length} live=${t}`);let n=(await Promise.all(e.map(e=>tn(e,{refresh:!1})))).filter(Boolean).length;console.info(`[admin-ui] sidebar-bulk-delete op=done requested=${e.length} ok=${n} failed=${e.length-n}`),Z(),rn()},[q,z,tn,Z,rn]),on=(0,E.useCallback)(async(e,t)=>{if(e.stopPropagation(),!J.has(t.sessionId)){ht(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await M(`/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}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),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{ht(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,J,Z]),sn=(0,E.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!gt.has(t.sessionId)){_t(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await M(`/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}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),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{_t(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,gt,Z]),cn=(0,E.useCallback)(async e=>{let t=Tt.trim();if(!t){L({message:`Title can’t be empty`,failed:!0});return}if(t.length>bt){L({message:`Title too long (max ${bt})`,failed:!0});return}kt(!0);try{let n=await M(`/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}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),wt(null),Y(``),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{kt(!1)}},[M,Tt,Z]);return(0,T.jsxs)(`aside`,{className:`side`,children:[(0,T.jsxs)(`div`,{className:`side-brand`,children:[Re?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,className:`side-brand-icon-btn`,"aria-label":`Switch to house account`,disabled:!F,onClick:ze,children:(0,T.jsx)(`img`,{className:`side-brand-icon`,src:le,alt:``,"aria-hidden":`true`})}),(0,T.jsxs)(`button`,{type:`button`,className:`side-brand-trigger`,"aria-haspopup":`menu`,"aria-expanded":N,"aria-label":`Switch sub-account`,onClick:()=>{let e=!N;P(e),e&&Oe?.(),console.info(`[admin-ui] op=subaccount-switcher-toggle anchor=brand-head open=${e} available=true accounts=${A?.length??0}`)},children:[(0,T.jsxs)(`span`,{className:`side-brand-lockup`,children:[(0,T.jsx)(`span`,{className:`side-brand-business`,children:je}),(0,T.jsx)(`span`,{className:`side-brand-product`,children:p.productName})]}),(0,T.jsx)(ge,{size:14,className:`side-brand-caret`,"aria-hidden":`true`})]})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`img`,{className:`side-brand-icon`,src:le,alt:``,"aria-hidden":`true`}),(0,T.jsxs)(`span`,{className:`side-brand-lockup`,children:[(0,T.jsx)(`span`,{className:`side-brand-business`,children:je}),(0,T.jsx)(`span`,{className:`side-brand-product`,children:p.productName})]})]}),N&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`side-brand-scrim`,"aria-hidden":`true`,onClick:()=>P(!1)}),(0,T.jsx)(te,{open:N,accounts:A??[],activeAccountId:Te??null,switching:Ee??!1,onSelect:e=>De?.(e),onClose:()=>P(!1)})]})]}),(0,T.jsx)(`nav`,{className:`side-nav`,children:Yt.map(e=>(0,T.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,T.jsx)(`span`,{className:`label`,children:e.label}),(0,T.jsx)(`span`,{className:`kbd`})]},e.key))}),(()=>{let e=z.filter(e=>W?!0:!e.isSubagent).filter(e=>G?!0:!e.archived),t=z.some(e=>e.isSubagent),r=z.some(e=>e.archived);return(0,T.jsx)(`div`,{className:`side-sessions`,children:(0,T.jsxs)(`div`,{className:`side-list`,children:[(0,T.jsxs)(`div`,{className:`group-head`,children:[(0,T.jsx)(`span`,{children:`Sessions`}),(0,T.jsxs)(`span`,{className:`group-head-meta`,children:[(0,T.jsx)(`button`,{type:`button`,className:`group-head-select${K?` active`:``}`,"aria-pressed":K,title:K?`Exit select mode`:`Select multiple sessions to delete`,onClick:()=>{tt(e=>!e),rt(new Set),wt(null),Y(``)},children:`Select`}),(0,T.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Ut,disabled:U,children:(0,T.jsx)(n,{size:12,className:U?`spinning`:void 0})}),(0,T.jsx)(`span`,{children:U?`…`:String(e.length)}),(0,T.jsxs)(`button`,{type:`button`,className:`admin-btn-cta side-sessions-new`,onClick:()=>{console.info(`[admin-ui] new-session-modal op=open surface=sidebar default=applied`),Bt(!0)},disabled:X,"aria-busy":X,"aria-label":X?`Spawning session`:`New session`,title:X?`Spawning session`:`New session`,children:[X?(0,T.jsx)(f,{size:13,className:`spinning`}):(0,T.jsx)(se,{size:13}),(0,T.jsx)(`span`,{children:X?`Spawning…`:`New session`})]})]})]}),K&&(0,T.jsxs)(`div`,{className:`session-select-bar`,children:[(0,T.jsxs)(`span`,{className:`session-select-count`,children:[q.size,` selected`]}),(0,T.jsxs)(`button`,{type:`button`,className:`session-select-delete`,disabled:q.size===0,onClick:()=>st(!0),children:[`Delete `,q.size]}),(0,T.jsx)(`button`,{type:`button`,className:`session-select-cancel`,onClick:rn,children:`Cancel`})]}),Xe&&(0,T.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,T.jsx)(`code`,{children:Xe})}),(t||r)&&(0,T.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,T.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${W?` active`:``}`,"aria-pressed":W,onClick:()=>Je(e=>!e),title:W?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),r&&(0,T.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${G?` active`:``}`,"aria-pressed":G,onClick:()=>Ye(e=>!e),title:G?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),H&&(0,T.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:H}),V&&!H&&e.length===0&&(0,T.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=Ct(e.startedAt),n=pt.has(e.sessionId),r=Qe.has(e.sessionId),i=J.has(e.sessionId),a=gt.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,T.jsx)(ve,{size:12}),busy:n,onClick:()=>{Xt(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,T.jsx)(be,{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,T.jsx)(k,{size:12}),onClick:t=>{en(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,T.jsx)(w,{size:12}),busy:i,onClick:t=>{on(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,T.jsx)(pe,{size:12}),busy:a,onClick:t=>{sn(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,T.jsx)(me,{size:12}),busy:a,onClick:t=>{sn(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,T.jsx)(m,{size:12}),busy:Ot&&yt===e.sessionId,onClick:t=>{t.stopPropagation(),wt(e.sessionId),Y(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,T.jsx)(ee,{size:12}),danger:!0,busy:r,onClick:t=>{$t(t,e)}},ke({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`?_({operatorName:e.personName??null,whatsappName:e.whatsappName??null,senderId:e.senderId,title:e.title,channel:e.channel}):e.personName??e.title;return(0,T.jsxs)(`div`,{ref:t=>{let n=et.current;t?n.set(e.sessionId,t):n.delete(e.sessionId)},className:`conv conv-with-actions${l}${e.sessionId===B?` active`:``}`,children:[(0,T.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${d} in webchat`,onClick:()=>{if(yt!==e.sessionId){if(K){nn(e.sessionId);return}s()}},onKeyDown:t=>{yt!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),K?nn(e.sessionId):s())},children:[K&&(0,T.jsx)(`span`,{className:`conv-select-check`,onClick:e=>e.stopPropagation(),children:(0,T.jsx)(de,{checked:q.has(e.sessionId),ariaLabel:`Select ${d}`,onChange:()=>nn(e.sessionId)})}),(0,T.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,T.jsxs)(`span`,{className:`conv-stack`,children:[(0,T.jsxs)(`span`,{className:`conv-name-line`,children:[u&&(0,T.jsx)(v,{channel:e.channel,size:13}),yt===e.sessionId?(0,T.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,onFocus:e=>e.currentTarget.select(),value:Tt,disabled:Ot,"aria-label":`New title for session ${e.title}`,onChange:e=>Y(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),cn(e)):t.key===`Escape`&&(t.preventDefault(),wt(null),Y(``))},onBlur:()=>{yt===e.sessionId&&!Ot&&(wt(null),Y(``))}}):(0,T.jsx)(`span`,{className:`conv-name`,title:d,children:d})]}),(0,T.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,T.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,T.jsxs)(`span`,{children:[` · `,t]})]})]})]}),!K&&(0,T.jsx)(Ge,{actions:c,disabled:o})]},e.sessionId)})]})})})(),(0,T.jsxs)(`div`,{className:`side-foot`,children:[(0,T.jsx)(`div`,{className:`avatar`,children:h?(0,T.jsx)(`img`,{src:h,alt:Me}):Ne}),(0,T.jsxs)(`div`,{className:`who`,children:[(0,T.jsx)(`span`,{className:`name`,children:Me}),(0,T.jsx)(Dt,{})]}),(0,T.jsx)(`button`,{type:`button`,className:`side-foot-kebab`,"aria-label":`Account menu`,"aria-haspopup":`menu`,"aria-expanded":Ie,onClick:()=>Le(e=>!e),children:(0,T.jsx)(_e,{size:16})}),Ie&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`side-foot-menu-scrim`,"aria-hidden":`true`,onClick:()=>Le(!1)}),(0,T.jsx)(`div`,{className:`side-foot-menu`,role:`menu`,children:(0,T.jsx)(S,{variant:`admin`,onCloseMenu:()=>Le(!1),onLogout:ue??(()=>{}),onDisconnect:D,disconnecting:fe,claudeConnected:O,onConnectClaude:c,cacheKey:o,onOpenConversations:j})})]})]}),I&&(0,T.jsx)(`div`,{className:`copy-toast${I.failed?` copy-toast-failed`:``}`,role:`status`,children:I.message}),(0,T.jsx)(ct,{open:zt,pending:X,onConfirm:e=>{Qt(e)},onCancel:e=>{console.info(`[admin-ui] new-session-modal op=cancel surface=sidebar via=${e}`),Bt(!1)}}),(0,T.jsx)(ut,{error:Be,onClose:()=>R(null)}),(0,T.jsx)(ft,{open:Ve,onConnect:()=>{He(!1),c?.()},onClose:()=>He(!1)}),(0,T.jsx)(at,{target:lt,anchorEl:lt?et.current.get(lt.sessionId)??null:null,onCancel:()=>dt(null),onConfirm:()=>{let e=lt;dt(null),e&&tn(e)}},lt?.sessionId??`none`),(0,T.jsx)(ot,{open:it,count:q.size,liveCount:z.filter(e=>q.has(e.sessionId)&&e.live).length,onConfirm:()=>{st(!1),an()},onCancel:()=>st(!1)}),(0,T.jsx)(vt,{show:At!==null,onClose:()=>{jt(null),Nt(null),Lt(null)},anchorEl:At?et.current.get(At.sessionId)??null:null,sessionId:At?.sessionId??null,summary:Mt,loading:Pt,error:It},At?.sessionId??`none`)]})}var Tt=5e3,Et=3e4;function Dt(){let[e,t]=(0,E.useState)(null);if((0,E.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()},Tt))}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,T.jsxs)(`span`,{className:d.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,T.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),` · `,(0,T.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]})]})}var Y=`admin-sidebar-collapsed`,Ot=`admin-sidebar-drawer-open`,kt=1080;function At(){if(typeof window>`u`)return!1;let e=null;try{e=window.sessionStorage.getItem(Y)}catch{e=null}return e===null?typeof window.matchMedia==`function`?window.matchMedia(`(min-width: 721px) and (max-width: ${kt}px)`).matches:!1:e===`1`}function jt(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Y,`1`):window.sessionStorage.removeItem(Y)}catch{}}function Mt(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Ot)===`1`}catch{return!1}}function Nt(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Ot,`1`):window.sessionStorage.removeItem(Ot)}catch{}}function Pt(e){let[t,n]=(0,E.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,E.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 Ft=720;function It(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function Lt(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function X(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 Rt(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function zt(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`}function Bt(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:s,onConnectClaude:c,userName:l,userAvatar:u,role:d,onOpenConversations:f,children:p,footer:m}=e,{subAccounts:_,activeAccountId:ee,switching:v,switchAccount:te,refreshAccounts:b}=ae(t),[x,S]=(0,E.useState)([]),ne=(0,E.useCallback)(e=>{S(t=>t.filter(t=>t.waMessageId!==e))},[]);(0,E.useEffect)(()=>{if(!t)return;let e=null;try{e=new EventSource(h(`/api/admin/events`,t)),e.addEventListener(je,e=>{try{let t=JSON.parse(e.data);if(!t||typeof t.waMessageId!=`string`)return;S(e=>e.some(e=>e.waMessageId===t.waMessageId)?e:[...e,t])}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]);let[C,ie]=(0,E.useState)(!0);(0,E.useEffect)(()=>{if(s!==void 0||r!==`admin`)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||ie(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[s,r]);let oe=s??C,se=c??(()=>{window.location.assign(`/?connect=claude`)}),[w,ce]=(0,E.useState)(()=>At()),[le,ue]=(0,E.useState)(!1),de=(0,E.useRef)(!0);(0,E.useEffect)(()=>{if(de.current){de.current=!1;return}ue(!0);let e=setTimeout(()=>ue(!1),260);return()=>clearTimeout(e)},[w]);let[D,fe]=(0,E.useState)(()=>Mt()),O=Pt(`(max-width: ${Ft}px)`),[pe,me]=(0,E.useState)(()=>typeof window>`u`||Rt(window.location.pathname,window.location.search)?null:X(window.location.pathname,window.location.search)),[he,ge]=(0,E.useState)(()=>typeof window>`u`?!1:Rt(window.location.pathname,window.location.search)),[_e]=(0,E.useState)(()=>he),ve=(0,E.useCallback)(e=>{jt(e),ce(e)},[]),k=(0,E.useCallback)(e=>{Nt(e),fe(e)},[]);(0,E.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${w} drawer=${D}`)},[]),(0,E.useEffect)(()=>{typeof window>`u`||!pe||(console.info(`[admin-ui] wa-hydrate route=/ remoteJid=${pe.remoteJid??``}`),window.history.replaceState(null,``,`/`))},[]),(0,E.useEffect)(()=>{typeof window>`u`||!he||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let ye=(0,E.useCallback)(e=>{if(ge(!1),e===null){me(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=It(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?me(e):window.location.href=n.href},[]),be=(0,E.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=Lt(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}me(null),ge(!0)},[]),A=O?D:!w,xe=(0,E.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${Ft}px)`).matches){let e=D;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),k(!e)}else{let e=w;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),ve(!e)}},[w,D,ve,k]),Se=(0,E.useCallback)(e=>{let t=zt(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),Ce={collapsed:w,mobileDrawerOpen:D,sidebarOpen:A,onToggleSidebar:xe,setMobileDrawerOpen:k,selectedWhatsapp:pe,onClearWhatsapp:()=>me(null),onSelectWhatsappConversation:ye,dataOpen:he};return r===`operator`?(0,T.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[v&&(0,T.jsx)(y,{surface:`switch`}),(0,T.jsx)(re,{businessName:n,variant:r,onNavigate:Se,onOpenConversations:f,onToggleSidebar:xe,sidebarOpen:A,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t,subAccounts:_,activeAccountId:ee,switchingAccount:v,onSwitchAccount:te,refreshAccounts:b}),(0,T.jsx)(`div`,{className:`platform platform-operator`,children:typeof p==`function`?p(Ce):p}),(0,T.jsx)(N,{variant:`operator`,onOpenConversations:f}),m,(0,T.jsx)(Ae,{frames:x,onExpire:ne})]}):(0,T.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[v&&(0,T.jsx)(y,{surface:`switch`}),(0,T.jsxs)(`div`,{className:`platform${D?` menu-open`:``}${!O&&w?` sidebar-collapsed`:``}${le?` sidebar-animating`:``}`,"data-artefact":`closed`,children:[(0,T.jsx)(wt,{businessName:n,cacheKey:t,onConnectClaude:se,role:d??null,userName:l,userAvatar:u??null,onSelectProjects:()=>{window.location.href=`/graph?label=${g().label}`},onSelectTasks:()=>{window.location.href=`/tasks`},onCloseMobileDrawer:()=>k(!1),collapsed:w,mobileDrawerOpen:D,onSelectData:be,onCloseData:()=>ge(!1),initialDataSurface:_e,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:oe,subAccounts:_,activeAccountId:ee,switchingAccount:v,onSwitchAccount:te,refreshAccounts:b,onOpenConversations:f}),!O&&(0,T.jsx)(He,{}),(0,T.jsx)(Pe,{sidebarOpen:A,onToggleSidebar:xe,claudeConnected:oe,onConnectClaude:se}),typeof p==`function`?p(Ce):p]}),D&&(0,T.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>k(!1)}),(0,T.jsx)(N,{}),m,(0,T.jsx)(Ae,{frames:x,onExpire:ne})]})}export{he as C,de as D,O as E,ue as O,ge as S,pe as T,be as _,dt as a,ve as b,H as c,W as d,I as f,xe as g,Se as h,ft as i,Ke as l,we as m,Pt as n,ct as o,ze as p,St as r,U as s,Bt as t,Ye as u,ye as v,me as w,_e as x,k as y};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,H as n,J as r,K as i,U as a,_ as o,a as s,d as c,s as l,u,v as ee,x as te}from"./useSubAccountSwitcher-BEwQMRMo.js";import{n as d,t as f}from"./AdminLoginScreens-7Czw3MAC.js";import{f as ne,s as p,x as m}from"./useVoiceRecorder-CiDOh8PG.js";import{C as h,S as re,a as g,b as _,h as ie,t as v}from"./AdminShell-D5GApZ_n.js";import{n as ae}from"./file-download-Di_s0_4w.js";import{t as y}from"./chevron-left-CdUzxzeB.js";import{t as oe}from"./chevron-right-CKGwd-M0.js";import{n as b,r as x}from"./page-CNJl3tWT.js";import{t as se}from"./file-text-CP1KIrJV.js";import"./graph-labels-CgP17xHK.js";import"./CdpScreencastSurface-BbekDUFw.js";var S=i(),C=e(r(),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)(y,{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:r}){let i=ee(e),[o,d]=(0,C.useState)(null),[f,p]=(0,C.useState)(null),[m,g]=(0,C.useState)(null),v=(0,C.useRef)(!1),[y,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,a){let o=Date.now(),s=typeof n==`string`?n:`unresolved`;try{typeof n!=`string`&&(s=await n());let c=await i(s);if(!c.ok)throw Error(`status ${c.status}`);let l=await c.json();t||a(r(l)),console.info(`[admin-ui] op=dashboard-fetch slice=${e} url=${s} outcome=ok ms=${Date.now()-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 r(){if(!J.current){let e=await i(`/api/admin/accounts`);if(!e.ok)throw Error(`accounts status ${e.status}`);let t=await e.json(),n=t.accounts??[],r=t.activeAccountId??null,a=n.find(e=>e.accountId===r);if(!a)throw Error(`accounts: active ${r??`none`} absent from list of ${n.length}`);let o=a.isHouse||n.length===1;J.current={accountId:a.accountId,isHouse:o}}let{accountId:e,isHouse:t}=J.current;return console.info(`[admin-ui] op=dashboard-channels-source source=${t?`all`:`scoped`} account=${e.slice(0,8)}`),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`,r,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(console.info(`[admin-ui] op=dashboard-refresh-settled ms=${t}`),!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(a(`/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,i]);let Y=(0,C.useMemo)(()=>(o??[]).filter(e=>!e.isSubagent),[o]),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)(()=>{v.current||Z.length!==0&&(v.current=!0,g(Z[0].channel))},[Z]);let Q=(0,C.useRef)(!1);(0,C.useEffect)(()=>{Q.current||!B.has(`bookingLink`)||!B.has(`portalLink`)||(Q.current=!0,console.info(`[admin-ui] dashboard-public-pages booking=${k!=null} filedrop=${j!=null}`))},[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 i(`/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}console.info(`[admin-ui] dashboard-session-stop sessionId=${e}`),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})}}},[i,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}ae(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(y)}`:`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(y?.cpuPct??null)}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`RAM `,R(y?.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)(h,{size:16}):(0,w.jsx)(se,{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 i=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":i,onClick:()=>g(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)(c,{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:i?(0,w.jsx)(re,{size:14}):(0,w.jsx)(oe,{size:14})})]}),i?(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:()=>r(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:s(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){console.info(`[admin-ui] claude-info-open cached=true ms=0`);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)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}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)(o,{cacheKey:e.cacheKey,onSessionExpired:i,surface:`chat`,children:(0,w.jsx)(v,{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)(g,{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:s(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:s(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,{}));
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,H as n,J as r,K as i,L as a,M as o,O as s,T as c,_ as l,b as u,g as d,y as f}from"./useSubAccountSwitcher-BEwQMRMo.js";import{O as p,b as m,t as h}from"./AdminShell-D5GApZ_n.js";import{t as g}from"./chevron-left-CdUzxzeB.js";import{t as _}from"./chevron-right-CKGwd-M0.js";import{t as v}from"./clock-Cf8Oe9qi.js";var y=a(`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`}]]),b=a(`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`}]]),x=a(`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`}]]),S=a(`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`}]]),C=a(`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`}]]),w=i(),T=e(r(),1);function E(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function D(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function O(e){let t=E(e),n=t.getDay();return D(t,n===0?-6:1-n)}function k(e){let t=O(e);return Array.from({length:7},(e,n)=>D(t,n))}function A(e){let t=O(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>D(t,n))}function j(){return Array.from({length:24},(e,t)=>t)}function M(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function N(e,t){switch(e){case`day`:{let e=E(t);return{from:e,to:D(e,1)}}case`week`:{let e=O(t);return{from:e,to:D(e,7)}}case`month`:{let e=O(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:D(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function P(e,t,n){switch(e){case`day`:return D(t,n);case`week`:return D(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 F(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}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=n(),R=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],z=3;function ee(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function B({anchor:e,meetings:t,onSelect:n}){let r=A(e),i=e.getMonth(),a=new Date;return(0,L.jsxs)(`div`,{className:`cal-month`,children:[(0,L.jsx)(`div`,{className:`cal-weekday-row`,children:R.map(e=>(0,L.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,L.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>F(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=F(e,a);return(0,L.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,L.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,z).map(e=>(0,L.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...I(e,n),children:[!e.isAllDay&&(0,L.jsx)(`span`,{className:`cal-chip-time`,children:ee(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>z&&(0,L.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-z,` more`]})]},e.toISOString())})})]})}var V=1440,H=1.8;function U(e){return e.getHours()*60+e.getMinutes()}function W(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function G({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&F(new Date(t.startsAt),e));return(0,L.jsx)(`div`,{className:`cal-day-col`,children:(0,L.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,L.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=U(n),o=F(i,e)?U(i):V,s=a/V*100,c=Math.max((o-a)/V*100,H);return(0,L.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...I(t,r),children:[(0,L.jsx)(`span`,{className:`cal-event-time`,children:W(n)}),(0,L.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var K=44;function q(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function J({anchor:e,meetings:t,onSelect:n}){let r=k(e),i=new Date;return(0,L.jsxs)(`div`,{className:`cal-timed`,children:[(0,L.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,L.jsxs)(`div`,{className:`cal-day-head${F(e,i)?` cal-day-head-today`:``}`,children:[(0,L.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,L.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,L.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,L.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&F(new Date(t.startsAt),e)).map(e=>(0,L.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...I(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,L.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:j().map(e=>(0,L.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${K}px`},children:e===0?``:q(e)},e))}),r.map(e=>(0,L.jsx)(G,{day:e,meetings:t,hourHeight:K,onSelect:n},e.toISOString()))]})]})}var Y=52;function X(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function Z({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&F(new Date(t.startsAt),e));return(0,L.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,L.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,L.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,L.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...I(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,L.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:j().map(e=>(0,L.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${Y}px`},children:e===0?``:X(e)},e))}),(0,L.jsx)(G,{day:e,meetings:t,hourHeight:Y,onSelect:n})]})]})}var te=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function ne(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function re({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>ne(new Date(e.startsAt))));return(0,L.jsx)(`div`,{className:`cal-year`,children:(0,L.jsx)(`div`,{className:`cal-year-grid`,children:M(e).map(e=>{let t=A(e),a=e.getMonth();return(0,L.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,L.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,L.jsx)(`div`,{className:`cal-mini-weekrow`,children:te.map((e,t)=>(0,L.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,L.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=F(e,r),o=!t&&i.has(ne(e));return(0,L.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,L.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var ie={meeting:`Meeting`,event:`Event`,task:`Task`};function ae(e){let t=new Date(e),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 oe(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function se(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=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function ce(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function le(e,t){return e.email??`${e.name??`unknown`}-${t}`}function ue({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 de({meeting:e,adminFetch:t,onClose:n,onSaved:r,onDeleted:i}){let a=e.kind===`meeting`,[l,d]=(0,T.useState)(!1),[p,m]=(0,T.useState)(!1),[h,g]=(0,T.useState)(!1),[_,w]=(0,T.useState)(!1),[E,D]=(0,T.useState)(null),[O,k]=(0,T.useState)(e),[A,j]=(0,T.useState)(e.title??``),[M,N]=(0,T.useState)(ae(e.startsAt)),[P,F]=(0,T.useState)(e.endsAt?ae(e.endsAt):``),[I,R]=(0,T.useState)(e.location??``),[z,ee]=(0,T.useState)(e.privateNote??``),[B,V]=(0,T.useState)(``),[H,U]=(0,T.useState)(``);(0,T.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!_&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,n]);let W=(0,T.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=oe(M);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=P?oe(P):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=I.trim()||null;i!==(O.location??null)&&(e.location=i);let a=z.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,M,P,I,z,O]),G=(0,T.useCallback)(async()=>{let n=W();if(Object.keys(n).length===0){d(!1);return}w(!0),D(null);try{let i=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();k(a.meeting),r(a.meeting),d(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{w(!1)}},[t,W,e.meetingId,r]),K=(0,T.useCallback)(async()=>{let n=B.trim(),i=H.trim();if(!(!n&&!i)){w(!0),D(null);try{let a=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:i||void 0})});if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.json();k(o.meeting),r(o.meeting),V(``),U(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{w(!1)}}},[t,B,H,e.meetingId,r]),q=(0,T.useCallback)(async n=>{let i=n.email?{email:n.email}:{name:n.name};w(!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(i)});if(!n.ok)throw Error(`HTTP ${n.status}`);let a=await n.json();k(a.meeting),r(a.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{w(!1)}},[t,e.meetingId,r]),J=(0,T.useCallback)(async()=>{w(!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}`);i(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),w(!1)}},[t,e.meetingId,i]),Y=(0,T.useCallback)(async n=>{g(!1),w(!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=ce(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{w(!1)}},[t,e.meetingId]),X=ie[e.kind??`meeting`],Z=B.trim().length>0||H.trim().length>0;return(0,L.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{_||n()},children:(0,L.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":l?`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:X}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:_,children:(0,L.jsx)(f,{size:16})})]}),!l&&(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)(v,{size:14}),(0,L.jsx)(`span`,{children:se(O)})]}),O.location&&(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(b,{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)(C,{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)(ue,{a:e})},le(e,t)))})]}),O.privateNote&&(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,L.jsx)(x,{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)(y,{size:14}),(0,L.jsx)(`span`,{children:X})]})]}),l&&(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=>N(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:P,onChange:e=>F(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:I,onChange:e=>R(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)(ue,{a:e}),(0,L.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>q(e),disabled:_,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,L.jsx)(f,{size:13})})]},le(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:H,onChange:e=>U(e.target.value),disabled:_,"aria-label":`Attendee email`}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:K,disabled:_||!Z,"aria-label":`Add attendee`,children:_?(0,L.jsx)(s,{size:13,className:`spin`}):(0,L.jsx)(S,{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:z,onChange:e=>ee(e.target.value),disabled:_,rows:3,placeholder:`Only you and your team can see this.`})]})]}),E&&(0,L.jsx)(`div`,{className:`cal-modal-error`,children:E}),a&&(0,L.jsxs)(`div`,{className:`cal-modal-actions`,children:[!l&&!p&&!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)(c,{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)(u,{size:14}),` Delete`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?g(!0):Y(!1)},disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):(0,L.jsx)(o,{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:()=>Y(!0),disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):null,` Yes`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>Y(!1),disabled:_,children:`No`}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>g(!1),disabled:_,children:`Cancel`})]}),l&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:G,disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):null,` Save`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{d(!1),D(null)},disabled:_,children:`Cancel`})]}),p&&(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:J,disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):null,` Delete`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:_,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,fe=[`day`,`week`,`month`,`year`];function pe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=N(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function me(){let[e,t]=(0,T.useState)(null),[n,r]=(0,T.useState)(!1),[i,a]=(0,T.useState)(void 0),[o,s]=(0,T.useState)(null),[c,u]=(0,T.useState)(void 0),[f,m]=(0,T.useState)(null),[g,_]=(0,T.useState)(null);(0,T.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),u(e.userName===void 0?null:e.userName),m(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,T.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,T.useState)(!1),x=(0,T.useCallback)(async()=>{b(!0);try{let e=await p();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,L.jsx)(l,{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:c,userAvatar:f,role:g,children:(0,L.jsx)(he,{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)(d,{surface:`gate`})}function he({cacheKey:e}){let{adminFetch:n,sessionRefetchNonce:r}=t({initialCacheKey:e,surface:`calendar`}),[i,a]=(0,T.useState)(`month`),[o,c]=(0,T.useState)(()=>new Date),[l,u]=(0,T.useState)([]),[f,p]=(0,T.useState)(!1),[h,v]=(0,T.useState)(!1),[y,b]=(0,T.useState)(null),[x,S]=(0,T.useState)(null),[C,w]=(0,T.useState)(null);(0,T.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&&w(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[n]),(0,T.useEffect)(()=>{let e=!1,{from:t,to:r}=N(i,o);return p(!0),b(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();u(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(b(t instanceof Error?t.message:`Failed to load`),u([]))}).finally(()=>{e||(p(!1),v(!0))}),()=>{e=!0}},[i,o,r,n]);let E=(0,T.useCallback)(()=>c(new Date),[]),D=(0,T.useCallback)(()=>c(e=>P(i,e,-1)),[i]),O=(0,T.useCallback)(()=>c(e=>P(i,e,1)),[i]),k=(0,T.useCallback)(e=>{c(e),a(`month`)},[]);(0,T.useEffect)(()=>{S(null)},[i,o]);let A=(0,T.useCallback)(e=>{u(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),S(e)},[]),j=(0,T.useCallback)(e=>{u(t=>t.filter(t=>t.meetingId!==e)),S(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:pe(i,o)}),(0,L.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:D,"aria-label":`Previous`,children:(0,L.jsx)(g,{size:18})}),(0,L.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:O,"aria-label":`Next`,children:(0,L.jsx)(_,{size:18})}),(0,L.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:E,children:`Today`}),f&&(0,L.jsx)(s,{size:16,className:`spin`})]}),(0,L.jsx)(`div`,{className:`cal-views`,children:fe.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===i?` cal-view-btn-active`:``}`,onClick:()=>a(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),C&&(0,L.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${C}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,L.jsx)(m,{size:14}),` Booking page`]})]}),(0,L.jsxs)(`div`,{className:`cal-body`,children:[y&&(0,L.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,y]}),i===`day`&&(0,L.jsx)(Z,{anchor:o,meetings:l,onSelect:S}),i===`week`&&(0,L.jsx)(J,{anchor:o,meetings:l,onSelect:S}),i===`month`&&(0,L.jsx)(B,{anchor:o,meetings:l,onSelect:S}),i===`year`&&(0,L.jsx)(re,{anchor:o,meetings:l,onPickMonth:k})]}),x&&(0,L.jsx)(de,{meeting:x,adminFetch:n,onClose:()=>S(null),onSaved:A,onDeleted:j})]}):(0,L.jsx)(d,{surface:`gate`})}(0,w.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(me,{}));
@@ -1 +0,0 @@
1
- import{H as e,K as t}from"./useSubAccountSwitcher-BEwQMRMo.js";import"./useVoiceRecorder-CiDOh8PG.js";import"./AdminShell-D5GApZ_n.js";import{n}from"./page-CPVUAwb8.js";import"./useCopyFeedback-BvIRgs7W.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
- import{L as e}from"./useSubAccountSwitcher-BEwQMRMo.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
@@ -1 +0,0 @@
1
- import{L as e}from"./useSubAccountSwitcher-BEwQMRMo.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
@@ -1 +0,0 @@
1
- import{L as e}from"./useSubAccountSwitcher-BEwQMRMo.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]);export{t};
@@ -1 +0,0 @@
1
- import{H as e,K as t}from"./useSubAccountSwitcher-BEwQMRMo.js";import"./useVoiceRecorder-CiDOh8PG.js";import{t as n}from"./page-CNJl3tWT.js";import"./graph-labels-CgP17xHK.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
-  `�j[�2�[�M�"���V�������F�Z���l�x|�H����!&S�Q-p� ��;V��P��6}^_W�1B|�8�eB���Z�ܵ�c��P�}?����d���G�d�7�l
@@ -1 +0,0 @@
1
- �`��Y��c��^�P�QZS�Y���0ј�)O��-�Z Q����[�1D�8��� 6�:�W���#�j��ݻ���}Q��F�qT7W.Ƒ�6ϮJ_ef3���ZQ��:'�P���X/,����j��� �|j ��d���@�����0[�ex��M���.G�}t2+z�"��\�˧���I�����>�o~�jB��O/ !f�ȗ�?
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CltuBf4Z.js";import{H as t,J as n,K as r}from"./useSubAccountSwitcher-BEwQMRMo.js";import{n as i,t as a}from"./AdminLoginScreens-7Czw3MAC.js";import"./useVoiceRecorder-CiDOh8PG.js";import"./AdminShell-D5GApZ_n.js";import{t as o}from"./page-CPVUAwb8.js";import"./CdpScreencastSurface-BbekDUFw.js";import"./useCopyFeedback-BvIRgs7W.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,console.info(`[operator-ui] op=auth-gate state=${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,{}));
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CltuBf4Z.js";import{C as t,G as n,H as r,J as i,L as a,M as o,O as s,S as c,T as l,_ as u,a as d,b as f,c as p,f as m,g as h,i as g,j as _,p as v,s as y,t as b,w as ee,x as te,y as x}from"./useSubAccountSwitcher-BEwQMRMo.js";import{D as S,O as ne,T as re,f as C,n as ie,r as w,s as T,w as E}from"./useVoiceRecorder-CiDOh8PG.js";import{a as ae,i as D,n as oe,t as se}from"./file-download-Di_s0_4w.js";import{t as O}from"./chevron-left-CdUzxzeB.js";import{t as k}from"./file-text-CP1KIrJV.js";import{i as ce,t as A}from"./graph-labels-CgP17xHK.js";import{t as le}from"./triangle-alert-vAaSDhVq.js";var ue=a(`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=a(`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=a(`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=a(`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=a(`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=a(`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=a(`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=a(`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=a(`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(i(),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=>!w(e.type,ne));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=r();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)(_,{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,p]=(0,M.useState)(!1),[m,h]=(0,M.useState)(!1),[g,_]=(0,M.useState)(!1),[v,y]=(0,M.useState)([]),b=(0,M.useRef)(null),{pendingFiles:S,attachError:ne,addFiles:C,removeFile:w,clearFiles:T}=ve(),{state:ae,elapsedSeconds:D,errorMessage:oe,start:se,send:O,discard:ce}=ie(),A=ae===`recording`||ae===`paused`,le=(0,M.useCallback)(()=>{console.info(`[operator-ui] op=voice-record state=start ms=0`),se()},[se]),ue=(0,M.useCallback)(async()=>{let e=D*1e3,t=await O();if(console.info(`[operator-ui] op=voice-record state=stop ms=${e}`),t){let e=t.type===`audio/ogg`?`.ogg`:t.type===`audio/mp4`?`.m4a`:`.webm`;C([new File([t],`voice-note${e}`,{type:t.type})])}},[D,O,C]),de=(0,M.useCallback)(()=>{console.info(`[operator-ui] op=voice-record state=cancel ms=${D*1e3}`),ce()},[D,ce]),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.useRef)(44),L=(0,M.useCallback)(e=>{let t=I.current;if(!t)return;t.moved=!0;let n=Math.min(pe(),Math.max(44,t.startH+(t.startY-e.clientY)));Ce.current=n,_e(n)},[]),R=(0,M.useCallback)(()=>{let e=I.current?.moved??!1;I.current=null,window.removeEventListener(`pointermove`,L),window.removeEventListener(`pointerup`,R),e&&console.info(`[operator-ui] op=wa-composer-resize mode=drag h=${Ce.current}`)},[L]),we=(0,M.useCallback)(e=>{I.current={startY:e.clientY,startH:b.current?.offsetHeight??44,moved:!1},window.addEventListener(`pointermove`,L),window.addEventListener(`pointerup`,R),e.preventDefault()},[L,R]),Te=(0,M.useCallback)(e=>{let t=me??b.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),console.info(`[operator-ui] op=wa-composer-resize mode=key h=${n}`))},[me]),z=(0,M.useRef)(``);(0,M.useEffect)(()=>{let e=b.current;if(!e)return;let t=z.current!==``&&a===``;if(z.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 Ee=(a.trim().length>0||S.length>0||v.length>0)&&!s,De=(0,M.useCallback)(async()=>{if(!fe.current&&!(a.trim().length===0&&S.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(S.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 S)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.info(`[operator-ui] op=reply-fail remoteJid=${t} error=${l.error??`unknown`}`);return}o(``),T(),y([]),i?.(),console.info(`[operator-ui] op=reply-sent remoteJid=${t} sent=${l.sent??0}`)}catch(e){u(`Could not reach the server. Try again.`),console.info(`[operator-ui] op=reply-fail remoteJid=${t} error=${String(e)}`)}finally{fe.current=!1,c(!1)}}},[a,S,v,r,i,e,t,n,T]),Oe=(0,M.useCallback)(e=>{let t=b.current,{value:n,caret:r}=ye(a,e,t?t.selectionStart:null,t?t.selectionEnd:null);o(n),p(!1),requestAnimationFrame(()=>{let e=b.current;e&&(e.focus(),e.setSelectionRange(r,r))})},[a]),ke=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ee&&De())},B=e=>e.dataTransfer.types.includes(`Files`),V=(0,M.useCallback)(e=>{B(e)&&(e.preventDefault(),_(!0))},[]),Ae=(0,M.useCallback)(()=>_(!1),[]),je=(0,M.useCallback)(e=>{if(!B(e))return;e.preventDefault(),_(!1);let t=[...e.dataTransfer.files];if(t.length===0)return;let n=Math.max(0,S.length+t.length-5);console.info(`[operator-ui] op=composer-drop count=${t.length} rejected=${n}`),C(t)},[S.length,C]),H=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:V,onDragLeave:Ae,onDrop:je,children:[m&&(0,P.jsx)(be,{sessionKey:n,onPick:e=>{y(t=>[...t,e].slice(0,5)),h(!1)},onClose:()=>h(!1)}),d&&(0,P.jsx)(F,{onSelect:Oe}),l&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:l}),ne&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:ne}),ae===`error`&&oe&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:oe}),(S.length>0||v.length>0)&&(0,P.jsxs)(`div`,{className:`wa-reply-attachments`,children:[S.map((e,t)=>(0,P.jsxs)(`div`,{className:`wa-reply-chip`,children:[H(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:()=>y(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})})]}),!A&&(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:we,onKeyDown:Te}),(0,P.jsx)(`div`,{className:`wa-reply-row`,children:A?(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)(f,{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(D)]}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void ue(),"aria-label":`Stop recording`,children:(0,P.jsx)(te,{size:20})})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-emoji`,onClick:()=>p(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)(ee,{size:22})}),(0,P.jsx)(`textarea`,{ref:b,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:ke}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-mic`,onClick:()=>void le(),disabled:s,"aria-label":`Record voice note`,children:(0,P.jsx)(E,{size:22})}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void De(),disabled:!Ee,"aria-label":`Send`,children:(0,P.jsx)(he,{size:20})})]})})]})}function I({accountId:e,remoteJid:t,contactName:n,sessionKey:r,onBack:i}){let a=p(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(``)},[m,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)(C,{accountId:e,jid:t,sessionKey:r}),c?(0,P.jsxs)(`div`,{className:`wa-web-search`,children:[(0,P.jsx)(ce,{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)(ce,{size:20})})]})]}),(0,P.jsx)(`div`,{className:`wa-web-body`,children:(0,P.jsx)(T,{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:m,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 L(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 R({conversations:e,sessionKey:t,onBack:n}){let[r,i]=(0,M.useState)(null),a=g(e);return r?r.source===`store`&&r.accountId&&r.remoteJid?(0,P.jsx)(I,{accountId:r.accountId,remoteJid:r.remoteJid,contactName:d(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:d(r)})]}),(0,P.jsx)(T,{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)(m,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{console.info(`[operator-ui] op=reader-open channel=${e.channel} key=${y(e)} readonly=true source=${e.source}`),i(e)},children:[e.source===`store`&&e.accountId&&e.remoteJid&&(0,P.jsx)(C,{accountId:e.accountId,jid:e.remoteJid,sessionKey:t,className:`op-conv-avatar`,size:16}),(0,P.jsx)(`span`,{className:`op-conv-name`,children:d(e)}),e.modelGated&&(0,P.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,P.jsx)(le,{size:13})}),(0,P.jsx)(`span`,{className:`op-conv-when`,children:L(e.lastMessageAt)})]},y(e)))]},e.channel))]})}var we=/\.(png|jpe?g|gif|webp|svg)$/i;function Te(e){return we.test(e)}function z(e){return e.entryPath??e.name}var Ee=`maxy-data-view`,De=95*1024*1024,Oe=48*1024*1024;function ke(){return typeof window>`u`?`list`:window.localStorage.getItem(Ee)===`grid`?`grid`:`list`}function B(){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)(u,{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)(V,{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)(h,{surface:`gate`})}function V({cacheKey:e}){let{adminFetch:t,cacheKey:r,sessionRefetchNonce:i}=n({initialCacheKey:e,surface:`data`});return(0,P.jsx)(Fe,{adminFetch:t,cacheKey:r,sessionRefetchNonce:i})}function Ae(){if(typeof window>`u`)return`@home`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`@home`}function je(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 H(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function U(e){return new Promise((t,n)=>e.file(t,n))}async function Me(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 U(r),relpath:e});else if(r.isDirectory){let t=await H(r.createReader());n.push(...await Me(t,e))}}return n}function Ne(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 Pe({adminFetch:e,cacheKey:n,sessionRefetchNonce:r}){let[i,a]=(0,M.useState)(``),u=(0,M.useRef)(null),[d,p]=(0,M.useState)(``),[m,g]=(0,M.useState)(null),[v,y]=(0,M.useState)(`hybrid`),[b,ee]=(0,M.useState)(!1),[te,S]=(0,M.useState)(null),[ne,re]=(0,M.useState)(null),[C,ie]=(0,M.useState)(0),[w,T]=(0,M.useState)(!1),[E,O]=(0,M.useState)(()=>Ae()),[A,le]=(0,M.useState)(null),[j,he]=(0,M.useState)(()=>ke()),[ge,ve]=(0,M.useState)(null),[N,ye]=(0,M.useState)([]),[F,be]=(0,M.useState)(null),[xe,Se]=(0,M.useState)(0),[I,L]=(0,M.useState)(null),R=(0,M.useRef)(null),we=N.slice(0,-1).map(e=>e.name).join(`/`),B=(()=>{let e=N.map(e=>e.name);return e.length>=2&&e[0]===`accounts`?`${e[0]}/${e[1]}`:null})(),V=F?we:E,H=(0,M.useCallback)(e=>V===`.`||V===``?e:`${V}/${e}`,[V]),[U,Pe]=(0,M.useState)(!1),[Fe,Ie]=(0,M.useState)(!1),[ze,Be]=(0,M.useState)(null),[Ve,We]=(0,M.useState)(!1),[W,G]=(0,M.useState)(null),[Ge,Ke]=(0,M.useState)(null),[qe,Je]=(0,M.useState)(null),[Ye,Xe]=(0,M.useState)(!1),[Ze,Qe]=(0,M.useState)(null),$e=(0,M.useRef)(null),[et,tt]=(0,M.useState)(0),[nt,rt]=(0,M.useState)(!1),[it,at]=(0,M.useState)(``),[ot,st]=(0,M.useState)(null),[ct,lt]=(0,M.useState)(``),[ut,dt]=(0,M.useState)(null),K=(()=>{let e=E===`.`?[]:E.split(`/`).filter(Boolean);return e.some(e=>e.startsWith(`@`))?!1:e.length>=2&&e[0]===`accounts`})(),[ft,pt]=(0,M.useState)(!1),mt=(0,M.useRef)(null),[ht,q]=(0,M.useState)(!1),gt=(0,M.useRef)(null);(0,M.useEffect)(()=>{let e=i.trim();if(!e){p(``),g(null),S(null);return}T(!1);let t=setTimeout(()=>p(e),300);return()=>clearTimeout(t)},[i]),(0,M.useEffect)(()=>{if(!d){ee(!1);return}let t=!1;return ee(!0),S(null),e(`/api/admin/graph-search?q=${encodeURIComponent(d)}&labels=FileArtifact&limit=20${w?`&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||(g(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||ee(!1)}),()=>{t=!0}},[d,e,r,w]);let _t=(0,M.useMemo)(()=>m?Ce(m):[],[m]),vt=ne&&_t.includes(ne)?ne:null,yt=(0,M.useMemo)(()=>m?vt?m.filter(e=>e.labels.includes(vt)):m:null,[m,vt]),bt=(0,M.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let r=`/api/admin/files/download?session_key=${encodeURIComponent(n)}&path=${encodeURIComponent(t)}`,i=document.createElement(`a`);i.href=r,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[n]);(0,M.useEffect)(()=>{if(!m)return;let e=m.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(`,`)}`)},[m]),(0,M.useEffect)(()=>{let t=!1;return Pe(!0),Be(null),e(`/api/admin/files?path=${encodeURIComponent(E===`.`?``:E)}`).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||(le(e.entries),ye(e.displayPath??[]),be(e.view??null),Se(typeof e.systemCount==`number`?e.systemCount:0))}).catch(e=>{t||(le([]),ye([]),be(null),Se(0),Be(e instanceof Error?e.message:String(e)))}).finally(()=>{t||(Pe(!1),Ie(!0))}),()=>{t=!0}},[e,E,et,r]),(0,M.useEffect)(()=>{if(F!==null||!B||R.current===B)return;R.current=B;let t=!1;return e(`/api/admin/files?path=${encodeURIComponent(`${B}/@home`)}`).then(e=>e.ok?e.json():null).then(e=>{t||!e||L((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,B]),(0,M.useEffect)(()=>{je(E)},[E]);let xt=(0,M.useCallback)(()=>{tt(e=>e+1)},[]),J=(0,M.useCallback)(e=>{pt(!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);console.log(`[data-search] op=locate nodeId=${e.nodeId} folder=${r}`),a(``),S(null),re(null),J(r)},[J]),Ct=(0,M.useCallback)(()=>{if(!E.split(`/`).some(e=>e.startsWith(`@`))){if(E===`.`||E===``)return;let e=E.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(`/`):`.`)},[E,N]),wt=(0,M.useCallback)(e=>{oe(n,H(z(e)))},[H,n]),[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])),console.info(`[data-ui] op=select-enter count=1`)},[]),Q=(0,M.useCallback)(e=>{Tt(!1),Et(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),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(Ee,e),console.info(`[data] op=view-mode mode=${e}`)},[]),Pt=(0,M.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){At(e.name);return}ve({src:se(n,H(z(e))),alt:e.displayName??e.name})},[Y,At,H,n]),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&&D(n,e.map(e=>H(z(e)))),Q(`action`)},[Lt,wt,H,n,Q]),zt=(0,M.useCallback)(async()=>{let t=Ft(),n=t.filter(e=>!e.protected),r=t.length-n.length;Qe(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=H(z(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){Qe(e instanceof Error?e.message:String(e))}}tt(e=>e+1),Q(`action`)},[Ft,H,e,Q]),Bt=(0,M.useCallback)(async()=>{let e=Ft();if(console.info(`[data-ui] op=share supported=${Ot} count=${e.length}`),Ot)try{let t=await Promise.all(e.map(async e=>{let t=H(z(e)),r=`/api/admin/files/download?session_key=${encodeURIComponent(n)}&path=${encodeURIComponent(t)}`,i=await(await fetch(r)).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,H,n]),Vt=(0,M.useCallback)(()=>{$e.current?.click()},[]),Ht=(0,M.useCallback)((e,t={})=>{let r=(r,i,a)=>{let o=new URLSearchParams({session_key:n,path:E===`.`?``:E,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 n=new XMLHttpRequest;n.open(`POST`,`/api/admin/files/upload?${o.toString()}`),n.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(n.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),n.onload=()=>{let e={};try{e=JSON.parse(n.responseText)}catch{}t({status:n.status,data:e})},n.onerror=()=>t({status:0,data:{}}),n.onabort=()=>t({status:0,data:{error:`aborted`}}),n.send(r)})};if(e.size<=De)return r(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/Oe);return(async()=>{let n={status:0,data:{}};for(let o=0;o<a;o++){let s=o*Oe;if(n=await r(e.slice(s,Math.min(s+Oe,e.size)),{uploadId:i,seq:String(o),total:String(a)},n=>t.onProgress?.(s+n,e.size)),!(n.status>=200&&n.status<300))return n}return n})()},[n,E]),Ut=(0,M.useCallback)(async e=>{Ke(null),We(!0),G({loaded:0,total:e.size});try{let{status:t,data:n}=await Ht(e,{onProgress:(e,t)=>G({loaded:e,total:t})});t>=200&&t<300&&n.path?(O(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),tt(e=>e+1)):Ke(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{We(!1),G(null),$e.current&&($e.current.value=``)}},[Ht]),Wt=(0,M.useCallback)(e=>{K&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Xe(!0))},[K]),Gt=(0,M.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Xe(!1)},[]),Kt=(0,M.useCallback)(async e=>{e.preventDefault(),Xe(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(console.info(`[data-ui] op=drop-received token=${t} items=${n.length}`),n.length===0)return;if(!K){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),Ke(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);We(!0),Ke(null),Je(null);let i=performance.now();try{let e=await Me(r),n=e.reduce((e,t)=>e+t.file.size,0),a=new Set(e.map(e=>e.relpath.split(`/`).slice(0,-1).join(`/`)).filter(Boolean)).size;console.info(`[data-ui] op=drop-walk token=${t} files=${e.length} dirs=${a} bytes=${n}`);let o=0,s=[];for(let n=0;n<e.length;n++){let{file:r,relpath:i}=e[n];console.info(`[data-ui] op=drop-file token=${t} rel="${i}" i=${n+1}/${e.length}`),G({loaded:0,total:r.size});let{status:a,data:c}=await Ht(r,{relpath:i,token:t,onProgress:(e,t)=>G({loaded:e,total:t})});if(a>=200&&a<300)o++,console.info(`[data-ui] op=drop-file-ok token=${t} rel="${i}"`);else{let e=a===0?`http=0`:Ne(a,c.error);s.push(`${i} (${e})`),console.info(`[data-ui] op=drop-file-skip token=${t} rel="${i}" reason=${e}`)}}let c=Math.round(performance.now()-i);console.info(`[data-ui] op=drop-done token=${t} uploaded=${o} skipped=${s.length} ms=${c}`),Je(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),tt(e=>e+1)}catch(e){Ke(e instanceof Error?e.message:String(e))}finally{We(!1),G(null)}},[K,Ht]),qt=(0,M.useCallback)(async()=>{let t=it.trim();if(t){dt(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:E===`.`?``:E,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);rt(!1),at(``),tt(e=>e+1)}catch(e){dt(e instanceof Error?e.message:String(e))}}},[e,it,E]),Jt=(0,M.useCallback)(async()=>{if(!ot)return;let t=ct.trim();if(!t)return;dt(null);let n=H(ot);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}`);st(null),lt(``),Q(`action`),tt(e=>e+1)}catch(e){dt(e instanceof Error?e.message:String(e))}},[e,ct,ot,H,Q]);(0,M.useEffect)(()=>{if(!ft)return;let e=e=>{mt.current&&!mt.current.contains(e.target)&&pt(!1)},t=e=>{e.key===`Escape`&&pt(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[ft]),(0,M.useEffect)(()=>{if(!ht)return;let e=e=>{gt.current&&!gt.current.contains(e.target)&&q(!1)},t=e=>{e.key===`Escape`&&q(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[ht]);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 Fe?(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:[i===``&&(0,P.jsx)(ce,{size:14}),(0,P.jsx)(`input`,{ref:u,type:`text`,value:i,onChange:e=>a(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),b&&(0,P.jsx)(s,{size:14,className:`spin`}),i!==``&&(0,P.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{a(``),u.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:gt,children:[(0,P.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>q(e=>!e),"aria-haspopup":`menu`,"aria-expanded":ht,"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":ht?`true`:void 0,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{xt(),q(!1)},disabled:U,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[U?(0,P.jsx)(s,{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(),q(!1)},disabled:Ve||!K,title:K?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Ve?W&&W.total>0?(0,P.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(W.loaded/W.total*100),`%`]}):(0,P.jsx)(s,{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:()=>{rt(e=>!e),at(``),dt(null),q(!1)},disabled:Ve||!K,title:K?`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`),q(!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:[E!==`.`&&(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)(ae,{size:14})}),Xt?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`span`,{className:`data-crumb-wrap`,ref:mt,children:[(0,P.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>pt(e=>!e),"aria-haspopup":`menu`,"aria-expanded":ft,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),ft&&(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)))]})]}),nt&&(0,P.jsxs)(`div`,{className:`data-inline-form`,children:[(0,P.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:it,autoFocus:!0,onChange:e=>at(e.target.value),onKeyDown:e=>{e.key===`Enter`&&qt(),e.key===`Escape`&&rt(!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:()=>rt(!1),children:`Cancel`})]}),ot&&(0,P.jsxs)(`div`,{className:`data-inline-form`,children:[(0,P.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:ct,autoFocus:!0,onChange:e=>lt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Jt(),e.key===`Escape`&&st(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:()=>st(null),children:`Cancel`})]}),ut&&(0,P.jsx)(`div`,{className:`data-error`,children:ut}),(0,P.jsx)(`input`,{type:`file`,ref:$e,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Ut(t)}})]}),(0,P.jsxs)(`div`,{className:`data-body`,"data-drag-active":Ye?`true`:void 0,onDragEnter:Wt,onDragOver:Wt,onDragLeave:Gt,onDrop:Kt,children:[F===null&&B&&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=`${B}/${e}`,n=E===t||E.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)(_,{size:13}),(0,P.jsx)(`span`,{className:`data-rail-item-name`,children:e})]})},e)})})]}),(0,P.jsxs)(`div`,{className:`data-content`,children:[(te!==null||m!==null)&&(0,P.jsxs)(`section`,{className:`data-panel admin-card`,children:[te&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,te]}),_t.length>0&&(0,P.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:_t.map(e=>{let t=e===vt;return(0,P.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>re(t?null:e),children:Re([e])??e},e)})}),m&&!b&&(0,P.jsxs)(`div`,{className:`data-results-meta`,children:[yt.length,` of `,m.length,` result`,m.length===1?``:`s`]}),m&&!b&&!vt&&C>0&&!w&&(0,P.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>T(!0),children:[C,` low-confidence result`,C===1?``:`s`,` hidden — show all`]}),m&&!b&&!vt&&w&&(0,P.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>T(!1),children:`Showing all results — hide low-confidence`}),m&&m.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)(Le,{hit:e,mode:v,onDownload:bt,onLocate:St},e.nodeId))})]}),(0,P.jsxs)(`section`,{className:`data-panel data-panel--wide admin-card`,children:[W&&(0,P.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":W.total>0?Math.round(W.loaded/W.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:`${W.total>0?Math.round(W.loaded/W.total*100):0}%`}})}),(0,P.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,W.total>0?`${Math.round(W.loaded/W.total*100)}%`:``]})]}),Ge&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,Ge]}),qe&&(0,P.jsx)(`div`,{className:`data-status`,children:qe}),Ze&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Ze]}),ze&&(0,P.jsx)(`div`,{className:`data-error`,children:ze}),U&&(0,P.jsxs)(`div`,{className:`data-loading`,children:[(0,P.jsx)(s,{size:14,className:`spin`}),` Loading…`]}),!Y&&!U&&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.`})]}),!U&&F!==`home`&&A&&A.length===0&&!ze&&(0,P.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!U&&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(H(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)(_,{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(H(`@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.`})})]})]}),!U&&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,r=Y&&X.has(e.name);if(e.kind===`directory`)return(0,P.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`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(H(e.name))},children:[Y&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsx)(_,{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=Te(z(e)),a=H(z(e));return(0,P.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`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:se(n,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:He(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)})}),!U&&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(H(e.name))},children:[Y&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsx)(_,{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 ${Ue(e.modifiedAt)}`,children:[He(e.sizeBytes),` · `,Ue(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)(c,{size:16}),` Share`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Rt,disabled:X.size===0,children:[(0,P.jsx)(o,{size:16}),` Download`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=It();e&&(st(e.name),lt(e.name))},disabled:!It(),children:[(0,P.jsx)(l,{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)(f,{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)(h,{surface:`gate`})}function Fe({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){(0,M.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);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)(v,{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)(R,{conversations:a,sessionKey:t,onBack:()=>c(`files`)}):(0,P.jsx)(Pe,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function Ie({cacheKey:e}){let{adminFetch:t,cacheKey:r,sessionRefetchNonce:i}=n({initialCacheKey:e,surface:`data`});return(0,P.jsx)(`div`,{className:`data-page`,children:(0,P.jsx)(`main`,{className:`data-main`,children:(0,P.jsx)(Pe,{adminFetch:t,cacheKey:r,sessionRefetchNonce:i})})})}function Le({hit:e,mode:t,onDownload:n,onLocate:r}){let i=ze(e.properties),a=Be(e.properties),o=Re(e.labels),s=Ve(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 `,Ue(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)(_,{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 Re(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 ze(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 Be(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 Ve(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 He(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 Ue(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{Ie as n,I as r,B as t};