limixbot 0.3.102 → 0.3.103

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 (159) hide show
  1. package/dist/assets/{ActivityPanel-C2Cl2jTl.js → ActivityPanel-DdSZ8OXc.js} +1 -1
  2. package/dist/assets/{App-D19QFJed.js → App-ftB4PetT.js} +123 -122
  3. package/dist/assets/{AppEventEditor-DDT3F9L_.js → AppEventEditor-B7KR7gbZ.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-CvzVPzcO.js → BotSettingsDialog-BntQ38tC.js} +4 -4
  5. package/dist/assets/{BrowserPanel-DEM-W63m.js → BrowserPanel-B8zEv2yz.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-hBmo6d_g.js → BrowserProfilesManager-eHlKAUFP.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-DaNbSVwD.js → CloudAddDialog-u5oxANAD.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-CnWxeVGZ.js → ComputerFilesPane-CyG5dv52.js} +1 -1
  9. package/dist/assets/{ComputerPanel-Cc8yiCLe.js → ComputerPanel-BUjqykLD.js} +2 -2
  10. package/dist/assets/{DataPanel-BvWkaAdQ.js → DataPanel-DWJbbJNX.js} +1 -1
  11. package/dist/assets/{DesktopViewer-PXMs_Z3h.js → DesktopViewer-CfXOdLV9.js} +1 -1
  12. package/dist/assets/{GrokMoveDialog-B6UGJUMK.js → GrokMoveDialog-Cj5HG8AL.js} +1 -1
  13. package/dist/assets/{InspectorPanel-wIVziMZN.js → InspectorPanel-CaOmVE1M.js} +1 -1
  14. package/dist/assets/{KeyboardShortcutsModal-mCYGqr7E.js → KeyboardShortcutsModal-kspIwkDg.js} +1 -1
  15. package/dist/assets/{LimixResizeHandles-o2O_Or0r.js → LimixResizeHandles-SzYhwKNE.js} +1 -1
  16. package/dist/assets/{LiveDesktop-mR-T2RF6.js → LiveDesktop-D3CJ56hW.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-DNCErB3Y.js → LocalVmWorkspace-DEAykEFC.js} +1 -1
  18. package/dist/assets/{MacLocalControl-bs1yDd1K.js → MacLocalControl-C1f-JAvN.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-f4zmKhJ7.js → MarkdownFilePreview-BkZMg8ux.js} +1 -1
  20. package/dist/assets/{MenuMotion-BclWiAVe.js → MenuMotion-y3_mgPH0.js} +1 -1
  21. package/dist/assets/{NewBotDialog-DWIR2UbB.js → NewBotDialog-DUlssZFn.js} +1 -1
  22. package/dist/assets/{PhoneAppDialog-CqasrSYT.js → PhoneAppDialog-jl-A35lD.js} +1 -1
  23. package/dist/assets/{PlacesRail-DyYA64do.js → PlacesRail-Be4MJsKP.js} +1 -1
  24. package/dist/assets/{PluginsPanel-ZfoIaFp9.js → PluginsPanel-9DDdusDH.js} +1 -1
  25. package/dist/assets/{ProIntroduction-Dfj-Bvcm.js → ProIntroduction-DRl6O52f.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-BXzq5ZPK.js → RemoteAgentSettingsPanel-DNUP5pZq.js} +1 -1
  27. package/dist/assets/{RoomPanel-xD6A1XTL.js → RoomPanel-DAvyN5bX.js} +1 -1
  28. package/dist/assets/{RoutinesPage-Ebk_GO7p.js → RoutinesPage-ByrijqT9.js} +1 -1
  29. package/dist/assets/{SettingsModal-MqvTSjjb.js → SettingsModal-DhldX0LY.js} +1 -1
  30. package/dist/assets/{ShareTeamDialog-BzoKwVa3.js → ShareTeamDialog-hRc_SYb6.js} +1 -1
  31. package/dist/assets/{SignedInSites-D7ldK6GO.js → SignedInSites-BxJ2YKXx.js} +1 -1
  32. package/dist/assets/TeamLibraryPanel-CC_SkTIo.js +3 -0
  33. package/dist/assets/{TeamMapPage-B5fJM5qJ.js → TeamMapPage-DAfSlcPu.js} +1 -1
  34. package/dist/assets/{TriggersPage-AhCCyPfR.js → TriggersPage-Bipd1gYY.js} +1 -1
  35. package/dist/assets/{VisibilitySection-CsJ0IbTV.js → VisibilitySection-DbJ_5rwD.js} +1 -1
  36. package/dist/assets/{WebhookTrigger-4w1WLP-_.js → WebhookTrigger-aLhrK-YU.js} +1 -1
  37. package/dist/assets/{WorksOnGrid--l9pu37B.js → WorksOnGrid-u1rPeHHO.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-CKc5IYc4.js → abnfDiagram-YUKMZFIV-ChcWlNpY.js} +1 -1
  39. package/dist/assets/{activity-CwaOixB9.js → activity-SfzB9gft.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-BzQ3blap.js → architectureDiagram-47P4ROYG-DVoUFfCS.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-Cg5etqDi.js → blockDiagram-E7TT5TSB-DqPV7RMZ.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-ChJTr_PL.js → c4Diagram-CRA5TL53-BGmVwlFz.js} +1 -1
  43. package/dist/assets/{calendar-days-DYBafFRo.js → calendar-days-D3-4I6P4.js} +1 -1
  44. package/dist/assets/channel-BeYKH3lV.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-DwRap1YG.js → chunk-2Q5K7J3B-B1ypkJ8E.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-BO6BTUz7.js → chunk-5VM5RSS4-CcV9LLDc.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-B2VKEfok.js → chunk-7TKQ45FW-BIxUGZLZ.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-C7vsX4VD.js → chunk-AW2ZBBNX-BeDhUW76.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-CIjSXjvq.js → chunk-FVRAUYC3-ChrQXxWu.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-CCWLt9W1.js → chunk-HTAEGDNF-CoqYrJ09.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-CYUijN37.js → chunk-JWPE2WC7-x_G8N4UY.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-D0cFTyVc.js → chunk-KQW6MTUR-BNgvE0Zx.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-CE20wx8I.js → chunk-XXDRQBXY-B6XLUBJo.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-QBcA1FUG.js → classDiagram-v2-K4WV4PDN-DBiYaY2I.js} +1 -1
  55. package/dist/assets/{coins-CQDndxZe.js → coins-DkeI1D3d.js} +1 -1
  56. package/dist/assets/{core-CCOmUTd-.js → core-Bc6arvu2.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-CPygoF45.js → cose-bilkent-JH36ORCC-DcXcgm4G.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-DjRSXXUK.js → cynefin-EF2NZ3EQ-D4661Ow3.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-C4D5WdA1.js → cynefinDiagram-3GCD6N5R-D9JCrRjr.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-CwHowYoX.js → dagre-W4DXFKR2-D7uDOym_.js} +1 -1
  61. package/dist/assets/de-CrO5MppH.js +8 -0
  62. package/dist/assets/{diagram-2UJZ2QOL-IOgxIe2m.js → diagram-2UJZ2QOL-C1DYfm72.js} +1 -1
  63. package/dist/assets/{diagram-OVF4WLC6-6M2t3aC-.js → diagram-OVF4WLC6-C-nti_Wz.js} +1 -1
  64. package/dist/assets/{diagram-PFPMY2P6-C3MDtWX5.js → diagram-PFPMY2P6-B9JKIvnW.js} +1 -1
  65. package/dist/assets/{diagram-UMYRVEAY-CpXR83ix.js → diagram-UMYRVEAY-B3XBHAVr.js} +1 -1
  66. package/dist/assets/{diagram-YEKJPTXX-DF58kzII.js → diagram-YEKJPTXX-R_DeJtDT.js} +1 -1
  67. package/dist/assets/{diagram-ZIFT7M5P-BTWYDC1S.js → diagram-ZIFT7M5P-ClA3xuGy.js} +1 -1
  68. package/dist/assets/{ebnfDiagram-VR2GEFS7-DWMxXTtf.js → ebnfDiagram-VR2GEFS7-D3DyL10J.js} +1 -1
  69. package/dist/assets/{elk-IJKZMXRS-ZDF01LK0.js → elk-IJKZMXRS-NoFnL8PW.js} +1 -1
  70. package/dist/assets/{erDiagram-O2IAPWRE-DKeRGnUv.js → erDiagram-O2IAPWRE-BPyOLz1a.js} +1 -1
  71. package/dist/assets/es-bnXYOspp.js +6 -0
  72. package/dist/assets/{file-up-Cr20e4wl.js → file-up-BV8p1OPd.js} +1 -1
  73. package/dist/assets/{flowDiagram-OXPTDLAJ-BTJVRu9A.js → flowDiagram-OXPTDLAJ-CdHiMknj.js} +1 -1
  74. package/dist/assets/fr-Drpg1nRS.js +8 -0
  75. package/dist/assets/{ganttDiagram-R7TSEDQI-BrBIiPkW.js → ganttDiagram-R7TSEDQI-B3qyDG4d.js} +1 -1
  76. package/dist/assets/{gitGraphDiagram-XJZIOB7I-xBYIjsc8.js → gitGraphDiagram-XJZIOB7I-CN5_yp8t.js} +1 -1
  77. package/dist/assets/hi-hKAbiCLa.js +1 -0
  78. package/dist/assets/{import-name-B7Do-JDx.js → import-name-baZlXmGk.js} +1 -1
  79. package/dist/assets/{index-CJtPXUE4.js → index-BZfn5_k5.js} +3 -3
  80. package/dist/assets/{index-CXTkkn4L.js → index-CyrxXrGh.js} +1 -1
  81. package/dist/assets/{infoDiagram-5W2HQ5XZ-B-FCUMEX.js → infoDiagram-5W2HQ5XZ-C1awaPUj.js} +1 -1
  82. package/dist/assets/{ishikawaDiagram-K3B6WC7H-DxhcI9nM.js → ishikawaDiagram-K3B6WC7H-DcG1GTWM.js} +1 -1
  83. package/dist/assets/it-D6cE_lzY.js +13 -0
  84. package/dist/assets/ja-5lJcngPy.js +13 -0
  85. package/dist/assets/{journeyDiagram-COXZFDF6-DSwqQn-4.js → journeyDiagram-COXZFDF6-B-T-4Ss2.js} +1 -1
  86. package/dist/assets/{kanban-definition-P3RFRI5V-Bidc1dLu.js → kanban-definition-P3RFRI5V-DhgMKb1S.js} +1 -1
  87. package/dist/assets/ko-IP18hNxI.js +13 -0
  88. package/dist/assets/{mcp-servers-CAJBEPpM.js → mcp-servers-BFkC95ER.js} +1 -1
  89. package/dist/assets/{mermaid.core-1-GuV68k.js → mermaid.core-C0Ni5l0v.js} +4 -4
  90. package/dist/assets/{mindmap-definition-LZFPQGKD-BtlXbTTm.js → mindmap-definition-LZFPQGKD-CljImffi.js} +1 -1
  91. package/dist/assets/{minimize-CoPseS7J.js → minimize-CkQHJV84.js} +1 -1
  92. package/dist/assets/{monitor-B9eyPPw6.js → monitor-D_UAFHyW.js} +1 -1
  93. package/dist/assets/new-bot-peJFipB7.js +2 -0
  94. package/dist/assets/{org-library-DKT7NXTB.js → org-library-Br6VR8QD.js} +1 -1
  95. package/dist/assets/{package-format-BLTn6eID.js → package-format-CPaz8LNO.js} +1 -1
  96. package/dist/assets/{pegDiagram-BGZESJAR-uFZWnUng.js → pegDiagram-BGZESJAR-CgnU1Ac1.js} +1 -1
  97. package/dist/assets/{pieDiagram-CAPJLFHJ-B2Itft-D.js → pieDiagram-CAPJLFHJ-BJmtZCJF.js} +1 -1
  98. package/dist/assets/pl-s3VOXZNa.js +13 -0
  99. package/dist/assets/pt-br-WeqOetEr.js +13 -0
  100. package/dist/assets/{quadrantDiagram-GDMTTRAM-Btivs4tR.js → quadrantDiagram-GDMTTRAM-Dqg3HXnH.js} +1 -1
  101. package/dist/assets/{rail-ar9TQRSE.js → rail-Bi4B37ED.js} +1 -1
  102. package/dist/assets/{railroadDiagram-SM67HX2B-92CU8YQH.js → railroadDiagram-SM67HX2B-Dh4hx5Fo.js} +1 -1
  103. package/dist/assets/{remote-desktop-panel-B-H6RmM2.js → remote-desktop-panel-DRsUOxPA.js} +1 -1
  104. package/dist/assets/{requirementDiagram-X7JNWC4A-5izSc7xN.js → requirementDiagram-X7JNWC4A-DoDrImJb.js} +1 -1
  105. package/dist/assets/ru-xPDlIHlb.js +13 -0
  106. package/dist/assets/{sankeyDiagram-UM26HJRW-DPnrZSB2.js → sankeyDiagram-UM26HJRW-4kxKCZbK.js} +1 -1
  107. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-Bda0M6Hv.js → sequenceDiagram-ZO4K6R2Y-Dfn3sj5H.js} +1 -1
  108. package/dist/assets/{sizeCapture-INFHLROL-DKRN8tPD.js → sizeCapture-INFHLROL-e4etpscL.js} +1 -1
  109. package/dist/assets/{stateDiagram-v2-TBUQTH76-D6MqFrrx.js → stateDiagram-v2-TBUQTH76-CiH2EjAT.js} +1 -1
  110. package/dist/assets/{styles-DOwrpvZY.js → styles-BC55IU1j.js} +2 -2
  111. package/dist/assets/{swimlanes-N4OXWK64-D_pFpyCW.js → swimlanes-N4OXWK64-elz4HcrR.js} +1 -1
  112. package/dist/assets/swimlanesDiagram-K3J5GTZL-C2oR937G.js +8 -0
  113. package/dist/assets/{team-share-CS8lXIGF.js → team-share-CVGnlnZg.js} +1 -1
  114. package/dist/assets/{timeline-definition-YOQAKGHF-CsXwhMm7.js → timeline-definition-YOQAKGHF-CBvNtqBT.js} +1 -1
  115. package/dist/assets/tr-D52N3H-s.js +6 -0
  116. package/dist/assets/uk-BgibvZRE.js +1 -0
  117. package/dist/assets/{usecaseDiagram-VIAY4XPW-XU2vytSZ.js → usecaseDiagram-VIAY4XPW-Cqnlu-5K.js} +1 -1
  118. package/dist/assets/{vennDiagram-BLWOH2XV-beqZKO-E.js → vennDiagram-BLWOH2XV-B1DVqqPC.js} +1 -1
  119. package/dist/assets/vi-Dtr5uxBT.js +15 -0
  120. package/dist/assets/{wardleyDiagram-YMQ3BMBF-Ci5sPNvX.js → wardleyDiagram-YMQ3BMBF-CQPngjvL.js} +1 -1
  121. package/dist/assets/{xychartDiagram-TAQBALBS-BCJ2N2BY.js → xychartDiagram-TAQBALBS-Djna4qxy.js} +1 -1
  122. package/dist/assets/zh-Cr6ncAKb.js +13 -0
  123. package/dist/assets/zh-tw-BhYWJRt3.js +13 -0
  124. package/dist/index.html +2 -2
  125. package/dist/rail.html +4 -4
  126. package/dist-server/index.js +78 -70
  127. package/dist-server/package.json +1 -1
  128. package/dist-server/server/bot-channels/engine.js +51 -22
  129. package/dist-server/server/limix-skill-store.js +2 -1
  130. package/dist-server/server/routes/bots-create.js +11 -0
  131. package/dist-server/shared/ready-bots.js +15 -0
  132. package/package.json +1 -1
  133. package/skills/video-workflow/SKILL.md +26 -0
  134. package/skills/video-workflow/assets/hybrid-policy.json +10 -0
  135. package/skills/video-workflow/assets/starter/build.svrun +5 -0
  136. package/skills/video-workflow/assets/starter/main.svml +24 -0
  137. package/skills/video-workflow/assets/starter/package.json +1 -0
  138. package/skills/video-workflow/assets/starter/style.svs +4 -0
  139. package/skills/video-workflow/manifest.json +19 -0
  140. package/skills/video-workflow/references/vi.md +13 -0
  141. package/dist/assets/TeamLibraryPanel-B4r-AOrt.js +0 -3
  142. package/dist/assets/channel-DI8VRWh8.js +0 -1
  143. package/dist/assets/de-XojPh3_p.js +0 -8
  144. package/dist/assets/es-C0MD2HR1.js +0 -6
  145. package/dist/assets/fr-hktiWwtw.js +0 -8
  146. package/dist/assets/hi-D_Yu59YK.js +0 -1
  147. package/dist/assets/it-zbTil6cI.js +0 -13
  148. package/dist/assets/ja-CtqaLHju.js +0 -13
  149. package/dist/assets/ko-DrT-vz1y.js +0 -13
  150. package/dist/assets/new-bot-CQ9YWyiC.js +0 -2
  151. package/dist/assets/pl-BaR1MZm6.js +0 -13
  152. package/dist/assets/pt-br-mFy7aZD6.js +0 -13
  153. package/dist/assets/ru-BJ0ARJtn.js +0 -13
  154. package/dist/assets/swimlanesDiagram-K3J5GTZL-D6oFbwqj.js +0 -8
  155. package/dist/assets/tr-DnXBUn9-.js +0 -6
  156. package/dist/assets/uk-RZHdJ2pL.js +0 -1
  157. package/dist/assets/vi-Bx9YsUag.js +0 -15
  158. package/dist/assets/zh-DMiI3Rx1.js +0 -13
  159. package/dist/assets/zh-tw-DoGBLWPr.js +0 -13
