limixbot 0.2.7 → 0.2.9

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 (190) hide show
  1. package/dist/assets/{ActivityPanel-CmDCy7eZ.js → ActivityPanel-DNJrm-It.js} +1 -1
  2. package/dist/assets/{App-Dbsatjme.js → App-0-mtr0MN.js} +9 -9
  3. package/dist/assets/{AppEventEditor-B4RQnsS3.js → AppEventEditor-cxtdNROG.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-DyScwvnb.js → BotSettingsDialog-Bke-uC9C.js} +1 -1
  5. package/dist/assets/{BrowserPanel-CFFNXZUh.js → BrowserPanel-DIWnLFx0.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-H57RKPMu.js → BrowserProfilesManager-Byg78_T6.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-Bj6_HHBS.js → CloudAddDialog-DbnC3LUp.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-CZ3bEdi-.js → ComputerFilesPane-D8NwEQh2.js} +1 -1
  9. package/dist/assets/{ComputerPanel-BQUsGs4_.js → ComputerPanel-BVjkZ-QX.js} +2 -2
  10. package/dist/assets/{DataPanel-BFafyj9T.js → DataPanel-jd0L0Ng-.js} +1 -1
  11. package/dist/assets/{DesktopViewer-DuoSRrPG.js → DesktopViewer-Bj7DyfxJ.js} +1 -1
  12. package/dist/assets/{FilesView-D2WrDHpg.js → FilesView-D2dpovi2.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-Ciq95MT4.js → GrokMoveDialog-Cu9vgUWd.js} +1 -1
  14. package/dist/assets/{InspectorPanel-DP9ekeeT.js → InspectorPanel-B6Ix1Q90.js} +1 -1
  15. package/dist/assets/{KeyboardShortcutsModal-BMt7r3Va.js → KeyboardShortcutsModal-BxLj1UAT.js} +1 -1
  16. package/dist/assets/{LiveDesktop-JYitfkP5.js → LiveDesktop-IhmS_70N.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-ZIznHPod.js → LocalVmWorkspace-Cz_8PBvO.js} +1 -1
  18. package/dist/assets/{MacLocalControl-B2mYWfM_.js → MacLocalControl-BQx0dmBY.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-C9o8GlmR.js → MarkdownFilePreview-BvcKRvLj.js} +1 -1
  20. package/dist/assets/{MenuMotion-BVlWdNZd.js → MenuMotion-Dg_hALEl.js} +1 -1
  21. package/dist/assets/{NewBotDialog-42cdLuX9.js → NewBotDialog-AG4lwjLs.js} +1 -1
  22. package/dist/assets/{PhoneAppDialog-2HsbrbDR.js → PhoneAppDialog-DnxYDUcZ.js} +1 -1
  23. package/dist/assets/PlacesRail-C-RypDbo.js +57 -0
  24. package/dist/assets/{PluginsPanel-gMX9siqC.js → PluginsPanel-DUMsui1-.js} +1 -1
  25. package/dist/assets/{ProIntroduction-DLeyaIp4.js → ProIntroduction-DrVULNMR.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-CI4mV7e4.js → RemoteAgentSettingsPanel-C9bAP3v4.js} +1 -1
  27. package/dist/assets/{RoomPanel-QM7b4JcY.js → RoomPanel-DjGGiSTe.js} +1 -1
  28. package/dist/assets/{RoutinesPage-9oF95jVB.js → RoutinesPage-DI6CbJ-R.js} +1 -1
  29. package/dist/assets/{SettingsModal-D-qQozfZ.js → SettingsModal-2iNaR6ei.js} +1 -1
  30. package/dist/assets/{ShareTeamDialog-BSCDpGsw.js → ShareTeamDialog-D7jlR9HK.js} +1 -1
  31. package/dist/assets/{SignedInSites-CCJy494V.js → SignedInSites-zRGAI6no.js} +1 -1
  32. package/dist/assets/{TeamLibraryPanel-VGQUqTlV.js → TeamLibraryPanel-ssb1UDr5.js} +1 -1
  33. package/dist/assets/{TeamMapPage-rjPtLGmj.js → TeamMapPage-BS05D1gH.js} +1 -1
  34. package/dist/assets/{TriggersPage-0G0do_3b.js → TriggersPage-Bnny-m5i.js} +1 -1
  35. package/dist/assets/{VisibilitySection-Gh6OTOCE.js → VisibilitySection-DYoJ1GdM.js} +1 -1
  36. package/dist/assets/{WebhookTrigger-DpcmCVTL.js → WebhookTrigger-TRl3ZXbh.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-L6LFTE2_.js → WorksOnGrid-KH_NgeB8.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-CUWh2GsH.js → abnfDiagram-YUKMZFIV-BJa3HT_w.js} +1 -1
  39. package/dist/assets/{activity-LHXr5xxZ.js → activity-DpguW9va.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-DVX8QyiO.js → architectureDiagram-47P4ROYG-C5gEKdsw.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-CEURT8Q8.js → blockDiagram-E7TT5TSB-CT7xbCQZ.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-Dxo3va1-.js → c4Diagram-CRA5TL53-DSFZqTvf.js} +1 -1
  43. package/dist/assets/{calendar-days-dgtKqWUC.js → calendar-days-ASlaivsQ.js} +1 -1
  44. package/dist/assets/channel-BqGEhKY0.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-Cwoh8ivv.js → chunk-2Q5K7J3B-OtLqmkVp.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-D3VEPh-j.js → chunk-5VM5RSS4-Rq3LG0x-.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-DkXnciwj.js → chunk-7TKQ45FW-BvOFm5yO.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-CNUnktBg.js → chunk-AW2ZBBNX-Bp8ouRZs.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-DDh_Qx3V.js → chunk-FVRAUYC3-htnnltbK.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-Cl-K7zHu.js → chunk-HTAEGDNF-dT7z7xQV.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-BZMB3nUT.js → chunk-JWPE2WC7-BKhNCYBO.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-CK00Y5Mf.js → chunk-KQW6MTUR-DeA1KhMw.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-D9bXnXn1.js → chunk-XXDRQBXY-DJCz3KwB.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-vMIXHAit.js → classDiagram-v2-K4WV4PDN-BxZQcXjn.js} +1 -1
  55. package/dist/assets/{coins-C6ydDjtx.js → coins-Kra8C23v.js} +1 -1
  56. package/dist/assets/{core-PBrJFfNa.js → core-D_ShnPPB.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-CKEtjhno.js → cose-bilkent-JH36ORCC-DPvzbWJ-.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-X7332_6L.js → cynefin-EF2NZ3EQ-BU7oS4Kz.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-C3ehmT22.js → cynefinDiagram-3GCD6N5R-BGBWfDSm.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-8j_7yTJf.js → dagre-W4DXFKR2-IWCaUQIb.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-Dpan5gHO.js → diagram-2UJZ2QOL-Bhk3LC2M.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-84oGxj_T.js → diagram-OVF4WLC6-CuabegT5.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-CtkBChQX.js → diagram-PFPMY2P6-CoS7hKtb.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-BtLD2TMp.js → diagram-UMYRVEAY-BQmo6hIx.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-BSsG3sMr.js → diagram-YEKJPTXX-Dn-KHH-s.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-DzGdrnet.js → diagram-ZIFT7M5P-BCWmVp3z.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-BCgvwxBO.js → ebnfDiagram-VR2GEFS7-Bb086aqc.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-MrcuY098.js → elk-IJKZMXRS-C0AdhTr_.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-CkiPC10P.js → erDiagram-O2IAPWRE-CGa-MwBB.js} +1 -1
  70. package/dist/assets/{file-up-YAGDCUmC.js → file-up-XN39lGyR.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-Dy30n92Z.js → flowDiagram-OXPTDLAJ-BdLF4FEb.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI-7aj2jc8X.js → ganttDiagram-R7TSEDQI-iXPVrTqJ.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-C90-6xd7.js → gitGraphDiagram-XJZIOB7I-DA55YE0F.js} +1 -1
  74. package/dist/assets/{import-name-DwHxnzLo.js → import-name-CNEv8Wx8.js} +1 -1
  75. package/dist/assets/{index-Dh9vBoyU.js → index-BDVsw1Qr.js} +1 -1
  76. package/dist/assets/{index-CEBe4ppp.js → index-CnQ2pCf7.js} +2 -2
  77. package/dist/assets/{index-J6AJ8PJY.js → index-CtBcDSNT.js} +1 -1
  78. package/dist/assets/{infoDiagram-5W2HQ5XZ-JsL4Ulqu.js → infoDiagram-5W2HQ5XZ-DwwOOuPK.js} +1 -1
  79. package/dist/assets/{ishikawaDiagram-K3B6WC7H-DGvScV7R.js → ishikawaDiagram-K3B6WC7H-uOns6fyB.js} +1 -1
  80. package/dist/assets/{journeyDiagram-COXZFDF6-DLSEKXoP.js → journeyDiagram-COXZFDF6-BNlo402b.js} +1 -1
  81. package/dist/assets/{kanban-definition-P3RFRI5V-CoxK_0bl.js → kanban-definition-P3RFRI5V-rApNRuxE.js} +1 -1
  82. package/dist/assets/{mcp-servers-Dy6saID9.js → mcp-servers-DiCs_cE-.js} +1 -1
  83. package/dist/assets/{mermaid.core-73koJZWB.js → mermaid.core-UoMXw4Pf.js} +4 -4
  84. package/dist/assets/{mindmap-definition-LZFPQGKD-CbTxcgIF.js → mindmap-definition-LZFPQGKD-DMx0e0Ua.js} +1 -1
  85. package/dist/assets/{minimize-DNbi21po.js → minimize-C6tWjaQW.js} +1 -1
  86. package/dist/assets/{monitor-EYAEQme8.js → monitor-CqHNmvSo.js} +1 -1
  87. package/dist/assets/{new-bot-C2jdhFdl.js → new-bot-CpjPfYn1.js} +1 -1
  88. package/dist/assets/{org-library-BayvlLSA.js → org-library-DkWIJaGU.js} +1 -1
  89. package/dist/assets/{package-format-BvNOAJ-8.js → package-format-DQ8Q_tWB.js} +1 -1
  90. package/dist/assets/{pegDiagram-BGZESJAR-vPF7wjW0.js → pegDiagram-BGZESJAR-BGjO4xhf.js} +1 -1
  91. package/dist/assets/{pieDiagram-CAPJLFHJ-CcXS-bXc.js → pieDiagram-CAPJLFHJ-CKDnQaP9.js} +1 -1
  92. package/dist/assets/{quadrantDiagram-GDMTTRAM-ue9nAF1U.js → quadrantDiagram-GDMTTRAM-2Yd2aagw.js} +1 -1
  93. package/dist/assets/{rail-BVFx-Ggi.js → rail-DzTUJt9y.js} +1 -1
  94. package/dist/assets/{railroadDiagram-SM67HX2B-BeQYm6nT.js → railroadDiagram-SM67HX2B-2p7uXTy-.js} +1 -1
  95. package/dist/assets/{remote-desktop-panel-Bgx8ebdG.js → remote-desktop-panel-CWP7wnfp.js} +1 -1
  96. package/dist/assets/{requirementDiagram-X7JNWC4A-DZouafhW.js → requirementDiagram-X7JNWC4A-B8Tb583R.js} +1 -1
  97. package/dist/assets/{sankeyDiagram-UM26HJRW-DHon18zu.js → sankeyDiagram-UM26HJRW-uH_0e9a7.js} +1 -1
  98. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-atekCKa7.js → sequenceDiagram-ZO4K6R2Y-BL2NmEjq.js} +1 -1
  99. package/dist/assets/{sizeCapture-INFHLROL-Dt3J5cN4.js → sizeCapture-INFHLROL-CF5rj-Tn.js} +1 -1
  100. package/dist/assets/{stateDiagram-v2-TBUQTH76-Y6UtBULW.js → stateDiagram-v2-TBUQTH76-Bi8FVJmD.js} +1 -1
  101. package/dist/assets/{styles-CnQhCz_w.js → styles-3gApXdcp.js} +2 -2
  102. package/dist/assets/styles-D-yh7Z23.css +1 -0
  103. package/dist/assets/{swimlanes-N4OXWK64-BpUnlH-3.js → swimlanes-N4OXWK64-cI7SKAY4.js} +1 -1
  104. package/dist/assets/swimlanesDiagram-K3J5GTZL-D8raS3ll.js +8 -0
  105. package/dist/assets/{team-share-DkzY22CD.js → team-share-Dy8-U6dh.js} +1 -1
  106. package/dist/assets/{timeline-definition-YOQAKGHF-DhG3OlON.js → timeline-definition-YOQAKGHF-DgYVfZT2.js} +1 -1
  107. package/dist/assets/{usecaseDiagram-VIAY4XPW-DFUcbznD.js → usecaseDiagram-VIAY4XPW-DA-ohLD0.js} +1 -1
  108. package/dist/assets/{vennDiagram-BLWOH2XV-D49fiyRh.js → vennDiagram-BLWOH2XV-DvsWwQlH.js} +1 -1
  109. package/dist/assets/vi-KgT8L8Qj.js +15 -0
  110. package/dist/assets/{wardleyDiagram-YMQ3BMBF-DFVNNZPs.js → wardleyDiagram-YMQ3BMBF--20oJB2z.js} +1 -1
  111. package/dist/assets/{xychartDiagram-TAQBALBS-DiHMuK-U.js → xychartDiagram-TAQBALBS-C8j4OKSW.js} +1 -1
  112. package/dist/index.html +3 -3
  113. package/dist/rail.html +5 -5
  114. package/dist-server/index.js +87 -54
  115. package/dist-server/openmausbot.js +87 -54
  116. package/dist-server/package.json +1 -1
  117. package/dist-server/shared/mascot-bodies.js +23 -23
  118. package/package.json +1 -1
  119. package/skills/agent-reach/LICENSE +21 -0
  120. package/skills/agent-reach/SKILL.md +117 -0
  121. package/skills/agent-reach/manifest.json +41 -0
  122. package/skills/agent-reach/references/capabilities.md +31 -0
  123. package/skills/agent-reach/references/maintenance.md +13 -0
  124. package/skills/agent-reach/references/sessions.md +41 -0
  125. package/skills/rea-video/LICENSE +202 -0
  126. package/skills/rea-video/NOTICE +4 -0
  127. package/skills/rea-video/SKILL.md +124 -0
  128. package/skills/rea-video/manifest.json +32 -0
  129. package/skills/rea-video/references/audio.md +97 -0
  130. package/skills/rea-video/references/materials.md +34 -0
  131. package/skills/rea-video/references/memory.md +7 -0
  132. package/skills/rea-video/references/output-template.md +46 -0
  133. package/skills/rea-video/references/remake.md +41 -0
  134. package/skills/rea-video/references/review.md +42 -0
  135. package/skills/rea-video/references/setup.md +51 -0
  136. package/skills/rea-video/references/taxonomy.md +139 -0
  137. package/skills/ui-ux-pro-max/LICENSE +21 -0
  138. package/skills/ui-ux-pro-max/SKILL.md +221 -0
  139. package/skills/ui-ux-pro-max/data/app-interface.csv +33 -0
  140. package/skills/ui-ux-pro-max/data/catalog-summary.json +78 -0
  141. package/skills/ui-ux-pro-max/data/charts.csv +26 -0
  142. package/skills/ui-ux-pro-max/data/colors.csv +193 -0
  143. package/skills/ui-ux-pro-max/data/data-provenance.json +1396 -0
  144. package/skills/ui-ux-pro-max/data/google-font-licenses.json +20185 -0
  145. package/skills/ui-ux-pro-max/data/google-fonts.csv +1935 -0
  146. package/skills/ui-ux-pro-max/data/icons.csv +106 -0
  147. package/skills/ui-ux-pro-max/data/landing.csv +35 -0
  148. package/skills/ui-ux-pro-max/data/motion.csv +18 -0
  149. package/skills/ui-ux-pro-max/data/phosphor-icons-upstream.json +32582 -0
  150. package/skills/ui-ux-pro-max/data/products.csv +193 -0
  151. package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  152. package/skills/ui-ux-pro-max/data/stacks/angular.csv +51 -0
  153. package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  154. package/skills/ui-ux-pro-max/data/stacks/avalonia.csv +57 -0
  155. package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  156. package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +60 -0
  157. package/skills/ui-ux-pro-max/data/stacks/javafx.csv +76 -0
  158. package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  159. package/skills/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
  160. package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +62 -0
  161. package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +84 -0
  162. package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +68 -0
  163. package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  164. package/skills/ui-ux-pro-max/data/stacks/react.csv +67 -0
  165. package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +69 -0
  166. package/skills/ui-ux-pro-max/data/stacks/svelte.csv +56 -0
  167. package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  168. package/skills/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
  169. package/skills/ui-ux-pro-max/data/stacks/uno.csv +60 -0
  170. package/skills/ui-ux-pro-max/data/stacks/uwp.csv +56 -0
  171. package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  172. package/skills/ui-ux-pro-max/data/stacks/winui.csv +60 -0
  173. package/skills/ui-ux-pro-max/data/stacks/wpf.csv +57 -0
  174. package/skills/ui-ux-pro-max/data/styles.csv +90 -0
  175. package/skills/ui-ux-pro-max/data/typography.csv +75 -0
  176. package/skills/ui-ux-pro-max/data/ui-reasoning.csv +193 -0
  177. package/skills/ui-ux-pro-max/data/ux-guidelines.csv +121 -0
  178. package/skills/ui-ux-pro-max/manifest.json +34 -0
  179. package/skills/ui-ux-pro-max/references/pro-rules.md +117 -0
  180. package/skills/ui-ux-pro-max/references/quick-reference.md +257 -0
  181. package/skills/ui-ux-pro-max/scripts/core.py +1053 -0
  182. package/skills/ui-ux-pro-max/scripts/design_system.py +1668 -0
  183. package/skills/ui-ux-pro-max/scripts/reasoning_contract.py +123 -0
  184. package/skills/ui-ux-pro-max/scripts/search.py +201 -0
  185. package/skills/ui-ux-pro-max/scripts/validate_data.py +1095 -0
  186. package/dist/assets/PlacesRail-XEjyWavr.js +0 -57
  187. package/dist/assets/channel-B_-MyCfi.js +0 -1
  188. package/dist/assets/styles-D8FmJr6X.css +0 -1
  189. package/dist/assets/swimlanesDiagram-K3J5GTZL-CNvy2omc.js +0 -8
  190. package/dist/assets/vi-VlbIiohE.js +0 -6
