@bikdotai/bik-component-library 0.0.841-beta.0 → 0.0.841

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 (147) hide show
  1. package/dist/cjs/components/agent-builder/AgentBuilder.js +1 -1
  2. package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
  3. package/dist/cjs/components/agent-builder/AgentBuilder.styled.js +51 -39
  4. package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
  5. package/dist/cjs/components/agent-builder/components/AgentBuilderFooter.js +1 -1
  6. package/dist/cjs/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
  7. package/dist/cjs/components/agent-builder/components/AgentBuilderTopBar.js +1 -1
  8. package/dist/cjs/components/agent-builder/components/AgentBuilderTopBar.js.map +1 -1
  9. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +2 -2
  10. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  11. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +1 -1
  12. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  13. package/dist/cjs/components/agent-builder/components/DiscardModal.js +1 -1
  14. package/dist/cjs/components/agent-builder/components/DiscardModal.js.map +1 -1
  15. package/dist/cjs/components/agent-builder/components/GoLiveModal.js +1 -1
  16. package/dist/cjs/components/agent-builder/components/GoLiveModal.js.map +1 -1
  17. package/dist/cjs/components/agent-builder/components/MentionEditor.js +1 -1
  18. package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
  19. package/dist/cjs/components/agent-builder/components/MentionPicker.js +22 -22
  20. package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
  21. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +4 -4
  22. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  23. package/dist/cjs/components/agent-builder/components/SelectableListSection.js +6 -6
  24. package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
  25. package/dist/cjs/components/agent-builder/components/StepSectionHeader.js +1 -1
  26. package/dist/cjs/components/agent-builder/components/StepSectionHeader.js.map +1 -1
  27. package/dist/cjs/components/agent-builder/constants/tools.js +1 -1
  28. package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -1
  29. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
  30. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  31. package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js +3 -1
  32. package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
  33. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js +1 -1
  34. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  35. package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js +1 -1
  36. package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
  37. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +5 -3
  38. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  39. package/dist/cjs/components/agent-listing/AgentListing.js +1 -1
  40. package/dist/cjs/components/agent-listing/AgentListing.js.map +1 -1
  41. package/dist/cjs/components/agent-listing/AgentTable.js +1 -1
  42. package/dist/cjs/components/agent-listing/AgentTable.js.map +1 -1
  43. package/dist/cjs/components/agent-listing/AgentTableRow.js +1 -1
  44. package/dist/cjs/components/agent-listing/AgentTableRow.js.map +1 -1
  45. package/dist/cjs/components/agent-listing/AgentTableShimmer.js +2 -0
  46. package/dist/cjs/components/agent-listing/AgentTableShimmer.js.map +1 -0
  47. package/dist/cjs/components/agent-listing/DeleteAgentModal.js +1 -1
  48. package/dist/cjs/components/agent-listing/DeleteAgentModal.js.map +1 -1
  49. package/dist/cjs/components/avatar/Avatar.js +1 -1
  50. package/dist/cjs/components/avatar/Avatar.js.map +1 -1
  51. package/dist/cjs/components/avatar/Avatar.styled.js +4 -12
  52. package/dist/cjs/components/avatar/Avatar.styled.js.map +1 -1
  53. package/dist/cjs/components/button/Button.styled.js +1 -0
  54. package/dist/cjs/components/button/Button.styled.js.map +1 -1
  55. package/dist/cjs/components/dropdown/Dropdown.js +1 -1
  56. package/dist/cjs/components/dropdown/Dropdown.js.map +1 -1
  57. package/dist/cjs/editor/BikEditor.js +1 -1
  58. package/dist/cjs/editor/BikEditor.js.map +1 -1
  59. package/dist/cjs/editor/BikEditor.styles.js +97 -54
  60. package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
  61. package/dist/cjs/editor/extensions/jsonHighlight/JsonHighlightExtension.js +3 -3
  62. package/dist/cjs/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -1
  63. package/dist/cjs/icons/Informational/Common UI/Shield.js +2 -0
  64. package/dist/cjs/icons/Informational/Common UI/Shield.js.map +1 -0
  65. package/dist/cjs/icons/index.js +1 -1
  66. package/dist/esm/components/agent-builder/AgentBuilder.js +106 -102
  67. package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
  68. package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +3 -6
  69. package/dist/esm/components/agent-builder/AgentBuilder.styled.js +118 -106
  70. package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
  71. package/dist/esm/components/agent-builder/__fixtures__/agentValue.d.ts +11 -0
  72. package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js +29 -21
  73. package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
  74. package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js +27 -26
  75. package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js.map +1 -1
  76. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +25 -25
  77. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  78. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +24 -23
  79. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  80. package/dist/esm/components/agent-builder/components/DiscardModal.d.ts +3 -1
  81. package/dist/esm/components/agent-builder/components/DiscardModal.js +33 -24
  82. package/dist/esm/components/agent-builder/components/DiscardModal.js.map +1 -1
  83. package/dist/esm/components/agent-builder/components/GoLiveModal.js +23 -21
  84. package/dist/esm/components/agent-builder/components/GoLiveModal.js.map +1 -1
  85. package/dist/esm/components/agent-builder/components/MentionEditor.js +19 -19
  86. package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
  87. package/dist/esm/components/agent-builder/components/MentionPicker.js +174 -144
  88. package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
  89. package/dist/esm/components/agent-builder/components/RestApiToolPanel.d.ts +2 -0
  90. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +111 -105
  91. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  92. package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +13 -4
  93. package/dist/esm/components/agent-builder/components/SelectableListSection.js +161 -136
  94. package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
  95. package/dist/esm/components/agent-builder/components/StepSectionHeader.js +7 -7
  96. package/dist/esm/components/agent-builder/components/StepSectionHeader.js.map +1 -1
  97. package/dist/esm/components/agent-builder/constants/tools.js +6 -6
  98. package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
  99. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +104 -103
  100. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  101. package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js +101 -102
  102. package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
  103. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +146 -144
  104. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  105. package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js +23 -79
  106. package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
  107. package/dist/esm/components/agent-builder/utils/mentionSerialization.js +35 -23
  108. package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  109. package/dist/esm/components/agent-listing/AgentListing.js +65 -65
  110. package/dist/esm/components/agent-listing/AgentListing.js.map +1 -1
  111. package/dist/esm/components/agent-listing/AgentTable.d.ts +2 -0
  112. package/dist/esm/components/agent-listing/AgentTable.js +16 -15
  113. package/dist/esm/components/agent-listing/AgentTable.js.map +1 -1
  114. package/dist/esm/components/agent-listing/AgentTableRow.js +11 -11
  115. package/dist/esm/components/agent-listing/AgentTableRow.js.map +1 -1
  116. package/dist/esm/components/agent-listing/AgentTableShimmer.d.ts +12 -0
  117. package/dist/esm/components/agent-listing/AgentTableShimmer.js +20 -0
  118. package/dist/esm/components/agent-listing/AgentTableShimmer.js.map +1 -0
  119. package/dist/esm/components/agent-listing/DeleteAgentModal.js +8 -8
  120. package/dist/esm/components/agent-listing/DeleteAgentModal.js.map +1 -1
  121. package/dist/esm/components/agent-listing/__fixtures__/agents.d.ts +3 -0
  122. package/dist/esm/components/avatar/Avatar.d.ts +1 -2
  123. package/dist/esm/components/avatar/Avatar.js +24 -34
  124. package/dist/esm/components/avatar/Avatar.js.map +1 -1
  125. package/dist/esm/components/avatar/Avatar.styled.d.ts +0 -1
  126. package/dist/esm/components/avatar/Avatar.styled.js +8 -17
  127. package/dist/esm/components/avatar/Avatar.styled.js.map +1 -1
  128. package/dist/esm/components/button/Button.styled.js +25 -19
  129. package/dist/esm/components/button/Button.styled.js.map +1 -1
  130. package/dist/esm/components/dropdown/Dropdown.js +18 -13
  131. package/dist/esm/components/dropdown/Dropdown.js.map +1 -1
  132. package/dist/esm/editor/BikEditor.js +173 -160
  133. package/dist/esm/editor/BikEditor.js.map +1 -1
  134. package/dist/esm/editor/BikEditor.styles.d.ts +20 -3
  135. package/dist/esm/editor/BikEditor.styles.js +102 -57
  136. package/dist/esm/editor/BikEditor.styles.js.map +1 -1
  137. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.d.ts +5 -8
  138. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js +87 -68
  139. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -1
  140. package/dist/esm/icons/Informational/Common UI/Shield.d.ts +7 -0
  141. package/dist/esm/icons/Informational/Common UI/Shield.js +34 -0
  142. package/dist/esm/icons/Informational/Common UI/Shield.js.map +1 -0
  143. package/dist/esm/icons/Informational/Common UI/index.d.ts +1 -0
  144. package/dist/esm/icons/index.d.ts +1 -1
  145. package/dist/esm/icons/index.js +156 -154
  146. package/dist/esm/icons/index.js.map +1 -1
  147. package/package.json +1 -1
