limixbot 0.3.97 → 0.3.98

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 (132) hide show
  1. package/dist/assets/{ActivityPanel-Ce3WOtjK.js → ActivityPanel-CoXniiKe.js} +1 -1
  2. package/dist/assets/{App-BBIWFBTX.js → App-JBHRknbK.js} +120 -119
  3. package/dist/assets/{AppEventEditor-D0gWwBWQ.js → AppEventEditor-C1ePu4TZ.js} +1 -1
  4. package/dist/assets/BotSettingsDialog-3HA523QI.js +16 -0
  5. package/dist/assets/{BrowserPanel-B4rA8HgQ.js → BrowserPanel-BncAUjhw.js} +2 -2
  6. package/dist/assets/{BrowserProfilesManager-BHLrXwdR.js → BrowserProfilesManager-nXxdo8at.js} +1 -1
  7. package/dist/assets/CloudAddDialog-DrQFVN3k.js +1 -0
  8. package/dist/assets/ComputerFilesPane--23192mW.js +1 -0
  9. package/dist/assets/ComputerPanel-f0DBK1BM.js +2 -0
  10. package/dist/assets/{DataPanel-4iVu-JZJ.js → DataPanel-Qx8ejB2v.js} +1 -1
  11. package/dist/assets/{DesktopViewer-C0i68loQ.js → DesktopViewer-B-tK0Oxe.js} +1 -1
  12. package/dist/assets/{GrokMoveDialog-CSqPlRkr.js → GrokMoveDialog-DyLziipn.js} +1 -1
  13. package/dist/assets/{InspectorPanel-BzlC1uIe.js → InspectorPanel-BeyN-3hE.js} +2 -2
  14. package/dist/assets/KeyboardShortcutsModal-CoJHdiTo.js +1 -0
  15. package/dist/assets/{LimixResizeHandles-BKkhoxk3.js → LimixResizeHandles-DF3sBE58.js} +1 -1
  16. package/dist/assets/{LiveDesktop-BAt9kTnK.js → LiveDesktop-B6bCA1Sy.js} +1 -1
  17. package/dist/assets/LocalVmWorkspace-_efBejue.js +1 -0
  18. package/dist/assets/MacLocalControl-CWFg24WD.js +1 -0
  19. package/dist/assets/{MarkdownFilePreview-BZStpotV.js → MarkdownFilePreview-By0LvF5k.js} +1 -1
  20. package/dist/assets/{MenuMotion-BcyCOXoC.js → MenuMotion-C5SnaLCp.js} +1 -1
  21. package/dist/assets/NewBotDialog-CRH2mfBZ.js +1 -0
  22. package/dist/assets/{PhoneAppDialog-CyuHiqC8.js → PhoneAppDialog-Bk7IXpmZ.js} +1 -1
  23. package/dist/assets/PlacesRail-fsCwAmTh.js +1 -0
  24. package/dist/assets/{PluginsPanel-DI7RFtQY.js → PluginsPanel-DLvJLTjJ.js} +4 -4
  25. package/dist/assets/{ProIntroduction-YElEwlq1.js → ProIntroduction-BJOrhauU.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-D9vINstQ.js → RemoteAgentSettingsPanel-DWwydp6H.js} +1 -1
  27. package/dist/assets/RoomPanel-Ci_6NkIf.js +2 -0
  28. package/dist/assets/{RoutinesPage-Ca-IZwR3.js → RoutinesPage-C6V9sNCi.js} +2 -2
  29. package/dist/assets/{SettingsModal-DqiWigf_.js → SettingsModal-DJ1NDwtg.js} +4 -4
  30. package/dist/assets/{ShareTeamDialog-CrPLELxa.js → ShareTeamDialog-Ccy_4evB.js} +1 -1
  31. package/dist/assets/{SignedInSites-x_vu3svk.js → SignedInSites-dd6dOslW.js} +1 -1
  32. package/dist/assets/{TeamLibraryPanel-C0COcPVi.js → TeamLibraryPanel-DTPEo4rO.js} +2 -2
  33. package/dist/assets/TeamMapPage-CC6LOX_3.js +1 -0
  34. package/dist/assets/TriggersPage-B97r6c0P.js +1 -0
  35. package/dist/assets/VisibilitySection-B7Kw8iq4.js +22 -0
  36. package/dist/assets/{WebhookTrigger-CQn-8Bfs.js → WebhookTrigger-Dx9K79YQ.js} +1 -1
  37. package/dist/assets/WorksOnGrid-Dfvd28u3.js +1 -0
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-SdtgfdOX.js → abnfDiagram-YUKMZFIV-DAGd1DeN.js} +1 -1
  39. package/dist/assets/{activity-Cii5qqn7.js → activity-Dpky-sAb.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-DX0CW1VW.js → architectureDiagram-47P4ROYG-BU67j-gE.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-CVurEHCS.js → blockDiagram-E7TT5TSB-C385GUrT.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-vzVgMMaW.js → c4Diagram-CRA5TL53-DFrj77dT.js} +1 -1
  43. package/dist/assets/{calendar-days-ClO6PWuq.js → calendar-days-6SuCoh1k.js} +1 -1
  44. package/dist/assets/channel-DuMEOXSp.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-Dva6jhfl.js → chunk-2Q5K7J3B-D7Jr7bxK.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-Sbm-QR_j.js → chunk-5VM5RSS4-C2asukj_.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-Df2yRELF.js → chunk-7TKQ45FW-D8B9pFzM.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-TZhODsHK.js → chunk-AW2ZBBNX-gTP7048c.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-BilLYokr.js → chunk-FVRAUYC3-DUhUbb-o.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-BiUzo2Ja.js → chunk-HTAEGDNF-CHirxI__.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-CBa2nycY.js → chunk-JWPE2WC7-BsfTkZQ_.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-D4nWUeri.js → chunk-KQW6MTUR-Bx7xZ6AB.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-Cf3FkCu1.js → chunk-XXDRQBXY-wjUEshff.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-CjI3noDN.js → classDiagram-v2-K4WV4PDN-BoMql4K0.js} +1 -1
  55. package/dist/assets/{coins-uyi3_IfX.js → coins-D0aBBxmT.js} +1 -1
  56. package/dist/assets/{core-BEBXpx4K.js → core-01gcymBq.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-gRmfc_8k.js → cose-bilkent-JH36ORCC-BjFby5vO.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-eICftSA1.js → cynefin-EF2NZ3EQ-DU1kDHzF.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-DfIFWH8k.js → cynefinDiagram-3GCD6N5R-DIfxfSqz.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-4SucTq4W.js → dagre-W4DXFKR2-u1ftnmLW.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-D6xmr465.js → diagram-2UJZ2QOL-BwzyxeHi.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-BaQ-8PL6.js → diagram-OVF4WLC6-DT2pXJwo.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-CTYfFw_F.js → diagram-PFPMY2P6-5CpBzv3A.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-D2wkebAn.js → diagram-UMYRVEAY-BnoUKoPV.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-Cs8OM-kp.js → diagram-YEKJPTXX-CrarxMDx.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-BaFhDAmM.js → diagram-ZIFT7M5P-B5KLaxW9.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-B4SzePMu.js → ebnfDiagram-VR2GEFS7-BA9zJAqe.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-EflZvzEg.js → elk-IJKZMXRS-ubPXDENR.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-DRrHoV_M.js → erDiagram-O2IAPWRE-Nr0w3uDF.js} +1 -1
  70. package/dist/assets/{file-up-DLOjehra.js → file-up-DK0u_g9g.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-BF0VD0yL.js → flowDiagram-OXPTDLAJ-CfPLYj7k.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI--iGggAeo.js → ganttDiagram-R7TSEDQI-CLWr1YKt.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-17tu6uYz.js → gitGraphDiagram-XJZIOB7I-DkBwb9tn.js} +1 -1
  74. package/dist/assets/{import-name-B2N5mYM1.js → import-name-CACT_zPn.js} +1 -1
  75. package/dist/assets/{index-DBqlNqGW.js → index-B7sMeTFe.js} +1 -1
  76. package/dist/assets/{index-BIvjGJcC.js → index-C1x8eZ6l.js} +3 -3
  77. package/dist/assets/{infoDiagram-5W2HQ5XZ-DaPIqyPz.js → infoDiagram-5W2HQ5XZ-BYuTEDzO.js} +1 -1
  78. package/dist/assets/{ishikawaDiagram-K3B6WC7H-B-ZUvlri.js → ishikawaDiagram-K3B6WC7H-D7Bl9knA.js} +1 -1
  79. package/dist/assets/{journeyDiagram-COXZFDF6-DpRC9Lyh.js → journeyDiagram-COXZFDF6-CpeZrIcc.js} +1 -1
  80. package/dist/assets/{kanban-definition-P3RFRI5V-BvOXAPx-.js → kanban-definition-P3RFRI5V-BUOzn-Fr.js} +1 -1
  81. package/dist/assets/{mcp-servers-DJ9yWKIk.js → mcp-servers-ByXtlWTN.js} +1 -1
  82. package/dist/assets/{mermaid.core-DRLUqLnv.js → mermaid.core-DflvVzsO.js} +4 -4
  83. package/dist/assets/{mindmap-definition-LZFPQGKD-Do1biNMt.js → mindmap-definition-LZFPQGKD-DiGuXwjd.js} +1 -1
  84. package/dist/assets/{minimize-BwYHIgLM.js → minimize-BAc9pXKu.js} +1 -1
  85. package/dist/assets/{monitor-Pq_cuaeR.js → monitor-DpQ5uncj.js} +1 -1
  86. package/dist/assets/{new-bot-C-jsCc1U.js → new-bot-C7VaDaI3.js} +2 -2
  87. package/dist/assets/org-library-B7zPJgcz.js +1 -0
  88. package/dist/assets/{package-format-BSPbsc0W.js → package-format-R8RFoVUu.js} +1 -1
  89. package/dist/assets/{pegDiagram-BGZESJAR-Bi3XsRM6.js → pegDiagram-BGZESJAR-CRKEQIBP.js} +1 -1
  90. package/dist/assets/{pieDiagram-CAPJLFHJ-CdBlzdsy.js → pieDiagram-CAPJLFHJ-CWGKot3a.js} +1 -1
  91. package/dist/assets/{quadrantDiagram-GDMTTRAM-BoewpJJD.js → quadrantDiagram-GDMTTRAM-Bk4z1m10.js} +1 -1
  92. package/dist/assets/{rail-DSmElBAl.js → rail-Dd6xcO61.js} +1 -1
  93. package/dist/assets/{railroadDiagram-SM67HX2B-DlQKNESq.js → railroadDiagram-SM67HX2B-2QupGL7S.js} +1 -1
  94. package/dist/assets/{remote-desktop-panel-CmfdSZVf.js → remote-desktop-panel-5EHslJa1.js} +1 -1
  95. package/dist/assets/{requirementDiagram-X7JNWC4A-DYjJPykg.js → requirementDiagram-X7JNWC4A-CLKLTclj.js} +1 -1
  96. package/dist/assets/{sankeyDiagram-UM26HJRW-DGHZZ8DP.js → sankeyDiagram-UM26HJRW-BzjGddGa.js} +1 -1
  97. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-CjHH1cFz.js → sequenceDiagram-ZO4K6R2Y-0jtsIYcx.js} +1 -1
  98. package/dist/assets/{sizeCapture-INFHLROL-DCOf2evt.js → sizeCapture-INFHLROL-DQ-4qxWf.js} +1 -1
  99. package/dist/assets/{stateDiagram-v2-TBUQTH76-BbGFAXlk.js → stateDiagram-v2-TBUQTH76-hlf88UYN.js} +1 -1
  100. package/dist/assets/{styles-yUlq65bJ.js → styles-CWnH418X.js} +3 -3
  101. package/dist/assets/{swimlanes-N4OXWK64-BKBeWaCq.js → swimlanes-N4OXWK64-CWHfoSJI.js} +1 -1
  102. package/dist/assets/swimlanesDiagram-K3J5GTZL-Bwg62lGR.js +8 -0
  103. package/dist/assets/team-share-CbHmwu8l.js +2 -0
  104. package/dist/assets/{timeline-definition-YOQAKGHF-Duk4KEoF.js → timeline-definition-YOQAKGHF-DfyZPwCG.js} +1 -1
  105. package/dist/assets/{usecaseDiagram-VIAY4XPW-DIU5hAaZ.js → usecaseDiagram-VIAY4XPW-BZBJ0XV_.js} +1 -1
  106. package/dist/assets/{vennDiagram-BLWOH2XV-Cv-ZP8UH.js → vennDiagram-BLWOH2XV-o2QEjBYb.js} +1 -1
  107. package/dist/assets/{vi-CfrSoDHa.js → vi-0C1d4biz.js} +1 -1
  108. package/dist/assets/{wardleyDiagram-YMQ3BMBF-CwoLtXZa.js → wardleyDiagram-YMQ3BMBF-BSx5RhNP.js} +1 -1
  109. package/dist/assets/{xychartDiagram-TAQBALBS-CLzSDytf.js → xychartDiagram-TAQBALBS-X73RQNI6.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/BotSettingsDialog-vvMN2z7G.js +0 -16
  115. package/dist/assets/CloudAddDialog-CLP5xu5F.js +0 -1
  116. package/dist/assets/ComputerFilesPane-DBErQp52.js +0 -1
  117. package/dist/assets/ComputerPanel-B4NA1h9g.js +0 -2
  118. package/dist/assets/FilesView-NszFXh7j.js +0 -2
  119. package/dist/assets/KeyboardShortcutsModal-IQgQ6gDj.js +0 -1
  120. package/dist/assets/LocalVmWorkspace-sOfN__fZ.js +0 -1
  121. package/dist/assets/MacLocalControl-B-ZMyjBM.js +0 -1
  122. package/dist/assets/NewBotDialog-B1aIYfHP.js +0 -1
  123. package/dist/assets/PlacesRail-BkM5BsOu.js +0 -1
  124. package/dist/assets/RoomPanel-BN0c2Op7.js +0 -2
  125. package/dist/assets/TeamMapPage-DjoAPS38.js +0 -1
  126. package/dist/assets/TriggersPage-CIIcLsMk.js +0 -1
  127. package/dist/assets/VisibilitySection-Dx0nPQ93.js +0 -22
  128. package/dist/assets/WorksOnGrid-CXCZxfxH.js +0 -1
  129. package/dist/assets/channel-DR35OWd3.js +0 -1
  130. package/dist/assets/org-library-ev6mFvGV.js +0 -1
  131. package/dist/assets/swimlanesDiagram-K3J5GTZL-CaGrbi1Y.js +0 -8
  132. package/dist/assets/team-share-CvK6ffba.js +0 -2
@@ -1 +1 @@
1
- import{r,t as a,d as ne,j as e,X as le,f as ce}from"./styles-yUlq65bJ.js";import{r as ie,L as K}from"./PlacesRail-BkM5BsOu.js";import{S as B,a as de,p as J,r as oe,s as V,b as me,c as xe,t as pe,n as ue,d as he,e as fe,f as ge}from"./team-share-CvK6ffba.js";import{u as Se,n as A,M as be}from"./App-BBIWFBTX.js";import"./monitor-Pq_cuaeR.js";import"./index-BIvjGJcC.js";import"./MenuMotion-BcyCOXoC.js";function G({preview:l,includeMemory:x,localSkips:b}){const i=l.document.package,c=l.summary.counts,L=i.team?.leader?i.agents.find(s=>s.key===i.team?.leader)?.name:void 0,j=i.agents.filter(s=>s.appearance.avatar).length,T=i.agents.reduce((s,p)=>s+Object.keys(p.seed?.memory??{}).length,0),k=[[a("teamShare.part.bots"),`${c.bots} · ${l.summary.botNames.join(", ")}`],[a("teamShare.part.skills"),String(c.skills)],[a("teamShare.part.playbooks"),String(c.playbooks)],[a("teamShare.part.rooms"),String(c.rooms)],[a("teamShare.part.routines"),String(c.routines)],[a("teamShare.part.brief"),i.team?.brief?a("teamShare.yes"):a("teamShare.none")],[a("teamShare.part.leader"),L??a("teamShare.none")],[a("teamShare.part.connections"),String(c.connections)],[a("teamShare.part.pictures"),String(j)],[a("teamShare.part.notes"),x?String(T):a("teamShare.none")],...c.presets?[[a("teamShare.part.presets"),`${c.presets} · ${l.summary.presetNames.join(", ")}`]]:[]],C=[...b,...l.skipped.map(s=>he(s,l.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:a("teamShare.included")}),e.jsx("dl",{className:"mt-2 grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px]",children:k.map(([s,p])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:s}),e.jsx("dd",{className:"max-w-[260px] truncate text-right text-ink",title:p,children:p})]},s))}),i.connections?.length?e.jsxs("div",{className:"mt-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.addresses")}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:i.connections.map(s=>e.jsxs("li",{className:"break-all",children:[e.jsx("span",{className:"text-ink",children:s.label})," · ",s.mcp.url]},s.key))})]}):null,e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(be,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:a("teamShare.never")})]}),l.redacted.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:l.redacted.map(s=>e.jsx("li",{children:fe(s,l.document)},s))})]}),C.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:C.map((s,p)=>e.jsx("li",{children:s},`${s}-${p}`))})]})]})}function je({available:l,ticked:x,counted:b,onToggle:i}){return e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a("teamShare.includeSkills")}),b&&l.length===0&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:a("teamShare.noSkills")}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-x-4 gap-y-1",children:l.map(c=>e.jsxs("label",{className:"flex items-center gap-1.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"size-3.5 accent-accent",checked:x.has(c),onChange:()=>i(c)}),c]},c))})]})}function Pe({team:l,onClose:x}){const{state:b}=Se(),i=r.useRef(null),c=r.useMemo(()=>b.bots.filter(t=>!t.hidden&&(t.section?.trim()??"")===l),[b.bots,l]),L=r.useMemo(()=>new Map(c.map(t=>[t.id,t.name])),[c]),[j,T]=r.useState(l||a("teamLibrary.general")),[k,C]=r.useState(""),[s,p]=r.useState(""),[z,I]=r.useState(""),[R,W]=r.useState(""),[h,X]=r.useState(B.includePictures),[f,Q]=r.useState(B.includeMemory),[u,Y]=r.useState(!1),[g,H]=r.useState(null),[y,Z]=r.useState(null),[S,O]=r.useState(null),[ee,E]=r.useState(de),{preview:$,available:N,included:te,error:D}=ee,U=t=>E(n=>({...n,error:t})),[d,_]=r.useState(!1),[P,ae]=r.useState(null),M=r.useRef(0);r.useEffect(()=>{let t=!1;return J(c).then(n=>{t||O({avatars:n.avatars,skipped:n.skipped.map(o=>`${L.get(o.botId)??o.botId} · ${a("teamShare.field.picture")} — ${ne(`teamShare.skip.${o.reason}`,o.reason)}`)})}).catch(()=>{t||O({avatars:{},skipped:[]})}),()=>{t=!0}},[]),r.useEffect(()=>{if(!u||g)return;let t=!1;return A("/api/bot-defaults").then(({defaults:n})=>J([{id:"defaults",avatarUrl:n.profile.avatarUrl,avatarCrop:n.profile.avatarCrop}])).then(n=>{t||H({dataUrl:n.avatars.defaults})}).catch(()=>{t||H({})}),()=>{t=!0}},[u,g]);const q=r.useCallback(t=>({team:l,name:j,tagline:k,summary:s,release:z,notes:R,skills:oe(y,N),includeMemory:f,...h&&S?{avatars:S.avatars}:{},...u?{includeDefaultsPreset:!0,...h&&g?.dataUrl?{presetAvatar:g.dataUrl}:{}}:{},dryRun:t}),[l,j,k,s,z,R,y,N,f,h,S,u,g]);r.useEffect(()=>{if(!S)return;if(u&&!g){E(m=>({...m,preview:null}));return}const t=++M.current,n=y===null,o=window.setTimeout(()=>{A("/api/teams/export",{method:"POST",body:JSON.stringify(V({...q(!0),release:void 0}))}).then(m=>{t===M.current&&(E(w=>me(w,m,n)),I(w=>w||m.document.package.release))}).catch(m=>{t===M.current&&E(w=>xe(w,m))})},250);return()=>window.clearTimeout(o)},[S,y,f,h,u,g]);const se=async()=>{if(!d){_(!0),U("");try{const t=await A("/api/teams/export",{method:"POST",body:JSON.stringify(V(q(!1)))});ge(t.filename,t.document),ae(t)}catch(t){U(t instanceof Error?t.message:String(t))}finally{_(!1)}}};r.useEffect(()=>{const t=document.activeElement instanceof HTMLElement?document.activeElement:null;return i.current?.focus(),()=>{t?.isConnected&&t.focus()}},[]);const F=pe(y,te,N),re=t=>{const n=new Set(F);n.has(t)?n.delete(t):n.add(t),Z(n)},v="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[14px] text-ink disabled:opacity-60";return ie.createPortal(e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4",onMouseDown:t=>t.stopPropagation(),children:e.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-labelledby":"share-team-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[620px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:t=>{if(t.key==="Escape"&&!d&&(t.stopPropagation(),x()),t.key==="Tab"){const n=i.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!n?.length)return;const o=n[0],m=n[n.length-1];t.shiftKey&&document.activeElement===o?(t.preventDefault(),m.focus()):!t.shiftKey&&document.activeElement===m&&(t.preventDefault(),o.focus())}},children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-6 pb-2 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"share-team-title",className:"text-[17px] font-semibold",children:a("teamShare.title",{name:l||a("teamLibrary.general")})}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:a("teamShare.intro")})]}),e.jsx("button",{"aria-label":a("teamShare.close"),disabled:d,onClick:x,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(le,{size:18})})]}),P?e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(ce,{size:16,className:"text-success"}),a("teamShare.saved",{filename:P.filename})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:a("teamShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(G,{preview:P,includeMemory:f,localSkips:h?S?.skipped??[]:[]})})]}):e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:[$?e.jsx(G,{preview:$,includeMemory:f,localSkips:h?S?.skipped??[]:[]}):!D&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(K,{size:15,className:"animate-spin"}),a("teamShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:d,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:h,onChange:t=>X(t.target.checked)}),a("teamShare.includePictures")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:f,onChange:t=>Q(t.target.checked)}),a("teamShare.includeNotes")]}),e.jsx("p",{className:"pl-6 text-[12px] leading-relaxed text-ink-secondary",children:ue(f)}),e.jsx(je,{available:N??[],ticked:F,counted:N!==null,onToggle:re}),e.jsxs("label",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:u,onChange:t=>Y(t.target.checked)}),a("teamShare.includePreset")]}),u&&e.jsx("p",{className:"pl-6 text-[12px] leading-relaxed text-ink-secondary",children:a("teamShare.presetHint")})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[a("teamShare.name"),e.jsx("input",{value:j,maxLength:100,disabled:d,onChange:t=>T(t.target.value),className:v})]}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[a("teamShare.release"),e.jsx("input",{value:z,maxLength:20,disabled:d,placeholder:"1.0.0",onChange:t=>I(t.target.value),className:v})]})]}),e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:a("teamShare.releaseHint")}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.notes"),e.jsx("textarea",{value:R,maxLength:4e3,rows:2,disabled:d,onChange:t=>W(t.target.value),className:v})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.tagline"),e.jsx("input",{value:k,maxLength:160,disabled:d,onChange:t=>C(t.target.value),className:v})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.summary"),e.jsx("textarea",{value:s,maxLength:2e3,rows:2,disabled:d,onChange:t=>p(t.target.value),className:v})]})]}),D&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:D}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:P?e.jsx("button",{onClick:x,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:a("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:d,onClick:x,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:a("common.cancel")}),e.jsxs("button",{disabled:d||!$||!j.trim(),onClick:()=>{se()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[d&&e.jsx(K,{size:14,className:"animate-spin"}),d?a("teamShare.saving"):a("teamShare.save")]})]})})]})}),document.body)}export{je as ShareSkillChoices,G as ShareTeamContents,Pe as ShareTeamDialog};
1
+ import{r,t as a,b as ne,j as e,X as le,d as ce}from"./styles-CWnH418X.js";import{r as ie,L as K}from"./PlacesRail-fsCwAmTh.js";import{S as B,a as de,p as J,r as oe,s as V,b as me,c as xe,t as pe,n as ue,d as he,e as fe,f as ge}from"./team-share-CbHmwu8l.js";import{u as Se,j as I,E as be}from"./App-JBHRknbK.js";import"./monitor-DpQ5uncj.js";import"./index-C1x8eZ6l.js";import"./MenuMotion-C5SnaLCp.js";function G({preview:l,includeMemory:x,localSkips:b}){const i=l.document.package,c=l.summary.counts,L=i.team?.leader?i.agents.find(s=>s.key===i.team?.leader)?.name:void 0,j=i.agents.filter(s=>s.appearance.avatar).length,T=i.agents.reduce((s,p)=>s+Object.keys(p.seed?.memory??{}).length,0),k=[[a("teamShare.part.bots"),`${c.bots} · ${l.summary.botNames.join(", ")}`],[a("teamShare.part.skills"),String(c.skills)],[a("teamShare.part.playbooks"),String(c.playbooks)],[a("teamShare.part.rooms"),String(c.rooms)],[a("teamShare.part.routines"),String(c.routines)],[a("teamShare.part.brief"),i.team?.brief?a("teamShare.yes"):a("teamShare.none")],[a("teamShare.part.leader"),L??a("teamShare.none")],[a("teamShare.part.connections"),String(c.connections)],[a("teamShare.part.pictures"),String(j)],[a("teamShare.part.notes"),x?String(T):a("teamShare.none")],...c.presets?[[a("teamShare.part.presets"),`${c.presets} · ${l.summary.presetNames.join(", ")}`]]:[]],C=[...b,...l.skipped.map(s=>he(s,l.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:a("teamShare.included")}),e.jsx("dl",{className:"mt-2 grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px]",children:k.map(([s,p])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:s}),e.jsx("dd",{className:"max-w-[260px] truncate text-right text-ink",title:p,children:p})]},s))}),i.connections?.length?e.jsxs("div",{className:"mt-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.addresses")}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:i.connections.map(s=>e.jsxs("li",{className:"break-all",children:[e.jsx("span",{className:"text-ink",children:s.label})," · ",s.mcp.url]},s.key))})]}):null,e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(be,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:a("teamShare.never")})]}),l.redacted.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:l.redacted.map(s=>e.jsx("li",{children:fe(s,l.document)},s))})]}),C.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:a("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:C.map((s,p)=>e.jsx("li",{children:s},`${s}-${p}`))})]})]})}function je({available:l,ticked:x,counted:b,onToggle:i}){return e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a("teamShare.includeSkills")}),b&&l.length===0&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:a("teamShare.noSkills")}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-x-4 gap-y-1",children:l.map(c=>e.jsxs("label",{className:"flex items-center gap-1.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"size-3.5 accent-accent",checked:x.has(c),onChange:()=>i(c)}),c]},c))})]})}function Pe({team:l,onClose:x}){const{state:b}=Se(),i=r.useRef(null),c=r.useMemo(()=>b.bots.filter(t=>!t.hidden&&(t.section?.trim()??"")===l),[b.bots,l]),L=r.useMemo(()=>new Map(c.map(t=>[t.id,t.name])),[c]),[j,T]=r.useState(l||a("teamLibrary.general")),[k,C]=r.useState(""),[s,p]=r.useState(""),[z,M]=r.useState(""),[R,W]=r.useState(""),[h,X]=r.useState(B.includePictures),[f,Q]=r.useState(B.includeMemory),[u,Y]=r.useState(!1),[g,H]=r.useState(null),[y,Z]=r.useState(null),[S,O]=r.useState(null),[ee,E]=r.useState(de),{preview:$,available:N,included:te,error:D}=ee,U=t=>E(n=>({...n,error:t})),[d,_]=r.useState(!1),[P,ae]=r.useState(null),A=r.useRef(0);r.useEffect(()=>{let t=!1;return J(c).then(n=>{t||O({avatars:n.avatars,skipped:n.skipped.map(o=>`${L.get(o.botId)??o.botId} · ${a("teamShare.field.picture")} — ${ne(`teamShare.skip.${o.reason}`,o.reason)}`)})}).catch(()=>{t||O({avatars:{},skipped:[]})}),()=>{t=!0}},[]),r.useEffect(()=>{if(!u||g)return;let t=!1;return I("/api/bot-defaults").then(({defaults:n})=>J([{id:"defaults",avatarUrl:n.profile.avatarUrl,avatarCrop:n.profile.avatarCrop}])).then(n=>{t||H({dataUrl:n.avatars.defaults})}).catch(()=>{t||H({})}),()=>{t=!0}},[u,g]);const q=r.useCallback(t=>({team:l,name:j,tagline:k,summary:s,release:z,notes:R,skills:oe(y,N),includeMemory:f,...h&&S?{avatars:S.avatars}:{},...u?{includeDefaultsPreset:!0,...h&&g?.dataUrl?{presetAvatar:g.dataUrl}:{}}:{},dryRun:t}),[l,j,k,s,z,R,y,N,f,h,S,u,g]);r.useEffect(()=>{if(!S)return;if(u&&!g){E(m=>({...m,preview:null}));return}const t=++A.current,n=y===null,o=window.setTimeout(()=>{I("/api/teams/export",{method:"POST",body:JSON.stringify(V({...q(!0),release:void 0}))}).then(m=>{t===A.current&&(E(w=>me(w,m,n)),M(w=>w||m.document.package.release))}).catch(m=>{t===A.current&&E(w=>xe(w,m))})},250);return()=>window.clearTimeout(o)},[S,y,f,h,u,g]);const se=async()=>{if(!d){_(!0),U("");try{const t=await I("/api/teams/export",{method:"POST",body:JSON.stringify(V(q(!1)))});ge(t.filename,t.document),ae(t)}catch(t){U(t instanceof Error?t.message:String(t))}finally{_(!1)}}};r.useEffect(()=>{const t=document.activeElement instanceof HTMLElement?document.activeElement:null;return i.current?.focus(),()=>{t?.isConnected&&t.focus()}},[]);const F=pe(y,te,N),re=t=>{const n=new Set(F);n.has(t)?n.delete(t):n.add(t),Z(n)},v="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[14px] text-ink disabled:opacity-60";return ie.createPortal(e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4",onMouseDown:t=>t.stopPropagation(),children:e.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-labelledby":"share-team-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[620px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:t=>{if(t.key==="Escape"&&!d&&(t.stopPropagation(),x()),t.key==="Tab"){const n=i.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!n?.length)return;const o=n[0],m=n[n.length-1];t.shiftKey&&document.activeElement===o?(t.preventDefault(),m.focus()):!t.shiftKey&&document.activeElement===m&&(t.preventDefault(),o.focus())}},children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-6 pb-2 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"share-team-title",className:"text-[17px] font-semibold",children:a("teamShare.title",{name:l||a("teamLibrary.general")})}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:a("teamShare.intro")})]}),e.jsx("button",{"aria-label":a("teamShare.close"),disabled:d,onClick:x,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(le,{size:18})})]}),P?e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(ce,{size:16,className:"text-success"}),a("teamShare.saved",{filename:P.filename})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:a("teamShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(G,{preview:P,includeMemory:f,localSkips:h?S?.skipped??[]:[]})})]}):e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:[$?e.jsx(G,{preview:$,includeMemory:f,localSkips:h?S?.skipped??[]:[]}):!D&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(K,{size:15,className:"animate-spin"}),a("teamShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:d,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:h,onChange:t=>X(t.target.checked)}),a("teamShare.includePictures")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:f,onChange:t=>Q(t.target.checked)}),a("teamShare.includeNotes")]}),e.jsx("p",{className:"pl-6 text-[12px] leading-relaxed text-ink-secondary",children:ue(f)}),e.jsx(je,{available:N??[],ticked:F,counted:N!==null,onToggle:re}),e.jsxs("label",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:u,onChange:t=>Y(t.target.checked)}),a("teamShare.includePreset")]}),u&&e.jsx("p",{className:"pl-6 text-[12px] leading-relaxed text-ink-secondary",children:a("teamShare.presetHint")})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[a("teamShare.name"),e.jsx("input",{value:j,maxLength:100,disabled:d,onChange:t=>T(t.target.value),className:v})]}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[a("teamShare.release"),e.jsx("input",{value:z,maxLength:20,disabled:d,placeholder:"1.0.0",onChange:t=>M(t.target.value),className:v})]})]}),e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:a("teamShare.releaseHint")}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.notes"),e.jsx("textarea",{value:R,maxLength:4e3,rows:2,disabled:d,onChange:t=>W(t.target.value),className:v})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.tagline"),e.jsx("input",{value:k,maxLength:160,disabled:d,onChange:t=>C(t.target.value),className:v})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[a("teamShare.summary"),e.jsx("textarea",{value:s,maxLength:2e3,rows:2,disabled:d,onChange:t=>p(t.target.value),className:v})]})]}),D&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:D}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:P?e.jsx("button",{onClick:x,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:a("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:d,onClick:x,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:a("common.cancel")}),e.jsxs("button",{disabled:d||!$||!j.trim(),onClick:()=>{se()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[d&&e.jsx(K,{size:14,className:"animate-spin"}),d?a("teamShare.saving"):a("teamShare.save")]})]})})]})}),document.body)}export{je as ShareSkillChoices,G as ShareTeamContents,Pe as ShareTeamDialog};
@@ -1 +1 @@
1
- import{r,j as s,t}from"./styles-yUlq65bJ.js";import{n as b}from"./App-BBIWFBTX.js";import{a as k}from"./PlacesRail-BkM5BsOu.js";function E({target:i,scope:a={},sharedBy:x,disabled:N=!1,bare:l=!1}){const[n,S]=r.useState(null),[o,m]=r.useState(!1),[c,u]=r.useState(""),p=async e=>{m(!0),u("");try{S((await e()).sites)}catch(d){u(d instanceof Error&&d.message?d.message:t("settings.sites.error"))}finally{m(!1)}},g=()=>p(()=>b(`/api/browser-sites?${new URLSearchParams({...i,...a}).toString()}`)),f=e=>p(()=>b("/api/browser-sites/sign-out",{method:"POST",body:JSON.stringify({...i,...a,...e?{site:e}:{}})})),v=`${"bot"in i?`bot:${i.bot}`:`profile:${i.profile}`}${a.threadId?`:${a.threadId}`:""}`;r.useEffect(()=>{l&&g()},[l,v]);const h=N||o,j="flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",y=s.jsxs("div",{className:l?"flex min-w-0 flex-col gap-2":"mt-2 flex flex-col gap-2","aria-busy":o,children:[x.length>1&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.sites.shared",{names:x.join(", ")})}),n===null&&!c&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.sites.loading")}),n?.length===0&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.sites.none")}),!!n?.length&&s.jsx("ul",{className:"divide-y divide-hairline/30",children:n.map(e=>s.jsxs("li",{className:"flex min-w-0 items-center gap-2 py-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",title:e.site,children:e.site}),s.jsxs("button",{type:"button",disabled:h,onClick:()=>{f(e.site)},"aria-label":t("settings.sites.signOutOf",{site:e.site}),className:j,children:[s.jsx(k,{size:13}),t("settings.sites.signOut")]})]},e.site))}),!!n?.length&&s.jsxs("button",{type:"button",disabled:h,onClick:()=>{f()},className:`${j} self-start`,children:[s.jsx(k,{size:13}),t("settings.sites.signOutAll")]}),c&&s.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:c})]});return l?y:s.jsxs("details",{className:"min-w-0",onToggle:e=>{e.currentTarget.open&&!o&&g()},children:[s.jsx("summary",{className:"cursor-pointer text-[12px] font-medium text-ink-secondary hover:text-ink",children:t("settings.sites.title")}),y]})}export{E as S};
1
+ import{r,j as s,t}from"./styles-CWnH418X.js";import{j as b}from"./App-JBHRknbK.js";import{a as k}from"./PlacesRail-fsCwAmTh.js";function E({target:i,scope:a={},sharedBy:x,disabled:N=!1,bare:l=!1}){const[n,S]=r.useState(null),[o,m]=r.useState(!1),[c,u]=r.useState(""),p=async e=>{m(!0),u("");try{S((await e()).sites)}catch(d){u(d instanceof Error&&d.message?d.message:t("settings.sites.error"))}finally{m(!1)}},g=()=>p(()=>b(`/api/browser-sites?${new URLSearchParams({...i,...a}).toString()}`)),f=e=>p(()=>b("/api/browser-sites/sign-out",{method:"POST",body:JSON.stringify({...i,...a,...e?{site:e}:{}})})),v=`${"bot"in i?`bot:${i.bot}`:`profile:${i.profile}`}${a.threadId?`:${a.threadId}`:""}`;r.useEffect(()=>{l&&g()},[l,v]);const h=N||o,j="flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",y=s.jsxs("div",{className:l?"flex min-w-0 flex-col gap-2":"mt-2 flex flex-col gap-2","aria-busy":o,children:[x.length>1&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.sites.shared",{names:x.join(", ")})}),n===null&&!c&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.sites.loading")}),n?.length===0&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.sites.none")}),!!n?.length&&s.jsx("ul",{className:"divide-y divide-hairline/30",children:n.map(e=>s.jsxs("li",{className:"flex min-w-0 items-center gap-2 py-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",title:e.site,children:e.site}),s.jsxs("button",{type:"button",disabled:h,onClick:()=>{f(e.site)},"aria-label":t("settings.sites.signOutOf",{site:e.site}),className:j,children:[s.jsx(k,{size:13}),t("settings.sites.signOut")]})]},e.site))}),!!n?.length&&s.jsxs("button",{type:"button",disabled:h,onClick:()=>{f()},className:`${j} self-start`,children:[s.jsx(k,{size:13}),t("settings.sites.signOutAll")]}),c&&s.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:c})]});return l?y:s.jsxs("details",{className:"min-w-0",onToggle:e=>{e.currentTarget.open&&!o&&g()},children:[s.jsx("summary",{className:"cursor-pointer text-[12px] font-medium text-ink-secondary hover:text-ink",children:t("settings.sites.title")}),y]})}export{E as S};
@@ -1,3 +1,3 @@
1
- import{t as s,r as i,j as e,X as nt,a as C,f as ve,S as Et}from"./styles-yUlq65bJ.js";import{r as we,L as T,P as it,N as Xe,O as Bt,v as Qe,Q as zt,t as ce}from"./PlacesRail-BkM5BsOu.js";import{n as L,E as u,bz as Tt,bA as It,bB as $t,w as Ot,bC as Ve,bD as Rt,aT as lt,u as ot,bE as Dt,bF as Pt,bG as At,bH as ct,bI as Mt,bJ as Ft,bK as Gt,bL as Ze,bM as _t,F as Ut,bN as Kt}from"./App-BBIWFBTX.js";import{t as de,o as dt,a as Yt,b as qt,c as Ht,d as Jt,e as Wt,M as Xt}from"./org-library-ev6mFvGV.js";import{t as Qt,a as Vt}from"./import-name-B2N5mYM1.js";import{L as Zt}from"./LimixResizeHandles-BKkhoxk3.js";import{ShareTeamDialog as es}from"./ShareTeamDialog-CrPLELxa.js";import{R as ts}from"./MenuMotion-BcyCOXoC.js";import"./monitor-Pq_cuaeR.js";import"./index-BIvjGJcC.js";import"./package-format-BSPbsc0W.js";import"./team-share-CvK6ffba.js";const ss={"seo growth team":"seoGrowth","engineering team":"engineering","100x marketing team":"marketing100x","reddit lead miner":"redditLeadMiner","competitor watch":"competitorWatch","inbox follow-up":"inboxFollowup"};function Se(a){const c=ss[a.name.trim().toLowerCase()];return c?{...a,name:s(`templates.catalog.${c}.name`),summary:s(`templates.catalog.${c}.summary`),outcome:a.outcome?s(`templates.catalog.${c}.outcome`):void 0}:a}function as(a,c){const x=Se(a);return`${x.name} ${x.summary} ${a.name} ${a.summary} ${a.category} ${a.skills.join(" ")} ${a.requires.apps.join(" ")}`.toLowerCase().includes(c)}function mt({title:a,subtitle:c,icon:x,loading:p,error:o,sections:g,useLabel:N,onUse:v,onClose:m}){const h=i.useRef(null);i.useEffect(()=>{h.current?.querySelector("[data-details-close]")?.focus();const k=S=>{S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),m())};return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[m]);const w=g.filter(k=>typeof k.body=="string"?k.body.trim():k.body.length);return we.createPortal(e.jsx("div",{className:"ui-scrim fixed inset-0 z-[90] flex items-center justify-center p-4",onMouseDown:k=>{k.target===k.currentTarget&&m()},children:e.jsxs("div",{ref:h,role:"dialog","aria-modal":"true","aria-labelledby":"template-details-title","data-template-details":"",className:"ui-modal relative flex max-h-[min(720px,calc(100dvh-32px))] w-[min(560px,calc(100vw-32px))] flex-col border-0 p-0 text-ink",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-hairline/40 px-5 py-4 pe-12",children:[x,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{id:"template-details-title",className:"break-words text-[17px] font-semibold",children:a}),c&&e.jsx("p",{className:"break-words text-[13px] text-ink-secondary",children:c})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:[p&&e.jsxs("p",{className:"flex items-center gap-2 py-2 text-[13px] text-ink-secondary",children:[e.jsx(T,{size:14,className:"animate-spin","aria-hidden":"true"}),u("Đang tải chi tiết…","Loading details…")]}),o&&e.jsx("p",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[13px] text-danger",children:o}),w.map(k=>e.jsxs("section",{className:"mb-4 last:mb-0",children:[e.jsx("h3",{className:"mb-1 text-[12px] font-medium uppercase tracking-wide text-ink-tertiary",children:k.label}),typeof k.body=="string"?e.jsx("p",{className:"whitespace-pre-line break-words text-[13px] leading-[1.5] text-ink-secondary",children:k.body}):e.jsx("ul",{className:"list-disc space-y-0.5 ps-5 text-[13px] leading-[1.5] text-ink-secondary",children:k.body.map((S,R)=>e.jsx("li",{className:"break-words",children:S},R))})]},k.label))]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-hairline/40 px-5 py-3",children:[e.jsx("button",{type:"button",onClick:m,className:"rounded-full px-4 py-2 text-[13px] text-ink-secondary hover:text-ink",children:u("Đóng","Close")}),v&&e.jsxs("button",{type:"button",onClick:v,className:"flex items-center gap-1 rounded-full bg-raised px-4 py-2 text-[13px] font-medium text-ink hover:bg-raised-hover",children:[e.jsx(it,{size:14,"aria-hidden":"true"}),N]})]}),e.jsx("button",{type:"button","data-details-close":"",onClick:m,"aria-label":u("Đóng","Close"),className:"ui-icon-button absolute end-3 top-3",children:e.jsx(nt,{size:16})})]})}),document.body)}function rs({entry:a,onUse:c,onClose:x}){const p=Se(a),[o,g]=i.useState(null),[N,v]=i.useState("");i.useEffect(()=>{let h=!0;return L(`/api/team-library/teams/${a.slug}`).then(w=>{h&&g(de(w))},w=>{h&&v(w instanceof Error?w.message:String(w))}),()=>{h=!1}},[a.slug]);const m=[s("templates.botCount",{count:o?.members.length??a.members}),...o?[u(`${o.rooms} phòng`,`${o.rooms} rooms`),u(`${o.routines} lịch định kỳ`,`${o.routines} routines`)]:[],...a.setupMinutes?[s("templates.minutes",{count:a.setupMinutes})]:[]];return e.jsx(mt,{title:p.name,subtitle:a.category,loading:!o&&!N,error:N,sections:[{label:u("Nhóm này làm gì","What the team does"),body:[p.summary,p.outcome].filter(Boolean).join(`
1
+ import{t as s,r as i,j as e,X as nt,a as C,d as ve,S as Et}from"./styles-CWnH418X.js";import{r as we,L as T,P as it,M as Xe,N as Bt,v as Qe,O as zt,t as ce}from"./PlacesRail-fsCwAmTh.js";import{j as L,x as u,bw as Tt,bx as It,by as $t,C as Ot,bz as Ve,bA as Rt,aQ as lt,u as ot,bB as Dt,bC as Pt,bD as At,bE as ct,bF as Mt,bG as Gt,bH as Ft,bI as Ze,bJ as _t,af as Ut,bK as Kt}from"./App-JBHRknbK.js";import{t as de,o as dt,a as Yt,b as qt,c as Ht,d as Jt,e as Wt,M as Xt}from"./org-library-B7zPJgcz.js";import{t as Qt,a as Vt}from"./import-name-CACT_zPn.js";import{L as Zt}from"./LimixResizeHandles-DF3sBE58.js";import{ShareTeamDialog as es}from"./ShareTeamDialog-Ccy_4evB.js";import{R as ts}from"./MenuMotion-C5SnaLCp.js";import"./monitor-DpQ5uncj.js";import"./index-C1x8eZ6l.js";import"./package-format-R8RFoVUu.js";import"./team-share-CbHmwu8l.js";const ss={"seo growth team":"seoGrowth","engineering team":"engineering","100x marketing team":"marketing100x","reddit lead miner":"redditLeadMiner","competitor watch":"competitorWatch","inbox follow-up":"inboxFollowup"};function Se(a){const c=ss[a.name.trim().toLowerCase()];return c?{...a,name:s(`templates.catalog.${c}.name`),summary:s(`templates.catalog.${c}.summary`),outcome:a.outcome?s(`templates.catalog.${c}.outcome`):void 0}:a}function as(a,c){const x=Se(a);return`${x.name} ${x.summary} ${a.name} ${a.summary} ${a.category} ${a.skills.join(" ")} ${a.requires.apps.join(" ")}`.toLowerCase().includes(c)}function mt({title:a,subtitle:c,icon:x,loading:p,error:o,sections:g,useLabel:N,onUse:v,onClose:m}){const h=i.useRef(null);i.useEffect(()=>{h.current?.querySelector("[data-details-close]")?.focus();const k=S=>{S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),m())};return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[m]);const w=g.filter(k=>typeof k.body=="string"?k.body.trim():k.body.length);return we.createPortal(e.jsx("div",{className:"ui-scrim fixed inset-0 z-[90] flex items-center justify-center p-4",onMouseDown:k=>{k.target===k.currentTarget&&m()},children:e.jsxs("div",{ref:h,role:"dialog","aria-modal":"true","aria-labelledby":"template-details-title","data-template-details":"",className:"ui-modal relative flex max-h-[min(720px,calc(100dvh-32px))] w-[min(560px,calc(100vw-32px))] flex-col border-0 p-0 text-ink",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-hairline/40 px-5 py-4 pe-12",children:[x,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{id:"template-details-title",className:"break-words text-[17px] font-semibold",children:a}),c&&e.jsx("p",{className:"break-words text-[13px] text-ink-secondary",children:c})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:[p&&e.jsxs("p",{className:"flex items-center gap-2 py-2 text-[13px] text-ink-secondary",children:[e.jsx(T,{size:14,className:"animate-spin","aria-hidden":"true"}),u("Đang tải chi tiết…","Loading details…")]}),o&&e.jsx("p",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[13px] text-danger",children:o}),w.map(k=>e.jsxs("section",{className:"mb-4 last:mb-0",children:[e.jsx("h3",{className:"mb-1 text-[12px] font-medium uppercase tracking-wide text-ink-tertiary",children:k.label}),typeof k.body=="string"?e.jsx("p",{className:"whitespace-pre-line break-words text-[13px] leading-[1.5] text-ink-secondary",children:k.body}):e.jsx("ul",{className:"list-disc space-y-0.5 ps-5 text-[13px] leading-[1.5] text-ink-secondary",children:k.body.map((S,R)=>e.jsx("li",{className:"break-words",children:S},R))})]},k.label))]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-hairline/40 px-5 py-3",children:[e.jsx("button",{type:"button",onClick:m,className:"rounded-full px-4 py-2 text-[13px] text-ink-secondary hover:text-ink",children:u("Đóng","Close")}),v&&e.jsxs("button",{type:"button",onClick:v,className:"flex items-center gap-1 rounded-full bg-raised px-4 py-2 text-[13px] font-medium text-ink hover:bg-raised-hover",children:[e.jsx(it,{size:14,"aria-hidden":"true"}),N]})]}),e.jsx("button",{type:"button","data-details-close":"",onClick:m,"aria-label":u("Đóng","Close"),className:"ui-icon-button absolute end-3 top-3",children:e.jsx(nt,{size:16})})]})}),document.body)}function rs({entry:a,onUse:c,onClose:x}){const p=Se(a),[o,g]=i.useState(null),[N,v]=i.useState("");i.useEffect(()=>{let h=!0;return L(`/api/team-library/teams/${a.slug}`).then(w=>{h&&g(de(w))},w=>{h&&v(w instanceof Error?w.message:String(w))}),()=>{h=!1}},[a.slug]);const m=[s("templates.botCount",{count:o?.members.length??a.members}),...o?[u(`${o.rooms} phòng`,`${o.rooms} rooms`),u(`${o.routines} lịch định kỳ`,`${o.routines} routines`)]:[],...a.setupMinutes?[s("templates.minutes",{count:a.setupMinutes})]:[]];return e.jsx(mt,{title:p.name,subtitle:a.category,loading:!o&&!N,error:N,sections:[{label:u("Nhóm này làm gì","What the team does"),body:[p.summary,p.outcome].filter(Boolean).join(`
2
2
 
3
- `)},{label:u("Tổng quan","At a glance"),body:m},{label:u("Thành viên","Members"),body:(o?.members??[]).map(h=>h.title?`${h.name} — ${h.title}`:h.name)},{label:u("Kỹ năng đi kèm","Skills included"),body:o?.skills?.length?o.skills:a.skills},{label:u("Ứng dụng cần kết nối","Apps needed"),body:o?.apps.length?o.apps.map(h=>h.optional?u(`${h.label} (không bắt buộc)`,`${h.label} (optional)`):h.label):a.requires.apps},{label:u("Lưu ý","Notes"),body:o?.warnings??[]}],useLabel:s("templates.load"),onUse:c,onClose:x})}const U=["bg-purple-500/15 text-purple-300","bg-cyan-500/15 text-cyan-300","bg-orange-500/15 text-orange-300","bg-emerald-500/15 text-emerald-300"];function ns({pending:a,importedNames:c,org:x=!1}){return e.jsxs(e.Fragment,{children:[a.description&&e.jsx("p",{className:"max-w-2xl text-[14px] leading-relaxed text-ink-secondary",children:a.description}),a.brief&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.brief")}),e.jsx("p",{className:"mt-1 line-clamp-4 whitespace-pre-wrap break-words",children:a.brief})]}),!!a.warnings?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"mb-2 font-medium text-ink",children:s("templates.backupNotes")}),a.warnings?.map((p,o)=>e.jsx("p",{children:p},o))]}),(a.kind==="package"||a.kind==="backup")&&e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2 text-[12px] text-ink-secondary",children:[a.chiefOfStaff&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Tt,{size:13}),s("templates.leads",{name:a.chiefOfStaff})]}),!a.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(It,{size:13}),s("templates.groupChats",{count:a.rooms})]}),!(a.library&&!a.playbooks)&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx($t,{size:13}),s("templates.playbooks",{count:a.playbooks})]}),!a.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ot,{size:13}),a.version===2?s("teamImport.routinesPaused",{count:a.routines}):s("templates.pausedRoutines",{count:a.routines})]}),a.kind==="package"&&a.version!==2&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ve,{size:13}),s("templates.connections",{count:a.apps.length})]}),!!a.connections?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ve,{size:13}),s("teamImport.connections",{count:a.connections?.length??0})]}),!!a.notes&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Rt,{size:13}),s("teamImport.notes",{count:a.notes??0})]}),!!a.presets?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(lt,{size:13}),s("teamImport.presets",{count:a.presets?.length??0})]})]}),!!a.skills?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:x?s("orgLibrary.skillsOn"):a.version===2?s("teamImport.skillsOff"):s("templates.skillsDisabled")}),e.jsx("p",{className:"mt-1 break-words",children:a.skills?.join(", ")}),!x&&e.jsx("p",{className:"mt-1",children:a.version===2?s("teamImport.skillsReview"):s("templates.skillsReview")})]}),a.library&&!!a.presets?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.presetList")}),e.jsx("p",{className:"mt-1 break-words",children:a.presets?.join(", ")})]}),!!a.offeredSkills?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.offeredSkills")}),e.jsx("p",{className:"mt-1 break-words",children:a.offeredSkills?.join(", ")})]}),!!a.connections?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.connections",{count:a.connections?.length??0})}),e.jsx("ul",{className:"mt-1",children:a.connections?.map((p,o)=>e.jsxs("li",{className:"truncate",children:[p.label," · ",p.url]},`${p.label}-${o}`))})]}),a.members.length>0&&e.jsx("div",{className:"mt-6 text-[12px] font-medium text-ink-secondary",children:s("templates.teamMembers")}),e.jsx("div",{className:"mt-2 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:a.members.map((p,o)=>e.jsxs("div",{className:"flex min-h-[72px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[a.pictures?.[o]?e.jsx("img",{src:a.pictures[o],alt:"",className:"size-9 shrink-0 rounded-lg object-cover"}):e.jsx("div",{className:C("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",U[o%U.length]),children:p.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-medium text-ink",children:c[o]}),c[o]!==p.name&&e.jsx("div",{className:"text-[12px] text-ink-secondary",children:s("templates.newCopyOf",{name:p.name})}),e.jsx("div",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:p.title||s("templates.generalAssistant")})]})]},`${p.name}-${o}`))}),e.jsxs("div",{className:"mt-6 flex items-start gap-2.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(ve,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("p",{children:a.kind==="backup"?s("templates.backupSafety",{archived:a.archivedBots?s("templates.archivedBots",{count:a.archivedBots}):""}):x?a.members.length?s("orgLibrary.teamSafety"):s("orgLibrary.librarySafety"):a.library?s("teamImport.librarySafety"):a.version===2?s("teamImport.sharedTeamSafety"):a.kind==="package"?s("templates.packageSafety"):s("templates.legacySafety")})]})]})}async function is(a,c){for(const x of c??[])await fetch(`/api/limix/skill-store/${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:x,add:!0})}).catch(()=>{})}const et={gmail:"Gmail",github:"GitHub",discord:"Discord",slack:"Slack",googlecalendar:"Google Calendar",notion:"Notion",linear:"Linear",figma:"Figma",gong:"Gong",hubspot:"HubSpot",postiz:"Postiz"},ke={everyday:"readyBots.category.everyday",work:"readyBots.category.work",writing:"readyBots.category.writing",design:"readyBots.category.design",sales:"readyBots.category.sales",personal:"readyBots.category.personal"},Ne=()=>ct.map(a=>{const c=Mt(a);return{id:a.id,name:a.name,title:c.title,category:a.category,description:c.description,try:c.tryAsking,look:a.look,apps:a.apps,routines:a.routines?.length??0,builtIn:!0}});let _=null;async function ls(){const{bots:a}=await L("/api/limix/bots/refresh",{method:"POST"});return _=a.length?a.map(c=>({...c,builtIn:!1})):null,a.length}const os=(a,c)=>{const x=c.trim().toLowerCase();return!x||[a.name,a.title,a.description,a.category].some(p=>p.toLowerCase().includes(x))};function cs({search:a,onDialog:c,onAdded:x,revision:p=0}){const{state:o,dispatch:g}=ot(),[N,v]=i.useState(null),[m,h]=i.useState(_),[w,k]=i.useState(!1),[S,R]=i.useState(null),[K,Y]=i.useState(""),[$,A]=i.useState(null);i.useEffect(()=>{if(p>0){h(_??Ne()),k(!1);return}let r=!0;return L("/api/limix/bots").then(({bots:f})=>{if(!r)return;const d=f.length?f.map(P=>({...P,builtIn:!1})):Ne();_=f.length?d:null,h(d),k(!1)}).catch(()=>{r&&(h(_??Ne()),k(!_))}),()=>{r=!1}},[p]);const H=()=>{A(null),c(!1)},[b,B]=i.useState(null),J=r=>{if(c(!0),r.builtIn){B({card:r,bot:ct.find(f=>f.id===r.id)});return}B({card:r}),L(`/api/limix/bots/${r.id}`).then(({bot:f})=>B(d=>d?.card.id===r.id?{card:r,bot:f}:d),f=>B(d=>d?.card.id===r.id?{card:r,error:f instanceof Error?f.message:String(f)}:d))},me=()=>{B(null),c(!1)},W=async r=>{if(!(S||Ft(o))){if(Y(""),window.ogb?.remoteClient?.active){g({type:"newBot",onCreated:x});return}if(r.builtIn){A({id:r.id}),c(!0);return}R(r.id);try{const{bot:f}=await L(`/api/limix/bots/${r.id}`);A({id:r.id,data:f,skills:f.skills}),c(!0)}catch(f){Y(f instanceof Error?f.message:String(f))}finally{R(null)}}};if(!m)return e.jsxs("div",{className:"mb-8 flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(T,{size:15,className:"animate-spin"}),s("templates.loading")]});const D=m.filter(r=>(!N||r.category===N)&&os(r,a));return a.trim()&&D.length===0?null:e.jsxs("section",{className:"mb-8","aria-labelledby":"ready-bots-title",children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-baseline justify-between gap-2",children:[e.jsx("h3",{id:"ready-bots-title",className:"text-[12px] font-medium text-ink-secondary",children:s("readyBots.title")}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx("p",{className:"text-[12px] text-ink-tertiary",role:"status","aria-live":"polite",children:w?u("Đang dùng bản có sẵn trong ứng dụng (chưa tải được kho mẫu).","Showing the bots built into the app (the template library could not be loaded)."):s("readyBots.subtitle")})})]}),e.jsx("div",{className:"mb-3 mt-2 flex flex-wrap gap-1.5",role:"group","aria-label":s("readyBots.categories"),children:[null,...Dt].map(r=>e.jsx("button",{type:"button","aria-pressed":N===r,onClick:()=>v(r),className:C("rounded-full px-3 py-1 text-[13px] transition-colors",N===r?"bg-ink text-panel":"bg-raised/70 text-ink-secondary hover:text-ink"),children:r?s(ke[r]):s("readyBots.all")},r??"all"))}),K&&e.jsx("p",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[13px] text-danger",children:K}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,280px),1fr))] gap-3",children:D.map(r=>e.jsxs("article",{"data-ready-bot":r.id,className:"flex min-w-0 flex-col rounded-2xl border border-hairline/40 bg-card p-4 [overflow-wrap:anywhere]",children:[e.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)] items-center gap-3",children:[e.jsx(Xe,{color:r.look.color,bodyId:r.look.mascotBody,state:r.look.mascotExpression??"idle",size:40,animated:!1,label:r.name}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"text-[14px] font-medium text-ink",children:r.name}),e.jsxs("p",{className:"text-[12px] text-ink-secondary",children:[r.title," · ",s(ke[r.category])]})]})]}),e.jsx("p",{className:"mt-3 text-[13px] leading-[1.45] text-ink-secondary",children:r.description}),e.jsx("p",{className:"mt-2 text-[12px] italic text-ink-tertiary",children:s("readyBots.try",{prompt:r.try})}),e.jsxs("div",{className:"mt-auto flex flex-wrap items-center justify-between gap-2 pt-3",children:[e.jsxs("button",{type:"button","data-ready-bot-details":r.id,onClick:()=>J(r),"aria-label":u(`Xem thêm về ${r.name}`,`More about ${r.name}`),className:"flex w-fit items-center gap-1 text-[12px] font-medium text-accent-text hover:underline focus-visible:outline-2 focus-visible:outline-accent",children:[e.jsx(Pt,{size:13,"aria-hidden":"true"}),u("Xem thêm","See more")]}),e.jsxs("button",{type:"button",onClick:()=>{W(r)},disabled:S!==null,"aria-label":u(`Dùng mẫu ${r.name}, ${r.title}`,`Use template ${r.name}, ${r.title}`),className:"flex h-8 shrink-0 items-center gap-1 rounded-full bg-raised px-3 text-[13px] font-medium text-ink hover:bg-raised-hover disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-accent",children:[S===r.id?e.jsx(T,{size:14,className:"animate-spin","aria-hidden":"true"}):e.jsx(it,{size:14,"aria-hidden":"true"}),u("Dùng mẫu","Use template")]})]}),(r.apps.length>0||r.routines>0)&&e.jsx("p",{className:"pt-2 text-[12px] text-ink-tertiary",children:[r.apps.length>0&&s("readyBots.worksWith",{apps:r.apps.map(f=>et[f]??f).join(", ")}),r.routines>0&&s("readyBots.pausedRoutine")].filter(Boolean).join(" · ")})]},r.id))}),b&&e.jsx(mt,{title:b.card.name,subtitle:`${b.card.title} · ${s(ke[b.card.category])}`,icon:e.jsx(Xe,{color:b.card.look.color,bodyId:b.card.look.mascotBody,state:b.card.look.mascotExpression??"idle",size:44,animated:!1,label:b.card.name}),loading:!b.bot&&!b.error,error:b.error,sections:[{label:u("Bot này làm gì","What it does"),body:b.bot?.description??b.card.description},{label:u("Cách bot làm việc","How it works"),body:b.bot?.soul??""},{label:u("Bạn có thể hỏi","Things to ask"),body:b.bot?.tryAsking??[b.card.try]},{label:u("Kỹ năng đi kèm","Skills included"),body:b.bot?.skills??[]},{label:u("Ứng dụng nên kết nối","Apps it works with"),body:(b.bot?.apps??b.card.apps).map(r=>et[r]??r)},{label:u("Lịch định kỳ (tạo ở trạng thái tạm dừng)","Routines (created paused)"),body:(b.bot?.routines??[]).map(r=>r.schedule&&"time"in r.schedule&&r.schedule.time?`${r.name} · ${r.schedule.time}`:r.name)}],useLabel:u("Dùng mẫu","Use template"),onUse:()=>{const r=b.card;B(null),W(r)},onClose:me}),$&&we.createPortal(e.jsx(At,{readyBotId:$.id,readyBotData:$.data,onClose:H,onCreated:r=>{c(!1),is(r.id,$.skills),x(r)}}),document.body)]})}const tt=["bg-cyan-500/15 text-cyan-300","bg-purple-500/15 text-purple-300","bg-emerald-500/15 text-emerald-300","bg-orange-500/15 text-orange-300"];function ds({listing:a,busy:c,notice:x,error:p,onAdd:o,onDetails:g}){const N=a.organization.name;return e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("orgLibrary.intro",{name:N})}),a.packages.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:s("orgLibrary.empty",{name:N})}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:a.packages.map((v,m)=>e.jsx(ms,{entry:v,index:m,busy:c,onAdd:o,onDetails:g},v.packageId))}),x&&e.jsx("div",{role:"status",className:"mt-4 rounded-lg bg-raised/60 px-3 py-2 text-[13px] text-ink-secondary",children:x}),p&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:p})]})}function ms({entry:a,index:c,busy:x,onAdd:p,onDetails:o}){const g=dt(a),N=Yt(a),v=qt(a),m=x===a.packageId;return e.jsxs("article",{className:"flex min-h-[104px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx("div",{className:C("flex size-11 shrink-0 items-center justify-center rounded-xl",tt[c%tt.length]),children:e.jsx(Bt,{size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:a.name}),e.jsx("p",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:a.tagline}),e.jsxs("p",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:Ht(a)}),N&&e.jsx("span",{className:"rounded-full bg-accent/10 px-2 py-0.5 text-accent-text",children:N}),a.release&&e.jsx("span",{children:a.release.version})]}),e.jsx("p",{className:"mt-0.5 truncate text-[12px] text-ink-tertiary",children:Jt(a.contents)}),v.map(h=>e.jsx("p",{className:"mt-0.5 text-[12px] text-warning",children:h},h))]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[g==="add"&&e.jsxs("button",{onClick:()=>p(a),disabled:x!==null,"aria-label":s("orgLibrary.addAria",{name:a.name}),className:"flex min-w-[72px] items-center justify-center gap-1.5 rounded-full bg-accent px-3.5 py-2 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[m&&e.jsx(T,{size:13,className:"animate-spin"}),m?s("orgLibrary.adding"):s("orgLibrary.add")]}),g==="added"&&e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-raised px-3 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(ve,{size:13,className:"text-success"}),s("orgLibrary.added")]}),g==="updateApp"&&e.jsx("span",{className:"max-w-[140px] text-right text-[12px] text-ink-secondary",children:s("orgLibrary.updateApp")}),g==="notReady"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("orgLibrary.notReady")}),g==="noRelease"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("orgLibrary.noRelease")}),a.blob==="ready"&&e.jsx("button",{onClick:()=>o(a),disabled:x!==null,"aria-label":s("orgLibrary.detailsAria",{name:a.name}),className:"rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:s("orgLibrary.details")})]})]})}const xs="https://github.com/leomieo/limix-bot-teams",st=["cyan","red","purple","green","orange"];async function at(a){if(window.ogb?.openExternal){await window.ogb.openExternal(a);return}const c=window.open(a,"_blank","noopener,noreferrer");c&&(c.opener=null)}function ps(a,c){const x=new Map;for(const o of c){if(o.hidden)continue;const g=o.section?.trim()??"";x.set(g,(x.get(g)??0)+1)}return[...[...new Set([...a.map(o=>o.trim()).filter(Boolean),...x.keys()])].filter(o=>o!==""),""].flatMap(o=>x.get(o)?[{name:o,bots:x.get(o)}]:[])}function rt({index:a}){return e.jsx("div",{className:C("flex size-11 shrink-0 items-center justify-center rounded-xl",U[a%U.length]),children:e.jsx(lt,{size:20})})}function Cs({onClose:a,onImported:c,returnFocusRef:x,initialUrl:p}){const{state:o,dispatch:g}=ot(),N=i.useRef(null),v=i.useRef(null),[m,h]=i.useState("explore"),[w,k]=i.useState(null),[S,R]=i.useState(!0),[K,Y]=i.useState(""),[$,A]=i.useState(!1),[H,b]=i.useState(""),[B,J]=i.useState(""),[me,W]=i.useState(0),D=i.useRef(0),[r,f]=i.useState(null),[d,P]=i.useState(null),[xt,pt]=i.useState("file"),[xe,Ce]=i.useState(""),[Le,Ee]=i.useState(!1),[I,X]=i.useState(!1),[ut,pe]=i.useState(!1),[ue,ht]=i.useState(""),[M,y]=i.useState(""),[Be,ze]=i.useState(""),[Q,Te]=i.useState(!1),[E,Ie]=i.useState(null),[gt,bt]=i.useState(""),[V,he]=i.useState(null),[$e,Oe]=i.useState(new Set),[Re,De]=i.useState(""),[Z,Pe]=i.useState(!1),[ee,Ae]=i.useState(null),[Me,te]=i.useState(!1),[ge,be]=i.useState(null),[se,Fe]=i.useState(null),[ft,ae]=i.useState(null),[yt,Ge]=i.useState(""),[jt,re]=i.useState(""),[F,ne]=i.useState(null),O=i.useRef(!1),G=i.useRef(0),fe=o.bots.filter(t=>!t.hidden).length,_e=ps(o.sections??[],o.bots),kt=new Set(o.bots.map(t=>t.name.trim().toLowerCase())),Nt=d?.members.map(t=>Qt(t.name,kt))??[],ie=i.useCallback(async(t=!1)=>{const n=++D.current;R(!0),Y("");try{const l=await L(`/api/team-library/catalog${t?"?fresh=1":""}`);return n===D.current&&k(l),!0}catch(l){return n===D.current&&Y(l instanceof Error?l.message:String(l)),!1}finally{n===D.current&&R(!1)}},[]),vt=async()=>{if(!$){A(!0),b(""),J("");try{const[t,n]=await Promise.allSettled([ls(),ie(!0)]);if(t.status==="fulfilled"&&W(l=>l+1),t.status==="fulfilled"&&n.status==="fulfilled"&&n.value)b(u("Đã cập nhật mẫu Bot và mẫu nhóm Bot.","Bot and team templates updated."));else{const l=[...t.status==="rejected"?[u("mẫu Bot","bot templates")]:[],...n.status==="rejected"||!n.value?[u("mẫu nhóm Bot","team templates")]:[]];J(u(`Chưa cập nhật được ${l.join(", ")}. Hãy thử lại.`,`Could not update ${l.join(", ")}. Please retry.`))}}finally{A(!1)}}};i.useEffect(()=>{ie()},[ie]);const le=i.useCallback(async()=>{try{const t=await L("/api/org-library");Fe(t),t.organization&&!O.current&&h("org")}catch{Fe({organization:null,packages:[]})}},[]);i.useEffect(()=>{le()},[le]),i.useEffect(()=>(N.current?.focus(),()=>x.current?.focus()),[x]),i.useEffect(()=>{const t=n=>{if(ee!==null||Me)return;if(n.key==="Escape"&&!I){n.preventDefault(),n.stopPropagation(),d?(P(null),ne(null)):a();return}if(n.key!=="Tab")return;const l=N.current,j=Array.from(l?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex="-1"])')??[]);if(!l||j.length===0)return;const z=j[0],oe=j.at(-1);n.shiftKey&&(document.activeElement===z||!l.contains(document.activeElement))?(n.preventDefault(),oe.focus()):!n.shiftKey&&document.activeElement===oe&&(n.preventDefault(),z.focus())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[I,a,d,ee,Me]);const ye=(t,n)=>{P(t),pt(n),y("")},Ue=async t=>{if(t.size>Xt)throw new Error(s("templates.fileTooLarge"));const n=await t.text();let l=n;if(!t.name.toLowerCase().endsWith(".md"))try{l=JSON.parse(n)}catch(j){throw j instanceof SyntaxError?new Error(s("teamLibrary.invalidJson")):j}ye(de(l),"file")},Ke=async t=>{f(t.slug),y("");try{ye(de(await L(`/api/team-library/teams/${t.slug}`)),"library")}catch(n){y(n instanceof Error?n.message:String(n))}finally{f(null)}},Ye=async()=>{await qe(xe)},qe=async t=>{if(t.trim()){Ee(!0),y("");try{const n=await L("/api/team-library/github",{method:"POST",body:JSON.stringify({url:t.trim()})});ye(de(n),"github")}catch(n){y(n instanceof Error?n.message:String(n))}finally{Ee(!1)}}};i.useEffect(()=>{p&&(O.current=!0,h("import"),Ce(p),qe(p))},[p]);const wt=async()=>{if(d){X(!0),y("");try{const t=await Vt(d.manifest,g);ce("team_imported",{members:t.bots.length,source:xt,mode:"add",format:d.kind}),c({name:d.name,members:t.bots.length,...t.connections?.length?{connections:t.connections.length}:{},...t.presets?.length?{presets:t.presets.length}:{}})}catch(t){y(t instanceof Error?t.message:String(t))}finally{X(!1)}}},St=async t=>{ae(t.packageId),re("");try{const n=await L(`/api/org-library/packages/${t.packageId}`);P(Wt(n.document)),ne(t),y("")}catch(n){re(n instanceof Error?n.message:String(n))}finally{ae(null)}},He=async t=>{ae(t.packageId),X(!0),re(""),Ge(""),y("");try{const n=await L("/api/org-library/add",{method:"POST",body:JSON.stringify({packageId:t.packageId})});for(const j of n.bots??[])g({type:"botAdded",bot:j});for(const j of n.groups??[])g({type:"groupPatched",group:j});for(const j of n.routines??[])g({type:"routinePatched",routine:j});const l=n.bots?.find(j=>!j.hidden);if(ce("team_imported",{members:n.bots?.length??0,source:"organization",mode:"add",format:"package"}),l){g({type:"select",id:l.id}),c({name:t.name,members:n.bots.length,...n.connections?.length?{connections:n.connections.length}:{}});return}P(null),ne(null),n.alreadyAdded||Ge(s("orgLibrary.addedSkills",{name:t.name})),await le()}catch(n){const l=n instanceof Error?n.message:String(n);F?y(l):re(l),await le()}finally{ae(null),X(!1)}},q=Be.trim(),je=async t=>{const n=++G.current;Te(!0),y(""),Ie(null),he(null),Oe(new Set);try{const l=await L(`/api/teams/scout?cwd=${encodeURIComponent(t)}`);if(n!==G.current)return;Ie(l),bt(t),De(l.suggestion.roomName),ce("team_scouted",{signals:l.suggestion.manifest.team.members.length-1}),L(`/api/teams/scout/directory?cwd=${encodeURIComponent(t)}`).then(j=>{n===G.current&&he(j.directory)}).catch(()=>{n===G.current&&he([])})}catch(l){if(n!==G.current)return;y(l instanceof Error?l.message:String(l))}finally{n===G.current&&Te(!1)}},Ct=async()=>{const t=await window.ogb?.pickFolder?.(q||void 0);t&&(ze(t),await je(t))},Lt=async()=>{if(!(!E||Z)){Pe(!0),y("");try{const t=(V??[]).filter(z=>$e.has(z.slug)).map((z,oe)=>({key:`dir-${z.slug}`,name:z.name,title:z.category||s("templates.communityBot"),description:z.prompt,appearance:{color:st[oe%st.length]}})),n={...E.suggestion.manifest,team:{...E.suggestion.manifest.team,members:[...E.suggestion.manifest.team.members,...t]}},l=Re.trim()||E.suggestion.roomName,j=await L(`/api/teams/import?mode=project&cwd=${encodeURIComponent(gt)}&room=${encodeURIComponent(l)}`,{method:"POST",body:JSON.stringify(n)});for(const z of j.bots)g({type:"botAdded",bot:z});j.group&&(g({type:"groupPatched",group:{...j.group,messages:[]}}),g({type:"select",id:j.group.id})),ce("team_imported",{members:j.bots.length,source:"scout",mode:"project"}),c({name:l,members:j.bots.length})}catch(t){y(t instanceof Error?t.message:String(t))}finally{Pe(!1)}}},Je=ue.trim().toLowerCase(),We=(w?.teams??[]).filter(t=>!Je||as(t,Je));return we.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4 sm:p-6",onMouseDown:t=>t.stopPropagation(),children:[e.jsxs("div",{ref:N,role:"dialog","aria-modal":"true","aria-labelledby":"team-library-title",tabIndex:-1,className:"animate-pop-in relative flex h-[min(780px,calc(100dvh-2rem))] max-h-full w-[min(100%,1040px)] 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 px-6 pb-3 pt-6 sm:px-8 sm:pt-7",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx("button",{onClick:()=>{P(null),ne(null),y("")},disabled:I,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":s("templates.back"),children:e.jsx(Gt,{size:18})}),e.jsx("h2",{id:"team-library-title",className:"[overflow-wrap:anywhere] text-[22px] font-semibold tracking-[-0.01em] text-ink",children:d?d.name:s("templates.title")})]}),e.jsx("p",{className:C("mt-1 text-[13px] text-ink-secondary",d&&"ml-9"),children:d?d.kind==="backup"?s("templates.backupSummary",{bots:d.members.length,conversations:d.conversations??0}):d.kind==="package"?d.library?s("teamImport.library"):d.version===2?s("teamImport.sharedTeam",{count:d.members.length}):s("templates.playbookSummary",{count:d.members.length}):s("templates.readyBots",{count:d.members.length}):s("templates.subtitle")})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!d&&e.jsxs("button",{onClick:()=>{at(w?.repositoryUrl??xs)},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-2 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",title:s("templates.openRepository"),children:[e.jsx(Ze,{size:16}),e.jsx("span",{className:"max-sm:hidden",children:s("templates.communityRepo")}),e.jsx(Qe,{size:12})]}),e.jsx("button",{onClick:a,disabled:I,className:"rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":s("templates.close"),children:e.jsx(nt,{size:21})})]})]}),d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-6 pt-6 sm:px-8",children:[e.jsx(ns,{pending:d,importedNames:Nt,org:F!==null}),M&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:M})]}),e.jsxs("footer",{className:"flex flex-col gap-3 border-t border-hairline/35 px-6 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-8",children:[e.jsxs("div",{className:"text-[13px] text-ink-secondary",children:[s(fe===0?"templates.existingNone":fe===1?"templates.existingOne":"templates.existingMany",{count:fe})," ",d.kind==="backup"?s("teamImport.backupCopies"):d.library?s("teamImport.libraryAdds"):d.members.length===0?"":s("teamImport.newSection",{name:d.teamName??d.name})]}),F?dt(F)==="add"?e.jsxs("button",{onClick:()=>{He(F)},disabled:I,"aria-label":s("orgLibrary.addAria",{name:F.name}),className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[I&&e.jsx(T,{size:15,className:"animate-spin"}),I?s("orgLibrary.adding"):s("orgLibrary.add")]}):e.jsxs("span",{className:"flex shrink-0 items-center gap-1 rounded-full bg-raised px-4 py-2 text-[13px] text-ink-secondary",children:[e.jsx(ve,{size:14,className:"text-success"}),s("orgLibrary.added")]}):e.jsxs("button",{onClick:()=>{wt()},disabled:I,className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[I&&e.jsx(T,{size:15,className:"animate-spin"}),I?s("templates.importing"):d.kind==="backup"?s("templates.importBackup"):d.library?s("teamImport.addPresets"):s("templates.addTeam")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-6 pb-4 pt-5 sm:px-8",children:[e.jsxs("div",{className:"flex max-w-full flex-wrap rounded-xl bg-raised/70 p-1",role:"tablist","aria-label":s("templates.source"),children:[se?.organization&&e.jsx("button",{role:"tab","aria-selected":m==="org",onClick:()=>{O.current=!0,h("org"),y("")},className:C("max-w-[220px] truncate rounded-lg px-4 py-2 text-[14px] transition-colors",m==="org"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("orgLibrary.tab",{name:se.organization.name})}),e.jsx("button",{role:"tab","aria-selected":m==="explore",onClick:()=>{O.current=!0,h("explore"),y("")},className:C("rounded-lg px-4 py-2 text-[14px] transition-colors",m==="explore"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.explore")}),e.jsx("button",{role:"tab","aria-selected":m==="import",onClick:()=>{O.current=!0,h("import"),y("")},className:C("rounded-lg px-4 py-2 text-[14px] transition-colors",m==="import"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.import")}),e.jsx("button",{role:"tab","aria-selected":m==="scout",onClick:()=>{O.current=!0,h("scout"),y("")},className:C("rounded-lg px-4 py-2 text-[14px] transition-colors",m==="scout"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.fromFolder")}),e.jsx("button",{role:"tab","aria-selected":m==="share",onClick:()=>{O.current=!0,h("share"),y("")},className:C("rounded-lg px-4 py-2 text-[14px] transition-colors",m==="share"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("teamLibrary.shareTab")}),e.jsx("button",{role:"tab","aria-selected":m==="teams",onClick:()=>{O.current=!0,h("teams"),y("")},className:C("rounded-lg px-4 py-2 text-[14px] transition-colors",m==="teams"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:u("Bản mẫu Nhóm","Team templates")})]}),e.jsxs("button",{type:"button",onClick:()=>{vt()},disabled:$,title:u("Tải lại mẫu Bot và mẫu nhóm Bot mới nhất từ kho","Reload the latest bot and team templates"),className:"flex h-10 shrink-0 items-center gap-1.5 rounded-xl bg-raised/70 px-3 text-[13px] font-medium text-ink hover:bg-raised-hover disabled:opacity-60",children:[e.jsx(ts,{size:14,"aria-hidden":"true",className:$?"animate-spin":void 0}),$?u("Đang cập nhật","Updating"):u("Cập nhật","Update")]}),(m==="explore"||m==="teams")&&e.jsxs("label",{className:"flex h-11 w-full items-center gap-2.5 rounded-xl bg-raised/70 px-3.5 sm:ml-auto sm:w-[240px]",children:[e.jsx(Et,{size:17,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:ue,onChange:t=>ht(t.target.value),placeholder:s("templates.search"),"aria-label":s("templates.search"),className:"min-w-0 flex-1 bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})]}),(H||B)&&e.jsx("p",{role:B?"alert":"status",className:C("px-6 pb-2 text-[13px] sm:px-8",B?"text-danger":"text-ink-secondary"),children:B||H}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-7 pt-5 sm:px-8",children:[m==="org"&&se?.organization&&e.jsx(ds,{listing:se,busy:ft,notice:yt,error:jt,onAdd:t=>{He(t)},onDetails:t=>{St(t)}}),m==="explore"&&e.jsx(cs,{revision:me,search:ue,onDialog:te,onAdded:a}),m==="teams"&&e.jsxs("div",{children:[ge&&e.jsx(rs,{entry:ge,onClose:()=>{be(null),te(!1)},onUse:()=>{const t=ge;be(null),te(!1),Ke(t)}}),S&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-24 text-[13px] text-ink-secondary",children:[e.jsx(T,{size:16,className:"animate-spin"})," ",s("templates.loading")]}),!S&&K&&e.jsxs("div",{className:"rounded-xl bg-danger/10 p-4 text-[13px] text-danger",children:[e.jsx("p",{children:K}),e.jsx("button",{onClick:()=>{ie()},className:"mt-3 rounded-full bg-raised px-3.5 py-2 text-ink hover:bg-raised-hover",children:s("common.tryAgain")})]}),!S&&w&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,360px),1fr))] gap-x-10",children:We.map((t,n)=>{const l=Se(t);return e.jsxs("article",{className:"grid grid-cols-[auto_minmax(0,1fr)] items-start gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx(rt,{index:n}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"[overflow-wrap:anywhere] text-[14px] font-medium text-ink",children:l.name}),e.jsx("p",{className:"mt-0.5 [overflow-wrap:anywhere] text-[13px] text-ink-secondary",children:l.outcome??l.summary}),e.jsxs("p",{className:"mt-1 [overflow-wrap:anywhere] text-[12px] text-ink-tertiary",children:[s("templates.botCount",{count:t.members})," · ",s("templates.playbookCount",{count:t.skills.length}),t.requires.apps.length>0&&` · ${t.requires.apps.join(", ")}`,t.setupMinutes&&` · ${s("templates.minutes",{count:t.setupMinutes})}`]})]}),e.jsxs("div",{className:"col-span-2 flex flex-wrap justify-end gap-2",children:[e.jsx("button",{type:"button","data-team-details":t.slug,onClick:()=>{be(t),te(!0)},className:"shrink-0 rounded-full px-2.5 py-2 text-[13px] text-accent-text hover:underline",children:u("Xem thêm","See more")}),e.jsxs("button",{onClick:()=>{Ke(t)},disabled:r!==null,className:"flex min-w-[72px] items-center justify-center gap-1.5 rounded-full bg-raised px-3.5 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-40",children:[r===t.slug&&e.jsx(T,{size:13,className:"animate-spin"}),r===t.slug?s("templates.loadingShort"):s("templates.load")]})]})]},t.slug)})}),!S&&w&&We.length===0&&e.jsxs("div",{className:"flex min-h-56 flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("templates.noneFound")}),e.jsx("div",{className:"mt-1 text-[13px] text-ink-secondary",children:s("templates.tryDifferentSearch")})]})]}),m==="import"&&e.jsxs("div",{children:[e.jsx("input",{ref:v,type:"file",accept:".md,.json,.mausbackup.json,.mausteam.json,text/markdown,application/json",className:"hidden",onChange:t=>{const n=t.currentTarget.files?.[0];t.currentTarget.value="",n&&Ue(n).catch(l=>y(l instanceof Error?l.message:String(l)))}}),e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:s("templates.bringYourOwn")}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("button",{onClick:()=>v.current?.click(),onDragEnter:t=>{t.preventDefault(),pe(!0)},onDragOver:t=>t.preventDefault(),onDragLeave:()=>pe(!1),onDrop:t=>{t.preventDefault(),pe(!1);const n=t.dataTransfer.files[0];n&&Ue(n).catch(l=>y(l instanceof Error?l.message:String(l)))},className:C("flex min-h-56 flex-col items-center justify-center rounded-2xl border border-dashed px-6 text-center transition-colors",ut?"border-accent bg-accent/5":"border-hairline/60 bg-raised/20 hover:bg-raised/35"),children:[e.jsx(zt,{size:27,className:"text-accent"}),e.jsx("span",{className:"mt-3 text-[14px] font-medium text-ink",children:s("templates.chooseFile")}),e.jsx("span",{className:"mt-1 text-[13px] text-ink-secondary",children:s("templates.dropFile")})]}),e.jsxs("div",{className:"flex min-h-56 flex-col justify-center rounded-2xl bg-raised/25 px-6",children:[e.jsx(Ze,{size:25,className:"text-ink-secondary"}),e.jsx("h3",{className:"mt-3 text-[14px] font-medium text-ink",children:s("templates.loadGithub")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("templates.githubHint")}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("input",{value:xe,onChange:t=>Ce(t.target.value),onKeyDown:t=>t.key==="Enter"&&void Ye(),placeholder:s("templates.githubPlaceholder"),"aria-label":s("templates.githubUrl"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsxs("button",{onClick:()=>{Ye()},disabled:!xe.trim()||Le,className:"flex items-center gap-1.5 rounded-full bg-accent px-4 py-2.5 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[Le&&e.jsx(T,{size:13,className:"animate-spin"}),s("templates.load")]})]})]})]}),M&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:M})]}),m==="share"&&e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("teamLibrary.shareIntro")}),_e.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:s("teamLibrary.shareEmpty")}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:_e.map((t,n)=>e.jsxs("article",{className:"flex min-h-[84px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx(rt,{index:n}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:t.name||s("teamLibrary.general")}),e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:s("teamLibrary.shareBots",{count:t.bots})})]}),e.jsxs("button",{onClick:()=>Ae(t.name),"aria-label":s("teamLibrary.shareTeamAria",{name:t.name||s("teamLibrary.general")}),className:"flex items-center gap-1.5 rounded-full bg-raised px-3.5 py-2 text-[13px] text-ink hover:bg-raised-hover",children:[e.jsx(_t,{size:13}),s("teamLibrary.shareTeam")]})]},t.name||"general"))})]}),m==="scout"&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:s("templates.startFolder")}),e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("templates.scoutHint")}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{value:Be,onChange:t=>ze(t.target.value),onKeyDown:t=>t.key==="Enter"&&q&&void je(q),placeholder:"/path/to/your/project","aria-label":s("templates.projectFolder"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),!!window.ogb?.pickFolder&&e.jsxs("button",{onClick:()=>{Ct()},disabled:Q,className:"flex items-center justify-center gap-1.5 rounded-full bg-raised px-4 py-2.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-40",children:[e.jsx(Ut,{size:14}),s("templates.browse")]}),e.jsxs("button",{onClick:()=>{je(q)},disabled:!q||Q,className:"flex items-center justify-center gap-1.5 rounded-full bg-accent px-4 py-2.5 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[Q?e.jsx(T,{size:14,className:"animate-spin"}):e.jsx(Kt,{size:14}),Q?s("templates.scouting"):s("templates.scout")]})]}),E&&e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"rounded-2xl bg-raised/25 px-5 py-4",children:[e.jsx("div",{className:"text-[15px] font-semibold text-ink",children:E.profile.name}),E.profile.summary&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:E.profile.summary}),E.profile.stacks.length>0&&e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:E.profile.stacks.map(t=>e.jsx("span",{className:"rounded-full bg-raised px-2.5 py-1 text-[12px] text-ink-secondary",children:t},t))})]}),e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:s("templates.suggestedTeam")}),e.jsx("div",{className:"mt-1 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:E.suggestion.manifest.team.members.map((t,n)=>e.jsxs("div",{className:"flex min-h-[64px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[e.jsx("div",{className:C("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",U[n%U.length]),children:t.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-[14px] font-medium text-ink",children:[t.name," ",e.jsxs("span",{className:"font-normal text-ink-secondary",children:["· ",t.title]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:E.suggestion.reasons[t.key]??""})]})]},t.key))}),V&&V.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:s("templates.communityDirectory")}),e.jsx("div",{className:"mt-1 flex flex-col",children:V.map(t=>e.jsxs("div",{className:"flex items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:$e.has(t.slug),onChange:()=>Oe(n=>{const l=new Set(n);return l.has(t.slug)?l.delete(t.slug):l.add(t.slug),l}),className:"size-4 accent-accent"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"truncate text-[14px] font-medium text-ink",children:[t.name,t.category&&e.jsxs("span",{className:"font-normal text-ink-secondary",children:[" · ",t.category]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:s("templates.matches",{values:t.matched.join(", ")})})]})]}),e.jsx("button",{onClick:()=>{at(t.detailUrl)},"aria-label":s("templates.openDirectory",{name:t.name}),title:s("templates.readBeforeAdding"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(Qe,{size:14})})]},t.slug))})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx("input",{value:Re,onChange:t=>De(t.target.value),"aria-label":s("templates.groupChatName"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsxs("button",{onClick:()=>{Lt()},disabled:Z,className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[Z&&e.jsx(T,{size:15,className:"animate-spin"}),Z?s("templates.creating"):s("templates.createGroupChat")]})]}),e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("templates.createGroupHint")})]}),M&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:M})]})]})]}),e.jsx(Zt,{storageKey:"limix.templates.size",widthInset:48,heightInset:48,showGrip:!0})]}),ee!==null&&e.jsx(es,{team:ee,onClose:()=>Ae(null)})]}),document.body)}export{ns as TeamImportDetails,Cs as TeamLibraryPanel,ps as shareableTeamList};
3
+ `)},{label:u("Tổng quan","At a glance"),body:m},{label:u("Thành viên","Members"),body:(o?.members??[]).map(h=>h.title?`${h.name} — ${h.title}`:h.name)},{label:u("Kỹ năng đi kèm","Skills included"),body:o?.skills?.length?o.skills:a.skills},{label:u("Ứng dụng cần kết nối","Apps needed"),body:o?.apps.length?o.apps.map(h=>h.optional?u(`${h.label} (không bắt buộc)`,`${h.label} (optional)`):h.label):a.requires.apps},{label:u("Lưu ý","Notes"),body:o?.warnings??[]}],useLabel:s("templates.load"),onUse:c,onClose:x})}const U=["bg-purple-500/15 text-purple-300","bg-cyan-500/15 text-cyan-300","bg-orange-500/15 text-orange-300","bg-emerald-500/15 text-emerald-300"];function ns({pending:a,importedNames:c,org:x=!1}){return e.jsxs(e.Fragment,{children:[a.description&&e.jsx("p",{className:"max-w-2xl text-[14px] leading-relaxed text-ink-secondary",children:a.description}),a.brief&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.brief")}),e.jsx("p",{className:"mt-1 line-clamp-4 whitespace-pre-wrap break-words",children:a.brief})]}),!!a.warnings?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"mb-2 font-medium text-ink",children:s("templates.backupNotes")}),a.warnings?.map((p,o)=>e.jsx("p",{children:p},o))]}),(a.kind==="package"||a.kind==="backup")&&e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2 text-[12px] text-ink-secondary",children:[a.chiefOfStaff&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Tt,{size:13}),s("templates.leads",{name:a.chiefOfStaff})]}),!a.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(It,{size:13}),s("templates.groupChats",{count:a.rooms})]}),!(a.library&&!a.playbooks)&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx($t,{size:13}),s("templates.playbooks",{count:a.playbooks})]}),!a.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ot,{size:13}),a.version===2?s("teamImport.routinesPaused",{count:a.routines}):s("templates.pausedRoutines",{count:a.routines})]}),a.kind==="package"&&a.version!==2&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ve,{size:13}),s("templates.connections",{count:a.apps.length})]}),!!a.connections?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ve,{size:13}),s("teamImport.connections",{count:a.connections?.length??0})]}),!!a.notes&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Rt,{size:13}),s("teamImport.notes",{count:a.notes??0})]}),!!a.presets?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(lt,{size:13}),s("teamImport.presets",{count:a.presets?.length??0})]})]}),!!a.skills?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:x?s("orgLibrary.skillsOn"):a.version===2?s("teamImport.skillsOff"):s("templates.skillsDisabled")}),e.jsx("p",{className:"mt-1 break-words",children:a.skills?.join(", ")}),!x&&e.jsx("p",{className:"mt-1",children:a.version===2?s("teamImport.skillsReview"):s("templates.skillsReview")})]}),a.library&&!!a.presets?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.presetList")}),e.jsx("p",{className:"mt-1 break-words",children:a.presets?.join(", ")})]}),!!a.offeredSkills?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.offeredSkills")}),e.jsx("p",{className:"mt-1 break-words",children:a.offeredSkills?.join(", ")})]}),!!a.connections?.length&&e.jsxs("div",{className:"mt-4 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamImport.connections",{count:a.connections?.length??0})}),e.jsx("ul",{className:"mt-1",children:a.connections?.map((p,o)=>e.jsxs("li",{className:"truncate",children:[p.label," · ",p.url]},`${p.label}-${o}`))})]}),a.members.length>0&&e.jsx("div",{className:"mt-6 text-[12px] font-medium text-ink-secondary",children:s("templates.teamMembers")}),e.jsx("div",{className:"mt-2 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:a.members.map((p,o)=>e.jsxs("div",{className:"flex min-h-[72px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[a.pictures?.[o]?e.jsx("img",{src:a.pictures[o],alt:"",className:"size-9 shrink-0 rounded-lg object-cover"}):e.jsx("div",{className:C("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",U[o%U.length]),children:p.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-medium text-ink",children:c[o]}),c[o]!==p.name&&e.jsx("div",{className:"text-[12px] text-ink-secondary",children:s("templates.newCopyOf",{name:p.name})}),e.jsx("div",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:p.title||s("templates.generalAssistant")})]})]},`${p.name}-${o}`))}),e.jsxs("div",{className:"mt-6 flex items-start gap-2.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(ve,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("p",{children:a.kind==="backup"?s("templates.backupSafety",{archived:a.archivedBots?s("templates.archivedBots",{count:a.archivedBots}):""}):x?a.members.length?s("orgLibrary.teamSafety"):s("orgLibrary.librarySafety"):a.library?s("teamImport.librarySafety"):a.version===2?s("teamImport.sharedTeamSafety"):a.kind==="package"?s("templates.packageSafety"):s("templates.legacySafety")})]})]})}async function is(a,c){for(const x of c??[])await fetch(`/api/limix/skill-store/${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:x,add:!0})}).catch(()=>{})}const et={gmail:"Gmail",github:"GitHub",discord:"Discord",slack:"Slack",googlecalendar:"Google Calendar",notion:"Notion",linear:"Linear",figma:"Figma",gong:"Gong",hubspot:"HubSpot",postiz:"Postiz"},ke={everyday:"readyBots.category.everyday",work:"readyBots.category.work",writing:"readyBots.category.writing",design:"readyBots.category.design",sales:"readyBots.category.sales",personal:"readyBots.category.personal"},Ne=()=>ct.map(a=>{const c=Mt(a);return{id:a.id,name:a.name,title:c.title,category:a.category,description:c.description,try:c.tryAsking,look:a.look,apps:a.apps,routines:a.routines?.length??0,builtIn:!0}});let _=null;async function ls(){const{bots:a}=await L("/api/limix/bots/refresh",{method:"POST"});return _=a.length?a.map(c=>({...c,builtIn:!1})):null,a.length}const os=(a,c)=>{const x=c.trim().toLowerCase();return!x||[a.name,a.title,a.description,a.category].some(p=>p.toLowerCase().includes(x))};function cs({search:a,onDialog:c,onAdded:x,revision:p=0}){const{state:o,dispatch:g}=ot(),[N,v]=i.useState(null),[m,h]=i.useState(_),[w,k]=i.useState(!1),[S,R]=i.useState(null),[K,Y]=i.useState(""),[$,A]=i.useState(null);i.useEffect(()=>{if(p>0){h(_??Ne()),k(!1);return}let r=!0;return L("/api/limix/bots").then(({bots:f})=>{if(!r)return;const d=f.length?f.map(P=>({...P,builtIn:!1})):Ne();_=f.length?d:null,h(d),k(!1)}).catch(()=>{r&&(h(_??Ne()),k(!_))}),()=>{r=!1}},[p]);const H=()=>{A(null),c(!1)},[b,B]=i.useState(null),J=r=>{if(c(!0),r.builtIn){B({card:r,bot:ct.find(f=>f.id===r.id)});return}B({card:r}),L(`/api/limix/bots/${r.id}`).then(({bot:f})=>B(d=>d?.card.id===r.id?{card:r,bot:f}:d),f=>B(d=>d?.card.id===r.id?{card:r,error:f instanceof Error?f.message:String(f)}:d))},me=()=>{B(null),c(!1)},W=async r=>{if(!(S||Gt(o))){if(Y(""),window.ogb?.remoteClient?.active){g({type:"newBot",onCreated:x});return}if(r.builtIn){A({id:r.id}),c(!0);return}R(r.id);try{const{bot:f}=await L(`/api/limix/bots/${r.id}`);A({id:r.id,data:f,skills:f.skills}),c(!0)}catch(f){Y(f instanceof Error?f.message:String(f))}finally{R(null)}}};if(!m)return e.jsxs("div",{className:"mb-8 flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(T,{size:15,className:"animate-spin"}),s("templates.loading")]});const D=m.filter(r=>(!N||r.category===N)&&os(r,a));return a.trim()&&D.length===0?null:e.jsxs("section",{className:"mb-8","aria-labelledby":"ready-bots-title",children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-baseline justify-between gap-2",children:[e.jsx("h3",{id:"ready-bots-title",className:"text-[12px] font-medium text-ink-secondary",children:s("readyBots.title")}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx("p",{className:"text-[12px] text-ink-tertiary",role:"status","aria-live":"polite",children:w?u("Đang dùng bản có sẵn trong ứng dụng (chưa tải được kho mẫu).","Showing the bots built into the app (the template library could not be loaded)."):s("readyBots.subtitle")})})]}),e.jsx("div",{className:"mb-3 mt-2 flex flex-wrap gap-1.5",role:"group","aria-label":s("readyBots.categories"),children:[null,...Dt].map(r=>e.jsx("button",{type:"button","aria-pressed":N===r,onClick:()=>v(r),className:C("rounded-full px-3 py-1 text-[13px] transition-colors",N===r?"bg-ink text-panel":"bg-raised/70 text-ink-secondary hover:text-ink"),children:r?s(ke[r]):s("readyBots.all")},r??"all"))}),K&&e.jsx("p",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[13px] text-danger",children:K}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,280px),1fr))] gap-3",children:D.map(r=>e.jsxs("article",{"data-ready-bot":r.id,className:"flex min-w-0 flex-col rounded-2xl border border-hairline/40 bg-card p-4 [overflow-wrap:anywhere]",children:[e.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)] items-center gap-3",children:[e.jsx(Xe,{color:r.look.color,bodyId:r.look.mascotBody,state:r.look.mascotExpression??"idle",size:40,animated:!1,label:r.name}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"text-[14px] font-medium text-ink",children:r.name}),e.jsxs("p",{className:"text-[12px] text-ink-secondary",children:[r.title," · ",s(ke[r.category])]})]})]}),e.jsx("p",{className:"mt-3 text-[13px] leading-[1.45] text-ink-secondary",children:r.description}),e.jsx("p",{className:"mt-2 text-[12px] italic text-ink-tertiary",children:s("readyBots.try",{prompt:r.try})}),e.jsxs("div",{className:"mt-auto flex flex-wrap items-center justify-between gap-2 pt-3",children:[e.jsxs("button",{type:"button","data-ready-bot-details":r.id,onClick:()=>J(r),"aria-label":u(`Xem thêm về ${r.name}`,`More about ${r.name}`),className:"flex w-fit items-center gap-1 text-[12px] font-medium text-accent-text hover:underline focus-visible:outline-2 focus-visible:outline-accent",children:[e.jsx(Pt,{size:13,"aria-hidden":"true"}),u("Xem thêm","See more")]}),e.jsxs("button",{type:"button",onClick:()=>{W(r)},disabled:S!==null,"aria-label":u(`Dùng mẫu ${r.name}, ${r.title}`,`Use template ${r.name}, ${r.title}`),className:"flex h-8 shrink-0 items-center gap-1 rounded-full bg-raised px-3 text-[13px] font-medium text-ink hover:bg-raised-hover disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-accent",children:[S===r.id?e.jsx(T,{size:14,className:"animate-spin","aria-hidden":"true"}):e.jsx(it,{size:14,"aria-hidden":"true"}),u("Dùng mẫu","Use template")]})]}),(r.apps.length>0||r.routines>0)&&e.jsx("p",{className:"pt-2 text-[12px] text-ink-tertiary",children:[r.apps.length>0&&s("readyBots.worksWith",{apps:r.apps.map(f=>et[f]??f).join(", ")}),r.routines>0&&s("readyBots.pausedRoutine")].filter(Boolean).join(" · ")})]},r.id))}),b&&e.jsx(mt,{title:b.card.name,subtitle:`${b.card.title} · ${s(ke[b.card.category])}`,icon:e.jsx(Xe,{color:b.card.look.color,bodyId:b.card.look.mascotBody,state:b.card.look.mascotExpression??"idle",size:44,animated:!1,label:b.card.name}),loading:!b.bot&&!b.error,error:b.error,sections:[{label:u("Bot này làm gì","What it does"),body:b.bot?.description??b.card.description},{label:u("Cách bot làm việc","How it works"),body:b.bot?.soul??""},{label:u("Bạn có thể hỏi","Things to ask"),body:b.bot?.tryAsking??[b.card.try]},{label:u("Kỹ năng đi kèm","Skills included"),body:b.bot?.skills??[]},{label:u("Ứng dụng nên kết nối","Apps it works with"),body:(b.bot?.apps??b.card.apps).map(r=>et[r]??r)},{label:u("Lịch định kỳ (tạo ở trạng thái tạm dừng)","Routines (created paused)"),body:(b.bot?.routines??[]).map(r=>r.schedule&&"time"in r.schedule&&r.schedule.time?`${r.name} · ${r.schedule.time}`:r.name)}],useLabel:u("Dùng mẫu","Use template"),onUse:()=>{const r=b.card;B(null),W(r)},onClose:me}),$&&we.createPortal(e.jsx(At,{readyBotId:$.id,readyBotData:$.data,onClose:H,onCreated:r=>{c(!1),is(r.id,$.skills),x(r)}}),document.body)]})}const tt=["bg-cyan-500/15 text-cyan-300","bg-purple-500/15 text-purple-300","bg-emerald-500/15 text-emerald-300","bg-orange-500/15 text-orange-300"];function ds({listing:a,busy:c,notice:x,error:p,onAdd:o,onDetails:g}){const N=a.organization.name;return e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("orgLibrary.intro",{name:N})}),a.packages.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:s("orgLibrary.empty",{name:N})}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:a.packages.map((v,m)=>e.jsx(ms,{entry:v,index:m,busy:c,onAdd:o,onDetails:g},v.packageId))}),x&&e.jsx("div",{role:"status",className:"mt-4 rounded-lg bg-raised/60 px-3 py-2 text-[13px] text-ink-secondary",children:x}),p&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:p})]})}function ms({entry:a,index:c,busy:x,onAdd:p,onDetails:o}){const g=dt(a),N=Yt(a),v=qt(a),m=x===a.packageId;return e.jsxs("article",{className:"flex min-h-[104px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx("div",{className:C("flex size-11 shrink-0 items-center justify-center rounded-xl",tt[c%tt.length]),children:e.jsx(Bt,{size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:a.name}),e.jsx("p",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:a.tagline}),e.jsxs("p",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:Ht(a)}),N&&e.jsx("span",{className:"rounded-full bg-accent/10 px-2 py-0.5 text-accent-text",children:N}),a.release&&e.jsx("span",{children:a.release.version})]}),e.jsx("p",{className:"mt-0.5 truncate text-[12px] text-ink-tertiary",children:Jt(a.contents)}),v.map(h=>e.jsx("p",{className:"mt-0.5 text-[12px] text-warning",children:h},h))]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[g==="add"&&e.jsxs("button",{onClick:()=>p(a),disabled:x!==null,"aria-label":s("orgLibrary.addAria",{name:a.name}),className:"flex min-w-[72px] items-center justify-center gap-1.5 rounded-full bg-accent px-3.5 py-2 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[m&&e.jsx(T,{size:13,className:"animate-spin"}),m?s("orgLibrary.adding"):s("orgLibrary.add")]}),g==="added"&&e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-raised px-3 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(ve,{size:13,className:"text-success"}),s("orgLibrary.added")]}),g==="updateApp"&&e.jsx("span",{className:"max-w-[140px] text-right text-[12px] text-ink-secondary",children:s("orgLibrary.updateApp")}),g==="notReady"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("orgLibrary.notReady")}),g==="noRelease"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("orgLibrary.noRelease")}),a.blob==="ready"&&e.jsx("button",{onClick:()=>o(a),disabled:x!==null,"aria-label":s("orgLibrary.detailsAria",{name:a.name}),className:"rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:s("orgLibrary.details")})]})]})}const xs="https://github.com/leomieo/limix-bot-teams",st=["cyan","red","purple","green","orange"];async function at(a){if(window.ogb?.openExternal){await window.ogb.openExternal(a);return}const c=window.open(a,"_blank","noopener,noreferrer");c&&(c.opener=null)}function ps(a,c){const x=new Map;for(const o of c){if(o.hidden)continue;const g=o.section?.trim()??"";x.set(g,(x.get(g)??0)+1)}return[...[...new Set([...a.map(o=>o.trim()).filter(Boolean),...x.keys()])].filter(o=>o!==""),""].flatMap(o=>x.get(o)?[{name:o,bots:x.get(o)}]:[])}function rt({index:a}){return e.jsx("div",{className:C("flex size-11 shrink-0 items-center justify-center rounded-xl",U[a%U.length]),children:e.jsx(lt,{size:20})})}function Cs({onClose:a,onImported:c,returnFocusRef:x,initialUrl:p}){const{state:o,dispatch:g}=ot(),N=i.useRef(null),v=i.useRef(null),[m,h]=i.useState("explore"),[w,k]=i.useState(null),[S,R]=i.useState(!0),[K,Y]=i.useState(""),[$,A]=i.useState(!1),[H,b]=i.useState(""),[B,J]=i.useState(""),[me,W]=i.useState(0),D=i.useRef(0),[r,f]=i.useState(null),[d,P]=i.useState(null),[xt,pt]=i.useState("file"),[xe,Ce]=i.useState(""),[Le,Ee]=i.useState(!1),[I,X]=i.useState(!1),[ut,pe]=i.useState(!1),[ue,ht]=i.useState(""),[M,y]=i.useState(""),[Be,ze]=i.useState(""),[Q,Te]=i.useState(!1),[E,Ie]=i.useState(null),[gt,bt]=i.useState(""),[V,he]=i.useState(null),[$e,Oe]=i.useState(new Set),[Re,De]=i.useState(""),[Z,Pe]=i.useState(!1),[ee,Ae]=i.useState(null),[Me,te]=i.useState(!1),[ge,be]=i.useState(null),[se,Ge]=i.useState(null),[ft,ae]=i.useState(null),[yt,Fe]=i.useState(""),[jt,re]=i.useState(""),[G,ne]=i.useState(null),O=i.useRef(!1),F=i.useRef(0),fe=o.bots.filter(t=>!t.hidden).length,_e=ps(o.sections??[],o.bots),kt=new Set(o.bots.map(t=>t.name.trim().toLowerCase())),Nt=d?.members.map(t=>Qt(t.name,kt))??[],ie=i.useCallback(async(t=!1)=>{const n=++D.current;R(!0),Y("");try{const l=await L(`/api/team-library/catalog${t?"?fresh=1":""}`);return n===D.current&&k(l),!0}catch(l){return n===D.current&&Y(l instanceof Error?l.message:String(l)),!1}finally{n===D.current&&R(!1)}},[]),vt=async()=>{if(!$){A(!0),b(""),J("");try{const[t,n]=await Promise.allSettled([ls(),ie(!0)]);if(t.status==="fulfilled"&&W(l=>l+1),t.status==="fulfilled"&&n.status==="fulfilled"&&n.value)b(u("Đã cập nhật mẫu Bot và mẫu nhóm Bot.","Bot and team templates updated."));else{const l=[...t.status==="rejected"?[u("mẫu Bot","bot templates")]:[],...n.status==="rejected"||!n.value?[u("mẫu nhóm Bot","team templates")]:[]];J(u(`Chưa cập nhật được ${l.join(", ")}. Hãy thử lại.`,`Could not update ${l.join(", ")}. Please retry.`))}}finally{A(!1)}}};i.useEffect(()=>{ie()},[ie]);const le=i.useCallback(async()=>{try{const t=await L("/api/org-library");Ge(t),t.organization&&!O.current&&h("org")}catch{Ge({organization:null,packages:[]})}},[]);i.useEffect(()=>{le()},[le]),i.useEffect(()=>(N.current?.focus(),()=>x.current?.focus()),[x]),i.useEffect(()=>{const t=n=>{if(ee!==null||Me)return;if(n.key==="Escape"&&!I){n.preventDefault(),n.stopPropagation(),d?(P(null),ne(null)):a();return}if(n.key!=="Tab")return;const l=N.current,j=Array.from(l?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex="-1"])')??[]);if(!l||j.length===0)return;const z=j[0],oe=j.at(-1);n.shiftKey&&(document.activeElement===z||!l.contains(document.activeElement))?(n.preventDefault(),oe.focus()):!n.shiftKey&&document.activeElement===oe&&(n.preventDefault(),z.focus())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[I,a,d,ee,Me]);const ye=(t,n)=>{P(t),pt(n),y("")},Ue=async t=>{if(t.size>Xt)throw new Error(s("templates.fileTooLarge"));const n=await t.text();let l=n;if(!t.name.toLowerCase().endsWith(".md"))try{l=JSON.parse(n)}catch(j){throw j instanceof SyntaxError?new Error(s("teamLibrary.invalidJson")):j}ye(de(l),"file")},Ke=async t=>{f(t.slug),y("");try{ye(de(await L(`/api/team-library/teams/${t.slug}`)),"library")}catch(n){y(n instanceof Error?n.message:String(n))}finally{f(null)}},Ye=async()=>{await qe(xe)},qe=async t=>{if(t.trim()){Ee(!0),y("");try{const n=await L("/api/team-library/github",{method:"POST",body:JSON.stringify({url:t.trim()})});ye(de(n),"github")}catch(n){y(n instanceof Error?n.message:String(n))}finally{Ee(!1)}}};i.useEffect(()=>{p&&(O.current=!0,h("import"),Ce(p),qe(p))},[p]);const wt=async()=>{if(d){X(!0),y("");try{const t=await Vt(d.manifest,g);ce("team_imported",{members:t.bots.length,source:xt,mode:"add",format:d.kind}),c({name:d.name,members:t.bots.length,...t.connections?.length?{connections:t.connections.length}:{},...t.presets?.length?{presets:t.presets.length}:{}})}catch(t){y(t instanceof Error?t.message:String(t))}finally{X(!1)}}},St=async t=>{ae(t.packageId),re("");try{const n=await L(`/api/org-library/packages/${t.packageId}`);P(Wt(n.document)),ne(t),y("")}catch(n){re(n instanceof Error?n.message:String(n))}finally{ae(null)}},He=async t=>{ae(t.packageId),X(!0),re(""),Fe(""),y("");try{const n=await L("/api/org-library/add",{method:"POST",body:JSON.stringify({packageId:t.packageId})});for(const j of n.bots??[])g({type:"botAdded",bot:j});for(const j of n.groups??[])g({type:"groupPatched",group:j});for(const j of n.routines??[])g({type:"routinePatched",routine:j});const l=n.bots?.find(j=>!j.hidden);if(ce("team_imported",{members:n.bots?.length??0,source:"organization",mode:"add",format:"package"}),l){g({type:"select",id:l.id}),c({name:t.name,members:n.bots.length,...n.connections?.length?{connections:n.connections.length}:{}});return}P(null),ne(null),n.alreadyAdded||Fe(s("orgLibrary.addedSkills",{name:t.name})),await le()}catch(n){const l=n instanceof Error?n.message:String(n);G?y(l):re(l),await le()}finally{ae(null),X(!1)}},q=Be.trim(),je=async t=>{const n=++F.current;Te(!0),y(""),Ie(null),he(null),Oe(new Set);try{const l=await L(`/api/teams/scout?cwd=${encodeURIComponent(t)}`);if(n!==F.current)return;Ie(l),bt(t),De(l.suggestion.roomName),ce("team_scouted",{signals:l.suggestion.manifest.team.members.length-1}),L(`/api/teams/scout/directory?cwd=${encodeURIComponent(t)}`).then(j=>{n===F.current&&he(j.directory)}).catch(()=>{n===F.current&&he([])})}catch(l){if(n!==F.current)return;y(l instanceof Error?l.message:String(l))}finally{n===F.current&&Te(!1)}},Ct=async()=>{const t=await window.ogb?.pickFolder?.(q||void 0);t&&(ze(t),await je(t))},Lt=async()=>{if(!(!E||Z)){Pe(!0),y("");try{const t=(V??[]).filter(z=>$e.has(z.slug)).map((z,oe)=>({key:`dir-${z.slug}`,name:z.name,title:z.category||s("templates.communityBot"),description:z.prompt,appearance:{color:st[oe%st.length]}})),n={...E.suggestion.manifest,team:{...E.suggestion.manifest.team,members:[...E.suggestion.manifest.team.members,...t]}},l=Re.trim()||E.suggestion.roomName,j=await L(`/api/teams/import?mode=project&cwd=${encodeURIComponent(gt)}&room=${encodeURIComponent(l)}`,{method:"POST",body:JSON.stringify(n)});for(const z of j.bots)g({type:"botAdded",bot:z});j.group&&(g({type:"groupPatched",group:{...j.group,messages:[]}}),g({type:"select",id:j.group.id})),ce("team_imported",{members:j.bots.length,source:"scout",mode:"project"}),c({name:l,members:j.bots.length})}catch(t){y(t instanceof Error?t.message:String(t))}finally{Pe(!1)}}},Je=ue.trim().toLowerCase(),We=(w?.teams??[]).filter(t=>!Je||as(t,Je));return we.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4 sm:p-6",onMouseDown:t=>t.stopPropagation(),children:[e.jsxs("div",{ref:N,role:"dialog","aria-modal":"true","aria-labelledby":"team-library-title",tabIndex:-1,className:"animate-pop-in relative flex h-[min(780px,calc(100dvh-2rem))] max-h-full w-[min(100%,1040px)] 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 px-6 pb-3 pt-6 sm:px-8 sm:pt-7",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx("button",{onClick:()=>{P(null),ne(null),y("")},disabled:I,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":s("templates.back"),children:e.jsx(Ft,{size:18})}),e.jsx("h2",{id:"team-library-title",className:"[overflow-wrap:anywhere] text-[22px] font-semibold tracking-[-0.01em] text-ink",children:d?d.name:s("templates.title")})]}),e.jsx("p",{className:C("mt-1 text-[13px] text-ink-secondary",d&&"ml-9"),children:d?d.kind==="backup"?s("templates.backupSummary",{bots:d.members.length,conversations:d.conversations??0}):d.kind==="package"?d.library?s("teamImport.library"):d.version===2?s("teamImport.sharedTeam",{count:d.members.length}):s("templates.playbookSummary",{count:d.members.length}):s("templates.readyBots",{count:d.members.length}):s("templates.subtitle")})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!d&&e.jsxs("button",{onClick:()=>{at(w?.repositoryUrl??xs)},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-2 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",title:s("templates.openRepository"),children:[e.jsx(Ze,{size:16}),e.jsx("span",{className:"max-sm:hidden",children:s("templates.communityRepo")}),e.jsx(Qe,{size:12})]}),e.jsx("button",{onClick:a,disabled:I,className:"rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":s("templates.close"),children:e.jsx(nt,{size:21})})]})]}),d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-6 pt-6 sm:px-8",children:[e.jsx(ns,{pending:d,importedNames:Nt,org:G!==null}),M&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:M})]}),e.jsxs("footer",{className:"flex flex-col gap-3 border-t border-hairline/35 px-6 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-8",children:[e.jsxs("div",{className:"text-[13px] text-ink-secondary",children:[s(fe===0?"templates.existingNone":fe===1?"templates.existingOne":"templates.existingMany",{count:fe})," ",d.kind==="backup"?s("teamImport.backupCopies"):d.library?s("teamImport.libraryAdds"):d.members.length===0?"":s("teamImport.newSection",{name:d.teamName??d.name})]}),G?dt(G)==="add"?e.jsxs("button",{onClick:()=>{He(G)},disabled:I,"aria-label":s("orgLibrary.addAria",{name:G.name}),className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[I&&e.jsx(T,{size:15,className:"animate-spin"}),I?s("orgLibrary.adding"):s("orgLibrary.add")]}):e.jsxs("span",{className:"flex shrink-0 items-center gap-1 rounded-full bg-raised px-4 py-2 text-[13px] text-ink-secondary",children:[e.jsx(ve,{size:14,className:"text-success"}),s("orgLibrary.added")]}):e.jsxs("button",{onClick:()=>{wt()},disabled:I,className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[I&&e.jsx(T,{size:15,className:"animate-spin"}),I?s("templates.importing"):d.kind==="backup"?s("templates.importBackup"):d.library?s("teamImport.addPresets"):s("templates.addTeam")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-6 pb-4 pt-5 sm:px-8",children:[e.jsxs("div",{className:"flex max-w-full flex-wrap rounded-xl bg-raised/70 p-1",role:"tablist","aria-label":s("templates.source"),children:[se?.organization&&e.jsx("button",{role:"tab","aria-selected":m==="org",onClick:()=>{O.current=!0,h("org"),y("")},className:C("max-w-[220px] truncate rounded-lg px-4 py-2 text-[14px] transition-colors",m==="org"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("orgLibrary.tab",{name:se.organization.name})}),e.jsx("button",{role:"tab","aria-selected":m==="explore",onClick:()=>{O.current=!0,h("explore"),y("")},className:C("rounded-lg px-4 py-2 text-[14px] transition-colors",m==="explore"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.explore")}),e.jsx("button",{role:"tab","aria-selected":m==="import",onClick:()=>{O.current=!0,h("import"),y("")},className:C("rounded-lg px-4 py-2 text-[14px] transition-colors",m==="import"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.import")}),e.jsx("button",{role:"tab","aria-selected":m==="scout",onClick:()=>{O.current=!0,h("scout"),y("")},className:C("rounded-lg px-4 py-2 text-[14px] transition-colors",m==="scout"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("templates.fromFolder")}),e.jsx("button",{role:"tab","aria-selected":m==="share",onClick:()=>{O.current=!0,h("share"),y("")},className:C("rounded-lg px-4 py-2 text-[14px] transition-colors",m==="share"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s("teamLibrary.shareTab")}),e.jsx("button",{role:"tab","aria-selected":m==="teams",onClick:()=>{O.current=!0,h("teams"),y("")},className:C("rounded-lg px-4 py-2 text-[14px] transition-colors",m==="teams"?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:u("Bản mẫu Nhóm","Team templates")})]}),e.jsxs("button",{type:"button",onClick:()=>{vt()},disabled:$,title:u("Tải lại mẫu Bot và mẫu nhóm Bot mới nhất từ kho","Reload the latest bot and team templates"),className:"flex h-10 shrink-0 items-center gap-1.5 rounded-xl bg-raised/70 px-3 text-[13px] font-medium text-ink hover:bg-raised-hover disabled:opacity-60",children:[e.jsx(ts,{size:14,"aria-hidden":"true",className:$?"animate-spin":void 0}),$?u("Đang cập nhật","Updating"):u("Cập nhật","Update")]}),(m==="explore"||m==="teams")&&e.jsxs("label",{className:"flex h-11 w-full items-center gap-2.5 rounded-xl bg-raised/70 px-3.5 sm:ml-auto sm:w-[240px]",children:[e.jsx(Et,{size:17,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:ue,onChange:t=>ht(t.target.value),placeholder:s("templates.search"),"aria-label":s("templates.search"),className:"min-w-0 flex-1 bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})]}),(H||B)&&e.jsx("p",{role:B?"alert":"status",className:C("px-6 pb-2 text-[13px] sm:px-8",B?"text-danger":"text-ink-secondary"),children:B||H}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-7 pt-5 sm:px-8",children:[m==="org"&&se?.organization&&e.jsx(ds,{listing:se,busy:ft,notice:yt,error:jt,onAdd:t=>{He(t)},onDetails:t=>{St(t)}}),m==="explore"&&e.jsx(cs,{revision:me,search:ue,onDialog:te,onAdded:a}),m==="teams"&&e.jsxs("div",{children:[ge&&e.jsx(rs,{entry:ge,onClose:()=>{be(null),te(!1)},onUse:()=>{const t=ge;be(null),te(!1),Ke(t)}}),S&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-24 text-[13px] text-ink-secondary",children:[e.jsx(T,{size:16,className:"animate-spin"})," ",s("templates.loading")]}),!S&&K&&e.jsxs("div",{className:"rounded-xl bg-danger/10 p-4 text-[13px] text-danger",children:[e.jsx("p",{children:K}),e.jsx("button",{onClick:()=>{ie()},className:"mt-3 rounded-full bg-raised px-3.5 py-2 text-ink hover:bg-raised-hover",children:s("common.tryAgain")})]}),!S&&w&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,360px),1fr))] gap-x-10",children:We.map((t,n)=>{const l=Se(t);return e.jsxs("article",{className:"grid grid-cols-[auto_minmax(0,1fr)] items-start gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx(rt,{index:n}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"[overflow-wrap:anywhere] text-[14px] font-medium text-ink",children:l.name}),e.jsx("p",{className:"mt-0.5 [overflow-wrap:anywhere] text-[13px] text-ink-secondary",children:l.outcome??l.summary}),e.jsxs("p",{className:"mt-1 [overflow-wrap:anywhere] text-[12px] text-ink-tertiary",children:[s("templates.botCount",{count:t.members})," · ",s("templates.playbookCount",{count:t.skills.length}),t.requires.apps.length>0&&` · ${t.requires.apps.join(", ")}`,t.setupMinutes&&` · ${s("templates.minutes",{count:t.setupMinutes})}`]})]}),e.jsxs("div",{className:"col-span-2 flex flex-wrap justify-end gap-2",children:[e.jsx("button",{type:"button","data-team-details":t.slug,onClick:()=>{be(t),te(!0)},className:"shrink-0 rounded-full px-2.5 py-2 text-[13px] text-accent-text hover:underline",children:u("Xem thêm","See more")}),e.jsxs("button",{onClick:()=>{Ke(t)},disabled:r!==null,className:"flex min-w-[72px] items-center justify-center gap-1.5 rounded-full bg-raised px-3.5 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-40",children:[r===t.slug&&e.jsx(T,{size:13,className:"animate-spin"}),r===t.slug?s("templates.loadingShort"):s("templates.load")]})]})]},t.slug)})}),!S&&w&&We.length===0&&e.jsxs("div",{className:"flex min-h-56 flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("templates.noneFound")}),e.jsx("div",{className:"mt-1 text-[13px] text-ink-secondary",children:s("templates.tryDifferentSearch")})]})]}),m==="import"&&e.jsxs("div",{children:[e.jsx("input",{ref:v,type:"file",accept:".md,.json,.mausbackup.json,.mausteam.json,text/markdown,application/json",className:"hidden",onChange:t=>{const n=t.currentTarget.files?.[0];t.currentTarget.value="",n&&Ue(n).catch(l=>y(l instanceof Error?l.message:String(l)))}}),e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:s("templates.bringYourOwn")}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("button",{onClick:()=>v.current?.click(),onDragEnter:t=>{t.preventDefault(),pe(!0)},onDragOver:t=>t.preventDefault(),onDragLeave:()=>pe(!1),onDrop:t=>{t.preventDefault(),pe(!1);const n=t.dataTransfer.files[0];n&&Ue(n).catch(l=>y(l instanceof Error?l.message:String(l)))},className:C("flex min-h-56 flex-col items-center justify-center rounded-2xl border border-dashed px-6 text-center transition-colors",ut?"border-accent bg-accent/5":"border-hairline/60 bg-raised/20 hover:bg-raised/35"),children:[e.jsx(zt,{size:27,className:"text-accent"}),e.jsx("span",{className:"mt-3 text-[14px] font-medium text-ink",children:s("templates.chooseFile")}),e.jsx("span",{className:"mt-1 text-[13px] text-ink-secondary",children:s("templates.dropFile")})]}),e.jsxs("div",{className:"flex min-h-56 flex-col justify-center rounded-2xl bg-raised/25 px-6",children:[e.jsx(Ze,{size:25,className:"text-ink-secondary"}),e.jsx("h3",{className:"mt-3 text-[14px] font-medium text-ink",children:s("templates.loadGithub")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("templates.githubHint")}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("input",{value:xe,onChange:t=>Ce(t.target.value),onKeyDown:t=>t.key==="Enter"&&void Ye(),placeholder:s("templates.githubPlaceholder"),"aria-label":s("templates.githubUrl"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsxs("button",{onClick:()=>{Ye()},disabled:!xe.trim()||Le,className:"flex items-center gap-1.5 rounded-full bg-accent px-4 py-2.5 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[Le&&e.jsx(T,{size:13,className:"animate-spin"}),s("templates.load")]})]})]})]}),M&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:M})]}),m==="share"&&e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("teamLibrary.shareIntro")}),_e.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:s("teamLibrary.shareEmpty")}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:_e.map((t,n)=>e.jsxs("article",{className:"flex min-h-[84px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx(rt,{index:n}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:t.name||s("teamLibrary.general")}),e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:s("teamLibrary.shareBots",{count:t.bots})})]}),e.jsxs("button",{onClick:()=>Ae(t.name),"aria-label":s("teamLibrary.shareTeamAria",{name:t.name||s("teamLibrary.general")}),className:"flex items-center gap-1.5 rounded-full bg-raised px-3.5 py-2 text-[13px] text-ink hover:bg-raised-hover",children:[e.jsx(_t,{size:13}),s("teamLibrary.shareTeam")]})]},t.name||"general"))})]}),m==="scout"&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:s("templates.startFolder")}),e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:s("templates.scoutHint")}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{value:Be,onChange:t=>ze(t.target.value),onKeyDown:t=>t.key==="Enter"&&q&&void je(q),placeholder:"/path/to/your/project","aria-label":s("templates.projectFolder"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),!!window.ogb?.pickFolder&&e.jsxs("button",{onClick:()=>{Ct()},disabled:Q,className:"flex items-center justify-center gap-1.5 rounded-full bg-raised px-4 py-2.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-40",children:[e.jsx(Ut,{size:14}),s("templates.browse")]}),e.jsxs("button",{onClick:()=>{je(q)},disabled:!q||Q,className:"flex items-center justify-center gap-1.5 rounded-full bg-accent px-4 py-2.5 text-[13px] font-medium text-white hover:bg-accent/90 disabled:opacity-40",children:[Q?e.jsx(T,{size:14,className:"animate-spin"}):e.jsx(Kt,{size:14}),Q?s("templates.scouting"):s("templates.scout")]})]}),E&&e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"rounded-2xl bg-raised/25 px-5 py-4",children:[e.jsx("div",{className:"text-[15px] font-semibold text-ink",children:E.profile.name}),E.profile.summary&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:E.profile.summary}),E.profile.stacks.length>0&&e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:E.profile.stacks.map(t=>e.jsx("span",{className:"rounded-full bg-raised px-2.5 py-1 text-[12px] text-ink-secondary",children:t},t))})]}),e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:s("templates.suggestedTeam")}),e.jsx("div",{className:"mt-1 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:E.suggestion.manifest.team.members.map((t,n)=>e.jsxs("div",{className:"flex min-h-[64px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[e.jsx("div",{className:C("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",U[n%U.length]),children:t.name.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-[14px] font-medium text-ink",children:[t.name," ",e.jsxs("span",{className:"font-normal text-ink-secondary",children:["· ",t.title]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:E.suggestion.reasons[t.key]??""})]})]},t.key))}),V&&V.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:s("templates.communityDirectory")}),e.jsx("div",{className:"mt-1 flex flex-col",children:V.map(t=>e.jsxs("div",{className:"flex items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:$e.has(t.slug),onChange:()=>Oe(n=>{const l=new Set(n);return l.has(t.slug)?l.delete(t.slug):l.add(t.slug),l}),className:"size-4 accent-accent"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"truncate text-[14px] font-medium text-ink",children:[t.name,t.category&&e.jsxs("span",{className:"font-normal text-ink-secondary",children:[" · ",t.category]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:s("templates.matches",{values:t.matched.join(", ")})})]})]}),e.jsx("button",{onClick:()=>{at(t.detailUrl)},"aria-label":s("templates.openDirectory",{name:t.name}),title:s("templates.readBeforeAdding"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(Qe,{size:14})})]},t.slug))})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx("input",{value:Re,onChange:t=>De(t.target.value),"aria-label":s("templates.groupChatName"),className:"min-w-0 flex-1 rounded-xl bg-raised/80 px-3 py-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsxs("button",{onClick:()=>{Lt()},disabled:Z,className:"flex shrink-0 items-center justify-center gap-2 rounded-full bg-accent px-5 py-2.5 text-[14px] font-medium text-white hover:bg-accent/90 disabled:opacity-60",children:[Z&&e.jsx(T,{size:15,className:"animate-spin"}),Z?s("templates.creating"):s("templates.createGroupChat")]})]}),e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("templates.createGroupHint")})]}),M&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:M})]})]})]}),e.jsx(Zt,{storageKey:"limix.templates.size",widthInset:48,heightInset:48,showGrip:!0})]}),ee!==null&&e.jsx(es,{team:ee,onClose:()=>Ae(null)})]}),document.body)}export{ns as TeamImportDetails,Cs as TeamLibraryPanel,ps as shareableTeamList};
@@ -0,0 +1 @@
1
+ import{c as We,t as s,r as a,j as e,a as ne,F as Qe,X as Be,d as kt,i as Ee,ac as jt}from"./styles-CWnH418X.js";import{L as Re,W as wt,B as Ze,E as Ct,P as Ke,r as et,v as Nt,u as St}from"./PlacesRail-fsCwAmTh.js";import{j as te,l as It,Y as Mt,u as Ne,aQ as dt,by as ut,dg as mt,cK as Tt,T as pt,dh as ft,di as Et,dj as At,dk as Rt,dl as Ot,ci as xt,bw as Bt,ah as Xe,b5 as tt,dm as Dt,dn as zt,dp as Lt,w as ht,W as $e,$ as Je,dq as Pt,dr as Ve,ds as $t,dt as _t,b as Ht,du as Kt,dv as Ut,dw as qt,dx as Ft,d0 as Yt,dy as Xt,dz as Jt,bO as Vt,dA as Gt,cL as Wt,dB as Qt,a0 as Zt,dC as en,dD as tn,dE as nn}from"./App-JBHRknbK.js";import{M as Oe}from"./monitor-DpQ5uncj.js";import{R as sn,a as an}from"./MenuMotion-C5SnaLCp.js";import"./index-C1x8eZ6l.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,Ye=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?Ye:0)+_e,M=x+Fe,h=l.map((v,y)=>({botId:v.id,x:we+(i&&y>=n.chiefs.length?Ye: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 R=I(l.length)-He;let U=Math.max(R,Te+Me),A=d.length?M+Ge:x;if(r.team){const v=l.map((K,G)=>({bot:K,index:G})).filter(({bot:K})=>r.team.botIds.includes(K.id)),y=(v.length?v:l.map((K,G)=>({bot:K,index:G}))).map(({index:K})=>g(K)),j=y.length?(Math.min(...y)+Math.max(...y))/2:Te+je/2,O=A+Fe*(d.length?1.5:2),L=Math.max(Te,j-je/2),X=O-Fe/2,_=L+je/2;w.push({id:r.team.id,x:O,y:L});for(const{bot:K,index:G}of v){const B={x:h[G].x+_e,y:g(G)};b.push({botId:K.id,computerId:r.team.id,points:[B,{x:X,y:B.y},{x:X,y:_},{x:O,y:_}]})}A=O+Ge,U=Math.max(U,L+je)}const H=[];if(i){const v=we+Ye/2,y=n.chiefs.length;H.push([{x:v,y:h[y-1].y+Me},{x:v,y:g(l.length-1)}]);for(let j=y;j<l.length;j++)H.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:H}}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((R,U)=>U%i===b).map(R=>R.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(R=>R.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,R,U,A,H)=>{if((g.current[b]?.at??-1/0)>=A)return;let v;try{v=URL.createObjectURL(Tn(R,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:H}},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,R=!1;const U=async()=>{if(!(b||R||document.visibilityState!=="visible")){R=!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 O of y.computers){const L=O.frame;L?.data&&w(O.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{R=!1}}};U();const A=window.setInterval(U,Cn),H=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),H()}},[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"},Dn=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 zn({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()),R=x.instances.find(A=>A.instanceId===n.modelSelection.instanceId),U=R?.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:()=>Xe(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:()=>Xe(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:R?e.jsx(Dt,{instance:R,size:13}):e.jsx(zt,{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:R={},onOpenComputer:U,taggedBotIds:A=[],sent:H,bottomInset:v=0}){const{state:y}=Ne(),j=a.useRef(null),O=a.useRef(null),L=a.useRef(!1),X=a.useRef(!1),_=a.useRef(null),[K,G]=a.useState({}),[B,q]=a.useState({}),[m,D]=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(B,t.key)?B[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,B]),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,K,pe),[n,K,pe]),ce=a.useRef({view:m,positions:K,tiles:be,selectedId:y.selectedId,settingsOpen:y.settingsOpen,bottomInset:v});ce.current={view:m,positions:K,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(B,t)?B[t]:[],k=(t,p,u,C)=>{const E={...B,[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&&D(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;D(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(),O.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)));D(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;D({...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||O.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:K,moved:!1},ae=C===void 0?void 0:be.find(V=>V.key===C);O.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 z=Q.find(Y=>Y.dataset.botId===V.id)?.closest("article")?.getBoundingClientRect();return z?p<z.top+z.height/2:!1});return{section:u,lane:C,remaining:E,index:ae<0?E.length:ae}},bt=t=>{const p=O.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"&&D({...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,z=V?.remaining[V.index]??V?.remaining.at(-1);ee(V&&z?{botId:z.id,after:V.index===V.remaining.length}:null)}},Ce=(t,p=!1)=>{const u=O.current;if(!(!u||t&&u.id!==t.pointerId)){if(O.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),D(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))}}},De=t=>{const p=j.current?.getBoundingClientRect();p&&D(at(m,Math.max(.3,Math.min(1.5,m.scale*t)),{x:p.width/2,y:p.height/2}))},ze=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=>ze.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=>{X.current=!1,t.target.closest("details")||t.currentTarget.querySelectorAll("details[open]").forEach(p=>p.removeAttribute("open"))},onKeyDownCapture:t=>{t.key==="Tab"&&(X.current=!0)},onPointerLeave:()=>{O.current&&!O.current.moved&&Ce(void 0,!0)},onLostPointerCapture:()=>{O.current&&Ce(void 0,!0)},onFocusCapture:t=>{if(!X.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)&&D(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(),D({...m,x:m.x+u.x,y:m.y+u.y})),(t.key==="+"||t.key==="=")&&(t.preventDefault(),De(1.2)),t.key==="-"&&(t.preventDefault(),De(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=z=>e.jsxs("div",{className:"relative",children:[F?.botId===z.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(zn,{bot:z,selected:y.selectedId===z.id&&y.settingsOpen,moving:N?.bot.id===z.id||ie===z.id,connected:w.includes(z.id),tagged:A.includes(z.id),sent:H?.botIds.includes(z.id)?H.key:void 0,onComputer:g,onArrange:fe?J:void 0})]},z.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:z=>{const Y={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[z.key];if(!Y)return;z.preventDefault(),z.stopPropagation();const ye=z.shiftKey?40:10;f({...K,[t.key]:{x:u.x+Y[0]*ye,y:u.y+Y[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:z=>{if(z.currentTarget.open){const Y=j.current?.getBoundingClientRect();ge(Y&&z.currentTarget.getBoundingClientRect().bottom>Y.bottom-210*m.scale?t.key:null),j.current?.querySelectorAll("details[open]").forEach(ye=>{ye!==z.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:z=>{const Y=z.currentTarget.closest("details");Y?.querySelector("summary")?.focus(),Y?.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((z,Y)=>e.jsx("path",{d:rt(z),fill:"none",strokeWidth:1.5,className:"stroke-ink-secondary/25"},`tree-${Y}`)),C.links.map(z=>{const Y=ze.get(z.botId)?.busy===!0;return e.jsx("path",{d:rt(z.points),fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:Y?2.25:1.5,strokeDasharray:Y?"7 5":void 0,className:Y?"animate-link-flow stroke-success/80":"stroke-ink-secondary/35"},`${z.botId}:${z.computerId}`)})]}),C.cards.map(z=>{const Y=ze.get(z.botId);return Y?e.jsx("div",{className:"absolute",style:{left:z.x,top:z.y},children:V(Y)},Y.id):null}),C.monitors.map(z=>{const Y=yt.get(z.id);if(!Y)return null;const ye=Y.botIds.flatMap(Ue=>ze.get(Ue)??[]);return e.jsx(Dn,{computer:Y,bots:ye,x:z.x,y:z.y,frameUrl:Object.hasOwn(R,Y.id)?R[Y.id].url:void 0,state:vt(Y),activity:Pn(ye.find(Ue=>Ue.busy),y.instances),onOpen:U?()=>U(Y):void 0},Y.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:()=>De(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:()=>De(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,R]=a.useState(null),U=a.useRef(!1),A=a.useRef(0),[H,v]=a.useState(!1),[y,j]=a.useState({kind:"term",name:"",detail:""}),O=`section=${encodeURIComponent(n)}`,L=a.useCallback(async()=>{const m=++A.current;try{const D=await te(`/api/team-memory?${O}`);if(A.current!==m)return;c(D.entries),g(D.loadedIds),w(null)}catch(D){if(A.current!==m)return;w(D instanceof Error?D.message:String(D))}},[O]);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 D=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",D),()=>{window.removeEventListener("keydown",D),m?.focus()}},[l]);const X=async(m,D)=>{if(U.current)return!1;U.current=!0;const N=++A.current;R(m??"new"),w(null);try{const $=await D();return A.current!==N?!1:(c($.entries),R(null),$.loadedIds?g($.loadedIds):L(),!0)}catch($){return A.current===N&&w($ instanceof Error?$.message:String($)),!1}finally{U.current=!1,A.current===N&&R(null)}},_=m=>X(m.id,()=>te(`/api/team-memory/${m.id}?${O}`,{method:"PATCH",body:JSON.stringify({accept:!0,expectedRevision:m.revision})})),K=m=>X(m.id,()=>te(`/api/team-memory/${m.id}?${O}&revision=${m.revision}`,{method:"DELETE"})),G=(m,D,N)=>{D.trim()===m.detail&&(N===void 0||N===m.name)||X(m.id,()=>te(`/api/team-memory/${m.id}?${O}`,{method:"PATCH",body:JSON.stringify({detail:D,...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:D},P}))},B=()=>{!y.name.trim()||!y.detail.trim()||X(null,()=>te(`/api/team-memory?${O}`,{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.stopPropagation(),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,D])=>e.jsxs("p",{className:"mb-3 text-[12px] text-ink-secondary",children:[e.jsx("strong",{children:D.name})," · ",s("teamMemory.unsaved",{text:D.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:()=>{K(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:D,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(D)}),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:()=>{X(T.id,()=>te(`/api/team-memory/${T.id}?${O}`,{method:"PATCH",body:JSON.stringify({pinned:!T.pinned,expectedRevision:T.revision})}))},children:e.jsx(Lt,{size:13})}),e.jsx("button",{onClick:()=>{K(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)}),H?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"&&B()},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:B,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,R]=a.useState(""),[U,A]=a.useState(""),[H,v]=a.useState(null),[y,j]=a.useState(!1),[O,L]=a.useState(""),X=a.useRef($e()),_=a.useRef(null),K=a.useRef(null),G=a.useRef(null),B=a.useRef(!1),q=a.useRef(!0),m=a.useRef(null),D=a.useRef(I);D.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(!(B.current||o.section===k)){if(o.section!==null&&k!==null){R(s("canvasComputers.unassignBeforeMove",{computer:o.name,team:o.section||s("settings.section.general")}));return}R(""),$({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(""),D.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(()=>{!B.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&&K.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(!B.current){B.current=!0,v(o),R(""),m.current?.abort();try{const le=await k();q.current&&J?.(le)}catch(le){q.current&&(R(le instanceof Error?le.message:String(le)),Z?.())}finally{B.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||H!==null,onClick:()=>{R(""),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??O.trim();!k||!x?.configured||(_.current=k,pe("create",()=>te("/api/team-computers",{method:"POST",body:JSON.stringify({name:k,requestId:X.current,acknowledgeCost:!0})}),()=>{L(""),j(!1),X.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:K,id:"canvas-computer-name",className:Hn,value:O,maxLength:60,placeholder:s("canvasComputers.namePlaceholder"),disabled:H!==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:H!==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||!O.trim()||H!==null,children:[H==="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:H!==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=>{B.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,H===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:H!==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:H!==null||le,onClick:()=>{pe(o.id,()=>ce(o.id,"provision",{acknowledgeCost:!0}))},children:s("canvasComputers.startRetry")}),k&&!le&&e.jsx("button",{className:xe,disabled:H!==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:H!==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:H!==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:R})=>h.slice(0,R.length).toLowerCase()===R.toLowerCase()&&!_t(h.slice(R.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 Yn(n,r=2){return n.length<=r+1?{names:[...n],more:0}:{names:n.slice(0,r),more:n.length-r}}function Xn({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),[R,U]=a.useState(null),[A,H]=a.useState(0),[v,y]=a.useState(null),j=a.useMemo(()=>n.filter(S=>!S.hidden),[n]),O=a.useMemo(()=>qn(M,j,r),[M,j,r]),L=a.useMemo(()=>ct(O,j,!1),[O,j]),X=L.botIds.join(",");a.useEffect(()=>{l(X?X.split(","):[])},[X,l]),a.useEffect(()=>()=>l([]),[l]);const _=Kt(M,w),K=a.useMemo(()=>{if(!_||_.start===R)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)},[_,R,j,r]),G=K.length>0,B=an(G);a.useEffect(()=>H(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&&O.botIds.length>0,D=async()=>{if(!m)return;const S=M.trim(),F=O;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=Yn($.map(S=>S.name)),P=v?.expanded?$:$.slice(0,T.names.length),se=M.trim()&&!O.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:B,choices:K,highlight:A,everyoneCount:j.length,onPick:q,onHighlight:H}),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(!Yt(S.nativeEvent)){if(G){if(S.key==="ArrowDown"||S.key==="ArrowUp"){S.preventDefault(),H(F=>(F+(S.key==="ArrowDown"?1:-1)+K.length)%K.length);return}if(S.key==="Enter"||S.key==="Tab"){S.preventDefault(),q(K[A]);return}if(S.key==="Escape"){S.preventDefault(),S.stopPropagation(),U(_?.start??null);return}}Xt(S.nativeEvent,I)&&(S.preventDefault(),D())}}}),e.jsx("button",{onClick:()=>{D()},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||O.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,R]=a.useState(24e3),[U,A]=a.useState(null),[H,v]=a.useState(!0),[y,j]=a.useState(!1),[O,L]=a.useState(null),X=x!==h,_=a.useMemo(()=>new TextEncoder().encode(x).byteLength,[x]);c.current=l,I.current=y,g.current=X;const K=a.useCallback(()=>{I.current||g.current&&!window.confirm(s("team.instructionsDiscard"))||c.current()},[]);a.useEffect(()=>{const B=document.activeElement instanceof HTMLElement?document.activeElement:null;d.current?.focus();const q=m=>{if(m.key==="Escape"&&!I.current){m.preventDefault(),K();return}if(m.key!=="Tab")return;const D=d.current;if(!D)return;const N=[...D.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [href], [tabindex]:not([tabindex="-1"])')];if(N.length===0){m.preventDefault(),D.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),B?.focus()}},[K]),a.useEffect(()=>{let B=!1;return v(!0),L(null),te(`/api/section-context?section=${encodeURIComponent(n)}`).then(q=>{B||(M(q.text),w(q.text),A(q.updatedAt),R(q.maxBytes),window.setTimeout(()=>i.current?.focus(),0))}).catch(q=>{B||L(q instanceof Error?q.message:String(q))}).finally(()=>{B||v(!1)}),()=>{B=!0}},[n]);const G=async()=>{if(!(_>b)){j(!0),L(null);try{const B=await te(`/api/section-context?section=${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({text:x})});w(B.text),M(B.text),A(B.updatedAt),R(B.maxBytes)}catch(B){L(B instanceof Error?B.message:String(B))}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:B=>B.stopPropagation(),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:K,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:[H?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:B=>M(B.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())})})]})]}),O&&e.jsx("div",{className:"mt-3 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:O})]}),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:K,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:H||y||!X||_>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),[R,U]=a.useState(null),[A,H]=a.useState(null),[v,y]=a.useState(null),[j,O]=a.useState(null),[L,X]=a.useState(!1),[_,K]=a.useState(0),[G,B]=a.useState([]),[q,m]=a.useState(null),D=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:()=>X(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:()=>{X(!0),K(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=>Xe(r,"access",{botId:f.id}),computers:ee&&ie&&!d?ue.computers:void 0,computerFrames:ue.frames,onOpenComputer:f=>f.kind==="team"?X(!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:()=>X(!0),onComputerDrop:(f,o)=>{d||(X(!0),m({id:f,section:o}))},onInstructions:(f,o)=>U({section:f,label:o}),onMemory:(f,o)=>H({section:f,label:o}),onEditTeam:(f,o)=>y({section:f,rename:o}),onDeleteTeam:O,isEmpty:f=>![...n.bots,...n.groups].some(o=>o.section?.trim()===f)}),P.length>0&&e.jsx(Xn,{bots:P,teams:Se,onTagged:fe,onSent:ve})]}),!d&&e.jsx(Un,{open:L,createRequest:_,drop:q,sections:se,onClose:()=>X(!1),onDropHandled:D,onChange:B})]}),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}`))})]}),R&&e.jsx(Vn,{section:R.section,label:R.label,onClose:()=>U(null)}),v&&e.jsx(tn,{...v,onClose:()=>y(null)}),A&&e.jsx(_n,{...A,onClose:()=>H(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:()=>O(null),onConfirm:()=>{const f=j;O(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};