@@ -32,7 +32,7 @@ const mediaSchema = z.discriminatedUnion("kind", [
32
32
  const inboxSchema = z.object({
33
33
  id: z.string(), chatId: z.string(), from: z.object({ id: z.string(), name: z.string() }),
34
34
  text: z.string(), direct: z.boolean(), media: z.boolean().optional(),
35
- downloading: z.boolean().optional(), attachment: mediaSchema.optional(), owner: z.boolean(),
35
+ downloading: z.boolean().optional(), attachment: mediaSchema.optional(), owner: z.boolean(), grant: z.string().optional(),
36
36
  started: z.boolean().optional(),
37
37
  result: z.object({ reply: z.string(), attachments: z.array(mediaSchema).optional() }).optional(),
38
38
  sent: z.number().int().min(0).optional(),
@@ -45,7 +45,8 @@ const botSchema = z.object({
45
45
  access: z.enum(["owner", "everyone"]).default("owner"),
46
46
  groupMentions: z.boolean().optional(),
47
47
  owner: z.object({ id: z.union([z.string(), z.number()]).transform(String), name: z.string() }).optional(),
48
- link: z.object({ hash: z.string(), expiresAt: z.number() }).optional(),
48
+ admins: z.array(z.object({ id: z.string(), name: z.string(), grant: z.string() })).default([]),
49
+ link: z.object({ role: z.enum(["owner", "admin"]).optional(), hash: z.string(), expiresAt: z.number() }).optional(),
49
50
  offset: z.number().default(0),
50
51
  chats: z.record(z.string(), z.string()).default({}),
51
52
  error: z.string().optional(),
@@ -53,6 +54,13 @@ const botSchema = z.object({
53
54
  recent: z.record(z.string(), z.number()).default({}),
54
55
  });
55
56
  const fileSchema = z.object({ v: z.literal(1), bots: z.record(z.string(), botSchema) });
57
+ function privateGrant(adapter, entry, message) {
58
+ if (!entry?.enabled || !message.direct || adapter.guestsOnly)
59
+ return undefined;
60
+ if (entry.owner?.id === message.from.id)
61
+ return "owner";
62
+ return entry.admins.find(admin => admin.id === message.from.id)?.grant;
63
+ }
56
64
  const text = (label) => ({
57
65
  start: `Chào bạn! Đây là bot Limix. Nhắn tin để trò chuyện. Chủ bot: gửi /link MÃ để liên kết.`,
58
66
  linked: "Đã liên kết. Từ giờ bạn nhắn ở đây như nhắn trong app Limix.",
@@ -228,8 +236,8 @@ export function createBotChannels(deps) {
228
236
  log(`${adapter.kind}: send failed (${failure(error)})`);
229
237
  }
230
238
  }
231
- async function askWhenReady(botId, input, signal, onQueue) {
232
- while (!signal.aborted) {
239
+ async function askWhenReady(botId, input, signal, onQueue, authorized) {
240
+ while (!signal.aborted && authorized()) {
233
241
  try {
234
242
  return await deps.ask(botId, input);
235
243
  }
@@ -255,9 +263,10 @@ export function createBotChannels(deps) {
255
263
  }
256
264
  async function deliverResult(adapter, botId, id, message, signal) {
257
265
  const lane = `${adapter.kind}:${botId}`;
266
+ const authorized = () => !message.owner || privateGrant(adapter, read(adapter.kind).bots[botId], message) === (message.grant ?? "owner");
258
267
  const result = message.result;
259
268
  let sent = message.sent ?? 0;
260
- while (!signal.aborted) {
269
+ while (!signal.aborted && authorized()) {
261
270
  const session = sessions.get(lane);
262
271
  if (!session) {
263
272
  await sleep(BUSY_RETRY_MS, signal);
@@ -270,13 +279,13 @@ export function createBotChannels(deps) {
270
279
  try {
271
280
  const file = media[sent];
272
281
  await paced(adapter, botId, () => {
273
- if (signal.aborted || sessions.get(lane) !== session)
282
+ if (signal.aborted || !authorized() || sessions.get(lane) !== session)
274
283
  throw new ChannelError("drop", "Connection changed");
275
284
  return file ? session.sendMedia(message.chatId, file) : session.send(message.chatId, parts[sent - media.length]);
276
285
  });
277
286
  }
278
287
  catch (error) {
279
- if (signal.aborted)
288
+ if (signal.aborted || !authorized())
280
289
  return;
281
290
  if (sessions.get(lane) !== session || error instanceof ChannelError && error.reason === "retry") {
282
291
  await sleep(BACKOFF_MS[0], signal);
@@ -311,17 +320,26 @@ export function createBotChannels(deps) {
311
320
  const ok = entry.link && entry.link.expiresAt > now() && code && timingSafeEqual(Buffer.from(hashCode(code)), Buffer.from(entry.link.hash));
312
321
  if (!ok)
313
322
  return void await send(say.badCode);
314
- patch(kind, botId, (current) => { const { link: _used, ...rest } = current; return { ...rest, owner: { id: message.from.id, name: message.from.name } }; });
323
+ patch(kind, botId, (current) => {
324
+ const { link, ...rest } = current;
325
+ const person = { id: message.from.id, name: message.from.name };
326
+ if (current.owner?.id === person.id || current.admins.some(admin => admin.id === person.id))
327
+ return rest;
328
+ if (!current.owner && link?.role !== "admin")
329
+ return { ...rest, owner: person };
330
+ return { ...rest, admins: [...current.admins, { ...person, grant: randomBytes(16).toString("hex") }] };
331
+ });
315
332
  return void await send(say.linked);
316
333
  }
317
- const isOwner = message.direct && !adapter.guestsOnly && entry.owner?.id === message.from.id;
318
- if (saved?.row.owner && !isOwner)
334
+ const grant = privateGrant(adapter, entry, message);
335
+ const owner = !!grant && (saved?.row.owner ?? true);
336
+ const authorized = () => !saved?.row.owner || privateGrant(adapter, read(kind).bots[botId], message) === (saved.row.grant ?? "owner");
337
+ if (!authorized())
319
338
  return;
320
- const owner = isOwner && (saved?.row.owner ?? true);
321
339
  const allowsGuest = acceptGuest(kind, entry, message);
322
340
  if (!owner && !allowsGuest)
323
341
  return message.direct && !adapter.quietToStrangers ? void await send(say.ownerOnly) : undefined;
324
- const conversation = message.direct ? message.chatId : `${message.chatId}:${message.from.id}`;
342
+ const conversation = owner && grant !== "owner" ? JSON.stringify(["admin", grant, message.chatId]) : message.direct ? message.chatId : `${message.chatId}:${message.from.id}`;
325
343
  if (command?.[1] === "new") {
326
344
  patch(kind, botId, (current) => { const chats = { ...current.chats }; delete chats[conversation]; return { ...current, chats }; });
327
345
  return void await send(say.fresh);
@@ -359,11 +377,11 @@ export function createBotChannels(deps) {
359
377
  if (!signal.aborted)
360
378
  patch(kind, botId, (current) => ({ ...current, chats: { ...current.chats, [conversation]: threadId } }));
361
379
  },
362
- approval() { if (!signal.aborted)
380
+ approval() { if (!signal.aborted && authorized())
363
381
  void send(say.approval); },
364
382
  },
365
- }, signal, saved.queued);
366
- if (!answer || signal.aborted)
383
+ }, signal, saved.queued, authorized);
384
+ if (!answer || signal.aborted || !authorized())
367
385
  return;
368
386
  patch(kind, botId, (current) => ({ ...current, chats: { ...current.chats, [conversation]: answer.threadId } }));
369
387
  const attachments = answer.attachments;
@@ -399,9 +417,10 @@ export function createBotChannels(deps) {
399
417
  if (link && adapter.guestsOnly)
400
418
  return;
401
419
  const command = link || !message.media && /^\/start(?:@\w+)?$/.test(message.text.trim());
402
- const owner = message.direct && !adapter.guestsOnly && entry.owner?.id === message.from.id;
420
+ const grant = privateGrant(adapter, entry, message);
421
+ const owner = !!grant;
403
422
  const eligible = (owner || acceptGuest(kind, entry, message)) && !command && (message.text.trim() || message.loadMedia);
404
- const row = restored ?? (eligible ? inboxSchema.parse({ ...message, owner, downloading: Boolean(message.loadMedia) }) : undefined);
423
+ const row = restored ?? (eligible ? inboxSchema.parse({ ...message, owner, grant, downloading: Boolean(message.loadMedia) }) : undefined);
405
424
  if (!row && !firstSight(`${chat}:${id}`))
406
425
  return;
407
426
  if (row && !restored)
@@ -520,6 +539,7 @@ export function createBotChannels(deps) {
520
539
  connected: true, username: entry.username, name: entry.name, enabled: entry.enabled, access: entry.access,
521
540
  ...(kind === "zalo" ? { groupMentions: entry.groupMentions ?? entry.access === "everyone" } : {}),
522
541
  ...(entry.owner ? { owner: entry.owner.name } : {}),
542
+ ...(entry.admins.length ? { admins: entry.admins.map(({ id, name }) => ({ id, name })) } : {}),
523
543
  ...(entry.link && entry.link.expiresAt > now() ? { linkExpiresAt: entry.link.expiresAt } : {}),
524
544
  ...(entry.error ? { error: entry.error } : {}),
525
545
  ...(login ? { login } : {}),
@@ -535,7 +555,7 @@ export function createBotChannels(deps) {
535
555
  data.bots[botId] = botSchema.parse({
536
556
  sealed: seal(secret), username: account.username, name: account.name, enabled: true, access: kept?.access ?? (adapter.guestsOnly ? "everyone" : "owner"),
537
557
  groupMentions: kept?.groupMentions,
538
- ...(sameAccount && kept.owner ? { owner: kept.owner } : {}), offset: sameAccount ? kept.offset : 0, chats: sameAccount ? kept.chats : {},
558
+ ...(sameAccount && kept.owner ? { owner: kept.owner } : {}), admins: sameAccount ? kept.admins : [], offset: sameAccount ? kept.offset : 0, chats: sameAccount ? kept.chats : {},
539
559
  inbox: sameAccount ? kept.inbox : {}, recent: sameAccount ? kept.recent : {},
540
560
  });
541
561
  write(kind, data);
@@ -559,7 +579,7 @@ export function createBotChannels(deps) {
559
579
  .catch((error) => { if (live() && !abort.signal.aborted)
560
580
  current.state = { error: failure(error) }; });
561
581
  }
562
- const PATH = /^\/api\/bots\/([\w-]{1,128})\/(telegram|discord|zalo|facebook|messenger)(?:\/(link|unlink|login))?$/;
582
+ const PATH = /^\/api\/bots\/([\w-]{1,128})\/(telegram|discord|zalo|facebook|messenger)(?:\/(link|unlink|login|remove-admin))?$/;
563
583
  const changeSchema = z.object({ token: z.string().max(400).optional(), enabled: z.boolean().optional(), access: z.enum(["owner", "everyone"]).optional(), groupMentions: z.boolean().optional() }).strict();
564
584
  const routes = async ({ req, res, path, method, auth, json, readBody }) => {
565
585
  const match = PATH.exec(path);
@@ -593,14 +613,23 @@ export function createBotChannels(deps) {
593
613
  return json(res, 202, view(kind, botId));
594
614
  }
595
615
  if (action === "link") {
616
+ if (adapters.get(kind).guestsOnly)
617
+ return json(res, 400, { error: "Guest-only channel" });
596
618
  if (!read(kind).bots[botId])
597
619
  return json(res, 409, { error: `Kết nối ${adapters.get(kind).label} trước.` });
598
- const code = randomBytes(4).toString("hex").toUpperCase().slice(0, 6);
599
- patch(kind, botId, (current) => ({ ...current, link: { hash: hashCode(code), expiresAt: now() + LINK_MS } }));
620
+ const code = randomBytes(8).toString("hex").toUpperCase();
621
+ patch(kind, botId, (current) => ({ ...current, link: { role: current.owner ? "admin" : "owner", hash: hashCode(code), expiresAt: now() + LINK_MS } }));
600
622
  return json(res, 200, { code, ...view(kind, botId) });
601
623
  }
624
+ if (action === "remove-admin") {
625
+ const input = z.object({ id: z.string().min(1) }).strict().safeParse(await readBody(req));
626
+ if (!input.success)
627
+ return json(res, 400, { error: "Invalid administrator ID" });
628
+ patch(kind, botId, current => ({ ...current, admins: current.admins.filter(admin => admin.id !== input.data.id) }));
629
+ return json(res, 200, view(kind, botId));
630
+ }
602
631
  if (action === "unlink") {
603
- patch(kind, botId, (current) => { const { owner: _gone, ...rest } = current; return rest; });
632
+ patch(kind, botId, (current) => { const { owner: _gone, link: _cancelled, ...rest } = current; return rest; });
604
633
  return json(res, 200, view(kind, botId));
605
634
  }
606
635
  const parsed = changeSchema.safeParse(await readBody(req));
@@ -24,6 +24,7 @@ export const LIMIX_CORE_SKILLS = new Set([
24
24
  ]);
25
25
  /** What a shipped skill does, in the app's language (the manifest has one language; the skill itself is unchanged). */
26
26
  const BUNDLED_TEXT = {
27
+ "video-workflow": ["Lên kịch bản phân cảnh, tạo dự án video Hypit và kiểm tra phim xuất ra.", "Storyboard short videos, author Hypit projects and verify rendered files."],
27
28
  "limix-bot-factory": ["Tạo bản nháp bot và kỹ năng, kiểm tra quyền và xuất gói mẫu.", "Draft bots and skills, check permissions and export template packages."],
28
29
  "agent-reach": ["Tìm và đọc (chỉ đọc) X/Twitter, Reddit, YouTube (phụ đề), GitHub, Bilibili, XiaoHongShu, V2EX, LinkedIn… bằng lệnh agent-reach.", "Read-only search and reading on X/Twitter, Reddit, YouTube (subtitles), GitHub, Bilibili, XiaoHongShu, V2EX, LinkedIn and more through the agent-reach command."],
29
30
  "create-verification-skill": ["Viết một kĩ năng kiểm chứng cho một ứng dụng hoặc dự án cụ thể.", "Write one verification skill for a specific app or project."],
@@ -86,7 +87,7 @@ export function limixSelectBundled(text, capabilities, skills) {
86
87
  const folded = foldVietnamese(text);
87
88
  const unaccented = usable.filter(({ manifest }) => manifest.defaultEnabled && manifest.triggerTerms.some((term) => folded.includes(foldVietnamese(term))));
88
89
  const called = usable.filter(({ manifest }) => slashCalled(text, manifest.id));
89
- return mergeSkills(mergeSkills(selectBundledSkills(text, available, skills), unaccented), [...called, ...usable.filter(skill => industrySkills.has(skill.manifest.id))]);
90
+ return mergeSkills(mergeSkills(selectBundledSkills(text, available, skills), unaccented), [...called, ...usable.filter(skill => skill.manifest.id === "video-workflow" || industrySkills.has(skill.manifest.id))]);
90
91
  }
91
92
  /** The bot's shipped skills as rows of its Skills page. */
92
93
  export function limixBundledListings(botId, helperFactory = false) {
@@ -1,4 +1,6 @@
1
1
  import { industryBotSettings, industryTemplate } from "../../shared/industry-templates.js";
2
+ import { VIDEO_WORKFLOW } from "../../shared/ready-bots.js";
3
+ import { limixBundledSwitch } from "../limix-skill-store.js";
2
4
  import { enableIndustryCare } from "../industry-care.js";
3
5
  import { freshLook } from "../bot-look.js";
4
6
  import { validateBotCwd } from "../bot-cwd.js";
@@ -58,6 +60,11 @@ export function createBotCreateRoutes(deps) {
58
60
  const industry = typeof body.industryTemplate === "string" ? industryTemplate(body.industryTemplate, typeof body.templateLocale === "string" ? body.templateLocale : "en") : undefined;
59
61
  if (body.industryTemplate !== undefined && !industry)
60
62
  return json(res, 400, { error: "Unknown built-in industry template" });
63
+ const video = body.videoTemplate === true;
64
+ if (video && (industry || body.preset !== undefined))
65
+ return json(res, 400, { error: "Choose one bot template" });
66
+ if (video && auth.kind === "session" && !auth.scopes.includes("admin"))
67
+ return json(res, 403, { error: "Installing a video template requires the admin scope" });
61
68
  if (industry && body.preset !== undefined)
62
69
  return json(res, 400, { error: "Choose one bot template" });
63
70
  if (industry && auth.kind === "session" && !auth.scopes.includes("admin")) {
@@ -70,6 +77,8 @@ export function createBotCreateRoutes(deps) {
70
77
  },
71
78
  } : body);
72
79
  const settings = template.profile;
80
+ if (video)
81
+ settings.soul = VIDEO_WORKFLOW.soul;
73
82
  if (auth.kind === "session" && !auth.scopes.includes("admin")) {
74
83
  const field = clientBotPatchViolation(settings);
75
84
  if (field || body.preset !== undefined || template.skills.length || template.routines.length || Object.keys(template.memory).length) {
@@ -228,6 +237,8 @@ export function createBotCreateRoutes(deps) {
228
237
  if (ownersRoutines)
229
238
  cloudRoutineAuthors?.wrote(created.id, ownersRoutines);
230
239
  }
240
+ if (video && limixBundledSwitch(bot.id, VIDEO_WORKFLOW.id, true)?.status !== 200)
241
+ throw new Error("Could not install the video workflow skill");
231
242
  if (industry)
232
243
  enableIndustryCare(bot.id, industry.id);
233
244
  }
@@ -2,7 +2,19 @@ import { industryBotSettings, industryTemplate } from "./industry-templates.js";
2
2
  export const READY_BOT_CATEGORIES = ["everyday", "work", "writing", "design", "sales", "personal"];
3
3
  const WEEKDAYS = [1, 2, 3, 4, 5];
4
4
  const paused = (name, prompt, time, weekdays) => ({ name, prompt, schedule: { type: "daily", time, weekdays }, enabled: false, overlap: "skip" });
5
+ export const VIDEO_WORKFLOW = {
6
+ id: "video-workflow", category: "design", name: "Kino", title: "Short-form video producer",
7
+ description: "Turn a brief or reference into an editable Hypit project with a shot list, captions and video variants.",
8
+ soul: [
9
+ "Use the video-workflow skill to produce short videos from a brief or an authorized reference. Speak the user's language.",
10
+ "Deliver an original shot list, script and caption timings. Use editable Hypit project files and keep approved source media intact.",
11
+ "Check and plan the composition before building. Ask before paid generation, uploads or publication. Verify exported media before calling a render complete.",
12
+ ].join("\n"),
13
+ look: { color: "purple", mascotBody: "star" }, apps: [], skills: ["video-workflow"],
14
+ tryAsking: ["Storyboard a 30-second vertical video for this product.", "Create two different openings for this clip."],
15
+ };
5
16
  export const READY_BOTS = [
17
+ VIDEO_WORKFLOW,
6
18
  {
7
19
  id: "assistant",
8
20
  category: "everyday",
@@ -306,6 +318,9 @@ export function readyBotTemplate(defaults, bot, locale = "en") {
306
318
  const template = industry ? {
307
319
  profile: { ...industryBotSettings(), ...(defaults.profile.modelSelection ? { modelSelection: structuredClone(defaults.profile.modelSelection) } : {}) },
308
320
  skills: [], routines: [], memory: {},
321
+ } : bot.id === VIDEO_WORKFLOW.id ? {
322
+ profile: { approvalMode: "ask", ...(defaults.profile.modelSelection ? { modelSelection: structuredClone(defaults.profile.modelSelection) } : {}) },
323
+ skills: [], routines: [], memory: {},
309
324
  } : structuredClone(defaults);
310
325
  bot = industry ?? bot;
311
326
  template.profile = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limixbot",
3
- "version": "0.3.102",
3
+ "version": "0.3.103",
4
4
  "description": "Run the Limix Bot server anywhere and pair your devices to it (Leox ৹ Limix AI)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: video-workflow
3
+ description: Analyze a reference video, author an editable Hypit workflow and produce verified short-form variants.
4
+ ---
5
+
6
+ # Short-form video production
7
+
8
+ ## English Core
9
+
10
+ Start from a brief or a reference the user can use. Record the intended audience, language, canvas, duration, available footage and requested number of variants. Keep originals and approved renders intact.
11
+
12
+ ## Workflow
13
+
14
+ 1. Inspect the reference locally. Record observed cuts, spoken beats, captions, cutaways, transitions and sound in a shot table. Mark uncertain timing or speaker attribution.
15
+ 2. Write an original script. Identify the elements to keep and the single difference to test per variant. Keep captions and narration in the requested audience language. Anchor edits to spoken words when alignment is available.
16
+ 3. To start from still artwork, copy the files in assets/starter to the project directory, place the supplied image at hero.png and update the image dimensions. Author the composition in main.svml, appearance in style.svs and the delivery target in build.svrun. Reuse accepted media across variants.
17
+ 4. If the operator has installed Hypit, inspect its version, run `hypit check main.svml` and `hypit plan build.svrun` in the project. Summarize the targets, missing inputs, remote operations and expected charges if known. A working source or plan is a valid deliverable when rendering is unavailable.
18
+ 5. With a prepared runtime and an approved plan, run `hypit build build.svrun --follow`; read the actual build ID and export with `hypit get BUILD_ID --output final.video --to output/final.mp4`. Retain the sources, plan, output and differences between versions.
19
+
20
+ ## Safety Boundaries
21
+
22
+ Check permission to use footage, voices and likenesses. Request approval before paid generation, transmitting private media to a provider or publishing. Keep credentials in operator configuration. If the local CLI or runtime is missing, identify the missing dependency. Do not install packages, upload media or claim a completed render implicitly.
23
+
24
+ ## Verification
25
+
26
+ Probe each exported file for dimensions, frame rate, duration and expected audio. Inspect the opening, the main transition and the ending. For speech, verify caption synchronization and audibility. Deliver only files that exist and state which variants were rendered. Vietnamese usage examples are in `references/vi.md`.
@@ -0,0 +1,10 @@
1
+ {
2
+ "format": "hybrid-en-core-vi-layer/v1",
3
+ "core_locale": "en",
4
+ "user_locale": "vi",
5
+ "core_entrypoint": "SKILL.md",
6
+ "vietnamese_layer": "references/vi.md",
7
+ "core_authoritative": true,
8
+ "load_mode": "progressive",
9
+ "external_skill_policy": "reviewed_only"
10
+ }
@@ -0,0 +1,5 @@
1
+ <?svml using="@hypit/markup/run@1"?>
2
+ <svrun version="1">
3
+ <author source="./main.svml"/>
4
+ <target output="final.video"/>
5
+ </svrun>
@@ -0,0 +1,24 @@
1
+ <?svml using="@hypit/markup@1"?>
2
+ <svml>
3
+ <import as="space" from="@hypit/spatial@1"/>
4
+ <import as="clockwork" from="@hypit/timeline-author@1"/>
5
+ <import as="asset" from="@hypit/media@1"/>
6
+ <import as="shots" from="@hypit/visual-track@1"/>
7
+ <import as="movie" from="@hypit/film@1"/>
8
+ <import as="encode" from="@hypit/html-video@1"/>
9
+ <import as="palette" source="./style.svs"/>
10
+
11
+ <space:Canvas id="portrait" width="540" height="960"/>
12
+ <space:Extent id="art-size" width="540" height="960"/>
13
+ <space:Frame id="stage" within={portrait.bounds} left="6%" top="6%" right="94%" bottom="94%"/>
14
+ <clockwork:Clock id="rate" frame-rate="24"/>
15
+ <clockwork:Timeline id="cut" clock={rate} end="3s"/>
16
+ <asset:Image id="hero" src="./hero.png"/>
17
+ <shots:Track id="picture" timeline={cut.timeline}>
18
+ <shots:Clip id="cover" image={hero} extent={art-size} during={cut.window} frame={stage} z="10" fit="contain"/>
19
+ </shots:Track>
20
+ <movie:Film id="portrait-cut" canvas={portrait.canvas} timeline={cut.timeline} appearance={palette.film.cover}>
21
+ <movie:Track source={picture.visual}/>
22
+ </movie:Film>
23
+ <encode:Video id="final" composition={portrait-cut.composition} timeline={cut.timeline}/>
24
+ </svml>
@@ -0,0 +1 @@
1
+ {"name":"kino-video-project","private":true,"hypit":{"project":true}}
@@ -0,0 +1,4 @@
1
+ <?svml using="@hypit/recipe@1"?>
2
+ <sheet version="1">
3
+ film.cover { background: #121a28; }
4
+ </sheet>
@@ -0,0 +1,19 @@
1
+ {
2
+ "id": "video-workflow",
3
+ "name": "Kino",
4
+ "version": "1.0.0",
5
+ "description": "Analyze footage, author editable video compositions and verify rendered variants.",
6
+ "defaultEnabled": false,
7
+ "triggerTerms": [
8
+ "video",
9
+ "Hypit",
10
+ "SVML",
11
+ "dựng phim",
12
+ "kịch bản",
13
+ "bảng cảnh",
14
+ "storyboard",
15
+ "render",
16
+ "phụ đề"
17
+ ],
18
+ "requiredCapabilities": []
19
+ }
@@ -0,0 +1,13 @@
1
+ # Dựng video ngắn với Kino
2
+
3
+ ## Mục đích
4
+
5
+ Kino giúp phân tích nhịp dựng của video tham khảo và biến kịch bản thành một dự án có thể chỉnh sửa, dùng lại hoặc xuất thành nhiều phiên bản.
6
+
7
+ ## Cách dùng
8
+
9
+ Gửi video, hình ảnh hoặc mô tả ý tưởng. Ví dụ, “Từ ảnh sản phẩm này, chuẩn bị hai phiên bản video dọc. Chỉ thay câu mở đầu, dùng phụ đề tiếng Việt và cho tôi xem phương án trước khi dựng.” Nếu đã có dự án Hypit, gửi đường dẫn thư mục để bot kiểm tra tệp và kế hoạch dựng.
10
+
11
+ ## Giới hạn
12
+
13
+ Lõi xử lý nằm trong `SKILL.md`. Để xuất MP4 qua Hypit, máy dựng cần có công cụ dòng lệnh và môi trường dựng đã cấu hình. Bot có thể chuẩn bị kịch bản, bảng cảnh và tệp dự án trước bước này. Khi cần giọng đọc hoặc hình ảnh từ dịch vụ có phí, bot sẽ hỏi trước.
@@ -1,3 +0,0 @@
1
- import{l as P,b as Le,t as a,r as i,j as e,X as bt,a as S,d as Ie,S as Ft}from"./styles-DOwrpvZY.js";import{r as ze,L as $,P as ft,Q as it,R as _t,v as lt,U as Ut,t as he}from"./PlacesRail-DyYA64do.js";import{a$ as A,cd as ot,ce as Gt,cf as $e,cg as yt,ch as Kt,ci as Yt,j as C,x as u,cj as Ht,ck as qt,cl as Wt,C as Jt,cm as ct,cn as Xt,aQ as kt,u as jt,co as Be,cp as Qt,cq as Zt,cr as Vt,cs as es,ct as ts,cu as ss,c5 as as,cv as ns,cw as rs,cx as dt,cy as is,af as ls,cz as os}from"./App-D19QFJed.js";import{t as ge,o as Nt,a as cs,b as ds,c as ms,d as xs,e as ps,M as us}from"./org-library-DKT7NXTB.js";import{t as hs,a as gs}from"./import-name-B7Do-JDx.js";import{L as bs}from"./LimixResizeHandles-o2O_Or0r.js";import{ShareTeamDialog as fs}from"./ShareTeamDialog-BzoKwVa3.js";import{R as ys}from"./MenuMotion-BclWiAVe.js";import"./monitor-B9eyPPw6.js";import"./index-CJtPXUE4.js";import"./package-format-BLTn6eID.js";import"./team-share-CS8lXIGF.js";function ks(t){const d=A(t.id,P());if(d)return ot(d);const o=ot(t),x=`readyBots.bot.${t.id}`;return{title:Le(`${x}.title`,o.title),description:Le(`${x}.description`,o.description),tryAsking:Le(`${x}.try`,o.tryAsking)}}const js={"seo growth team":"seoGrowth","engineering team":"engineering","100x marketing team":"marketing100x","reddit lead miner":"redditLeadMiner","competitor watch":"competitorWatch","inbox follow-up":"inboxFollowup"};function Re(t){const d=t.builtIn&&$e.find(x=>`industry-${x.slug}`===t.slug);if(d)return{...t,...Yt(d,P())};const o=js[t.name.trim().toLowerCase()];return o?{...t,name:a(`templates.catalog.${o}.name`),summary:a(`templates.catalog.${o}.summary`),outcome:t.outcome?a(`templates.catalog.${o}.outcome`):void 0}:t}function Ns(t,d){const o=Re(t);return`${o.name} ${o.summary} ${t.name} ${t.summary} ${t.category} ${t.skills.join(" ")} ${t.requires.apps.join(" ")}`.toLowerCase().includes(d)}function Oe(t){const d=P();if(t==="industry-customer-care")return Gt(d).intake;const o=$e.find(x=>`industry-${x.slug}`===t);return o?`${yt(o,d).name} · ${o.roles.map(x=>Kt(x,d).name).join(", ")}`:t}function vt({title:t,subtitle:d,icon:o,loading:x,error:c,sections:k,useLabel:j,onUse:v,onClose:w}){const m=i.useRef(null);i.useEffect(()=>{m.current?.querySelector("[data-details-close]")?.focus();const g=B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),w())};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[w]);const N=k.filter(g=>typeof g.body=="string"?g.body.trim():g.body.length);return ze.createPortal(e.jsx("div",{className:"ui-scrim fixed inset-0 z-[90] flex items-center justify-center p-4",onMouseDown:g=>{g.target===g.currentTarget&&w()},children:e.jsxs("div",{ref:m,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:[o,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:t}),d&&e.jsx("p",{className:"break-words text-[13px] text-ink-secondary",children:d})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:[x&&e.jsxs("p",{className:"flex items-center gap-2 py-2 text-[13px] text-ink-secondary",children:[e.jsx($,{size:14,className:"animate-spin","aria-hidden":"true"}),u("Đang tải chi tiết…","Loading details…")]}),c&&e.jsx("p",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[13px] text-danger",children:c}),N.map(g=>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:g.label}),typeof g.body=="string"?e.jsx("p",{className:"whitespace-pre-line break-words text-[13px] leading-[1.5] text-ink-secondary",children:g.body}):e.jsx("ul",{className:"list-disc space-y-0.5 ps-5 text-[13px] leading-[1.5] text-ink-secondary",children:g.body.map((B,I)=>e.jsx("li",{className:"break-words",children:B},I))})]},g.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:w,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(ft,{size:14,"aria-hidden":"true"}),j]})]}),e.jsx("button",{type:"button","data-details-close":"",onClick:w,"aria-label":u("Đóng","Close"),className:"ui-icon-button absolute end-3 top-3",children:e.jsx(bt,{size:16})})]})}),document.body)}function vs({entry:t,onUse:d,onClose:o}){const x=Re(t),[c,k]=i.useState(null),[j,v]=i.useState("");i.useEffect(()=>{let m=!0;return C(`/api/team-library/teams/${t.slug}${t.builtIn?`?locale=${P()}`:""}`).then(N=>{m&&k(ge(N))},N=>{m&&v(N instanceof Error?N.message:String(N))}),()=>{m=!1}},[t.slug]);const w=[a("templates.botCount",{count:c?.members.length??t.members}),...c?[u(`${c.rooms} phòng`,`${c.rooms} rooms`),u(`${c.routines} lịch định kỳ`,`${c.routines} routines`)]:[],...t.setupMinutes?[a("templates.minutes",{count:t.setupMinutes})]:[]];return e.jsx(vt,{title:x.name,subtitle:x.category,loading:!c&&!j,error:j,sections:[{label:u("Nhóm này làm gì","What the team does"),body:[x.summary,x.outcome].filter(Boolean).join(`
2
-
3
- `)},{label:u("Tổng quan","At a glance"),body:w},{label:u("Thành viên","Members"),body:(c?.members??[]).map(m=>m.title?`${m.name} — ${m.title}`:m.name)},{label:u("Kỹ năng đi kèm","Skills included"),body:t.builtIn?t.skills.map(Oe):c?.skills?.length?c.skills:t.skills},{label:u("Ứng dụng cần kết nối","Apps needed"),body:c?.apps.length?c.apps.map(m=>m.optional?u(`${m.label} (không bắt buộc)`,`${m.label} (optional)`):m.label):t.requires.apps},{label:u("Lưu ý","Notes"),body:c?.warnings??[]}],useLabel:a("templates.load"),onUse:d,onClose:o})}const q=["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 ws({pending:t,importedNames:d,org:o=!1}){return e.jsxs(e.Fragment,{children:[t.description&&e.jsx("p",{className:"max-w-2xl text-[14px] leading-relaxed text-ink-secondary",children:t.description}),t.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:a("teamImport.brief")}),e.jsx("p",{className:"mt-1 line-clamp-4 whitespace-pre-wrap break-words",children:t.brief})]}),!!t.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:a("templates.backupNotes")}),t.warnings?.map((x,c)=>e.jsx("p",{children:x},c))]}),(t.kind==="package"||t.kind==="backup")&&e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2 text-[12px] text-ink-secondary",children:[t.chiefOfStaff&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Ht,{size:13}),a("templates.leads",{name:t.chiefOfStaff})]}),!t.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(qt,{size:13}),a("templates.groupChats",{count:t.rooms})]}),!(t.library&&!t.playbooks)&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Wt,{size:13}),a("templates.playbooks",{count:t.playbooks})]}),!t.library&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Jt,{size:13}),t.version===2?a("teamImport.routinesPaused",{count:t.routines}):a("templates.pausedRoutines",{count:t.routines})]}),t.kind==="package"&&t.version!==2&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(ct,{size:13}),a("templates.connections",{count:t.apps.length})]}),!!t.connections?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(ct,{size:13}),a("teamImport.connections",{count:t.connections?.length??0})]}),!!t.notes&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(Xt,{size:13}),a("teamImport.notes",{count:t.notes??0})]}),!!t.presets?.length&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-raised px-3 py-1.5",children:[e.jsx(kt,{size:13}),a("teamImport.presets",{count:t.presets?.length??0})]})]}),!!t.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:o?a("orgLibrary.skillsOn"):t.version===2?a("teamImport.skillsOff"):a("templates.skillsDisabled")}),e.jsx("p",{className:"mt-1 break-words",children:t.skills?.join(", ")}),!o&&e.jsx("p",{className:"mt-1",children:t.version===2?a("teamImport.skillsReview"):a("templates.skillsReview")})]}),t.library&&!!t.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:a("teamImport.presetList")}),e.jsx("p",{className:"mt-1 break-words",children:t.presets?.join(", ")})]}),!!t.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:a("teamImport.offeredSkills")}),e.jsx("p",{className:"mt-1 break-words",children:t.offeredSkills?.join(", ")})]}),!!t.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:a("teamImport.connections",{count:t.connections?.length??0})}),e.jsx("ul",{className:"mt-1",children:t.connections?.map((x,c)=>e.jsxs("li",{className:"truncate",children:[x.label," · ",x.url]},`${x.label}-${c}`))})]}),t.members.length>0&&e.jsx("div",{className:"mt-6 text-[12px] font-medium text-ink-secondary",children:a("templates.teamMembers")}),e.jsx("div",{className:"mt-2 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:t.members.map((x,c)=>e.jsxs("div",{className:"flex min-h-[72px] items-center gap-3 border-b border-hairline/35 px-1 py-3",children:[t.pictures?.[c]?e.jsx("img",{src:t.pictures[c],alt:"",className:"size-9 shrink-0 rounded-lg object-cover"}):e.jsx("div",{className:S("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",q[c%q.length]),children:x.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:d[c]}),d[c]!==x.name&&e.jsx("div",{className:"text-[12px] text-ink-secondary",children:a("templates.newCopyOf",{name:x.name})}),e.jsx("div",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:x.title||a("templates.generalAssistant")})]})]},`${x.name}-${c}`))}),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(Ie,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("p",{children:t.kind==="backup"?a("templates.backupSafety",{archived:t.archivedBots?a("templates.archivedBots",{count:t.archivedBots}):""}):o?t.members.length?a("orgLibrary.teamSafety"):a("orgLibrary.librarySafety"):t.library?a("teamImport.librarySafety"):t.version===2?a("teamImport.sharedTeamSafety"):t.kind==="package"?a("templates.packageSafety"):a("templates.legacySafety")})]})]})}async function Ss(t,d){for(const o of d??[])await fetch(`/api/limix/skill-store/${encodeURIComponent(t)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:o,add:!0})}).catch(()=>{})}const mt={gmail:"Gmail",github:"GitHub",discord:"Discord",slack:"Slack",googlecalendar:"Google Calendar",notion:"Notion",linear:"Linear",figma:"Figma",gong:"Gong",hubspot:"HubSpot",postiz:"Postiz"},Te={everyday:"readyBots.category.everyday",work:"readyBots.category.work",writing:"readyBots.category.writing",design:"readyBots.category.design",sales:"readyBots.category.sales",personal:"readyBots.category.personal"};function Ee(t){t=A(t.id,P())??t;const d=ks(t);return{id:t.id,name:t.name,title:d.title,category:t.category,description:d.description,try:d.tryAsking,look:t.look,apps:t.apps,routines:t.routines?.length??0,builtIn:!0}}function H(t){const d=t.length?t.filter(o=>!A(o.id)).map(o=>({...o,builtIn:!1})):ts.map(Ee);return[...ss.map(Ee),...d]}let F=null;async function Cs(){const{bots:t}=await C("/api/limix/bots/refresh",{method:"POST"});return F=t.length?H(t):null,(F??H([])).length}const xt=(t,d)=>{const o=d.trim().toLowerCase();return!o||[t.name,t.title,t.description,t.category].some(x=>x.toLowerCase().includes(o))};function Ls({search:t,onDialog:d,onAdded:o,revision:x=0,suggestion:c}){const{state:k,dispatch:j}=jt(),[v,w]=i.useState(null),[m,N]=i.useState(""),[g,B]=i.useState(()=>F??H([])),[I,W]=i.useState(!1),[R,J]=i.useState(null),[X,_]=i.useState(""),[O,U]=i.useState(null);i.useEffect(()=>{if(x>0){B(F??H([])),W(!1);return}let n=!0;return C("/api/limix/bots").then(({bots:b})=>{if(!n)return;const p=H(b);F=b.length?p:null,B(p),W(!1)}).catch(()=>{n&&(B(F??H([])),W(!F))}),()=>{n=!1}},[x]);const V=()=>{U(null),d(!1)},[h,T]=i.useState(null),ee=n=>{if(d(!0),n.builtIn){T({card:n,bot:A(n.id,P())??as(n.id)});return}T({card:n}),C(`/api/limix/bots/${n.id}`).then(({bot:b})=>T(p=>p?.card.id===n.id?{card:n,bot:b}:p),b=>T(p=>p?.card.id===n.id?{card:n,error:b instanceof Error?b.message:String(b)}:p))},be=()=>{T(null),d(!1)},te=async n=>{if(!(R||ns(k))){if(_(""),window.ogb?.remoteClient?.active){A(n.id)?(d(!1),_(u("Hãy mở mẫu này trên máy chủ Limix Bot để cài bộ công cụ CSKH.","Open this template on the Limix Bot host to install its customer care tools."))):j({type:"newBot",onCreated:o});return}if(n.builtIn){U({id:n.id}),d(!0);return}J(n.id);try{const{bot:b}=await C(`/api/limix/bots/${n.id}`);U({id:n.id,data:b,skills:b.skills}),d(!0)}catch(b){_(b instanceof Error?b.message:String(b))}finally{J(null)}}},M=g.map(n=>{const b=n.builtIn&&A(n.id);return b?Ee(b):n}).filter(n=>c==="support"?n.builtIn&&n.id===Be&&xt(n,t):c==="department"&&(!n.builtIn||n.id===Be||!A(n.id))?!1:(!v||n.category===v)&&xt(n,t)&&(!m||n.builtIn&&(n.id===Be||n.id.startsWith(`industry-${m}-`))));return!m&&t.trim()&&M.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:a("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:I?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)."):a("readyBots.subtitle")})})]}),e.jsxs("div",{className:"mb-3 mt-2 flex flex-wrap gap-1.5",role:"group","aria-label":a("readyBots.categories"),children:[!c&&[null,...Qt].map(n=>e.jsx("button",{type:"button","aria-pressed":v===n,onClick:()=>{w(n),N("")},className:S("rounded-full px-3 py-1 text-[13px] transition-colors",v===n?"bg-ink text-panel":"bg-raised/70 text-ink-secondary hover:text-ink"),children:n?a(Te[n]):a("readyBots.all")},n??"all")),c!=="support"&&e.jsxs("select",{value:m,"aria-label":u("Lọc mẫu bot theo ngành","Filter bot templates by industry"),className:"rounded-full border border-hairline bg-panel px-3 py-1 text-[13px] text-ink",onChange:n=>{N(n.target.value),w(null)},children:[e.jsx("option",{value:"",children:u("Tất cả ngành","All industries")}),$e.map(n=>e.jsx("option",{value:n.slug,children:yt(n,P()).name},n.slug))]})]}),X&&e.jsx("p",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[13px] text-danger",children:X}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,280px),1fr))] gap-3",children:M.map(n=>e.jsxs("article",{"data-ready-bot":n.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(it,{color:n.look.color,bodyId:n.look.mascotBody,state:n.look.mascotExpression??"idle",size:40,animated:!1,label:n.name}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"text-[14px] font-medium text-ink",children:n.name}),e.jsxs("p",{className:"text-[12px] text-ink-secondary",children:[n.title," · ",a(Te[n.category])]})]})]}),e.jsx("p",{className:"mt-3 text-[13px] leading-[1.45] text-ink-secondary",children:n.description}),e.jsx("p",{className:"mt-2 text-[12px] italic text-ink-tertiary",children:a("readyBots.try",{prompt:n.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":n.id,onClick:()=>ee(n),"aria-label":u(`Xem thêm về ${n.name}`,`More about ${n.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(Zt,{size:13,"aria-hidden":"true"}),u("Xem thêm","See more")]}),e.jsxs("button",{type:"button",onClick:()=>{te(n)},disabled:R!==null,"aria-label":u(`Dùng mẫu ${n.name}, ${n.title}`,`Use template ${n.name}, ${n.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:[R===n.id?e.jsx($,{size:14,className:"animate-spin","aria-hidden":"true"}):e.jsx(ft,{size:14,"aria-hidden":"true"}),u("Dùng mẫu","Use template")]})]}),(n.apps.length>0||n.routines>0)&&e.jsx("p",{className:"pt-2 text-[12px] text-ink-tertiary",children:[n.apps.length>0&&a("readyBots.worksWith",{apps:n.apps.map(b=>mt[b]??b).join(", ")}),n.routines>0&&a("readyBots.pausedRoutine")].filter(Boolean).join(" · ")})]},n.id))}),h&&e.jsx(vt,{title:h.card.name,subtitle:`${h.card.title} · ${a(Te[h.card.category])}`,icon:e.jsx(it,{color:h.card.look.color,bodyId:h.card.look.mascotBody,state:h.card.look.mascotExpression??"idle",size:44,animated:!1,label:h.card.name}),loading:!h.bot&&!h.error,error:h.error,sections:[{label:u("Bot này làm gì","What it does"),body:h.bot?.description??h.card.description},{label:u("Cách bot làm việc","How it works"),body:h.bot?.soul??""},{label:u("Bạn có thể hỏi","Things to ask"),body:h.bot?.tryAsking??[h.card.try]},{label:u("Kỹ năng đi kèm","Skills included"),body:A(h.card.id)?Vt(h.card.id).map(Oe):h.bot?.skills??[]},{label:u("Kênh chăm sóc khách hàng","Customer service channels"),body:A(h.card.id)?u("Sau khi tạo bot, mở Cài đặt của bot để kết nối Zalo, Facebook Page, Messenger hoặc Telegram.","After creating the bot, open its settings to connect Zalo, a Facebook Page, Messenger or Telegram."):""},{label:u("Ứng dụng nên kết nối","Apps it works with"),body:(h.bot?.apps??h.card.apps).map(n=>mt[n]??n)},{label:u("Lịch định kỳ (tạo ở trạng thái tạm dừng)","Routines (created paused)"),body:(h.bot?.routines??[]).map(n=>n.schedule&&"time"in n.schedule&&n.schedule.time?`${n.name} · ${n.schedule.time}`:n.name)}],useLabel:u("Dùng mẫu","Use template"),onUse:()=>{const n=h.card;T(null),te(n)},onClose:be}),O&&ze.createPortal(e.jsx(es,{readyBotId:O.id,readyBotData:O.data,onClose:V,onCreated:n=>{d(!1),Ss(n.id,O.skills),o(n)}}),document.body)]})}const pt=["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 Bs({listing:t,busy:d,notice:o,error:x,onAdd:c,onDetails:k}){const j=t.organization.name;return e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:a("orgLibrary.intro",{name:j})}),t.packages.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:a("orgLibrary.empty",{name:j})}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:t.packages.map((v,w)=>e.jsx(Ts,{entry:v,index:w,busy:d,onAdd:c,onDetails:k},v.packageId))}),o&&e.jsx("div",{role:"status",className:"mt-4 rounded-lg bg-raised/60 px-3 py-2 text-[13px] text-ink-secondary",children:o}),x&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:x})]})}function Ts({entry:t,index:d,busy:o,onAdd:x,onDetails:c}){const k=Nt(t),j=cs(t),v=ds(t),w=o===t.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:S("flex size-11 shrink-0 items-center justify-center rounded-xl",pt[d%pt.length]),children:e.jsx(_t,{size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:t.name}),e.jsx("p",{className:"mt-0.5 truncate text-[13px] text-ink-secondary",children:t.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:ms(t)}),j&&e.jsx("span",{className:"rounded-full bg-accent/10 px-2 py-0.5 text-accent-text",children:j}),t.release&&e.jsx("span",{children:t.release.version})]}),e.jsx("p",{className:"mt-0.5 truncate text-[12px] text-ink-tertiary",children:xs(t.contents)}),v.map(m=>e.jsx("p",{className:"mt-0.5 text-[12px] text-warning",children:m},m))]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[k==="add"&&e.jsxs("button",{onClick:()=>x(t),disabled:o!==null,"aria-label":a("orgLibrary.addAria",{name:t.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:[w&&e.jsx($,{size:13,className:"animate-spin"}),w?a("orgLibrary.adding"):a("orgLibrary.add")]}),k==="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(Ie,{size:13,className:"text-success"}),a("orgLibrary.added")]}),k==="updateApp"&&e.jsx("span",{className:"max-w-[140px] text-right text-[12px] text-ink-secondary",children:a("orgLibrary.updateApp")}),k==="notReady"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:a("orgLibrary.notReady")}),k==="noRelease"&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:a("orgLibrary.noRelease")}),t.blob==="ready"&&e.jsx("button",{onClick:()=>c(t),disabled:o!==null,"aria-label":a("orgLibrary.detailsAria",{name:t.name}),className:"rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:a("orgLibrary.details")})]})]})}const Es="https://github.com/leomieo/limix-bot-teams",ut=["cyan","red","purple","green","orange"];async function ht(t){if(window.ogb?.openExternal){await window.ogb.openExternal(t);return}const d=window.open(t,"_blank","noopener,noreferrer");d&&(d.opener=null)}function Is(t,d){const o=new Map;for(const c of d){if(c.hidden)continue;const k=c.section?.trim()??"";o.set(k,(o.get(k)??0)+1)}return[...[...new Set([...t.map(c=>c.trim()).filter(Boolean),...o.keys()])].filter(c=>c!==""),""].flatMap(c=>o.get(c)?[{name:c,bots:o.get(c)}]:[])}function gt({index:t}){return e.jsx("div",{className:S("flex size-11 shrink-0 items-center justify-center rounded-xl",q[t%q.length]),children:e.jsx(kt,{size:20})})}function Ks({onClose:t,onImported:d,returnFocusRef:o,initialUrl:x,initialIndustrySuggestion:c}){const{state:k,dispatch:j}=jt(),v=i.useRef(null),w=i.useRef(null),[m,N]=i.useState(c==="team"?"teams":"explore"),[g,B]=i.useState(c),[I,W]=i.useState(null),[R,J]=i.useState(!0),[X,_]=i.useState(""),[O,U]=i.useState(!1),[V,h]=i.useState(""),[T,ee]=i.useState(""),[be,te]=i.useState(0),M=i.useRef(0),[n,b]=i.useState(null),[p,Q]=i.useState(null),[wt,St]=i.useState("file"),[fe,Ae]=i.useState(""),[De,Pe]=i.useState(!1),[z,se]=i.useState(!1),[Ct,ye]=i.useState(!1),[ke,Lt]=i.useState(""),[G,f]=i.useState(""),[Me,Fe]=i.useState(""),[ae,_e]=i.useState(!1),[L,Ue]=i.useState(null),[Bt,Tt]=i.useState(""),[ne,je]=i.useState(null),[Ge,Ke]=i.useState(new Set),[Ye,He]=i.useState(""),[re,qe]=i.useState(!1),[ie,We]=i.useState(null),[Je,le]=i.useState(!1),[Ne,ve]=i.useState(null),[oe,Xe]=i.useState(null),[Et,ce]=i.useState(null),[It,Qe]=i.useState(""),[zt,de]=i.useState(""),[K,me]=i.useState(null),D=i.useRef(!!c),Y=i.useRef(0),we=k.bots.filter(s=>!s.hidden).length,Ze=Is(k.sections??[],k.bots),$t=new Set(k.bots.map(s=>s.name.trim().toLowerCase())),Rt=p?.members.map(s=>hs(s.name,$t))??[],xe=i.useCallback(async(s=!1)=>{const r=++M.current;J(!0),_("");try{const l=await C(`/api/team-library/catalog${s?"?fresh=1":""}`);return r===M.current&&W(l),l.communityAvailable!==!1}catch(l){return r===M.current&&_(l instanceof Error?l.message:String(l)),!1}finally{r===M.current&&J(!1)}},[]),Ot=async()=>{if(!O){U(!0),h(""),ee("");try{const[s,r]=await Promise.allSettled([Cs(),xe(!0)]);if(s.status==="fulfilled"&&te(l=>l+1),s.status==="fulfilled"&&r.status==="fulfilled"&&r.value)h(u("Đã cập nhật mẫu Bot và mẫu nhóm Bot.","Bot and team templates updated."));else{const l=[...s.status==="rejected"?[u("mẫu Bot","bot templates")]:[],...r.status==="rejected"||!r.value?[u("mẫu nhóm Bot","team templates")]:[]];ee(u(`Chưa cập nhật được ${l.join(", ")}. Hãy thử lại.`,`Could not update ${l.join(", ")}. Please retry.`))}}finally{U(!1)}}};i.useEffect(()=>{xe()},[xe]);const pe=i.useCallback(async()=>{try{const s=await C("/api/org-library");Xe(s),s.organization&&!D.current&&N("org")}catch{Xe({organization:null,packages:[]})}},[]);i.useEffect(()=>{pe()},[pe]),i.useEffect(()=>(v.current?.focus(),()=>o.current?.focus()),[o]),i.useEffect(()=>{const s=r=>{if(ie!==null||Je)return;if(r.key==="Escape"&&!z){r.preventDefault(),r.stopPropagation(),p?(Q(null),me(null)):t();return}if(r.key!=="Tab")return;const l=v.current,y=Array.from(l?.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex="-1"])')??[]);if(!l||y.length===0)return;const E=y[0],ue=y.at(-1);r.shiftKey&&(document.activeElement===E||!l.contains(document.activeElement))?(r.preventDefault(),ue.focus()):!r.shiftKey&&document.activeElement===ue&&(r.preventDefault(),E.focus())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[z,t,p,ie,Je]);const Se=(s,r)=>{Q(s),St(r),f("")},Ve=async s=>{if(s.size>us)throw new Error(a("templates.fileTooLarge"));const r=await s.text();let l=r;if(!s.name.toLowerCase().endsWith(".md"))try{l=JSON.parse(r)}catch(y){throw y instanceof SyntaxError?new Error(a("teamLibrary.invalidJson")):y}Se(ge(l),"file")},et=async s=>{b(s.slug),f("");try{const r=ge(await C(`/api/team-library/teams/${s.slug}${s.builtIn?`?locale=${P()}`:""}`));Se(s.builtIn?{...r,builtInTeam:s.slug}:r,"library")}catch(r){f(r instanceof Error?r.message:String(r))}finally{b(null)}},tt=async()=>{await st(fe)},st=async s=>{if(s.trim()){Pe(!0),f("");try{const r=await C("/api/team-library/github",{method:"POST",body:JSON.stringify({url:s.trim()})});Se(ge(r),"github")}catch(r){f(r instanceof Error?r.message:String(r))}finally{Pe(!1)}}};i.useEffect(()=>{x&&(D.current=!0,N("import"),Ae(x),st(x))},[x]);const At=async()=>{if(p){se(!0),f("");try{const s=await gs(p.manifest,j,p.builtInTeam);he("team_imported",{members:s.bots.length,source:wt,mode:"add",format:p.kind}),d({name:p.name,members:s.bots.length,...s.connections?.length?{connections:s.connections.length}:{},...s.presets?.length?{presets:s.presets.length}:{}})}catch(s){f(s instanceof Error?s.message:String(s))}finally{se(!1)}}},Dt=async s=>{ce(s.packageId),de("");try{const r=await C(`/api/org-library/packages/${s.packageId}`);Q(ps(r.document)),me(s),f("")}catch(r){de(r instanceof Error?r.message:String(r))}finally{ce(null)}},at=async s=>{ce(s.packageId),se(!0),de(""),Qe(""),f("");try{const r=await C("/api/org-library/add",{method:"POST",body:JSON.stringify({packageId:s.packageId})});for(const y of r.bots??[])j({type:"botAdded",bot:y});for(const y of r.groups??[])j({type:"groupPatched",group:y});for(const y of r.routines??[])j({type:"routinePatched",routine:y});const l=r.bots?.find(y=>!y.hidden);if(he("team_imported",{members:r.bots?.length??0,source:"organization",mode:"add",format:"package"}),l){j({type:"select",id:l.id}),d({name:s.name,members:r.bots.length,...r.connections?.length?{connections:r.connections.length}:{}});return}Q(null),me(null),r.alreadyAdded||Qe(a("orgLibrary.addedSkills",{name:s.name})),await pe()}catch(r){const l=r instanceof Error?r.message:String(r);K?f(l):de(l),await pe()}finally{ce(null),se(!1)}},Z=Me.trim(),Ce=async s=>{const r=++Y.current;_e(!0),f(""),Ue(null),je(null),Ke(new Set);try{const l=await C(`/api/teams/scout?cwd=${encodeURIComponent(s)}`);if(r!==Y.current)return;Ue(l),Tt(s),He(l.suggestion.roomName),he("team_scouted",{signals:l.suggestion.manifest.team.members.length-1}),C(`/api/teams/scout/directory?cwd=${encodeURIComponent(s)}`).then(y=>{r===Y.current&&je(y.directory)}).catch(()=>{r===Y.current&&je([])})}catch(l){if(r!==Y.current)return;f(l instanceof Error?l.message:String(l))}finally{r===Y.current&&_e(!1)}},Pt=async()=>{const s=await window.ogb?.pickFolder?.(Z||void 0);s&&(Fe(s),await Ce(s))},Mt=async()=>{if(!(!L||re)){qe(!0),f("");try{const s=(ne??[]).filter(E=>Ge.has(E.slug)).map((E,ue)=>({key:`dir-${E.slug}`,name:E.name,title:E.category||a("templates.communityBot"),description:E.prompt,appearance:{color:ut[ue%ut.length]}})),r={...L.suggestion.manifest,team:{...L.suggestion.manifest.team,members:[...L.suggestion.manifest.team.members,...s]}},l=Ye.trim()||L.suggestion.roomName,y=await C(`/api/teams/import?mode=project&cwd=${encodeURIComponent(Bt)}&room=${encodeURIComponent(l)}`,{method:"POST",body:JSON.stringify(r)});for(const E of y.bots)j({type:"botAdded",bot:E});y.group&&(j({type:"groupPatched",group:{...y.group,messages:[]}}),j({type:"select",id:y.group.id})),he("team_imported",{members:y.bots.length,source:"scout",mode:"project"}),d({name:l,members:y.bots.length})}catch(s){f(s instanceof Error?s.message:String(s))}finally{qe(!1)}}},nt=ke.trim().toLowerCase(),rt=(I?.teams??[]).filter(s=>(g!=="team"||s.builtIn)&&(!nt||Ns(s,nt)));return ze.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4 sm:p-6",onMouseDown:s=>s.stopPropagation(),children:[e.jsxs("div",{ref:v,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:[p&&e.jsx("button",{onClick:()=>{Q(null),me(null),f("")},disabled:z,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":a("templates.back"),children:e.jsx(rs,{size:18})}),e.jsx("h2",{id:"team-library-title",className:"[overflow-wrap:anywhere] text-[22px] font-semibold tracking-[-0.01em] text-ink",children:p?p.name:a("templates.title")})]}),e.jsx("p",{className:S("mt-1 text-[13px] text-ink-secondary",p&&"ml-9"),children:p?p.kind==="backup"?a("templates.backupSummary",{bots:p.members.length,conversations:p.conversations??0}):p.kind==="package"?p.library?a("teamImport.library"):p.version===2?a("teamImport.sharedTeam",{count:p.members.length}):a("templates.playbookSummary",{count:p.members.length}):a("templates.readyBots",{count:p.members.length}):a("templates.subtitle")})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!p&&e.jsxs("button",{onClick:()=>{ht(I?.repositoryUrl??Es)},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:a("templates.openRepository"),children:[e.jsx(dt,{size:16}),e.jsx("span",{className:"max-sm:hidden",children:a("templates.communityRepo")}),e.jsx(lt,{size:12})]}),e.jsx("button",{onClick:t,disabled:z,className:"rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":a("templates.close"),children:e.jsx(bt,{size:21})})]})]}),p?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(ws,{pending:p,importedNames:Rt,org:K!==null}),p.builtInTeam&&e.jsxs("p",{className:"mt-3 text-[13px] text-ink-secondary",children:[I?.teams.find(s=>s.slug===p.builtInTeam)?.skills.map(Oe).join(" · "),e.jsx("br",{}),u("Mỗi thành viên có kỹ năng CSKH, công cụ phân loại yêu cầu và tra danh mục công khai riêng. Kết nối kênh và nạp dữ liệu của doanh nghiệp sau khi tạo.","Each member gets the customer-care skill, ticket triage and its own public catalog lookup. Set up your business data and channels after creation.")]}),G&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:G})]}),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:[a(we===0?"templates.existingNone":we===1?"templates.existingOne":"templates.existingMany",{count:we})," ",p.kind==="backup"?a("teamImport.backupCopies"):p.library?a("teamImport.libraryAdds"):p.members.length===0?"":a("teamImport.newSection",{name:p.teamName??p.name})]}),K?Nt(K)==="add"?e.jsxs("button",{onClick:()=>{at(K)},disabled:z,"aria-label":a("orgLibrary.addAria",{name:K.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:[z&&e.jsx($,{size:15,className:"animate-spin"}),z?a("orgLibrary.adding"):a("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(Ie,{size:14,className:"text-success"}),a("orgLibrary.added")]}):e.jsxs("button",{onClick:()=>{At()},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($,{size:15,className:"animate-spin"}),z?a("templates.importing"):p.kind==="backup"?a("templates.importBackup"):p.library?a("teamImport.addPresets"):a("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":a("templates.source"),children:[oe?.organization&&e.jsx("button",{role:"tab","aria-selected":m==="org",onClick:()=>{D.current=!0,N("org"),f("")},className:S("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:a("orgLibrary.tab",{name:oe.organization.name})}),e.jsx("button",{role:"tab","aria-selected":m==="explore",onClick:()=>{D.current=!0,N("explore"),f("")},className:S("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:a("templates.explore")}),e.jsx("button",{role:"tab","aria-selected":m==="import",onClick:()=>{D.current=!0,N("import"),f("")},className:S("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:a("templates.import")}),e.jsx("button",{role:"tab","aria-selected":m==="scout",onClick:()=>{D.current=!0,N("scout"),f("")},className:S("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:a("templates.fromFolder")}),e.jsx("button",{role:"tab","aria-selected":m==="share",onClick:()=>{D.current=!0,N("share"),f("")},className:S("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:a("teamLibrary.shareTab")}),e.jsx("button",{role:"tab","aria-selected":m==="teams",onClick:()=>{D.current=!0,N("teams"),f("")},className:S("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:()=>{Ot()},disabled:O,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(ys,{size:14,"aria-hidden":"true",className:O?"animate-spin":void 0}),O?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(Ft,{size:17,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:ke,onChange:s=>Lt(s.target.value),placeholder:a("templates.search"),"aria-label":a("templates.search"),className:"min-w-0 flex-1 bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})]}),(V||T)&&e.jsx("p",{role:T?"alert":"status",className:S("px-6 pb-2 text-[13px] sm:px-8",T?"text-danger":"text-ink-secondary"),children:T||V}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-7 pt-5 sm:px-8",children:[g&&(g==="team"&&m==="teams"||g!=="team"&&m==="explore")&&e.jsx("button",{type:"button",onClick:()=>B(void 0),className:"mb-3 text-[13px] text-ink-secondary underline hover:text-ink",children:u("Xem tất cả mẫu","Browse all templates")}),m==="org"&&oe?.organization&&e.jsx(Bs,{listing:oe,busy:Et,notice:It,error:zt,onAdd:s=>{at(s)},onDetails:s=>{Dt(s)}}),m==="explore"&&e.jsx(Ls,{revision:be,search:ke,suggestion:g==="team"?void 0:g,onDialog:le,onAdded:t}),m==="teams"&&e.jsxs("div",{children:[Ne&&e.jsx(vs,{entry:Ne,onClose:()=>{ve(null),le(!1)},onUse:()=>{const s=Ne;ve(null),le(!1),et(s)}}),R&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-24 text-[13px] text-ink-secondary",children:[e.jsx($,{size:16,className:"animate-spin"})," ",a("templates.loading")]}),!R&&X&&e.jsxs("div",{className:"rounded-xl bg-danger/10 p-4 text-[13px] text-danger",children:[e.jsx("p",{children:X}),e.jsx("button",{onClick:()=>{xe()},className:"mt-3 rounded-full bg-raised px-3.5 py-2 text-ink hover:bg-raised-hover",children:a("common.tryAgain")})]}),!R&&I?.communityAvailable===!1&&e.jsx("p",{role:"status",className:"mb-4 text-[13px] text-ink-secondary",children:u("Đang hiển thị các nhóm có sẵn trong Limix Bot. Thư viện cộng đồng chưa kết nối được.","Showing built-in Limix Bot teams. The community library is currently unavailable.")}),!R&&I&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,360px),1fr))] gap-x-10",children:rt.map((s,r)=>{const l=Re(s);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(gt,{index:r}),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:[a("templates.botCount",{count:s.members})," · ",a("templates.playbookCount",{count:s.builtIn?1:s.skills.length}),s.requires.apps.length>0&&` · ${s.requires.apps.join(", ")}`,s.setupMinutes&&` · ${a("templates.minutes",{count:s.setupMinutes})}`]})]}),e.jsxs("div",{className:"col-span-2 flex flex-wrap justify-end gap-2",children:[e.jsx("button",{type:"button","data-team-details":s.slug,onClick:()=>{ve(s),le(!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:()=>{et(s)},disabled:n!==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:[n===s.slug&&e.jsx($,{size:13,className:"animate-spin"}),n===s.slug?a("templates.loadingShort"):a("templates.load")]})]})]},s.slug)})}),!R&&I&&rt.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:a("templates.noneFound")}),e.jsx("div",{className:"mt-1 text-[13px] text-ink-secondary",children:a("templates.tryDifferentSearch")})]})]}),m==="import"&&e.jsxs("div",{children:[e.jsx("input",{ref:w,type:"file",accept:".md,.json,.mausbackup.json,.mausteam.json,text/markdown,application/json",className:"hidden",onChange:s=>{const r=s.currentTarget.files?.[0];s.currentTarget.value="",r&&Ve(r).catch(l=>f(l instanceof Error?l.message:String(l)))}}),e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:a("templates.bringYourOwn")}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("button",{onClick:()=>w.current?.click(),onDragEnter:s=>{s.preventDefault(),ye(!0)},onDragOver:s=>s.preventDefault(),onDragLeave:()=>ye(!1),onDrop:s=>{s.preventDefault(),ye(!1);const r=s.dataTransfer.files[0];r&&Ve(r).catch(l=>f(l instanceof Error?l.message:String(l)))},className:S("flex min-h-56 flex-col items-center justify-center rounded-2xl border border-dashed px-6 text-center transition-colors",Ct?"border-accent bg-accent/5":"border-hairline/60 bg-raised/20 hover:bg-raised/35"),children:[e.jsx(Ut,{size:27,className:"text-accent"}),e.jsx("span",{className:"mt-3 text-[14px] font-medium text-ink",children:a("templates.chooseFile")}),e.jsx("span",{className:"mt-1 text-[13px] text-ink-secondary",children:a("templates.dropFile")})]}),e.jsxs("div",{className:"flex min-h-56 flex-col justify-center rounded-2xl bg-raised/25 px-6",children:[e.jsx(dt,{size:25,className:"text-ink-secondary"}),e.jsx("h3",{className:"mt-3 text-[14px] font-medium text-ink",children:a("templates.loadGithub")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:a("templates.githubHint")}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("input",{value:fe,onChange:s=>Ae(s.target.value),onKeyDown:s=>s.key==="Enter"&&void tt(),placeholder:a("templates.githubPlaceholder"),"aria-label":a("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:()=>{tt()},disabled:!fe.trim()||De,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:[De&&e.jsx($,{size:13,className:"animate-spin"}),a("templates.load")]})]})]})]}),G&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:G})]}),m==="share"&&e.jsxs("div",{children:[e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:a("teamLibrary.shareIntro")}),Ze.length===0?e.jsx("p",{className:"mt-6 text-[13px] text-ink-secondary",children:a("teamLibrary.shareEmpty")}):e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:Ze.map((s,r)=>e.jsxs("article",{className:"flex min-h-[84px] items-center gap-3 border-b border-hairline/35 px-1 py-4",children:[e.jsx(gt,{index:r}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-medium text-ink",children:s.name||a("teamLibrary.general")}),e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:a("teamLibrary.shareBots",{count:s.bots})})]}),e.jsxs("button",{onClick:()=>We(s.name),"aria-label":a("teamLibrary.shareTeamAria",{name:s.name||a("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(is,{size:13}),a("teamLibrary.shareTeam")]})]},s.name||"general"))})]}),m==="scout"&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-3 text-[12px] font-medium text-ink-secondary",children:a("templates.startFolder")}),e.jsx("p",{className:"max-w-2xl text-[13px] leading-relaxed text-ink-secondary",children:a("templates.scoutHint")}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{value:Me,onChange:s=>Fe(s.target.value),onKeyDown:s=>s.key==="Enter"&&Z&&void Ce(Z),placeholder:"/path/to/your/project","aria-label":a("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:()=>{Pt()},disabled:ae,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(ls,{size:14}),a("templates.browse")]}),e.jsxs("button",{onClick:()=>{Ce(Z)},disabled:!Z||ae,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:[ae?e.jsx($,{size:14,className:"animate-spin"}):e.jsx(os,{size:14}),ae?a("templates.scouting"):a("templates.scout")]})]}),L&&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:L.profile.name}),L.profile.summary&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:L.profile.summary}),L.profile.stacks.length>0&&e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:L.profile.stacks.map(s=>e.jsx("span",{className:"rounded-full bg-raised px-2.5 py-1 text-[12px] text-ink-secondary",children:s},s))})]}),e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:a("templates.suggestedTeam")}),e.jsx("div",{className:"mt-1 grid grid-cols-1 gap-x-10 md:grid-cols-2",children:L.suggestion.manifest.team.members.map((s,r)=>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:S("flex size-9 shrink-0 items-center justify-center rounded-lg text-[13px] font-semibold",q[r%q.length]),children:s.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:[s.name," ",e.jsxs("span",{className:"font-normal text-ink-secondary",children:["· ",s.title]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:L.suggestion.reasons[s.key]??""})]})]},s.key))}),ne&&ne.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-5 text-[12px] font-medium text-ink-secondary",children:a("templates.communityDirectory")}),e.jsx("div",{className:"mt-1 flex flex-col",children:ne.map(s=>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:Ge.has(s.slug),onChange:()=>Ke(r=>{const l=new Set(r);return l.has(s.slug)?l.delete(s.slug):l.add(s.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:[s.name,s.category&&e.jsxs("span",{className:"font-normal text-ink-secondary",children:[" · ",s.category]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[12px] text-ink-secondary",children:a("templates.matches",{values:s.matched.join(", ")})})]})]}),e.jsx("button",{onClick:()=>{ht(s.detailUrl)},"aria-label":a("templates.openDirectory",{name:s.name}),title:a("templates.readBeforeAdding"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(lt,{size:14})})]},s.slug))})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx("input",{value:Ye,onChange:s=>He(s.target.value),"aria-label":a("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:()=>{Mt()},disabled:re,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:[re&&e.jsx($,{size:15,className:"animate-spin"}),re?a("templates.creating"):a("templates.createGroupChat")]})]}),e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:a("templates.createGroupHint")})]}),G&&e.jsx("div",{role:"alert",className:"mt-4 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:G})]})]})]}),e.jsx(bs,{storageKey:"limix.templates.size",widthInset:48,heightInset:48,showGrip:!0})]}),ie!==null&&e.jsx(fs,{team:ie,onClose:()=>We(null)})]}),document.body)}export{ws as TeamImportDetails,Ks as TeamLibraryPanel,Is as shareableTeamList};
@@ -1 +0,0 @@
1
- import{U as a,C as n}from"./mermaid.core-1-GuV68k.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};