limixbot 0.2.13 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActivityPanel-Crvi6UFN.js → ActivityPanel-O6Su2c-u.js} +1 -1
- package/dist/assets/{App-DBQxC6tF.js → App-Bcey1qup.js} +108 -108
- package/dist/assets/{AppEventEditor-BKkrL3lm.js → AppEventEditor-BlJGPJ3Z.js} +1 -1
- package/dist/assets/{BotSettingsDialog-BVTAiGvS.js → BotSettingsDialog-PiCk9us7.js} +4 -4
- package/dist/assets/{BrowserPanel-CXiPysF8.js → BrowserPanel-BWcb5CXi.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-B5ZQeFJ9.js → BrowserProfilesManager-dKHyQotG.js} +1 -1
- package/dist/assets/{CloudAddDialog-CjSOW3Ui.js → CloudAddDialog-D1ZSbkxV.js} +1 -1
- package/dist/assets/{ComputerFilesPane-VwEQWopG.js → ComputerFilesPane-wgtikCgi.js} +1 -1
- package/dist/assets/{ComputerPanel-C4y6Mvwd.js → ComputerPanel-Cyj53a7W.js} +2 -2
- package/dist/assets/{DataPanel-CeaLVEeb.js → DataPanel-BlBidswi.js} +1 -1
- package/dist/assets/{DesktopViewer-CfxFVwdn.js → DesktopViewer-D7JeLJbi.js} +1 -1
- package/dist/assets/{FilesView-B9X_qlkn.js → FilesView-CNkEKeZB.js} +1 -1
- package/dist/assets/{GrokMoveDialog-CuC9v4Fd.js → GrokMoveDialog-fyBulzXL.js} +2 -2
- package/dist/assets/{InspectorPanel-B6ZAVTyD.js → InspectorPanel-Cut2OqiB.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-DkoOxF2t.js → KeyboardShortcutsModal-DnxUB4cd.js} +1 -1
- package/dist/assets/{LiveDesktop-BsPQ6sGB.js → LiveDesktop-CnbyXW61.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-U6rVY7_g.js → LocalVmWorkspace-D9xFPGF0.js} +1 -1
- package/dist/assets/{MacLocalControl-CC-lKazM.js → MacLocalControl-CpswtfCI.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-D0maDIQ1.js → MarkdownFilePreview-V-y-0ksi.js} +1 -1
- package/dist/assets/{MenuMotion-CLF0GByT.js → MenuMotion-VeZ_fZ8M.js} +1 -1
- package/dist/assets/NewBotDialog-rBjsSV0e.js +1 -0
- package/dist/assets/{PhoneAppDialog-CTPZwJnL.js → PhoneAppDialog-DAW1N-hM.js} +1 -1
- package/dist/assets/{PlacesRail-D510vk5R.js → PlacesRail-C_3Mh4C8.js} +1 -1
- package/dist/assets/{PluginsPanel-BC0YDZ8h.js → PluginsPanel-CMsgWSNg.js} +1 -1
- package/dist/assets/{ProIntroduction-BIiaveWm.js → ProIntroduction-6ByF2_US.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-OVWheJHu.js → RemoteAgentSettingsPanel-D4X4rHMQ.js} +1 -1
- package/dist/assets/{RoomPanel-mDRTZ2vs.js → RoomPanel-mg6M04wy.js} +1 -1
- package/dist/assets/{RoutinesPage-9VDuovqw.js → RoutinesPage-DomuZMUT.js} +2 -2
- package/dist/assets/{SettingsModal-BHJvNrwz.js → SettingsModal-Dd9l0b2C.js} +1 -1
- package/dist/assets/{ShareTeamDialog-C4go2USY.js → ShareTeamDialog-B_0Gr8Mq.js} +1 -1
- package/dist/assets/{SignedInSites-Cm_X_p_X.js → SignedInSites-C-eqeBxT.js} +1 -1
- package/dist/assets/TeamLibraryPanel-DpXOFOQr.js +1 -0
- package/dist/assets/{TeamMapPage-CkYOrZ7X.js → TeamMapPage-CIQPYaxL.js} +1 -1
- package/dist/assets/{TriggersPage-_qYPJ97Z.js → TriggersPage-D7RDjrjV.js} +1 -1
- package/dist/assets/{VisibilitySection-CpwyInUL.js → VisibilitySection-Bimhk6c5.js} +1 -1
- package/dist/assets/{WebhookTrigger-CfspvK5m.js → WebhookTrigger-D5c2bPJu.js} +1 -1
- package/dist/assets/{WorksOnGrid-BtfeNPO2.js → WorksOnGrid-PZ-caKHg.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-qTIn3JJ1.js → abnfDiagram-YUKMZFIV-D7az-C1J.js} +1 -1
- package/dist/assets/{activity-CEhxqMcq.js → activity-W_ia4q-Y.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-BQls0L4i.js → architectureDiagram-47P4ROYG-B2IC9169.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-DMD6noIL.js → blockDiagram-E7TT5TSB-FnweBzU4.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-CIp2zuwT.js → c4Diagram-CRA5TL53-rxgwSaAP.js} +1 -1
- package/dist/assets/{calendar-days-Di_J-dvc.js → calendar-days-wM1DS-Cu.js} +1 -1
- package/dist/assets/channel-BQyC_QMX.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-BBkqbpZ4.js → chunk-2Q5K7J3B-B7yhqEe8.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-JdwNE0CO.js → chunk-5VM5RSS4-Sw6phnaf.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-D_Zh7_1M.js → chunk-7TKQ45FW-CheglUSd.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-BvSbOQeA.js → chunk-AW2ZBBNX-CswkqPkf.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-CXYsdaIb.js → chunk-FVRAUYC3-DeN53o4S.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-CO93FKYG.js → chunk-HTAEGDNF-CCZ_Udf0.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-Ko0D98Sv.js → chunk-JWPE2WC7-nG1rfC9P.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-DBGMbUnJ.js → chunk-KQW6MTUR-Bh_TxL0e.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-PVMPph1f.js → chunk-XXDRQBXY-CLIJBS-V.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-Z-SRrzrQ.js → classDiagram-v2-K4WV4PDN-B04FntQx.js} +1 -1
- package/dist/assets/{coins-QIRjm19F.js → coins-81htcDNx.js} +1 -1
- package/dist/assets/{core-Cb-3LQeb.js → core-BLAzrox0.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-DcOhjasx.js → cose-bilkent-JH36ORCC-D9PAieWF.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-D9Pv76Si.js → cynefin-EF2NZ3EQ-BAC2DRg5.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-1Nlm6fT4.js → cynefinDiagram-3GCD6N5R-Cc3k_C-5.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-CW-TdWBz.js → dagre-W4DXFKR2-CpbzxBGo.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-DJYwBSWN.js → diagram-2UJZ2QOL-d22NGVzG.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-ZajDgMU2.js → diagram-OVF4WLC6-BFTJTNpN.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-D03UoQDq.js → diagram-PFPMY2P6-CA_YgAo3.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-B9gI6La0.js → diagram-UMYRVEAY-CCsuWndY.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-Dxzg_fDQ.js → diagram-YEKJPTXX-Bcwhmpgl.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-Cv6eTFZE.js → diagram-ZIFT7M5P-Bs1iIjhq.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-BCUklW6x.js → ebnfDiagram-VR2GEFS7-CFr96fLM.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-VcZs96wT.js → elk-IJKZMXRS-DSdTG_hW.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-CJ61fO-Z.js → erDiagram-O2IAPWRE-BGdMdwi1.js} +1 -1
- package/dist/assets/{file-up-BObBqrEg.js → file-up-DvGMRF5I.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-CQMoLXxB.js → flowDiagram-OXPTDLAJ-DL25A20O.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-ev5i74AH.js → ganttDiagram-R7TSEDQI-DQaNIRGv.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-B8MGdCiz.js → gitGraphDiagram-XJZIOB7I-B6ypA1ZF.js} +1 -1
- package/dist/assets/{import-name-6aD0J6QH.js → import-name-Cdh9ZlkK.js} +1 -1
- package/dist/assets/{index-Dpov1WyC.js → index-BaW02tJl.js} +1 -1
- package/dist/assets/{index-CRF26t5P.js → index-CxcnLo81.js} +1 -1
- package/dist/assets/{index-DgGTgaCO.js → index-oVds-_Vz.js} +2 -2
- package/dist/assets/{infoDiagram-5W2HQ5XZ-CoqaIohe.js → infoDiagram-5W2HQ5XZ-8YbtI4S4.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-BMzA3Pkb.js → ishikawaDiagram-K3B6WC7H-DYpDWk2K.js} +1 -1
- package/dist/assets/{journeyDiagram-COXZFDF6-DLNIN037.js → journeyDiagram-COXZFDF6-BUd8Vnbq.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-savLUzO8.js → kanban-definition-P3RFRI5V-AywqsEBB.js} +1 -1
- package/dist/assets/{mcp-servers-D2hHUxUp.js → mcp-servers-Bu5RuYBT.js} +1 -1
- package/dist/assets/{mermaid.core-1h5EGl1v.js → mermaid.core-B5yiNmEY.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-hMbAYcVv.js → mindmap-definition-LZFPQGKD-DRALSCg6.js} +1 -1
- package/dist/assets/{minimize-63hYzV5y.js → minimize-CWsi9mRL.js} +1 -1
- package/dist/assets/{monitor-DOeLdhQc.js → monitor-c1mf38zt.js} +1 -1
- package/dist/assets/{new-bot-DkcWCdL_.js → new-bot-mp2gi3ed.js} +1 -1
- package/dist/assets/{org-library-C-rnQ1YG.js → org-library-Bi3EieNo.js} +1 -1
- package/dist/assets/{package-format-CMpBgycc.js → package-format-CaPiTXn3.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-BIY55aib.js → pegDiagram-BGZESJAR-Drj_UJz5.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-DR8o8piD.js → pieDiagram-CAPJLFHJ-CL7MryRt.js} +1 -1
- package/dist/assets/{quadrantDiagram-GDMTTRAM-Dqb1703W.js → quadrantDiagram-GDMTTRAM-BvWxqPJn.js} +1 -1
- package/dist/assets/{rail-Ok1gt1lN.js → rail-DApFzTxo.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-ZWJ9xWQY.js → railroadDiagram-SM67HX2B-CGfR0UsO.js} +1 -1
- package/dist/assets/{remote-desktop-panel-ganxVzJo.js → remote-desktop-panel-B4uIIoh3.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-Cjv_VLZj.js → requirementDiagram-X7JNWC4A-CJq96anP.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-ChHoiXzB.js → sankeyDiagram-UM26HJRW-BdZSA65i.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-B67gwOH0.js → sequenceDiagram-ZO4K6R2Y-B5W6udgn.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-DOr4ZALb.js → sizeCapture-INFHLROL-CuKCNVLn.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-DnoBtm-E.js → stateDiagram-v2-TBUQTH76-C7mAgpvB.js} +1 -1
- package/dist/assets/{styles-BcVNrxGE.js → styles-C_rlkDrt.js} +2 -2
- package/dist/assets/styles-bUbK33f1.css +1 -0
- package/dist/assets/{swimlanes-N4OXWK64-2TFXb7MH.js → swimlanes-N4OXWK64-D-mimAU7.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-Dn31PG7h.js +8 -0
- package/dist/assets/{team-share-C9qIusMs.js → team-share-wuAG66b7.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-4zjxAMyG.js → timeline-definition-YOQAKGHF-C5prnOXi.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-CCfZ1eoO.js → usecaseDiagram-VIAY4XPW-BC-9KKSF.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-h7rTFRTN.js → vennDiagram-BLWOH2XV-LCNTQN9e.js} +1 -1
- package/dist/assets/{vi-KgT8L8Qj.js → vi-NX09tr5q.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-CXwA22zv.js → wardleyDiagram-YMQ3BMBF-CtWGEzVU.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-d4qol5BJ.js → xychartDiagram-TAQBALBS-DadPRdBp.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/rail.html +5 -5
- package/dist-server/container-mcp.js +22 -21
- package/dist-server/index.js +106 -105
- package/dist-server/openmausbot.js +24 -24
- package/dist-server/package.json +1 -1
- package/dist-server/pair-cli.js +24 -24
- package/dist-server/server/config.js +6 -1
- package/dist-server/server/container-computer.js +4 -4
- package/dist-server/server/host/team-connections-host.js +2 -2
- package/dist-server/server/index.js +20 -3
- package/dist-server/server/mcp-registry.js +2 -2
- package/dist-server/server/service-unit.js +1 -1
- package/dist-server/server/skill-library.js +1 -1
- package/dist-server/server/team-library.js +2 -2
- package/dist-server/shared/grok-import.js +1 -1
- package/dist-server/shared/package-format.js +3 -3
- package/dist-server/vps-container-mcp.js +22 -21
- package/dist-server/workspace-backup.worker.js +20 -20
- package/package.json +1 -1
- package/dist/assets/NewBotDialog-D9e-ED-j.js +0 -1
- package/dist/assets/TeamLibraryPanel-B-R6YFK-.js +0 -1
- package/dist/assets/channel-DRGNbeY-.js +0 -1
- package/dist/assets/styles-D-yh7Z23.css +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-C_836Lnu.js +0 -8
|
@@ -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-BcVNrxGE.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-D510vk5R.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-DBQxC6tF.js";import{AppEventEditor as kt}from"./AppEventEditor-BKkrL3lm.js";import{C as Ie,S as jt}from"./MenuMotion-CLF0GByT.js";import{C as vt,E as wt,Q as Nt,b as Ct,H as St,R as It}from"./RoutinesPage-9VDuovqw.js";import{WebhookEditor as Bt}from"./WebhookTrigger-CfspvK5m.js";import"./monitor-DOeLdhQc.js";import"./index-DgGTgaCO.js";import"./remote-desktop-DDRRx8uY.js";import"./ProIntroduction-BIiaveWm.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-C_rlkDrt.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_3Mh4C8.js";import{cp as ge,cq as Pe,cr as Fe,cs as oe,Y as $e,u as H,ct as We,cu as Ye,cv as ee,cw as ye,cx as de,cy as _e,cz as ke,cA as He,cB as Ue,cC as Ge,cD as Je,br as qe,cE as Qe,cF as je,cG as ue,cH as Ke,cI as Ve,T as Xe,cJ as Ze,cK as et,cL as Z,cM as ve,cg as we,cN as tt,cO as ne,cP as st,cQ as nt,cR as Ne,n as W,cS as Ce,cT as at,cU as it,cV as ot,cW as xe,cX as rt,cY as lt,cZ as dt,c_ as ct,D as re,w as ut,c$ as xt,bF as pt,d0 as mt,bD as ht,d1 as bt,d2 as ft,S as Se,d3 as gt,d4 as yt}from"./App-Bcey1qup.js";import{AppEventEditor as kt}from"./AppEventEditor-BlJGPJ3Z.js";import{C as Ie,S as jt}from"./MenuMotion-VeZ_fZ8M.js";import{C as vt,E as wt,Q as Nt,b as Ct,H as St,R as It}from"./RoutinesPage-DomuZMUT.js";import{WebhookEditor as Bt}from"./WebhookTrigger-D5c2bPJu.js";import"./monitor-c1mf38zt.js";import"./index-oVds-_Vz.js";import"./remote-desktop-DDRRx8uY.js";import"./ProIntroduction-6ByF2_US.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};
|