@@ -1 +1 @@
1
- import{j as e,t,a as S,i as ie,f as he,r as m,X as be,C as fe,n as Ae,S as Re}from"./styles-CnQhCz_w.js";import{C as Ee,J as ze,B as Te,c as Me,d as Le,P as ce,V as Oe}from"./PlacesRail-XEjyWavr.js";import{co as ge,cp as Pe,cq as Fe,cr as oe,Y as $e,u as H,cs as We,ct as Ye,cu as ee,cv as ye,cw as de,cx as _e,cy as ke,cz as He,cA as Ue,cB as Ge,cC as Je,br as qe,cD as Qe,cE as je,cF as ue,cG as Ke,cH as Ve,T as Xe,cI as Ze,cJ as et,cK as Z,cL as ve,cf as we,cM as tt,cN as ne,cO as st,cP as nt,cQ as Ne,n as W,cR as Ce,cS as at,cT as it,cU as ot,cV as xe,cW as rt,cX as lt,cY as dt,cZ as ct,D as re,w as ut,c_ as xt,bF as pt,c$ as mt,bD as ht,d0 as bt,d1 as ft,S as Se,d2 as gt,d3 as yt}from"./App-Dbsatjme.js";import{AppEventEditor as kt}from"./AppEventEditor-B4RQnsS3.js";import{C as Ie,S as jt}from"./MenuMotion-BVlWdNZd.js";import{C as vt,E as wt,Q as Nt,b as Ct,H as St,R as It}from"./RoutinesPage-9oF95jVB.js";import{WebhookEditor as Bt}from"./WebhookTrigger-DpcmCVTL.js";import"./monitor-EYAEQme8.js";import"./index-CEBe4ppp.js";import"./remote-desktop-DDRRx8uY.js";import"./ProIntroduction-DLeyaIp4.js";const le="\0general";function Dt(n,r){const l=n.filter(h=>!h.hidden),g=new Set(l.map(h=>h.section).filter(h=>!!h));return{names:r.filter(h=>g.has(h)),hasGeneral:l.some(h=>!h.section)}}function te(n,r){return r==="all"?!0:n?r===le?!n.section:n.section===r:!1}function At({trigger:n}){const{attempts:r,service:l}=ge(),g=r.filter(o=>o.triggerId===n.id).slice(-6).reverse(),h=Pe(n);return e.jsxs("section",{"data-app-events":n.id,children:[e.jsx("h3",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t("automations.panel.events")}),h&&e.jsx("p",{className:"mb-2 rounded-lg bg-warning/10 px-2.5 py-1.5 text-[12px] text-warning",children:h}),g.length===0?e.jsx("p",{className:"text-[13px] text-ink-secondary",children:t("automations.panel.noEvents")}):e.jsx("ul",{className:"space-y-1",children:g.map(o=>{const b=Fe(o),p=oe(o.at);return e.jsxs("li",{className:"flex items-baseline gap-2 px-2 py-1 text-[13px]",children:[e.jsx("span",{className:"shrink-0 text-ink-secondary",children:p.charAt(0).toLocaleUpperCase()+p.slice(1)}),e.jsx("span",{className:S("shrink-0 font-semibold",b.mark==="✓"?"text-success":b.mark==="✗"?"text-danger":"text-ink-tertiary"),children:b.mark}),e.jsx("span",{className:"min-w-0 truncate text-ink",title:b.text,children:b.text})]},o.id)})}),l?.eventsPerDay&&e.jsx("p",{className:"mt-2 text-[11px] text-ink-tertiary",children:t("automations.app.limit",{count:l.eventsPerDay.toLocaleString(ie()),place:t(l.plan==="cloud"?"automations.app.placeCloud":"automations.app.placeDesktop")})})]})}function Be({status:n,className:r}){return n.state==="needs-you"?e.jsx($e,{size:15,"aria-hidden":"true",className:S("shrink-0 text-warning",r)}):n.state==="done"?e.jsx(he,{size:14,"aria-hidden":"true",className:S("shrink-0 text-ink-tertiary",r)}):e.jsx("span",{"aria-hidden":"true",className:S("size-2.5 shrink-0 rounded-full",n.state==="working"?"bg-success":"bg-ink-tertiary/60",r)})}function De({automation:n,status:r,actions:l,onEdit:g,className:h}){const{dispatch:o}=H();if(r.state!=="needs-you"||!r.fix)return null;const b=r.fix,p=b==="answer"?We(n.runs):void 0,i=()=>{b==="answer"?l.openRun(n,p):b==="sign-in"?l.openRun(n,n.runs.find(x=>x.status!=="queued")):b==="usage"?o({type:"toggleAppSettings",open:!0,section:"usage"}):b==="edit"?g():b==="reconnect"?o({type:"togglePlugins",open:!0,surface:"apps"}):l.runNow(n)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:i,disabled:!!l.busy,className:S("shrink-0 rounded-lg bg-warning/15 px-2.5 py-1 text-[12px] font-medium text-warning hover:bg-warning/25 disabled:opacity-50",h),children:t(Ye[b])}),p&&e.jsx("button",{type:"button","data-automation-cancel-run":!0,onClick:()=>{l.cancelRun(n,p)},disabled:!!l.busy,className:S("shrink-0 rounded-lg px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50",h),children:t("routines.drawer.cancelRun")})]})}const Rt=5,K="flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-[13px] font-medium disabled:opacity-50";function Et({automation:n,sentence:r,onClose:l,onEdit:g,onDeleted:h}){const{state:o,dispatch:b}=H(),[p]=m.useState(()=>new Set(n.runs.filter(u=>ee(u)&&!u.seenAt).map(u=>u.id))),i=n.runs.filter((u,C)=>C<Rt||p.has(u.id)||ee(u)&&!u.seenAt);m.useEffect(()=>{for(const u of n.runs)ee(u)&&!u.seenAt&&b({type:"markRoutineRunSeen",runId:u.id})},[n.runs,b]);const x=ye(),j=de(n),f=n.kind==="webhook"?o.webhooks.find(u=>u.id===n.id):void 0,v=f?_e(ke())[f.id]:void 0,y=o.webhookIngress?.available!==!1,N=t(He[j.state]),w=n.name.trim(),R=o.bots.find(u=>u.id===n.botId)?.name??t("routines.unavailableBot"),B=n.instructions.trim(),c=j.state==="done"?t("automations.reason.done"):j.reason,I=f?Ue(f.id,o.webhookAttempts):[],T=f?Ge(f,o.webhookAttempts):null,[A,Y]=m.useState(null),[M,D]=m.useState(!1),[E,_]=m.useState(!1),z=async u=>{if(await ze(u)!=="copied"){x.setError(t("automations.address.copyFailed"));return}_(!0),setTimeout(()=>_(!1),1800)};return e.jsxs("aside",{"aria-label":t("automations.panel.label"),className:"flex h-full w-[min(380px,100vw)] shrink-0 flex-col border-l border-hairline/40 bg-panel",children:[e.jsxs("div",{className:"flex items-start gap-3 border-b border-hairline/40 px-5 py-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-[16px] font-semibold leading-snug text-ink",children:w||r}),w&&e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:Je(n,R)})]}),e.jsx("button",{type:"button",onClick:l,className:"rounded-full p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("automations.panel.close"),children:e.jsx(be,{size:16})})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[13px]","data-automation-status":j.state,children:[e.jsx(Be,{status:j}),e.jsx("span",{className:S("font-medium",j.state==="needs-you"?"text-warning":"text-ink"),children:N}),c&&e.jsx("span",{className:"min-w-0 text-ink-secondary",children:c}),e.jsx(De,{automation:n,status:j,actions:x,onEdit:g})]}),f&&e.jsxs("section",{className:"rounded-xl border border-hairline/45 bg-inset/50 p-3.5",children:[e.jsx("h3",{className:"text-[13px] font-medium text-ink",children:t("automations.address.title")}),e.jsxs("button",{type:"button",disabled:!!x.busy||!y,onClick:()=>{x.copyAddress(f.id)},className:S(K,"mt-2.5 bg-accent text-accent-ink hover:brightness-110"),children:[x.copied===f.id?e.jsx(he,{size:14}):e.jsx(Ee,{size:14}),x.copied===f.id?t("automations.address.copied"):t("automations.address.copy")]}),(!y||!o.config?.cloudHome)&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:y?t("automations.address.keepOpen"):t("automations.address.unavailable")}),e.jsxs("details",{className:"mt-2.5 text-[12px] text-ink-secondary",children:[e.jsx("summary",{className:"cursor-pointer select-none font-medium text-ink-secondary hover:text-ink",children:t("automations.more")}),e.jsxs("div",{className:"mt-2 space-y-2 leading-relaxed",children:[T&&e.jsxs("section",{"aria-label":t("automations.received.title"),children:[e.jsxs("p",{className:"font-medium text-ink",children:[t("automations.received.title")," · ",oe(T.at)]}),e.jsx("p",{className:"mt-0.5",children:t("automations.received.help")}),e.jsx("pre",{className:"mt-1.5 max-h-40 overflow-auto whitespace-pre-wrap break-all rounded-lg bg-inset px-2.5 py-2 font-mono text-[11px] text-ink",children:T.preview.slice(0,1e3)})]}),e.jsxs("section",{"aria-label":t("automations.calls.title"),children:[e.jsx("p",{className:"font-medium text-ink",children:t("automations.calls.title")}),I.length===0?e.jsx("p",{className:"mt-0.5",children:t("automations.calls.none")}):e.jsx("ul",{className:"mt-1 space-y-0.5",children:I.map(u=>e.jsxs("li",{"data-call":u.ok?"ok":"refused",children:[e.jsxs("button",{type:"button","aria-expanded":A===u.id,onClick:()=>Y(C=>C===u.id?null:u.id),className:"flex w-full items-baseline gap-2 rounded-md px-1.5 py-1 text-left hover:bg-raised",children:[e.jsx("span",{className:"shrink-0",children:qe(oe(u.at))}),e.jsx("span",{className:S("shrink-0 font-semibold",u.ok?"text-success":"text-danger"),children:u.ok?"✓":"✗"}),e.jsx("span",{className:"min-w-0 truncate text-ink",children:u.reason})]}),A===u.id&&e.jsx("pre",{className:"mx-1.5 mb-1 whitespace-pre-wrap break-all rounded-md bg-inset px-2 py-1.5 font-mono text-[11px] text-ink",children:u.preview||t("automations.calls.empty")})]},u.id))})]}),e.jsx("p",{className:"font-medium text-ink",children:t("automations.address.showSecret")}),v?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1","data-secret":M?"shown":"masked",children:[e.jsx("span",{className:"min-w-0 break-all font-mono text-[11px]",children:t("automations.address.secret",{secret:M?v.secret:"••••••••"})}),e.jsx("button",{type:"button","aria-label":t(M?"automations.address.hideSecretLabel":"automations.address.showSecretLabel"),onClick:()=>D(u=>!u),className:"rounded-md px-1.5 py-0.5 font-medium text-ink hover:bg-raised",children:t(M?"automations.address.hideSecret":"automations.address.revealSecret")}),e.jsx("button",{type:"button","aria-label":t("automations.address.copySecretLabel"),onClick:()=>{z(v.secret)},className:"rounded-md px-1.5 py-0.5 font-medium text-ink hover:bg-raised",children:E?t("automations.address.copied"):t("automations.address.copySecret")})]}):e.jsx("p",{className:"break-all font-mono text-[11px]",children:t("automations.address.secretUnknown")}),e.jsx("p",{children:t("automations.address.header")}),f.eventTypes?.length?e.jsx("p",{children:t("automations.address.events",{events:f.eventTypes.join(", ")})}):null,e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{window.confirm(t("automations.address.replaceConfirm"))&&x.copyAddress(f.id,!0)},className:"flex items-center gap-1.5 rounded-lg border border-hairline/50 px-2.5 py-1.5 text-ink hover:bg-raised",children:[e.jsx(Qe,{size:12}),t("automations.address.replace")]})]})]})]}),w&&B&&e.jsx("p",{"data-testid":"automation-instructions",className:"whitespace-pre-wrap break-words text-[13px] leading-relaxed text-ink",children:B}),n.appTrigger&&e.jsx(At,{trigger:n.appTrigger}),e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t("automations.panel.recent")}),n.runs.length===0?e.jsx("p",{className:"text-[13px] text-ink-secondary",children:t("automations.panel.noRuns")}):e.jsx("ul",{className:"space-y-1",children:i.map(u=>{const C=je(u);return e.jsx("li",{children:e.jsxs("button",{type:"button",disabled:!u.threadId,onClick:()=>x.openRun(n,u),title:u.threadId?t("automations.panel.open"):void 0,className:"flex w-full items-baseline gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] hover:bg-raised disabled:hover:bg-transparent",children:[e.jsx("span",{className:"shrink-0 text-ink-secondary",children:C.when}),e.jsx("span",{className:S("shrink-0 font-semibold",C.mark==="✓"?"text-success":C.mark==="✗"?"text-danger":"text-warning"),children:C.mark}),e.jsx("span",{className:"min-w-0 truncate text-ink",children:C.text})]})},u.id)})})]}),x.error&&e.jsx("p",{role:"alert",className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:x.error})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 border-t border-hairline/40 px-5 py-3.5",children:[e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.runNow(n)},className:S(K,"bg-accent text-accent-ink hover:brightness-110"),children:[e.jsx(ue,{size:14}),x.busy===`run:${n.id}`?t("automations.starting"):t("automations.runNow")]}),j.state!=="done"&&e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.toggle(n)},className:S(K,"border border-hairline/50 bg-control text-ink hover:bg-raised-hover"),children:[n.enabled?e.jsx(Ke,{size:14}):e.jsx(ue,{size:14}),n.enabled?t("automations.pause"):t("automations.resume")]}),e.jsxs("button",{type:"button",onClick:g,className:S(K,"text-ink hover:bg-raised"),children:[e.jsx(Ve,{size:14}),t("automations.edit")]}),e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.remove(n,t("automations.deleteConfirm",{sentence:r})).then(u=>{u&&h()})},className:S(K,"text-danger hover:bg-danger/10"),children:[e.jsx(Xe,{size:14}),t("automations.delete")]})]})]})}const zt=()=>Array.from({length:7},(n,r)=>new Intl.DateTimeFormat(Ae(),{weekday:"narrow",timeZone:"UTC"}).format(Date.UTC(2023,0,2+r)));function ae(n){const r=new Date(n);return new Date(r.getFullYear(),r.getMonth(),1)}function pe(n,r){return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function me(n,r){return new Date(n.getFullYear(),n.getMonth()+r,1)}function Tt({anchor:n,onSelect:r}){const[l,g]=m.useState(()=>ae(n));m.useEffect(()=>{g(ae(n))},[n]);const h=m.useMemo(()=>{const i=ae(l),x=(i.getDay()+6)%7,j=new Date(i);return j.setDate(i.getDate()-x),Array.from({length:42},(f,v)=>{const y=new Date(j);return y.setDate(j.getDate()+v),y})},[l]),o=new Date(n),b=new Date,p=l.toLocaleDateString(ie(),{month:"long",year:"numeric"});return e.jsxs("section",{"aria-label":t("routines.miniCalendar.label"),className:"select-none px-3 py-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[e.jsx("div",{className:"text-[13px] font-semibold text-ink",children:p}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>g(i=>me(i,-1)),className:"flex size-7 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-raised hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60","aria-label":t("routines.miniCalendar.previous"),children:e.jsx(fe,{size:15,"aria-hidden":"true"})}),e.jsx("button",{type:"button",onClick:()=>g(i=>me(i,1)),className:"flex size-7 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-raised hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60","aria-label":t("routines.miniCalendar.next"),children:e.jsx(Ie,{size:15,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"grid grid-cols-7","aria-hidden":"true",children:zt().map((i,x)=>e.jsx("div",{className:"flex h-6 items-center justify-center text-[9px] font-semibold uppercase tracking-[0.08em] text-ink-tertiary",children:i},`${i}-${x}`))}),e.jsx("div",{className:"grid grid-cols-7 gap-y-0.5",children:h.map(i=>{const x=pe(i,o),j=pe(i,b),f=i.getMonth()!==l.getMonth(),v=i.toLocaleDateString(ie(),{weekday:"long",month:"long",day:"numeric",year:"numeric"});return e.jsx("button",{type:"button",onClick:()=>r(i.getTime()),"aria-label":v,"aria-current":j?"date":void 0,"aria-pressed":x,className:"group flex h-7 items-center justify-center rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60",children:e.jsx("span",{className:`flex size-6 items-center justify-center rounded-full text-[11px] transition-colors ${x?"bg-accent font-semibold text-white shadow-sm":j?"font-semibold text-accent group-hover:bg-accent/12":f?"text-ink-tertiary group-hover:bg-raised group-hover:text-ink":"text-ink group-hover:bg-raised"}`,children:i.getDate()})},`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`)})})]})}const Mt="application/x-openmaus-bot";function Lt({bots:n,anchor:r,onSelectDate:l}){const[g,h]=m.useState(""),o=m.useMemo(()=>{const p=g.trim().toLocaleLowerCase();return p?n.filter(i=>`${i.name} ${i.title} ${i.description}`.toLocaleLowerCase().includes(p)):n},[n,g]),b=(p,i)=>{p.dataTransfer.effectAllowed="copy",p.dataTransfer.setData(Mt,i.id),p.dataTransfer.setData("text/plain",i.id)};return e.jsxs("aside",{"aria-label":t("routines.sidebar.label"),className:"flex h-full w-[320px] shrink-0 flex-col overflow-hidden border-r border-hairline/40 bg-panel",children:[e.jsx(Tt,{anchor:r,onSelect:l}),e.jsx("div",{className:"mx-4 border-t border-hairline/40"}),e.jsxs("section",{"aria-labelledby":"calendar-bots-heading",className:"flex min-h-0 flex-1 flex-col px-3 pb-3 pt-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[e.jsxs("div",{id:"calendar-bots-heading",className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.11em] text-ink-secondary",children:[e.jsx(Ze,{size:13,"aria-hidden":"true"}),t("routines.sidebar.myBots")]}),e.jsx("span",{className:"rounded-full bg-raised px-1.5 py-0.5 text-[9px] tabular-nums text-ink-secondary",children:n.length})]}),e.jsxs("label",{className:"relative mb-2 block",children:[e.jsx("span",{className:"sr-only",children:t("routines.sidebar.searchBots")}),e.jsx(Re,{size:13,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ink-tertiary","aria-hidden":"true"}),e.jsx("input",{value:g,onChange:p=>h(p.target.value),type:"search",placeholder:t("routines.sidebar.searchBots"),className:"h-8 w-full rounded-lg border border-hairline/45 bg-control/55 pl-8 pr-2.5 text-[12px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/60 focus:bg-control"})]}),e.jsxs("div",{role:"list","aria-label":t("routines.sidebar.availableBots"),className:"min-h-0 flex-1 space-y-0.5 overflow-y-auto pr-0.5",children:[o.map(p=>e.jsxs("div",{draggable:!0,onDragStart:i=>b(i,p),role:"listitem",className:"group flex cursor-grab items-center gap-2 rounded-xl px-2 py-2 transition-colors hover:bg-raised/80 active:cursor-grabbing","aria-label":t("routines.sidebar.dragBot",{name:p.name}),title:t("routines.sidebar.dragBot",{name:p.name}),children:[e.jsx(et,{size:13,className:"shrink-0 text-ink-secondary/35 transition-colors group-hover:text-ink-secondary","aria-hidden":"true"}),e.jsx(Te,{bot:p,size:27,animated:!1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-ink",children:p.name}),e.jsx("div",{className:"truncate text-[10px] text-ink-tertiary",children:p.title||t("routines.sidebar.botFallback")})]}),e.jsx("span",{className:"shrink-0 rounded-full border border-hairline/50 px-1.5 py-0.5 text-[9px] text-ink-tertiary opacity-0 transition-opacity group-hover:opacity-100",children:t("routines.sidebar.drag")})]},p.id)),o.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] leading-relaxed text-ink-secondary",children:n.length===0?t("routines.sidebar.noBots"):t("routines.sidebar.noMatch")})]}),e.jsx("p",{className:"mt-2 px-2 text-[10px] leading-relaxed text-ink-tertiary",children:t("routines.sidebar.dragHint")})]})]})}function Ot({botFilter:n,department:r="all",selectedAutomationId:l,onOpenAutomation:g,onOpenRoom:h}){const{state:o,dispatch:b}=H(),p=window.ogb?.remoteClient?.active===!0,[i,x]=m.useState(()=>window.innerWidth<640?1:7),[j,f]=m.useState(()=>Z(Date.now())),[v,y]=m.useState([]),[N,w]=m.useState(null),[R,B]=m.useState(null),[c,I]=m.useState(null),[T,A]=m.useState(""),Y=o.bots.filter(a=>!a.hidden),M=ve(Y,we(),R?.botIds[0]),D=i===7?tt(j):Z(j),E=ne(D,i);st(D);const _=nt(Ne(),D,E),z=m.useCallback(async()=>{try{y((await W("/api/calendar-calls")).calls??[])}catch(a){A(a instanceof Error?a.message:String(a))}},[]);m.useEffect(()=>{p||z()},[z,p]);const u=m.useMemo(()=>{const a=new Set(o.bots.map(k=>k.id)),s=o.routines.filter(k=>a.has(k.botId)),d=new Set(Ce({routines:s,webhooks:[],runs:o.routineRuns}).filter(k=>de(k).state==="needs-you").map(k=>k.id)),P=at(s,o.routineRuns.filter(k=>a.has(k.botId)),D,E).map(k=>({...k,kind:"routine",needsYou:!!(k.routine&&!k.run&&d.has(k.routine.id))})),F=it(v,D,E).map(k=>({...k,kind:"call"})),$=k=>o.bots.find(Q=>Q.id===k);return[...P,...F].filter(k=>k.kind==="call"?k.call.botIds.some(Q=>te($(Q),r)):te($(k.routine?.botId??k.run?.botId),r)).filter(k=>n==="all"||(k.kind==="call"?k.call.botIds.includes(n):(k.routine?.botId??k.run?.botId)===n)).sort((k,Q)=>k.at-Q.at)},[o.routines,o.routineRuns,o.bots,v,D,E,n,r]),C=c?.kind==="call"?(()=>{const a=v.find(s=>s.id===c.call.id);return a?{...c,call:a}:null})():null,U=a=>{if(a.kind==="call"){I(a);return}I(null);const s=a.routine?.id??a.run?.routineId;s&&g(s)},V=a=>g(a.routineId),L=C?.id??u.find(a=>a.kind==="routine"&&(a.routine?.id??a.run?.routineId)===l)?.id,O=a=>y(s=>s.some(d=>d.id===a.id)?s.map(d=>d.id===a.id?a:d):[a,...s]),G=async(a,s)=>{if(s!==a.at)try{if(a.kind==="routine"){const d=o.routines.find(F=>F.id===a.id);if(!d)return;if(d.schedule.type==="cron")throw new Error(t("automations.calendar.cronMove"));if(d.schedule.type!=="once"&&!window.confirm(t("automations.calendar.moveSeries")))return;const P=await W(`/api/routines/${d.id}`,{method:"PATCH",body:JSON.stringify({schedule:xe(d.schedule,a.at,s)})});b({type:"routinePatched",routine:P.routine})}else{const d=v.find(F=>F.id===a.id);if(!d||d.schedule.type==="daily"&&!window.confirm(t("automations.calendar.moveSeries")))return;const P=await W(`/api/calendar-calls/${d.id}`,{method:"PATCH",body:JSON.stringify({schedule:xe(d.schedule,a.at,s)})});O(P.call)}}catch(d){A(d instanceof Error?d.message:String(d))}},se=async(a,s)=>{if("botId"in a){I(null),w({kind:"routine",at:s.at,durationMinutes:30,botIds:[a.botId],limitReset:{engine:s.engine}});return}if(a.event.kind!=="routine")return A(t("limits.callNotOnReset"));try{const d=await W(`/api/routines/${a.event.id}`,{method:"PATCH",body:JSON.stringify({schedule:{type:"limit_reset",engine:s.engine,repeat:"once"}})});b({type:"routinePatched",routine:d.routine})}catch(d){A(d instanceof Error?d.message:String(d))}},X=async(a,s)=>{try{if(a.kind==="routine"&&a.routine){const d=await W(`/api/routines/${a.routine.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:s})});b({type:"routinePatched",routine:d.routine})}else if(a.kind==="call"){const d=await W(`/api/calendar-calls/${a.call.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:s})});O(d.call)}}catch(d){A(d instanceof Error?d.message:String(d))}},J=()=>{C&&(B({kind:"call",at:C.at,durationMinutes:C.call.durationMinutes,botIds:C.call.botIds,call:C.call}),I(null))},q=a=>S("rounded-md px-3 py-1 text-[12px] font-medium",a?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink");return e.jsxs("div",{className:"@container/routines relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-hairline/30 px-4 py-2",children:[e.jsx("button",{type:"button",onClick:()=>f(a=>ne(a,-i)),className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("routines.previous"),children:e.jsx(fe,{size:16})}),e.jsx("button",{type:"button",onClick:()=>f(a=>ne(a,i)),className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("routines.next"),children:e.jsx(Ie,{size:16})}),e.jsx("div",{className:"min-w-0 truncate px-1 text-[14px] font-medium text-ink","aria-live":"polite",children:ot(D,i)}),e.jsx("button",{type:"button",onClick:()=>f(Z(Date.now())),className:"rounded-lg border border-hairline/50 px-2.5 py-1 text-[12px] font-medium text-ink hover:bg-raised",children:t("routines.today")}),e.jsxs("div",{role:"group",className:"ml-auto flex items-center rounded-lg border border-hairline/50 bg-panel p-0.5","aria-label":t("routines.view.label"),children:[e.jsx("button",{type:"button","aria-pressed":i===1,onClick:()=>x(1),className:q(i===1),children:t("routines.view.day")}),e.jsx("button",{type:"button","aria-pressed":i===7,onClick:()=>x(7),className:q(i===7),children:t("routines.view.week")})]}),T&&e.jsx("button",{type:"button",onClick:()=>A(""),className:"w-full text-left text-[12px] text-danger",children:T})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[!C&&e.jsx("div",{className:"hidden shrink-0 @min-[1040px]/routines:block",children:e.jsx(Lt,{bots:Y,anchor:j,onSelectDate:a=>f(Z(a))})}),e.jsx(vt,{anchor:D,days:i,items:u,bots:o.bots,groups:o.groups,selectedId:L,onOpen:U,onCreate:a=>{I(null),w(a)},onMove:(a,s)=>{G(a,s)},onResize:(a,s)=>{X(a,s)},markers:_,onDropOnReset:(a,s)=>{se(a,s)}}),C&&e.jsx("div",{className:"absolute inset-y-0 right-0 z-30 flex shadow-2xl @min-[760px]/routines:static @min-[760px]/routines:shadow-none",children:e.jsx(wt,{item:C,bots:o.bots,onClose:()=>I(null),onEdit:J,onOpenRun:V,onCallChanged:a=>{a?y(s=>s.filter(d=>d.id!==a)):z()},onOpenRoom:h},`${C.kind}:${C.id}`)})]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/25",onMouseDown:()=>w(null)}),e.jsx(Nt,{seed:N,bots:M,routinesOnly:p,onClose:()=>w(null),onMore:a=>{w(null),B(a)},onSavedRoutine:a=>b({type:"routinePatched",routine:a}),onSavedCall:O})]}),R&&e.jsx(Ct,{seed:R,bots:M,routinesOnly:p,onClose:()=>B(null),onSavedCall:O})]})}function Pt({botFilter:n="all"}){const{state:r,dispatch:l}=H(),g=rt(Ne()),[h,o]=m.useState(null),[b,p]=m.useState(null),[i,x]=m.useState("");if(!g.length)return null;const j=y=>r.bots.find(N=>N.id===y)?.modelSelection?.instanceId,f=r.routines.filter(y=>n==="all"||y.botId===n),v=async(y,N)=>{o(y.engine),x("");try{for(const w of N){const R=await W("/api/limit-resets/after-reset",{method:"POST",body:JSON.stringify({routineId:w.id,engine:y.engine})});l({type:"routinePatched",routine:R.routine})}p(y.engine)}catch(w){x(w instanceof Error?w.message:String(w))}finally{o(null)}};return e.jsxs("section",{"aria-label":t("limits.title"),className:"mb-4 space-y-2",children:[g.map(y=>{const N=lt(f,j,y);return e.jsxs("div",{"data-limit-warning":y.engine,role:"status",className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 rounded-xl border border-warning/40 bg-warning/10 px-3.5 py-2.5 text-[13px] text-ink",children:[e.jsx(St,{size:15,className:"shrink-0 text-warning","aria-hidden":"true"}),e.jsx("span",{className:"font-medium tabular-nums",children:dt(y)}),N.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-secondary",children:t(N.length===1?"limits.dueOne":"limits.dueMany",{count:N.length})}),e.jsx("button",{type:"button",disabled:h===y.engine,onClick:()=>{v(y,N)},className:"ml-auto rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-50",children:t("limits.moveAfterReset")})]}):b===y.engine&&e.jsx("span",{className:"text-ink-secondary",children:t("limits.moved")})]},y.engine)}),i&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:i})]})}function Ft(n,r){const l=n.find(h=>h.id===r);if(l)return l;const g=h=>h.messages.at(-1)?.at??0;return[...n].sort((h,o)=>g(o)-g(h))[0]}function $t({initialText:n="",onClose:r,onSetUpYourself:l}){const{state:g,dispatch:h}=H(),o=g.bots.filter(c=>!c.hidden),[b,p]=m.useState(n),[i,x]=m.useState(()=>Ft(o,g.selectedId)?.id??""),[j,f]=m.useState(!1),[v,y]=m.useState("schedule"),N=m.useRef(null);Me(N,r);const w=o.find(c=>c.id===i),R=()=>{const c=b.trim();!c||!w||(h({type:"select",id:w.id}),h({type:"send",botId:w.id,text:c,threadId:w.threadId}),r())},B=(c,I,T)=>e.jsxs("button",{type:"button",role:"radio","aria-checked":v===c,onClick:()=>y(c),className:S("flex w-full items-center gap-3 rounded-xl border px-3.5 py-3 text-left text-[14px]",v===c?"border-accent/70 bg-accent/10 text-ink":"border-hairline/50 text-ink-secondary hover:bg-raised"),children:[e.jsx(T,{size:16,className:"shrink-0 text-accent"}),I]});return e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/50 p-5 pt-[14vh] backdrop-blur-sm",onMouseDown:c=>c.target===c.currentTarget&&r(),children:e.jsxs("div",{ref:N,role:"dialog","aria-modal":"true","aria-label":t("automations.newBox.title"),tabIndex:-1,className:"w-full max-w-[560px] rounded-2xl border border-hairline/60 bg-panel p-5 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:j?t("automations.newBox.when"):t("automations.newBox.title")}),e.jsx("button",{type:"button",onClick:r,"aria-label":t("automations.newBox.cancel"),className:"rounded-full p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(be,{size:16})})]}),j?e.jsxs(e.Fragment,{children:[e.jsxs("div",{role:"radiogroup","aria-label":t("automations.newBox.when"),className:"mt-4 space-y-2",children:[B("schedule",t("automations.newBox.onSchedule"),ut),B("app",t("automations.newBox.whenAppEvent"),xt),B("webhook",t("automations.newBox.whenApp"),pt)]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(!1),className:"rounded-lg px-2 py-1.5 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",children:t("automations.newBox.back")}),e.jsx("button",{type:"button",onClick:()=>l(v,w?.id??""),className:"rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110",children:t("automations.newBox.continue")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("textarea",{autoFocus:!0,value:b,onChange:c=>p(c.target.value),rows:3,"aria-label":t("automations.newBox.title"),placeholder:t("automations.newBox.placeholder"),onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!ct(c.nativeEvent)&&(c.preventDefault(),R())},className:"mt-4 w-full resize-none rounded-xl border border-hairline/60 bg-inset px-3.5 py-3 text-[14px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/70"}),o.length===0&&e.jsx("p",{className:"mt-2 text-[13px] text-warning",children:t("automations.newBox.noBots")}),o.length>1&&e.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink-secondary",children:[t("automations.newBox.bot"),e.jsx(re,{size:"sm",value:i,onChange:c=>x(c.target.value),"aria-label":t("automations.newBox.bot"),className:"max-w-[220px]",children:o.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(!0),className:"rounded-lg px-2 py-1.5 text-[13px] text-ink-secondary underline-offset-2 hover:text-ink hover:underline",children:t("automations.newBox.yourself")}),e.jsxs("button",{type:"button",disabled:!b.trim()||!w,onClick:R,className:"flex items-center gap-2 rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-40",children:[e.jsx(jt,{size:14}),t("automations.newBox.send")]})]})]})]})})}const Wt=9;function es({onBack:n,onOpenRoom:r}){const{state:l,dispatch:g}=H(),{capabilities:h}=Le(),o=ye(),b=ge(),p=m.useRef(null),i=l.routinesFocus,x=i?.view==="calendar"?"calendar":"list",[j,f]=m.useState(i?.section!=="logs"?i?.routineId??null:null),[v,y]=m.useState(i?.botId??"all"),[N,w]=m.useState("all"),[R,B]=m.useState(null),[c,I]=m.useState(null),T=window.ogb?.remoteClient?.active===!0,A=l.bots.filter(s=>!s.hidden),Y=we(),M=s=>l.bots.find(d=>d.id===s)?.name??t("routines.unavailableBot");m.useEffect(()=>{y(i?.botId??"all"),i?.routineId&&i.section!=="logs"&&f(i.routineId)},[i]),m.useEffect(()=>{p.current?.focus({preventScroll:!0})},[]);const D=m.useMemo(()=>Ce({routines:l.routines,webhooks:T?[]:l.webhooks,appTriggers:b.triggers,runs:l.routineRuns,bots:l.bots}),[l.routines,l.webhooks,b.triggers,l.routineRuns,l.bots,T]),E=Dt(l.bots,[...new Set([...l.sections??[],...l.bots.flatMap(s=>s.section?[s.section]:[])])]),_=E.names.length+(E.hasGeneral?1:0)>1,z=N==="all"||(N===le?E.hasGeneral:E.names.includes(N))?N:"all";m.useEffect(()=>{z!==N&&(w("all"),y("all"))},[z,N]);const u=s=>te(l.bots.find(d=>d.id===s),z),C=A.filter(s=>te(s,z)),U=D.length>=Wt&&new Set(D.map(s=>s.botId)).size>1,V=mt(D.filter(s=>u(s.botId)&&(!U||v==="all"||s.botId===v))),L=D.find(s=>s.id===j)??null,O=s=>yt(s,M(s.botId)),G=h.windowChrome==="mac-inset",se=G?{WebkitAppRegion:"drag"}:void 0,X=G?{WebkitAppRegion:"no-drag"}:void 0,J=c?.kind==="schedule"?l.routines.find(s=>s.id===c.id):void 0,q=c?.kind==="webhook"?l.webhooks.find(s=>s.id===c.id):void 0,a=c?.kind==="app"?b.triggers.find(s=>s.id===c.id):void 0;return e.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col bg-app animate-workspace-in",children:[e.jsx("header",{className:S("shrink-0 border-b border-hairline/35 bg-app py-3 pr-4",G&&!Oe(h)&&x==="calendar"?"pl-[86px]":x==="list"?"pl-12 md:pl-4":"pl-4"),style:se,children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",ref:p,onClick:n,"aria-label":t("automations.back"),title:t("automations.back"),className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-raised hover:text-ink",style:X,children:e.jsx(ht,{size:18})}),e.jsx("h1",{"data-tour":"automations-page",className:"mr-1 text-[18px] font-semibold tracking-tight text-ink",children:t("automations.title")}),e.jsxs("div",{className:"ml-auto flex items-center gap-3",style:X,children:[_&&e.jsxs(re,{size:"sm","aria-label":t("automations.allDepartments"),value:z,onChange:s=>{w(s.target.value),y("all")},className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allDepartments")}),E.names.map(s=>e.jsx("option",{value:s,children:s},s)),E.hasGeneral&&e.jsx("option",{value:le,children:t("automations.generalDepartment")})]}),U&&x==="list"&&e.jsxs(re,{size:"sm","aria-label":t("automations.allBots"),value:v,onChange:s=>y(s.target.value),className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allBots")}),C.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]}),e.jsx("div",{role:"group","aria-label":t("automations.view"),className:"flex items-center rounded-lg border border-hairline/50 bg-panel p-0.5",children:["list","calendar"].map(s=>e.jsx("button",{type:"button","aria-pressed":x===s,onClick:()=>g({type:"showRoutines",view:s,botId:v==="all"?void 0:v}),className:S("rounded-md px-3 py-1 text-[13px] font-medium",x===s?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s==="list"?t("automations.list"):t("automations.calendar")},s))}),e.jsxs("button",{type:"button",onClick:()=>B(""),className:"flex items-center gap-1.5 rounded-lg bg-accent px-3.5 py-2 text-[13px] font-semibold text-accent-ink hover:brightness-110",children:[e.jsx(ce,{size:15,"aria-hidden":"true"}),t("automations.new")]})]})]})}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[x==="calendar"?e.jsx(Ot,{botFilter:v,department:z,selectedAutomationId:j,onOpenAutomation:f,onOpenRoom:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto w-full max-w-3xl p-4 sm:p-6",children:[e.jsx(Pt,{botFilter:U?v:"all"}),D.length===0&&l.routinesLoadState!=="loading"&&l.hydrated?e.jsxs("section",{"aria-label":t("automations.empty.title"),className:"px-6 py-16 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex size-12 items-center justify-center rounded-2xl bg-accent/10 text-accent",children:e.jsx(bt,{size:22})}),e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:t("automations.empty.title")}),e.jsx("button",{type:"button",onClick:()=>B(t("automations.empty.example")),className:"mt-3 text-[14px] text-accent-text underline-offset-2 hover:underline",children:t("automations.empty.try")}),e.jsx("div",{children:e.jsxs("button",{type:"button",onClick:()=>B(""),className:"mt-6 inline-flex items-center gap-2 rounded-xl bg-accent px-4 py-2.5 text-[13px] font-medium text-accent-ink hover:brightness-110",children:[e.jsx(ce,{size:15}),t("automations.new")]})})]}):e.jsx("ul",{"aria-label":t("automations.title"),className:"divide-y divide-hairline/30 overflow-hidden rounded-2xl border border-hairline/40 bg-card",children:V.map(s=>{const d=de(s),P=s.name.trim(),F=s.runs.find(k=>ee(k)&&!k.seenAt),$=F&&je(F);return e.jsxs("li",{"data-automation":s.id,"data-automation-status":d.state,className:S("flex items-start gap-3 px-4 py-3.5",j===s.id&&"bg-raised/60"),children:[e.jsx(Be,{status:d,className:"mt-[5px]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>f(s.id),className:"block text-left text-[15px] font-medium leading-snug text-ink hover:text-accent-text",children:P||O(s)}),P&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink",children:O(s)}),d.state==="needs-you"?e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2 text-[13px] text-warning",children:[t("automations.needsYou",{reason:d.reason??""}),e.jsx(De,{automation:s,status:d,actions:o,onEdit:()=>I({kind:s.kind,id:s.id})})]}):e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:ft(s)}),$&&e.jsxs("button",{type:"button",onClick:()=>f(s.id),className:"mt-1 flex items-baseline gap-2 text-left text-[13px] text-danger",children:[e.jsx("span",{"aria-hidden":"true",className:"size-2 shrink-0 self-center rounded-full bg-danger"}),e.jsxs("span",{children:[$.when," ",$.mark," ",$.text]})]}),o.error&&o.errorFor?.endsWith(`:${s.id}`)&&e.jsx("p",{role:"alert",className:"mt-1 text-[12px] text-danger",children:o.error})]}),d.state!=="done"&&e.jsx(Se,{checked:s.enabled,disabled:o.busy===`toggle:${s.id}`,"aria-label":t("automations.toggle",{name:s.name}),onClick:()=>{o.toggle(s)},className:"mt-0.5 shrink-0"})]},s.id)})}),o.error&&!V.some(s=>o.errorFor?.endsWith(`:${s.id}`))&&e.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-danger",children:o.error}),e.jsx(Yt,{})]})}),L&&e.jsx("div",{className:"absolute inset-y-0 right-0 z-30 flex shadow-2xl lg:static lg:shadow-none",children:e.jsx(Et,{automation:L,sentence:O(L),onClose:()=>f(null),onDeleted:()=>f(null),onEdit:()=>I({kind:L.kind,id:L.id})},L.id)})]}),R!==null&&e.jsx($t,{initialText:R,onClose:()=>B(null),onSetUpYourself:(s,d)=>{B(null),I({kind:s,botId:d})}}),c?.kind==="schedule"&&(J||!c.id)&&e.jsx(It,{routine:J,bots:ve(A,Y,J?.botId),initialBotId:c.botId,plain:!0,onClose:()=>I(null)}),c?.kind==="webhook"&&(q||!c.id)&&e.jsx(Bt,{webhook:q,bots:A,initialBotId:c.botId,onClose:()=>I(null),onCredential:(s,d)=>{gt(ke(),d,s),f(d)}}),c?.kind==="app"&&(a||!c.id)&&e.jsx(kt,{trigger:a,bots:A,initialBotId:c.botId,onClose:()=>I(null),onSaved:s=>f(s.id)})]})}function Yt(){const n=typeof window<"u"?window.ogb?.routines:void 0,[r,l]=m.useState(null),[g,h]=m.useState(!1);return m.useEffect(()=>{if(!n)return;let o=!1;const b=()=>n.wakeState().then(i=>{o||l(i)}).catch(()=>{});b();const p=window.setInterval(b,3e4);return()=>{o=!0,window.clearInterval(p)}},[n]),!n||!r?null:e.jsxs("div",{className:"mt-6 flex items-center justify-between gap-4 px-1 text-[12px] text-ink-secondary",children:[e.jsxs("span",{children:[t("automations.wake"),r.keepAwake&&r.onBattery?` ${t("automations.wakeBattery")}`:""]}),e.jsx(Se,{checked:r.keepAwake,disabled:g,"aria-label":t("automations.wake"),onClick:()=>{h(!0),n.keepAwake(!r.keepAwake).then(l).catch(()=>{}).finally(()=>h(!1))},className:"shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}export{es as TriggersPage};
1
+ import{j as e,t,a as S,i as ie,f as he,r as m,X as be,C as fe,n as Ae,S as Re}from"./styles-3gApXdcp.js";import{C as Ee,J as ze,B as Te,c as Me,d as Le,P as ce,V as Oe}from"./PlacesRail-C-RypDbo.js";import{co as ge,cp as Pe,cq as Fe,cr as oe,Y as $e,u as H,cs as We,ct as Ye,cu as ee,cv as ye,cw as de,cx as _e,cy as ke,cz as He,cA as Ue,cB as Ge,cC as Je,br as qe,cD as Qe,cE as je,cF as ue,cG as Ke,cH as Ve,T as Xe,cI as Ze,cJ as et,cK as Z,cL as ve,cf as we,cM as tt,cN as ne,cO as st,cP as nt,cQ as Ne,n as W,cR as Ce,cS as at,cT as it,cU as ot,cV as xe,cW as rt,cX as lt,cY as dt,cZ as ct,D as re,w as ut,c_ as xt,bF as pt,c$ as mt,bD as ht,d0 as bt,d1 as ft,S as Se,d2 as gt,d3 as yt}from"./App-0-mtr0MN.js";import{AppEventEditor as kt}from"./AppEventEditor-cxtdNROG.js";import{C as Ie,S as jt}from"./MenuMotion-Dg_hALEl.js";import{C as vt,E as wt,Q as Nt,b as Ct,H as St,R as It}from"./RoutinesPage-DI6CbJ-R.js";import{WebhookEditor as Bt}from"./WebhookTrigger-TRl3ZXbh.js";import"./monitor-CqHNmvSo.js";import"./index-CnQ2pCf7.js";import"./remote-desktop-DDRRx8uY.js";import"./ProIntroduction-DrVULNMR.js";const le="\0general";function Dt(n,r){const l=n.filter(h=>!h.hidden),g=new Set(l.map(h=>h.section).filter(h=>!!h));return{names:r.filter(h=>g.has(h)),hasGeneral:l.some(h=>!h.section)}}function te(n,r){return r==="all"?!0:n?r===le?!n.section:n.section===r:!1}function At({trigger:n}){const{attempts:r,service:l}=ge(),g=r.filter(o=>o.triggerId===n.id).slice(-6).reverse(),h=Pe(n);return e.jsxs("section",{"data-app-events":n.id,children:[e.jsx("h3",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t("automations.panel.events")}),h&&e.jsx("p",{className:"mb-2 rounded-lg bg-warning/10 px-2.5 py-1.5 text-[12px] text-warning",children:h}),g.length===0?e.jsx("p",{className:"text-[13px] text-ink-secondary",children:t("automations.panel.noEvents")}):e.jsx("ul",{className:"space-y-1",children:g.map(o=>{const b=Fe(o),p=oe(o.at);return e.jsxs("li",{className:"flex items-baseline gap-2 px-2 py-1 text-[13px]",children:[e.jsx("span",{className:"shrink-0 text-ink-secondary",children:p.charAt(0).toLocaleUpperCase()+p.slice(1)}),e.jsx("span",{className:S("shrink-0 font-semibold",b.mark==="✓"?"text-success":b.mark==="✗"?"text-danger":"text-ink-tertiary"),children:b.mark}),e.jsx("span",{className:"min-w-0 truncate text-ink",title:b.text,children:b.text})]},o.id)})}),l?.eventsPerDay&&e.jsx("p",{className:"mt-2 text-[11px] text-ink-tertiary",children:t("automations.app.limit",{count:l.eventsPerDay.toLocaleString(ie()),place:t(l.plan==="cloud"?"automations.app.placeCloud":"automations.app.placeDesktop")})})]})}function Be({status:n,className:r}){return n.state==="needs-you"?e.jsx($e,{size:15,"aria-hidden":"true",className:S("shrink-0 text-warning",r)}):n.state==="done"?e.jsx(he,{size:14,"aria-hidden":"true",className:S("shrink-0 text-ink-tertiary",r)}):e.jsx("span",{"aria-hidden":"true",className:S("size-2.5 shrink-0 rounded-full",n.state==="working"?"bg-success":"bg-ink-tertiary/60",r)})}function De({automation:n,status:r,actions:l,onEdit:g,className:h}){const{dispatch:o}=H();if(r.state!=="needs-you"||!r.fix)return null;const b=r.fix,p=b==="answer"?We(n.runs):void 0,i=()=>{b==="answer"?l.openRun(n,p):b==="sign-in"?l.openRun(n,n.runs.find(x=>x.status!=="queued")):b==="usage"?o({type:"toggleAppSettings",open:!0,section:"usage"}):b==="edit"?g():b==="reconnect"?o({type:"togglePlugins",open:!0,surface:"apps"}):l.runNow(n)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:i,disabled:!!l.busy,className:S("shrink-0 rounded-lg bg-warning/15 px-2.5 py-1 text-[12px] font-medium text-warning hover:bg-warning/25 disabled:opacity-50",h),children:t(Ye[b])}),p&&e.jsx("button",{type:"button","data-automation-cancel-run":!0,onClick:()=>{l.cancelRun(n,p)},disabled:!!l.busy,className:S("shrink-0 rounded-lg px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50",h),children:t("routines.drawer.cancelRun")})]})}const Rt=5,K="flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-[13px] font-medium disabled:opacity-50";function Et({automation:n,sentence:r,onClose:l,onEdit:g,onDeleted:h}){const{state:o,dispatch:b}=H(),[p]=m.useState(()=>new Set(n.runs.filter(u=>ee(u)&&!u.seenAt).map(u=>u.id))),i=n.runs.filter((u,C)=>C<Rt||p.has(u.id)||ee(u)&&!u.seenAt);m.useEffect(()=>{for(const u of n.runs)ee(u)&&!u.seenAt&&b({type:"markRoutineRunSeen",runId:u.id})},[n.runs,b]);const x=ye(),j=de(n),f=n.kind==="webhook"?o.webhooks.find(u=>u.id===n.id):void 0,v=f?_e(ke())[f.id]:void 0,y=o.webhookIngress?.available!==!1,N=t(He[j.state]),w=n.name.trim(),R=o.bots.find(u=>u.id===n.botId)?.name??t("routines.unavailableBot"),B=n.instructions.trim(),c=j.state==="done"?t("automations.reason.done"):j.reason,I=f?Ue(f.id,o.webhookAttempts):[],T=f?Ge(f,o.webhookAttempts):null,[A,Y]=m.useState(null),[M,D]=m.useState(!1),[E,_]=m.useState(!1),z=async u=>{if(await ze(u)!=="copied"){x.setError(t("automations.address.copyFailed"));return}_(!0),setTimeout(()=>_(!1),1800)};return e.jsxs("aside",{"aria-label":t("automations.panel.label"),className:"flex h-full w-[min(380px,100vw)] shrink-0 flex-col border-l border-hairline/40 bg-panel",children:[e.jsxs("div",{className:"flex items-start gap-3 border-b border-hairline/40 px-5 py-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-[16px] font-semibold leading-snug text-ink",children:w||r}),w&&e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:Je(n,R)})]}),e.jsx("button",{type:"button",onClick:l,className:"rounded-full p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("automations.panel.close"),children:e.jsx(be,{size:16})})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[13px]","data-automation-status":j.state,children:[e.jsx(Be,{status:j}),e.jsx("span",{className:S("font-medium",j.state==="needs-you"?"text-warning":"text-ink"),children:N}),c&&e.jsx("span",{className:"min-w-0 text-ink-secondary",children:c}),e.jsx(De,{automation:n,status:j,actions:x,onEdit:g})]}),f&&e.jsxs("section",{className:"rounded-xl border border-hairline/45 bg-inset/50 p-3.5",children:[e.jsx("h3",{className:"text-[13px] font-medium text-ink",children:t("automations.address.title")}),e.jsxs("button",{type:"button",disabled:!!x.busy||!y,onClick:()=>{x.copyAddress(f.id)},className:S(K,"mt-2.5 bg-accent text-accent-ink hover:brightness-110"),children:[x.copied===f.id?e.jsx(he,{size:14}):e.jsx(Ee,{size:14}),x.copied===f.id?t("automations.address.copied"):t("automations.address.copy")]}),(!y||!o.config?.cloudHome)&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:y?t("automations.address.keepOpen"):t("automations.address.unavailable")}),e.jsxs("details",{className:"mt-2.5 text-[12px] text-ink-secondary",children:[e.jsx("summary",{className:"cursor-pointer select-none font-medium text-ink-secondary hover:text-ink",children:t("automations.more")}),e.jsxs("div",{className:"mt-2 space-y-2 leading-relaxed",children:[T&&e.jsxs("section",{"aria-label":t("automations.received.title"),children:[e.jsxs("p",{className:"font-medium text-ink",children:[t("automations.received.title")," · ",oe(T.at)]}),e.jsx("p",{className:"mt-0.5",children:t("automations.received.help")}),e.jsx("pre",{className:"mt-1.5 max-h-40 overflow-auto whitespace-pre-wrap break-all rounded-lg bg-inset px-2.5 py-2 font-mono text-[11px] text-ink",children:T.preview.slice(0,1e3)})]}),e.jsxs("section",{"aria-label":t("automations.calls.title"),children:[e.jsx("p",{className:"font-medium text-ink",children:t("automations.calls.title")}),I.length===0?e.jsx("p",{className:"mt-0.5",children:t("automations.calls.none")}):e.jsx("ul",{className:"mt-1 space-y-0.5",children:I.map(u=>e.jsxs("li",{"data-call":u.ok?"ok":"refused",children:[e.jsxs("button",{type:"button","aria-expanded":A===u.id,onClick:()=>Y(C=>C===u.id?null:u.id),className:"flex w-full items-baseline gap-2 rounded-md px-1.5 py-1 text-left hover:bg-raised",children:[e.jsx("span",{className:"shrink-0",children:qe(oe(u.at))}),e.jsx("span",{className:S("shrink-0 font-semibold",u.ok?"text-success":"text-danger"),children:u.ok?"✓":"✗"}),e.jsx("span",{className:"min-w-0 truncate text-ink",children:u.reason})]}),A===u.id&&e.jsx("pre",{className:"mx-1.5 mb-1 whitespace-pre-wrap break-all rounded-md bg-inset px-2 py-1.5 font-mono text-[11px] text-ink",children:u.preview||t("automations.calls.empty")})]},u.id))})]}),e.jsx("p",{className:"font-medium text-ink",children:t("automations.address.showSecret")}),v?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1","data-secret":M?"shown":"masked",children:[e.jsx("span",{className:"min-w-0 break-all font-mono text-[11px]",children:t("automations.address.secret",{secret:M?v.secret:"••••••••"})}),e.jsx("button",{type:"button","aria-label":t(M?"automations.address.hideSecretLabel":"automations.address.showSecretLabel"),onClick:()=>D(u=>!u),className:"rounded-md px-1.5 py-0.5 font-medium text-ink hover:bg-raised",children:t(M?"automations.address.hideSecret":"automations.address.revealSecret")}),e.jsx("button",{type:"button","aria-label":t("automations.address.copySecretLabel"),onClick:()=>{z(v.secret)},className:"rounded-md px-1.5 py-0.5 font-medium text-ink hover:bg-raised",children:E?t("automations.address.copied"):t("automations.address.copySecret")})]}):e.jsx("p",{className:"break-all font-mono text-[11px]",children:t("automations.address.secretUnknown")}),e.jsx("p",{children:t("automations.address.header")}),f.eventTypes?.length?e.jsx("p",{children:t("automations.address.events",{events:f.eventTypes.join(", ")})}):null,e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{window.confirm(t("automations.address.replaceConfirm"))&&x.copyAddress(f.id,!0)},className:"flex items-center gap-1.5 rounded-lg border border-hairline/50 px-2.5 py-1.5 text-ink hover:bg-raised",children:[e.jsx(Qe,{size:12}),t("automations.address.replace")]})]})]})]}),w&&B&&e.jsx("p",{"data-testid":"automation-instructions",className:"whitespace-pre-wrap break-words text-[13px] leading-relaxed text-ink",children:B}),n.appTrigger&&e.jsx(At,{trigger:n.appTrigger}),e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t("automations.panel.recent")}),n.runs.length===0?e.jsx("p",{className:"text-[13px] text-ink-secondary",children:t("automations.panel.noRuns")}):e.jsx("ul",{className:"space-y-1",children:i.map(u=>{const C=je(u);return e.jsx("li",{children:e.jsxs("button",{type:"button",disabled:!u.threadId,onClick:()=>x.openRun(n,u),title:u.threadId?t("automations.panel.open"):void 0,className:"flex w-full items-baseline gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] hover:bg-raised disabled:hover:bg-transparent",children:[e.jsx("span",{className:"shrink-0 text-ink-secondary",children:C.when}),e.jsx("span",{className:S("shrink-0 font-semibold",C.mark==="✓"?"text-success":C.mark==="✗"?"text-danger":"text-warning"),children:C.mark}),e.jsx("span",{className:"min-w-0 truncate text-ink",children:C.text})]})},u.id)})})]}),x.error&&e.jsx("p",{role:"alert",className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:x.error})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 border-t border-hairline/40 px-5 py-3.5",children:[e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.runNow(n)},className:S(K,"bg-accent text-accent-ink hover:brightness-110"),children:[e.jsx(ue,{size:14}),x.busy===`run:${n.id}`?t("automations.starting"):t("automations.runNow")]}),j.state!=="done"&&e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.toggle(n)},className:S(K,"border border-hairline/50 bg-control text-ink hover:bg-raised-hover"),children:[n.enabled?e.jsx(Ke,{size:14}):e.jsx(ue,{size:14}),n.enabled?t("automations.pause"):t("automations.resume")]}),e.jsxs("button",{type:"button",onClick:g,className:S(K,"text-ink hover:bg-raised"),children:[e.jsx(Ve,{size:14}),t("automations.edit")]}),e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.remove(n,t("automations.deleteConfirm",{sentence:r})).then(u=>{u&&h()})},className:S(K,"text-danger hover:bg-danger/10"),children:[e.jsx(Xe,{size:14}),t("automations.delete")]})]})]})}const zt=()=>Array.from({length:7},(n,r)=>new Intl.DateTimeFormat(Ae(),{weekday:"narrow",timeZone:"UTC"}).format(Date.UTC(2023,0,2+r)));function ae(n){const r=new Date(n);return new Date(r.getFullYear(),r.getMonth(),1)}function pe(n,r){return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function me(n,r){return new Date(n.getFullYear(),n.getMonth()+r,1)}function Tt({anchor:n,onSelect:r}){const[l,g]=m.useState(()=>ae(n));m.useEffect(()=>{g(ae(n))},[n]);const h=m.useMemo(()=>{const i=ae(l),x=(i.getDay()+6)%7,j=new Date(i);return j.setDate(i.getDate()-x),Array.from({length:42},(f,v)=>{const y=new Date(j);return y.setDate(j.getDate()+v),y})},[l]),o=new Date(n),b=new Date,p=l.toLocaleDateString(ie(),{month:"long",year:"numeric"});return e.jsxs("section",{"aria-label":t("routines.miniCalendar.label"),className:"select-none px-3 py-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[e.jsx("div",{className:"text-[13px] font-semibold text-ink",children:p}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>g(i=>me(i,-1)),className:"flex size-7 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-raised hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60","aria-label":t("routines.miniCalendar.previous"),children:e.jsx(fe,{size:15,"aria-hidden":"true"})}),e.jsx("button",{type:"button",onClick:()=>g(i=>me(i,1)),className:"flex size-7 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-raised hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60","aria-label":t("routines.miniCalendar.next"),children:e.jsx(Ie,{size:15,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"grid grid-cols-7","aria-hidden":"true",children:zt().map((i,x)=>e.jsx("div",{className:"flex h-6 items-center justify-center text-[9px] font-semibold uppercase tracking-[0.08em] text-ink-tertiary",children:i},`${i}-${x}`))}),e.jsx("div",{className:"grid grid-cols-7 gap-y-0.5",children:h.map(i=>{const x=pe(i,o),j=pe(i,b),f=i.getMonth()!==l.getMonth(),v=i.toLocaleDateString(ie(),{weekday:"long",month:"long",day:"numeric",year:"numeric"});return e.jsx("button",{type:"button",onClick:()=>r(i.getTime()),"aria-label":v,"aria-current":j?"date":void 0,"aria-pressed":x,className:"group flex h-7 items-center justify-center rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60",children:e.jsx("span",{className:`flex size-6 items-center justify-center rounded-full text-[11px] transition-colors ${x?"bg-accent font-semibold text-white shadow-sm":j?"font-semibold text-accent group-hover:bg-accent/12":f?"text-ink-tertiary group-hover:bg-raised group-hover:text-ink":"text-ink group-hover:bg-raised"}`,children:i.getDate()})},`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`)})})]})}const Mt="application/x-openmaus-bot";function Lt({bots:n,anchor:r,onSelectDate:l}){const[g,h]=m.useState(""),o=m.useMemo(()=>{const p=g.trim().toLocaleLowerCase();return p?n.filter(i=>`${i.name} ${i.title} ${i.description}`.toLocaleLowerCase().includes(p)):n},[n,g]),b=(p,i)=>{p.dataTransfer.effectAllowed="copy",p.dataTransfer.setData(Mt,i.id),p.dataTransfer.setData("text/plain",i.id)};return e.jsxs("aside",{"aria-label":t("routines.sidebar.label"),className:"flex h-full w-[320px] shrink-0 flex-col overflow-hidden border-r border-hairline/40 bg-panel",children:[e.jsx(Tt,{anchor:r,onSelect:l}),e.jsx("div",{className:"mx-4 border-t border-hairline/40"}),e.jsxs("section",{"aria-labelledby":"calendar-bots-heading",className:"flex min-h-0 flex-1 flex-col px-3 pb-3 pt-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[e.jsxs("div",{id:"calendar-bots-heading",className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.11em] text-ink-secondary",children:[e.jsx(Ze,{size:13,"aria-hidden":"true"}),t("routines.sidebar.myBots")]}),e.jsx("span",{className:"rounded-full bg-raised px-1.5 py-0.5 text-[9px] tabular-nums text-ink-secondary",children:n.length})]}),e.jsxs("label",{className:"relative mb-2 block",children:[e.jsx("span",{className:"sr-only",children:t("routines.sidebar.searchBots")}),e.jsx(Re,{size:13,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ink-tertiary","aria-hidden":"true"}),e.jsx("input",{value:g,onChange:p=>h(p.target.value),type:"search",placeholder:t("routines.sidebar.searchBots"),className:"h-8 w-full rounded-lg border border-hairline/45 bg-control/55 pl-8 pr-2.5 text-[12px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/60 focus:bg-control"})]}),e.jsxs("div",{role:"list","aria-label":t("routines.sidebar.availableBots"),className:"min-h-0 flex-1 space-y-0.5 overflow-y-auto pr-0.5",children:[o.map(p=>e.jsxs("div",{draggable:!0,onDragStart:i=>b(i,p),role:"listitem",className:"group flex cursor-grab items-center gap-2 rounded-xl px-2 py-2 transition-colors hover:bg-raised/80 active:cursor-grabbing","aria-label":t("routines.sidebar.dragBot",{name:p.name}),title:t("routines.sidebar.dragBot",{name:p.name}),children:[e.jsx(et,{size:13,className:"shrink-0 text-ink-secondary/35 transition-colors group-hover:text-ink-secondary","aria-hidden":"true"}),e.jsx(Te,{bot:p,size:27,animated:!1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-ink",children:p.name}),e.jsx("div",{className:"truncate text-[10px] text-ink-tertiary",children:p.title||t("routines.sidebar.botFallback")})]}),e.jsx("span",{className:"shrink-0 rounded-full border border-hairline/50 px-1.5 py-0.5 text-[9px] text-ink-tertiary opacity-0 transition-opacity group-hover:opacity-100",children:t("routines.sidebar.drag")})]},p.id)),o.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] leading-relaxed text-ink-secondary",children:n.length===0?t("routines.sidebar.noBots"):t("routines.sidebar.noMatch")})]}),e.jsx("p",{className:"mt-2 px-2 text-[10px] leading-relaxed text-ink-tertiary",children:t("routines.sidebar.dragHint")})]})]})}function Ot({botFilter:n,department:r="all",selectedAutomationId:l,onOpenAutomation:g,onOpenRoom:h}){const{state:o,dispatch:b}=H(),p=window.ogb?.remoteClient?.active===!0,[i,x]=m.useState(()=>window.innerWidth<640?1:7),[j,f]=m.useState(()=>Z(Date.now())),[v,y]=m.useState([]),[N,w]=m.useState(null),[R,B]=m.useState(null),[c,I]=m.useState(null),[T,A]=m.useState(""),Y=o.bots.filter(a=>!a.hidden),M=ve(Y,we(),R?.botIds[0]),D=i===7?tt(j):Z(j),E=ne(D,i);st(D);const _=nt(Ne(),D,E),z=m.useCallback(async()=>{try{y((await W("/api/calendar-calls")).calls??[])}catch(a){A(a instanceof Error?a.message:String(a))}},[]);m.useEffect(()=>{p||z()},[z,p]);const u=m.useMemo(()=>{const a=new Set(o.bots.map(k=>k.id)),s=o.routines.filter(k=>a.has(k.botId)),d=new Set(Ce({routines:s,webhooks:[],runs:o.routineRuns}).filter(k=>de(k).state==="needs-you").map(k=>k.id)),P=at(s,o.routineRuns.filter(k=>a.has(k.botId)),D,E).map(k=>({...k,kind:"routine",needsYou:!!(k.routine&&!k.run&&d.has(k.routine.id))})),F=it(v,D,E).map(k=>({...k,kind:"call"})),$=k=>o.bots.find(Q=>Q.id===k);return[...P,...F].filter(k=>k.kind==="call"?k.call.botIds.some(Q=>te($(Q),r)):te($(k.routine?.botId??k.run?.botId),r)).filter(k=>n==="all"||(k.kind==="call"?k.call.botIds.includes(n):(k.routine?.botId??k.run?.botId)===n)).sort((k,Q)=>k.at-Q.at)},[o.routines,o.routineRuns,o.bots,v,D,E,n,r]),C=c?.kind==="call"?(()=>{const a=v.find(s=>s.id===c.call.id);return a?{...c,call:a}:null})():null,U=a=>{if(a.kind==="call"){I(a);return}I(null);const s=a.routine?.id??a.run?.routineId;s&&g(s)},V=a=>g(a.routineId),L=C?.id??u.find(a=>a.kind==="routine"&&(a.routine?.id??a.run?.routineId)===l)?.id,O=a=>y(s=>s.some(d=>d.id===a.id)?s.map(d=>d.id===a.id?a:d):[a,...s]),G=async(a,s)=>{if(s!==a.at)try{if(a.kind==="routine"){const d=o.routines.find(F=>F.id===a.id);if(!d)return;if(d.schedule.type==="cron")throw new Error(t("automations.calendar.cronMove"));if(d.schedule.type!=="once"&&!window.confirm(t("automations.calendar.moveSeries")))return;const P=await W(`/api/routines/${d.id}`,{method:"PATCH",body:JSON.stringify({schedule:xe(d.schedule,a.at,s)})});b({type:"routinePatched",routine:P.routine})}else{const d=v.find(F=>F.id===a.id);if(!d||d.schedule.type==="daily"&&!window.confirm(t("automations.calendar.moveSeries")))return;const P=await W(`/api/calendar-calls/${d.id}`,{method:"PATCH",body:JSON.stringify({schedule:xe(d.schedule,a.at,s)})});O(P.call)}}catch(d){A(d instanceof Error?d.message:String(d))}},se=async(a,s)=>{if("botId"in a){I(null),w({kind:"routine",at:s.at,durationMinutes:30,botIds:[a.botId],limitReset:{engine:s.engine}});return}if(a.event.kind!=="routine")return A(t("limits.callNotOnReset"));try{const d=await W(`/api/routines/${a.event.id}`,{method:"PATCH",body:JSON.stringify({schedule:{type:"limit_reset",engine:s.engine,repeat:"once"}})});b({type:"routinePatched",routine:d.routine})}catch(d){A(d instanceof Error?d.message:String(d))}},X=async(a,s)=>{try{if(a.kind==="routine"&&a.routine){const d=await W(`/api/routines/${a.routine.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:s})});b({type:"routinePatched",routine:d.routine})}else if(a.kind==="call"){const d=await W(`/api/calendar-calls/${a.call.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:s})});O(d.call)}}catch(d){A(d instanceof Error?d.message:String(d))}},J=()=>{C&&(B({kind:"call",at:C.at,durationMinutes:C.call.durationMinutes,botIds:C.call.botIds,call:C.call}),I(null))},q=a=>S("rounded-md px-3 py-1 text-[12px] font-medium",a?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink");return e.jsxs("div",{className:"@container/routines relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-hairline/30 px-4 py-2",children:[e.jsx("button",{type:"button",onClick:()=>f(a=>ne(a,-i)),className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("routines.previous"),children:e.jsx(fe,{size:16})}),e.jsx("button",{type:"button",onClick:()=>f(a=>ne(a,i)),className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("routines.next"),children:e.jsx(Ie,{size:16})}),e.jsx("div",{className:"min-w-0 truncate px-1 text-[14px] font-medium text-ink","aria-live":"polite",children:ot(D,i)}),e.jsx("button",{type:"button",onClick:()=>f(Z(Date.now())),className:"rounded-lg border border-hairline/50 px-2.5 py-1 text-[12px] font-medium text-ink hover:bg-raised",children:t("routines.today")}),e.jsxs("div",{role:"group",className:"ml-auto flex items-center rounded-lg border border-hairline/50 bg-panel p-0.5","aria-label":t("routines.view.label"),children:[e.jsx("button",{type:"button","aria-pressed":i===1,onClick:()=>x(1),className:q(i===1),children:t("routines.view.day")}),e.jsx("button",{type:"button","aria-pressed":i===7,onClick:()=>x(7),className:q(i===7),children:t("routines.view.week")})]}),T&&e.jsx("button",{type:"button",onClick:()=>A(""),className:"w-full text-left text-[12px] text-danger",children:T})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[!C&&e.jsx("div",{className:"hidden shrink-0 @min-[1040px]/routines:block",children:e.jsx(Lt,{bots:Y,anchor:j,onSelectDate:a=>f(Z(a))})}),e.jsx(vt,{anchor:D,days:i,items:u,bots:o.bots,groups:o.groups,selectedId:L,onOpen:U,onCreate:a=>{I(null),w(a)},onMove:(a,s)=>{G(a,s)},onResize:(a,s)=>{X(a,s)},markers:_,onDropOnReset:(a,s)=>{se(a,s)}}),C&&e.jsx("div",{className:"absolute inset-y-0 right-0 z-30 flex shadow-2xl @min-[760px]/routines:static @min-[760px]/routines:shadow-none",children:e.jsx(wt,{item:C,bots:o.bots,onClose:()=>I(null),onEdit:J,onOpenRun:V,onCallChanged:a=>{a?y(s=>s.filter(d=>d.id!==a)):z()},onOpenRoom:h},`${C.kind}:${C.id}`)})]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/25",onMouseDown:()=>w(null)}),e.jsx(Nt,{seed:N,bots:M,routinesOnly:p,onClose:()=>w(null),onMore:a=>{w(null),B(a)},onSavedRoutine:a=>b({type:"routinePatched",routine:a}),onSavedCall:O})]}),R&&e.jsx(Ct,{seed:R,bots:M,routinesOnly:p,onClose:()=>B(null),onSavedCall:O})]})}function Pt({botFilter:n="all"}){const{state:r,dispatch:l}=H(),g=rt(Ne()),[h,o]=m.useState(null),[b,p]=m.useState(null),[i,x]=m.useState("");if(!g.length)return null;const j=y=>r.bots.find(N=>N.id===y)?.modelSelection?.instanceId,f=r.routines.filter(y=>n==="all"||y.botId===n),v=async(y,N)=>{o(y.engine),x("");try{for(const w of N){const R=await W("/api/limit-resets/after-reset",{method:"POST",body:JSON.stringify({routineId:w.id,engine:y.engine})});l({type:"routinePatched",routine:R.routine})}p(y.engine)}catch(w){x(w instanceof Error?w.message:String(w))}finally{o(null)}};return e.jsxs("section",{"aria-label":t("limits.title"),className:"mb-4 space-y-2",children:[g.map(y=>{const N=lt(f,j,y);return e.jsxs("div",{"data-limit-warning":y.engine,role:"status",className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 rounded-xl border border-warning/40 bg-warning/10 px-3.5 py-2.5 text-[13px] text-ink",children:[e.jsx(St,{size:15,className:"shrink-0 text-warning","aria-hidden":"true"}),e.jsx("span",{className:"font-medium tabular-nums",children:dt(y)}),N.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-secondary",children:t(N.length===1?"limits.dueOne":"limits.dueMany",{count:N.length})}),e.jsx("button",{type:"button",disabled:h===y.engine,onClick:()=>{v(y,N)},className:"ml-auto rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-50",children:t("limits.moveAfterReset")})]}):b===y.engine&&e.jsx("span",{className:"text-ink-secondary",children:t("limits.moved")})]},y.engine)}),i&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:i})]})}function Ft(n,r){const l=n.find(h=>h.id===r);if(l)return l;const g=h=>h.messages.at(-1)?.at??0;return[...n].sort((h,o)=>g(o)-g(h))[0]}function $t({initialText:n="",onClose:r,onSetUpYourself:l}){const{state:g,dispatch:h}=H(),o=g.bots.filter(c=>!c.hidden),[b,p]=m.useState(n),[i,x]=m.useState(()=>Ft(o,g.selectedId)?.id??""),[j,f]=m.useState(!1),[v,y]=m.useState("schedule"),N=m.useRef(null);Me(N,r);const w=o.find(c=>c.id===i),R=()=>{const c=b.trim();!c||!w||(h({type:"select",id:w.id}),h({type:"send",botId:w.id,text:c,threadId:w.threadId}),r())},B=(c,I,T)=>e.jsxs("button",{type:"button",role:"radio","aria-checked":v===c,onClick:()=>y(c),className:S("flex w-full items-center gap-3 rounded-xl border px-3.5 py-3 text-left text-[14px]",v===c?"border-accent/70 bg-accent/10 text-ink":"border-hairline/50 text-ink-secondary hover:bg-raised"),children:[e.jsx(T,{size:16,className:"shrink-0 text-accent"}),I]});return e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/50 p-5 pt-[14vh] backdrop-blur-sm",onMouseDown:c=>c.target===c.currentTarget&&r(),children:e.jsxs("div",{ref:N,role:"dialog","aria-modal":"true","aria-label":t("automations.newBox.title"),tabIndex:-1,className:"w-full max-w-[560px] rounded-2xl border border-hairline/60 bg-panel p-5 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:j?t("automations.newBox.when"):t("automations.newBox.title")}),e.jsx("button",{type:"button",onClick:r,"aria-label":t("automations.newBox.cancel"),className:"rounded-full p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(be,{size:16})})]}),j?e.jsxs(e.Fragment,{children:[e.jsxs("div",{role:"radiogroup","aria-label":t("automations.newBox.when"),className:"mt-4 space-y-2",children:[B("schedule",t("automations.newBox.onSchedule"),ut),B("app",t("automations.newBox.whenAppEvent"),xt),B("webhook",t("automations.newBox.whenApp"),pt)]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(!1),className:"rounded-lg px-2 py-1.5 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",children:t("automations.newBox.back")}),e.jsx("button",{type:"button",onClick:()=>l(v,w?.id??""),className:"rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110",children:t("automations.newBox.continue")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("textarea",{autoFocus:!0,value:b,onChange:c=>p(c.target.value),rows:3,"aria-label":t("automations.newBox.title"),placeholder:t("automations.newBox.placeholder"),onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!ct(c.nativeEvent)&&(c.preventDefault(),R())},className:"mt-4 w-full resize-none rounded-xl border border-hairline/60 bg-inset px-3.5 py-3 text-[14px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/70"}),o.length===0&&e.jsx("p",{className:"mt-2 text-[13px] text-warning",children:t("automations.newBox.noBots")}),o.length>1&&e.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink-secondary",children:[t("automations.newBox.bot"),e.jsx(re,{size:"sm",value:i,onChange:c=>x(c.target.value),"aria-label":t("automations.newBox.bot"),className:"max-w-[220px]",children:o.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(!0),className:"rounded-lg px-2 py-1.5 text-[13px] text-ink-secondary underline-offset-2 hover:text-ink hover:underline",children:t("automations.newBox.yourself")}),e.jsxs("button",{type:"button",disabled:!b.trim()||!w,onClick:R,className:"flex items-center gap-2 rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-40",children:[e.jsx(jt,{size:14}),t("automations.newBox.send")]})]})]})]})})}const Wt=9;function es({onBack:n,onOpenRoom:r}){const{state:l,dispatch:g}=H(),{capabilities:h}=Le(),o=ye(),b=ge(),p=m.useRef(null),i=l.routinesFocus,x=i?.view==="calendar"?"calendar":"list",[j,f]=m.useState(i?.section!=="logs"?i?.routineId??null:null),[v,y]=m.useState(i?.botId??"all"),[N,w]=m.useState("all"),[R,B]=m.useState(null),[c,I]=m.useState(null),T=window.ogb?.remoteClient?.active===!0,A=l.bots.filter(s=>!s.hidden),Y=we(),M=s=>l.bots.find(d=>d.id===s)?.name??t("routines.unavailableBot");m.useEffect(()=>{y(i?.botId??"all"),i?.routineId&&i.section!=="logs"&&f(i.routineId)},[i]),m.useEffect(()=>{p.current?.focus({preventScroll:!0})},[]);const D=m.useMemo(()=>Ce({routines:l.routines,webhooks:T?[]:l.webhooks,appTriggers:b.triggers,runs:l.routineRuns,bots:l.bots}),[l.routines,l.webhooks,b.triggers,l.routineRuns,l.bots,T]),E=Dt(l.bots,[...new Set([...l.sections??[],...l.bots.flatMap(s=>s.section?[s.section]:[])])]),_=E.names.length+(E.hasGeneral?1:0)>1,z=N==="all"||(N===le?E.hasGeneral:E.names.includes(N))?N:"all";m.useEffect(()=>{z!==N&&(w("all"),y("all"))},[z,N]);const u=s=>te(l.bots.find(d=>d.id===s),z),C=A.filter(s=>te(s,z)),U=D.length>=Wt&&new Set(D.map(s=>s.botId)).size>1,V=mt(D.filter(s=>u(s.botId)&&(!U||v==="all"||s.botId===v))),L=D.find(s=>s.id===j)??null,O=s=>yt(s,M(s.botId)),G=h.windowChrome==="mac-inset",se=G?{WebkitAppRegion:"drag"}:void 0,X=G?{WebkitAppRegion:"no-drag"}:void 0,J=c?.kind==="schedule"?l.routines.find(s=>s.id===c.id):void 0,q=c?.kind==="webhook"?l.webhooks.find(s=>s.id===c.id):void 0,a=c?.kind==="app"?b.triggers.find(s=>s.id===c.id):void 0;return e.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col bg-app animate-workspace-in",children:[e.jsx("header",{className:S("shrink-0 border-b border-hairline/35 bg-app py-3 pr-4",G&&!Oe(h)&&x==="calendar"?"pl-[86px]":x==="list"?"pl-12 md:pl-4":"pl-4"),style:se,children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",ref:p,onClick:n,"aria-label":t("automations.back"),title:t("automations.back"),className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-raised hover:text-ink",style:X,children:e.jsx(ht,{size:18})}),e.jsx("h1",{"data-tour":"automations-page",className:"mr-1 text-[18px] font-semibold tracking-tight text-ink",children:t("automations.title")}),e.jsxs("div",{className:"ml-auto flex items-center gap-3",style:X,children:[_&&e.jsxs(re,{size:"sm","aria-label":t("automations.allDepartments"),value:z,onChange:s=>{w(s.target.value),y("all")},className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allDepartments")}),E.names.map(s=>e.jsx("option",{value:s,children:s},s)),E.hasGeneral&&e.jsx("option",{value:le,children:t("automations.generalDepartment")})]}),U&&x==="list"&&e.jsxs(re,{size:"sm","aria-label":t("automations.allBots"),value:v,onChange:s=>y(s.target.value),className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allBots")}),C.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]}),e.jsx("div",{role:"group","aria-label":t("automations.view"),className:"flex items-center rounded-lg border border-hairline/50 bg-panel p-0.5",children:["list","calendar"].map(s=>e.jsx("button",{type:"button","aria-pressed":x===s,onClick:()=>g({type:"showRoutines",view:s,botId:v==="all"?void 0:v}),className:S("rounded-md px-3 py-1 text-[13px] font-medium",x===s?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s==="list"?t("automations.list"):t("automations.calendar")},s))}),e.jsxs("button",{type:"button",onClick:()=>B(""),className:"flex items-center gap-1.5 rounded-lg bg-accent px-3.5 py-2 text-[13px] font-semibold text-accent-ink hover:brightness-110",children:[e.jsx(ce,{size:15,"aria-hidden":"true"}),t("automations.new")]})]})]})}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[x==="calendar"?e.jsx(Ot,{botFilter:v,department:z,selectedAutomationId:j,onOpenAutomation:f,onOpenRoom:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto w-full max-w-3xl p-4 sm:p-6",children:[e.jsx(Pt,{botFilter:U?v:"all"}),D.length===0&&l.routinesLoadState!=="loading"&&l.hydrated?e.jsxs("section",{"aria-label":t("automations.empty.title"),className:"px-6 py-16 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex size-12 items-center justify-center rounded-2xl bg-accent/10 text-accent",children:e.jsx(bt,{size:22})}),e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:t("automations.empty.title")}),e.jsx("button",{type:"button",onClick:()=>B(t("automations.empty.example")),className:"mt-3 text-[14px] text-accent-text underline-offset-2 hover:underline",children:t("automations.empty.try")}),e.jsx("div",{children:e.jsxs("button",{type:"button",onClick:()=>B(""),className:"mt-6 inline-flex items-center gap-2 rounded-xl bg-accent px-4 py-2.5 text-[13px] font-medium text-accent-ink hover:brightness-110",children:[e.jsx(ce,{size:15}),t("automations.new")]})})]}):e.jsx("ul",{"aria-label":t("automations.title"),className:"divide-y divide-hairline/30 overflow-hidden rounded-2xl border border-hairline/40 bg-card",children:V.map(s=>{const d=de(s),P=s.name.trim(),F=s.runs.find(k=>ee(k)&&!k.seenAt),$=F&&je(F);return e.jsxs("li",{"data-automation":s.id,"data-automation-status":d.state,className:S("flex items-start gap-3 px-4 py-3.5",j===s.id&&"bg-raised/60"),children:[e.jsx(Be,{status:d,className:"mt-[5px]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>f(s.id),className:"block text-left text-[15px] font-medium leading-snug text-ink hover:text-accent-text",children:P||O(s)}),P&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink",children:O(s)}),d.state==="needs-you"?e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2 text-[13px] text-warning",children:[t("automations.needsYou",{reason:d.reason??""}),e.jsx(De,{automation:s,status:d,actions:o,onEdit:()=>I({kind:s.kind,id:s.id})})]}):e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:ft(s)}),$&&e.jsxs("button",{type:"button",onClick:()=>f(s.id),className:"mt-1 flex items-baseline gap-2 text-left text-[13px] text-danger",children:[e.jsx("span",{"aria-hidden":"true",className:"size-2 shrink-0 self-center rounded-full bg-danger"}),e.jsxs("span",{children:[$.when," ",$.mark," ",$.text]})]}),o.error&&o.errorFor?.endsWith(`:${s.id}`)&&e.jsx("p",{role:"alert",className:"mt-1 text-[12px] text-danger",children:o.error})]}),d.state!=="done"&&e.jsx(Se,{checked:s.enabled,disabled:o.busy===`toggle:${s.id}`,"aria-label":t("automations.toggle",{name:s.name}),onClick:()=>{o.toggle(s)},className:"mt-0.5 shrink-0"})]},s.id)})}),o.error&&!V.some(s=>o.errorFor?.endsWith(`:${s.id}`))&&e.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-danger",children:o.error}),e.jsx(Yt,{})]})}),L&&e.jsx("div",{className:"absolute inset-y-0 right-0 z-30 flex shadow-2xl lg:static lg:shadow-none",children:e.jsx(Et,{automation:L,sentence:O(L),onClose:()=>f(null),onDeleted:()=>f(null),onEdit:()=>I({kind:L.kind,id:L.id})},L.id)})]}),R!==null&&e.jsx($t,{initialText:R,onClose:()=>B(null),onSetUpYourself:(s,d)=>{B(null),I({kind:s,botId:d})}}),c?.kind==="schedule"&&(J||!c.id)&&e.jsx(It,{routine:J,bots:ve(A,Y,J?.botId),initialBotId:c.botId,plain:!0,onClose:()=>I(null)}),c?.kind==="webhook"&&(q||!c.id)&&e.jsx(Bt,{webhook:q,bots:A,initialBotId:c.botId,onClose:()=>I(null),onCredential:(s,d)=>{gt(ke(),d,s),f(d)}}),c?.kind==="app"&&(a||!c.id)&&e.jsx(kt,{trigger:a,bots:A,initialBotId:c.botId,onClose:()=>I(null),onSaved:s=>f(s.id)})]})}function Yt(){const n=typeof window<"u"?window.ogb?.routines:void 0,[r,l]=m.useState(null),[g,h]=m.useState(!1);return m.useEffect(()=>{if(!n)return;let o=!1;const b=()=>n.wakeState().then(i=>{o||l(i)}).catch(()=>{});b();const p=window.setInterval(b,3e4);return()=>{o=!0,window.clearInterval(p)}},[n]),!n||!r?null:e.jsxs("div",{className:"mt-6 flex items-center justify-between gap-4 px-1 text-[12px] text-ink-secondary",children:[e.jsxs("span",{children:[t("automations.wake"),r.keepAwake&&r.onBattery?` ${t("automations.wakeBattery")}`:""]}),e.jsx(Se,{checked:r.keepAwake,disabled:g,"aria-label":t("automations.wake"),onClick:()=>{h(!0),n.keepAwake(!r.keepAwake).then(l).catch(()=>{}).finally(()=>h(!1))},className:"shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}export{es as TriggersPage};