@@ -13,11 +13,11 @@ const it = ({
13
13
  onChange: g,
14
14
  maxLength: a,
15
15
  placeholder: C,
16
- minHeight: x = "200px",
16
+ minHeight: T = "200px",
17
17
  resetKey: l,
18
18
  mentionItems: n,
19
- tools: T,
20
- onMentionSelect: b,
19
+ tools: b,
20
+ onMentionSelect: x,
21
21
  onFocus: E,
22
22
  registerInsert: r,
23
23
  onCreateSubAgent: k,
@@ -25,16 +25,16 @@ const it = ({
25
25
  integrationStatus: O,
26
26
  onConnectIntegration: R,
27
27
  action: D,
28
- ...M
28
+ ...L
29
29
  }) => {
30
- const c = w(null), [y, s] = F(e.length), m = N(
31
- (t, o, B) => {
30
+ const c = w(null), [M, m] = F(e.length), s = N(
31
+ (t, o, A) => {
32
32
  const f = c.current;
33
33
  if (!f)
34
34
  return;
35
- const L = n.find(
35
+ const B = n.find(
36
36
  (u) => String(u.id) === String(o) && u.meta?.kind === t
37
- ), j = B ?? L?.label ?? o;
37
+ ), j = A ?? B?.label ?? o;
38
38
  f.insertInlineContent(
39
39
  `${z(String(o), j, t)} `
40
40
  );
@@ -43,34 +43,34 @@ const it = ({
43
43
  );
44
44
  p(() => {
45
45
  if (r)
46
- return r(m), () => r(null);
47
- }, [r, m]);
48
- const A = _(
46
+ return r(s), () => r(null);
47
+ }, [r, s]);
48
+ const y = _(
49
49
  () => Q(e, n),
50
50
  // eslint-disable-next-line react-hooks/exhaustive-deps
51
51
  [l]
52
52
  );
53
53
  return p(
54
- () => s(e.length),
54
+ () => m(e.length),
55
55
  // eslint-disable-next-line react-hooks/exhaustive-deps
56
56
  [l]
57
57
  ), /* @__PURE__ */ i(P, { children: [
58
58
  /* @__PURE__ */ i(Y, { children: [
59
59
  /* @__PURE__ */ d(G, { color: h.content.primary, children: S }),
60
60
  /* @__PURE__ */ i(J, { color: h.content.secondary, children: [
61
- y,
61
+ M,
62
62
  "/",
63
63
  a
64
64
  ] })
65
65
  ] }),
66
- /* @__PURE__ */ i($, { minHeight: x, "data-test": M["data-test"], children: [
66
+ /* @__PURE__ */ i($, { minHeight: T, "data-test": L["data-test"], children: [
67
67
  /* @__PURE__ */ d(
68
68
  W,
69
69
  {
70
70
  ref: c,
71
- initialContent: A,
71
+ initialContent: y,
72
72
  placeholder: C,
73
- maxCharacters: a,
73
+ characterLimit: a,
74
74
  minHeight: "120px",
75
75
  maxHeight: "320px",
76
76
  style: { border: "none" },
@@ -91,13 +91,13 @@ const it = ({
91
91
  ),
92
92
  onSelect: (t) => {
93
93
  const o = t.meta?.kind;
94
- o && b?.(o, String(t.id));
94
+ o && x?.(o, String(t.id));
95
95
  }
96
96
  },
97
97
  onChange: (t) => {
98
- s(t.characterCount);
98
+ m(t.characterCount);
99
99
  const o = c.current?.getJSON() ?? null;
100
- g(U(o, T));
100
+ g(U(o, b));
101
101
  }
102
102
  },
103
103
  l
@@ -1 +1 @@
1
- {"version":3,"file":"MentionEditor.js","sources":["../../../../../src/components/agent-builder/components/MentionEditor.tsx"],"sourcesContent":["import { BikEditor, BikEditorRef, MentionItem } from '@src/editor';\nimport React, {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { AgentTool } from '../AgentBuilder.model';\nimport {\n\tAiTextAreaShell,\n\tFieldBlock,\n\tFieldLabelRow,\n} from '../AgentBuilder.styled';\nimport { AGENT_EDITOR_STYLE } from '../constants/editorStyle';\nimport type { ToolAction, ToolSource } from '../constants/tools';\nimport {\n\tbuildMentionHtml,\n\teditorDocToInstructions,\n\tinstructionsToEditorHtml,\n\tMentionKindMeta,\n} from '../utils/mentionSerialization';\nimport { MentionPicker } from './MentionPicker';\n\ntype InsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;\n\ninterface MentionEditorProps {\n\tlabel: string;\n\tvalue: string;\n\tonChange: (text: string) => void;\n\tmaxLength: number;\n\tplaceholder?: string;\n\tminHeight?: string;\n\t/** Changing this remounts the editor with fresh content. */\n\tresetKey?: string | number;\n\t/** Items shown in the `@` picker (tools, and sub-agents where allowed). */\n\tmentionItems: MentionItem[];\n\t/** Tools used to serialise mention nodes back to `{{tool:KEY}}`. */\n\ttools: AgentTool[];\n\t/** Called when an item is picked from the `@` menu (to attach it upstream). */\n\tonMentionSelect?: (kind: 'tool' | 'subagent', id: string) => void;\n\tonFocus?: () => void;\n\t/** Receives an insert-at-cursor fn (and null on unmount) for side-panel adds. */\n\tregisterInsert?: (fn: InsertFn | null) => void;\n\t/**\n\t * When set, the `@` picker's Sub-agent view shows a \"Create new\" row that calls\n\t * this (opens the create-sub-agent drawer). Omit to hide it (e.g. the drawer's\n\t * own editors, which can't nest sub-agents).\n\t */\n\tonCreateSubAgent?: () => void;\n\t/**\n\t * Built-in tool actions (Rest API / Handover to email) shown in the `@` picker's\n\t * Tools view. Picking one opens its drawer instead of inserting a mention.\n\t */\n\ttoolActions?: ToolAction[];\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\tonConnectIntegration?: (source: ToolSource) => void;\n\t/** Optional action(s) rendered inside the shell, below the editor. */\n\taction?: React.ReactNode;\n\t'data-test'?: string;\n}\n\n/**\n * Presentational BikEditor field with `@` mentions. Stores firebase token text\n * (`{{tool:KEY}}` / `{{subagent:ID}}`). Context-free — both the builder's\n * Step-3 fields and the create-sub-agent drawer compose it.\n */\nexport const MentionEditor: React.FC<MentionEditorProps> = ({\n\tlabel,\n\tvalue,\n\tonChange,\n\tmaxLength,\n\tplaceholder,\n\tminHeight = '200px',\n\tresetKey,\n\tmentionItems,\n\ttools,\n\tonMentionSelect,\n\tonFocus,\n\tregisterInsert,\n\tonCreateSubAgent,\n\ttoolActions,\n\tintegrationStatus,\n\tonConnectIntegration,\n\taction,\n\t...rest\n}) => {\n\tconst editorRef = useRef<BikEditorRef>(null);\n\tconst [count, setCount] = useState(value.length);\n\n\tconst insert = useCallback<InsertFn>(\n\t\t(kind, id, overrideLabel) => {\n\t\t\tconst editor = editorRef.current;\n\t\t\tif (!editor) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst item = mentionItems.find(\n\t\t\t\t(m) =>\n\t\t\t\t\tString(m.id) === String(id) &&\n\t\t\t\t\t(m.meta as unknown as MentionKindMeta | undefined)?.kind === kind,\n\t\t\t);\n\t\t\tconst finalLabel = overrideLabel ?? item?.label ?? id;\n\t\t\teditor.insertInlineContent(\n\t\t\t\t`${buildMentionHtml(String(id), finalLabel, kind)}&nbsp;`,\n\t\t\t);\n\t\t},\n\t\t[mentionItems],\n\t);\n\n\tuseEffect(() => {\n\t\tif (!registerInsert) {\n\t\t\treturn;\n\t\t}\n\t\tregisterInsert(insert);\n\t\treturn () => registerInsert(null);\n\t}, [registerInsert, insert]);\n\n\t// Mount-only initial HTML; recomputed (editor remounted via key) on resetKey.\n\tconst initialHtml = useMemo(\n\t\t() => instructionsToEditorHtml(value, mentionItems),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\tuseEffect(\n\t\t() => setCount(value.length),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\treturn (\n\t\t<FieldBlock>\n\t\t\t<FieldLabelRow>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t{count}/{maxLength}\n\t\t\t\t</BodyCaption>\n\t\t\t</FieldLabelRow>\n\n\t\t\t<AiTextAreaShell minHeight={minHeight} data-test={rest['data-test']}>\n\t\t\t\t<BikEditor\n\t\t\t\t\tkey={resetKey}\n\t\t\t\t\tref={editorRef}\n\t\t\t\t\tinitialContent={initialHtml}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\tmaxCharacters={maxLength}\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\tmaxHeight=\"320px\"\n\t\t\t\t\tstyle={{ border: 'none' }}\n\t\t\t\t\teditorStyle={AGENT_EDITOR_STYLE}\n\t\t\t\t\tonFocus={onFocus}\n\t\t\t\t\tmentions={{\n\t\t\t\t\t\tagents: mentionItems,\n\t\t\t\t\t\tremoveTriggerOnDismiss: true,\n\t\t\t\t\t\trenderDropdown: (props) => (\n\t\t\t\t\t\t\t<MentionPicker\n\t\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\t\tonCreateSubAgent={onCreateSubAgent}\n\t\t\t\t\t\t\t\ttoolActions={toolActions}\n\t\t\t\t\t\t\t\tintegrationStatus={integrationStatus}\n\t\t\t\t\t\t\t\tonConnectIntegration={onConnectIntegration}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t),\n\t\t\t\t\t\tonSelect: (item) => {\n\t\t\t\t\t\t\tconst kind = (item.meta as unknown as MentionKindMeta | undefined)\n\t\t\t\t\t\t\t\t?.kind;\n\t\t\t\t\t\t\tif (kind) {\n\t\t\t\t\t\t\t\tonMentionSelect?.(kind, String(item.id));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonChange={(snapshot) => {\n\t\t\t\t\t\tsetCount(snapshot.characterCount);\n\t\t\t\t\t\tconst doc = editorRef.current?.getJSON() ?? null;\n\t\t\t\t\t\tonChange(editorDocToInstructions(doc, tools));\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t{action}\n\t\t\t</AiTextAreaShell>\n\t\t</FieldBlock>\n\t);\n};\n"],"names":["MentionEditor","label","value","onChange","maxLength","placeholder","minHeight","resetKey","mentionItems","tools","onMentionSelect","onFocus","registerInsert","onCreateSubAgent","toolActions","integrationStatus","onConnectIntegration","action","rest","editorRef","useRef","count","setCount","useState","insert","useCallback","kind","id","overrideLabel","editor","item","m","finalLabel","buildMentionHtml","useEffect","initialHtml","useMemo","instructionsToEditorHtml","FieldBlock","jsxs","FieldLabelRow","jsx","TitleSmall","COLORS","BodyCaption","AiTextAreaShell","BikEditor","AGENT_EDITOR_STYLE","props","MentionPicker","snapshot","doc","editorDocToInstructions"],"mappings":"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"}
1
+ {"version":3,"file":"MentionEditor.js","sources":["../../../../../src/components/agent-builder/components/MentionEditor.tsx"],"sourcesContent":["import { BikEditor, BikEditorRef, MentionItem } from '@src/editor';\nimport React, {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { AgentTool } from '../AgentBuilder.model';\nimport {\n\tAiTextAreaShell,\n\tFieldBlock,\n\tFieldLabelRow,\n} from '../AgentBuilder.styled';\nimport { AGENT_EDITOR_STYLE } from '../constants/editorStyle';\nimport type { ToolAction, ToolSource } from '../constants/tools';\nimport {\n\tbuildMentionHtml,\n\teditorDocToInstructions,\n\tinstructionsToEditorHtml,\n\tMentionKindMeta,\n} from '../utils/mentionSerialization';\nimport { MentionPicker } from './MentionPicker';\n\ntype InsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;\n\ninterface MentionEditorProps {\n\tlabel: string;\n\tvalue: string;\n\tonChange: (text: string) => void;\n\tmaxLength: number;\n\tplaceholder?: string;\n\tminHeight?: string;\n\t/** Changing this remounts the editor with fresh content. */\n\tresetKey?: string | number;\n\t/** Items shown in the `@` picker (tools, and sub-agents where allowed). */\n\tmentionItems: MentionItem[];\n\t/** Tools used to serialise mention nodes back to `{{tool:KEY}}`. */\n\ttools: AgentTool[];\n\t/** Called when an item is picked from the `@` menu (to attach it upstream). */\n\tonMentionSelect?: (kind: 'tool' | 'subagent', id: string) => void;\n\tonFocus?: () => void;\n\t/** Receives an insert-at-cursor fn (and null on unmount) for side-panel adds. */\n\tregisterInsert?: (fn: InsertFn | null) => void;\n\t/**\n\t * When set, the `@` picker's Sub-agent view shows a \"Create new\" row that calls\n\t * this (opens the create-sub-agent drawer). Omit to hide it (e.g. the drawer's\n\t * own editors, which can't nest sub-agents).\n\t */\n\tonCreateSubAgent?: () => void;\n\t/**\n\t * Built-in tool actions (Rest API / Handover to email) shown in the `@` picker's\n\t * Tools view. Picking one opens its drawer instead of inserting a mention.\n\t */\n\ttoolActions?: ToolAction[];\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\tonConnectIntegration?: (source: ToolSource) => void;\n\t/** Optional action(s) rendered inside the shell, below the editor. */\n\taction?: React.ReactNode;\n\t'data-test'?: string;\n}\n\n/**\n * Presentational BikEditor field with `@` mentions. Stores firebase token text\n * (`{{tool:KEY}}` / `{{subagent:ID}}`). Context-free — both the builder's\n * Step-3 fields and the create-sub-agent drawer compose it.\n */\nexport const MentionEditor: React.FC<MentionEditorProps> = ({\n\tlabel,\n\tvalue,\n\tonChange,\n\tmaxLength,\n\tplaceholder,\n\tminHeight = '200px',\n\tresetKey,\n\tmentionItems,\n\ttools,\n\tonMentionSelect,\n\tonFocus,\n\tregisterInsert,\n\tonCreateSubAgent,\n\ttoolActions,\n\tintegrationStatus,\n\tonConnectIntegration,\n\taction,\n\t...rest\n}) => {\n\tconst editorRef = useRef<BikEditorRef>(null);\n\tconst [count, setCount] = useState(value.length);\n\n\tconst insert = useCallback<InsertFn>(\n\t\t(kind, id, overrideLabel) => {\n\t\t\tconst editor = editorRef.current;\n\t\t\tif (!editor) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst item = mentionItems.find(\n\t\t\t\t(m) =>\n\t\t\t\t\tString(m.id) === String(id) &&\n\t\t\t\t\t(m.meta as unknown as MentionKindMeta | undefined)?.kind === kind,\n\t\t\t);\n\t\t\tconst finalLabel = overrideLabel ?? item?.label ?? id;\n\t\t\teditor.insertInlineContent(\n\t\t\t\t`${buildMentionHtml(String(id), finalLabel, kind)}&nbsp;`,\n\t\t\t);\n\t\t},\n\t\t[mentionItems],\n\t);\n\n\tuseEffect(() => {\n\t\tif (!registerInsert) {\n\t\t\treturn;\n\t\t}\n\t\tregisterInsert(insert);\n\t\treturn () => registerInsert(null);\n\t}, [registerInsert, insert]);\n\n\t// Mount-only initial HTML; recomputed (editor remounted via key) on resetKey.\n\tconst initialHtml = useMemo(\n\t\t() => instructionsToEditorHtml(value, mentionItems),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\tuseEffect(\n\t\t() => setCount(value.length),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\treturn (\n\t\t<FieldBlock>\n\t\t\t<FieldLabelRow>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t{count}/{maxLength}\n\t\t\t\t</BodyCaption>\n\t\t\t</FieldLabelRow>\n\n\t\t\t<AiTextAreaShell minHeight={minHeight} data-test={rest['data-test']}>\n\t\t\t\t<BikEditor\n\t\t\t\t\tkey={resetKey}\n\t\t\t\t\tref={editorRef}\n\t\t\t\t\tinitialContent={initialHtml}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t// Soft limit: blocks typing past the cap but lets a paste through\n\t\t\t\t\t// (overflow rendered grey) instead of rejecting the whole paste.\n\t\t\t\t\tcharacterLimit={maxLength}\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\tmaxHeight=\"320px\"\n\t\t\t\t\tstyle={{ border: 'none' }}\n\t\t\t\t\teditorStyle={AGENT_EDITOR_STYLE}\n\t\t\t\t\tonFocus={onFocus}\n\t\t\t\t\tmentions={{\n\t\t\t\t\t\tagents: mentionItems,\n\t\t\t\t\t\tremoveTriggerOnDismiss: true,\n\t\t\t\t\t\trenderDropdown: (props) => (\n\t\t\t\t\t\t\t<MentionPicker\n\t\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\t\tonCreateSubAgent={onCreateSubAgent}\n\t\t\t\t\t\t\t\ttoolActions={toolActions}\n\t\t\t\t\t\t\t\tintegrationStatus={integrationStatus}\n\t\t\t\t\t\t\t\tonConnectIntegration={onConnectIntegration}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t),\n\t\t\t\t\t\tonSelect: (item) => {\n\t\t\t\t\t\t\tconst kind = (item.meta as unknown as MentionKindMeta | undefined)\n\t\t\t\t\t\t\t\t?.kind;\n\t\t\t\t\t\t\tif (kind) {\n\t\t\t\t\t\t\t\tonMentionSelect?.(kind, String(item.id));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonChange={(snapshot) => {\n\t\t\t\t\t\tsetCount(snapshot.characterCount);\n\t\t\t\t\t\tconst doc = editorRef.current?.getJSON() ?? null;\n\t\t\t\t\t\tonChange(editorDocToInstructions(doc, tools));\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t{action}\n\t\t\t</AiTextAreaShell>\n\t\t</FieldBlock>\n\t);\n};\n"],"names":["MentionEditor","label","value","onChange","maxLength","placeholder","minHeight","resetKey","mentionItems","tools","onMentionSelect","onFocus","registerInsert","onCreateSubAgent","toolActions","integrationStatus","onConnectIntegration","action","rest","editorRef","useRef","count","setCount","useState","insert","useCallback","kind","id","overrideLabel","editor","item","m","finalLabel","buildMentionHtml","useEffect","initialHtml","useMemo","instructionsToEditorHtml","FieldBlock","jsxs","FieldLabelRow","jsx","TitleSmall","COLORS","BodyCaption","AiTextAreaShell","BikEditor","AGENT_EDITOR_STYLE","props","MentionPicker","snapshot","doc","editorDocToInstructions"],"mappings":"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"}
@@ -1,256 +1,286 @@
1
- import { jsxs as m, jsx as u, Fragment as W } from "react/jsx-runtime";
2
- import X from "../../../assets/icons/chevronRight.svg.js";
3
- import Y from "../../../assets/icons/searchIcon.svg.js";
4
- import Z from "../../../icons/Arrows/Normal arrows/ArrowLeft.js";
5
- import { useState as A, useMemo as x, useEffect as P, useRef as K } from "react";
1
+ import { jsxs as m, jsx as u, Fragment as Z } from "react/jsx-runtime";
2
+ import K from "../../../assets/icons/chevronRight.svg.js";
3
+ import H from "../../../assets/icons/searchIcon.svg.js";
4
+ import ee from "../../../icons/Arrows/Normal arrows/ArrowLeft.js";
5
+ import { useState as B, useMemo as x, useEffect as z, useRef as te } from "react";
6
6
  import p from "styled-components";
7
- import { TitleSmall as H, BodySecondary as ee } from "../../TypographyStyle.js";
8
- import { COLORS as o } from "../../../constants/Theme.js";
9
- import { CATEGORIES as te, toolSourceRank as F, CONFIG_TOOL_SOURCES as ne } from "../constants/tools.js";
10
- import { toolSourceLabel as D } from "../utils/mentionSerialization.js";
11
- import { sourceIcon as z, renderSourceIcon as G } from "../utils/sourceIcons.js";
12
- const y = (a) => a.meta, L = (a) => y(a)?.plainLabel ?? a.label, re = "__bik_create_subagent__", Se = ({
13
- items: a,
14
- onSelect: R,
15
- registerKeyHandler: w,
16
- onClose: I,
17
- onCreateSubAgent: k,
18
- initialSource: q,
19
- toolActions: h,
20
- integrationStatus: M,
21
- onConnectIntegration: N
7
+ import { TitleSmall as ne, BodySecondary as re } from "../../TypographyStyle.js";
8
+ import { COLORS as i } from "../../../constants/Theme.js";
9
+ import { CATEGORIES as oe, toolSourceRank as Q, CONFIG_TOOL_SOURCES as ie } from "../constants/tools.js";
10
+ import { toolSourceLabel as N } from "../utils/mentionSerialization.js";
11
+ import { sourceIcon as E, renderSourceIcon as V } from "../utils/sourceIcons.js";
12
+ const k = (l) => l.meta, I = (l) => k(l)?.plainLabel ?? l.label, le = "__bik_create_subagent__", Le = ({
13
+ items: l,
14
+ onSelect: S,
15
+ registerKeyHandler: C,
16
+ onClose: v,
17
+ onCreateSubAgent: y,
18
+ initialSource: U,
19
+ toolActions: b,
20
+ integrationStatus: j,
21
+ onConnectIntegration: F
22
22
  }) => {
23
- const [J, B] = A(null), [c, E] = A(q ?? null), [C, g] = A(0), [v, U] = A(""), b = x(
24
- () => a.filter((e) => y(e)?.kind === "tool"),
25
- [a]
26
- ), S = x(
27
- () => a.filter((e) => y(e)?.kind === "subagent"),
28
- [a]
29
- ), _ = x(() => {
23
+ const [W, _] = B(null), [c, O] = B(U ?? null), [A, h] = B(-1), [w, G] = B(""), g = x(
24
+ () => l.filter((e) => k(e)?.kind === "tool"),
25
+ [l]
26
+ ), $ = x(
27
+ () => l.filter((e) => k(e)?.kind === "subagent"),
28
+ [l]
29
+ ), T = x(() => {
30
30
  const e = [];
31
- return b.forEach((r) => {
32
- const f = y(r)?.source ?? "other";
31
+ return g.forEach((r) => {
32
+ const f = k(r)?.source ?? "other";
33
33
  e.includes(f) || e.push(f);
34
34
  }), e;
35
- }, [b]), O = x(
35
+ }, [g]), P = x(
36
36
  () => new Map(
37
- (h ?? []).map((e) => [e.source, e])
37
+ (b ?? []).map((e) => [e.source, e])
38
38
  ),
39
- [h]
40
- ), $ = x(
41
- () => te.filter(
42
- (e) => e.key === "tool" ? b.length > 0 || (h?.length ?? 0) > 0 : S.length > 0 || !!k
39
+ [b]
40
+ ), L = x(
41
+ () => oe.filter(
42
+ (e) => e.key === "tool" ? g.length > 0 || (b?.length ?? 0) > 0 : $.length > 0 || !!y
43
43
  ),
44
- [b.length, S.length, k, h?.length]
45
- ), T = $.length === 1 ? $[0].key : null, l = J ?? T, d = l ? l === "subagent" ? (
44
+ [g.length, $.length, y, b?.length]
45
+ ), D = L.length === 1 ? L[0].key : null, s = W ?? D, d = s ? s === "subagent" ? (
46
46
  // Always titled — with a back arrow only when the category chooser is above.
47
47
  {
48
48
  title: "Sub-agent",
49
- onBack: T ? void 0 : () => B(null)
49
+ onBack: D ? void 0 : () => _(null)
50
50
  }
51
51
  ) : c ? {
52
- title: D(c),
53
- onBack: () => E(null),
54
- icon: z(c)
52
+ title: N(c),
53
+ // Deep-linked to a source (opened from a right-panel source button):
54
+ // that source IS the root, so no back arrow. In the @-drill flow
55
+ // (no initialSource) back returns to the source chooser.
56
+ onBack: U ? void 0 : () => O(null),
57
+ icon: E(c)
55
58
  } : (
56
59
  // Always titled — matches the Sub-agent header; back arrow only when the
57
60
  // category chooser is above (i.e. not the sole category).
58
61
  {
59
62
  title: "Tools",
60
- onBack: T ? void 0 : () => B(null)
63
+ onBack: D ? void 0 : () => _(null)
61
64
  }
62
- ) : null, s = x(() => {
63
- if (!l)
64
- return $.map((n) => ({
65
+ ) : null, a = x(() => {
66
+ if (!s)
67
+ return L.map((n) => ({
65
68
  id: n.key,
66
69
  label: n.label,
67
70
  drillsIn: !0,
68
71
  onActivate: () => {
69
- B(n.key), E(null);
72
+ _(n.key), O(null);
70
73
  }
71
74
  }));
72
- if (l === "subagent") {
73
- const n = v.trim().toLowerCase(), t = S.filter((i) => !n || L(i).toLowerCase().includes(n)).map((i) => ({
74
- id: String(i.id),
75
- label: L(i),
75
+ if (s === "subagent") {
76
+ const n = w.trim().toLowerCase(), t = $.filter((o) => !n || I(o).toLowerCase().includes(n)).map((o) => ({
77
+ id: String(o.id),
78
+ label: I(o),
76
79
  drillsIn: !1,
77
- onActivate: () => R(i)
80
+ onActivate: () => S(o)
78
81
  }));
79
- return k && t.push({
80
- id: re,
82
+ return y && t.push({
83
+ id: le,
81
84
  label: "Create new",
82
85
  drillsIn: !1,
83
86
  isCreate: !0,
84
87
  onActivate: () => {
85
- I?.(), k();
88
+ v?.(), y();
86
89
  }
87
90
  }), t;
88
91
  }
89
92
  if (!c) {
90
- const n = (h ?? []).map((t) => t.source).filter((t) => !_.includes(t));
91
- return [..._, ...n].sort((t, i) => F(t) - F(i)).map((t) => {
92
- const i = O.get(t);
93
- return (i !== void 0 ? i.connected : M?.[t]) === !1 ? {
94
- id: t,
95
- label: D(t),
96
- drillsIn: !1,
97
- icon: z(t) ?? i?.icon,
98
- rightLabel: "Connect",
99
- onActivate: () => {
100
- I?.(), i?.onConnect ? i.onConnect() : N?.(t);
101
- }
102
- } : {
93
+ const n = (b ?? []).map((t) => t.source).filter((t) => !T.includes(t));
94
+ return [...T, ...n].sort((t, o) => Q(t) - Q(o)).map((t) => {
95
+ const o = P.get(t);
96
+ if ((o !== void 0 ? o.connected : j?.[t]) === !1)
97
+ return {
98
+ id: t,
99
+ label: N(t),
100
+ drillsIn: !1,
101
+ icon: E(t) ?? o?.icon,
102
+ rightLabel: "Connect",
103
+ onActivate: () => {
104
+ v?.(), o?.onConnect ? o.onConnect() : F?.(t);
105
+ }
106
+ };
107
+ const J = g.filter(
108
+ (R) => (k(R)?.source ?? "other") === t
109
+ );
110
+ if (J.length + (o ? 1 : 0) === 1) {
111
+ const R = E(t) ?? o?.icon;
112
+ if (o)
113
+ return {
114
+ id: t,
115
+ label: o.label,
116
+ drillsIn: !1,
117
+ icon: R,
118
+ onActivate: () => {
119
+ v?.(), o.onSelect();
120
+ }
121
+ };
122
+ const M = J[0];
123
+ return {
124
+ id: String(M.id),
125
+ label: I(M),
126
+ drillsIn: !1,
127
+ icon: R,
128
+ onActivate: () => S(M)
129
+ };
130
+ }
131
+ return {
103
132
  id: t,
104
- label: D(t),
133
+ label: N(t),
105
134
  drillsIn: !0,
106
- icon: z(t) ?? i?.icon,
107
- onActivate: () => E(t)
135
+ icon: E(t) ?? o?.icon,
136
+ onActivate: () => O(t)
108
137
  };
109
138
  });
110
139
  }
111
- const e = v.trim().toLowerCase(), r = b.filter((n) => (y(n)?.source ?? "other") === c).filter((n) => !e || L(n).toLowerCase().includes(e)).map((n) => ({
140
+ const e = w.trim().toLowerCase(), r = g.filter((n) => (k(n)?.source ?? "other") === c).filter((n) => !e || I(n).toLowerCase().includes(e)).map((n) => ({
112
141
  id: String(n.id),
113
- label: L(n),
142
+ label: I(n),
114
143
  drillsIn: !1,
115
- onActivate: () => R(n)
116
- })), f = O.get(c);
144
+ onActivate: () => S(n)
145
+ })), f = P.get(c);
117
146
  if (f) {
118
- const n = c in ne;
147
+ const n = c in ie;
119
148
  r.push({
120
149
  id: `create:${c}`,
121
150
  label: f.label,
122
151
  drillsIn: !1,
123
152
  isCreate: !n,
124
153
  onActivate: () => {
125
- I?.(), f.onSelect();
154
+ v?.(), f.onSelect();
126
155
  }
127
156
  });
128
157
  }
129
158
  return r;
130
159
  }, [
131
- l,
132
- $,
160
+ s,
161
+ L,
133
162
  c,
163
+ w,
164
+ g,
165
+ $,
166
+ T,
167
+ S,
134
168
  v,
169
+ y,
135
170
  b,
136
- S,
137
- _,
138
- R,
139
- I,
140
- k,
141
- h,
142
- O,
143
- M,
144
- N
171
+ P,
172
+ j,
173
+ F
145
174
  ]);
146
- P(() => g(0), [l, c, v, a]), P(() => U(""), [l, c]);
147
- const j = K({ rows: s, activeIndex: C, header: d });
148
- j.current = { rows: s, activeIndex: C, header: d }, P(() => {
149
- if (w)
150
- return w((e) => {
151
- const { rows: r, activeIndex: f, header: n } = j.current;
175
+ z(() => h(-1), [s, c, w, l]), z(() => G(""), [s, c]);
176
+ const q = te({ rows: a, activeIndex: A, header: d });
177
+ q.current = { rows: a, activeIndex: A, header: d }, z(() => {
178
+ if (C)
179
+ return C((e) => {
180
+ const { rows: r, activeIndex: f, header: n } = q.current;
152
181
  switch (e.key) {
153
182
  case "ArrowDown":
154
- return r.length && g((t) => (t + 1) % r.length), !0;
183
+ return r.length && h((t) => (t + 1) % r.length), !0;
155
184
  case "ArrowUp":
156
- return r.length && g((t) => (t + r.length - 1) % r.length), !0;
185
+ return r.length && h((t) => (t + r.length - 1) % r.length), !0;
157
186
  case "ArrowRight":
158
187
  case "Enter":
159
- return r[f]?.onActivate(), !0;
188
+ return (r[f] ?? r[0])?.onActivate(), !0;
160
189
  case "ArrowLeft":
161
190
  return n?.onBack ? (n.onBack(), !0) : !1;
162
191
  default:
163
192
  return !1;
164
193
  }
165
- }), () => w(null);
166
- }, [w]);
167
- const Q = l ? s.length && !s[0].drillsIn ? "items" : "sources" : "categories", V = l === "tool" && !!c || l === "subagent";
168
- return /* @__PURE__ */ m(oe, { className: `bik-mention-picker bik-mention-picker--${Q}`, children: [
194
+ }), () => C(null);
195
+ }, [C]);
196
+ const X = s ? a.length && !a[0].drillsIn ? "items" : "sources" : "categories", Y = s === "tool" && !!c || s === "subagent";
197
+ return /* @__PURE__ */ m(ce, { className: `bik-mention-picker bik-mention-picker--${X}`, children: [
169
198
  d && /* @__PURE__ */ m(
170
- ue,
199
+ he,
171
200
  {
172
201
  type: "button",
173
202
  onClick: d.onBack,
174
203
  disabled: !d.onBack,
175
204
  style: {
176
- background: o.surface.subdued,
205
+ background: i.surface.subdued,
177
206
  cursor: d.onBack ? "pointer" : "default"
178
207
  },
179
208
  children: [
180
209
  d.onBack && /* @__PURE__ */ u(
181
- Z,
210
+ ee,
182
211
  {
183
212
  width: 20,
184
213
  height: 20,
185
- color: o.content.primary
214
+ color: i.content.primary
186
215
  }
187
216
  ),
188
- d.icon && G(d.icon),
189
- /* @__PURE__ */ m(H, { children: [
217
+ d.icon && V(d.icon),
218
+ /* @__PURE__ */ m(ne, { children: [
190
219
  " ",
191
220
  d.title
192
221
  ] })
193
222
  ]
194
223
  }
195
224
  ),
196
- V && /* @__PURE__ */ m(ie, { children: [
225
+ Y && /* @__PURE__ */ m(ae, { children: [
197
226
  /* @__PURE__ */ u(
198
- Y,
227
+ H,
199
228
  {
200
229
  width: 20,
201
230
  height: 20,
202
- color: o.content.placeholder
231
+ color: i.content.placeholder
203
232
  }
204
233
  ),
205
234
  /* @__PURE__ */ u(
206
- ae,
235
+ se,
207
236
  {
208
237
  autoFocus: !0,
209
- value: v,
238
+ value: w,
210
239
  placeholder: "Search",
211
240
  "data-test": "mention-picker-search",
212
- onChange: (e) => U(e.target.value),
241
+ onChange: (e) => G(e.target.value),
213
242
  onKeyDown: (e) => {
214
- s.length && (e.key === "ArrowDown" ? (e.preventDefault(), g((r) => (r + 1) % s.length)) : e.key === "ArrowUp" ? (e.preventDefault(), g((r) => (r + s.length - 1) % s.length)) : e.key === "Enter" && (e.preventDefault(), s[C]?.onActivate()));
243
+ a.length && (e.key === "ArrowDown" ? (e.preventDefault(), h((r) => (r + 1) % a.length)) : e.key === "ArrowUp" ? (e.preventDefault(), h((r) => (r + a.length - 1) % a.length)) : e.key === "Enter" && (e.preventDefault(), (a[A] ?? a[0])?.onActivate()));
215
244
  }
216
245
  }
217
246
  )
218
247
  ] }),
219
- s.length === 0 ? /* @__PURE__ */ u(pe, { children: l === "subagent" ? "No sub-agents available" : "No tools available" }) : s.map((e, r) => /* @__PURE__ */ u(
220
- ce,
248
+ a.length === 0 ? /* @__PURE__ */ u(ge, { children: s === "subagent" ? null : "No tools available" }) : a.map((e, r) => /* @__PURE__ */ u(
249
+ de,
221
250
  {
222
251
  type: "button",
223
- $active: r === C,
224
- onMouseEnter: () => g(r),
252
+ $active: r === A,
253
+ onMouseEnter: () => h(r),
254
+ onMouseLeave: () => h(-1),
225
255
  onClick: e.onActivate,
226
- children: e.isCreate ? /* @__PURE__ */ u(de, { children: e.label }) : /* @__PURE__ */ m(W, { children: [
227
- /* @__PURE__ */ m(le, { children: [
228
- G(e.icon),
229
- /* @__PURE__ */ u(ee, { color: o.content.primary, children: e.label })
256
+ children: e.isCreate ? /* @__PURE__ */ u(fe, { children: e.label }) : /* @__PURE__ */ m(Z, { children: [
257
+ /* @__PURE__ */ m(ue, { children: [
258
+ V(e.icon),
259
+ /* @__PURE__ */ u(re, { color: i.content.primary, children: e.label })
230
260
  ] }),
231
- e.rightLabel ? /* @__PURE__ */ u(se, { children: e.rightLabel }) : e.drillsIn && /* @__PURE__ */ u(X, { width: 12, height: 12 })
261
+ e.rightLabel ? /* @__PURE__ */ u(pe, { children: e.rightLabel }) : e.drillsIn && /* @__PURE__ */ u(K, { width: 12, height: 12 })
232
262
  ] })
233
263
  },
234
264
  e.id
235
265
  ))
236
266
  ] });
237
- }, oe = p.div`
267
+ }, ce = p.div`
238
268
  display: flex;
239
269
  flex-direction: column;
240
270
  min-width: 240px;
241
271
  max-height: 301px;
242
272
  overflow-y: auto;
243
- background: ${o.surface.standard};
244
- border: 1px solid ${o.stroke.primary};
273
+ background: ${i.surface.standard};
274
+ border: 1px solid ${i.stroke.primary};
245
275
  border-radius: 4px;
246
276
  box-shadow: 0px -2px 8px 0px #0000001f;
247
- `, ie = p.div`
277
+ `, ae = p.div`
248
278
  display: flex;
249
279
  align-items: center;
250
280
  gap: 8px;
251
281
  padding: 10px 12px;
252
- border-bottom: 1px solid ${o.stroke.primary};
253
- `, ae = p.input`
282
+ border-bottom: 1px solid ${i.stroke.primary};
283
+ `, se = p.input`
254
284
  flex: 1;
255
285
  min-width: 0;
256
286
  border: none;
@@ -258,12 +288,12 @@ const y = (a) => a.meta, L = (a) => y(a)?.plainLabel ?? a.label, re = "__bik_cre
258
288
  background: transparent;
259
289
  font-family: Inter;
260
290
  font-size: 14px;
261
- color: ${o.content.primary};
291
+ color: ${i.content.primary};
262
292
 
263
293
  &::placeholder {
264
- color: ${o.content.placeholder};
294
+ color: ${i.content.placeholder};
265
295
  }
266
- `, ce = p.button`
296
+ `, de = p.button`
267
297
  display: flex;
268
298
  justify-content: space-between;
269
299
  align-items: center;
@@ -272,39 +302,39 @@ const y = (a) => a.meta, L = (a) => y(a)?.plainLabel ?? a.label, re = "__bik_cre
272
302
  padding: 8px 10px;
273
303
  height: 48px;
274
304
  border: none;
275
- border-bottom: 1px solid ${o.stroke.primary};
276
- background: ${(a) => a.$active ? o.surface.subdued : "transparent"};
305
+ border-bottom: 1px solid ${i.stroke.primary};
306
+ background: ${(l) => l.$active ? i.surface.subdued : "transparent"};
277
307
  cursor: pointer;
278
308
  text-align: left;
279
309
 
280
310
  &:hover {
281
- background: ${o.surface.subdued};
311
+ background: ${i.surface.hovered};
282
312
  }
283
- `, le = p.div`
313
+ `, ue = p.div`
284
314
  display: flex;
285
315
  align-items: center;
286
316
  gap: 12px;
287
317
  min-width: 0;
288
- `, se = p.span`
318
+ `, pe = p.span`
289
319
  flex-shrink: 0;
290
- color: ${o.content.brand};
320
+ color: ${i.content.brand};
291
321
  font-family: Inter;
292
322
  font-size: 14px;
293
323
  font-weight: 600;
294
324
  white-space: nowrap;
295
- `, de = p.div`
325
+ `, fe = p.div`
296
326
  width: 100%;
297
327
  text-align: center;
298
- color: ${o.content.brand};
328
+ color: ${i.content.brand};
299
329
  font-family: Inter;
300
330
  font-size: 14px;
301
331
  font-weight: 600;
302
- `, ue = p.button`
332
+ `, he = p.button`
303
333
  display: flex;
304
334
  align-items: center;
305
335
  padding: 12px 16px;
306
336
  border: none;
307
- border-bottom: 1px solid ${o.stroke.primary};
337
+ border-bottom: 1px solid ${i.stroke.primary};
308
338
  background: transparent;
309
339
  cursor: pointer;
310
340
  font-family: Inter;
@@ -312,13 +342,13 @@ const y = (a) => a.meta, L = (a) => y(a)?.plainLabel ?? a.label, re = "__bik_cre
312
342
  font-weight: 600;
313
343
  height: 48px;
314
344
  gap: 4px;
315
- `, pe = p.div`
345
+ `, ge = p.div`
316
346
  padding: 12px 10px;
317
347
  font-family: Inter;
318
348
  font-size: 13px;
319
- color: ${o.content.secondary};
349
+ color: ${i.content.secondary};
320
350
  `;
321
351
  export {
322
- Se as MentionPicker
352
+ Le as MentionPicker
323
353
  };
324
354
  //# sourceMappingURL=MentionPicker.js.map