@rubytech/create-maxy-code 0.1.432 → 0.1.433

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 (161) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +2 -2
  3. package/payload/platform/plugins/docs/references/admin-ui.md +1 -1
  4. package/payload/server/public/assets/AdminLoginScreens-CH-kznsr.js +1 -0
  5. package/payload/server/public/assets/AdminShell-DzgrZYpX.js +2 -0
  6. package/payload/server/public/assets/{Checkbox-BC0c_gbn.js → Checkbox-ChPx3-af.js} +1 -1
  7. package/payload/server/public/assets/admin-VHYR1DAp.js +1 -0
  8. package/payload/server/public/assets/{arc-qKfXIt8v.js → arc-Bm9oSOth.js} +1 -1
  9. package/payload/server/public/assets/architecture-YZFGNWBL-Bbnxm4F4.js +1 -0
  10. package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-DkVrGn7G.js → architectureDiagram-Q4EWVU46-C2dK88g3.js} +1 -1
  11. package/payload/server/public/assets/{blockDiagram-DXYQGD6D-DqavswGH.js → blockDiagram-DXYQGD6D-DfLSsjCJ.js} +1 -1
  12. package/payload/server/public/assets/{browser-CvZxNdKw.js → browser-DkTz3Atj.js} +1 -1
  13. package/payload/server/public/assets/{c4Diagram-AHTNJAMY-B7fyKiXe.js → c4Diagram-AHTNJAMY-Bxkmp6OL.js} +1 -1
  14. package/payload/server/public/assets/{calendar-DXxLMF2J.js → calendar-DlQUywFC.js} +1 -1
  15. package/payload/server/public/assets/channel-CatPTq-5.js +1 -0
  16. package/payload/server/public/assets/chat-CPOGOzmQ.js +1 -0
  17. package/payload/server/public/assets/chevron-left-Ch2-JhmS.js +1 -0
  18. package/payload/server/public/assets/{chunk-2KRD3SAO-DsgMtGkv.js → chunk-2KRD3SAO-BVNDFwNH.js} +1 -1
  19. package/payload/server/public/assets/{chunk-336JU56O-CkdISfNt.js → chunk-336JU56O-Daz6nMta.js} +2 -2
  20. package/payload/server/public/assets/chunk-426QAEUC-CqLMwOdA.js +1 -0
  21. package/payload/server/public/assets/{chunk-4BX2VUAB-CYpiF2bl.js → chunk-4BX2VUAB-DTldfvwP.js} +1 -1
  22. package/payload/server/public/assets/{chunk-4TB4RGXK-CWyc_F7v.js → chunk-4TB4RGXK-DhM8pwRG.js} +1 -1
  23. package/payload/server/public/assets/{chunk-55IACEB6-BbzKMw2Z.js → chunk-55IACEB6-CzTsbIHo.js} +1 -1
  24. package/payload/server/public/assets/{chunk-5FUZZQ4R-u19Nai9e.js → chunk-5FUZZQ4R-BrcObZhe.js} +1 -1
  25. package/payload/server/public/assets/{chunk-5PVQY5BW-Ba8by6Uy.js → chunk-5PVQY5BW-SFqTuS11.js} +1 -1
  26. package/payload/server/public/assets/{chunk-67CJDMHE-BwUuxtyb.js → chunk-67CJDMHE-EIbrSGOo.js} +1 -1
  27. package/payload/server/public/assets/{chunk-7N4EOEYR-BRH9iM9L.js → chunk-7N4EOEYR-B1D4Jorr.js} +1 -1
  28. package/payload/server/public/assets/{chunk-AA7GKIK3-BGoztgLL.js → chunk-AA7GKIK3-BKHiX4cC.js} +1 -1
  29. package/payload/server/public/assets/{chunk-BSJP7CBP-C5GDAZTl.js → chunk-BSJP7CBP-xBzu29m7.js} +1 -1
  30. package/payload/server/public/assets/{chunk-CIAEETIT-ChY32VPS.js → chunk-CIAEETIT-x2x0gMpL.js} +1 -1
  31. package/payload/server/public/assets/{chunk-EDXVE4YY-CPSD3p6p.js → chunk-EDXVE4YY-D5UkD28M.js} +1 -1
  32. package/payload/server/public/assets/{chunk-ENJZ2VHE-D1oL-iUr.js → chunk-ENJZ2VHE-Dbz67a7E.js} +1 -1
  33. package/payload/server/public/assets/{chunk-FMBD7UC4-CPvYEr54.js → chunk-FMBD7UC4-XfWvuu2F.js} +1 -1
  34. package/payload/server/public/assets/{chunk-FOC6F5B3-9Yyj7Vbz.js → chunk-FOC6F5B3-DfOEDS4q.js} +1 -1
  35. package/payload/server/public/assets/{chunk-ICPOFSXX-BaYgh8FR.js → chunk-ICPOFSXX-D_WEZZvg.js} +2 -2
  36. package/payload/server/public/assets/{chunk-K5T4RW27-5ucpeRvm.js → chunk-K5T4RW27-7O627Xi1.js} +1 -1
  37. package/payload/server/public/assets/{chunk-KGLVRYIC-DW-FHk7T.js → chunk-KGLVRYIC-BXI3XDP9.js} +1 -1
  38. package/payload/server/public/assets/{chunk-LIHQZDEY-CGGVfAyG.js → chunk-LIHQZDEY-B9cFNN0l.js} +1 -1
  39. package/payload/server/public/assets/{chunk-ORNJ4GCN-Bv8EUa5d.js → chunk-ORNJ4GCN-BR3UNDTn.js} +1 -1
  40. package/payload/server/public/assets/{chunk-OYMX7WX6-C1mXJnyw.js → chunk-OYMX7WX6-2wKIEtFZ.js} +1 -1
  41. package/payload/server/public/assets/chunk-QZHKN3VN-CjWy8NJ7.js +1 -0
  42. package/payload/server/public/assets/{chunk-U2HBQHQK-PwSQz6EP.js → chunk-U2HBQHQK-augM3AXB.js} +1 -1
  43. package/payload/server/public/assets/{chunk-X2U36JSP--NPHTBlU.js → chunk-X2U36JSP-BAM9q9ZQ.js} +1 -1
  44. package/payload/server/public/assets/{chunk-XPW4576I-Bbc7Da32.js → chunk-XPW4576I-DxPpji5P.js} +1 -1
  45. package/payload/server/public/assets/{chunk-YZCP3GAM-D-9v8e--.js → chunk-YZCP3GAM-BD3ClFXP.js} +1 -1
  46. package/payload/server/public/assets/{chunk-ZZ45TVLE-CMPg670Q.js → chunk-ZZ45TVLE-CqxhLPep.js} +1 -1
  47. package/payload/server/public/assets/classDiagram-6PBFFD2Q-DHhR5rdN.js +1 -0
  48. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-DH4pAdfu.js +1 -0
  49. package/payload/server/public/assets/clone-DCKzwjWW.js +1 -0
  50. package/payload/server/public/assets/{cose-bilkent-S5V4N54A-NVSb1Bhy.js → cose-bilkent-S5V4N54A-xywWX-9i.js} +1 -1
  51. package/payload/server/public/assets/{dagre-QfLcO-1j.js → dagre-BaHjDQ-8.js} +1 -1
  52. package/payload/server/public/assets/{dagre-KV5264BT-V2Ai1DFl.js → dagre-KV5264BT-ChRpqqiH.js} +1 -1
  53. package/payload/server/public/assets/data-Ppxc3gvy.js +1 -0
  54. package/payload/server/public/assets/{diagram-5BDNPKRD-Caw21693.js → diagram-5BDNPKRD-KjwTpyBi.js} +1 -1
  55. package/payload/server/public/assets/{diagram-G4DWMVQ6-CgwVkT2q.js → diagram-G4DWMVQ6-DZO9njAF.js} +1 -1
  56. package/payload/server/public/assets/{diagram-MMDJMWI5-DFUrLZhs.js → diagram-MMDJMWI5-Bus-U-TI.js} +1 -1
  57. package/payload/server/public/assets/{diagram-TYMM5635-CEEiEuZJ.js → diagram-TYMM5635-CfJodFgq.js} +1 -1
  58. package/payload/server/public/assets/{erDiagram-SMLLAGMA-CG10NrT3.js → erDiagram-SMLLAGMA-Bt5zqWiW.js} +1 -1
  59. package/payload/server/public/assets/{file-download-B2B2DTar.js → file-download-CX16TB7C.js} +1 -1
  60. package/payload/server/public/assets/{flatten-DAO0sfCM.js → flatten-Bpu1L63d.js} +1 -1
  61. package/payload/server/public/assets/{flowDiagram-DWJPFMVM-BqkV9Okv.js → flowDiagram-DWJPFMVM-B64Q590S.js} +1 -1
  62. package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-DRiCDQF6.js → ganttDiagram-T4ZO3ILL-BWdgCEpH.js} +1 -1
  63. package/payload/server/public/assets/gitGraph-7Q5UKJZL-Ps5HDzLh.js +1 -0
  64. package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-BZV2voyy.js → gitGraphDiagram-UUTBAWPF-Djq2B0WT.js} +1 -1
  65. package/payload/server/public/assets/{graph-DRNzDBTV.js → graph-DPqvHCZ4.js} +3 -3
  66. package/payload/server/public/assets/{graph-labels-DxqDdO7G.js → graph-labels-D_0uou0Z.js} +1 -1
  67. package/payload/server/public/assets/{graphlib-DGPThX8M.js → graphlib-CNJh9_lx.js} +1 -1
  68. package/payload/server/public/assets/info-OMHHGYJF-gtlpwIig.js +1 -0
  69. package/payload/server/public/assets/infoDiagram-42DDH7IO-CPrWlrsa.js +2 -0
  70. package/payload/server/public/assets/{isEmpty-Cb_U81C6.js → isEmpty-DkDEVnMZ.js} +1 -1
  71. package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-BKsAxSvp.js → ishikawaDiagram-UXIWVN3A-V3ACkWCW.js} +1 -1
  72. package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-CmliuOd-.js → journeyDiagram-VCZTEJTY-9T0qZeH3.js} +1 -1
  73. package/payload/server/public/assets/{kanban-definition-6JOO6SKY-DAlElMb-.js → kanban-definition-6JOO6SKY-CxZ0ukx3.js} +1 -1
  74. package/payload/server/public/assets/{line-DKZqLKAC.js → line-DUHKCQZT.js} +1 -1
  75. package/payload/server/public/assets/{linear-CbSGdh1x.js → linear-BgIBblun.js} +1 -1
  76. package/payload/server/public/assets/{maximize-2-DKx6OBKv.js → maximize-2-BTHbMSfz.js} +1 -1
  77. package/payload/server/public/assets/{mermaid-parser.core-DFvbao9C.js → mermaid-parser.core-CyHygs0-.js} +2 -2
  78. package/payload/server/public/assets/{mermaid.core-C0vEBxDm.js → mermaid.core-L55fJBSx.js} +3 -3
  79. package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-CShASUKd.js → mindmap-definition-QFDTVHPH-DczaUX_E.js} +1 -1
  80. package/payload/server/public/assets/operator-BCZ7UoWU.js +1 -0
  81. package/payload/server/public/assets/{ordinal-H0tVmBDP.js → ordinal-DK3QISRR.js} +1 -1
  82. package/payload/server/public/assets/packet-4T2RLAQJ-DrSn1e0n.js +1 -0
  83. package/payload/server/public/assets/page-BObPPwJr.js +32 -0
  84. package/payload/server/public/assets/page-CqN6MkYM.js +1 -0
  85. package/payload/server/public/assets/{pdf-render-jAQU0nXt.js → pdf-render-COLA4aPx.js} +1 -1
  86. package/payload/server/public/assets/pie-ZZUOXDRM-C09i6N-g.js +1 -0
  87. package/payload/server/public/assets/{pieDiagram-DEJITSTG-CBZHpDAJ.js → pieDiagram-DEJITSTG-Da5TdnNt.js} +1 -1
  88. package/payload/server/public/assets/{play-DHttF4fl.js → play-Bw1WkeRC.js} +1 -1
  89. package/payload/server/public/assets/public-DI5OCw9V.js +1 -0
  90. package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-n3bB3K91.js → quadrantDiagram-34T5L4WZ-DX7J81uh.js} +1 -1
  91. package/payload/server/public/assets/radar-PYXPWWZC-CMZN2KQH.js +1 -0
  92. package/payload/server/public/assets/{reduce-DAvwat-a.js → reduce-uzWdoyL7.js} +1 -1
  93. package/payload/server/public/assets/{requirementDiagram-MS252O5E-DiDvQK3c.js → requirementDiagram-MS252O5E-DJQGrZPG.js} +1 -1
  94. package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-DWDQQZmd.js → sankeyDiagram-XADWPNL6-Ba8fGz96.js} +1 -1
  95. package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-DmAqRlBT.js → sequenceDiagram-FGHM5R23-BmDPC7qx.js} +1 -1
  96. package/payload/server/public/assets/{stateDiagram-FHFEXIEX-D4R-n6bZ.js → stateDiagram-FHFEXIEX-1VkptYFz.js} +1 -1
  97. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-BdgkPHuh.js +1 -0
  98. package/payload/server/public/assets/tasks-Bj03-1M6.js +1 -0
  99. package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-CjiHGP4l.js → timeline-definition-GMOUNBTQ-B92U3T_f.js} +1 -1
  100. package/payload/server/public/assets/treeView-SZITEDCU-CeuUM5oL.js +1 -0
  101. package/payload/server/public/assets/treemap-W4RFUUIX-C--fAaJv.js +1 -0
  102. package/payload/server/public/assets/{useCopyFeedback-CPEOUSGU.js → useCopyFeedback-8b1gtbRz.js} +1 -1
  103. package/payload/server/public/assets/useSubAccountSwitcher-Cmbcd72K.js +9 -0
  104. package/payload/server/public/assets/{useSubAccountSwitcher-CdS1CorH.css → useSubAccountSwitcher-DRRuGtGS.css} +1 -1
  105. package/payload/server/public/assets/useVoiceRecorder-D9Qa7Eua.js +2 -0
  106. package/payload/server/public/assets/{vennDiagram-DHZGUBPP-CBdDQ7c-.js → vennDiagram-DHZGUBPP-Y6Wkihrs.js} +1 -1
  107. package/payload/server/public/assets/wardley-RL74JXVD-4WPJ2UA9.js +1 -0
  108. package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-BlIQPKLb.js → wardleyDiagram-NUSXRM2D-iJpfal2z.js} +1 -1
  109. package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-CslKgh9B.js → xychartDiagram-5P7HB3ND-S0bv7oH0.js} +1 -1
  110. package/payload/server/public/browser.html +5 -6
  111. package/payload/server/public/calendar.html +6 -7
  112. package/payload/server/public/chat.html +12 -13
  113. package/payload/server/public/data.html +10 -10
  114. package/payload/server/public/graph.html +10 -11
  115. package/payload/server/public/index.html +13 -14
  116. package/payload/server/public/operator.html +14 -15
  117. package/payload/server/public/public.html +12 -13
  118. package/payload/server/public/tasks.html +4 -5
  119. package/payload/server/server.js +292 -109
  120. package/payload/server/public/assets/AdminLoginScreens-BM45lL5G.js +0 -1
  121. package/payload/server/public/assets/AdminShell-BfLQQ27Z.js +0 -2
  122. package/payload/server/public/assets/admin-B8Eb9Wbj.js +0 -1
  123. package/payload/server/public/assets/architecture-YZFGNWBL-FPHT7s-C.js +0 -1
  124. package/payload/server/public/assets/audio-attachment-mime-Cx5d3Jls.js +0 -2
  125. package/payload/server/public/assets/channel-j70eMvcL.js +0 -1
  126. package/payload/server/public/assets/chat-LEEUAJOG.js +0 -1
  127. package/payload/server/public/assets/chevron-left-CLPxfjDV.js +0 -1
  128. package/payload/server/public/assets/chunk-426QAEUC-D-NcAlTW.js +0 -1
  129. package/payload/server/public/assets/chunk-QZHKN3VN-CAwbQBtf.js +0 -1
  130. package/payload/server/public/assets/classDiagram-6PBFFD2Q-Ct6Rn0vt.js +0 -1
  131. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-B_2XCIFv.js +0 -1
  132. package/payload/server/public/assets/clone-DjPWA_NH.js +0 -1
  133. package/payload/server/public/assets/data-CKojMQSz.js +0 -1
  134. package/payload/server/public/assets/gitGraph-7Q5UKJZL-B8Hx7f-D.js +0 -1
  135. package/payload/server/public/assets/info-OMHHGYJF-BicCJTqU.js +0 -1
  136. package/payload/server/public/assets/infoDiagram-42DDH7IO-tf-8rOez.js +0 -2
  137. package/payload/server/public/assets/operator-OwY_sWTH.js +0 -1
  138. package/payload/server/public/assets/packet-4T2RLAQJ-Ckn_5hq0.js +0 -1
  139. package/payload/server/public/assets/page-B7nCws9K.js +0 -1
  140. package/payload/server/public/assets/page-C3L6-Ufk.js +0 -32
  141. package/payload/server/public/assets/pie-ZZUOXDRM-DzlGQW3J.js +0 -1
  142. package/payload/server/public/assets/public-CSLXSSy5.js +0 -1
  143. package/payload/server/public/assets/radar-PYXPWWZC-BHo2YD8b.js +0 -1
  144. package/payload/server/public/assets/square-CHcQHtK8.js +0 -1
  145. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-BcFRbGRu.js +0 -1
  146. package/payload/server/public/assets/tasks-ClfJU1CK.js +0 -1
  147. package/payload/server/public/assets/treeView-SZITEDCU-BtRr5vXp.js +0 -1
  148. package/payload/server/public/assets/treemap-W4RFUUIX-D8p0sbyo.js +0 -1
  149. package/payload/server/public/assets/useSubAccountSwitcher-DyjTbzQR.js +0 -9
  150. package/payload/server/public/assets/wardley-RL74JXVD-DgMn-9ZJ.js +0 -1
  151. /package/payload/server/public/assets/{_baseFor-D3BqAOBr.js → _baseFor-Q4DeIqQC.js} +0 -0
  152. /package/payload/server/public/assets/{array-iYP9fzJp.js → array-WaOTgZu7.js} +0 -0
  153. /package/payload/server/public/assets/{cytoscape.esm-BQSBzPsB.js → cytoscape.esm-CMmjo4hO.js} +0 -0
  154. /package/payload/server/public/assets/{defaultLocale-BrdA1gDi.js → defaultLocale-BxqJVxq5.js} +0 -0
  155. /package/payload/server/public/assets/{dist-Cvgxm7qv.js → dist-Dx-cpU53.js} +0 -0
  156. /package/payload/server/public/assets/{init-Bx0S6pkp.js → init-DX7c5Edh.js} +0 -0
  157. /package/payload/server/public/assets/{katex-BsiH_a6d.js → katex-B2dtGfSp.js} +0 -0
  158. /package/payload/server/public/assets/{path-BLSgTy3w.js → path-CnSyroar.js} +0 -0
  159. /package/payload/server/public/assets/{preload-helper-ClBMtM1g.js → preload-helper-DqboRNgS.js} +0 -0
  160. /package/payload/server/public/assets/{rough.esm-BMOtDaaS.js → rough.esm-eLccZ4OJ.js} +0 -0
  161. /package/payload/server/public/assets/{src-DV4LKv2E.js → src-Dqs1wlnb.js} +0 -0
