@epam/ai-dial-skills 1.2.0-dev.14 → 1.2.0-dev.142

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 (36) hide show
  1. package/components/ChatSkill/ChatSkill.d.ts +3 -2
  2. package/components/ChatSkill/ChatSkill.d.ts.map +1 -1
  3. package/components/FavoriteSkillsPanel/FavoriteSkillsPanel.d.ts.map +1 -1
  4. package/components/SkillArchiveUploadDialog/SkillArchiveUploadDialog.d.ts +9 -0
  5. package/components/SkillArchiveUploadDialog/SkillArchiveUploadDialog.d.ts.map +1 -0
  6. package/components/SkillInfoTooltipContent/SkillInfoTooltipContent.d.ts.map +1 -1
  7. package/components/SkillSelectorField/SkillSelectorField.d.ts +5 -0
  8. package/components/SkillSelectorField/SkillSelectorField.d.ts.map +1 -0
  9. package/constants/public-class-names.d.ts +15 -0
  10. package/constants/public-class-names.d.ts.map +1 -0
  11. package/hooks/useSkillMentions/useSkillMentions.d.ts +50 -0
  12. package/hooks/useSkillMentions/useSkillMentions.d.ts.map +1 -0
  13. package/hooks/useSkillSelectorOverlay/useSkillSelectorOverlay.d.ts +4 -3
  14. package/hooks/useSkillSelectorOverlay/useSkillSelectorOverlay.d.ts.map +1 -1
  15. package/index.css +2 -2
  16. package/index.d.ts +13 -0
  17. package/index.d.ts.map +1 -1
  18. package/index.js +507 -198
  19. package/models/favorite-skills-panel-props.d.ts +32 -5
  20. package/models/favorite-skills-panel-props.d.ts.map +1 -1
  21. package/models/skill-archive-upload-dialog-props.d.ts +33 -0
  22. package/models/skill-archive-upload-dialog-props.d.ts.map +1 -0
  23. package/models/skill-info-tooltip-content-props.d.ts +6 -0
  24. package/models/skill-info-tooltip-content-props.d.ts.map +1 -1
  25. package/models/skill-mention-anchor.d.ts +12 -0
  26. package/models/skill-mention-anchor.d.ts.map +1 -0
  27. package/models/skill-selector-field-props.d.ts +80 -0
  28. package/models/skill-selector-field-props.d.ts.map +1 -0
  29. package/models/skill-selector-overlay.d.ts +101 -55
  30. package/models/skill-selector-overlay.d.ts.map +1 -1
  31. package/package.json +5 -5
  32. package/test-setup.d.ts +1 -0
  33. package/utils/skill-mention-matching.d.ts +25 -0
  34. package/utils/skill-mention-matching.d.ts.map +1 -0
  35. package/utils/skill-mention-tracking.d.ts +39 -0
  36. package/utils/skill-mention-tracking.d.ts.map +1 -0
