limixbot 0.3.11 → 0.3.12

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 (124) hide show
  1. package/dist/assets/{ActivityPanel-BODxWmfO.js → ActivityPanel-CJM61CWQ.js} +1 -1
  2. package/dist/assets/{App-DPG1sq1r.js → App-DRnqqiJP.js} +125 -125
  3. package/dist/assets/{AppEventEditor-QyHQdp7V.js → AppEventEditor-1hupO_kL.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-BCNOcqOS.js → BotSettingsDialog-B56-kmya.js} +4 -4
  5. package/dist/assets/{BrowserPanel-BqPnj2Bz.js → BrowserPanel-BXBygd1y.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-BMk7i2tc.js → BrowserProfilesManager-CzzGhZGz.js} +1 -1
  7. package/dist/assets/CloudAddDialog-MMhMrVK3.js +1 -0
  8. package/dist/assets/{ComputerFilesPane-BWmAv8JT.js → ComputerFilesPane-Hpxjnk2e.js} +1 -1
  9. package/dist/assets/ComputerPanel-CMce64RT.js +2 -0
  10. package/dist/assets/{DataPanel-BgfqxYo9.js → DataPanel-BQ7Ua1Oq.js} +1 -1
  11. package/dist/assets/{DesktopViewer-BMD84CFj.js → DesktopViewer-BRzNtGEm.js} +1 -1
  12. package/dist/assets/{FilesView-CGYpajry.js → FilesView-DQYXl0zm.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-B3aEa4hb.js → GrokMoveDialog-Dk-pwczv.js} +1 -1
  14. package/dist/assets/{InspectorPanel-CTNcZYHr.js → InspectorPanel-CvnM0TFW.js} +1 -1
  15. package/dist/assets/{KeyboardShortcutsModal-CBmbtwhH.js → KeyboardShortcutsModal-BQ8aAw16.js} +1 -1
  16. package/dist/assets/{LiveDesktop-7h7Mxr41.js → LiveDesktop-Cr7uAFoQ.js} +1 -1
  17. package/dist/assets/LocalVmWorkspace-BJ-i68MR.js +1 -0
  18. package/dist/assets/MacLocalControl-DE8MVZkU.js +1 -0
  19. package/dist/assets/{MarkdownFilePreview-_1MC5Db0.js → MarkdownFilePreview-B_6azXNT.js} +1 -1
  20. package/dist/assets/{MenuMotion-C1J3xC0E.js → MenuMotion-BDYr4RxL.js} +1 -1
  21. package/dist/assets/{NewBotDialog-C35vqYL4.js → NewBotDialog-D9fUysLU.js} +1 -1
  22. package/dist/assets/PhoneAppDialog-DUv4Qx8n.js +1 -0
  23. package/dist/assets/{PlacesRail-DnedL3jM.js → PlacesRail-yZdo57pP.js} +1 -1
  24. package/dist/assets/{PluginsPanel-CvZhoTE-.js → PluginsPanel-DYuWdWZd.js} +1 -1
  25. package/dist/assets/{ProIntroduction-B1QqcZmr.js → ProIntroduction-DapZkP7I.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-DU6QyjIY.js → RemoteAgentSettingsPanel-sNv3TbBd.js} +1 -1
  27. package/dist/assets/{RoomPanel-Om9r5yMG.js → RoomPanel-DrlyOJKZ.js} +1 -1
  28. package/dist/assets/{RoutinesPage-BWJ5Z1Sk.js → RoutinesPage-CIo30TVq.js} +2 -2
  29. package/dist/assets/SettingsModal-BpJhi2nc.js +11 -0
  30. package/dist/assets/{ShareTeamDialog-DkKdhm01.js → ShareTeamDialog-CH1ts7Uj.js} +1 -1
  31. package/dist/assets/{SignedInSites-Dxnqcjlx.js → SignedInSites-CisTAQW0.js} +1 -1
  32. package/dist/assets/{TeamLibraryPanel-C3QFOJmQ.js → TeamLibraryPanel-DvnKye05.js} +1 -1
  33. package/dist/assets/TeamMapPage-JOiilgs0.js +1 -0
  34. package/dist/assets/TriggersPage-DQ3HQ6_i.js +1 -0
  35. package/dist/assets/{VisibilitySection-DiD7SczA.js → VisibilitySection-DXfPp0Ql.js} +1 -1
  36. package/dist/assets/{WebhookTrigger-w_Pjci5K.js → WebhookTrigger-BYeOyOpX.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-B84wDbPo.js → WorksOnGrid-8fCnUzpQ.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-Dr-8nZOt.js → abnfDiagram-YUKMZFIV-Boj-Bkbs.js} +1 -1
  39. package/dist/assets/{activity-bTJO9mSI.js → activity-MpAxS_kw.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-23P1y-s5.js → architectureDiagram-47P4ROYG-Cl-ocqce.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-D1mBvWuR.js → blockDiagram-E7TT5TSB-0nSQiv6g.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-BKK5iCAq.js → c4Diagram-CRA5TL53-Cx9iymkb.js} +1 -1
  43. package/dist/assets/{calendar-days-Ckb7s5k5.js → calendar-days-DXHDRm_4.js} +1 -1
  44. package/dist/assets/channel-BStWWrSt.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-C6ElI8Gj.js → chunk-2Q5K7J3B-0rIrumUG.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-B9VKa5BI.js → chunk-5VM5RSS4-w9e6iKvs.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-CrgJv6B8.js → chunk-7TKQ45FW-c4KxVKkf.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-CVe28FV5.js → chunk-AW2ZBBNX-DmaBcuOP.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-BLPrVPPQ.js → chunk-FVRAUYC3-BLzfqLHR.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-BB9kWhE5.js → chunk-HTAEGDNF-BN48XtBm.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-y2b0u5g-.js → chunk-JWPE2WC7-D2NACa6i.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-BMp5NWQw.js → chunk-KQW6MTUR-CbAfnxxG.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-gUdzE10_.js → chunk-XXDRQBXY-Bwg-DPP_.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-DNfrg4LR.js → classDiagram-v2-K4WV4PDN-Dh3ohoZp.js} +1 -1
  55. package/dist/assets/{coins-CBbaS4z-.js → coins-Bv8-qll4.js} +1 -1
  56. package/dist/assets/{core-BNIINisk.js → core-DeJAGBXR.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-D84YhUzh.js → cose-bilkent-JH36ORCC-DCHadn0L.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-DMBZCt-X.js → cynefin-EF2NZ3EQ-ClpPPxUg.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-BZhcnyNF.js → cynefinDiagram-3GCD6N5R-DZ5l7nkL.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-DY68eKcA.js → dagre-W4DXFKR2-BagTvT62.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-Bv-0-qqw.js → diagram-2UJZ2QOL-DuByootb.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-CEnRLa7p.js → diagram-OVF4WLC6-BQ8Cvr0D.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-D3UjLOE9.js → diagram-PFPMY2P6-D_pklaf9.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-CJCYH8n7.js → diagram-UMYRVEAY-1BuHq7tR.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-D_YEp1XW.js → diagram-YEKJPTXX-CK0cPx8n.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-C7RgDQ_I.js → diagram-ZIFT7M5P-DVzPho45.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-CVbikCfA.js → ebnfDiagram-VR2GEFS7-D8UO_5sE.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-BQv73EB6.js → elk-IJKZMXRS-BRigfR5V.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-ZMuLXVBq.js → erDiagram-O2IAPWRE-CXHPobWj.js} +1 -1
  70. package/dist/assets/{file-up-BsMMeeDy.js → file-up-CQezfdJk.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-CkF5DDZj.js → flowDiagram-OXPTDLAJ-CqKD6jh8.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI-BaYEK3at.js → ganttDiagram-R7TSEDQI-C9FV3gsA.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-eVpEz6un.js → gitGraphDiagram-XJZIOB7I-CRu4dnr_.js} +1 -1
  74. package/dist/assets/{import-name-DzZIJafj.js → import-name-dEG0japD.js} +1 -1
  75. package/dist/assets/{index-BSIcl6wl.js → index-B4HW_T-k.js} +1 -1
  76. package/dist/assets/{index-BkcZ5EE3.js → index-COnd2OMZ.js} +2 -2
  77. package/dist/assets/{infoDiagram-5W2HQ5XZ-cLDLLbyG.js → infoDiagram-5W2HQ5XZ-CCRjb2CQ.js} +1 -1
  78. package/dist/assets/{ishikawaDiagram-K3B6WC7H-Dxie_tdO.js → ishikawaDiagram-K3B6WC7H-TaNPsGZS.js} +1 -1
  79. package/dist/assets/{journeyDiagram-COXZFDF6-DWzHn4oz.js → journeyDiagram-COXZFDF6-Dz7YIIc2.js} +1 -1
  80. package/dist/assets/{kanban-definition-P3RFRI5V-BFNqkDTK.js → kanban-definition-P3RFRI5V-Cg69Fpp8.js} +1 -1
  81. package/dist/assets/{mcp-servers-DJceaBjT.js → mcp-servers-Ih6dI7Ga.js} +1 -1
  82. package/dist/assets/{mermaid.core-Cn7buzY3.js → mermaid.core-DiG3LoLz.js} +4 -4
  83. package/dist/assets/{mindmap-definition-LZFPQGKD-DVS-3JPN.js → mindmap-definition-LZFPQGKD-nxP4f0fq.js} +1 -1
  84. package/dist/assets/{minimize-BpyGl78C.js → minimize-B_k_fmmo.js} +1 -1
  85. package/dist/assets/{monitor-FKQbSjca.js → monitor-BfmnPU-I.js} +1 -1
  86. package/dist/assets/{new-bot-Df7cGS3Z.js → new-bot-CQm0FPc5.js} +2 -2
  87. package/dist/assets/{org-library-CT3HZbof.js → org-library-C2li0IRL.js} +1 -1
  88. package/dist/assets/{package-format-CgnYlqV5.js → package-format-B3whu9DW.js} +1 -1
  89. package/dist/assets/{pegDiagram-BGZESJAR-qwRUMAPC.js → pegDiagram-BGZESJAR-gPjpGcNH.js} +1 -1
  90. package/dist/assets/{pieDiagram-CAPJLFHJ-CTzsGZac.js → pieDiagram-CAPJLFHJ-Cgh25Z4_.js} +1 -1
  91. package/dist/assets/{quadrantDiagram-GDMTTRAM-B7Mx793h.js → quadrantDiagram-GDMTTRAM-DD9luyqA.js} +1 -1
  92. package/dist/assets/{rail-B_BFwBxk.js → rail-B1mj4zlo.js} +1 -1
  93. package/dist/assets/{railroadDiagram-SM67HX2B-zMy3LSMK.js → railroadDiagram-SM67HX2B-CS_TYko7.js} +1 -1
  94. package/dist/assets/{remote-desktop-panel-DPutXzoI.js → remote-desktop-panel-DIllbP7i.js} +1 -1
  95. package/dist/assets/{requirementDiagram-X7JNWC4A-Dm_K18IR.js → requirementDiagram-X7JNWC4A-BePHia6E.js} +1 -1
  96. package/dist/assets/{sankeyDiagram-UM26HJRW-Dx_FP9cL.js → sankeyDiagram-UM26HJRW-24ExCXGS.js} +1 -1
  97. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-D3tIz4Te.js → sequenceDiagram-ZO4K6R2Y-Dtmx27I5.js} +1 -1
  98. package/dist/assets/{sizeCapture-INFHLROL-CwiX8-_Z.js → sizeCapture-INFHLROL-2LvmoT1T.js} +1 -1
  99. package/dist/assets/{stateDiagram-v2-TBUQTH76-Biv0Rjec.js → stateDiagram-v2-TBUQTH76-moL2SIo9.js} +1 -1
  100. package/dist/assets/{styles-Cm26P6hN.js → styles-6RbfQIY7.js} +1 -1
  101. package/dist/assets/{swimlanes-N4OXWK64-Daie2jEh.js → swimlanes-N4OXWK64-D95Pk8qh.js} +1 -1
  102. package/dist/assets/swimlanesDiagram-K3J5GTZL-DByi9G3i.js +8 -0
  103. package/dist/assets/{team-share-DyK3j6N2.js → team-share-0GXKeixY.js} +1 -1
  104. package/dist/assets/{timeline-definition-YOQAKGHF-_OnzqB6-.js → timeline-definition-YOQAKGHF-HM-J25k2.js} +1 -1
  105. package/dist/assets/{usecaseDiagram-VIAY4XPW-CITmAUqx.js → usecaseDiagram-VIAY4XPW-C6q6bCzJ.js} +1 -1
  106. package/dist/assets/{vennDiagram-BLWOH2XV-BAx_UxlU.js → vennDiagram-BLWOH2XV-hf0dh2yT.js} +1 -1
  107. package/dist/assets/{vi-GKa1-xWX.js → vi-CVDyZGky.js} +1 -1
  108. package/dist/assets/{wardleyDiagram-YMQ3BMBF-DjWzxLzl.js → wardleyDiagram-YMQ3BMBF-CpT_eRn9.js} +1 -1
  109. package/dist/assets/{xychartDiagram-TAQBALBS-DpQbiSMS.js → xychartDiagram-TAQBALBS-D6g1V9DG.js} +1 -1
  110. package/dist/index.html +2 -2
  111. package/dist/rail.html +4 -4
  112. package/dist-server/package.json +1 -1
  113. package/package.json +1 -1
  114. package/dist/assets/CloudAddDialog-S7ngrMRc.js +0 -1
  115. package/dist/assets/ComputerPanel-BDPrbwmC.js +0 -2
  116. package/dist/assets/LocalVmWorkspace-Bxvn8CQX.js +0 -1
  117. package/dist/assets/MacLocalControl-C3rHusSl.js +0 -1
  118. package/dist/assets/PhoneAppDialog-DhEEfxbl.js +0 -1
  119. package/dist/assets/SettingsModal-DmFTwQIH.js +0 -11
  120. package/dist/assets/TeamMapPage-CpPh11mE.js +0 -1
  121. package/dist/assets/TriggersPage-YjklCz2p.js +0 -1
  122. package/dist/assets/channel-_uzpXF9W.js +0 -1
  123. package/dist/assets/index-DvRd5uj9.js +0 -1
  124. package/dist/assets/swimlanesDiagram-K3J5GTZL-EP8Nb7CO.js +0 -8