@@ -1,2 +0,0 @@
1
- import{o as e}from"./chunk-Ck5AOu5v.js";import{C as t,a as n,c as r,d as i,f as a,h as o,i as s,l as c,m as l,n as u,o as d,t as f,v as p,w as m,y as h}from"./useSubAccountSwitcher-DyjTbzQR.js";import{a as g,d as _,f as ee,h as te,l as ne,m as re,n as ie,o as ae,p as oe,s as se,u as ce}from"./file-download-B2B2DTar.js";import{t as le}from"./square-CHcQHtK8.js";async function v(){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 y=e(m(),1),b=h(),x={sm:14,md:16,lg:18},S={sm:30,md:38,lg:46};function C({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,style:u,className:d,children:f}){let p=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,d].filter(Boolean).join(` `),m=x[t],h={...e===`send`?{width:S[t],height:S[t]}:{},...u},g=Object.keys(h).length>0;return(0,b.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,b.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,b.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,b.jsx)(n,{size:m})]}),i&&(0,b.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var ue=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`}]]),w=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`}]]),T=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`}]]),de=l(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),E=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),fe=l(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),pe=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`}]]),me=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`}]]),D=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`}]]),he=l(`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`}]]),O=`maxy-shell-side-px`;function ge(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function k(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-ge());return Math.min(Math.max(e,248),n)}function _e(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(O);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 k(t)}catch{}return 264}function ve({targetSelector:e=`.platform`}){let t=(0,y.useRef)(null),[n,r]=(0,y.useState)(()=>_e()),i=(0,y.useRef)(n);(0,y.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,y.useCallback)(()=>{r(e=>{let t=k(e);return t===e?e:t})},[]);(0,y.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(k(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(O,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=k(264);r(e);try{window.localStorage.removeItem(O)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,b.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var A=t();function ye({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,y.useRef)(null),[s,c]=(0,y.useState)({position:`fixed`,visibility:`hidden`}),l=(0,y.useCallback)(()=>{let t=e.current,n=o.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right-i.width;a<4&&(a=4);let s=window.innerHeight-r.bottom<i.height+8&&r.top>i.height+8?r.top-i.height:r.bottom;c({position:`fixed`,left:a,top:s,visibility:`visible`})},[e]);return(0,y.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,y.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||o.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,A.createPortal)((0,b.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function be({actions:e,disabled:t}){let[n,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(null),s=(0,y.useRef)(null),c=(0,y.useCallback)(()=>{i(!1),o(null)},[]);return(0,b.jsxs)(`div`,{className:`conv-actions`,children:[(0,b.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,b.jsx)(r,{size:12})}),n&&(0,b.jsx)(ye,{anchorRef:s,onClose:c,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,b.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,b.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,b.jsx)(`span`,{children:e.menuLabel})]}),a===e.key&&(0,b.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,b.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,b.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var j=`claude-opus-4-8[1m]`,M=`claude-sonnet-5`,N=`claude-haiku-4-5`,P={[j]:`Opus 4.8 (1M context)`,[M]:`Sonnet 5`,[N]:`Haiku 4.5`};function F(e){return P[e]??e}var I=[j,M,N];function L(e){return e.replace(/\[1m\]$/,``)}function xe(e){return I.find(t=>L(t)===L(e))??e}var Se=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],R=[`low`,`medium`,`high`,`xhigh`];[...Se],[...R],[...R];var Ce=[j,M,N],we={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},Te=Se.map(e=>({value:e,label:we[e]??e})),Ee={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},De=R.map(e=>({value:e,label:Ee[e]??e}));function z(e){if(e){let t=Ce.find(t=>L(t)===L(e));if(t)return t}return j}function Oe({row:e,adminFetch:t,onError:n}){let[r,i]=(0,y.useState)(()=>z(e.model)),[a,o]=(0,y.useState)(``),[s,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(!1),f=(0,y.useRef)(!1);(0,y.useEffect)(()=>{i(z(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!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}`),f.current=!1,d(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),f.current=!1,d(!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)}`),f.current=!1,d(!1)}}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`label`,{className:`reseat-field`,children:[(0,b.jsx)(`span`,{children:`Model`}),(0,b.jsx)(`select`,{"data-kind":`model`,value:r,disabled:u,onChange:e=>i(e.target.value),children:Ce.map(e=>(0,b.jsx)(`option`,{value:e,children:F(e)},e))})]}),(0,b.jsxs)(`label`,{className:`reseat-field`,children:[(0,b.jsx)(`span`,{children:`Mode`}),(0,b.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:u,onChange:e=>o(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Keep current`}),Te.map(e=>(0,b.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,b.jsxs)(`label`,{className:`reseat-field`,children:[(0,b.jsx)(`span`,{children:`Effort`}),(0,b.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:u,onChange:e=>l(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Keep current`}),De.map(e=>(0,b.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,b.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:u,"aria-busy":u,onClick:()=>void p(),children:u?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(c,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function B(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 ke(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function V(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Ae({target:e,onConfirm:t,onCancel:n}){return e?(0,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`span`,{children:`Delete this conversation?`}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`,e.live&&(0,b.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,b.jsx)(C,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,b.jsx)(C,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var je=`auth-refresh-failed`;function Me({error:e,onClose:t}){if(!e)return null;let n=e.reason===je,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,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`span`,{children:r}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,b.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,b.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Ne(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,y.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,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,b.jsx)(`span`,{children:`Claude Code`}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,children:[(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,b.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,b.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,b.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,b.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,children:[(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:p>0?ke(p):`—`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:B(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,b.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 V(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function Pe({open:e,onConnect:t,onClose:n}){return e?(0,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`span`,{children:`Claude isn’t connected`}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,b.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,b.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,b.jsx)(C,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,b.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function H(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 Fe(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function U(e){return e.toLocaleString(`en-GB`)}function W(e){return`£${e.toFixed(2)}`}function Ie(e){let t=[`Day`,`Active`,`Output tokens`,`Input tokens`,`Cache write`,`Cache read`,`Opus 4.8 (GBP)`,`Sonnet 4.6 (GBP)`],n=(e,t)=>[e,H(Fe(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 G({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,b.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,b.jsx)(r,{className:`usage-day`,children:e}),(0,b.jsx)(r,{children:H(Fe(t))}),(0,b.jsx)(r,{children:U(t.tokens.output)}),(0,b.jsx)(r,{children:U(t.tokens.input)}),(0,b.jsx)(r,{children:U(t.tokens.cacheWrite)}),(0,b.jsx)(r,{children:U(t.tokens.cacheRead)}),(0,b.jsx)(r,{children:W(t.costGBP.opus)}),(0,b.jsx)(r,{children:W(t.costGBP.sonnet)})]})}function Le({show:e,onClose:t,sessionId:r,summary:i,loading:a,error:o}){if(!e)return null;let s=!!i&&i.days.length>0,c=()=>{if(!i)return;let e=new Blob([Ie(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)};return(0,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,b.jsxs)(`div`,{className:`claude-info-modal usage-modal`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Session usage and cost`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsxs)(`span`,{children:[`Usage & cost`,r?` · ${r.slice(0,8)}`:``]}),s&&(0,b.jsx)(`button`,{className:`usage-download`,onClick:c,"aria-label":`Download as CSV`,title:`Download as CSV`,children:(0,b.jsx)(te,{size:14})}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,b.jsx)(n,{size:14})})]}),(0,b.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[a&&(0,b.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!a&&o&&(0,b.jsx)(`div`,{className:`usage-note usage-error`,children:o}),!a&&!o&&i&&i.days.length===0&&(0,b.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!a&&!o&&i&&i.days.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`usage-table-scroll`,children:(0,b.jsxs)(`table`,{className:`usage-table`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,b.jsx)(`th`,{children:`Active`}),(0,b.jsx)(`th`,{children:`Output tok`}),(0,b.jsx)(`th`,{children:`Input tok`}),(0,b.jsx)(`th`,{children:`Cache write`}),(0,b.jsx)(`th`,{children:`Cache read`}),(0,b.jsx)(`th`,{children:`Opus 4.8 (£)`}),(0,b.jsx)(`th`,{children:`Sonnet 4.6 (£)`})]})}),(0,b.jsxs)(`tbody`,{children:[i.days.map(e=>(0,b.jsx)(G,{label:e.date,d:e},e.date)),(0,b.jsx)(G,{label:`TOTAL (${i.days.length} d)`,d:i.totals,bold:!0})]})]})}),(0,b.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; Sonnet is a tokenizer-adjusted estimate.`]})]})]})]})})}var Re=`https://claude.ai/code`,ze=200,Be=[500,1e3,1500,2e3,2500,3e3,3e3];function Ve(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:`${Re}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function He(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Ue(e){let{businessName:t,cacheKey:n,onConnectClaude:r,role:c,userName:l,userAvatar:u,onSelectProjects:f,onSelectPeople:m,onSelectTasks:h,onSelectAgents:v,onCloseMobileDrawer:x,collapsed:S,selectedWhatsappId:C,onSelectWhatsappConversation:O,initialWhatsappSurface:ge=!1,onSelectData:k,onCloseData:_e,initialDataSurface:ve=!1}=e,A=s(n),ye=(0,y.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,b.jsx)(D,{size:12}),panel:()=>(0,b.jsx)(Oe,{row:e,adminFetch:A,onError:e=>B({message:e,failed:!0})})}),[A]),j=o.productName,M=typeof l==`string`?l:l===null?`name unavailable`:t||j,N=(M.trim().charAt(0)||`?`).toUpperCase(),[P,F]=(0,y.useState)(ve?`data`:ge?`whatsapp`:`sessions`),[I,L]=(0,y.useState)([]),[xe,Se]=(0,y.useState)(!1),[R,Ce]=(0,y.useState)(null),[we,Te]=(0,y.useState)(!1),[Ee,De]=(0,y.useState)(`file`),[z,B]=(0,y.useState)(null),[ke,V]=(0,y.useState)(null),[je,Ne]=(0,y.useState)(!1),[H,Fe]=(0,y.useState)([]),[U]=(0,y.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`session`)),[W,Ie]=(0,y.useState)(!1),[G,Re]=(0,y.useState)(null),[Ue,We]=(0,y.useState)(!1),[K,Je]=(0,y.useState)(!1),[q,Ye]=(0,y.useState)(!1),[Xe,Ze]=(0,y.useState)(null),[J,Qe]=(0,y.useState)(new Set),[$e,et]=(0,y.useState)(null),[tt,nt]=(0,y.useState)(new Set),[rt,it]=(0,y.useState)(new Set),[at,ot]=(0,y.useState)(new Set),[Y,st]=(0,y.useState)(null),[ct,X]=(0,y.useState)(``),[lt,ut]=(0,y.useState)(!1),[dt,ft]=(0,y.useState)(null),[pt,mt]=(0,y.useState)(null),[ht,gt]=(0,y.useState)(!1),[_t,vt]=(0,y.useState)(null),[Z,yt]=(0,y.useState)(!1),bt=(0,y.useRef)(0),[xt,St]=(0,y.useState)([]),[Ct,wt]=(0,y.useState)(!1),[Tt,Et]=(0,y.useState)(null),[Dt,Ot]=(0,y.useState)(`whatsapp`),kt=(0,y.useCallback)(e=>{if(x(),!n){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),B({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),B({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),ie(n,e.downloadPath,e.downloadRoot??`data`),B({message:`Downloading ${e.name}`,failed:!1})},[n,x]);(0,y.useEffect)(()=>{if(!z)return;let e=setTimeout(()=>B(null),2500);return()=>clearTimeout(e)},[z]);let At=U!=null&&H.some(e=>e.sessionId===U);(0,y.useEffect)(()=>{U==null||!W||console.info(`[sidebar-sessions] op=select-highlight session=${U.slice(0,8)} matched=${At}`)},[U,At,W]);let jt=(0,y.useCallback)(async()=>{if(n){Te(!0),Ce(null);try{let e=await A(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);L((await e.json()).artefacts??[]),Se(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Ce(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{Te(!1)}}},[n,A]),Q=(0,y.useCallback)(async()=>{if(!n)return null;let e=++bt.current;We(!0),Re(null);try{let t=await A(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===bt.current?(Fe(r),Ze(n.accountId??null),Ie(!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===bt.current&&Re(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===bt.current&&We(!1)}},[n,A]),Mt=(0,y.useCallback)(async()=>{if(n){Et(null);try{let e=await A(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);St((await e.json()).conversations??[]),wt(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Et(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[n,A]);(0,y.useEffect)(()=>{!n||W||Q()},[n,W,Q]),(0,y.useEffect)(()=>{if(!n)return;let e=null;return Mt(),e=setInterval(()=>{Mt()},Ge),()=>{e!==null&&clearInterval(e)}},[n,Mt]),(0,y.useEffect)(()=>{if(!n)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function r(){e===null&&(e=setInterval(t,Ke))}function i(){e!==null&&(clearInterval(e),e=null)}function a(){document.hidden?i():(t(),r())}return document.hidden||r(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[n,Q]);let Nt=(0,y.useMemo)(()=>{let e=new Map;for(let t of ae)e.set(t,[]);for(let t of xt)e.get(t.channel)?.push(t);for(let t of ae)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[xt]),Pt={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},Ft=()=>{O(null),F(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${xe?I.length:0} collapsed=${S}`),jt()},$=1.5,It=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),jt()},Lt=()=>{O(null),F(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${W?H.length:0} collapsed=${S}`),W||Q()},Rt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},zt=()=>{F(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${S}`),k(),x()},Bt=e=>{_e?.(),F(`whatsapp`),Ot(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${Nt.get(e)?.length??0} collapsed=${S}`)},Vt=(0,y.useCallback)(async e=>{if(tt.has(e.sessionId))return;nt(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await A(`/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=Ve(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`?(x(),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}`),V(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}`),V({sessionId:e.sessionId,reason:r})}finally{nt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[A,x,tt]),Ht=(0,y.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=Be.length;n++){await new Promise(e=>setTimeout(e,Be[n-1]));let r=await Q();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}`)},[Q]),Ut=(0,y.useCallback)(async()=>{if(!Z){yt(!0);try{let e=await A(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=Ve(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?Ht(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):e.status===503||n.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),Ne(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),V(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),V({sessionId:null,reason:t})}finally{yt(!1)}}},[A,Z,Ht]),Wt=(0,y.useCallback)((e,t)=>{e.stopPropagation(),et(t)},[]),Gt=(0,y.useCallback)(async(e,t)=>{e.stopPropagation(),ft(t),mt(null),vt(null),gt(!0);try{let e=await A(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?mt(n):vt(n.error??`status ${e.status}`)}catch(e){vt(e instanceof Error?e.message:String(e))}finally{gt(!1)}},[A]),Kt=(0,y.useCallback)(async e=>{if(!J.has(e.sessionId)){Qe(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await A(`/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(()=>({}));console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),B({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0});return}let n=await t.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),Fe(t=>t.filter(t=>t.sessionId!==e.sessionId)),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),B({message:`Delete failed: ${n}`,failed:!0})}finally{Qe(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[A,J,Q]),qt=(0,y.useCallback)(async(e,t)=>{if(e.stopPropagation(),!rt.has(t.sessionId)){it(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await A(`/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`}`),B({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),B({message:`Stop failed: ${n}`,failed:!0})}finally{it(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[A,rt,Q]),Jt=(0,y.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!at.has(t.sessionId)){ot(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await A(`/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`}`),B({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}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}`),B({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{ot(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[A,at,Q]),Yt=(0,y.useCallback)(async e=>{let t=ct.trim();if(!t){B({message:`Title can’t be empty`,failed:!0});return}if(t.length>ze){B({message:`Title too long (max ${ze})`,failed:!0});return}ut(!0);try{let n=await A(`/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}`),B({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),st(null),X(``),Q()}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}`),B({message:`Rename failed: ${n}`,failed:!0})}finally{ut(!1)}},[A,ct,Q]);return(0,b.jsxs)(`aside`,{className:`side`,children:[(0,b.jsx)(`div`,{className:`side-new-session-row`,children:(0,b.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:Ut,disabled:Z,"aria-busy":Z,children:[(0,b.jsx)(ee,{size:14}),(0,b.jsx)(`span`,{children:Z?`Spawning…`:`New session`})]})}),(0,b.jsxs)(`nav`,{className:`side-nav`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),m(),x()},children:[(0,b.jsx)(he,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`People`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),v(),x()},children:[(0,b.jsx)(T,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Agents`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),f(),x()},children:[(0,b.jsx)(de,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:p().term}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),h(),x()},children:[(0,b.jsx)(pe,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${P===`artefacts`?` active`:``}`,onClick:Ft,children:[(0,b.jsx)(re,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${P===`sessions`?` active`:``}`,onClick:Lt,children:[(0,b.jsx)(fe,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${P===`data`?` active`:``}`,onClick:zt,children:[(0,b.jsx)(a,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Data`}),(0,b.jsx)(`span`,{className:`kbd`})]}),Ct&&ae.filter(e=>Nt.get(e).length>0).map(e=>(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${P===`whatsapp`&&Dt===e?` active`:``}`,onClick:()=>Bt(e),children:[(0,b.jsx)(ne,{channel:e,size:16}),(0,b.jsx)(`span`,{className:`label`,children:Pt[e]}),(0,b.jsx)(`span`,{className:`kbd`})]},e)),Tt&&(0,b.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,b.jsx)(`span`,{className:`label`,children:Tt})})]}),P===`artefacts`&&(0,b.jsxs)(`div`,{className:`side-list`,children:[(0,b.jsxs)(`div`,{className:`group-head`,children:[(0,b.jsx)(`span`,{children:`Artefacts`}),(0,b.jsxs)(`span`,{className:`group-head-meta`,children:[(0,b.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:It,disabled:we,children:(0,b.jsx)(_,{size:12,className:we?`spinning`:void 0})}),(0,b.jsx)(`span`,{children:we?`…`:String(I.length)})]})]}),R&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:R}),xe&&!R&&I.length>0&&(()=>{let e=I.filter(e=>e.kind===`agent-template`).length,t=I.length-e;return(0,b.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:I.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,b.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${Ee===e.key?` active`:``}`,onClick:()=>De(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,b.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),xe&&!R&&I.length===0&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),I.filter(e=>Ee===`all`?!0:Ee===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?T:re,r=He(e.updatedAt),i=e.downloadPath!==null;return(0,b.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>kt(e),disabled:!i,style:i?void 0:{cursor:`default`},title:i?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,b.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,b.jsxs)(`span`,{className:`conv-stack`,children:[(0,b.jsx)(`span`,{className:`conv-name-line`,children:(0,b.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,b.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),i&&(0,b.jsx)(te,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),P===`sessions`&&(()=>{let e=H.filter(e=>K?!0:!e.isSubagent).filter(e=>q?!0:!e.archived),t=H.some(e=>e.isSubagent),n=H.some(e=>e.archived);return(0,b.jsxs)(`div`,{className:`side-list`,children:[(0,b.jsxs)(`div`,{className:`group-head`,children:[(0,b.jsx)(`span`,{children:`Sessions`}),(0,b.jsxs)(`span`,{className:`group-head-meta`,children:[(0,b.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Rt,disabled:Ue,children:(0,b.jsx)(_,{size:12,className:Ue?`spinning`:void 0})}),(0,b.jsx)(`span`,{children:Ue?`…`:String(e.length)})]})]}),Xe&&(0,b.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,b.jsx)(`code`,{children:Xe})}),(t||n)&&(0,b.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,b.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${K?` active`:``}`,"aria-pressed":K,onClick:()=>Je(e=>!e),title:K?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),n&&(0,b.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${q?` active`:``}`,"aria-pressed":q,onClick:()=>Ye(e=>!e),title:q?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),G&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:G}),W&&!G&&e.length===0&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=He(e.startedAt),n=tt.has(e.sessionId),r=J.has(e.sessionId),a=rt.has(e.sessionId),o=at.has(e.sessionId),s=n||r||a||o,c=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},l=[{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,b.jsx)(i,{size:12}),busy:n,onClick:()=>{Vt(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,b.jsx)(me,{size:12}),onClick:()=>{c()}},{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,b.jsx)(E,{size:12}),onClick:t=>{Gt(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,b.jsx)(le,{size:12}),busy:a,onClick:t=>{qt(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,b.jsx)(ue,{size:12}),busy:o,onClick:t=>{Jt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,b.jsx)(w,{size:12}),busy:o,onClick:t=>{Jt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,b.jsx)(oe,{size:12}),busy:lt&&Y===e.sessionId,onClick:t=>{t.stopPropagation(),st(e.sessionId),X(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,b.jsx)(d,{size:12}),danger:!0,busy:r,onClick:t=>{Wt(t,e)}},ye({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})];return(0,b.jsxs)(`div`,{className:`conv conv-with-actions${e.sessionId===U?` active`:``}`,children:[(0,b.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${e.personName??e.title} in webchat`,onClick:()=>{Y!==e.sessionId&&c()},onKeyDown:t=>{Y!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),c())},children:[(0,b.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,b.jsxs)(`span`,{className:`conv-stack`,children:[(0,b.jsxs)(`span`,{className:`conv-name-line`,children:[e.channel&&(0,b.jsx)(ce,{channel:e.channel,size:13}),Y===e.sessionId?(0,b.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:ct,disabled:lt,"aria-label":`New title for session ${e.title}`,onChange:e=>X(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),Yt(e)):t.key===`Escape`&&(t.preventDefault(),st(null),X(``))},onBlur:()=>{Y===e.sessionId&&!lt&&(st(null),X(``))}}):(0,b.jsx)(`span`,{className:`conv-name`,title:e.personName??e.title,children:e.personName??e.title})]}),(0,b.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,b.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,b.jsxs)(`span`,{children:[` · `,t]})]})]})]}),(0,b.jsx)(be,{actions:l,disabled:s})]},e.sessionId)})]})})(),P===`whatsapp`&&(0,b.jsxs)(`div`,{className:`side-list`,children:[(0,b.jsxs)(`div`,{className:`group-head`,children:[(0,b.jsx)(`span`,{children:Pt[Dt]}),(0,b.jsxs)(`span`,{className:`group-head-meta`,children:[(0,b.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{Mt()},children:(0,b.jsx)(_,{size:12})}),(0,b.jsx)(`span`,{children:String(Nt.get(Dt).length)})]})]}),Nt.get(Dt).map(e=>{let t=He(e.lastMessageAt),n=se(e);return(0,b.jsxs)(`div`,{className:`conv conv-with-actions${e.source===`store`?e.scope===`admin`?` conv-scope-admin`:` conv-scope-public`:``}${C===n?` active`:``}`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{O(e),x()},title:e.title,children:[(0,b.jsx)(ne,{channel:e.channel,size:14}),(0,b.jsxs)(`span`,{className:`conv-stack`,children:[(0,b.jsx)(`span`,{className:`conv-name-line`,children:(0,b.jsx)(`span`,{className:`conv-name`,children:g(e)})}),t&&(0,b.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),e.source===`session`&&(0,b.jsx)(be,{actions:[ye({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1})]},n)})]}),(0,b.jsx)(qe,{}),(0,b.jsxs)(`div`,{className:`side-foot`,children:[(0,b.jsx)(`div`,{className:`avatar`,children:u?(0,b.jsx)(`img`,{src:u,alt:M}):N}),(0,b.jsxs)(`div`,{className:`who`,children:[(0,b.jsx)(`span`,{className:`name`,children:M}),(0,b.jsx)(`span`,{className:`role`,children:c??`operator`})]})]}),z&&(0,b.jsx)(`div`,{className:`copy-toast${z.failed?` copy-toast-failed`:``}`,role:`status`,children:z.message}),(0,b.jsx)(Me,{error:ke,onClose:()=>V(null)}),(0,b.jsx)(Pe,{open:je,onConnect:()=>{Ne(!1),r?.()},onClose:()=>Ne(!1)}),(0,b.jsx)(Ae,{target:$e,onCancel:()=>et(null),onConfirm:()=>{let e=$e;et(null),e&&Kt(e)}}),(0,b.jsx)(Le,{show:dt!==null,onClose:()=>{ft(null),mt(null),vt(null)},sessionId:dt?.sessionId??null,summary:pt,loading:ht,error:_t})]})}var We=5e3,Ge=3e4,Ke=3e4;function qe(){let[e,t]=(0,y.useState)(null);if((0,y.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()},We))}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=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,b.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,b.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,b.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,b.jsx)(`div`,{className:`system-stats__bar`,children:(0,b.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,b.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,b.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,b.jsx)(`div`,{className:`system-stats__bar`,children:(0,b.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var K=`admin-sidebar-collapsed`,Je=`admin-sidebar-drawer-open`;function q(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(K)===`1`}catch{return!1}}function Ye(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(K,`1`):window.sessionStorage.removeItem(K)}catch{}}function Xe(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Je)===`1`}catch{return!1}}function Ze(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Je,`1`):window.sessionStorage.removeItem(Je)}catch{}}function J(e){let[t,n]=(0,y.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,y.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 Qe=720;function $e(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function et(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function tt(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 nt(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function rt(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function it(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:s,onConnectClaude:c,userName:l,userAvatar:d,role:m,onOpenConversations:h,children:g,footer:_}=e,{subAccounts:ee,activeAccountId:te,switching:ne,switchAccount:re,refreshAccounts:ie}=f(t),[ae,oe]=(0,y.useState)(!0);(0,y.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||oe(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[s,r]);let ce=s??ae,le=c??(()=>{window.location.assign(`/?connect=claude`)}),[v,x]=(0,y.useState)(()=>q()),[S,C]=(0,y.useState)(()=>Xe()),ue=J(`(max-width: ${Qe}px)`),[w,T]=(0,y.useState)(()=>typeof window>`u`||nt(window.location.pathname,window.location.search)?null:tt(window.location.pathname,window.location.search)),[de]=(0,y.useState)(()=>w!==null),[E,fe]=(0,y.useState)(()=>typeof window>`u`?!1:nt(window.location.pathname,window.location.search)),[pe]=(0,y.useState)(()=>E),me=(0,y.useCallback)(e=>{Ye(e),x(e)},[]),D=(0,y.useCallback)(e=>{Ze(e),C(e)},[]);(0,y.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=${v} drawer=${S}`)},[]),(0,y.useEffect)(()=>{typeof window>`u`||!w||(console.info(`[admin-ui] wa-hydrate route=/ remoteJid=${w.remoteJid??``}`),window.history.replaceState(null,``,`/`))},[]),(0,y.useEffect)(()=>{typeof window>`u`||!E||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let he=(0,y.useCallback)(e=>{if(fe(!1),e===null){T(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=$e(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?T(e):window.location.href=n.href},[]),O=(0,y.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=et(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}T(null),fe(!0)},[]),ge=ue?S:!v,k=(0,y.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${Qe}px)`).matches){let e=S;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),D(!e)}else{let e=v;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),me(!e)}},[v,S,me,D]),_e=(0,y.useCallback)(e=>{let t=rt(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),A={collapsed:v,mobileDrawerOpen:S,sidebarOpen:ge,onToggleSidebar:k,setMobileDrawerOpen:D,selectedWhatsapp:w,onClearWhatsapp:()=>T(null),dataOpen:E};return r===`operator`?(0,b.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,b.jsx)(u,{businessName:n,variant:r,onNavigate:_e,onOpenConversations:h,onToggleSidebar:k,sidebarOpen:ge,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t,subAccounts:ee,activeAccountId:te,switchingAccount:ne,onSwitchAccount:re,refreshAccounts:ie}),(0,b.jsx)(`div`,{className:`platform platform-operator`,children:typeof g==`function`?g(A):g}),_]}):(0,b.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,b.jsx)(u,{businessName:n,variant:r,onNavigate:_e,onOpenConversations:h,onToggleSidebar:k,sidebarOpen:ge,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:ce,onConnectClaude:le,cacheKey:t,subAccounts:ee,activeAccountId:te,switchingAccount:ne,onSwitchAccount:re,refreshAccounts:ie}),(0,b.jsxs)(`div`,{className:`platform${S?` menu-open`:``}${v?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,b.jsx)(Ue,{businessName:n,cacheKey:t,onConnectClaude:le,role:m??null,userName:l,userAvatar:d??null,onSelectProjects:()=>{window.location.href=`/graph?label=${p().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/tasks`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>D(!1),collapsed:v,mobileDrawerOpen:S,selectedWhatsappId:w?se(w):null,onSelectWhatsappConversation:he,initialWhatsappSurface:de,onSelectData:O,onCloseData:()=>fe(!1),initialDataSurface:pe}),!ue&&(0,b.jsx)(ve,{}),typeof g==`function`?g(A):g]}),S&&(0,b.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>D(!1)}),_]})}export{w as _,Ne as a,v as b,j as c,F as d,he as f,T as g,E as h,Pe as i,M as l,pe as m,J as n,V as o,D as p,Ve as r,N as s,it as t,xe as u,ue as v,C as y};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-Ck5AOu5v.js";import{S as t,r as n,w as r,y as i}from"./useSubAccountSwitcher-DyjTbzQR.js";import{n as a,t as o}from"./AdminLoginScreens-BM45lL5G.js";import{a as s}from"./audio-attachment-mime-Cx5d3Jls.js";import{a as c,t as l}from"./AdminShell-BfLQQ27Z.js";import"./Checkbox-BC0c_gbn.js";import{n as u,r as d}from"./page-B7nCws9K.js";import{a as f,s as p}from"./file-download-B2B2DTar.js";import"./graph-labels-DxqDdO7G.js";var m=t(),h=e(r(),1),g=i();function _({onOpen:e}){return(0,g.jsx)(`footer`,{className:`admin-footer`,children:(0,g.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,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,g.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function v(){let e=a(),[t,r]=(0,h.useState)(!1);(0,h.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&r(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let i=(0,h.useCallback)(async()=>{let t=e.claudeInfo!=null;if(r(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let n=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-n}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-n} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),m=(0,h.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,g.jsx)(n,{cacheKey:e.cacheKey,onSessionExpired:m,surface:`chat`,children:(0,g.jsx)(l,{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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(_,{onOpen:i}),(0,g.jsx)(c,{show:t,onClose:()=>r(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,g.jsx)(g.Fragment,{children:t.dataOpen&&e.cacheKey?(0,g.jsx)(u,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?t.selectedWhatsapp.source===`store`&&t.selectedWhatsapp.remoteJid&&t.selectedWhatsapp.accountId?(0,g.jsx)(d,{accountId:t.selectedWhatsapp.accountId,remoteJid:t.selectedWhatsapp.remoteJid,contactName:f(t.selectedWhatsapp),sessionKey:e.cacheKey},p(t.selectedWhatsapp)):(0,g.jsx)(s,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,forceDeliveredOnly:!0},p(t.selectedWhatsapp)):(0,g.jsx)(`main`,{})})})}):(0,g.jsx)(o,{auth:e})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(v,{}));
@@ -1 +0,0 @@
1
- import"./chunk-K5T4RW27-5ucpeRvm.js";import{n as e}from"./chunk-7N4EOEYR-BRH9iM9L.js";export{e as createArchitectureServices};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-render-jAQU0nXt.js","assets/preload-helper-ClBMtM1g.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./chunk-Ck5AOu5v.js";import{a as t,m as n,w as r,y as i}from"./useSubAccountSwitcher-DyjTbzQR.js";import{h as a}from"./file-download-B2B2DTar.js";import{t as o}from"./maximize-2-DKx6OBKv.js";import{t as s}from"./preload-helper-ClBMtM1g.js";var c=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar,application/zip,application/x-zip-compressed,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.oasis.opendocument.text,text/rtf,application/rtf,audio/ogg,audio/opus,audio/mp4,audio/x-m4a,audio/mpeg,audio/webm,audio/wav,video/mp4,.docx,.odt,.rtf,.opus,.ogg,.m4a,.mp4,.mp3,.wav,.webm`,l=new Set(c.split(`,`).filter(e=>!e.startsWith(`.`))),u=50*1024*1024;function d(e){switch(e){case`expanded`:return!0;case`collapsed`:return!1;default:return}}var f=n(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),p=n(`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`}]]),m=n(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),h=n(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),g=e(r(),1),_=i();function v({children:e,tail:t=null,repinSignals:n}){let r=(0,g.useRef)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(!0),[o,s]=(0,g.useState)(!0),c=(0,g.useRef)(0),l=(0,g.useRef)(0),u=()=>{let e=r.current;if(!e)return;let t=e.clientHeight,n=e.scrollHeight,i=t!==c.current||n!==l.current;if(c.current=t,l.current=n,i){a.current&&(e.scrollTop=e.scrollHeight);return}let o=n-e.scrollTop-t<=32;a.current=o,s(e=>e===o?e:o)},d=()=>{let e=r.current;e&&(e.scrollTop=e.scrollHeight,l.current=e.scrollHeight,c.current=e.clientHeight,a.current=!0,s(!0))},f=t!=null;return(0,g.useLayoutEffect)(()=>{let e=r.current;e&&a.current&&(e.scrollTop=e.scrollHeight),e&&(l.current=e.scrollHeight,c.current=e.clientHeight)},[...n,f]),(0,g.useLayoutEffect)(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>u());return r.current&&e.observe(r.current),i.current&&e.observe(i.current),()=>e.disconnect()},[]),(0,_.jsxs)(`div`,{className:`wa-reader`,children:[(0,_.jsx)(`div`,{className:`wa-reader-thread`,ref:r,onScroll:u,children:(0,_.jsxs)(`div`,{className:`wa-thread-scroll`,ref:i,children:[e,t]})}),!o&&(0,_.jsx)(`button`,{type:`button`,className:`wa-jump`,onClick:d,"aria-label":`Jump to latest message`,title:`Jump to latest message`,children:`↓`})]})}var y={auth_expired:`Your session has expired. Please sign in again.`,claude_down:`Claude is currently experiencing an outage. Please try again in a few minutes.`,claude_overloaded:`Claude is overloaded right now. Please try again shortly.`,model_unavailable:`The selected model is currently unavailable. Switch to a different model from the model picker to continue.`,agent_error:`Something went wrong. Please try again.`},b={auth_expired:`I'm not available right now. Please try again later.`,claude_down:`I'm not available right now. Please try again later.`,claude_overloaded:`I'm not available right now. Please try again shortly.`,model_unavailable:`I'm not available right now. Please try again later.`,agent_error:`I'm not available right now. Please try again later.`};function x(e,t=`admin`){return t===`public`?b[e]:y[e]}function S(e){return e===`whatsapp`?` · via WhatsApp`:e===`webchat`?` · via web`:``}var C=/\.(png|jpe?g|gif|webp|svg|bmp)$/i,w=/\.pdf$/i;function T(e,t){return(t?t.startsWith(`image/`):C.test(e))?`image`:t&&t.startsWith(`audio/`)?`audio`:(t?t===`application/pdf`:w.test(e))?`pdf`:`file`}function E(e,t,n,r){let i=encodeURIComponent(e.path),a=encodeURIComponent(n),o=r?`&disposition=${r}`:``;return e.root===`scratchpad`?`/api/admin/files/download?path=${i}&root=scratchpad&sessionId=${encodeURIComponent(t)}&session_key=${a}${o}`:`/api/admin/files/download?path=${i}&root=data&session_key=${a}${o}`}function D(e,t,n,r){return t===`public`?`/api/public-reader/attachment/${e}?sessionId=${encodeURIComponent(n)}`:`/api/admin/attachment/${e}?session_key=${encodeURIComponent(r)}`}function O(e){if(e<1024)return`${e} B`;let t=e/1024;if(t<1024)return`${t<10?t.toFixed(1):Math.round(t)} KB`;let n=t/1024;return`${n<10?n.toFixed(1):Math.round(n)} MB`}function k({href:e,filename:t,label:n}){return(0,_.jsxs)(`a`,{className:`chat-attachment-chip`,href:e,download:t,children:[(0,_.jsx)(h,{size:14,"aria-hidden":!0}),n]})}function A({href:e,filename:t,className:n,size:r=14,onClick:i}){return(0,_.jsx)(`a`,{className:n,href:e,download:t,"aria-label":`Download ${t}`,onClick:i,children:(0,_.jsx)(a,{size:r,"aria-hidden":!0})})}function j({src:e,filename:t,sizeBytes:n,expandable:r,onFail:i}){let[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(!1),l=n==null?t:`${t} · ${O(n)}`;return s?(0,_.jsx)(k,{href:e,filename:t,label:l}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`span`,{className:`chat-attachment-image-wrap`,children:[(0,_.jsx)(`img`,{className:`chat-attachment-image`,src:e,alt:t,onClick:r?()=>o(!0):void 0,onError:()=>{c(!0),i?.(`fetch`)}}),(0,_.jsx)(A,{href:e,filename:t,className:`chat-attachment-download`})]}),r&&a&&(0,_.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":t,onClick:()=>o(!1),children:(0,_.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:e,alt:t})})]})}var M=280,ee=360,N=16;function P({src:e,filename:t,sizeBytes:n,onFail:r}){let[i,a]=(0,g.useState)(!1),[c,l]=(0,g.useState)(!1),u=(0,g.useRef)(null),d=n==null?t:`${t} · ${O(n)}`;return(0,g.useEffect)(()=>{let t=!1,n=null;return(async()=>{try{let{loadPdf:r,renderPageToFit:i}=await s(async()=>{let{loadPdf:e,renderPageToFit:t}=await import(`./pdf-render-jAQU0nXt.js`);return{loadPdf:e,renderPageToFit:t}},__vite__mapDeps([0,1])),a=await r(e);n=a;let o=u.current;if(t||!o)return;await i(a,1,o,M,ee)}catch{t||(l(!0),r?.(`render`))}})(),()=>{t=!0;try{n?.destroy()}catch{}}},[e]),c?(0,_.jsx)(k,{href:e,filename:t,label:d}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`chat-attachment-pdf`,children:[(0,_.jsx)(`canvas`,{ref:u,className:`chat-attachment-pdf-canvas`,"aria-label":t}),(0,_.jsx)(A,{href:e,filename:t,className:`chat-attachment-download`}),(0,_.jsx)(`button`,{type:`button`,className:`chat-attachment-pdf-expand`,"aria-label":`Expand ${t}`,onClick:()=>a(!0),children:(0,_.jsx)(o,{size:14,"aria-hidden":!0})})]}),i&&(0,_.jsx)(F,{src:e,filename:t,label:d,onClose:()=>a(!1),onFail:r})]})}function F({src:e,filename:n,label:r,onClose:i,onFail:a}){let o=(0,g.useRef)(null),c=(0,g.useRef)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(!1);return(0,g.useEffect)(()=>{let t=!1;return(async()=>{try{let{loadPdf:n}=await s(async()=>{let{loadPdf:e}=await import(`./pdf-render-jAQU0nXt.js`);return{loadPdf:e}},__vite__mapDeps([0,1])),r=await n(e);if(t){try{r.destroy()}catch{}return}c.current=r,u(r.numPages)}catch{t||(f(!0),a?.(`render`))}})(),()=>{t=!0;try{c.current?.destroy()}catch{}}},[e]),(0,g.useEffect)(()=>{if(l==null)return;let e=o.current,t=c.current;if(!e||!t)return;let n=!1;return(async()=>{try{let{renderPageToWidth:r}=await s(async()=>{let{renderPageToWidth:e}=await import(`./pdf-render-jAQU0nXt.js`);return{renderPageToWidth:e}},__vite__mapDeps([0,1])),i=Array.from(e.querySelectorAll(`canvas.chat-attachment-overlay-page`)),a=Math.max(e.clientWidth-N*2,1);for(let e=0;e<i.length;e++){if(n)return;await r(t,e+1,i[e],a)}}catch{n||(f(!0),a?.(`render`))}})(),()=>{n=!0}},[l]),(0,_.jsxs)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":n,onClick:i,children:[(0,_.jsx)(`div`,{ref:o,className:`chat-attachment-overlay-pdf`,onClick:e=>e.stopPropagation(),children:d?(0,_.jsx)(k,{href:e,filename:n,label:r}):Array.from({length:l??0},(e,t)=>(0,_.jsx)(`canvas`,{className:`chat-attachment-overlay-page`,"aria-label":`${n} page ${t+1}`},t))}),(0,_.jsx)(A,{href:e,filename:n,className:`chat-attachment-overlay-download`,size:20,onClick:e=>e.stopPropagation()}),(0,_.jsx)(`button`,{type:`button`,className:`chat-attachment-overlay-close`,"aria-label":`Close`,onClick:i,children:(0,_.jsx)(t,{size:20,"aria-hidden":!0})})]})}function I({filename:e,href:t,mimeType:n,sizeBytes:r,expandable:i,telemetry:a}){let o=T(e,n);(0,g.useEffect)(()=>{a?.onRender?.({kind:o,mime:n,served:!!t})},[]);let s=a?.onFail?e=>a.onFail({kind:o===`pdf`?`pdf`:`image`,mime:n,reason:e}):void 0;if(o===`image`&&t)return(0,_.jsx)(j,{src:t,filename:e,sizeBytes:r,expandable:i,onFail:s});if(o===`audio`&&t)return(0,_.jsx)(`audio`,{className:`chat-attachment-audio`,controls:!0,preload:`metadata`,src:t});if(o===`pdf`&&t)return(0,_.jsx)(P,{src:t,filename:e,sizeBytes:r,onFail:s});let c=r==null?e:`${e} · ${O(r)}`;return t?(0,_.jsx)(k,{href:t,filename:e,label:c}):(0,_.jsxs)(`p`,{className:`chat-doc`,children:[(0,_.jsx)(h,{size:14,"aria-hidden":!0,style:{verticalAlign:`text-bottom`}}),` `,c]})}function L(e,t,n,r=`/api/whatsapp-reader/stream`,i=e,a=!0){let[o,s]=(0,g.useState)([]),[c,l]=(0,g.useState)(`open`),[u,d]=(0,g.useState)(null),f=(0,g.useRef)([]);return(0,g.useEffect)(()=>{f.current=o},[o]),(0,g.useEffect)(()=>{s([]),f.current=[],d(null)},[i,t,n,r]),(0,g.useEffect)(()=>{if(l(`open`),!a)return;let i=f.current.slice(),o=i.map(R),c=0,u=i.length>0,p=`${r}?sessionId=${encodeURIComponent(e)}&projectDir=${encodeURIComponent(t)}&session_key=${encodeURIComponent(n)}`,m=new EventSource(p);return m.onopen=()=>{console.info(`[admin-ui] wa-stream onopen sessionId=${e}`),l(`open`)},m.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(u){if(c<o.length&&R(t)===o[c]){c+=1;return}u=!1}s(e=>[...e,t])},m.addEventListener(`activity`,e=>{try{d(JSON.parse(e.data))}catch{}}),m.addEventListener(`activity-clear`,()=>d(null)),m.onerror=()=>{m.readyState===2&&(console.error(`[admin-ui] wa-stream onerror readyState=${m.readyState}`),l(`error`))},()=>m.close()},[e,t,n,r,i,a]),{turns:o,status:c,subagentActivity:u}}function R(e){return JSON.stringify(e)}function te(e,t,n,r=!0){let[i,a]=(0,g.useState)([]),[o,s]=(0,g.useState)(`open`);return(0,g.useEffect)(()=>{if(a([]),s(`open`),!r||!e||!t)return;let i=`/api/whatsapp-reader/store-stream?accountId=${encodeURIComponent(e)}&remoteJid=${encodeURIComponent(t)}&session_key=${encodeURIComponent(n)}`,o=new EventSource(i);return o.onopen=()=>s(`open`),o.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}a(e=>[...e,t])},o.onerror=()=>{o.readyState===2&&s(`error`)},()=>o.close()},[e,t,n,r]),{turns:i,status:o}}var z=e=>{if(!e)return 1/0;let t=new Date(e).getTime();return Number.isNaN(t)?1/0:t};function ne(e,t){let n=[],r=0;return e.forEach((e,t)=>n.push({sort:z(e.ts),sub:1,ins:r++,item:{kind:`turn`,turn:e,idx:t}})),t.forEach(e=>n.push({sort:z(e.ts),sub:0,ins:r++,item:{kind:`directive`,entry:e}})),n.sort((e,t)=>e.sort===t.sort?e.sort===1/0?e.ins-t.ins:e.sub-t.sub||e.ins-t.ins:e.sort<t.sort?-1:1).map(e=>e.item)}function re(e,t,n=!0){let[r,i]=(0,g.useState)([]);return(0,g.useEffect)(()=>{if(!n||typeof fetch!=`function`)return;let r=!0,a=`/api/whatsapp-reader/directives?sessionId=${encodeURIComponent(e)}&session_key=${encodeURIComponent(t)}`;return fetch(a).then(e=>e.ok?e.json():{entries:[]}).then(e=>{r&&i(Array.isArray(e.entries)?e.entries:[])}).catch(()=>{r&&i([])}),()=>{r=!1}},[e,t,n]),r}var ie=new Set([`operator-inbound`,`operator-typed`,`agent-reply`,`agent-reply-document`,`agent-file`,`agent-error`,`agent-webchat-final`,`whatsapp-persisted`]);function B(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function V(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}var H=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],U=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function W(e){let t=String(e.getMonth()+1).padStart(2,`0`),n=String(e.getDate()).padStart(2,`0`);return`${e.getFullYear()}-${t}-${n}`}function G(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:W(t)}function K(e,t=new Date){if(!e)return``;let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=W(n);if(r===W(t))return`Today`;let i=new Date(t);return i.setDate(i.getDate()-1),r===W(i)?`Yesterday`:`${H[n.getDay()]} ${n.getDate()} ${U[n.getMonth()]} ${n.getFullYear()}`}function q(e){return e.kind===`turn`?e.turn.ts:e.entry.ts}function J({ts:e}){return(0,_.jsx)(`div`,{className:`day-divider`,role:`separator`,children:(0,_.jsx)(`span`,{className:`day-divider-label`,children:K(e)})})}function Y(){return(0,_.jsx)(`div`,{className:`session-divider`,role:`separator`,children:(0,_.jsx)(`span`,{className:`session-divider-label`,children:`Conversation continued`})})}function X({label:e,ts:t}){return(0,_.jsxs)(`div`,{className:`wa-turn-head`,children:[(0,_.jsx)(`span`,{className:`wa-who`,children:e}),(0,_.jsx)(`time`,{className:`wa-time`,children:B(t)})]})}function ae({turn:e}){let[t,n]=(0,g.useState)(!1),r=e.kind===`tool-result`,i=r?`wa-turn wa-turn-result${e.isError?` is-error`:``}`:`wa-turn wa-turn-tool`,a=r?e.isError?`result (error)`:`result`:`↳ ${e.name}`,o=r?e.text:JSON.stringify(e.input,null,2);return(0,_.jsxs)(`div`,{className:i,children:[(0,_.jsxs)(`button`,{type:`button`,className:`wa-tool-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,_.jsx)(`span`,{className:`wa-chevron`,children:t?`▾`:`▸`}),(0,_.jsx)(`span`,{className:`wa-who`,children:a}),(0,_.jsx)(`time`,{className:`wa-time`,children:B(e.ts)})]}),t&&(0,_.jsx)(`pre`,{className:`wa-code`,children:o})]})}function Z({entry:e,sessionId:t,sessionKey:n}){let[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),s=()=>{let s=!r;if(i(s),s&&a===null&&typeof fetch==`function`){let r=`/api/whatsapp-reader/directive?sessionId=${encodeURIComponent(t)}&name=${encodeURIComponent(e.name)}&session_key=${encodeURIComponent(n)}`;fetch(r).then(e=>e.ok?e.text():`(directive unavailable)`).then(o).catch(()=>o(`(directive unavailable)`))}};return(0,_.jsxs)(`div`,{className:`wa-turn wa-turn-directive`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`wa-tool-toggle`,"aria-expanded":r,onClick:s,children:[(0,_.jsx)(`span`,{className:`wa-chevron`,children:r?`▾`:`▸`}),(0,_.jsxs)(`span`,{className:`wa-who`,children:[`⚙ directive injected (`,e.len,` B)`]}),(0,_.jsx)(`time`,{className:`wa-time`,children:B(e.ts)})]}),r&&(0,_.jsx)(`pre`,{className:`wa-code`,children:a??`Loading…`})]})}var Q={onRender:({kind:e,mime:t,served:n})=>console.info(`[operator-ui] op=reader-attachment kind=${e} mime=${t??``} served=${n}`),onFail:({kind:e,mime:t,reason:n})=>console.info(`[operator-ui] op=reader-attachment-fail kind=${e} mime=${t??``} reason=${n}`)};function oe(e,t,n){switch(e.kind){case`operator-inbound`:return(0,_.jsxs)(`div`,{className:`wa-turn wa-turn-in`,children:[(0,_.jsx)(X,{label:`Operator${S(e.source)}`,ts:e.ts}),e.text&&(0,_.jsx)(`p`,{className:`wa-body`,children:e.text}),e.attachments&&e.attachments.length>0&&(0,_.jsx)(`div`,{className:`chat-attachment-list`,children:e.attachments.map((e,t)=>(0,_.jsx)(I,{expandable:!0,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,href:D(e.attachmentId,n.audience,n.sessionId,n.sessionKey),telemetry:Q},t))})]},t);case`operator-typed`:return(0,_.jsxs)(`div`,{className:`wa-turn wa-turn-in wa-turn-typed`,children:[(0,_.jsx)(X,{label:`Operator (web)`,ts:e.ts}),(0,_.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-text`:return(0,_.jsxs)(`div`,{className:`wa-turn wa-turn-think`,children:[(0,_.jsx)(X,{label:`Agent`,ts:e.ts}),(0,_.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-reply`:return(0,_.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,_.jsx)(X,{label:`Agent`,ts:e.ts}),(0,_.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-reply-document`:return(0,_.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,_.jsx)(X,{label:`Agent`,ts:e.ts}),(0,_.jsxs)(`p`,{className:`wa-doc`,children:[(0,_.jsx)(h,{size:14,"aria-hidden":!0,style:{verticalAlign:`text-bottom`}}),` `,`sent document(s): `,e.files.map(V).join(`, `)]}),e.caption&&(0,_.jsx)(`p`,{className:`wa-body`,children:e.caption})]},t);case`agent-file`:return(0,_.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,_.jsx)(X,{label:`Agent`,ts:e.ts}),e.files.map((t,r)=>{let i=V(t),a=e.downloads?.[r];return(0,_.jsx)(I,{expandable:!0,filename:i,href:a?E(a,n.sessionId,n.sessionKey,w.test(i)?`inline`:void 0):void 0,telemetry:Q},r)}),e.caption&&(0,_.jsx)(`p`,{className:`wa-body`,children:e.caption})]},t);case`whatsapp-persisted`:{let r=e.origin===`operator-manual`,i=e.fromMe?r?`You`:`Sent`:e.senderName??`Contact`;return(0,_.jsxs)(`div`,{className:`wa-turn ${e.fromMe?`wa-turn-out`:`wa-turn-in`}${r?` wa-op-manual`:``}`,children:[(0,_.jsx)(X,{label:i,ts:e.ts}),e.text&&(0,_.jsx)(`p`,{className:`wa-body`,children:e.text}),e.attachments&&e.attachments.length>0&&(0,_.jsx)(`div`,{className:`chat-attachment-list`,children:e.attachments.map((e,t)=>(0,_.jsx)(I,{expandable:!0,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,href:D(e.attachmentId,n.audience,n.sessionId,n.sessionKey),telemetry:Q},t))}),(0,_.jsxs)(`span`,{className:`wa-bubble-meta`,children:[r&&(0,_.jsx)(`span`,{className:`wa-op-tag`,children:`You`}),(0,_.jsx)(`time`,{className:`wa-bubble-time`,children:B(e.ts)}),e.fromMe&&(0,_.jsx)(f,{size:14,className:`wa-bubble-tick`,"aria-hidden":!0})]})]},t)}case`session-continued`:return(0,_.jsx)(Y,{},t);case`harness-internal`:return null;case`tool-call`:case`tool-result`:return(0,_.jsx)(ae,{turn:e},t);case`agent-error`:return(0,_.jsxs)(`div`,{className:`wa-turn wa-turn-error`,role:`alert`,children:[(0,_.jsx)(X,{label:`Agent`,ts:e.ts}),(0,_.jsx)(`p`,{className:`wa-body wa-error-body`,children:x(e.code,`admin`)}),e.code===`agent_error`&&e.raw&&(0,_.jsx)(`pre`,{className:`wa-code`,children:e.raw})]},t)}}function $(e,t,n,r=`admin`){let i={sessionId:t,sessionKey:n,audience:r},a=[],o=null;return e.forEach((e,r)=>{let s=q(e),c=G(s);c!==null&&c!==o&&(a.push((0,_.jsx)(J,{ts:s},`day-${r}`)),o=c),a.push(e.kind===`turn`?oe(e.turn,r,i):(0,_.jsx)(Z,{entry:e.entry,sessionId:t,sessionKey:n},r))}),a}function se(e){return e.filter(e=>e.kind===`turn`&&ie.has(e.turn.kind))}function ce({sessionId:e,projectDir:t,sessionKey:n,renderItems:r=$,clean:i,onToggleClean:a,forceDeliveredOnly:o=!1,streamEndpoint:s=`/api/whatsapp-reader/stream`,suppressDirectives:c=!1,tail:l=null,resetKey:u,onTurnsChange:d,onActivityChange:f,store:p}){let m=!!p,h=L(e,t,n,s,u,!m),y=te(p?.accountId??``,p?.remoteJid??``,n,m),{turns:b,status:x}=m?{turns:y.turns,status:y.status}:{turns:h.turns,status:h.status},S=m?null:h.subagentActivity;(0,g.useEffect)(()=>{f?.(S)},[S,f]),(0,g.useEffect)(()=>{d?.(b.length)},[b.length,d]);let C=ne(b,re(e,n,!c)),w=a==null?!1:!!i,T=o||w?se(C):C;return(0,_.jsxs)(v,{repinSignals:[b,w],tail:l,children:[x===`error`&&(0,_.jsx)(`div`,{className:`wa-reader-error`,children:`Stream disconnected.`}),b.length===0&&x===`open`&&(0,_.jsx)(`div`,{className:`wa-reader-placeholder`,children:`No messages in this conversation yet.`}),r(T,e,n)]})}function le(e,t){let n=e.split(`;`)[0].trim().toLowerCase();return t.has(n)}export{d as C,l as S,h as _,ce as a,c as b,B as c,P as d,C as f,x as g,E as h,Y as i,q as l,D as m,J as n,V as o,w as p,Z as r,G as s,le as t,I as u,m as v,u as x,p as y};
@@ -1 +0,0 @@
1
- import{it as e,rt as t}from"./chunk-ICPOFSXX-BaYgh8FR.js";var n=(n,r)=>e.lang.round(t.parse(n)[r]);export{n as t};
@@ -1 +0,0 @@
1
- import{S as e,y as t}from"./useSubAccountSwitcher-DyjTbzQR.js";import"./audio-attachment-mime-Cx5d3Jls.js";import"./AdminShell-BfLQQ27Z.js";import{n}from"./page-C3L6-Ufk.js";import"./useCopyFeedback-CPEOUSGU.js";import"./file-download-B2B2DTar.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
- import{m as e}from"./useSubAccountSwitcher-DyjTbzQR.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
@@ -1 +0,0 @@
1
- import{h as e,p as t}from"./src-DV4LKv2E.js";import{b as n}from"./chunk-ICPOFSXX-BaYgh8FR.js";var r=e(e=>{let{securityLevel:r}=n(),i=t(`body`);return r===`sandbox`&&(i=t((t(`#i${e}`).node()?.contentDocument??document).body)),i.select(`#${e}`)},`selectSvgElement`);export{r as t};
@@ -1 +0,0 @@
1
- import{h as e}from"./src-DV4LKv2E.js";var t=class{constructor(e){this.init=e,this.records=this.init()}static{e(this,`ImperativeState`)}reset(){this.records=this.init()}};export{t};
@@ -1 +0,0 @@
1
- import{h as e}from"./src-DV4LKv2E.js";import"./chunk-ICPOFSXX-BaYgh8FR.js";import"./dist-Cvgxm7qv.js";import"./chunk-5PVQY5BW-Ba8by6Uy.js";import"./chunk-U2HBQHQK-PwSQz6EP.js";import"./chunk-FMBD7UC4-CPvYEr54.js";import"./chunk-BSJP7CBP-C5GDAZTl.js";import"./chunk-ZZ45TVLE-CMPg670Q.js";import"./chunk-YZCP3GAM-D-9v8e--.js";import"./chunk-55IACEB6-BbzKMw2Z.js";import"./chunk-EDXVE4YY-CPSD3p6p.js";import"./chunk-X2U36JSP--NPHTBlU.js";import"./chunk-5FUZZQ4R-u19Nai9e.js";import"./chunk-ENJZ2VHE-D1oL-iUr.js";import"./chunk-336JU56O-CkdISfNt.js";import{i as t,n,r,t as i}from"./chunk-4TB4RGXK-CWyc_F7v.js";var a={parser:n,get db(){return new i},renderer:r,styles:t,init:e(e=>{e.class||={},e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute},`init`)};export{a as diagram};
@@ -1 +0,0 @@
1
- import{h as e}from"./src-DV4LKv2E.js";import"./chunk-ICPOFSXX-BaYgh8FR.js";import"./dist-Cvgxm7qv.js";import"./chunk-5PVQY5BW-Ba8by6Uy.js";import"./chunk-U2HBQHQK-PwSQz6EP.js";import"./chunk-FMBD7UC4-CPvYEr54.js";import"./chunk-BSJP7CBP-C5GDAZTl.js";import"./chunk-ZZ45TVLE-CMPg670Q.js";import"./chunk-YZCP3GAM-D-9v8e--.js";import"./chunk-55IACEB6-BbzKMw2Z.js";import"./chunk-EDXVE4YY-CPSD3p6p.js";import"./chunk-X2U36JSP--NPHTBlU.js";import"./chunk-5FUZZQ4R-u19Nai9e.js";import"./chunk-ENJZ2VHE-D1oL-iUr.js";import"./chunk-336JU56O-CkdISfNt.js";import{i as t,n,r,t as i}from"./chunk-4TB4RGXK-CWyc_F7v.js";var a={parser:n,get db(){return new i},renderer:r,styles:t,init:e(e=>{e.class||={},e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute},`init`)};export{a as diagram};
@@ -1 +0,0 @@
1
- import{i as e}from"./graphlib-DGPThX8M.js";var t=4;function n(n){return e(n,t)}export{n as t};
@@ -1 +0,0 @@
1
- import{S as e,y as t}from"./useSubAccountSwitcher-DyjTbzQR.js";import"./audio-attachment-mime-Cx5d3Jls.js";import{t as n}from"./page-B7nCws9K.js";import"./file-download-B2B2DTar.js";import"./graph-labels-DxqDdO7G.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
- import"./chunk-K5T4RW27-5ucpeRvm.js";import{n as e}from"./chunk-67CJDMHE-BwUuxtyb.js";export{e as createGitGraphServices};
@@ -1 +0,0 @@
1
- import"./chunk-K5T4RW27-5ucpeRvm.js";import{n as e}from"./chunk-KGLVRYIC-DW-FHk7T.js";export{e as createInfoServices};
@@ -1,2 +0,0 @@
1
- import"./chunk-K5T4RW27-5ucpeRvm.js";import"./chunk-7N4EOEYR-BRH9iM9L.js";import"./chunk-67CJDMHE-BwUuxtyb.js";import"./chunk-KGLVRYIC-DW-FHk7T.js";import"./chunk-FOC6F5B3-9Yyj7Vbz.js";import"./chunk-AA7GKIK3-BGoztgLL.js";import"./chunk-2KRD3SAO-DsgMtGkv.js";import"./chunk-ORNJ4GCN-Bv8EUa5d.js";import"./chunk-LIHQZDEY-CGGVfAyG.js";import"./chunk-CIAEETIT-ChY32VPS.js";import{g as e,h as t}from"./src-DV4LKv2E.js";import{c as n}from"./chunk-ICPOFSXX-BaYgh8FR.js";import{t as r}from"./chunk-426QAEUC-D-NcAlTW.js";import{t as i}from"./mermaid-parser.core-DFvbao9C.js";var a={parse:t(async t=>{let n=await i(`info`,t);e.debug(n)},`parse`)},o={version:`11.14.0`},s={parser:a,db:{getVersion:t(()=>o.version,`getVersion`)},renderer:{draw:t((t,i,a)=>{e.debug(`rendering info diagram
2
- `+t);let o=r(i);n(o,100,400,!0),o.append(`g`).append(`text`).attr(`x`,100).attr(`y`,40).attr(`class`,`version`).attr(`font-size`,32).style(`text-anchor`,`middle`).text(`v${a}`)},`draw`)}};export{s as diagram};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-Ck5AOu5v.js";import{S as t,w as n,y as r}from"./useSubAccountSwitcher-DyjTbzQR.js";import{n as i,t as a}from"./AdminLoginScreens-BM45lL5G.js";import"./audio-attachment-mime-Cx5d3Jls.js";import"./AdminShell-BfLQQ27Z.js";import"./Checkbox-BC0c_gbn.js";import{t as o}from"./page-C3L6-Ufk.js";import"./useCopyFeedback-CPEOUSGU.js";import"./file-download-B2B2DTar.js";var s=t(),c=e(n(),1),l=r();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"./chunk-K5T4RW27-5ucpeRvm.js";import{n as e}from"./chunk-FOC6F5B3-9Yyj7Vbz.js";export{e as createPacketServices};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-Ck5AOu5v.js";import{a as t,l as n,m as r,n as i,o as a,r as o,s,t as c,w as l,x as u,y as d}from"./useSubAccountSwitcher-DyjTbzQR.js";import{S as f,a as p,b as m,t as h,v as g,x as _,y as v}from"./audio-attachment-mime-Cx5d3Jls.js";import{t as y}from"./chevron-left-CLPxfjDV.js";import{a as b,c as x,d as ee,f as te,h as ne,i as re,m as ie,n as ae,p as oe,r as se,s as S,t as ce,u as le}from"./file-download-B2B2DTar.js";import{i as ue,t as C}from"./graph-labels-DxqDdO7G.js";var de=r(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),fe=r(`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`}]]),pe=r(`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`}]]),me=r(`folder`,[[`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`}]]),he=r(`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`}]]),ge=r(`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`}]]),_e=r(`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`}]]),ve=r(`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`}]]),w=r(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),ye=r(`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`}]]),T=r(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),be=r(`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`}]]),xe=r(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),E=r(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),D=e(l(),1);function Se(){let[e,t]=(0,D.useState)([]),[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(null),o=(0,D.useRef)(null),s=(0,D.useCallback)(e=>{a(null);let n=e.find(e=>!h(e.type,f));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>_);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,D.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,D.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,D.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,D.useCallback)(()=>{r(!1)},[]),onDrop:(0,D.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var O=d();function k({accountId:e,remoteJid:n,sessionKey:r}){let[i,a]=(0,D.useState)(``),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(null),{pendingFiles:u,attachError:d,fileInputRef:f,addFiles:p,removeFile:h,clearFiles:_}=Se(),v=(0,D.useRef)(!1),y=(i.trim().length>0||u.length>0)&&!o,b=(0,D.useCallback)(async()=>{if(!v.current&&!(i.trim().length===0&&u.length===0)){v.current=!0,s(!0),l(null);try{let t=`/api/whatsapp-reader/reply?session_key=${encodeURIComponent(r)}`,o;if(u.length>0){let r=new FormData;r.append(`accountId`,e),r.append(`remoteJid`,n),i.trim()&&r.append(`text`,i);for(let e of u)r.append(`files`,e);o=await fetch(t,{method:`POST`,body:r})}else o=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accountId:e,remoteJid:n,text:i})});let s=await o.json().catch(()=>({}));if(!o.ok){l(s.error??`Send failed.`),console.info(`[operator-ui] op=reply-fail remoteJid=${n} error=${s.error??`unknown`}`);return}a(``),_(),console.info(`[operator-ui] op=reply-sent remoteJid=${n} sent=${s.sent??0}`)}catch(e){l(`Could not reach the server. Try again.`),console.info(`[operator-ui] op=reply-fail remoteJid=${n} error=${String(e)}`)}finally{v.current=!1,s(!1)}}},[i,u,e,n,r,_]),x=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),y&&b())},ee=e=>e.startsWith(`image/`)?(0,O.jsx)(he,{size:14}):e===`application/pdf`?(0,O.jsx)(ie,{size:14}):(0,O.jsx)(g,{size:14});return(0,O.jsxs)(`div`,{className:`wa-reply`,children:[c&&(0,O.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:c}),d&&(0,O.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:d}),u.length>0&&(0,O.jsx)(`div`,{className:`wa-reply-attachments`,children:u.map((e,n)=>(0,O.jsxs)(`div`,{className:`wa-reply-chip`,children:[ee(e.type),(0,O.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>h(n),"aria-label":`Remove ${e.name}`,children:(0,O.jsx)(t,{size:12})})]},n))}),(0,O.jsxs)(`div`,{className:`wa-reply-row`,children:[(0,O.jsx)(`input`,{ref:f,type:`file`,multiple:!0,accept:m,style:{display:`none`},onChange:e=>{e.target.files&&p([...e.target.files]),e.target.value=``}}),(0,O.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:()=>f.current?.click(),disabled:o,"aria-label":`Attach files`,children:(0,O.jsx)(te,{size:22})}),(0,O.jsx)(`textarea`,{className:`wa-reply-input`,value:i,rows:1,placeholder:`Type a message`,disabled:o,onChange:e=>a(e.target.value),onKeyDown:x}),(0,O.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void b(),disabled:!y,"aria-label":`Send`,children:(0,O.jsx)(ye,{size:20})})]})]})}function A({accountId:e,remoteJid:t,contactName:n,sessionKey:r,onBack:i}){let a=x(t),o=t.split(`@`)[0],s=a?`Group`:n===`+${o}`?void 0:`+${o}`;return(0,O.jsxs)(`div`,{className:`wa-web`,children:[(0,O.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,O.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,O.jsx)(y,{size:20})}),(0,O.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,O.jsx)(xe,{size:20})}),(0,O.jsxs)(`div`,{className:`wa-web-titles`,children:[(0,O.jsx)(`span`,{className:`wa-web-name`,children:n}),s&&(0,O.jsx)(`span`,{className:`wa-web-subtitle`,children:s})]}),(0,O.jsxs)(`div`,{className:`wa-web-actions`,"aria-hidden":!0,children:[(0,O.jsx)(E,{size:20}),(0,O.jsx)(w,{size:20}),(0,O.jsx)(ue,{size:20}),(0,O.jsx)(v,{size:20})]})]}),(0,O.jsx)(`div`,{className:`wa-web-body`,children:(0,O.jsx)(p,{sessionId:``,projectDir:``,sessionKey:r,forceDeliveredOnly:!0,suppressDirectives:!0,store:{accountId:e,remoteJid:t}})}),a?(0,O.jsx)(`p`,{className:`wa-reply wa-reply-readonly`,children:`Group messages are read-only.`}):(0,O.jsx)(k,{accountId:e,remoteJid:t,sessionKey:r})]})}function Ce(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||C.has(e)&&(t.add(e),n.push(e)));return n}function j(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 we({conversations:e,sessionKey:t,onBack:n}){let[r,i]=(0,D.useState)(null),a=re(e);return r?r.source===`store`&&r.accountId&&r.remoteJid?(0,O.jsx)(A,{accountId:r.accountId,remoteJid:r.remoteJid,contactName:b(r),sessionKey:t,onBack:()=>i(null)},S(r)):(0,O.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,O.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>i(null),"aria-label":`Back to conversations`,children:[(0,O.jsx)(y,{size:16}),` Back`]}),(0,O.jsx)(`span`,{className:`op-conv-title`,children:b(r)})]}),(0,O.jsx)(p,{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},S(r))]}):(0,O.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,O.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,O.jsx)(y,{size:16}),` Chat`]}),(0,O.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),a.map(e=>(0,O.jsxs)(`div`,{className:`op-conv-group`,children:[(0,O.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,O.jsx)(le,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{console.info(`[operator-ui] op=reader-open channel=${e.channel} key=${S(e)} readonly=true source=${e.source}`),i(e)},children:[(0,O.jsx)(`span`,{className:`op-conv-name`,children:b(e)}),e.modelGated&&(0,O.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,O.jsx)(T,{size:13})}),(0,O.jsx)(`span`,{className:`op-conv-when`,children:j(e.lastMessageAt)})]},S(e)))]},e.channel))]})}var Te=/\.(png|jpe?g|gif|webp|svg)$/i;function Ee(e){return Te.test(e)}var De=`maxy-data-view`,Oe=95*1024*1024,ke=48*1024*1024;function Ae(){return typeof window>`u`?`list`:window.localStorage.getItem(De)===`grid`?`grid`:`list`}function je(){let[e,t]=(0,D.useState)(null),[r,i]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]),r?e?(0,O.jsx)(o,{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,O.jsx)(`div`,{className:`data-page data-page-full`,children:(0,O.jsx)(Me,{cacheKey:e})})}):(0,O.jsx)(`div`,{className:`data-page`,children:(0,O.jsxs)(`div`,{className:`data-empty`,children:[(0,O.jsx)(`p`,{children:`You are not signed in.`}),(0,O.jsxs)(`p`,{children:[`Open the `,(0,O.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,O.jsx)(`div`,{className:`data-page`,children:(0,O.jsxs)(`div`,{className:`data-loading`,children:[(0,O.jsx)(n,{size:18,className:`spin`}),` Loading…`]})})}function Me({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=u({initialCacheKey:e,surface:`data`});return(0,O.jsx)(Le,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function Ne(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function Pe(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function M(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function N(e){return new Promise((t,n)=>e.file(t,n))}async function Fe(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 N(r),relpath:e});else if(r.isDirectory){let t=await M(r.createReader());n.push(...await Fe(t,e))}}return n}function Ie(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 P({adminFetch:e,cacheKey:r,sessionRefetchNonce:i}){let[o,c]=(0,D.useState)(``),l=(0,D.useRef)(null),[u,d]=(0,D.useState)(``),[f,p]=(0,D.useState)(null),[m,h]=(0,D.useState)(`hybrid`),[g,_]=(0,D.useState)(!1),[v,y]=(0,D.useState)(null),[b,x]=(0,D.useState)(null),[te,re]=(0,D.useState)(0),[S,le]=(0,D.useState)(!1),[C,he]=(0,D.useState)(()=>Ne()),[w,ye]=(0,D.useState)(null),[T,xe]=(0,D.useState)(()=>Ae()),[E,Se]=(0,D.useState)(null),[k,A]=(0,D.useState)([]),[j,we]=(0,D.useState)(!1),[Te,je]=(0,D.useState)(null),[Me,M]=(0,D.useState)(!1),[N,P]=(0,D.useState)(null),[Le,F]=(0,D.useState)(null),[Be,Ve]=(0,D.useState)(null),[He,Ge]=(0,D.useState)(!1),[Ke,qe]=(0,D.useState)(null),I=(0,D.useRef)(null),[Je,L]=(0,D.useState)(0),[Ye,R]=(0,D.useState)(!1),[Xe,Ze]=(0,D.useState)(``),[z,B]=(0,D.useState)(null),[Qe,$e]=(0,D.useState)(``),[et,V]=(0,D.useState)(null),H=(()=>{let e=C===`.`?[]:C.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})(),[tt,nt]=(0,D.useState)(!1),rt=(0,D.useRef)(null),[it,U]=(0,D.useState)(!1),at=(0,D.useRef)(null);(0,D.useEffect)(()=>{let e=o.trim();if(!e){d(``),p(null),y(null);return}le(!1);let t=setTimeout(()=>d(e),300);return()=>clearTimeout(t)},[o]),(0,D.useEffect)(()=>{if(!u){_(!1);return}let t=!1;return _(!0),y(null),e(`/api/admin/graph-search?q=${encodeURIComponent(u)}&labels=FileArtifact&limit=20${S?`&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||(p(e.results),h(e.mode??`hybrid`),re(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||y(e instanceof Error?e.message:String(e))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[u,e,i,S]);let ot=(0,D.useMemo)(()=>f?Ce(f):[],[f]),W=b&&ot.includes(b)?b:null,st=(0,D.useMemo)(()=>f?W?f.filter(e=>e.labels.includes(W)):f:null,[f,W]),ct=(0,D.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=document.createElement(`a`);i.href=n,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[r]);(0,D.useEffect)(()=>{if(!f)return;let e=f.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(`,`)}`)},[f]),(0,D.useEffect)(()=>{let t=!1;return we(!0),je(null),e(`/api/admin/files?path=${encodeURIComponent(C===`.`?``:C)}`).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||(ye(e.entries),A(e.displayPath??[]))}).catch(e=>{t||(ye([]),A([]),je(e instanceof Error?e.message:String(e)))}).finally(()=>{t||we(!1)}),()=>{t=!0}},[e,C,Je,i]),(0,D.useEffect)(()=>{Pe(C)},[C]);let lt=(0,D.useCallback)(()=>{L(e=>e+1)},[]),G=(0,D.useCallback)(e=>{nt(!1),he(e)},[]),ut=(0,D.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}`),c(``),y(null),x(null),G(r)},[G]),dt=(0,D.useCallback)(()=>{if(C===`.`||C===``)return;let e=C.split(`/`).filter(Boolean);e.pop(),he(e.length===0?`.`:e.join(`/`))},[C]),ft=(0,D.useCallback)(e=>{ae(r,C===`.`?e.name:`${C}/${e.name}`)},[C,r]),[K,pt]=(0,D.useState)(!1),[q,mt]=(0,D.useState)(new Set),ht=(0,D.useRef)(null),J=(0,D.useRef)(!1),Y=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,gt=(0,D.useCallback)(e=>{pt(!0),mt(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),X=(0,D.useCallback)(e=>{pt(!1),mt(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Z=(0,D.useCallback)(e=>{mt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_t=(0,D.useCallback)(e=>{J.current=!1,ht.current=setTimeout(()=>{J.current=!0,gt(e)},500)},[gt]),Q=(0,D.useCallback)(()=>{ht.current&&=(clearTimeout(ht.current),null)},[]),vt=(0,D.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}ft(e)},[K,Z,ft]),yt=(0,D.useCallback)(e=>{xe(e),typeof window<`u`&&window.localStorage.setItem(De,e),console.info(`[data] op=view-mode mode=${e}`)},[]),bt=(0,D.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}Se({src:ce(r,C===`.`?e.name:`${C}/${e.name}`),alt:e.displayName??e.name})},[K,Z,C,r]),xt=(0,D.useCallback)(()=>(w??[]).filter(e=>e.kind===`file`&&q.has(e.name)),[w,q]),St=(0,D.useCallback)(()=>(w??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&q.has(e.name)),[w,q]),Ct=(0,D.useCallback)(()=>{let e=St(),t=e.some(e=>e.kind===`directory`);e.length===1&&!t?ft(e[0]):e.length>=1&&se(r,e.map(e=>C===`.`?e.name:`${C}/${e.name}`)),X(`action`)},[St,ft,C,r,X]),wt=(0,D.useCallback)(async()=>{let t=xt(),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=C===`.`?t.name:`${C}/${t.name}`;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))}}L(e=>e+1),X(`action`)},[xt,C,e,X]),Tt=(0,D.useCallback)(async()=>{let e=xt();if(console.info(`[data-ui] op=share supported=${Y} count=${e.length}`),Y)try{let t=await Promise.all(e.map(async e=>{let t=C===`.`?e.name:`${C}/${e.name}`,n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=await(await fetch(n)).blob();return new File([i],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)}`)}},[xt,Y,C,r]),Et=(0,D.useCallback)(()=>{I.current?.click()},[]),Dt=(0,D.useCallback)((e,t={})=>{let n=(n,i,a)=>{let o=new URLSearchParams({session_key:r,path:C===`.`?``:C,filename:e.name});t.relpath&&o.set(`relpath`,t.relpath),t.token&&o.set(`token`,t.token);for(let[e,t]of Object.entries(i))o.set(e,t);return new Promise(t=>{let r=new XMLHttpRequest;r.open(`POST`,`/api/admin/files/upload?${o.toString()}`),r.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(r.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),r.onload=()=>{let e={};try{e=JSON.parse(r.responseText)}catch{}t({status:r.status,data:e})},r.onerror=()=>t({status:0,data:{}}),r.onabort=()=>t({status:0,data:{error:`aborted`}}),r.send(n)})};if(e.size<=Oe)return n(e,{},n=>t.onProgress?.(n,e.size));let i=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/ke);return(async()=>{let r={status:0,data:{}};for(let o=0;o<a;o++){let s=o*ke;if(r=await n(e.slice(s,Math.min(s+ke,e.size)),{uploadId:i,seq:String(o),total:String(a)},n=>t.onProgress?.(s+n,e.size)),!(r.status>=200&&r.status<300))return r}return r})()},[r,C]),Ot=(0,D.useCallback)(async e=>{F(null),M(!0),P({loaded:0,total:e.size});try{let{status:t,data:n}=await Dt(e,{onProgress:(e,t)=>P({loaded:e,total:t})});t>=200&&t<300&&n.path?(he(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),L(e=>e+1)):F(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{M(!1),P(null),I.current&&(I.current.value=``)}},[Dt]),kt=(0,D.useCallback)(e=>{H&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Ge(!0))},[H]),At=(0,D.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Ge(!1)},[]),jt=(0,D.useCallback)(async e=>{e.preventDefault(),Ge(!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(!H){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),F(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);M(!0),F(null),Ve(null);let i=performance.now();try{let e=await Fe(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}`),P({loaded:0,total:r.size});let{status:a,data:c}=await Dt(r,{relpath:i,token:t,onProgress:(e,t)=>P({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`:Ie(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}`),Ve(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),L(e=>e+1)}catch(e){F(e instanceof Error?e.message:String(e))}finally{M(!1),P(null)}},[H,Dt]),Mt=(0,D.useCallback)(async()=>{let t=Xe.trim();if(t){V(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:C===`.`?``:C,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);R(!1),Ze(``),L(e=>e+1)}catch(e){V(e instanceof Error?e.message:String(e))}}},[e,Xe,C]),Nt=(0,D.useCallback)(async()=>{if(!z)return;let t=Qe.trim();if(!t)return;V(null);let n=C===`.`?z:`${C}/${z}`;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}`);B(null),$e(``),X(`action`),L(e=>e+1)}catch(e){V(e instanceof Error?e.message:String(e))}},[e,Qe,z,C,X]);(0,D.useEffect)(()=>{if(!tt)return;let e=e=>{rt.current&&!rt.current.contains(e.target)&&nt(!1)},t=e=>{e.key===`Escape`&&nt(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[tt]),(0,D.useEffect)(()=>{if(!it)return;let e=e=>{at.current&&!at.current.contains(e.target)&&U(!1)},t=e=>{e.key===`Escape`&&U(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[it]);let $=(0,D.useCallback)(e=>k.slice(0,e+1).map(e=>e.name).join(`/`),[k]),Pt=k.length>=2,Ft=Pt?[{name:`.`,label:`data`},...k.slice(0,k.length-2).map((e,t)=>({name:$(t),label:e.displayName??e.name}))]:[];return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`data-toolbar`,children:[K?(0,O.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>X(`cancel`),"aria-label":`Cancel selection`,children:[(0,O.jsx)(t,{size:14}),` Cancel`]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`data-search-input`,children:[o===``&&(0,O.jsx)(ue,{size:14}),(0,O.jsx)(`input`,{ref:l,type:`text`,value:o,onChange:e=>c(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),g&&(0,O.jsx)(n,{size:14,className:`spin`}),o!==``&&(0,O.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{c(``),l.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,O.jsx)(t,{size:14})})]}),(0,O.jsxs)(`div`,{className:`data-toolbar-actions`,ref:at,children:[(0,O.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>U(e=>!e),"aria-haspopup":`menu`,"aria-expanded":it,"aria-label":`File actions`,title:`File actions`,children:(0,O.jsx)(fe,{size:16})}),(0,O.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":it?`true`:void 0,children:[(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{lt(),U(!1)},disabled:j,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[j?(0,O.jsx)(n,{size:16,className:`spin`}):(0,O.jsx)(ee,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Et(),U(!1)},disabled:Me||!H,title:H?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Me?N&&N.total>0?(0,O.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(N.loaded/N.total*100),`%`]}):(0,O.jsx)(n,{size:16,className:`spin`}):(0,O.jsx)(be,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{R(e=>!e),Ze(``),V(null),U(!1)},disabled:Me||!H,title:H?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,O.jsx)(pe,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{yt(T===`grid`?`list`:`grid`),U(!1)},title:T===`grid`?`List view`:`Grid view`,"aria-label":T===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":T===`grid`,children:[T===`grid`?(0,O.jsx)(_e,{size:16}):(0,O.jsx)(ge,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:T===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,O.jsxs)(`div`,{className:`data-breadcrumbs`,children:[C!==`.`&&(0,O.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:dt,title:`Up one level`,"aria-label":`Up one level`,children:(0,O.jsx)(de,{size:14})}),Pt?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`span`,{className:`data-crumb-wrap`,ref:rt,children:[(0,O.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>nt(e=>!e),"aria-haspopup":`menu`,"aria-expanded":tt,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),tt&&(0,O.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Ft.map(e=>(0,O.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>G(e.name),title:e.label,children:e.label},e.name))})]}),[k.length-2,k.length-1].map(e=>{let t=k[e];return(0,O.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,O.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G($(e)),title:t.name,children:t.displayName??t.name})]},$(e))})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G(`.`),children:`data`}),k.map((e,t)=>(0,O.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,O.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G($(t)),title:e.name,children:e.displayName??e.name})]},$(t)))]})]}),Ye&&(0,O.jsxs)(`div`,{className:`data-inline-form`,children:[(0,O.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:Xe,autoFocus:!0,onChange:e=>Ze(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Mt(),e.key===`Escape`&&R(!1)}}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Mt,children:`Create`}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>R(!1),children:`Cancel`})]}),z&&(0,O.jsxs)(`div`,{className:`data-inline-form`,children:[(0,O.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:Qe,autoFocus:!0,onChange:e=>$e(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Nt(),e.key===`Escape`&&B(null)}}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Nt,children:`Rename`}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>B(null),children:`Cancel`})]}),et&&(0,O.jsx)(`div`,{className:`data-error`,children:et}),(0,O.jsx)(`input`,{type:`file`,ref:I,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Ot(t)}})]}),(0,O.jsxs)(`div`,{className:`data-body`,"data-drag-active":He?`true`:void 0,onDragEnter:kt,onDragOver:kt,onDragLeave:At,onDrop:jt,children:[(v!==null||f!==null)&&(0,O.jsxs)(`section`,{className:`data-panel`,children:[v&&(0,O.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,v]}),ot.length>0&&(0,O.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:ot.map(e=>{let t=e===W;return(0,O.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>x(t?null:e),children:ze([e])??e},e)})}),f&&!g&&(0,O.jsxs)(`div`,{className:`data-results-meta`,children:[st.length,` of `,f.length,` result`,f.length===1?``:`s`]}),f&&!g&&!W&&te>0&&!S&&(0,O.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>le(!0),children:[te,` low-confidence result`,te===1?``:`s`,` hidden — show all`]}),f&&!g&&!W&&S&&(0,O.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>le(!1),children:`Showing all results — hide low-confidence`}),f&&f.length===0&&!g&&(0,O.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),st&&st.length>0&&(0,O.jsx)(`ul`,{className:`data-results`,children:st.map(e=>(0,O.jsx)(Re,{hit:e,mode:m,onDownload:ct,onLocate:ut},e.nodeId))})]}),(0,O.jsxs)(`section`,{className:`data-panel`,children:[N&&(0,O.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":N.total>0?Math.round(N.loaded/N.total*100):void 0,children:[(0,O.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,O.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${N.total>0?Math.round(N.loaded/N.total*100):0}%`}})}),(0,O.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,N.total>0?`${Math.round(N.loaded/N.total*100)}%`:``]})]}),Le&&(0,O.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,Le]}),Be&&(0,O.jsx)(`div`,{className:`data-status`,children:Be}),Ke&&(0,O.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Ke]}),Te&&(0,O.jsx)(`div`,{className:`data-error`,children:Te}),j&&(0,O.jsxs)(`div`,{className:`data-loading`,children:[(0,O.jsx)(n,{size:14,className:`spin`}),` Loading…`]}),!K&&!j&&w&&w.length>0&&(0,O.jsxs)(`div`,{className:`data-select-hint`,children:[(0,O.jsx)(ve,{size:13}),(0,O.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!j&&w&&w.length===0&&!Te&&(0,O.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!j&&w&&w.length>0&&T===`grid`&&(0,O.jsx)(`ul`,{className:`data-grid`,children:w.map(e=>{let t=e.displayName??e.name,n=K&&q.has(e.name);if(e.kind===`directory`)return(0,O.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(C===`.`?e.name:`${C}/${e.name}`)},children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,O.jsx)(me,{size:28,className:`data-grid-glyph`}),(0,O.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t})]})},e.name);if(e.kind===`file`){let i=Ee(e.name),a=C===`.`?e.name:`${C}/${e.name}`;return(0,O.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>i?bt(e):vt(e),title:K?void 0:i?`Preview ${t}`:`Download ${t}`,children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,O.jsx)(`img`,{className:`data-grid-thumb`,src:ce(r,a),alt:t,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,O.jsx)(ie,{size:28,className:`data-grid-glyph`}),(0,O.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t}),!i&&(0,O.jsx)(`span`,{className:`data-grid-sub`,children:Ue(e.sizeBytes)})]})},e.name)}return(0,O.jsx)(`li`,{className:`data-grid-cell`,children:(0,O.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,O.jsx)(ie,{size:28,className:`data-grid-glyph`}),(0,O.jsx)(`span`,{className:`data-grid-label`,children:t}),(0,O.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!j&&w&&w.length>0&&T===`list`&&(0,O.jsx)(`ul`,{className:`data-entries`,children:w.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=K&&q.has(e.name);return(0,O.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(C===`.`?e.name:`${C}/${e.name}`)},children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,O.jsx)(me,{size:14}),(0,O.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=K&&q.has(e.name);return(0,O.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>vt(e),title:K?void 0:`Download ${t}`,children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,O.jsxs)(`span`,{className:`data-entry-text`,children:[(0,O.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,O.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${We(e.modifiedAt)}`,children:[Ue(e.sizeBytes),` · `,We(e.modifiedAt)]})]})]})},e.name)}return(0,O.jsx)(`li`,{className:`data-entry`,children:(0,O.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,O.jsxs)(`span`,{className:`data-entry-text`,children:[(0,O.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,O.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),K&&(0,O.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,O.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Tt,disabled:!Y||q.size===0,title:Y?`Share selected files`:`Sharing is not supported on this device`,children:[(0,O.jsx)(s,{size:16}),` Share`]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Ct,disabled:q.size===0,children:[(0,O.jsx)(ne,{size:16}),` Download`]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=[...q][0];e&&(B(e),$e(e))},disabled:q.size!==1,children:[(0,O.jsx)(oe,{size:16}),` Rename`]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:wt,disabled:q.size===0,children:[(0,O.jsx)(a,{size:16}),` Delete`]})]})}),E&&(0,O.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":E.alt,onClick:()=>Se(null),children:(0,O.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:E.src,alt:E.alt})})]})}function Le({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){(0,D.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let r=(0,D.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),a=(0,D.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[o,s]=(0,D.useState)([]),[l,u]=(0,D.useState)(`files`),{subAccounts:d,activeAccountId:f,switching:p,switchAccount:m}=c(t);return(0,D.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(t)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||s(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]),(0,O.jsxs)(`main`,{className:`data-main`,children:[(0,O.jsx)(i,{variant:`operator`,onNavigate:a,onOpenConversations:o.length>0?()=>u(`conversations`):void 0,onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:d,activeAccountId:f,switchingAccount:p,onSwitchAccount:m}),l===`conversations`?(0,O.jsx)(we,{conversations:o,sessionKey:t,onBack:()=>u(`files`)}):(0,O.jsx)(P,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function F({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=u({initialCacheKey:e,surface:`data`});return(0,O.jsx)(`div`,{className:`data-page`,children:(0,O.jsx)(`main`,{className:`data-main`,children:(0,O.jsx)(P,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})})})}function Re({hit:e,mode:t,onDownload:n,onLocate:r}){let i=Be(e.properties),a=Ve(e.properties),o=ze(e.labels),s=He(e.properties),[c,l]=(0,D.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,O.jsxs)(`li`,{className:`data-result`,children:[(0,O.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,O.jsx)(`div`,{className:`data-result-header`,children:(0,O.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,O.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,O.jsx)(`pre`,{className:`data-result-body`,children:d}),(0,O.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,O.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,We(s),` · `]}),f]})]}),m&&(0,O.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${g}`,"aria-label":`Locate in ${g}`,children:[(0,O.jsx)(me,{size:12}),g]}),u&&(0,O.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>l(e=>!e),children:c?`Show less`:`Show more`})]})}function ze(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 Be(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 Ve(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 He(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 Ue(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 We(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{F as n,A as r,je as t};