package/index.js CHANGED
@@ -1,171 +1,199 @@
1
- import { DeploymentIcon as e, buildCssVars as t, mergeClasses as n } from "@epam/ai-dial-chat-shared";
2
- import { BASE_ICON_SIZE as r, Button as i, ButtonAppearance as a, ButtonVariant as o, DIAL_ICON_SIZE as s, DIAL_KIT_ICON_STROKE as c, GhostButton as l, Highlight as u, InteractiveTooltip as d, Popup as f, PopupSize as p, ToggleIconButton as m, TooltipPlacement as h } from "@epam/ai-dial-ui-kit";
3
- import { Suspense as g, useCallback as _, useEffect as v, useLayoutEffect as y, useMemo as b, useRef as x, useState as S } from "react";
4
- import { IconBlocks as C, IconEye as w, IconStarFilled as T } from "@tabler/icons-react";
5
- import { jsx as E, jsxs as D } from "react/jsx-runtime";
6
- import { DetailsPanel as O } from "@epam/ai-dial-catalog";
7
- //#region src/components/SkillInfoTooltipContent/SkillInfoTooltipContent.tsx
8
- var k = ({ description: e, unsupportedMessage: t, viewDetailsLabel: n = "View details", onViewDetails: r }) => t == null ? /* @__PURE__ */ D("div", {
1
+ import { DeploymentIcon as e, buildCssVars as t, isSkillSelectionUnsupported as n, mergeClasses as r } from "@epam/ai-dial-chat-shared";
2
+ import { BASE_ICON_SIZE as i, Button as a, ButtonAppearance as o, ButtonVariant as s, DIAL_ICON_SIZE as c, DIAL_KIT_ICON_STROKE as l, Dropdown as u, FileDropzone as d, GhostButton as f, Highlight as p, Input as m, InteractiveTooltip as h, Popup as g, PopupSize as _, Search as v, ToggleIconButton as ee, TooltipPlacement as y } from "@epam/ai-dial-ui-kit";
3
+ import { Suspense as b, useCallback as x, useEffect as te, useId as S, useLayoutEffect as C, useMemo as w, useRef as T, useState as E } from "react";
4
+ import { IconBlocks as D, IconChevronDown as ne, IconEye as O, IconStarFilled as k, IconX as A } from "@tabler/icons-react";
5
+ import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
6
+ import { DetailsPanel as P } from "@epam/ai-dial-catalog";
7
+ //#region src/constants/public-class-names.ts
8
+ var F = {
9
+ selectorField: "dial-skills-selector-field",
10
+ favoritesPanel: "dial-skills-favorites-panel",
11
+ chip: "dial-skills-chip"
12
+ }, I = ({ description: e, unsupportedMessage: t, viewDetailsLabel: n = "View details", onViewDetails: r, viewDetailsTabIndex: i }) => t == null ? /* @__PURE__ */ N("div", {
9
13
  className: "flex flex-col gap-3",
10
- children: [e != null && e !== "" && /* @__PURE__ */ E("p", {
14
+ children: [e != null && e !== "" && /* @__PURE__ */ M("p", {
11
15
  className: "text-start",
12
16
  children: e
13
- }), /* @__PURE__ */ E(i, {
14
- variant: o.Primary,
15
- appearance: a.Link,
17
+ }), /* @__PURE__ */ M(a, {
18
+ variant: s.Primary,
19
+ appearance: o.Link,
16
20
  className: "h-[24px] self-start",
17
21
  label: n,
18
- iconBefore: /* @__PURE__ */ E(w, {
19
- size: s.SM,
20
- stroke: c,
22
+ iconBefore: /* @__PURE__ */ M(O, {
23
+ size: c.SM,
24
+ stroke: l,
21
25
  "aria-hidden": !0
22
26
  }),
23
- onClick: r
27
+ onClick: r,
28
+ tabIndex: i
24
29
  })]
25
- }) : /* @__PURE__ */ E("p", {
30
+ }) : /* @__PURE__ */ M("p", {
26
31
  className: "text-start",
27
32
  children: t
28
- }), A = ({ name: e, path: t, description: r, isUnsupported: i = !1, labelClassName: a = "dial-body-paragraph-text", unsupportedLabelClassName: o = "text-error", unsupportedClassName: s = "bg-error", onViewDetails: c, labels: u = {} }) => {
29
- let { viewDetailsLabel: f = "View details", unsupportedTooltipLabel: p = "Selected model does not support skills. Remove the skill or select different model to proceed." } = u, [m, g] = S(0);
30
- return /* @__PURE__ */ E(d, {
33
+ }), L = ({ name: e, path: t, description: n, isUnsupported: i = !1, labelClassName: a = "dial-body-paragraph-text text-accent", unsupportedLabelClassName: o = "text-error", unsupportedClassName: s = "bg-error", onViewDetails: c, labels: l = {} }) => {
34
+ let { viewDetailsLabel: u = "View details", unsupportedTooltipLabel: d = "Selected model does not support skills. Remove the skill or select different model to proceed." } = l, [f, p] = E(0), m = () => {
35
+ p((e) => e + 1), c(t);
36
+ }, g = T(null), [_, v] = E(null);
37
+ return C(() => {
38
+ v(g.current?.getBoundingClientRect().width ?? null);
39
+ }, [a]), /* @__PURE__ */ M(h, {
31
40
  asChild: !0,
32
- placement: h.Top,
41
+ placement: y.Top,
33
42
  contentClassName: "max-w-[550px]",
34
- content: i ? /* @__PURE__ */ E(k, { unsupportedMessage: p }) : /* @__PURE__ */ E(k, {
35
- description: r,
36
- viewDetailsLabel: f,
37
- onViewDetails: () => {
38
- g((e) => e + 1), c(t);
39
- }
43
+ content: i ? /* @__PURE__ */ M(I, { unsupportedMessage: d }) : /* @__PURE__ */ M(I, {
44
+ description: n,
45
+ viewDetailsLabel: u,
46
+ onViewDetails: m
40
47
  }),
41
- children: /* @__PURE__ */ E("span", {
42
- className: "inline-flex items-center",
43
- children: /* @__PURE__ */ E(l, {
44
- label: `/${e}`,
45
- textClassName: i ? n(a, o) : a,
46
- className: i ? n("h-auto px-2 py-0", s) : "h-auto px-2 py-0"
47
- })
48
+ children: /* @__PURE__ */ N("span", {
49
+ tabIndex: 0,
50
+ className: r("relative -me-1 -ms-1 inline-block cursor-pointer select-text rounded-full pe-1 ps-1", i ? s : "hover:bg-info focus-visible:bg-info active:bg-info", i ? r(a, o) : a, F.chip),
51
+ "aria-label": `/${e}`,
52
+ children: [/* @__PURE__ */ M("span", {
53
+ ref: g,
54
+ "aria-hidden": !0,
55
+ className: "inset-inline-start-0 pointer-events-none absolute top-0 select-none",
56
+ children: "/"
57
+ }), /* @__PURE__ */ M("span", {
58
+ "aria-hidden": !0,
59
+ className: "select-none",
60
+ style: { paddingInlineStart: _ ?? void 0 },
61
+ children: e
62
+ })]
48
63
  })
49
- }, m);
50
- }, j = {
51
- row: "_row_1ovug_1",
52
- header: "_header_1ovug_5",
53
- emptyHint: "_emptyHint_1ovug_9",
54
- star: "_star_1ovug_13",
55
- footer: "_footer_1ovug_17",
56
- rowEnter: "_rowEnter_1ovug_25",
57
- rowFadeIn: "_rowFadeIn_1ovug_1",
58
- rowLeaving: "_rowLeaving_1ovug_29",
59
- rowFadeOut: "_rowFadeOut_1ovug_1",
60
- listContent: "_listContent_1ovug_57"
61
- }, M = "px-3 pb-0.5 pt-2", N = 180, P = 288, F = ({ favorites: r, onSelect: i, onToggleFavorite: a, onBrowse: o, onViewDetails: c, searchQuery: f, labels: p = {}, colors: h, nameClassName: g = "dial-small-text", headerClassName: _ = "dial-tiny-lead-semi-text", emptyHintClassName: b = "dial-small-text" }) => {
62
- let { myCollectionLabel: C = "My Collection", emptyHintLabel: w = "Star a skill to pin it here", browseLabel: O = "Browse", removeFromFavoritesLabel: A = "Remove from favorites", viewDetailsLabel: F = "View details", noMatchingSkillsLabel: I = "No matching skills" } = p, L = t({
63
- "--fs-row-hover-bg": h?.rowHoverBackground,
64
- "--fs-header-text": h?.headerText,
65
- "--fs-empty-hint-text": h?.emptyHintText,
66
- "--fs-star-color": h?.starColor,
67
- "--fs-footer-border": h?.footerBorder
68
- }), [R, z] = S(/* @__PURE__ */ new Set()), B = x(/* @__PURE__ */ new Map());
69
- v(() => {
70
- let e = B.current;
64
+ }, f);
65
+ }, R = {
66
+ row: "_row_1v431_1",
67
+ header: "_header_1v431_8",
68
+ emptyHint: "_emptyHint_1v431_12",
69
+ star: "_star_1v431_16",
70
+ footer: "_footer_1v431_20",
71
+ rowEnter: "_rowEnter_1v431_28",
72
+ rowFadeIn: "_rowFadeIn_1v431_1",
73
+ rowLeaving: "_rowLeaving_1v431_32",
74
+ rowFadeOut: "_rowFadeOut_1v431_1",
75
+ listContent: "_listContent_1v431_60"
76
+ }, z = "px-3 pb-0.5 pt-2", B = 180, V = 288, H = ({ favorites: n, onSelect: i, onToggleFavorite: a, onBrowse: o, onViewDetails: s, className: l, rowClassName: u, searchQuery: d, listboxId: m, activeOptionId: g, isMenu: _ = !1, labels: v = {}, colors: y, nameClassName: b = "dial-small-text", headerClassName: x = "dial-tiny-lead-semi-text", emptyHintClassName: w = "dial-small-text" }) => {
77
+ let { myCollectionLabel: D = "My Collection", emptyHintLabel: ne = "Star a skill to pin it here", browseLabel: O = "Browse", removeFromFavoritesLabel: A = "Remove from favorites", viewDetailsLabel: j = "View details", noMatchingSkillsLabel: P = "No matching skills" } = v, L = t({
78
+ "--fs-row-hover-bg": y?.rowHoverBackground,
79
+ "--fs-header-text": y?.headerText,
80
+ "--fs-empty-hint-text": y?.emptyHintText,
81
+ "--fs-star-color": y?.starColor,
82
+ "--fs-footer-border": y?.footerBorder
83
+ }), [H, U] = E(/* @__PURE__ */ new Set()), W = T(/* @__PURE__ */ new Map());
84
+ te(() => {
85
+ let e = W.current;
71
86
  return () => {
72
87
  e.forEach((e) => clearTimeout(e)), e.clear();
73
88
  };
74
89
  }, []);
75
- let V = f != null, H = f?.toLowerCase() ?? "", U = V ? r.filter((e) => e.name.toLowerCase().includes(H)) : r, W = x(null), [G, K] = S();
76
- y(() => {
77
- W.current && K(Math.min(W.current.scrollHeight, P));
78
- }, [r, f]);
79
- let q = (e, t) => {
90
+ let G = m != null, K = _ && !G, q = G || K ? "none" : void 0, J = "button";
91
+ G ? J = "option" : K && (J = "menuitem");
92
+ let Y = S(), X = d != null, Z = d?.toLowerCase() ?? "", Q = X ? n.filter((e) => e.name.toLowerCase().includes(Z)) : n, re = T(null), [ie, ae] = E();
93
+ C(() => {
94
+ re.current && ae(Math.min(re.current.scrollHeight, V));
95
+ }, [n, d]);
96
+ let oe = (e, t) => {
80
97
  e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), i(t));
81
- }, J = (e) => {
82
- z((t) => new Set(t).add(e));
98
+ }, $ = (e) => {
99
+ U((t) => new Set(t).add(e));
83
100
  let t = setTimeout(() => {
84
- a(e), z((t) => {
101
+ a?.(e), U((t) => {
85
102
  let n = new Set(t);
86
103
  return n.delete(e), n;
87
- }), B.current.delete(e);
88
- }, N);
89
- B.current.set(e, t);
104
+ }), W.current.delete(e);
105
+ }, B);
106
+ W.current.set(e, t);
90
107
  };
91
- return /* @__PURE__ */ D("div", {
92
- className: "flex w-full flex-col desktop:w-[280px]",
108
+ return /* @__PURE__ */ N("div", {
109
+ className: r("flex w-full flex-col desktop:w-[280px]", l, F.favoritesPanel),
93
110
  style: L,
94
111
  children: [
95
- /* @__PURE__ */ E("p", {
96
- className: n(_, M, j.header),
97
- children: C
112
+ /* @__PURE__ */ M("p", {
113
+ id: Y,
114
+ className: r(x, z, R.header),
115
+ children: D
98
116
  }),
99
- /* @__PURE__ */ E("div", {
100
- className: n("max-h-72 min-h-0 flex-1 overflow-y-auto", j.listContent),
101
- style: { maxHeight: G },
102
- children: /* @__PURE__ */ E("div", {
103
- ref: W,
104
- children: U.length > 0 ? /* @__PURE__ */ E("ul", {
117
+ /* @__PURE__ */ M("div", {
118
+ className: r("max-h-72 min-h-0 flex-1 overflow-y-auto", R.listContent),
119
+ style: { maxHeight: ie },
120
+ children: /* @__PURE__ */ M("div", {
121
+ ref: re,
122
+ children: Q.length > 0 ? /* @__PURE__ */ M("ul", {
123
+ id: m,
124
+ role: G ? "listbox" : q,
125
+ "aria-labelledby": G ? Y : void 0,
105
126
  className: "flex flex-col gap-1 px-1 pb-1",
106
- children: U.map((t) => {
107
- let r = /* @__PURE__ */ D("div", {
108
- role: "button",
127
+ children: Q.map((t) => {
128
+ let n = G ? `${m}-${encodeURIComponent(t.id)}` : void 0, o = G ? -1 : void 0, l = /* @__PURE__ */ N("div", {
129
+ role: J,
130
+ id: n,
131
+ "aria-selected": G ? n === g : void 0,
132
+ "aria-label": t.name,
109
133
  tabIndex: 0,
110
- className: n("flex cursor-pointer items-center gap-2 rounded-lg border border-transparent px-2 py-1.5 transition-colors", j.row),
134
+ className: r("flex cursor-pointer items-center gap-2 rounded-lg border border-transparent px-2 py-1.5 transition-colors", R.row, u),
111
135
  onClick: () => i(t),
112
- onKeyDown: (e) => q(e, t),
136
+ onKeyDown: (e) => oe(e, t),
113
137
  children: [
114
- /* @__PURE__ */ E(e, {
115
- size: s.MD,
138
+ /* @__PURE__ */ M(e, {
139
+ size: c.MD,
116
140
  initialsName: t.name
117
141
  }),
118
- f == null ? /* @__PURE__ */ E("span", {
119
- className: n(g, "min-w-0 flex-1 truncate text-start"),
142
+ d == null ? /* @__PURE__ */ M("span", {
143
+ className: r(b, "min-w-0 flex-1 truncate text-start"),
120
144
  children: t.name
121
- }) : /* @__PURE__ */ E(u, {
145
+ }) : /* @__PURE__ */ M(p, {
122
146
  text: t.name,
123
- query: f,
147
+ query: d,
124
148
  maxLines: 1,
125
- className: n(g, "min-w-0 flex-1 text-start")
149
+ className: r(b, "min-w-0 flex-1 text-start")
126
150
  }),
127
- /* @__PURE__ */ E(m, {
128
- icon: /* @__PURE__ */ E(T, {
129
- size: s.SM,
130
- className: j.star,
151
+ a && /* @__PURE__ */ M(ee, {
152
+ icon: /* @__PURE__ */ M(k, {
153
+ size: c.SM,
154
+ className: R.star,
131
155
  "aria-hidden": !0
132
156
  }),
133
157
  "aria-label": A,
134
158
  isSelected: !0,
159
+ tabIndex: o,
135
160
  onClick: (e) => {
136
- e.stopPropagation(), J(t.id);
161
+ e.stopPropagation(), $(t.id);
137
162
  }
138
163
  })
139
164
  ]
140
165
  });
141
- return /* @__PURE__ */ E("li", {
142
- className: R.has(t.id) ? j.rowLeaving : j.rowEnter,
143
- children: /* @__PURE__ */ E(d, {
166
+ return /* @__PURE__ */ M("li", {
167
+ role: q,
168
+ className: H.has(t.id) ? R.rowLeaving : R.rowEnter,
169
+ children: s ? /* @__PURE__ */ M(h, {
144
170
  asChild: !0,
145
171
  contentClassName: "max-w-[550px]",
146
- content: /* @__PURE__ */ E(k, {
172
+ content: /* @__PURE__ */ M(I, {
147
173
  description: t.description,
148
- viewDetailsLabel: F,
149
- onViewDetails: () => c(t)
174
+ viewDetailsLabel: j,
175
+ onViewDetails: () => s(t),
176
+ viewDetailsTabIndex: o
150
177
  }),
151
- children: r
152
- })
178
+ children: l
179
+ }) : l
153
180
  }, t.id);
154
181
  })
155
- }) : V && H !== "" ? /* @__PURE__ */ E("p", {
182
+ }) : X && Z !== "" ? /* @__PURE__ */ M("p", {
156
183
  role: "status",
157
184
  "aria-live": "polite",
158
- className: n(b, "px-4 py-4 text-start", j.emptyHint),
159
- children: I
160
- }) : /* @__PURE__ */ E("p", {
161
- className: n(b, "px-4 py-4 text-start", j.emptyHint),
162
- children: w
185
+ className: r(w, "px-4 py-4 text-start", R.emptyHint),
186
+ children: P
187
+ }) : /* @__PURE__ */ M("p", {
188
+ className: r(w, "px-4 py-4 text-start", R.emptyHint),
189
+ children: ne
163
190
  })
164
191
  })
165
192
  }),
166
- /* @__PURE__ */ E("div", {
167
- className: n("border-t px-2 py-3", j.footer),
168
- children: /* @__PURE__ */ E(l, {
193
+ /* @__PURE__ */ M("div", {
194
+ className: r("border-t px-2 py-3", R.footer),
195
+ children: /* @__PURE__ */ M(f, {
196
+ role: K ? "menuitem" : void 0,
169
197
  label: O,
170
198
  className: "w-full justify-center",
171
199
  onClick: o
@@ -173,168 +201,449 @@ var k = ({ description: e, unsupportedMessage: t, viewDetailsLabel: n = "View de
173
201
  })
174
202
  ]
175
203
  });
176
- }, I = ({ isOpen: e, onClose: t, onSelect: n, title: r, renderContent: i }) => /* @__PURE__ */ E(f, {
204
+ }, U = ".zip,.md", W = ({ isOpen: e, errorText: t, accept: n = U, labels: r, onClose: i, onFilesSelected: a, onFilesRejected: o }) => {
205
+ let { dialogTitle: s = "Upload skill", dropZoneLabel: c = "Drag and drop it or click here to upload", dropZoneMobileLabel: l = "Click here to upload", formatsLabel: u = "File formats .zip and SKILL.md", fileInputAriaLabel: f = "Upload a skill ZIP archive or a SKILL.md file", closeAriaLabel: p = "Close" } = r ?? {};
206
+ return /* @__PURE__ */ M(g, {
207
+ open: e,
208
+ size: _.Sm,
209
+ header: s,
210
+ closeAriaLabel: p,
211
+ onClose: i,
212
+ children: /* @__PURE__ */ M("div", {
213
+ className: "px-6 py-4",
214
+ children: /* @__PURE__ */ M(d, {
215
+ label: /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("span", {
216
+ className: "desktop:hidden",
217
+ children: l
218
+ }), /* @__PURE__ */ M("span", {
219
+ className: "hidden desktop:inline",
220
+ children: c
221
+ })] }),
222
+ description: u,
223
+ ariaLabel: f,
224
+ accept: n,
225
+ errorText: t,
226
+ onChange: a,
227
+ onReject: o
228
+ })
229
+ })
230
+ });
231
+ }, G = ({ isOpen: e, onClose: t, onSelect: n, title: r, renderContent: i }) => /* @__PURE__ */ M(g, {
177
232
  open: e,
178
233
  header: r,
179
- size: p.Lg,
234
+ size: _.Lg,
180
235
  className: "h-[min(90vh,860px)] !max-w-[min(95vw,1200px)] overflow-hidden",
181
236
  onClose: t,
182
- children: /* @__PURE__ */ E("div", {
237
+ children: /* @__PURE__ */ M("div", {
183
238
  className: "h-[min(80vh,840px)] overflow-auto",
184
- children: /* @__PURE__ */ E(g, {
239
+ children: /* @__PURE__ */ M(b, {
185
240
  fallback: null,
186
241
  children: e && i(n, t)
187
242
  })
188
243
  })
189
- }), L = (e) => /* @__PURE__ */ E(O, { ...e }), R = (e) => ({
244
+ }), K = (e) => /* @__PURE__ */ M(P, { ...e }), q = (e) => e == null || /[\s/]/.test(e), J = (e, t, n) => {
245
+ let r = [], i = 0;
246
+ return t.forEach((t, a) => {
247
+ let o = `/${n(t.url)}`, s = i;
248
+ for (; s <= e.length;) {
249
+ let t = e.indexOf(o, s);
250
+ if (t === -1) return;
251
+ let n = t + o.length;
252
+ if (q(e[n])) {
253
+ r.push({
254
+ skillIndex: a,
255
+ start: t,
256
+ length: o.length
257
+ }), i = n;
258
+ return;
259
+ }
260
+ s = t + 1;
261
+ }
262
+ }), r;
263
+ }, Y = (e, t) => {
264
+ let n = Math.min(e.length, t.length), r = 0;
265
+ for (; r < n && e[r] === t[r];) r += 1;
266
+ let i = n - r, a = 0;
267
+ for (; a < i && e[e.length - 1 - a] === t[t.length - 1 - a];) a += 1;
268
+ return {
269
+ start: r,
270
+ deletedLength: e.length - r - a,
271
+ insertedLength: t.length - r - a
272
+ };
273
+ }, X = (e, t) => {
274
+ let n = t.start + t.deletedLength, r = t.insertedLength - t.deletedLength;
275
+ return e.reduce((e, i) => i.start + i.length <= t.start ? (e.push(i), e) : (i.start >= n && e.push({
276
+ ...i,
277
+ start: i.start + r
278
+ }), e), []);
279
+ }, Z = (e, t, n, r, i) => {
280
+ let a = r.length + 1, o = a + +!!i, s = e.map((e) => e.start >= t ? {
281
+ ...e,
282
+ start: e.start + o
283
+ } : e), c = {
284
+ url: n,
285
+ name: r,
286
+ start: t,
287
+ length: a
288
+ };
289
+ return [...s, c].sort((e, t) => e.start - t.start);
290
+ }, Q = (e, t) => e.find((e) => e.start + e.length === t), re = () => {
291
+ let [e, t] = E(""), [n, r] = E([]), i = T(e);
292
+ i.current = e;
293
+ let a = T(n);
294
+ return a.current = n, {
295
+ draft: e,
296
+ anchors: n,
297
+ onDraftChange: x((e) => {
298
+ let n = Y(i.current, e);
299
+ r((e) => X(e, n)), i.current = e, t(e);
300
+ }, []),
301
+ insertMention: x((e, n, a) => {
302
+ let o = i.current, s = !/^\s/.test(o.slice(a)), c = `/${n}${s ? " " : ""}`, l = o.slice(0, a) + c + o.slice(a);
303
+ return i.current = l, t(l), r((t) => Z(t, a, e, n, s)), s;
304
+ }, []),
305
+ onBackspaceAtCaret: x((e) => Q(a.current, e), []),
306
+ orderedSkills: w(() => {
307
+ if (n.length !== 0) return n.map((e) => ({ url: e.url }));
308
+ }, [n]),
309
+ reset: x(() => {
310
+ t(""), r([]);
311
+ }, []),
312
+ seedFromMessage: x((e, n, i) => {
313
+ let a = n ?? [], o = J(e, a, i);
314
+ t(e), r(o.map((e) => {
315
+ let t = a[e.skillIndex];
316
+ return {
317
+ url: t.url,
318
+ name: i(t.url),
319
+ start: e.start,
320
+ length: e.length
321
+ };
322
+ }));
323
+ }, [])
324
+ };
325
+ }, ie = (e) => ({
190
326
  id: e.url,
191
327
  name: e.name,
192
328
  description: e.description
193
- }), z = (e) => {
329
+ }), ae = (e) => {
194
330
  let t = e.split("/").filter((e) => e.length > 0);
195
331
  return t[t.length - 1] ?? e;
196
- }, B = ({ isEnabled: e, isSkillsSupported: t, skills: n, sharedWithMe: i, publicSkills: a, favoriteIds: o, onToggleFavorite: s, labels: l, historyChipLabelClassName: u, renderCatalogContent: d, detailsPanelComponent: f }) => {
197
- let { addMenuLabel: p = "Skills", backLabel: m = "Back", catalogModalTitleLabel: h = "Use skill", emptyQueryHintLabel: v = "Type to filter", unsupportedTooltipLabel: y = "Selected model does not support skills. Remove the skill or select different model to proceed.", panelLabels: x } = l ?? {}, w = e && t, [T, D] = S(!1), [O, k] = S(null), [j, M] = S(null), N = b(() => [
332
+ }, oe = ({ isEnabled: e, isSkillsSupported: t, skills: n, sharedWithMe: r, publicSkills: a, favoriteIds: o, onToggleFavorite: s, labels: c, historyChipLabelClassName: u, renderCatalogContent: d, detailsPanelComponent: f }) => {
333
+ let { addMenuLabel: p = "Skills", backLabel: m = "Back", catalogModalTitleLabel: h = "Use skill", emptyQueryHintLabel: g = "Type to filter", panelLabels: _ } = c ?? {}, v = e && t, [ee, y] = E(!1), [te, S] = E(null), [C, T] = E(0), [ne, O] = E(0), [k, A] = E(void 0), j = re(), N = w(() => [
198
334
  ...n,
199
- ...i ?? [],
335
+ ...r ?? [],
200
336
  ...a ?? []
201
337
  ], [
202
338
  n,
203
- i,
339
+ r,
204
340
  a
205
- ]), P = b(() => new Map(N.map((e) => [e.url, e])), [N]), L = b(() => N.filter((e) => o.has(e.url)).map((e) => R(e)), [N, o]), B = b(() => j == null ? null : P.get(j) ?? null, [P, j]), V = B != null && !t, H = _((e) => {
206
- M(e);
207
- }, []), U = _(() => {
208
- M(null);
209
- }, []), W = j, G = b(() => j == null ? void 0 : [{ url: j }], [j]), K = b(() => B == null ? null : /* @__PURE__ */ E(A, {
210
- name: B.name,
211
- path: B.url,
212
- description: B.description,
213
- isUnsupported: V,
214
- onViewDetails: k,
215
- labels: {
216
- viewDetailsLabel: x?.viewDetailsLabel,
217
- unsupportedTooltipLabel: y
218
- }
219
- }), [
220
- B,
221
- V,
222
- x,
223
- y
224
- ]), q = _((e) => e == null || e.length === 0 ? null : e.map((e) => {
341
+ ]), P = w(() => new Map(N.map((e) => [e.url, e])), [N]), F = x((e) => P.get(e)?.name ?? ae(e), [P]), I = w(() => N.filter((e) => o.has(e.url)).map((e) => ie(e)), [N, o]), R = j.anchors.length > 0 && !t, z = w(() => j.anchors.map((e) => ({
342
+ start: e.start,
343
+ length: e.length,
344
+ isUnsupported: !t,
345
+ render: () => /* @__PURE__ */ M(L, {
346
+ name: e.name,
347
+ path: e.url,
348
+ labelClassName: u,
349
+ description: P.get(e.url)?.description,
350
+ isUnsupported: !t,
351
+ onViewDetails: S,
352
+ labels: { viewDetailsLabel: _?.viewDetailsLabel }
353
+ })
354
+ })), [
355
+ j.anchors,
356
+ t,
357
+ P,
358
+ u,
359
+ _
360
+ ]), B = x((e, t, n) => {
361
+ let r = j.insertMention(e, t, n);
362
+ O((e) => e + 1), A(n + 1 + t.length + +!!r);
363
+ }, [j]), V = x(() => {
364
+ j.reset(), O((e) => e + 1), A(void 0);
365
+ }, [j]), U = x((e, t) => {
366
+ j.seedFromMessage(e, t, F), O((e) => e + 1), A(void 0);
367
+ }, [j, F]), W = x((e, t) => {
368
+ if (t == null || t.length === 0) return null;
369
+ let n = J(e, t, F), r = [], i = 0;
370
+ return n.forEach((n) => {
371
+ n.start > i && r.push(e.slice(i, n.start));
372
+ let a = t[n.skillIndex], o = P.get(a.url), s = o?.name ?? ae(a.url);
373
+ r.push(/* @__PURE__ */ M(L, {
374
+ name: s,
375
+ path: a.url,
376
+ labelClassName: u,
377
+ description: o?.description,
378
+ onViewDetails: S,
379
+ labels: { viewDetailsLabel: _?.viewDetailsLabel }
380
+ }, `${a.url}-${n.start}`)), i = n.start + n.length;
381
+ }), i < e.length && r.push(e.slice(i)), r;
382
+ }, [
383
+ F,
384
+ P,
385
+ u,
386
+ _
387
+ ]), K = x((e) => e == null || e.length === 0 ? null : e.map((e) => {
225
388
  let t = P.get(e.url);
226
- return /* @__PURE__ */ E(A, {
227
- name: t?.name ?? z(e.url),
389
+ return /* @__PURE__ */ M(L, {
390
+ name: t?.name ?? ae(e.url),
228
391
  path: e.url,
229
392
  labelClassName: u,
230
393
  description: t?.description,
231
- onViewDetails: k,
232
- labels: { viewDetailsLabel: x?.viewDetailsLabel }
394
+ onViewDetails: S,
395
+ labels: { viewDetailsLabel: _?.viewDetailsLabel }
233
396
  }, e.url);
234
397
  }), [
235
398
  P,
236
399
  u,
237
- x
238
- ]), J = _((e) => /* @__PURE__ */ E(F, {
239
- favorites: L,
240
- onSelect: (t) => {
241
- H(t.id), e();
400
+ _
401
+ ]), q = x((e, t) => /* @__PURE__ */ M(H, {
402
+ favorites: I,
403
+ isMenu: !0,
404
+ onSelect: (n) => {
405
+ B(n.id, n.name, t), e();
242
406
  },
243
407
  onToggleFavorite: s,
244
408
  onBrowse: () => {
245
- e(), D(!0);
409
+ T(t), e(), y(!0);
246
410
  },
247
411
  onViewDetails: (t) => {
248
- e(), k(t.id);
412
+ e(), S(t.id);
249
413
  },
250
- labels: x
414
+ labels: _
251
415
  }), [
252
- L,
253
- H,
416
+ I,
417
+ B,
254
418
  s,
255
- x
256
- ]), Y = b(() => w ? {
419
+ _
420
+ ]), Y = w(() => v ? {
257
421
  key: "skills",
258
422
  title: p,
259
- icon: /* @__PURE__ */ E(C, {
260
- size: r,
423
+ icon: /* @__PURE__ */ M(D, {
424
+ size: i,
261
425
  "aria-hidden": !0,
262
- stroke: c
426
+ stroke: l
263
427
  }),
264
- renderOverlay: J,
428
+ renderOverlay: q,
265
429
  backLabel: m
266
430
  } : void 0, [
267
- w,
431
+ v,
268
432
  p,
269
433
  m,
270
- J
271
- ]), X = b(() => w ? {
434
+ q
435
+ ]), X = w(() => v ? {
272
436
  triggerPrefix: "/",
273
437
  menuLabel: p,
274
- emptyQueryHint: v,
275
- renderMenu: ({ query: e, close: t }) => /* @__PURE__ */ E(F, {
276
- favorites: L,
438
+ emptyQueryHint: g,
439
+ renderMenu: ({ query: e, caretPosition: t, close: n, listboxId: r, activeOptionId: i }) => /* @__PURE__ */ M(H, {
440
+ favorites: I,
277
441
  searchQuery: e,
442
+ listboxId: r,
443
+ activeOptionId: i,
278
444
  onSelect: (e) => {
279
- t({ consumeQuery: !0 }), H(e.id);
445
+ n({ consumeQuery: !0 }), B(e.id, e.name, t);
280
446
  },
281
447
  onToggleFavorite: s,
282
448
  onBrowse: () => {
283
- t({ consumeQuery: !0 }), D(!0);
449
+ n({ consumeQuery: !0 }), T(t), y(!0);
284
450
  },
285
451
  onViewDetails: (e) => {
286
- t({ consumeQuery: !0 }), k(e.id);
452
+ n({ consumeQuery: !0 }), S(e.id);
287
453
  },
288
- labels: x
454
+ labels: _
289
455
  })
290
456
  } : void 0, [
291
- w,
292
- p,
293
457
  v,
294
- L,
295
- H,
458
+ p,
459
+ g,
460
+ I,
461
+ B,
296
462
  s,
297
- x
463
+ _
298
464
  ]);
299
465
  return e ? {
300
466
  skillMenuOverlay: Y,
301
467
  commandMenu: X,
302
- skillCatalogModal: /* @__PURE__ */ E(I, {
303
- isOpen: T,
304
- onClose: () => D(!1),
468
+ skillCatalogModal: /* @__PURE__ */ M(G, {
469
+ isOpen: ee,
470
+ onClose: () => y(!1),
305
471
  onSelect: (e) => {
306
- H(e), D(!1);
472
+ B(e, F(e), C), y(!1);
307
473
  },
308
474
  title: h,
309
475
  renderContent: d
310
476
  }),
311
- skillDetailsPanel: /* @__PURE__ */ E(g, {
477
+ skillDetailsPanel: /* @__PURE__ */ M(b, {
312
478
  fallback: null,
313
- children: /* @__PURE__ */ E(f, {
314
- skillId: O,
315
- onClose: () => k(null)
479
+ children: /* @__PURE__ */ M(f, {
480
+ skillId: te,
481
+ onClose: () => S(null)
316
482
  })
317
483
  }),
318
- selectedSkillElement: K,
319
- selectedSkillPath: W,
320
- selectedSkills: G,
321
- isSkillUnsupported: V,
322
- selectSkill: H,
323
- removeSelectedSkill: U,
324
- renderHistorySkills: q
484
+ message: j.draft,
485
+ messageRevision: ne,
486
+ activeMentions: z,
487
+ onDraftChange: j.onDraftChange,
488
+ onBackspaceAtCaret: j.onBackspaceAtCaret,
489
+ caretPositionOverride: k,
490
+ isSkillUnsupported: R,
491
+ selectedSkills: j.orderedSkills,
492
+ resetSkillMentions: V,
493
+ seedSkillMentions: U,
494
+ renderHistorySkillSegments: W,
495
+ renderHistorySkills: K
325
496
  } : {
326
497
  skillMenuOverlay: void 0,
327
498
  commandMenu: void 0,
328
499
  skillCatalogModal: null,
329
500
  skillDetailsPanel: null,
330
- selectedSkillElement: null,
331
- selectedSkillPath: null,
332
- selectedSkills: void 0,
501
+ message: "",
502
+ messageRevision: 0,
503
+ activeMentions: [],
504
+ onDraftChange: () => void 0,
505
+ onBackspaceAtCaret: () => void 0,
506
+ caretPositionOverride: void 0,
333
507
  isSkillUnsupported: !1,
334
- selectSkill: () => void 0,
335
- removeSelectedSkill: () => void 0,
508
+ selectedSkills: void 0,
509
+ resetSkillMentions: () => void 0,
510
+ seedSkillMentions: () => void 0,
511
+ renderHistorySkillSegments: () => null,
336
512
  renderHistorySkills: () => null
337
513
  };
514
+ }, $ = {
515
+ background: "_background_14zdf_1",
516
+ border: "_border_14zdf_5",
517
+ value: "_value_14zdf_9",
518
+ clear: "_clear_14zdf_13",
519
+ invalid: "_invalid_14zdf_17"
520
+ }, se = [], ce = ({ value: e, onChange: i, displayName: a, favorites: o = se, onToggleFavorite: s, onViewDetails: c, renderOverlay: d, isSkillsSupported: p, isDisabled: h = !1, isInvalid: g = !1, labelledById: _, describedById: ee, labels: y, renderCatalogContent: b, className: x, styles: C }) => {
521
+ let [w, D] = E(!1), [O, k] = E(!1), [P, I] = E(""), L = T(null), R = S(), z = T(null), B = T(!1), V = n(e, p), U = p && !h, W = w && U, K = O && U, q = () => {
522
+ z.current && !z.current.disabled ? z.current.focus() : L.current?.querySelector("button:not(:disabled)")?.focus();
523
+ };
524
+ te(() => {
525
+ B.current && !W && !K && ((document.activeElement === document.body || L.current?.contains(document.activeElement)) && q(), D(!1), k(!1)), B.current = W || K;
526
+ }, [W, K]);
527
+ let J = (e) => {
528
+ e && !U || (I(""), D(e));
529
+ }, Y = (e) => {
530
+ U && i(e), D(!1), k(!1);
531
+ }, X = {
532
+ ...t({
533
+ "--ssf-text": C?.colors?.text,
534
+ "--ssf-bg": C?.colors?.background,
535
+ "--ssf-border": C?.colors?.border,
536
+ "--ssf-error": C?.colors?.error
537
+ }),
538
+ ...C?.cssVars
539
+ }, Z = /* @__PURE__ */ N("div", {
540
+ id: R,
541
+ className: "w-full min-w-0",
542
+ children: [/* @__PURE__ */ M("div", {
543
+ className: "p-2",
544
+ children: /* @__PURE__ */ M(v, {
545
+ value: P,
546
+ onChange: (e) => I(e ?? ""),
547
+ placeholder: y.searchPlaceholder ?? "Search skills",
548
+ "aria-label": y.searchPlaceholder ?? "Search skills",
549
+ clearLabel: y.clearSearchLabel ?? "Clear search"
550
+ })
551
+ }), /* @__PURE__ */ M(H, {
552
+ className: "min-w-0 desktop:w-full",
553
+ rowClassName: "min-h-11",
554
+ favorites: o,
555
+ searchQuery: P,
556
+ labels: y.panelLabels,
557
+ onSelect: (e) => Y(e.id),
558
+ onToggleFavorite: s,
559
+ onViewDetails: c ? (e) => {
560
+ D(!1), c(e);
561
+ } : void 0,
562
+ onBrowse: () => {
563
+ D(!1), k(!0);
564
+ }
565
+ })]
566
+ }), Q = /* @__PURE__ */ M(m, {
567
+ inputRef: z,
568
+ readOnly: !0,
569
+ role: "combobox",
570
+ "aria-haspopup": "dialog",
571
+ "aria-expanded": W,
572
+ "aria-controls": W ? R : void 0,
573
+ "aria-labelledby": _,
574
+ "aria-describedby": ee,
575
+ "aria-invalid": g || V,
576
+ disabled: !U,
577
+ invalid: g || V,
578
+ value: e ? a || e : "",
579
+ placeholder: y.placeholder,
580
+ title: p ? e ? a || e : void 0 : y.unsupportedTooltipLabel,
581
+ containerClassName: "w-full min-w-0",
582
+ wrapperClassName: r("cursor-pointer", "--ssf-bg" in X && $.background, "--ssf-border" in X && $.border, (g || V) && $.invalid, C?.triggerClassName),
583
+ className: r("min-w-0 cursor-pointer text-ellipsis", "--ssf-text" in X && $.value, C?.typography?.fontClassName ?? "dial-small-text"),
584
+ onKeyDown: (e) => {
585
+ [
586
+ "Enter",
587
+ " ",
588
+ "ArrowDown"
589
+ ].includes(e.key) ? (e.preventDefault(), e.stopPropagation(), J(e.key === "ArrowDown" || !W)) : e.key === "Escape" && J(!1);
590
+ },
591
+ iconAfter: /* @__PURE__ */ N("span", {
592
+ className: "flex shrink-0 items-center",
593
+ children: [e && /* @__PURE__ */ M(f, {
594
+ type: "button",
595
+ className: r("size-11 shrink-0", $.clear),
596
+ disabled: h,
597
+ "aria-label": y.removeSkillLabel,
598
+ onKeyDown: (e) => e.stopPropagation(),
599
+ onClick: (e) => {
600
+ e.stopPropagation(), i(void 0), D(!1), U ? z.current?.focus() : L.current?.focus();
601
+ },
602
+ iconBefore: /* @__PURE__ */ M(A, {
603
+ "aria-hidden": !0,
604
+ size: 18,
605
+ stroke: l
606
+ })
607
+ }), /* @__PURE__ */ M(ne, {
608
+ "aria-hidden": !0,
609
+ size: 20,
610
+ stroke: l,
611
+ className: r("transition-transform", W && "rotate-180")
612
+ })]
613
+ })
614
+ });
615
+ return /* @__PURE__ */ N("div", {
616
+ ref: L,
617
+ role: "group",
618
+ "aria-labelledby": _,
619
+ tabIndex: -1,
620
+ className: r("min-w-0", x, F.selectorField),
621
+ style: X,
622
+ children: [d ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("div", {
623
+ className: "w-full min-w-0",
624
+ onClick: () => J(!W),
625
+ children: Q
626
+ }), d(Z, W, () => J(!1))] }) : /* @__PURE__ */ M(u, {
627
+ open: W,
628
+ onOpenChange: J,
629
+ disabled: !U,
630
+ className: "w-full min-w-0",
631
+ listClassName: "w-[min(var(--reference-width),calc(100vw-2rem))] max-w-full",
632
+ renderOverlay: () => /* @__PURE__ */ M("div", {
633
+ role: "dialog",
634
+ "aria-labelledby": _,
635
+ children: Z
636
+ }),
637
+ initialFocus: 0,
638
+ children: Q
639
+ }), K && /* @__PURE__ */ M(G, {
640
+ isOpen: !0,
641
+ onClose: () => k(!1),
642
+ title: y.modalTitle,
643
+ onSelect: Y,
644
+ renderContent: b
645
+ })]
646
+ });
338
647
  };
339
648
  //#endregion
340
- export { A as ChatSkill, F as FavoriteSkillsPanel, I as SkillCatalogModal, L as SkillDetailsSidePanel, k as SkillInfoTooltipContent, R as buildFavoriteSkillItem, B as useSkillSelectorOverlay };
649
+ export { L as ChatSkill, H as FavoriteSkillsPanel, F as SKILLS_CLASS, W as SkillArchiveUploadDialog, G as SkillCatalogModal, K as SkillDetailsSidePanel, I as SkillInfoTooltipContent, ce as SkillSelectorField, ie as buildFavoriteSkillItem, Y as diffTextChange, Q as findMentionAtCaret, ae as getSkillFallbackName, Z as insertAnchor, J as matchSkillMentions, X as reconcileAnchors, re as useSkillMentions, oe as useSkillSelectorOverlay };