@@ -1 +0,0 @@
1
- import{c as We,t as s,r as a,j as e,a as ne,z as Qe,X as Be,f as kt,i as Ee,a9 as jt}from"./styles-Cm26P6hN.js";import{L as Re,X as wt,B as Ze,E as Ct,P as Ke,r as et,z as Nt,u as St}from"./PlacesRail-DnedL3jM.js";import{n as te,l as It,$ as Mt,u as Ne,aP as dt,bx as ut,dh as mt,cL as Tt,T as pt,di as ft,dj as Et,dk as At,dl as Rt,dm as Ot,cj as xt,bv as Bt,ah as Ye,b4 as tt,dn as zt,dp as Dt,dq as Lt,D as ht,Z as $e,a2 as Je,dr as Pt,C as Ve,ds as $t,dt as _t,e as Ht,du as Kt,dv as Ut,dw as qt,dx as Ft,d1 as Xt,dy as Yt,dz as Jt,bO as Vt,dA as Gt,cM as Wt,dB as Qt,a3 as Zt,dC as en,dD as tn,dE as nn}from"./App-DPG1sq1r.js";import{M as Oe}from"./monitor-FKQbSjca.js";import{R as sn,a as an}from"./MenuMotion-C1J3xC0E.js";import"./index-BkcZ5EE3.js";const rn=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],on=We("message-circle",rn);const ln=[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],cn=We("monitor-off",ln);const dn=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],un=We("save",dn),mn={collaborations:[],queued:[],running:[]};function pn(n,r=[]){const l=new Map;for(const d of n){if(d.hidden)continue;const i=d.section?.trim()||"";l.set(i,[...l.get(i)??[],d])}for(const d of r){const i=d.trim();i&&!l.has(i)&&l.set(i,[])}return[...l].map(([d,i])=>({key:d,name:d||s("teamSettings.general"),chiefs:i.filter(c=>c.chiefOfStaff),members:i.filter(c=>!c.chiefOfStaff)}))}function fn(n,r){const l=new Set(n.filter(c=>!c.hidden).map(c=>c.id)),d=new Map,i=(c,I)=>[c,I].sort().join(":");for(const c of r.collaborations){const[I,g]=c.botIds;!l.has(I)||!l.has(g)||d.set(i(I,g),{sourceBotId:I,targetBotId:g,state:"connected",groupId:c.groupId,lastAt:c.lastAt})}for(const c of r.queued)!l.has(c.sourceBotId)||!l.has(c.targetBotId)||d.set(i(c.sourceBotId,c.targetBotId),{sourceBotId:c.sourceBotId,targetBotId:c.targetBotId,state:"queued",reason:c.reason,groupId:c.groupId,threadId:c.threadId});for(const c of r.running)!l.has(c.sourceBotId)||!l.has(c.targetBotId)||d.set(i(c.sourceBotId,c.targetBotId),{sourceBotId:c.sourceBotId,targetBotId:c.targetBotId,state:"running",groupId:c.groupId,threadId:c.threadId});return[...d.values()].sort((c,I)=>{const g={running:0,queued:1,connected:2};return g[c.state]-g[I.state]||(I.lastAt??0)-(c.lastAt??0)})}function xn(n){return n.activity==="waiting-on-you"?{label:s("canvas.status.waiting"),tone:"warning"}:n.activity==="dead"||n.activity==="no-signal"?{label:s("canvas.status.noSignal"),tone:"danger"}:n.busy||n.activity==="working"?{label:s("canvas.status.working"),tone:"success"}:{label:s("canvas.status.ready"),tone:"idle"}}function hn(n){return n===1?s("canvas.botCountOne"):s("canvas.botCount",{count:n})}const _e=236,Me=126,He=16,we=20,Te=64,qe="application/x-omb-computer";function ke(n,r=[]){const l=new Map(r.map((d,i)=>[d,i]));return[...n].sort((d,i)=>(l.get(d.id)??1/0)-(l.get(i.id)??1/0))}function gn(n,r,l){const d=n.map(c=>c.id);if(!d.includes(r))return d;const i=d.filter(c=>c!==r);return i.splice(Math.max(0,Math.min(i.length,l)),0,r),i}function bn(n){try{const r=JSON.parse(n??"null");return r===null||typeof r!="object"||Array.isArray(r)?{}:Object.fromEntries(Object.entries(r).flatMap(([l,d])=>Array.isArray(d)?[[l,[...new Set(d.filter(i=>typeof i=="string"&&i.length>0))]]]:[]))}catch{return{}}}function gt(n){const r=n.chiefs.length>0&&n.members.length>0,l=r?Math.max(n.chiefs.length,n.members.length):Math.max(1,n.chiefs.length+n.members.length);return{width:_e*(r?2:1)+we*2+(r?40:0),height:Te+we+l*(Me+He)-He}}function yn(n,r,l={}){const d=l.sizes??n.map(gt),i=Math.max(1,Math.floor(l.columns??2)),c=[40];for(let g=1;g<i;g++){const x=Math.max(0,...d.filter((M,h)=>h%i===g-1).map(M=>M.width));c.push(c[g-1]+x+56)}let I=40;return n.map((g,x)=>{x>0&&x%i===0&&(I+=Math.max(...d.slice(x-i,x).map(h=>h.height))+56);const M=Object.hasOwn(r,g.key)?r[g.key]:void 0;return{key:g.key,x:M?.x??c[x%i],y:M?.y??I,...d[x]}})}function vn(n,r,l){if(!n.length)return{x:0,y:0,scale:1};const d=Math.min(...n.map(x=>x.x)),i=Math.min(...n.map(x=>x.y)),c=Math.max(...n.map(x=>x.x+x.width))-d,I=Math.max(...n.map(x=>x.y+x.height))-i,g=Math.max(.3,Math.min(1,(r-80)/c,(l-80)/I));return{x:(r-c*g)/2-d*g,y:(l-I*g)/2-i*g,scale:g}}function at(n,r,l){const d=r/n.scale;return{x:l.x-(l.x-n.x)*d,y:l.y-(l.y-n.y)*d,scale:r}}function kn(n){try{const r=JSON.parse(n??"null");return r===null||typeof r!="object"||Array.isArray(r)?{}:Object.fromEntries(Object.entries(r).flatMap(([l,d])=>{if(d===null||typeof d!="object"||Array.isArray(d))return[];const{x:i,y:c}=d;return typeof i=="number"&&Number.isFinite(i)&&Math.abs(i)<1e5&&typeof c=="number"&&Number.isFinite(c)&&Math.abs(c)<1e5?[[l,{x:i,y:c}]]:[]}))}catch{return{}}}const Ge=272,je=208,Fe=44,Xe=28;function jn(n,r){const l=[...n.chiefs,...n.members],d=l.filter(v=>r.own.has(v.id));if(!d.length&&!r.team)return null;const i=n.chiefs.length>0&&n.members.length>0,c=d.length?je:Me,I=v=>Te+v*(c+He),g=v=>I(v)+c/2,x=we+(i?Xe:0)+_e,M=x+Fe,h=l.map((v,y)=>({botId:v.id,x:we+(i&&y>=n.chiefs.length?Xe:0),y:I(y)+(c-Me)/2})),w=[],b=[];l.forEach((v,y)=>{const j=r.own.get(v.id);j&&(w.push({id:j,x:M,y:I(y)+(c-je)/2}),b.push({botId:v.id,computerId:j,points:[{x:h[y].x+_e,y:g(y)},{x:M,y:g(y)}]}))});const O=I(l.length)-He;let U=Math.max(O,Te+Me),A=d.length?M+Ge:x;if(r.team){const v=l.map((H,G)=>({bot:H,index:G})).filter(({bot:H})=>r.team.botIds.includes(H.id)),y=(v.length?v:l.map((H,G)=>({bot:H,index:G}))).map(({index:H})=>g(H)),j=y.length?(Math.min(...y)+Math.max(...y))/2:Te+je/2,B=A+Fe*(d.length?1.5:2),L=Math.max(Te,j-je/2),Y=B-Fe/2,_=L+je/2;w.push({id:r.team.id,x:B,y:L});for(const{bot:H,index:G}of v){const R={x:h[G].x+_e,y:g(G)};b.push({botId:H.id,computerId:r.team.id,points:[R,{x:Y,y:R.y},{x:Y,y:_},{x:B,y:_}]})}A=B+Ge,U=Math.max(U,L+je)}const K=[];if(i){const v=we+Xe/2,y=n.chiefs.length;K.push([{x:v,y:h[y-1].y+Me},{x:v,y:g(l.length-1)}]);for(let j=y;j<l.length;j++)K.push([{x:v,y:g(j)},{x:h[j].x,y:g(j)}])}return{width:A+we,height:U+we,cards:h,monitors:w,links:b,tree:K}}function wn(n,r,l=56){if(n.length<2||r.width<=0||r.height<=0)return 2;let d={columns:2,scale:0};for(let i=1;i<=Math.min(n.length,6);i++){const c=Array.from({length:i},(w,b)=>Math.max(0,...n.filter((O,U)=>U%i===b).map(O=>O.width))),I=Math.ceil(n.length/i),g=Array.from({length:I},(w,b)=>Math.max(0,...n.slice(b*i,b*i+i).map(O=>O.height))),x=c.reduce((w,b)=>w+b,0)+l*(i-1),M=g.reduce((w,b)=>w+b,0)+l*(I-1),h=Math.min((r.width-80)/x,(r.height-80)/M);h>d.scale+.01&&(d={columns:i,scale:h})}return d.columns}function rt(n){return n.map((r,l)=>`${l?"L":"M"}${r.x} ${r.y}`).join(" ")}const Cn=2e3;function Nn(n,r){return n.find(l=>l.kind==="bot"&&l.id===r)??n.find(l=>l.kind==="team"&&l.botIds.includes(r))}function Sn(n,r,l){const d=new Set(r),i=l.find(c=>c.kind==="team"&&c.section===n);return{own:new Map(l.filter(c=>c.kind==="bot"&&d.has(c.id)).map(c=>[c.id,c.id])),...i?{team:{id:i.id,botIds:i.botIds.filter(c=>d.has(c))}}:{}}}function In(n){return Object.entries(n).map(([r,l])=>`${r}:${l.version}`).join(",")}function Mn(n,r,l){return l-Math.max(0,r-n)}function Tn(n,r){const l=atob(n),d=new Uint8Array(l.length);for(let i=0;i<l.length;i++)d[i]=l.charCodeAt(i);return new Blob([d],{type:r})}function En(n){const[r,l]=a.useState(null),[d,i]=a.useState({}),[c,I]=a.useState(null),g=a.useRef(d);g.current=d;const x=a.useRef([]);x.current=r?.computers??[];const M=a.useRef(new Set),h=a.useRef(!0),w=a.useCallback(async(b,O,U,A,K)=>{if((g.current[b]?.at??-1/0)>=A)return;let v;try{v=URL.createObjectURL(Tn(O,U))}catch{return}try{const j=new Image;j.src=v,await j.decode()}catch{URL.revokeObjectURL(v);return}if(!h.current||(g.current[b]?.at??-1/0)>=A){URL.revokeObjectURL(v);return}const y=g.current[b]?.url;g.current={...g.current,[b]:{url:v,at:A,version:K}},i(g.current),y&&(M.current.add(y),window.setTimeout(()=>{URL.revokeObjectURL(y),M.current.delete(y)},2e3))},[]);return a.useEffect(()=>(h.current=!0,()=>{h.current=!1;for(const b of Object.values(g.current))URL.revokeObjectURL(b.url);for(const b of M.current)URL.revokeObjectURL(b)}),[]),a.useEffect(()=>{if(!n)return;let b=!1,O=!1;const U=async()=>{if(!(b||O||document.visibilityState!=="visible")){O=!0;try{const v=In(g.current),y=await te(`/api/computers/frames${v?`?have=${encodeURIComponent(v)}`:""}`,{signal:AbortSignal.timeout(3e4)});if(b)return;const j=Date.now();l(y),I(null);for(const B of y.computers){const L=B.frame;L?.data&&w(B.id,L.data,L.mime,Mn(L.at,y.now,j),L.version)}}catch(v){b||I(v instanceof Error?v.message:String(v))}finally{O=!1}}};U();const A=window.setInterval(U,Cn),K=It({screens:!0,onFrame:v=>{if(v.kind!=="screen"||v.surface!=="computer"||!v.png)return;const y=Nn(x.current,v.botId);y&&w(y.id,v.png,v.mime??"image/png",Date.now(),"live")}});return()=>{b=!0,window.clearInterval(A),K()}},[n,w]),{computers:r?.computers??[],configured:r?.configured??null,frames:d,error:c}}function An(n){const[r,l]=a.useState(null),[d,i]=a.useState(null),[c,I]=a.useState(!1);a.useEffect(()=>{let x=!0;return te("/.well-known/openmausbot/environment",{signal:AbortSignal.timeout(5e3)}).then(M=>{if(!x||typeof M.environmentId!="string")return;const h=`omb-team-canvas:${M.environmentId}:computers`;l(h);try{const w=localStorage.getItem(h);(w==="on"||w==="off")&&i(w==="on")}catch{}}).catch(()=>{}).finally(()=>{x&&I(!0)}),()=>{x=!1}},[]);const g=a.useCallback(x=>{if(i(x),!!r)try{localStorage.setItem(r,x?"on":"off")}catch{}},[r]);return{show:d??n,loaded:c,choose:g}}const ot=28;function Rn(n){if(n&&typeof n=="object"&&!Array.isArray(n))return n;if(typeof n!="string")return{};try{const r=JSON.parse(n);return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch{return{}}}function On(n){const r=/(?:^|__)computer__(\w+)$/.exec(n.name)?.[1]??null;if(!r)return null;const l=Rn(n.input);if(r==="open_url")try{return s("mapComputer.step.open",{site:new URL(String(l.url)).hostname.replace(/^www\./,"")})}catch{return s("mapComputer.step.openPage")}if(r==="type_text"&&typeof l.text=="string"&&l.text.trim()){const d=l.text.replace(/\s+/g," ").trim();return s("mapComputer.step.type",{text:d.length>ot?`${d.slice(0,ot)}…`:d})}if(r==="key_press"){const d=[l.keys,l.key,l.combo].find(c=>typeof c=="string"||Array.isArray(c)),i=Array.isArray(d)?d.join("+"):typeof d=="string"?d:"";return i?s("mapComputer.step.key",{keys:i.slice(0,24)}):s("mapComputer.step.keyAny")}return r==="click"||r==="double_click"||r==="right_click"?s("mapComputer.step.click"):r==="scroll"?s("mapComputer.step.scroll"):r==="screenshot"?s("mapComputer.step.look"):r==="drag"?s("mapComputer.step.drag"):null}const it={starting:"mapComputer.state.starting",working:"mapComputer.state.working",idle:"mapComputer.state.idle",asleep:"mapComputer.state.asleep",off:"mapComputer.state.off",problem:"mapComputer.state.problem"},Bn={starting:"bg-warning",working:"bg-success",idle:"bg-sky-400",asleep:"bg-white/35",off:"bg-white/25",problem:"bg-danger"},zn=a.memo(function({computer:r,bots:l,frameUrl:d,state:i,activity:c,x:I,y:g,onOpen:x}){const M=i==="working",h=r.kind==="team"?r.name:s("mapComputer.botComputer",{name:r.name});return e.jsxs("div",{"data-computer-node":r.id,className:"absolute",style:{left:I,top:g,width:Ge,height:je},children:[M&&e.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute -inset-[5px] animate-computer-glow rounded-[22px] border-2 border-success/70 shadow-[0_0_24px_rgba(52,199,89,0.35)]"}),e.jsxs("button",{type:"button",onClick:x,disabled:!x,title:c?`${h} · ${c}`:h,"aria-label":s("mapComputer.open",{name:h,state:s(it[i])}),className:"relative flex size-full flex-col rounded-[18px] border border-white/10 bg-[#0f1117] p-2 text-left shadow-[0_10px_30px_rgba(0,0,0,0.35)] outline-none transition-transform hover:-translate-y-0.5 focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-default",children:[e.jsxs("span",{className:"relative block h-[160px] w-full overflow-hidden rounded-[8px] bg-[#06070b] [contain:paint]",children:[d?e.jsx("img",{src:d,alt:"",draggable:!1,decoding:"async",className:ne("size-full object-cover",i==="asleep"||i==="off"?"opacity-40 grayscale":"")}):e.jsxs("span",{className:"flex size-full flex-col items-center justify-center gap-2 bg-[radial-gradient(circle_at_50%_40%,#1b2030,#06070b_70%)] text-[11px] text-white/45",children:[i==="starting"?e.jsx(Re,{size:20,className:"animate-spin"}):i==="asleep"?e.jsx(wt,{size:20}):i==="problem"?e.jsx(Mt,{size:20}):e.jsx(cn,{size:20}),s(i==="starting"?"mapComputer.empty.starting":i==="asleep"?"mapComputer.empty.asleep":i==="problem"?"mapComputer.empty.problem":i==="off"?"mapComputer.empty.off":"mapComputer.empty.waiting")]}),e.jsxs("span",{className:"absolute left-2 top-2 flex items-center gap-1.5 rounded-full bg-black/65 px-2 py-0.5 text-[10px] font-medium text-white/90 backdrop-blur-[2px]",children:[e.jsx("span",{className:ne("size-1.5 rounded-full",Bn[i],M&&"animate-pulse")}),s(it[i])]}),c&&M&&e.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-gradient-to-t from-black/85 via-black/55 to-transparent px-2.5 pb-1.5 pt-6 text-[11px] leading-tight text-white/90",children:c})]}),e.jsxs("span",{className:"flex h-[32px] min-w-0 items-center gap-2 px-1 pt-1.5",children:[e.jsx("span",{className:"flex shrink-0 -space-x-1.5",children:l.slice(0,3).map(w=>e.jsx("span",{className:"rounded-full ring-2 ring-[#0f1117]",children:e.jsx(Ze,{bot:w,size:20,animated:!1,motion:"none",motionKey:0})},w.id))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium text-white/90",children:h}),l.length>3&&e.jsxs("span",{className:"shrink-0 text-[10px] text-white/50",children:["+",l.length-3]})]})]})]})}),Ae="flex size-9 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-ink focus-visible:outline-2 focus-visible:outline-accent",Ie="flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-left text-[12px] text-ink-secondary hover:bg-control hover:text-ink";function Dn({bot:n,selected:r,moving:l,connected:d,tagged:i=!1,sent:c,onComputer:I,onArrange:g}){const{state:x,dispatch:M}=Ne(),h=Qe(),w=xn(n),b=Ot(n,xt()),O=x.instances.find(A=>A.instanceId===n.modelSelection.instanceId),U=O?.models.options.find(A=>A.id===n.modelSelection.model)?.label??n.modelSelection.model;return e.jsxs("article",{className:ne("relative h-[126px] w-[236px] shrink-0 rounded-xl border bg-card shadow-sm transition-colors",r?"border-accent/60 ring-1 ring-accent/15":d?"border-accent/40":"border-hairline/50 hover:border-ink-secondary/40",i&&"border-accent ring-4 ring-accent/25",l&&"opacity-35"),children:[c!==void 0&&e.jsx("span",{"data-sent-highlight":!0,"aria-hidden":!0,className:"pointer-events-none absolute -inset-px animate-sent-border rounded-xl border-2 border-accent"},c),e.jsxs("button",{"data-bot-id":n.id,"aria-label":s("canvas.editBot",{name:b}),onClick:()=>Ye(M,"identity",{botId:n.id}),title:g?s("canvas.reorderHint"):void 0,onKeyDown:A=>{!g||!A.altKey||A.key!=="ArrowUp"&&A.key!=="ArrowDown"||(A.preventDefault(),A.stopPropagation(),g(n,A.key==="ArrowUp"?-1:1))},className:"flex h-[82px] w-full cursor-grab items-center gap-3 rounded-t-xl px-4 text-left active:cursor-grabbing focus-visible:outline-2 focus-visible:outline-accent",children:[e.jsx(Ze,{bot:n,size:38,motion:"none",motionKey:0,animated:!1}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[14px] font-semibold",children:b}),n.chiefOfStaff&&e.jsx(Bt,{size:12,className:"shrink-0 text-warning","aria-label":s("chat.chiefOfStaff")})]}),e.jsx("span",{className:"mt-1 block truncate text-[11px] text-ink-secondary",children:n.title||(n.chiefOfStaff?s("chat.chiefOfStaff"):s("canvas.bot"))})]})]}),e.jsxs("div",{className:"flex h-[43px] items-center gap-1 border-t border-hairline/30 px-2",children:[e.jsx("button",{className:ne(Ae,"size-8"),"aria-label":s("canvas.openBotChat",{name:n.name}),title:s("canvas.openChat"),onClick:()=>tt(M,n,h),children:e.jsx(on,{size:13})}),w.tone!=="idle"&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-ink-secondary",title:w.label,children:[e.jsx("span",{className:ne("size-1.5 rounded-full",w.tone==="success"?"bg-success":w.tone==="warning"?"bg-warning":w.tone==="danger"?"bg-danger":"bg-ink-secondary/35")}),w.label]}),r&&I&&e.jsx("button",{className:ne(Ae,"size-8"),"aria-label":s("canvas.botComputer",{name:n.name}),title:s("computer.tab.computer"),onClick:()=>I(n),children:e.jsx(Oe,{size:13})}),e.jsxs("button",{"aria-label":s("canvas.changeModel",{name:n.name}),title:`${s("canvas.defaultModel")}: ${U}`,onClick:()=>Ye(M,"model",{botId:n.id}),className:"ml-auto flex h-8 min-w-0 max-w-[130px] items-center gap-1.5 rounded-md px-2 text-[10px] text-ink-secondary hover:bg-control hover:text-ink focus-visible:outline-2 focus-visible:outline-accent",children:[e.jsx("span",{className:"flex size-3.5 shrink-0 items-center justify-center",children:O?e.jsx(zt,{instance:O,size:13}):e.jsx(Dt,{driverKind:"",size:13})}),e.jsx("span",{className:"truncate",children:U||s("canvas.defaultModel")})]})]})]})}const Ln=[];function Pn(n,r){if(!n?.busy)return;const l=n.tasks?.find(i=>i.threadId===n.threadId),d=!l||l.busy?n.messages.findLast(i=>i.kind==="activity"&&i.tool):void 0;return d?.tool?On(d.tool)??At(d.tool,Rt(n,r),d.dataResult):n.tasks?.find(i=>i.busy&&i.threadId!==n.threadId&&i.title.trim())?.title}function $n({sections:n,canManage:r,onMove:l,onInstructions:d,onMemory:i,onEditTeam:c,onDeleteTeam:I,onComputer:g,onComputerDrop:x,onTeamComputer:M,teamComputers:h={},connectedBotIds:w=[],computers:b=Ln,computerFrames:O={},onOpenComputer:U,taggedBotIds:A=[],sent:K,bottomInset:v=0}){const{state:y}=Ne(),j=a.useRef(null),B=a.useRef(null),L=a.useRef(!1),Y=a.useRef(!1),_=a.useRef(null),[H,G]=a.useState({}),[R,q]=a.useState({}),[m,z]=a.useState({x:40,y:40,scale:1}),[N,$]=a.useState(null),[T,P]=a.useState(null),[se,S]=a.useState(null),[F,ee]=a.useState(null),[ie,re]=a.useState(null),[ue,de]=a.useState(""),[fe,me]=a.useState(!1),[he,ge]=a.useState(null),[ve,Se]=a.useState({width:0,height:0}),oe=a.useMemo(()=>n.map(t=>{if(!b.length)return null;const p=Object.hasOwn(R,t.key)?R[t.key]:[],u=ke(t.chiefs,p),C=ke(t.members,p);return jn({chiefs:u,members:C},Sn(t.key,[...u,...C].map(E=>E.id),b))}),[n,b,R]),pe=a.useMemo(()=>{if(!oe.some(Boolean))return;const t=oe.map((p,u)=>p??gt(n[u]));return{sizes:t,columns:wn(t,{width:Math.round(ve.width/200)*200,height:Math.round(ve.height/200)*200})}},[oe,n,ve]),be=a.useMemo(()=>yn(n,H,pe),[n,H,pe]),ce=a.useRef({view:m,positions:H,tiles:be,selectedId:y.selectedId,settingsOpen:y.settingsOpen,bottomInset:v});ce.current={view:m,positions:H,tiles:be,selectedId:y.selectedId,settingsOpen:y.settingsOpen,bottomInset:v},a.useEffect(()=>{let t=!0;return te("/.well-known/openmausbot/environment",{signal:AbortSignal.timeout(5e3)}).then(p=>{if(!(!t||typeof p.environmentId!="string")){_.current=`omb-team-canvas:${p.environmentId}`;try{const u=kn(localStorage.getItem(_.current));G(C=>({...u,...C})),q(bn(localStorage.getItem(`${_.current}:bot-order`)))}catch{}}}).catch(()=>{}).finally(()=>{t&&me(!0)}),()=>{t=!1}},[]);const f=t=>{if(G(t),!!_.current)try{localStorage.setItem(_.current,JSON.stringify(Object.fromEntries(n.filter(p=>Object.hasOwn(t,p.key)).map(p=>[p.key,t[p.key]]))))}catch{}},o=t=>Object.hasOwn(R,t)?R[t]:[],k=(t,p,u,C)=>{const E={...R,[t.key]:[...gn(p,u.id,C),...ke(u.chiefOfStaff?t.members:t.chiefs,o(t.key)).map(Q=>Q.id)]};if(q(E),_.current)try{localStorage.setItem(`${_.current}:bot-order`,JSON.stringify(E))}catch{}de(s("canvas.arrangedBot",{name:u.name,team:t.name}))},J=(t,p)=>{const u=n.find(E=>E.key===(t.section?.trim()??""));if(!u)return;const C=ke(t.chiefOfStaff?u.chiefs:u.members,o(u.key));k(u,C,t,C.findIndex(E=>E.id===t.id)+p)},Z=a.useCallback(()=>{const t=j.current?.getBoundingClientRect();t&&z(vn(ce.current.tiles,t.width,Math.max(200,t.height-ce.current.bottomInset)))},[]);a.useEffect(()=>{const t=j.current;if(!t)return;let p=null;const u=new ResizeObserver(()=>{const C=t.getBoundingClientRect();if(Se({width:C.width,height:C.height}),!p)Z();else{const E=ce.current.settingsOpen?[...t.querySelectorAll("[data-bot-id]")].find(V=>V.dataset.botId===ce.current.selectedId)?.getBoundingClientRect():void 0,Q=E?C.width/2-(E.left-C.left+E.width/2):(C.width-p.width)/2,ae=E?C.height/2-(E.top-C.top+E.height/2):(C.height-p.height)/2;z(V=>({...V,x:V.x+Q,y:V.y+ae}))}p={width:C.width,height:C.height}});return u.observe(t),()=>u.disconnect()},[Z]);const le=JSON.stringify(be.map(({key:t,width:p,height:u})=>[t,p,u]));a.useEffect(()=>{Z()},[Z,le,fe]),a.useEffect(()=>{const t=j.current?.querySelector("details[open]"),p=j.current?.getBoundingClientRect();t&&p&&ge(t.getBoundingClientRect().bottom>p.bottom-210*m.scale?t.closest("[data-team-key]")?.dataset.teamKey??null:null)},[m,le]),a.useEffect(()=>{const t=j.current;if(!t)return;const p=u=>{if(u.target.closest("details[open]")||(u.preventDefault(),B.current))return;const C=ce.current.view,E=t.getBoundingClientRect();if(u.ctrlKey||u.metaKey){const Q=Math.min(1.5,Math.max(.3,C.scale*Math.exp(-u.deltaY*.006)));z(at(C,Q,{x:u.clientX-E.left,y:u.clientY-E.top}))}else{const Q=u.deltaMode===1?16:u.deltaMode===2?E.height:1;z({...C,x:C.x-u.deltaX*Q,y:C.y-u.deltaY*Q})}};return t.addEventListener("wheel",p,{passive:!1}),()=>t.removeEventListener("wheel",p)},[]);const W=t=>{if(t.button!==0||!t.isPrimary||B.current)return;const p=t.target,u=p.closest("[data-bot-id]")?.dataset.botId,C=p.closest("[data-arrange-team]")?.dataset.arrangeTeam,E=u?n.flatMap(V=>[...V.chiefs,...V.members]).find(V=>V.id===u):void 0;if(!E&&C===void 0&&p.closest("button, details, a, input, [data-team-key]")||E&&(ie||!fe)||C!==void 0&&!fe)return;const Q={id:t.pointerId,start:{x:t.clientX,y:t.clientY},view:m,positions:H,moved:!1},ae=C===void 0?void 0:be.find(V=>V.key===C);B.current=E?{...Q,kind:"bot",bot:E}:ae?{...Q,kind:"team",key:ae.key,origin:ae}:{...Q,kind:"pan"},L.current=!1},nt=(t,p)=>{const u=document.elementFromPoint(t,p)?.closest("[data-team-key]");return u&&j.current?.contains(u)?u.dataset.teamKey??null:null},st=(t,p)=>{const u=n.find(V=>V.key===(t.section?.trim()??""));if(!u)return null;const C=ke(t.chiefOfStaff?u.chiefs:u.members,o(u.key)),E=C.filter(V=>V.id!==t.id),Q=[...j.current?.querySelectorAll("[data-bot-id]")??[]],ae=E.findIndex(V=>{const D=Q.find(X=>X.dataset.botId===V.id)?.closest("article")?.getBoundingClientRect();return D?p<D.top+D.height/2:!1});return{section:u,lane:C,remaining:E,index:ae<0?E.length:ae}},bt=t=>{const p=B.current;if(!p||p.id!==t.pointerId)return;if(t.buttons===0){Ce(t,!0);return}const u=t.clientX-p.start.x,C=t.clientY-p.start.y;if(!(!p.moved&&Math.hypot(u,C)<5)&&(p.moved=!0,t.currentTarget.setPointerCapture(t.pointerId),p.kind==="pan"&&z({...p.view,x:p.view.x+u,y:p.view.y+C}),p.kind==="team"&&G({...p.positions,[p.key]:{x:p.origin.x+u/m.scale,y:p.origin.y+C/m.scale}}),p.kind==="bot")){const E=t.currentTarget.getBoundingClientRect();$({bot:p.bot,point:{x:t.clientX-E.left,y:t.clientY-E.top}});const Q=nt(t.clientX,t.clientY),ae=Q===(p.bot.section?.trim()??"");P(ae||r?Q:null);const V=ae?st(p.bot,t.clientY):null,D=V?.remaining[V.index]??V?.remaining.at(-1);ee(V&&D?{botId:D.id,after:V.index===V.remaining.length}:null)}},Ce=(t,p=!1)=>{const u=B.current;if(!(!u||t&&u.id!==t.pointerId)){if(B.current=null,L.current=u.moved,window.setTimeout(()=>{L.current=!1},0),$(null),P(null),ee(null),j.current?.hasPointerCapture(u.id)&&j.current.releasePointerCapture(u.id),p){G(u.positions),z(u.view);return}if(u.moved&&(u.kind==="team"&&t&&f({...u.positions,[u.key]:{x:u.origin.x+(t.clientX-u.start.x)/u.view.scale,y:u.origin.y+(t.clientY-u.start.y)/u.view.scale}}),u.kind==="bot"&&t)){const C=nt(t.clientX,t.clientY);if(C===null)return;if(C===(u.bot.section?.trim()??"")){const E=st(u.bot,t.clientY);E&&k(E.section,E.lane,u.bot,E.index);return}if(!r)return;re(u.bot.id),de(s("canvas.reviewMove",{name:u.bot.name,team:C||s("settings.section.general")})),l(u.bot,C).then(E=>{de(E===!1?s("canvas.moveCancelled"):s("canvas.moved",{name:u.bot.name,team:C||s("settings.section.general")}))}).catch(E=>{de(E instanceof Error?E.message:String(E))}).finally(()=>re(null))}}},ze=t=>{const p=j.current?.getBoundingClientRect();p&&z(at(m,Math.max(.3,Math.min(1.5,m.scale*t)),{x:p.width/2,y:p.height/2}))},De=new Map(n.flatMap(t=>[...t.chiefs,...t.members]).map(t=>[t.id,t])),yt=new Map(b.map(t=>[t.id,t])),vt=t=>{const p=t.botIds.flatMap(u=>De.get(u)??[]);return t.state==="idle"&&p.some(u=>u.busy)?"working":t.state!=="working"&&p.some(u=>y.computerStarts[u.id])?"starting":t.state},Le=n.find(t=>t.key===T),Pe=se!==null?s("canvas.assignComputer",{team:n.find(t=>t.key===se)?.name??se}):N&&Le?(N.bot.section?.trim()??"")===Le.key?s("canvas.arrangeBot",{name:N.bot.name,team:Le.name}):s("canvas.moveBot",{name:N.bot.name,team:Le.name}):null;return e.jsxs("div",{ref:j,role:"region","aria-label":s("canvas.region"),tabIndex:0,"data-team-canvas":!0,className:"relative min-h-0 flex-1 touch-none overflow-clip outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/40",style:{backgroundImage:"radial-gradient(circle, color-mix(in srgb, var(--color-ink-secondary) 18%, transparent) 1px, transparent 1px)",backgroundSize:`${24*m.scale}px ${24*m.scale}px`,backgroundPosition:`${m.x}px ${m.y}px`},onPointerDown:W,onPointerMove:bt,onPointerUp:t=>Ce(t),onPointerCancel:t=>Ce(t,!0),onDragOver:t=>{if(!r||!x||!t.dataTransfer.types.includes(qe))return;const p=t.target.closest("[data-team-key]"),u=p&&t.currentTarget.contains(p)?p.dataset.teamKey??null:null;S(u),u!==null&&(t.preventDefault(),t.dataTransfer.dropEffect="link")},onDragLeave:t=>{(!(t.relatedTarget instanceof Node)||!t.currentTarget.contains(t.relatedTarget))&&S(null)},onDrop:t=>{if(S(null),!r||!x||!t.dataTransfer.types.includes(qe))return;const p=t.target.closest("[data-team-key]"),u=p&&t.currentTarget.contains(p)?p.dataset.teamKey:void 0,C=t.dataTransfer.getData(qe);u===void 0||!n.some(E=>E.key===u)||!C||(t.preventDefault(),x(C,u))},onDragEnd:()=>S(null),onPointerDownCapture:t=>{Y.current=!1,t.target.closest("details")||t.currentTarget.querySelectorAll("details[open]").forEach(p=>p.removeAttribute("open"))},onKeyDownCapture:t=>{t.key==="Tab"&&(Y.current=!0)},onPointerLeave:()=>{B.current&&!B.current.moved&&Ce(void 0,!0)},onLostPointerCapture:()=>{B.current&&Ce(void 0,!0)},onFocusCapture:t=>{if(!Y.current||!(t.target instanceof HTMLElement)||!t.target.closest("[data-canvas-world]"))return;const p=t.currentTarget.getBoundingClientRect(),u=t.target.getBoundingClientRect(),C=u.left<p.left+16?p.left+16-u.left:u.right>p.right-16?p.right-16-u.right:0,E=u.top<p.top+16?p.top+16-u.top:u.bottom>p.bottom-70?p.bottom-70-u.bottom:0;(C||E)&&z(Q=>({...Q,x:Q.x+C,y:Q.y+E}))},onClickCapture:t=>{L.current&&(L.current=!1,t.preventDefault(),t.stopPropagation())},onKeyDown:t=>{if(t.key==="Escape"&&(Ce(void 0,!0),t.currentTarget.querySelectorAll("details[open]").forEach(C=>{C.querySelector("summary")?.focus({preventScroll:!0}),C.removeAttribute("open")})),t.target!==t.currentTarget)return;const u={ArrowLeft:{x:60,y:0},ArrowRight:{x:-60,y:0},ArrowUp:{x:0,y:60},ArrowDown:{x:0,y:-60}}[t.key];u&&(t.preventDefault(),z({...m,x:m.x+u.x,y:m.y+u.y})),(t.key==="+"||t.key==="=")&&(t.preventDefault(),ze(1.2)),t.key==="-"&&(t.preventDefault(),ze(1/1.2)),t.key==="0"&&(t.preventDefault(),Z())},children:[e.jsx("div",{"data-canvas-world":!0,className:"absolute left-0 top-0 origin-top-left",style:{transform:`translate(${m.x}px, ${m.y}px) scale(${m.scale})`},children:n.map((t,p)=>{const u=be[p],C=oe[p],E=t.chiefs.length>0&&t.members.length>0,Q=se===t.key||N&&T===t.key&&(N.bot.section?.trim()??"")!==t.key,ae=Object.hasOwn(h,t.key)?h[t.key]:void 0,V=D=>e.jsxs("div",{className:"relative",children:[F?.botId===D.id&&e.jsx("div",{className:ne("pointer-events-none absolute inset-x-1 h-0.5 rounded bg-accent",F.after?"-bottom-[9px]":"-top-[9px]")}),e.jsx(Dn,{bot:D,selected:y.selectedId===D.id&&y.settingsOpen,moving:N?.bot.id===D.id||ie===D.id,connected:w.includes(D.id),tagged:A.includes(D.id),sent:K?.botIds.includes(D.id)?K.key:void 0,onComputer:g,onArrange:fe?J:void 0})]},D.id);return e.jsxs("section",{"data-team-key":t.key,"aria-label":s("canvas.teamRegion",{name:t.name}),className:ne("absolute rounded-2xl border bg-panel/90 shadow-sm has-[details[open]]:z-20 data-[computer-dropping=true]:border-accent data-[computer-dropping=true]:ring-2 data-[computer-dropping=true]:ring-accent/25",Q?"border-accent ring-2 ring-accent/25":"border-hairline/50"),style:{left:u.x,top:u.y,width:u.width,height:u.height},children:[e.jsxs("header",{className:"flex h-16 items-center gap-2 px-5",children:[e.jsx("button",{"data-arrange-team":t.key,disabled:!fe,"aria-label":s("canvas.arrange",{name:t.name}),title:s("canvas.arrangeHint"),className:"min-w-0 flex-1 cursor-grab rounded-md py-2 text-left active:cursor-grabbing focus-visible:outline-2 focus-visible:outline-accent",onKeyDown:D=>{const X={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[D.key];if(!X)return;D.preventDefault(),D.stopPropagation();const ye=D.shiftKey?40:10;f({...H,[t.key]:{x:u.x+X[0]*ye,y:u.y+X[1]*ye}})},children:e.jsx("h2",{className:"truncate text-[13px] font-semibold tracking-tight",children:t.name})}),ae&&e.jsxs("button",{"aria-label":s("canvas.teamComputer",{team:t.name,name:ae.name}),title:`${ae.name}${ae.state?` · ${ae.state}`:""}`,disabled:!M,onClick:()=>M?.(t.key),className:"flex min-w-0 max-w-[120px] shrink items-center gap-1.5 rounded-md px-1.5 py-2 text-[10px] text-ink-secondary hover:bg-control hover:text-ink focus-visible:outline-2 focus-visible:outline-accent disabled:pointer-events-none",children:[e.jsx(Oe,{size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:ae.name})]}),e.jsx("span",{className:"text-[11px] tabular-nums text-ink-secondary",children:t.chiefs.length+t.members.length}),r&&e.jsxs("details",{className:"relative",onToggle:D=>{if(D.currentTarget.open){const X=j.current?.getBoundingClientRect();ge(X&&D.currentTarget.getBoundingClientRect().bottom>X.bottom-210*m.scale?t.key:null),j.current?.querySelectorAll("details[open]").forEach(ye=>{ye!==D.currentTarget&&ye.removeAttribute("open")})}},children:[e.jsx("summary",{"aria-label":s("canvas.manageTeam",{name:t.name}),className:ne(Ae,"cursor-pointer list-none [&::-webkit-details-marker]:hidden"),children:e.jsx(Ct,{size:17})}),e.jsxs("div",{className:ne("absolute right-0 z-30 w-[220px] animate-pop-in rounded-xl border border-hairline bg-panel p-1.5 shadow-xl",he===t.key?"bottom-10":"top-10"),onClick:D=>{const X=D.currentTarget.closest("details");X?.querySelector("summary")?.focus(),X?.removeAttribute("open")},children:[e.jsxs("button",{className:Ie,onClick:()=>c(t.key),"aria-label":s("team.moveTo",{name:t.name}),children:[e.jsx(dt,{size:14}),s("team.moveTo",{name:t.name})]}),e.jsxs("button",{className:Ie,onClick:()=>d(t.key,t.name),"aria-label":s("team.instructionsEdit",{name:t.name}),children:[e.jsx(ut,{size:14}),s("team.instructions")]}),i&&e.jsxs("button",{className:Ie,onClick:()=>i(t.key,t.name),"aria-label":s("team.memoryFor",{name:t.name}),children:[e.jsx(mt,{size:14}),s("team.memory")]}),t.key&&e.jsxs("button",{className:Ie,onClick:()=>c(t.key,!0),"aria-label":s("team.renameAria",{name:t.name}),children:[e.jsx(Tt,{size:14}),s("team.rename")]}),t.key&&e.jsxs("button",{className:ne(Ie,"hover:text-danger"),onClick:()=>I(t.key),"aria-label":s("team.deleteAria",{name:t.name}),children:[e.jsx(pt,{size:14}),s("team.delete")]})]})]})]}),Q&&e.jsx("div",{className:"pointer-events-none absolute -top-7 left-2 z-30 max-w-[calc(100%-16px)] truncate rounded-md bg-accent px-2 py-1 text-[10px] text-white shadow-sm",children:Pe}),C?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 overflow-visible",width:u.width,height:u.height,children:[C.tree.map((D,X)=>e.jsx("path",{d:rt(D),fill:"none",strokeWidth:1.5,className:"stroke-ink-secondary/25"},`tree-${X}`)),C.links.map(D=>{const X=De.get(D.botId)?.busy===!0;return e.jsx("path",{d:rt(D.points),fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:X?2.25:1.5,strokeDasharray:X?"7 5":void 0,className:X?"animate-link-flow stroke-success/80":"stroke-ink-secondary/35"},`${D.botId}:${D.computerId}`)})]}),C.cards.map(D=>{const X=De.get(D.botId);return X?e.jsx("div",{className:"absolute",style:{left:D.x,top:D.y},children:V(X)},X.id):null}),C.monitors.map(D=>{const X=yt.get(D.id);if(!X)return null;const ye=X.botIds.flatMap(Ue=>De.get(Ue)??[]);return e.jsx(zn,{computer:X,bots:ye,x:D.x,y:D.y,frameUrl:Object.hasOwn(O,X.id)?O[X.id].url:void 0,state:vt(X),activity:Pn(ye.find(Ue=>Ue.busy),y.instances),onOpen:U?()=>U(X):void 0},X.id)})]}):e.jsxs("div",{className:"flex items-center px-5 pb-5",children:[t.chiefs.length>0&&e.jsx("div",{className:"flex flex-col gap-4",children:ke(t.chiefs,o(t.key)).map(V)}),E&&e.jsx("div",{className:"flex w-10 shrink-0 justify-center text-ink-secondary/35","aria-hidden":"true",children:e.jsx(ft,{size:22,strokeWidth:1})}),t.members.length>0&&e.jsx("div",{className:"flex flex-col gap-4",children:ke(t.members,o(t.key)).map(V)}),t.chiefs.length+t.members.length===0&&e.jsx("p",{className:"flex h-[126px] w-[236px] items-center justify-center rounded-xl border border-dashed border-hairline/70 px-6 text-center text-[12px] leading-relaxed text-ink-secondary",children:s("canvas.dropHere")})]})]},t.key)})}),N&&e.jsxs("div",{className:"pointer-events-none absolute z-40 rounded-xl border border-accent/40 bg-card px-4 py-3 text-[13px] shadow-lg",style:{left:N.point.x+16,top:N.point.y+16},children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ze,{bot:N.bot,size:24,animated:!1}),N.bot.name]}),Pe&&e.jsx("p",{className:"mt-1 text-[10px] text-ink-secondary",children:Pe})]}),e.jsxs("div",{className:"pointer-events-none absolute inset-x-5 bottom-5 flex items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 rounded-lg bg-app/90 px-2 py-1.5 text-[11px] text-ink-secondary",children:[!v&&e.jsx("p",{className:"max-sm:hidden",children:s("canvas.hint")}),e.jsx("p",{role:"status","aria-live":"polite",className:"max-w-[440px]",children:Pe??ue})]}),e.jsxs("div",{className:"pointer-events-auto flex shrink-0 items-center gap-0.5 rounded-xl border border-hairline/60 bg-panel p-1 shadow-sm",children:[e.jsx("button",{className:Ae,"aria-label":s("canvas.zoomOut"),onClick:()=>ze(1/1.2),children:e.jsx(Et,{size:15})}),e.jsxs("button",{className:"min-w-12 rounded-md px-1 py-2 text-[11px] tabular-nums text-ink-secondary hover:bg-control","aria-label":s("canvas.fit"),title:s("canvas.fitHint"),onClick:Z,children:[Math.round(m.scale*100),"%"]}),e.jsx("button",{className:Ae,"aria-label":s("canvas.zoomIn"),onClick:()=>ze(1.2),children:e.jsx(Ke,{size:15})})]})]})]})}const lt=[{kind:"person",titleKey:"teamMemory.kind.people",hintKey:"teamMemory.kind.peopleHint"},{kind:"place",titleKey:"teamMemory.kind.places",hintKey:"teamMemory.kind.placesHint"},{kind:"decision",titleKey:"teamMemory.kind.decisions",hintKey:"teamMemory.kind.decisionsHint"},{kind:"term",titleKey:"teamMemory.kind.terms",hintKey:"teamMemory.kind.termsHint"}];function _n({section:n,label:r,onClose:l}){const d=a.useRef(null),[i,c]=a.useState(null),[I,g]=a.useState([]),[x,M]=a.useState({}),[h,w]=a.useState(null),[b,O]=a.useState(null),U=a.useRef(!1),A=a.useRef(0),[K,v]=a.useState(!1),[y,j]=a.useState({kind:"term",name:"",detail:""}),B=`section=${encodeURIComponent(n)}`,L=a.useCallback(async()=>{const m=++A.current;try{const z=await te(`/api/team-memory?${B}`);if(A.current!==m)return;c(z.entries),g(z.loadedIds),w(null)}catch(z){if(A.current!==m)return;w(z instanceof Error?z.message:String(z))}},[B]);a.useEffect(()=>(c(null),w(null),L(),()=>{A.current+=1}),[L]),a.useEffect(()=>{const m=document.activeElement instanceof HTMLElement?document.activeElement:null;d.current?.focus();const z=N=>{if(N.key==="Escape"&&(N.preventDefault(),l()),N.key==="Tab"){const $=d.current?.querySelectorAll("button:enabled, input:enabled, select:enabled");if(!$?.length)return;const T=$[0],P=$[$.length-1];N.shiftKey&&document.activeElement===T?(N.preventDefault(),P.focus()):!N.shiftKey&&document.activeElement===P&&(N.preventDefault(),T.focus())}};return window.addEventListener("keydown",z),()=>{window.removeEventListener("keydown",z),m?.focus()}},[l]);const Y=async(m,z)=>{if(U.current)return!1;U.current=!0;const N=++A.current;O(m??"new"),w(null);try{const $=await z();return A.current!==N?!1:(c($.entries),O(null),$.loadedIds?g($.loadedIds):L(),!0)}catch($){return A.current===N&&w($ instanceof Error?$.message:String($)),!1}finally{U.current=!1,A.current===N&&O(null)}},_=m=>Y(m.id,()=>te(`/api/team-memory/${m.id}?${B}`,{method:"PATCH",body:JSON.stringify({accept:!0,expectedRevision:m.revision})})),H=m=>Y(m.id,()=>te(`/api/team-memory/${m.id}?${B}&revision=${m.revision}`,{method:"DELETE"})),G=(m,z,N)=>{z.trim()===m.detail&&(N===void 0||N===m.name)||Y(m.id,()=>te(`/api/team-memory/${m.id}?${B}`,{method:"PATCH",body:JSON.stringify({detail:z,...N===void 0?{}:{name:N},expectedRevision:m.revision})})).then($=>M(T=>{const P={...T};return $?delete P[m.id]:P[m.id]={name:N??m.name,text:z},P}))},R=()=>{!y.name.trim()||!y.detail.trim()||Y(null,()=>te(`/api/team-memory?${B}`,{method:"POST",body:JSON.stringify(y)})).then(m=>{m&&(j({kind:y.kind,name:"",detail:""}),v(!1))})},q=(i??[]).filter(m=>m.status==="proposed");return et.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4 sm:p-6",onMouseDown:m=>m.target===m.currentTarget&&l(),children:e.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-labelledby":"team-memory-title",tabIndex:-1,className:"animate-pop-in flex max-h-[min(720px,calc(100dvh-2rem))] w-full max-w-[720px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl shadow-black/50 outline-none",children:[e.jsxs("header",{className:"flex items-start justify-between gap-4 border-b border-hairline/40 px-6 pb-4 pt-6 sm:px-8 sm:pt-7",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mt,{size:19,className:"text-accent"}),e.jsx("h2",{id:"team-memory-title",className:"text-[20px] font-semibold tracking-[-0.01em] text-ink",children:s("teamMemory.title",{name:r})})]}),e.jsx("p",{className:"mt-1.5 max-w-[560px] text-[13px] leading-relaxed text-ink-secondary",children:s("teamMemory.description")})]}),e.jsx("button",{onClick:l,"aria-label":s("teamMemory.close"),className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(Be,{size:19})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5 sm:px-8",children:[i===null&&!h&&e.jsx("div",{className:"flex min-h-[200px] items-center justify-center text-ink-secondary",children:e.jsx(Re,{size:20,className:"animate-spin","aria-label":s("teamMemory.loading")})}),i&&e.jsx("p",{className:"mb-3 text-[12px] text-ink-secondary",children:s("teamMemory.loadedSummary",{loaded:I.length,total:i.filter(m=>m.status==="accepted").length})}),h&&e.jsxs("div",{role:"alert",className:"mb-3 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:[h," ",e.jsx("button",{onClick:()=>{L()},className:"underline",children:s("teamMemory.reload")})]}),Object.entries(x).map(([m,z])=>e.jsxs("p",{className:"mb-3 text-[12px] text-ink-secondary",children:[e.jsx("strong",{children:z.name})," · ",s("teamMemory.unsaved",{text:z.text})]},m)),q.length>0&&e.jsxs("section",{className:"mb-5 rounded-xl border border-accent/30 bg-accent/5 p-3",children:[e.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-accent",children:s("teamMemory.waiting")}),e.jsx("ul",{className:"mt-2 space-y-2",children:q.map(m=>e.jsxs("li",{className:"flex items-start gap-3 text-[13px]",children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"text-ink-secondary",children:[s(`teamMemory.kind.${m.kind}`),": "]}),e.jsx("span",{className:"font-medium text-ink",children:m.name}),m.aliases.length>0&&e.jsxs("span",{className:"text-ink-secondary",children:[" (",s("teamMemory.also")," ",m.aliases.join(", "),")"]}),e.jsxs("span",{className:"text-ink",children:[" — ",m.detail]}),e.jsxs("span",{className:"block text-[11px] text-ink-secondary",children:[s("teamMemory.source",{name:m.source.botName}),m.source.quote&&` · ${s("teamMemory.sourceQuote",{quote:m.source.quote})}`]})]}),e.jsxs("button",{onClick:()=>{_(m)},disabled:b!==null,className:"flex shrink-0 items-center gap-1 rounded-md bg-accent px-2.5 py-1 text-[12px] font-medium text-white disabled:opacity-50",children:[e.jsx(kt,{size:12})," ",s("teamMemory.remember")]}),e.jsx("button",{onClick:()=>{H(m)},disabled:b!==null,className:"shrink-0 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:text-ink disabled:opacity-50",children:s("teamMemory.skip")})]},m.id))})]}),i!==null&&i.filter(m=>m.status==="accepted").length===0&&q.length===0&&e.jsx("div",{className:"rounded-xl bg-inset px-4 py-6 text-center text-[13px] text-ink-secondary",children:s("teamMemory.empty")}),lt.map(({kind:m,titleKey:z,hintKey:N})=>{const $=(i??[]).filter(T=>T.status==="accepted"&&T.kind===m);return $.length===0?null:e.jsxs("section",{className:"mb-5",children:[e.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-ink-secondary",title:s(N),children:s(z)}),e.jsx("ul",{className:"mt-2 divide-y divide-hairline/20 rounded-xl bg-inset",children:$.map(T=>e.jsxs("li",{className:"flex items-start gap-3 px-3 py-2 text-[13px]",children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium text-ink",children:T.name}),T.aliases.length>0&&e.jsxs("span",{className:"text-ink-secondary",children:[" (",s("teamMemory.also")," ",T.aliases.join(", "),")"]}),e.jsx("input",{defaultValue:T.detail,disabled:b!==null,onBlur:P=>G(T,P.target.value),onKeyDown:P=>{P.key==="Enter"&&P.target.blur()},"aria-label":s("teamMemory.entryDetailLabel",{name:T.name}),className:"mt-0.5 block w-full rounded bg-transparent px-1 py-0.5 text-[13px] text-ink outline-none hover:bg-card focus:bg-card"},T.revision),e.jsxs("span",{className:"block px-1 text-[11px] text-ink-secondary",children:[T.source.botName||s("teamMemory.you")," · ",new Date(T.updatedAt).toLocaleDateString(Ee())," · ",I.includes(T.id)?s("teamMemory.loaded"):s("teamMemory.searchable")]}),!!T.history?.length&&e.jsxs("details",{className:"mt-1 text-[11px] text-ink-secondary",children:[e.jsx("summary",{children:s("teamMemory.history")}),T.history.map((P,se)=>e.jsxs("div",{className:"mt-1",children:[new Date(P.at).toLocaleDateString(Ee()),": ",P.name," — ",P.detail," ",e.jsx("button",{disabled:b!==null,onClick:()=>G(T,P.detail,P.name),className:"underline",children:s("teamMemory.restore")})]},se))]})]}),e.jsx("button",{"aria-label":s(T.pinned?"teamMemory.unpin":"teamMemory.pin",{name:T.name}),"aria-pressed":T.pinned??!1,disabled:b!==null,className:"p-1 text-ink-secondary hover:text-accent",onClick:()=>{Y(T.id,()=>te(`/api/team-memory/${T.id}?${B}`,{method:"PATCH",body:JSON.stringify({pinned:!T.pinned,expectedRevision:T.revision})}))},children:e.jsx(Lt,{size:13})}),e.jsx("button",{onClick:()=>{H(T)},disabled:b!==null,"aria-label":s("teamMemory.remove",{name:T.name}),className:"shrink-0 rounded-md p-1 text-ink-secondary hover:text-danger disabled:opacity-50",children:e.jsx(pt,{size:13})})]},T.id))})]},m)}),K?e.jsxs("div",{className:"rounded-xl border border-hairline/40 bg-card p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ht,{size:"sm",value:y.kind,onChange:m=>j({...y,kind:m.target.value}),"aria-label":s("teamMemory.kindLabel"),children:lt.map(({kind:m})=>e.jsx("option",{value:m,children:s(`teamMemory.kind.${m}`)},m))}),e.jsx("input",{value:y.name,onChange:m=>j({...y,name:m.target.value}),placeholder:s("teamMemory.namePlaceholder"),"aria-label":s("teamMemory.nameLabel"),className:"min-w-[140px] flex-1 rounded-lg border border-hairline/40 bg-inset px-2 py-1 text-[13px] text-ink outline-none focus:border-accent"})]}),e.jsx("input",{value:y.detail,onChange:m=>j({...y,detail:m.target.value}),onKeyDown:m=>{m.key==="Enter"&&R()},placeholder:s("teamMemory.detailPlaceholder"),"aria-label":s("teamMemory.detailLabel"),className:"mt-2 w-full rounded-lg border border-hairline/40 bg-inset px-2 py-1 text-[13px] text-ink outline-none focus:border-accent"}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("button",{onClick:R,disabled:b!==null||!y.name.trim()||!y.detail.trim(),className:"rounded-lg bg-accent px-3 py-1 text-[13px] font-medium text-white disabled:opacity-50",children:b==="new"?s("teamMemory.adding"):s("teamMemory.add")}),e.jsx("button",{onClick:()=>v(!1),className:"text-[13px] text-ink-secondary hover:text-ink",children:s("common.cancel")})]})]}):e.jsxs("button",{onClick:()=>v(!0),className:ne("flex items-center gap-1.5 text-[13px] text-ink-secondary hover:text-ink",i===null&&"hidden"),children:[e.jsx(Ke,{size:13})," ",s("teamMemory.addEntry")]})]})]})}),document.body)}const xe="rounded-lg px-3 py-2 text-[12px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-40",Hn="w-full rounded-lg border border-hairline/60 bg-inset px-3 py-2 text-[12px] text-ink outline-none focus:border-accent";function Kn(n,r){if(r)return s("canvasComputers.updating");const l={idle:"idle",ready:"ready",running:"running",init:"starting",provisioning:"provisioning",provisioned:"starting",cloning:"starting",starting:"starting",sleeping:"sleeping"}[n];return l?s(`canvasComputers.state.${l}`):n}function Un({open:n,createRequest:r,drop:l,sections:d,onClose:i,onDropHandled:c,onChange:I}){const{dispatch:g}=Ne(),[x,M]=a.useState(null),[h,w]=a.useState(!1),[b,O]=a.useState(""),[U,A]=a.useState(""),[K,v]=a.useState(null),[y,j]=a.useState(!1),[B,L]=a.useState(""),Y=a.useRef($e()),_=a.useRef(null),H=a.useRef(null),G=a.useRef(null),R=a.useRef(!1),q=a.useRef(!0),m=a.useRef(null),z=a.useRef(I);z.current=I;const[N,$]=a.useState(null),[T,P]=a.useState(null),[se,S]=a.useState(null),F=a.useRef($e()),ee=a.useRef(null),ie=a.useRef(null),re=a.useRef(null),ue=a.useRef(null),[de,fe]=a.useState(null),me=a.useCallback(()=>{const o=re.current;re.current=null,ue.current?.removeAttribute("data-computer-dropping"),ue.current=null,o?.handle.hasPointerCapture(o.id)&&o.handle.releasePointerCapture(o.id),fe(null)},[]);a.useEffect(()=>(n||me(),()=>{ue.current?.removeAttribute("data-computer-dropping")}),[n,me]),a.useEffect(()=>{ee.current=se},[se]),a.useEffect(()=>()=>{const o=ee.current;o&&fetch(`/api/team-computers/${encodeURIComponent(o)}/control`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"release",controlLeaseId:F.current}),keepalive:!0}).catch(()=>{})},[]);const he=a.useCallback((o,k)=>{if(!(R.current||o.section===k)){if(o.section!==null&&k!==null){O(s("canvasComputers.unassignBeforeMove",{computer:o.name,team:o.section||s("settings.section.general")}));return}O(""),$({computer:o,section:k})}},[]),ge=(o,k)=>{const J=ie.current?.parentElement?.querySelector("[data-team-canvas]"),Z=document.elementFromPoint(o,k)?.closest("[data-team-key]");return Z&&J?.contains(Z)&&d.some(le=>le.key===Z.dataset.teamKey)?Z:null},ve=o=>{const k=re.current;if(!k||o.pointerId!==k.id)return;if(o.buttons===0){me();return}if(!k.moved&&Math.hypot(o.clientX-k.x,o.clientY-k.y)<5)return;k.moved=!0,o.currentTarget.setPointerCapture(o.pointerId);const J=ge(o.clientX,o.clientY);ue.current!==J&&(ue.current?.removeAttribute("data-computer-dropping"),J?.setAttribute("data-computer-dropping","true"),ue.current=J);const Z=J?d.find(le=>le.key===J.dataset.teamKey):null;fe({name:k.computer.name,x:o.clientX,y:o.clientY,hint:Z?k.computer.section!==null&&k.computer.section!==Z.key?s("canvasComputers.unassignBeforeMoving"):s("canvasComputers.assignTo",{team:Z.name}):s("canvasComputers.dropOntoTeam")})},Se=o=>{const k=re.current;if(!k||k.id!==o.pointerId)return;const J=k.moved?ge(o.clientX,o.clientY)?.dataset.teamKey:void 0;me(),J!==void 0&&he(k.computer,J)},oe=a.useCallback(async(o=!1)=>{m.current?.abort();const k=new AbortController;m.current=k,w(!0);try{const J=await te("/api/team-computers",{signal:AbortSignal.any([k.signal,AbortSignal.timeout(3e4)]),background:o});if(k.signal.aborted||!q.current)return;M(J),A(""),z.current(J.computers)}catch(J){!k.signal.aborted&&q.current&&A(J instanceof Error?J.message:String(J))}finally{!k.signal.aborted&&q.current&&w(!1)}},[]);a.useEffect(()=>(q.current=!0,oe(),()=>{q.current=!1,m.current?.abort()}),[oe]),a.useEffect(()=>{if(!n)return;oe();const o=window.setInterval(()=>{!R.current&&document.visibilityState==="visible"&&oe(!0)},2e4);return()=>window.clearInterval(o)},[n,oe]),a.useEffect(()=>{r>0&&j(!0)},[r]),a.useEffect(()=>{if(!n)return;const o=document.activeElement instanceof HTMLElement?document.activeElement:null;return G.current?.focus(),()=>{o?.isConnected&&o.focus()}},[n]),a.useEffect(()=>{n&&y&&H.current?.focus()},[n,y]),a.useEffect(()=>{if(!l)return;const o=x?.computers.find(k=>k.id===l.id);o&&he(o,l.section),c()},[l,x,c,he]);const pe=async(o,k,J,Z)=>{if(!R.current){R.current=!0,v(o),O(""),m.current?.abort();try{const le=await k();q.current&&J?.(le)}catch(le){q.current&&(O(le instanceof Error?le.message:String(le)),Z?.())}finally{R.current=!1,q.current&&(v(null),await oe())}}},be=a.useCallback(()=>$(null),[]),ce=(o,k,J={})=>te(`/api/team-computers/${encodeURIComponent(o)}/${k}`,{method:"POST",body:JSON.stringify(J)}),f=()=>{i(),g({type:"toggleAppSettings",open:!0,section:"computer"})};return e.jsxs(e.Fragment,{children:[n&&e.jsxs("aside",{ref:ie,"aria-label":s("canvasComputers.title"),onKeyDown:o=>{o.key==="Escape"&&!N&&(o.stopPropagation(),re.current?me():i())},className:"flex w-[300px] max-w-[90vw] shrink-0 flex-col border-l border-hairline/50 bg-panel max-sm:absolute max-sm:inset-y-0 max-sm:right-0 max-sm:z-30 max-sm:shadow-xl",children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-hairline/40 px-4 py-3",children:[e.jsx(Oe,{size:16,className:"text-ink-secondary"}),e.jsx("h2",{className:"flex-1 text-[13px] font-semibold",children:s("canvasComputers.title")}),e.jsx("button",{"aria-label":s("canvasComputers.refresh"),className:xe,disabled:h||K!==null,onClick:()=>{O(""),oe()},children:e.jsx(sn,{size:14,className:h?"animate-spin":""})}),e.jsx("button",{ref:G,"aria-label":s("canvasComputers.close"),className:xe,onClick:i,children:e.jsx(Be,{size:15})})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto p-4",children:[e.jsx("p",{className:"text-[12px] leading-relaxed text-ink-secondary",children:s("canvasComputers.hint")}),(b||U||x?.problem)&&e.jsx("p",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] text-danger",children:b||U||x?.problem}),x&&!x.configured&&e.jsxs("div",{className:"rounded-xl border border-hairline/50 p-3 text-[12px]",children:[e.jsx("p",{className:"text-ink-secondary",children:s("canvasComputers.connectBoatHint")}),e.jsx("button",{className:`${xe} mt-2 border border-hairline/50`,onClick:f,children:s("canvasComputers.connectBoat")})]}),y?e.jsxs("form",{className:"space-y-3 rounded-xl border border-hairline/60 bg-card p-3",onSubmit:o=>{o.preventDefault();const k=_.current??B.trim();!k||!x?.configured||(_.current=k,pe("create",()=>te("/api/team-computers",{method:"POST",body:JSON.stringify({name:k,requestId:Y.current,acknowledgeCost:!0})}),()=>{L(""),j(!1),Y.current=$e(),_.current=null},()=>{_.current=null}))},children:[e.jsx("label",{className:"block text-[12px] font-medium",htmlFor:"canvas-computer-name",children:s("canvasComputers.newCloud")}),e.jsx("input",{ref:H,id:"canvas-computer-name",className:Hn,value:B,maxLength:60,placeholder:s("canvasComputers.namePlaceholder"),disabled:K!==null||_.current!==null,onChange:o=>L(o.target.value)}),e.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:s("canvasComputers.createHint")}),e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx("button",{type:"button",className:xe,disabled:K!==null,onClick:()=>j(!1),children:s("common.cancel")}),e.jsxs("button",{type:"submit",className:"flex items-center gap-2 rounded-lg bg-accent px-3 py-2 text-[12px] font-medium text-white disabled:opacity-40",disabled:!x?.configured||!B.trim()||K!==null,children:[K==="create"&&e.jsx(Re,{size:13,className:"animate-spin"}),s("canvasComputers.create")]})]})]}):e.jsxs("button",{className:"flex w-full items-center justify-center gap-2 rounded-xl border border-dashed border-hairline/60 px-3 py-3 text-[12px] text-ink-secondary hover:bg-control hover:text-ink",disabled:K!==null,onClick:()=>j(!0),children:[e.jsx(Ke,{size:14})," ",s("canvasComputers.newCloud")]}),x?.computers.map(o=>{const k=["idle","ready","running"].includes(o.state),J=["init","provisioning","provisioned","cloning","starting"].includes(o.state),Z=se===o.id,le=o.held||Z;return e.jsxs("article",{"data-computer-id":o.id,className:"rounded-xl border border-hairline/60 bg-card p-3",children:[e.jsxs("div",{"data-computer-drag-id":o.id,role:"group",tabIndex:-1,"aria-label":s("canvasComputers.dragToTeam",{name:o.name}),onPointerDown:W=>{R.current||re.current||W.button!==0||!W.isPrimary||(W.currentTarget.focus({preventScroll:!0}),re.current={id:W.pointerId,x:W.clientX,y:W.clientY,moved:!1,computer:o,handle:W.currentTarget},W.currentTarget.setPointerCapture(W.pointerId))},onPointerMove:ve,onPointerUp:Se,onPointerCancel:me,onLostPointerCapture:()=>{re.current&&me()},className:"flex touch-none select-none cursor-grab items-center gap-2.5 rounded-lg py-1 outline-none active:cursor-grabbing",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-control text-ink-secondary",children:e.jsx(Je,{size:18})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-[13px] font-medium",children:o.name}),e.jsxs("span",{className:"block text-[11px] text-ink-secondary",children:[s("canvasComputers.cloudComputer")," · ",Kn(o.state,K===o.id)]})]})]}),o.problem&&e.jsx("p",{className:"mt-2 text-[11px] text-danger",children:o.problem}),e.jsx("label",{className:"sr-only",htmlFor:`computer-team-${o.id}`,children:s("canvasComputers.teamFor",{name:o.name})}),e.jsxs(ht,{id:`computer-team-${o.id}`,className:"mt-3 w-full",disabled:K!==null,value:o.section===null?"unassigned":`team:${o.section}`,onChange:W=>he(o,W.target.value==="unassigned"?null:W.target.value.slice(5)),children:[e.jsx("option",{value:"unassigned",children:s("canvasComputers.unassigned")}),d.filter(W=>o.section===null||W.key===o.section).map(W=>e.jsx("option",{value:`team:${W.key}`,children:W.name},W.key))]}),o.section!==null&&e.jsx("p",{className:"mt-1.5 text-[10px] text-ink-secondary",children:s("canvasComputers.unassignHint")}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[!k&&!J&&e.jsx("button",{className:xe,title:s("canvasComputers.startTitle"),disabled:K!==null||le,onClick:()=>{pe(o.id,()=>ce(o.id,"provision",{acknowledgeCost:!0}))},children:s("canvasComputers.startRetry")}),k&&!le&&e.jsx("button",{className:xe,disabled:K!==null,onClick:()=>{pe(o.id,()=>ce(o.id,"sleep"))},children:s("canvasComputers.sleep")}),k&&e.jsxs("button",{className:`${xe} flex items-center gap-1.5`,title:s("canvasComputers.openTitle"),disabled:K!==null,onClick:()=>{pe(o.id,async()=>(await ce(o.id,"control",{action:"take",controlLeaseId:F.current}),S(o.id),ce(o.id,"join")),W=>{typeof W.joinUrl=="string"&&W.joinUrl.startsWith("https://")&&P({id:o.id,url:W.joinUrl})})},children:[s("canvasComputers.openDesktop")," ",e.jsx(Nt,{size:11})]}),Z&&e.jsx("button",{className:`${xe} text-accent`,disabled:K!==null,onClick:()=>{pe(o.id,()=>ce(o.id,"control",{action:"release",controlLeaseId:F.current}),()=>{S(null),P(null)})},children:s("canvasComputers.returnToBots")}),o.held&&!Z&&e.jsx("button",{className:xe,disabled:!0,title:s("canvasComputers.inUseTitle"),children:s("canvasComputers.inUse")})]}),T?.id===o.id&&e.jsxs("a",{href:T.url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 block rounded-lg px-3 py-2 text-[12px] text-accent hover:bg-control",children:[s("canvasComputers.openSecure")," ",e.jsx(Pt,{size:14,"aria-hidden":"true",className:"inline align-[-2px]"})]})]},o.id)})]}),e.jsx("footer",{className:"border-t border-hairline/40 p-3",children:e.jsx("button",{className:`${xe} w-full text-left`,onClick:f,children:s("canvasComputers.moreSettings")})})]}),de&&et.createPortal(e.jsxs("div",{role:"status",className:"pointer-events-none fixed z-[70] rounded-xl border border-accent/40 bg-card px-4 py-3 text-[12px] text-ink shadow-xl",style:{left:de.x+14,top:de.y+14},children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Je,{size:15}),de.name]}),e.jsx("p",{className:"mt-1 text-[10px] text-ink-secondary",children:de.hint})]}),document.body),e.jsx(Ve,{open:N!==null,tone:"neutral",title:N?.section===null?s("canvasComputers.unassignTitle",{name:N?.computer.name??s("canvasComputers.computer")}):s("canvasComputers.assignTitle",{name:N?.computer.name??s("canvasComputers.computer"),team:N?.section||s("settings.section.general")}),body:N?.section===null?s("canvasComputers.unassignBody"):s("canvasComputers.assignBody"),confirmLabel:N?.section===null?s("canvasComputers.unassign"):s("canvasComputers.assign"),onCancel:be,onConfirm:()=>{const o=N;o&&($(null),P(null),pe(o.computer.id,()=>te(`/api/team-computers/${encodeURIComponent(o.computer.id)}`,{method:"PATCH",body:JSON.stringify({section:o.section,acknowledgeSharedAccess:!0})})))}})]})}function qn(n,r,l){const d=r.filter(h=>!h.hidden&&h.name.trim()),i=[...d.map(h=>({name:h.name,tag:{kind:"bot",name:h.name,botIds:[h.id]}})),...l.filter(h=>h.name.trim()).map(h=>({name:h.name,tag:{kind:"team",name:h.name,botIds:d.filter(w=>(w.section?.trim()??"")===h.key).map(w=>w.id)}})),{name:"everyone",tag:{kind:"everyone",name:"everyone",botIds:d.map(h=>h.id)}}].sort((h,w)=>w.name.length-h.name.length),c=[],I=[],g=[];let x=-1;for(;(x=n.indexOf("@",x+1))!==-1;){if(!$t(n,x))continue;const h=n.slice(x+1),w=i.find(({name:O})=>h.slice(0,O.length).toLowerCase()===O.toLowerCase()&&!_t(h.slice(O.length)));if(w){c.push(w.tag),g.push([x,x+1+w.name.length]),x+=w.name.length;continue}const b=/^[\p{L}\p{N}\p{M}_.-]+/u.exec(h)?.[0];b&&I.push(b)}const M=g.reduceRight((h,[w,b])=>h.slice(0,w)+h.slice(b),n).replace(/\s+/g," ").trim();return{botIds:[...new Set(c.flatMap(h=>h.botIds))],tags:c,unknown:I,words:M}}function ct(n,r,l){if(!n.tags.some(c=>c.kind==="everyone"))return{botIds:n.botIds};if(l)return{botIds:n.botIds,text:n.words};const d=Fn(r);if(!d)return{botIds:n.botIds};const i=n.tags.filter(c=>c.kind!=="everyone").flatMap(c=>c.botIds);return{botIds:[...new Set([d.id,...i])],chief:d}}function Fn(n){const r=n.filter(l=>l.chiefOfStaff&&!l.hidden);return r.find(l=>!l.section?.trim())??r[0]}function Xn(n,r=2){return n.length<=r+1?{names:[...n],more:0}:{names:n.slice(0,r),more:n.length-r}}function Yn({bots:n,teams:r,onTagged:l,onSent:d}){const{dispatch:i}=Ne(),c=Qe(),I=Ht(),g=a.useRef(null),x=a.useRef(null),[M,h]=a.useState(""),[w,b]=a.useState(0),[O,U]=a.useState(null),[A,K]=a.useState(0),[v,y]=a.useState(null),j=a.useMemo(()=>n.filter(S=>!S.hidden),[n]),B=a.useMemo(()=>qn(M,j,r),[M,j,r]),L=a.useMemo(()=>ct(B,j,!1),[B,j]),Y=L.botIds.join(",");a.useEffect(()=>{l(Y?Y.split(","):[])},[Y,l]),a.useEffect(()=>()=>l([]),[l]);const _=Kt(M,w),H=a.useMemo(()=>{if(!_||_.start===O)return[];const S=[...j.length>1?[{id:"__everyone__",name:"everyone",all:{count:j.length}}]:[],...r.filter(F=>F.count>0).map(F=>({id:`team:${F.key}`,name:F.name,team:{count:F.count}})),...j.map(F=>({id:F.id,name:F.name,bot:F}))];return Ut(S,_.query)},[_,O,j,r]),G=H.length>0,R=an(G);a.useEffect(()=>K(0),[_?.start,_?.query]),a.useEffect(()=>{G&&x.current?.querySelector(`[data-mention-index="${A}"]`)?.scrollIntoView({block:"nearest"})},[A,G]);const q=S=>{if(!_)return;const F=`${M.slice(0,_.start)}@${S.name} ${M.slice(w)}`,ee=_.start+S.name.length+2;h(F),b(ee),U(_.start),requestAnimationFrame(()=>{g.current?.focus(),g.current?.setSelectionRange(ee,ee)})},m=M.trim().length>0&&B.botIds.length>0,z=async()=>{if(!m)return;const S=M.trim(),F=B;h(""),b(0),U(null);const ee=L.chief?await te("/api/stop-line",{method:"POST",body:JSON.stringify({text:F.words})}).then(re=>re.stop===!0,()=>null):!1,ie=ee===null?{botIds:F.botIds}:ct(F,j,ee);for(const re of ie.botIds)i({type:"send",botId:re,text:ie.text||S,sendId:$e()});d(ie.botIds),y({botIds:ie.botIds,expanded:!1,...ie.chief?{chiefId:ie.chief.id}:{}})},N=v?.chiefId?j.find(S=>S.id===v.chiefId):void 0,$=(v?.botIds??[]).filter(S=>S!==N?.id).flatMap(S=>j.find(F=>F.id===S)??[]),T=Xn($.map(S=>S.name)),P=v?.expanded?$:$.slice(0,T.names.length),se=M.trim()&&!B.botIds.length?s("mapComposer.tagHint"):L.chief?s("mapComposer.willSendViaChief",{name:L.chief.name}):null;return e.jsx(e.Fragment,{children:e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-5 z-30 flex justify-center px-4",children:e.jsxs("div",{className:"pointer-events-auto w-full max-w-[620px]",children:[v&&(N||$.length>0)&&e.jsxs("p",{role:"status",className:"mb-2 flex flex-wrap items-center gap-x-1 gap-y-0.5 rounded-xl bg-panel/95 px-3 py-1.5 text-[12px] text-ink-secondary shadow-sm ring-1 ring-hairline/50",children:[N&&e.jsxs("span",{children:[s("mapComposer.sentViaChief",{name:N.name}),$.length>0?" ·":""]}),$.length>0&&e.jsx("span",{children:s("mapComposer.sentTo")}),P.map((S,F)=>e.jsxs("span",{children:[e.jsx("button",{className:"font-medium text-ink underline-offset-2 hover:underline",onClick:()=>tt(i,S,c),children:S.name}),F<P.length-1?",":""]},S.id)),!v.expanded&&T.more>0&&e.jsx("button",{className:"text-ink underline-offset-2 hover:underline",onClick:()=>y({...v,expanded:!0}),children:s("mapComposer.andMore",{count:T.more})}),e.jsx("button",{"aria-label":s("common.close"),className:"ml-auto rounded p-0.5 hover:bg-control",onClick:()=>y(null),children:e.jsx(Be,{size:12})})]}),e.jsxs("div",{className:"relative flex items-end gap-2 rounded-2xl bg-composer px-3 py-2 shadow-lg ring-1 ring-composer-ring",children:[e.jsx(qt,{listRef:x,motion:R,choices:H,highlight:A,everyoneCount:j.length,onPick:q,onHighlight:K}),e.jsx(Ft,{inputRef:g,peers:[...j,...r.map(S=>({name:S.name}))],everyone:!0,"aria-label":s("mapComposer.label"),placeholder:s("mapComposer.placeholder"),dir:"auto",rows:1,value:M,className:"block max-h-[9rem] min-h-6 w-full resize-none overflow-y-auto bg-transparent px-1 py-1 text-[15px] leading-6 placeholder:text-ink-secondary focus:outline-none",onChange:S=>{h(S.target.value),b(S.target.selectionStart??S.target.value.length),U(null)},onKeyUp:S=>b(S.target.selectionStart??0),onClick:S=>b(S.target.selectionStart??0),onKeyDown:S=>{if(!Xt(S.nativeEvent)){if(G){if(S.key==="ArrowDown"||S.key==="ArrowUp"){S.preventDefault(),K(F=>(F+(S.key==="ArrowDown"?1:-1)+H.length)%H.length);return}if(S.key==="Enter"||S.key==="Tab"){S.preventDefault(),q(H[A]);return}if(S.key==="Escape"){S.preventDefault(),S.stopPropagation(),U(_?.start??null);return}}Yt(S.nativeEvent,I)&&(S.preventDefault(),z())}}}),e.jsx("button",{onClick:()=>{z()},disabled:!m,"aria-label":s("mapComposer.send"),title:m?L.botIds.length===1?s("mapComposer.sendToOne"):s("mapComposer.sendTo",{count:L.botIds.length}):s("mapComposer.tagHint"),className:ne("mb-0.5 flex size-8 shrink-0 items-center justify-center rounded-full text-white transition-opacity",m?"bg-accent hover:brightness-110":"bg-ink-secondary/30"),children:e.jsx(Jt,{size:16})})]}),(se||B.botIds.length>0)&&e.jsx("p",{className:"mt-1.5 px-3 text-[11px] text-ink-secondary",children:se??(L.botIds.length===1?s("mapComposer.willSendOne"):s("mapComposer.willSend",{count:L.botIds.length}))})]})})})}function Jn({edge:n,bots:r}){const{state:l,dispatch:d}=Ne(),i=Qe(),c=r.find(x=>x.id===n.sourceBotId),I=r.find(x=>x.id===n.targetBotId);if(!c||!I)return null;const g=n.state!=="connected";return e.jsxs("button",{onClick:()=>{!n.groupId&&n.threadId?nn(d,{botId:I.id,threadId:n.threadId},l,i):n.groupId?d({type:"select",id:n.groupId}):tt(d,I,i)},className:"flex w-full items-center gap-3 rounded-xl border border-hairline/40 bg-card px-3 py-2.5 text-left transition hover:bg-raised/50",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-ink",children:c.name}),e.jsx(ft,{size:13,className:ne("shrink-0",g?"text-accent":"text-ink-secondary")}),e.jsx("span",{className:"truncate text-[13px] font-medium text-ink",children:I.name})]}),n.reason&&e.jsx("span",{className:"max-w-[220px] truncate text-[12px] text-ink-secondary",children:n.reason}),e.jsx("span",{className:ne("rounded-full px-2 py-0.5 text-[11px] font-medium",n.state==="running"?"bg-success/15 text-success":n.state==="queued"?"bg-warning/15 text-warning":"bg-control text-ink-secondary"),children:n.state==="running"?s("canvas.edge.running"):n.state==="queued"?s("canvas.edge.queued"):n.lastAt?jt(n.lastAt):s("canvas.edge.connected")})]})}function Vn({section:n,label:r,onClose:l}){const d=a.useRef(null),i=a.useRef(null),c=a.useRef(l),I=a.useRef(!1),g=a.useRef(!1),[x,M]=a.useState(""),[h,w]=a.useState(""),[b,O]=a.useState(24e3),[U,A]=a.useState(null),[K,v]=a.useState(!0),[y,j]=a.useState(!1),[B,L]=a.useState(null),Y=x!==h,_=a.useMemo(()=>new TextEncoder().encode(x).byteLength,[x]);c.current=l,I.current=y,g.current=Y;const H=a.useCallback(()=>{I.current||g.current&&!window.confirm(s("team.instructionsDiscard"))||c.current()},[]);a.useEffect(()=>{const R=document.activeElement instanceof HTMLElement?document.activeElement:null;d.current?.focus();const q=m=>{if(m.key==="Escape"&&!I.current){m.preventDefault(),H();return}if(m.key!=="Tab")return;const z=d.current;if(!z)return;const N=[...z.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [href], [tabindex]:not([tabindex="-1"])')];if(N.length===0){m.preventDefault(),z.focus();return}const $=N[0],T=N[N.length-1];m.shiftKey&&document.activeElement===$?(m.preventDefault(),T.focus()):!m.shiftKey&&document.activeElement===T&&(m.preventDefault(),$.focus())};return window.addEventListener("keydown",q),()=>{window.removeEventListener("keydown",q),R?.focus()}},[H]),a.useEffect(()=>{let R=!1;return v(!0),L(null),te(`/api/section-context?section=${encodeURIComponent(n)}`).then(q=>{R||(M(q.text),w(q.text),A(q.updatedAt),O(q.maxBytes),window.setTimeout(()=>i.current?.focus(),0))}).catch(q=>{R||L(q instanceof Error?q.message:String(q))}).finally(()=>{R||v(!1)}),()=>{R=!0}},[n]);const G=async()=>{if(!(_>b)){j(!0),L(null);try{const R=await te(`/api/section-context?section=${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({text:x})});w(R.text),M(R.text),A(R.updatedAt),O(R.maxBytes)}catch(R){L(R instanceof Error?R.message:String(R))}finally{j(!1)}}};return et.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4 sm:p-6",onMouseDown:R=>R.target===R.currentTarget&&H(),children:e.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-labelledby":"section-context-title",tabIndex:-1,className:"animate-pop-in flex max-h-[min(680px,calc(100dvh-2rem))] w-full max-w-[680px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl shadow-black/50 outline-none",children:[e.jsxs("header",{className:"flex items-start justify-between gap-4 border-b border-hairline/40 px-6 pb-4 pt-6 sm:px-8 sm:pt-7",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ut,{size:19,className:"text-accent"}),e.jsx("h2",{id:"section-context-title",className:"text-[20px] font-semibold tracking-[-0.01em] text-ink",children:s("team.instructionsTitle",{name:r})})]}),e.jsx("p",{className:"mt-1.5 max-w-[520px] text-[13px] leading-relaxed text-ink-secondary",children:s("team.instructionsHint")})]}),e.jsx("button",{onClick:H,disabled:y,"aria-label":s("team.instructionsClose"),className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:e.jsx(Be,{size:19})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5 sm:px-8",children:[K?e.jsx("div",{className:"flex min-h-[260px] items-center justify-center text-ink-secondary",children:e.jsx(Re,{size:20,className:"animate-spin","aria-label":s("team.instructionsLoading")})}):e.jsxs(e.Fragment,{children:[e.jsx("textarea",{ref:i,value:x,onChange:R=>M(R.target.value),placeholder:s("team.instructionsPlaceholder"),"aria-label":s("team.instructionsTitle",{name:r}),className:"min-h-[280px] w-full resize-y rounded-xl border border-hairline/60 bg-inset px-4 py-3 font-mono text-[13px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/50"}),e.jsxs("div",{className:"mt-2 flex items-start justify-between gap-4 text-[12px] text-ink-secondary",children:[e.jsxs("span",{children:[s("team.instructionsFactHint")," ",U?` ${s("team.instructionsLastSaved",{time:new Date(U).toLocaleString(Ee())})}`:""]}),e.jsx("span",{className:ne("shrink-0 tabular-nums",_>b&&"text-danger"),children:s("team.instructionsBytes",{bytes:_.toLocaleString(Ee()),limit:b.toLocaleString(Ee())})})]})]}),B&&e.jsx("div",{className:"mt-3 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:B})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-hairline/40 px-6 py-4 sm:px-8",children:[e.jsx("button",{onClick:H,disabled:y,className:"rounded-lg px-3.5 py-2 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:s("common.cancel")}),e.jsxs("button",{onClick:()=>{G()},disabled:K||y||!Y||_>b,className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-40",children:[y?e.jsx(Re,{size:14,className:"animate-spin"}):e.jsx(un,{size:14}),s("team.instructionsSave")]})]})]})}),document.body)}const Gn=1400;function ss(){const{state:n,dispatch:r}=Ne(),{dragProps:l}=St(),d=window.ogb?.remoteClient?.active===!0,i=xt(),c=Vt(),I=Gt()==="people"&&i!==null,[g,x]=a.useState(mn),[M,h]=a.useState(null),[w,b]=a.useState(null),[O,U]=a.useState(null),[A,K]=a.useState(null),[v,y]=a.useState(null),[j,B]=a.useState(null),[L,Y]=a.useState(!1),[_,H]=a.useState(0),[G,R]=a.useState([]),[q,m]=a.useState(null),z=a.useCallback(()=>m(null),[]),[N,$]=a.useState(null),T=a.useRef(N);T.current=N,a.useEffect(()=>()=>T.current?.resolve(!1),[]);const P=a.useMemo(()=>n.bots.filter(f=>!f.hidden),[n.bots]),se=a.useMemo(()=>{const f=[...new Set([...n.sections??[],...n.groups.flatMap(k=>k.section?[k.section]:[])])],o=k=>k===""?-1:f.includes(k)?f.indexOf(k):f.length;return pn(P,f).sort((k,J)=>o(k.key)-o(J.key))},[P,n.sections,n.groups]),S=a.useMemo(()=>fn(P,g),[P,g]),F=P.some(f=>f.computer==="cloud"&&f.cloudBackend!=="vps")||G.some(f=>f.section!==null),{show:ee,loaded:ie,choose:re}=An(F),ue=En(!d&&ie&&ee),[de,fe]=a.useState([]),[me,he]=a.useState(null),ge=a.useRef(void 0),ve=a.useCallback(f=>{window.clearTimeout(ge.current),he(o=>({botIds:f,key:(o?.key??0)+1})),ge.current=window.setTimeout(()=>he(null),Gn)},[]);a.useEffect(()=>()=>window.clearTimeout(ge.current),[]);const Se=a.useMemo(()=>se.map(f=>({key:f.key,name:f.name,count:f.chiefs.length+f.members.length})),[se]),oe=a.useCallback(async(f=!1)=>{try{x(await te("/api/team-map",f?{background:f}:void 0)),b(null)}catch(o){b(o instanceof Error?o.message:String(o))}},[]);a.useEffect(()=>{oe();const f=window.setInterval(()=>{document.visibilityState==="visible"&&oe(!0)},3e3);return()=>window.clearInterval(f)},[oe]);const pe=async(f,o)=>{h(null);try{const k=await te("/api/sidebar-sections",{method:"POST",body:JSON.stringify({name:o,botIds:[f.id]})});r({type:"sections",sections:k.sections});for(const J of k.bots)r({type:"botPatched",bot:J})}catch(k){throw h(k instanceof Error?k.message:String(k)),k}},be=(f,o)=>new Promise(k=>{T.current?.resolve(!1),$({bot:f,destination:o,resolve:k})}),ce=a.useCallback(()=>{T.current?.resolve(!1),$(null)},[]);return e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col overflow-hidden bg-app text-ink",children:[e.jsxs("header",{...l,className:"flex shrink-0 flex-wrap items-center justify-between gap-3 border-b border-hairline/40 px-6 py-4 max-md:pl-12",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Wt,{size:18,className:"text-ink-secondary"}),e.jsx("h1",{className:"text-[17px] font-semibold",children:s("canvas.title")}),e.jsx("span",{className:"ml-1 text-[11px] text-ink-secondary",children:hn(P.length)})]}),e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:s("canvas.description")})]}),i&&e.jsx(Qt,{}),!d&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>re(!ee),"aria-pressed":ee,title:s("canvas.showComputersHint"),className:ne("flex items-center gap-2 rounded-lg border px-3 py-2 text-[12px] font-medium transition-colors",ee?"border-accent/40 bg-accent/10 text-ink":"border-hairline/60 bg-panel text-ink-secondary hover:bg-control hover:text-ink"),children:[e.jsx("span",{"aria-hidden":!0,className:ne("relative h-4 w-7 shrink-0 rounded-full transition-colors",ee?"bg-accent":"bg-control"),children:e.jsx("span",{className:ne("absolute top-0.5 size-3 rounded-full bg-white shadow-sm transition-[left]",ee?"left-3.5":"left-0.5")})}),s("canvas.showComputers")]}),e.jsx("button",{onClick:()=>Y(f=>!f),"aria-label":s("canvas.computers"),"aria-expanded":L,className:"rounded-lg p-2 text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(Oe,{size:17})}),c!==!1&&e.jsxs("details",{className:"relative",onBlur:f=>{f.currentTarget.contains(f.relatedTarget)||f.currentTarget.removeAttribute("open")},onKeyDown:f=>{f.key==="Escape"&&(f.currentTarget.removeAttribute("open"),f.currentTarget.querySelector("summary")?.focus())},children:[e.jsxs("summary",{"aria-label":s("canvas.addToMap"),className:"flex cursor-pointer list-none items-center gap-1.5 rounded-lg border border-hairline/60 bg-panel px-3 py-2 text-[12px] font-medium hover:bg-control [&::-webkit-details-marker]:hidden",children:[e.jsx(Ke,{size:14})," ",s("common.add")]}),e.jsxs("div",{className:"absolute right-0 top-full z-40 mt-2 w-52 rounded-xl border border-hairline/60 bg-panel p-1.5 shadow-xl",onClick:f=>{const o=f.currentTarget.closest("details");o?.querySelector("summary")?.focus(),o?.removeAttribute("open")},children:[e.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-left text-[12px] hover:bg-control",onClick:()=>y({}),children:[e.jsx(dt,{size:14}),s("team.create")]}),e.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-left text-[12px] hover:bg-control",onClick:()=>{Y(!0),H(f=>f+1)},children:[e.jsx(Je,{size:14}),s("canvas.cloudComputer")]}),Zt("vm",n.config)&&e.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-left text-[12px] hover:bg-control",onClick:()=>r({type:"toggleAppSettings",section:"computer",open:!0}),children:[e.jsx(Oe,{size:14}),s("canvas.localVm")]})]})]})]})]}),(M||w)&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center justify-between gap-3 border-b border-danger/20 bg-danger/10 px-6 py-2 text-[12px] text-danger",children:[M||w,e.jsx("button",{"aria-label":s("common.close"),className:"rounded p-1 hover:bg-danger/10",onClick:()=>{h(null),b(null)},children:e.jsx(Be,{size:14})})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[e.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1",children:[I?e.jsx(en,{bots:P}):e.jsx($n,{sections:se,canManage:!d&&c!==!1,onMove:be,taggedBotIds:de,sent:me,bottomInset:P.length?96:0,connectedBotIds:n.settingsOpen?S.flatMap(f=>f.sourceBotId===n.selectedId?[f.targetBotId]:f.targetBotId===n.selectedId?[f.sourceBotId]:[]):[],onComputer:f=>Ye(r,"access",{botId:f.id}),computers:ee&&ie&&!d?ue.computers:void 0,computerFrames:ue.frames,onOpenComputer:f=>f.kind==="team"?Y(!0):r({type:"toggleComputer",open:!0,botId:f.id}),teamComputers:Object.fromEntries(G.filter(f=>f.section!==null).map(f=>[f.section,{name:f.name,state:f.state}])),onTeamComputer:()=>Y(!0),onComputerDrop:(f,o)=>{d||(Y(!0),m({id:f,section:o}))},onInstructions:(f,o)=>U({section:f,label:o}),onMemory:(f,o)=>K({section:f,label:o}),onEditTeam:(f,o)=>y({section:f,rename:o}),onDeleteTeam:B,isEmpty:f=>![...n.bots,...n.groups].some(o=>o.section?.trim()===f)}),P.length>0&&e.jsx(Yn,{bots:P,teams:Se,onTagged:fe,onSent:ve})]}),!d&&e.jsx(Un,{open:L,createRequest:_,drop:q,sections:se,onClose:()=>Y(!1),onDropHandled:z,onChange:R})]}),S.length>0&&e.jsxs("details",{className:"shrink-0 border-t border-hairline/40 bg-panel px-6 py-3",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:[s("canvas.whoHandsOn")," · ",S.length]}),e.jsx("div",{className:"mt-3 max-h-48 space-y-2 overflow-y-auto",children:S.slice(0,12).map(f=>e.jsx(Jn,{edge:f,bots:P},`${f.sourceBotId}:${f.targetBotId}`))})]}),O&&e.jsx(Vn,{section:O.section,label:O.label,onClose:()=>U(null)}),v&&e.jsx(tn,{...v,onClose:()=>y(null)}),A&&e.jsx(_n,{...A,onClose:()=>K(null)},A.section),e.jsx(Ve,{open:N!==null,tone:"neutral",title:s("canvas.moveConfirmTitle",{name:N?.bot.name??s("canvas.bot"),team:N?.destination||s("settings.section.general")}),body:s("canvas.moveConfirmBody"),confirmLabel:s("canvas.moveConfirm"),onCancel:ce,onConfirm:()=>{const f=T.current;f&&($(null),pe(f.bot,f.destination).then(()=>f.resolve(!0),()=>f.resolve(!1)))}}),e.jsx(Ve,{open:j!==null,title:s("team.deleteTitle",{name:j??""}),body:s("team.deleteKeepBotsDescription"),confirmLabel:s("team.delete"),onCancel:()=>B(null),onConfirm:()=>{const f=j;B(null),f&&te(`/api/sidebar-sections?section=${encodeURIComponent(f)}`,{method:"DELETE"}).then(({sections:o})=>r({type:"sections",sections:o})).catch(o=>h(o instanceof Error?o.message:String(o)))}})]})}export{Jn as EdgeRow,Vn as SectionContextDialog,ss as TeamMapPage};
@@ -1 +0,0 @@
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-Cm26P6hN.js";import{C as Ee,K as ze,B as Te,c as Me,d as Le,P as ce,W as Oe}from"./PlacesRail-DnedL3jM.js";import{cs as ge,ct as Pe,cu as Fe,cv as oe,$ as $e,u as G,cw as We,cx as Ye,cy as ee,cz as ye,cA as de,cB as _e,cC as ke,cD as Ge,cE as He,cF as Ue,cG as Je,bu as Ke,cH as Qe,cI as je,cJ as ue,cK as qe,cL as Ve,T as Xe,cM as Ze,cN as et,cO as Z,cP as ve,cj as we,cQ as tt,cR as ne,cS as st,cT as nt,cU as Ne,n as W,cV as Ce,cW as at,cX as it,cY as ot,cZ as xe,c_ as rt,c$ as lt,d0 as dt,d1 as ct,D as re,w as ut,d2 as xt,bI as pt,d3 as mt,bG as ht,d4 as bt,d5 as ft,S as Se,d6 as gt,d7 as yt}from"./App-DPG1sq1r.js";import{AppEventEditor as kt}from"./AppEventEditor-QyHQdp7V.js";import{C as Ie,S as jt}from"./MenuMotion-C1J3xC0E.js";import{C as vt,E as wt,Q as Nt,b as Ct,H as St,R as It}from"./RoutinesPage-BWJ5Z1Sk.js";import{WebhookEditor as Bt}from"./WebhookTrigger-w_Pjci5K.js";import"./monitor-FKQbSjca.js";import"./index-BkcZ5EE3.js";import"./remote-desktop-DDRRx8uY.js";import"./ProIntroduction-B1QqcZmr.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}=G();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,q="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}=G(),[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(Ge[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?He(f.id,o.webhookAttempts):[],T=f?Ue(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(q,"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:Ke(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(q,"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(q,"border border-hairline/50 bg-control text-ink hover:bg-raised-hover"),children:[n.enabled?e.jsx(qe,{size:14}):e.jsx(ue,{size:14}),n.enabled?t("automations.pause"):t("automations.resume")]}),e.jsxs("button",{type:"button",onClick:g,className:S(q,"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(q,"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}=G(),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,H=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]),U=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))},K=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:K(i===1),children:t("routines.view.day")}),e.jsx("button",{type:"button","aria-pressed":i===7,onClick:()=>x(7),className:K(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:H,onCreate:a=>{I(null),w(a)},onMove:(a,s)=>{U(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}=G(),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}=G(),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}=G(),{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)),H=D.length>=Wt&&new Set(D.map(s=>s.botId)).size>1,V=mt(D.filter(s=>u(s.botId)&&(!H||v==="all"||s.botId===v))),L=D.find(s=>s.id===j)??null,O=s=>yt(s,M(s.botId)),U=h.windowChrome==="mac-inset",se=U?{WebkitAppRegion:"drag"}:void 0,X=U?{WebkitAppRegion:"no-drag"}:void 0,J=c?.kind==="schedule"?l.routines.find(s=>s.id===c.id):void 0,K=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",U&&!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")})]}),H&&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:H?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"&&(K||!c.id)&&e.jsx(Bt,{webhook:K,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 +0,0 @@
1
- import{U as a,C as n}from"./mermaid.core-Cn7buzY3.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
@@ -1 +0,0 @@
1
- import{R}from"./styles-Cm26P6hN.js";var le=Object.defineProperty,D=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,Y=(u,l,s)=>l in u?le(u,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):u[l]=s,z=(u,l)=>{for(var s in l||(l={}))V.call(l,s)&&Y(u,s,l[s]);if(D)for(var s of D(l))x.call(l,s)&&Y(u,s,l[s]);return u},U=(u,l)=>{var s={};for(var c in u)V.call(u,c)&&l.indexOf(c)<0&&(s[c]=u[c]);if(u!=null&&D)for(var c of D(u))l.indexOf(c)<0&&x.call(u,c)&&(s[c]=u[c]);return s};var S;(u=>{const l=class g{constructor(e,n,t,r){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<g.MIN_VERSION||e>g.MAX_VERSION)throw new RangeError("Version value out of range");if(r<-1||r>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let o=[];for(let i=0;i<this.size;i++)o.push(!1);for(let i=0;i<this.size;i++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();const a=this.addEccAndInterleave(t);if(this.drawCodewords(a),r==-1){let i=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const h=this.getPenaltyScore();h<i&&(r=m,i=h),this.applyMask(m)}}E(0<=r&&r<=7),this.mask=r,this.applyMask(r),this.drawFormatBits(r),this.isFunction=[]}static encodeText(e,n){const t=u.QrSegment.makeSegments(e);return g.encodeSegments(t,n)}static encodeBinary(e,n){const t=u.QrSegment.makeBytes(e);return g.encodeSegments([t],n)}static encodeSegments(e,n,t=1,r=40,o=-1,a=!0){if(!(g.MIN_VERSION<=t&&t<=r&&r<=g.MAX_VERSION)||o<-1||o>7)throw new RangeError("Invalid value");let i,m;for(i=t;;i++){const d=g.getNumDataCodewords(i,n)*8,w=A.getTotalBits(e,i);if(w<=d){m=w;break}if(i>=r)throw new RangeError("Data too long")}for(const d of[g.Ecc.MEDIUM,g.Ecc.QUARTILE,g.Ecc.HIGH])a&&m<=g.getNumDataCodewords(i,d)*8&&(n=d);let h=[];for(const d of e){s(d.mode.modeBits,4,h),s(d.numChars,d.mode.numCharCountBits(i),h);for(const w of d.getData())h.push(w)}E(h.length==m);const P=g.getNumDataCodewords(i,n)*8;E(h.length<=P),s(0,Math.min(4,P-h.length),h),s(0,(8-h.length%8)%8,h),E(h.length%8==0);for(let d=236;h.length<P;d^=253)s(d,8,h);let p=[];for(;p.length*8<h.length;)p.push(0);return h.forEach((d,w)=>p[w>>>3]|=d<<7-(w&7)),new g(i,n,p,o)}getModule(e,n){return 0<=e&&e<this.size&&0<=n&&n<this.size&&this.modules[n][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),n=e.length;for(let t=0;t<n;t++)for(let r=0;r<n;r++)t==0&&r==0||t==0&&r==n-1||t==n-1&&r==0||this.drawAlignmentPattern(e[t],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const n=this.errorCorrectionLevel.formatBits<<3|e;let t=n;for(let o=0;o<10;o++)t=t<<1^(t>>>9)*1335;const r=(n<<10|t)^21522;E(r>>>15==0);for(let o=0;o<=5;o++)this.setFunctionModule(8,o,c(r,o));this.setFunctionModule(8,7,c(r,6)),this.setFunctionModule(8,8,c(r,7)),this.setFunctionModule(7,8,c(r,8));for(let o=9;o<15;o++)this.setFunctionModule(14-o,8,c(r,o));for(let o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,c(r,o));for(let o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,c(r,o));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;const n=this.version<<12|e;E(n>>>18==0);for(let t=0;t<18;t++){const r=c(n,t),o=this.size-11+t%3,a=Math.floor(t/3);this.setFunctionModule(o,a,r),this.setFunctionModule(a,o,r)}}drawFinderPattern(e,n){for(let t=-4;t<=4;t++)for(let r=-4;r<=4;r++){const o=Math.max(Math.abs(r),Math.abs(t)),a=e+r,i=n+t;0<=a&&a<this.size&&0<=i&&i<this.size&&this.setFunctionModule(a,i,o!=2&&o!=4)}}drawAlignmentPattern(e,n){for(let t=-2;t<=2;t++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,n+t,Math.max(Math.abs(r),Math.abs(t))!=1)}setFunctionModule(e,n,t){this.modules[n][e]=t,this.isFunction[n][e]=!0}addEccAndInterleave(e){const n=this.version,t=this.errorCorrectionLevel;if(e.length!=g.getNumDataCodewords(n,t))throw new RangeError("Invalid argument");const r=g.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][n],o=g.ECC_CODEWORDS_PER_BLOCK[t.ordinal][n],a=Math.floor(g.getNumRawDataModules(n)/8),i=r-a%r,m=Math.floor(a/r);let h=[];const P=g.reedSolomonComputeDivisor(o);for(let d=0,w=0;d<r;d++){let N=e.slice(w,w+m-o+(d<i?0:1));w+=N.length;const F=g.reedSolomonComputeRemainder(N,P);d<i&&N.push(0),h.push(N.concat(F))}let p=[];for(let d=0;d<h[0].length;d++)h.forEach((w,N)=>{(d!=m-o||N>=i)&&p.push(w[d])});return E(p.length==a),p}drawCodewords(e){if(e.length!=Math.floor(g.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let r=0;r<this.size;r++)for(let o=0;o<2;o++){const a=t-o,m=(t+1&2)==0?this.size-1-r:r;!this.isFunction[m][a]&&n<e.length*8&&(this.modules[m][a]=c(e[n>>>3],7-(n&7)),n++)}}E(n==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let t=0;t<this.size;t++){let r;switch(e){case 0:r=(t+n)%2==0;break;case 1:r=n%2==0;break;case 2:r=t%3==0;break;case 3:r=(t+n)%3==0;break;case 4:r=(Math.floor(t/3)+Math.floor(n/2))%2==0;break;case 5:r=t*n%2+t*n%3==0;break;case 6:r=(t*n%2+t*n%3)%2==0;break;case 7:r=((t+n)%2+t*n%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[n][t]&&r&&(this.modules[n][t]=!this.modules[n][t])}}getPenaltyScore(){let e=0;for(let o=0;o<this.size;o++){let a=!1,i=0,m=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[o][h]==a?(i++,i==5?e+=g.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,m),a||(e+=this.finderPenaltyCountPatterns(m)*g.PENALTY_N3),a=this.modules[o][h],i=1);e+=this.finderPenaltyTerminateAndCount(a,i,m)*g.PENALTY_N3}for(let o=0;o<this.size;o++){let a=!1,i=0,m=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[h][o]==a?(i++,i==5?e+=g.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,m),a||(e+=this.finderPenaltyCountPatterns(m)*g.PENALTY_N3),a=this.modules[h][o],i=1);e+=this.finderPenaltyTerminateAndCount(a,i,m)*g.PENALTY_N3}for(let o=0;o<this.size-1;o++)for(let a=0;a<this.size-1;a++){const i=this.modules[o][a];i==this.modules[o][a+1]&&i==this.modules[o+1][a]&&i==this.modules[o+1][a+1]&&(e+=g.PENALTY_N2)}let n=0;for(const o of this.modules)n=o.reduce((a,i)=>a+(i?1:0),n);const t=this.size*this.size,r=Math.ceil(Math.abs(n*20-t*10)/t)-1;return E(0<=r&&r<=9),e+=r*g.PENALTY_N4,E(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,n=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let t=[6];for(let r=this.size-7;t.length<e;r-=n)t.splice(1,0,r);return t}}static getNumRawDataModules(e){if(e<g.MIN_VERSION||e>g.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return E(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(g.getNumRawDataModules(e)/8)-g.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*g.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let n=[];for(let r=0;r<e-1;r++)n.push(0);n.push(1);let t=1;for(let r=0;r<e;r++){for(let o=0;o<n.length;o++)n[o]=g.reedSolomonMultiply(n[o],t),o+1<n.length&&(n[o]^=n[o+1]);t=g.reedSolomonMultiply(t,2)}return n}static reedSolomonComputeRemainder(e,n){let t=n.map(r=>0);for(const r of e){const o=r^t.shift();t.push(0),n.forEach((a,i)=>t[i]^=g.reedSolomonMultiply(a,o))}return t}static reedSolomonMultiply(e,n){if(e>>>8||n>>>8)throw new RangeError("Byte out of range");let t=0;for(let r=7;r>=0;r--)t=t<<1^(t>>>7)*285,t^=(n>>>r&1)*e;return E(t>>>8==0),t}finderPenaltyCountPatterns(e){const n=e[1];E(n<=this.size*3);const t=n>0&&e[2]==n&&e[3]==n*3&&e[4]==n&&e[5]==n;return(t&&e[0]>=n*4&&e[6]>=n?1:0)+(t&&e[6]>=n*4&&e[0]>=n?1:0)}finderPenaltyTerminateAndCount(e,n,t){return e&&(this.finderPenaltyAddHistory(n,t),n=0),n+=this.size,this.finderPenaltyAddHistory(n,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,n){n[0]==0&&(e+=this.size),n.pop(),n.unshift(e)}};l.MIN_VERSION=1,l.MAX_VERSION=40,l.PENALTY_N1=3,l.PENALTY_N2=3,l.PENALTY_N3=40,l.PENALTY_N4=10,l.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],l.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],u.QrCode=l;function s(C,e,n){if(e<0||e>31||C>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)n.push(C>>>t&1)}function c(C,e){return(C>>>e&1)!=0}function E(C){if(!C)throw new Error("Assertion error")}const f=class M{constructor(e,n,t){if(this.mode=e,this.numChars=n,this.bitData=t,n<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}static makeBytes(e){let n=[];for(const t of e)s(t,8,n);return new M(M.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!M.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let t=0;t<e.length;){const r=Math.min(e.length-t,3);s(parseInt(e.substring(t,t+r),10),r*3+1,n),t+=r}return new M(M.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!M.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n=[],t;for(t=0;t+2<=e.length;t+=2){let r=M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t))*45;r+=M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),s(r,11,n)}return t<e.length&&s(M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new M(M.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return e==""?[]:M.isNumeric(e)?[M.makeNumeric(e)]:M.isAlphanumeric(e)?[M.makeAlphanumeric(e)]:[M.makeBytes(M.toUtf8ByteArray(e))]}static makeEci(e){let n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)s(e,8,n);else if(e<16384)s(2,2,n),s(e,14,n);else if(e<1e6)s(6,3,n),s(e,21,n);else throw new RangeError("ECI assignment value out of range");return new M(M.Mode.ECI,0,n)}static isNumeric(e){return M.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return M.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,n){let t=0;for(const r of e){const o=r.mode.numCharCountBits(n);if(r.numChars>=1<<o)return 1/0;t+=4+o+r.bitData.length}return t}static toUtf8ByteArray(e){e=encodeURI(e);let n=[];for(let t=0;t<e.length;t++)e.charAt(t)!="%"?n.push(e.charCodeAt(t)):(n.push(parseInt(e.substring(t+1,t+3),16)),t+=2);return n}};f.NUMERIC_REGEX=/^[0-9]*$/,f.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,f.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let A=f;u.QrSegment=f})(S||(S={}));(u=>{(l=>{const s=class{constructor(E,f){this.ordinal=E,this.formatBits=f}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),l.Ecc=s})(u.QrCode||(u.QrCode={}))})(S||(S={}));(u=>{(l=>{const s=class{constructor(E,f){this.modeBits=E,this.numBitsCharCount=f}numCharCountBits(E){return this.numBitsCharCount[Math.floor((E+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),l.Mode=s})(u.QrSegment||(u.QrSegment={}))})(S||(S={}));var O=S;var ae={L:O.QrCode.Ecc.LOW,M:O.QrCode.Ecc.MEDIUM,Q:O.QrCode.Ecc.QUARTILE,H:O.QrCode.Ecc.HIGH},X=128,K="L",W="#FFFFFF",j="#000000",Z=!1,J=1,ce=4,ue=0,he=.1;function q(u,l=0){const s=[];return u.forEach(function(c,E){let f=null;c.forEach(function(A,C){if(!A&&f!==null){s.push(`M${f+l} ${E+l}h${C-f}v1H${f+l}z`),f=null;return}if(C===c.length-1){if(!A)return;f===null?s.push(`M${C+l},${E+l} h1v1H${C+l}z`):s.push(`M${f+l},${E+l} h${C+1-f}v1H${f+l}z`);return}A&&f===null&&(f=C)})}),s.join("")}function ee(u,l){return u.slice().map((s,c)=>c<l.y||c>=l.y+l.h?s:s.map((E,f)=>f<l.x||f>=l.x+l.w?E:!1))}function fe(u,l,s,c){if(c==null)return null;const E=u.length+s*2,f=Math.floor(l*he),A=E/l,C=(c.width||f)*A,e=(c.height||f)*A,n=c.x==null?u.length/2-C/2:c.x*A,t=c.y==null?u.length/2-e/2:c.y*A,r=c.opacity==null?1:c.opacity;let o=null;if(c.excavate){let i=Math.floor(n),m=Math.floor(t),h=Math.ceil(C+n-i),P=Math.ceil(e+t-m);o={x:i,y:m,w:h,h:P}}const a=c.crossOrigin;return{x:n,y:t,h:e,w:C,excavation:o,opacity:r,crossOrigin:a}}function de(u,l){return l!=null?Math.max(Math.floor(l),0):u?ce:ue}function te({value:u,level:l,minVersion:s,includeMargin:c,marginSize:E,imageSettings:f,size:A,boostLevel:C}){let e=R.useMemo(()=>{const i=(Array.isArray(u)?u:[u]).reduce((m,h)=>(m.push(...O.QrSegment.makeSegments(h)),m),[]);return O.QrCode.encodeSegments(i,ae[l],s,void 0,void 0,C)},[u,l,s,C]);const{cells:n,margin:t,numCells:r,calculatedImageSettings:o}=R.useMemo(()=>{let a=e.getModules();const i=de(c,E),m=a.length+i*2,h=fe(a,A,i,f);return{cells:a,margin:i,numCells:m,calculatedImageSettings:h}},[e,A,f,c,E]);return{qrcode:e,margin:t,cells:n,numCells:r,calculatedImageSettings:o}}var me=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ge=R.forwardRef(function(l,s){const c=l,{value:E,size:f=X,level:A=K,bgColor:C=W,fgColor:e=j,includeMargin:n=Z,minVersion:t=J,boostLevel:r,marginSize:o,imageSettings:a}=c,m=U(c,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:h}=m,P=U(m,["style"]),p=a?.src,d=R.useRef(null),w=R.useRef(null),N=R.useCallback(y=>{d.current=y,typeof s=="function"?s(y):s&&(s.current=y)},[s]),[F,_]=R.useState(!1),{margin:L,cells:T,numCells:B,calculatedImageSettings:v}=te({value:E,level:A,minVersion:t,boostLevel:r,includeMargin:n,marginSize:o,imageSettings:a,size:f});R.useEffect(()=>{if(d.current!=null){const y=d.current,I=y.getContext("2d");if(!I)return;let k=T;const b=w.current,H=v!=null&&b!==null&&b.complete&&b.naturalHeight!==0&&b.naturalWidth!==0;H&&v.excavation!=null&&(k=ee(T,v.excavation));const $=window.devicePixelRatio||1;y.height=y.width=f*$;const G=f/B*$;I.scale(G,G),I.fillStyle=C,I.fillRect(0,0,B,B),I.fillStyle=e,me?I.fill(new Path2D(q(k,L))):T.forEach(function(re,oe){re.forEach(function(se,ie){se&&I.fillRect(ie+L,oe+L,1,1)})}),v&&(I.globalAlpha=v.opacity),H&&I.drawImage(b,v.x+L,v.y+L,v.w,v.h)}}),R.useEffect(()=>{_(!1)},[p]);const ne=z({height:f,width:f},h);let Q=null;return p!=null&&(Q=R.createElement("img",{src:p,key:p,style:{display:"none"},onLoad:()=>{_(!0)},ref:w,crossOrigin:v?.crossOrigin})),R.createElement(R.Fragment,null,R.createElement("canvas",z({style:ne,height:f,width:f,ref:N,role:"img"},P)),Q)});ge.displayName="QRCodeCanvas";var Ee=R.forwardRef(function(l,s){const c=l,{value:E,size:f=X,level:A=K,bgColor:C=W,fgColor:e=j,includeMargin:n=Z,minVersion:t=J,boostLevel:r,title:o,marginSize:a,imageSettings:i}=c,m=U(c,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:h,cells:P,numCells:p,calculatedImageSettings:d}=te({value:E,level:A,minVersion:t,boostLevel:r,includeMargin:n,marginSize:a,imageSettings:i,size:f});let w=P,N=null;i!=null&&d!=null&&(d.excavation!=null&&(w=ee(P,d.excavation)),N=R.createElement("image",{href:i.src,height:d.h,width:d.w,x:d.x+h,y:d.y+h,preserveAspectRatio:"none",opacity:d.opacity,crossOrigin:d.crossOrigin}));const F=q(w,h);return R.createElement("svg",z({height:f,width:f,viewBox:`0 0 ${p} ${p}`,ref:s,role:"img"},m),!!o&&R.createElement("title",null,o),R.createElement("path",{fill:C,d:`M0,0 h${p}v${p}H0z`,shapeRendering:"crispEdges"}),R.createElement("path",{fill:e,d:F,shapeRendering:"crispEdges"}),N)});Ee.displayName="QRCodeSVG";export{Ee as Q};
@@ -1,8 +0,0 @@
1
- import{c as r,s as e}from"./flowDiagram-OXPTDLAJ-CkF5DDZj.js";import{_ as o}from"./mermaid.core-Cn7buzY3.js";import"./chunk-5VM5RSS4-B9VKa5BI.js";import"./chunk-XXDRQBXY-gUdzE10_.js";import"./chunk-KQW6MTUR-BMp5NWQw.js";import"./chunk-7TKQ45FW-CrgJv6B8.js";import"./channel-_uzpXF9W.js";import"./styles-Cm26P6hN.js";import"./step-CkmJJ7wq.js";var a=o(t=>`${e(t)}
2
- .swimlane.cluster:not([data-color-id]) rect {
3
- stroke: ${t.clusterBorder} !important;
4
- }
5
- [data-look="neo"].cluster rect {
6
- filter: none;
7
- }
8
- `,"getStyles"),m=a,y=r({styles:m});export{y as diagram};