@kitn.ai/ui 0.27.0 → 0.28.0

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 (266) hide show
  1. package/README.md +10 -2
  2. package/dist/{Icon-BnFKqqtY.js → Icon-DObhsRtm.js} +1 -1
  3. package/dist/{action-icons-CBskfBMz.js → action-icons-CcgNN2oT.js} +1 -1
  4. package/dist/arrow-down-CjRU3JgV.js +1 -0
  5. package/dist/arrow-left-Bnpb1UEW.js +1 -0
  6. package/dist/{artifact-CvXEm1lS.js → artifact-Bwt7OgcR.js} +1 -1
  7. package/dist/{attachments-C43ZegEq.js → attachments-Qr4kg-2b.js} +1 -1
  8. package/dist/{audio-visualizer-B-79y1Tj.js → audio-visualizer-DToYdfSc.js} +1 -1
  9. package/dist/{badge-BpUbq8c0.js → badge-CdEu_jn2.js} +1 -1
  10. package/dist/{bell-sn17Ip9v.js → bell-DQAAOpDz.js} +1 -1
  11. package/dist/{button-BH6rN0U-.js → button-DkuOnGLy.js} +1 -1
  12. package/dist/{card-renderer-Cb1gQmth.js → card-renderer-Jx70m6_l.js} +1 -1
  13. package/dist/{card-routing-DifQgS7n.js → card-routing-0YidER_3.js} +1 -1
  14. package/dist/check-njkVdZu2.js +1 -0
  15. package/dist/{checkbox-Dc9Yov_B.js → checkbox-D7iRB3nL.js} +1 -1
  16. package/dist/{checkbox-group-B1kDLLYk.js → checkbox-group-B2_rpoPM.js} +1 -1
  17. package/dist/chevron-down-B72s6PXR.js +1 -0
  18. package/dist/chevron-right-BatuHzUm.js +1 -0
  19. package/dist/{choice-card-BT3c1S8g.js → choice-card-m0BYqqOK.js} +1 -1
  20. package/dist/circle-check-B62pODB3.js +1 -0
  21. package/dist/{circle-x-wobWkoSx.js → circle-x-BPG0iPst.js} +1 -1
  22. package/dist/circle-zx0ByzY9.js +1 -0
  23. package/dist/code-block-ClMLKb7C.js +1 -0
  24. package/dist/{collapsible-CPJbf6FM.js → collapsible-B4DlWicL.js} +1 -1
  25. package/dist/components/chat-thread.d.ts +89 -1
  26. package/dist/components/conversation-item.d.ts +16 -0
  27. package/dist/components/conversation-panel.d.ts +29 -0
  28. package/dist/components/home-panel.d.ts +34 -0
  29. package/dist/components/widget-tab-bar.d.ts +16 -0
  30. package/dist/{composer-CjngLzal.js → composer-sQ0HcvyG.js} +3 -3
  31. package/dist/{confirm-card-DCx_A4bU.js → confirm-card-rQWDQsnC.js} +1 -1
  32. package/dist/construct-cli.es.js +182 -14
  33. package/dist/{context-BY8V-Nlp.js → context-0kg4ZX1J.js} +1 -1
  34. package/dist/controllable-CnGpMF6r.js +1 -0
  35. package/dist/conversation-item-BxwQLaFJ.js +1 -0
  36. package/dist/conversation-list-BCfGN1JU.js +1 -0
  37. package/dist/{copy-B6DO4PqB.js → copy-n9u9rqpi.js} +1 -1
  38. package/dist/{create-tween-CnMHviKB.js → create-tween-C-q-JCM-.js} +1 -1
  39. package/dist/{create-tween-D1aiGZZh.js → create-tween-CRrJXxBd.js} +1 -1
  40. package/dist/{create-tween-BPzaefTp.js → create-tween-DZ3RRDHD.js} +1 -1
  41. package/dist/{create-tween-DUSQUKpr.js → create-tween-uPkArjIG.js} +1 -1
  42. package/dist/custom-elements.json +51 -2
  43. package/dist/{default-input-CucQEOqH.js → default-input-CaMrJkgH.js} +1 -1
  44. package/dist/define-By-uL588.js +1 -0
  45. package/dist/define.js +2 -2
  46. package/dist/define.server.js +2 -2
  47. package/dist/{disclosure-CbLtajUQ.js → disclosure-WUImBbDv.js} +1 -1
  48. package/dist/{dropdown-BwhViJFd.js → dropdown-wZVeJOMd.js} +1 -1
  49. package/dist/elements/agent-card.js +1 -1
  50. package/dist/elements/artifact.js +1 -1
  51. package/dist/elements/attachments.js +1 -1
  52. package/dist/elements/audio-visualizer.js +1 -1
  53. package/dist/elements/avatar.js +1 -1
  54. package/dist/elements/badge.js +1 -1
  55. package/dist/elements/button.js +1 -1
  56. package/dist/elements/card.js +1 -1
  57. package/dist/elements/cards.js +1 -1
  58. package/dist/elements/chain-of-thought.js +1 -1
  59. package/dist/elements/chat-scope-picker.js +1 -1
  60. package/dist/elements/chat-workspace.js +1 -1
  61. package/dist/elements/chat.js +1 -1
  62. package/dist/elements/checkbox-group.js +1 -1
  63. package/dist/elements/checkbox.js +1 -1
  64. package/dist/elements/checkpoint.js +1 -1
  65. package/dist/elements/choice.js +1 -1
  66. package/dist/elements/coachmark.js +1 -1
  67. package/dist/elements/code-block.js +1 -1
  68. package/dist/elements/command.js +1 -1
  69. package/dist/elements/compare.js +1 -1
  70. package/dist/elements/composer.js +1 -1
  71. package/dist/elements/confirm-card.js +1 -1
  72. package/dist/elements/context-meter.js +1 -1
  73. package/dist/elements/conversation-item.js +1 -1
  74. package/dist/elements/conversation-list.js +1 -1
  75. package/dist/elements/dialog.js +1 -1
  76. package/dist/elements/dock.js +3 -3
  77. package/dist/elements/dropdown.js +1 -1
  78. package/dist/elements/editable-label.js +1 -1
  79. package/dist/elements/embed.js +1 -1
  80. package/dist/elements/empty.js +1 -1
  81. package/dist/elements/feedback-bar.js +1 -1
  82. package/dist/elements/file-tree.js +1 -1
  83. package/dist/elements/file-upload.js +1 -1
  84. package/dist/elements/form.js +1 -1
  85. package/dist/elements/hover-card.js +1 -1
  86. package/dist/elements/icon.js +1 -1
  87. package/dist/elements/image.js +1 -1
  88. package/dist/elements/input.js +1 -1
  89. package/dist/elements/kbd.js +1 -1
  90. package/dist/elements/link-preview.js +1 -1
  91. package/dist/elements/loader.js +1 -1
  92. package/dist/elements/markdown.js +1 -1
  93. package/dist/elements/menu.js +1 -1
  94. package/dist/elements/message-skills.js +1 -1
  95. package/dist/elements/message.js +1 -1
  96. package/dist/elements/model-switcher.js +1 -1
  97. package/dist/elements/nav.js +1 -1
  98. package/dist/elements/notice.js +1 -1
  99. package/dist/elements/pane-grid.js +1 -1
  100. package/dist/elements/pane-group.js +1 -1
  101. package/dist/elements/pane.js +1 -1
  102. package/dist/elements/popover.js +1 -1
  103. package/dist/elements/progress-bar.js +1 -1
  104. package/dist/elements/prompt-dock.js +1 -1
  105. package/dist/elements/prompt-input.js +1 -1
  106. package/dist/elements/prompt-suggestions.js +1 -1
  107. package/dist/elements/radio-group.js +1 -1
  108. package/dist/elements/reasoning.js +1 -1
  109. package/dist/elements/remote.js +1 -1
  110. package/dist/elements/resizable.js +1 -1
  111. package/dist/elements/response-stream.js +1 -1
  112. package/dist/elements/screen.js +1 -1
  113. package/dist/elements/scroll-area.js +1 -1
  114. package/dist/elements/scroll-button.js +1 -1
  115. package/dist/elements/search.js +1 -1
  116. package/dist/elements/segmented.js +1 -1
  117. package/dist/elements/select.js +1 -1
  118. package/dist/elements/separator.js +1 -1
  119. package/dist/elements/setting-item.js +1 -1
  120. package/dist/elements/settings-group.js +1 -1
  121. package/dist/elements/skeleton.js +1 -1
  122. package/dist/elements/slider.js +1 -1
  123. package/dist/elements/source.js +1 -1
  124. package/dist/elements/status.js +1 -1
  125. package/dist/elements/switch.js +1 -1
  126. package/dist/elements/tabs.js +1 -1
  127. package/dist/elements/tasks.js +1 -1
  128. package/dist/elements/text-shimmer.js +1 -1
  129. package/dist/elements/thinking-bar.js +1 -1
  130. package/dist/elements/thread.js +1 -1
  131. package/dist/elements/toast.js +1 -1
  132. package/dist/elements/tool.js +1 -1
  133. package/dist/elements/tooltip.js +1 -1
  134. package/dist/elements/voice-input.js +1 -1
  135. package/dist/elements/voice-output.js +1 -1
  136. package/dist/elements.d.ts +20 -4
  137. package/dist/{ellipsis-DFr4Vqr3.js → ellipsis-CbOpJnU3.js} +1 -1
  138. package/dist/{embed-5s_vU4J0.js → embed-CrfjkbUG.js} +1 -1
  139. package/dist/{external-link-u9d85ORQ.js → external-link-ByXAwBBQ.js} +1 -1
  140. package/dist/{file-text-CX7_x42o.js → file-text-DMib2qwt.js} +1 -1
  141. package/dist/{file-tree-D3kBjXI5.js → file-tree-CJqM2aP7.js} +1 -1
  142. package/dist/{folder-V-YdIL8f.js → folder-_BAb929C.js} +1 -1
  143. package/dist/{form-BRNUMCN2.js → form-DSZgZQZk.js} +1 -1
  144. package/dist/{hover-card-DaeiYrTA.js → hover-card-BQbul9eq.js} +1 -1
  145. package/dist/{icon-BpixdZNq.js → icon-CdcfRhYI.js} +1 -1
  146. package/dist/index.d.ts +3 -1
  147. package/dist/index.js +2842 -2703
  148. package/dist/index.server.js +2820 -2681
  149. package/dist/{info-8mFsIjS3.js → info-DsFjGuI_.js} +1 -1
  150. package/dist/{input-d1Yuu-hz.js → input-DKbmkMos.js} +1 -1
  151. package/dist/kai.es.js +1 -1
  152. package/dist/{kbd-961zMPFB.js → kbd-PvdGhX4s.js} +1 -1
  153. package/dist/{link-preview-DIIbV2Sd.js → link-preview-DbM1866N.js} +1 -1
  154. package/dist/{link-DlZZBGaR.js → link-zF8PzWfF.js} +1 -1
  155. package/dist/{loader-YQszHFaW.js → loader-BM4CEz4G.js} +1 -1
  156. package/dist/{markdown-CVk1MPsj.js → markdown-LMvmAyBk.js} +7 -7
  157. package/dist/mcp.es.js +78 -4
  158. package/dist/{message-CwKVEdZg.js → message-BSsgvHvf.js} +1 -1
  159. package/dist/{message-DS8lzHc1.js → message-BYZECyek.js} +1 -1
  160. package/dist/message-circle-DruwObfX.js +1 -0
  161. package/dist/message-square-BG6q6mlm.js +1 -0
  162. package/dist/{minimize-2-UEZmP2QT.js → minimize-2-BQRoBV1V.js} +1 -1
  163. package/dist/{model-switcher-Kk1jEQ5t.js → model-switcher-CMpCOYcB.js} +1 -1
  164. package/dist/{overlay-C1od6LOz.js → overlay-Cb-MkyDa.js} +1 -1
  165. package/dist/{panel-right-ryET0yyn.js → panel-right-i8warFxT.js} +1 -1
  166. package/dist/{paperclip-BDNoZFJP.js → paperclip-ByY3UVO6.js} +1 -1
  167. package/dist/play-BvKKq3fX.js +1 -0
  168. package/dist/primitives/conversation-store.d.ts +54 -0
  169. package/dist/{progress-bar-BvYX0aoy.js → progress-bar-jVAHvMUf.js} +1 -1
  170. package/dist/{prompt-suggestion-BRFu2lcu.js → prompt-suggestion-CD-qtNgC.js} +1 -1
  171. package/dist/{radio-DcL23cNJ.js → radio-BsoBMhkF.js} +1 -1
  172. package/dist/react/index.d.ts +393 -0
  173. package/dist/react.js +20 -20
  174. package/dist/{reasoning-Cackq4Rh.js → reasoning-4kBPtlTx.js} +1 -1
  175. package/dist/register-impl-B1hLkrI8.js +424 -0
  176. package/dist/{resizable-Cp9HUYih.js → resizable-uPmY9VY-.js} +1 -1
  177. package/dist/{rotate-ccw-0DLRDHH5.js → rotate-ccw-B2xn93py.js} +1 -1
  178. package/dist/{rotate-cw-DOB9IGcU.js → rotate-cw-CMVLoCyH.js} +1 -1
  179. package/dist/{scroll-area-emVmWP4K.js → scroll-area-BqLUo8ZZ.js} +1 -1
  180. package/dist/{scroll-button-CeP_gv1x.js → scroll-button-DslXiJyL.js} +1 -1
  181. package/dist/{select-CWmu00tS.js → select-2cLRtPGT.js} +1 -1
  182. package/dist/{separator-CE6vly6z.js → separator-BWQtNJcM.js} +1 -1
  183. package/dist/{settings-CE-78SvZ.js → settings-BBR63jLg.js} +1 -1
  184. package/dist/{settings-group-ZFWNxFQR.js → settings-group-B2ciy-Iw.js} +1 -1
  185. package/dist/{skeleton-BebdP4mf.js → skeleton-CkHI-HgC.js} +1 -1
  186. package/dist/{slider-BAKRYUlz.js → slider-DDR9U-i0.js} +1 -1
  187. package/dist/{solid-BE5ui6sy.js → solid-BzCFdL25.js} +7720 -7058
  188. package/dist/{solid-DFhsce3O.js → solid-DruVOXnf.js} +5864 -5283
  189. package/dist/solid.d.ts +6 -2
  190. package/dist/solid.js +217 -210
  191. package/dist/solid.server.js +217 -210
  192. package/dist/{source-B0FlguSx.js → source-GEnFF528.js} +1 -1
  193. package/dist/{star-CBMZvLuN.js → star-CilHq8GP.js} +1 -1
  194. package/dist/store-Ciyk6eZG.js +1 -0
  195. package/dist/{switch-CViARZCy.js → switch-KkeQIbuH.js} +1 -1
  196. package/dist/{tasks-card-MjCcOhR_.js → tasks-card-BrN4bggJ.js} +1 -1
  197. package/dist/{text-shimmer-DKlwRF2G.js → text-shimmer-Dcj1MHuq.js} +1 -1
  198. package/dist/{textarea-3ay2Me2-.js → textarea-Dpvbngbg.js} +1 -1
  199. package/dist/theme.tokens.css +28 -0
  200. package/dist/{thumbs-up-DQcu2HMO.js → thumbs-up-CsT9Wzb9.js} +1 -1
  201. package/dist/{toast-store-C6yKOhbk.js → toast-store-tgK6MuMv.js} +1 -1
  202. package/dist/{tool-BCYNlfKy.js → tool-DzUjIBT8.js} +1 -1
  203. package/dist/{tooltip-05zI4hjs.js → tooltip-Bkkg_4t0.js} +1 -1
  204. package/dist/{trash-2-BR1RxGky.js → trash-2-jBKxjGGQ.js} +1 -1
  205. package/dist/{triangle-alert-DHohDOCy.js → triangle-alert-DlQ68ppf.js} +1 -1
  206. package/dist/types.d.ts +48 -3
  207. package/dist/ui/dock.d.ts +29 -0
  208. package/dist/{upload-BbGW6A_u.js → upload-TcAHXv9W.js} +1 -1
  209. package/dist/{url-scheme-policy-DHpoTJwB.js → url-scheme-policy-DR5DgvkM.js} +1 -1
  210. package/dist/{use-card-resolution-CJW4grFa.js → use-card-resolution-DaZqAdWf.js} +1 -1
  211. package/dist/{variant-aurora-xiMPty8f.js → variant-aurora-BhLuYxJR.js} +1 -1
  212. package/dist/{variant-aurora-BUOVgPOB.js → variant-aurora-CNmfHhcx.js} +2 -2
  213. package/dist/{variant-aurora-CUsUJvFI.js → variant-aurora-D6GsdTPA.js} +2 -2
  214. package/dist/{variant-aurora-CW2i4bfr.js → variant-aurora-DbW_OWL2.js} +1 -1
  215. package/dist/{variant-custom-D91HjAKz.js → variant-custom-BRvaNHSi.js} +1 -1
  216. package/dist/{variant-custom-BQtOnmeO.js → variant-custom-BvYHR62b.js} +1 -1
  217. package/dist/{variant-custom-CAnzzppW.js → variant-custom-DMTrEO5w.js} +2 -2
  218. package/dist/{variant-custom-CAm9L-E5.js → variant-custom-DV2x254s.js} +2 -2
  219. package/dist/{variant-wave-Ca1Ls4_y.js → variant-wave-BNMGrDfj.js} +2 -2
  220. package/dist/{variant-wave-uY5crU_K.js → variant-wave-BpDd8t3Z.js} +1 -1
  221. package/dist/{variant-wave-CxX39DKd.js → variant-wave-CyBueXj9.js} +2 -2
  222. package/dist/{variant-wave-DYyzIIZv.js → variant-wave-sp-qwsdI.js} +1 -1
  223. package/dist/x-Z5UntkIJ.js +1 -0
  224. package/frameworks/react/index.tsx +14 -4
  225. package/llms-full.txt +7 -2
  226. package/package.json +1 -1
  227. package/src/agent-tooling/README.md +192 -0
  228. package/src/agent-tooling/catalog/invariants.ts +2 -2
  229. package/src/agent-tooling/construct/cli.ts +16 -0
  230. package/src/agent-tooling/construct/codegen.ts +309 -27
  231. package/src/agent-tooling/construct/construct.v1.schema.json +69 -0
  232. package/src/agent-tooling/construct/fixtures/owner-widget.construct.json +11 -2
  233. package/src/agent-tooling/construct/schema.ts +81 -0
  234. package/src/components/chat-thread.tsx +532 -36
  235. package/src/components/conversation-item.tsx +23 -0
  236. package/src/components/conversation-panel.tsx +118 -0
  237. package/src/components/home-panel.tsx +159 -0
  238. package/src/components/widget-tab-bar.tsx +73 -0
  239. package/src/elements/chat.tsx +94 -2
  240. package/src/elements/compiled.css +1 -1
  241. package/src/elements/element-meta.json +49 -6
  242. package/src/elements/element-nonscalar.json +2 -0
  243. package/src/elements/element-types.d.ts +20 -4
  244. package/src/index.ts +3 -1
  245. package/src/primitives/conversation-store.ts +248 -0
  246. package/src/solid.ts +10 -2
  247. package/src/types.ts +45 -3
  248. package/src/ui/dock.tsx +47 -1
  249. package/theme.css +28 -0
  250. package/dist/arrow-down-Br0qtpsz.js +0 -1
  251. package/dist/arrow-left-Dj7xgE12.js +0 -1
  252. package/dist/check-DPeeMUYx.js +0 -1
  253. package/dist/chevron-down-CHSWk7ZT.js +0 -1
  254. package/dist/chevron-right-B7l_fMgx.js +0 -1
  255. package/dist/circle-Bb0yOpqM.js +0 -1
  256. package/dist/circle-check-BGZpCiz7.js +0 -1
  257. package/dist/code-block-CUQ5mtv0.js +0 -1
  258. package/dist/controllable-D43BKmtX.js +0 -1
  259. package/dist/conversation-list-D4lLU_yS.js +0 -1
  260. package/dist/define-CGGX-7Vg.js +0 -1
  261. package/dist/message-circle-Xf8Q-vZp.js +0 -1
  262. package/dist/message-square-Cxnwgkns.js +0 -1
  263. package/dist/play-OFIvYXUQ.js +0 -1
  264. package/dist/register-impl-C7rENvPK.js +0 -424
  265. package/dist/store-7eoadydQ.js +0 -1
  266. package/dist/x-C5m1JFgi.js +0 -1
@@ -6,10 +6,11 @@ import { MediaTypeFilter } from '../wire/media-types.js';
6
6
  import { TriggerDef } from './composer.js';
7
7
  import { ChatMessage } from '../elements/chat-types.js';
8
8
  import { ProseSize } from '../primitives/chat-config.js';
9
- import { ModelOption } from '../types.js';
9
+ import { ModelOption, HomeConfig, HomeLinkEntry } from '../types.js';
10
10
  import { CardComponentMap } from '../primitives/card-registry.js';
11
11
  import { CardSchemaMap } from './card-renderer.js';
12
12
  import { JSX } from 'solid-js';
13
+ import { ConversationStore } from '../primitives/conversation-store.js';
13
14
  export interface ChatThreadContextUsage {
14
15
  usedTokens: number;
15
16
  maxTokens: number;
@@ -108,6 +109,79 @@ export interface ChatThreadProps {
108
109
  * toward `showHeader()` the same as `headerEnd`, so a construct with no title
109
110
  * and only this content still gets a header row to sit in. */
110
111
  headerEndContent?: JSX.Element;
112
+ /** Turns on the prior-conversations list: a list-toggle button appears in
113
+ * the header row and the panel gains a second, list, view (C-1 — one
114
+ * panel, two states, never a persistent sidebar). Off by default, same
115
+ * convention as every other capability in this file. Requires BOTH
116
+ * `store` AND `onConversationLoad` — the second is the only path a caller
117
+ * has to actually receive a loaded conversation's messages back (this
118
+ * component never mutates `props.messages` itself). Set with either
119
+ * missing, the feature decides loudly (one `console.error` on mount) and
120
+ * stays visually off rather than throwing or silently going inert: a
121
+ * `store` with no `onConversationLoad` would otherwise make row-select/
122
+ * new/restore fire and do nothing visible, and mount's own auto-restore
123
+ * would still stamp an active conversation id that the save effect could
124
+ * then clobber with whatever `props.messages` the caller drives in next. */
125
+ conversations?: boolean;
126
+ /** The adapter this thread persists through when `conversations` is on:
127
+ * `list()` on mount and on every list-view open, `load(id)` on row select,
128
+ * `save(id, messages)` on every message-array change for the active
129
+ * conversation. A kit-owned INTERFACE (C-3) — the dev owns invocation,
130
+ * transport, auth and retention entirely; `localStorageStore`/`fetchStore`
131
+ * (`@kitn.ai/ui`'s `primitives/conversation-store`) are the shipped
132
+ * built-ins. Set as a JS property; never expressible as an attribute (an
133
+ * adapter is a live object of functions, not scalar data). */
134
+ store?: ConversationStore;
135
+ /** Fires whenever `load(id)` resolves and this thread's `messages` are
136
+ * about to be replaced with that conversation's history — the hook a
137
+ * caller uses to actually own and re-render `messages` (this component
138
+ * does not mutate `props.messages` itself; C-8 keeps the state machine
139
+ * here but the message ARRAY stays the caller's own state, matching every
140
+ * other prop in this file). The second argument is the conversation's id
141
+ * — `undefined` for the "new conversation" case (C-6: no id exists until
142
+ * the first message mints one). Required whenever `conversations` is on;
143
+ * see that prop's own doc for the guard this component runs without it. */
144
+ onConversationLoad?: (messages: ChatMessage[], id?: string) => void;
145
+ /** Whether the surrounding chrome that HOSTS this thread is currently
146
+ * VISIBLE to the visitor — e.g. a docked widget's open/closed state.
147
+ * `ChatThread` has no knowledge of whatever hosts it (a `Dock`, a plain
148
+ * page, anything — same boundary `closeConversationsList` documents), so
149
+ * this is the seam: a host that can hide itself sets it, everyone else
150
+ * leaves it unset.
151
+ *
152
+ * Meaningful only when `conversations` is on, where it's the third leg of
153
+ * "seen" (owner round, 2026-08-26 — unread indicators): the active
154
+ * conversation counts as seen, and gets `store.markRead` called for it,
155
+ * only while it's ALSO the active conversation AND the chat view (not the
156
+ * list) is showing AND this is true. Undeclared/`true` (the default) means
157
+ * "always visible" — correct for every layout with no show/hide concept at
158
+ * all (fullscreen/aside/split/custom) and for any widget consumer that
159
+ * doesn't wire it, which just means unread never distinguishes "closed"
160
+ * from "open" for them (a smaller inaccuracy than the alternative: without
161
+ * this leg, a message arriving to the active conversation while the
162
+ * widget is actually closed would get silently marked read behind the
163
+ * visitor's back, purely because it happened to be the active id). */
164
+ hostOpen?: boolean;
165
+ /** Fires whenever "is any OTHER conversation (not the active one) unread"
166
+ * changes — the value this thread already renders as a dot on its own
167
+ * header toggle, reported outward so a sibling control with no view into
168
+ * `ChatThread`'s internal conversation-summary state (a `Dock`'s own
169
+ * `unread` prop, say) can mirror it. Only meaningful with `conversations`
170
+ * on; never fires otherwise. */
171
+ onUnreadChange?: (unread: boolean) => void;
172
+ /** Turns on the widget home screen (Intercom-pattern, H-1/H-2): the panel
173
+ * boots into a `home` view — greeting, most-recent-conversation card, a
174
+ * "new conversation" CTA, and host-defined links — with a Home/Messages
175
+ * tab bar beneath the content area. The prior-conversations list moves
176
+ * from the header toggle onto the Messages tab (H-2); a drilled-into chat
177
+ * (from a list row, the recent card, or "new conversation") hides the tab
178
+ * bar and shows a back arrow in the header instead. Off by default: unset,
179
+ * the widget renders byte-for-byte as it does today. */
180
+ home?: HomeConfig;
181
+ /** Fires when a `home.links` entry with no `href` is activated (an
182
+ * `href`-bearing entry navigates as a real anchor instead — see
183
+ * `HomePanelProps.onLink`). Meaningful only when `home` is set. */
184
+ onHomeLink?: (entry: HomeLinkEntry) => void;
111
185
  /** REPLACE: full custom header in place of the built-in title/model/context bar. */
112
186
  headerFull?: boolean;
113
187
  /** INJECT: left sidebar column (e.g. a conversation list / your own nav). */
@@ -178,5 +252,19 @@ export interface ChatThreadController {
178
252
  clear(): void;
179
253
  send(): void;
180
254
  scrollToBottom(behavior?: ScrollBehavior): void;
255
+ /** Force the widget back to its default landing view — `'home'` when the
256
+ * `home` prop is set (H-5), `'chat'` otherwise (a no-op if already there,
257
+ * or if neither `home` nor `conversations` is on). ChatThread has no knowledge of
258
+ * whatever chrome hosts it — a `Dock`, a plain page, anything — so it
259
+ * cannot know when that host closes. The seam is this one imperative
260
+ * call: a host that can go from visible to hidden and back (the `kai-dock`
261
+ * widget being the motivating case) calls it on every hide, so the NEXT
262
+ * open always lands on the chat view rather than wherever the list was
263
+ * left (owner: reopening the widget should show the default screen, not
264
+ * a stale list view). `Dock`'s own `onOpenChange` already fires on every
265
+ * close path — header X, the launcher toggle, and Escape — so a single
266
+ * `onOpenChange={(open) => !open && controller.closeConversationsList()}`
267
+ * at the call site covers all three with no per-path wiring. */
268
+ closeConversationsList(): void;
181
269
  }
182
270
  export declare function ChatThread(props: ChatThreadProps): JSX.Element;
@@ -15,6 +15,22 @@ export interface ConversationItemProps {
15
15
  * ticking clock. Returns '' for a missing or unparseable date.
16
16
  */
17
17
  export declare function relativeTimeShort(iso?: string, now?: number): string;
18
+ /**
19
+ * Whether a conversation should show an unread indicator (owner round,
20
+ * 2026-08-26). `lastReadAt`'s own doc (`types.ts`) has the full contract;
21
+ * this is the one place that reads it, so both list surfaces (this file's
22
+ * `ConversationItem` and the widget-box `ConversationPanel`) derive it
23
+ * identically rather than each restating the comparison.
24
+ *
25
+ * Absent `lastReadAt` reads as NOT unread — the decide-loudly default for a
26
+ * store that never implements `ConversationStore.markRead` at all (every
27
+ * summary it returns leaves the field undefined forever, so this always
28
+ * returns `false` for it) rather than guessing "probably unread" from a
29
+ * signal the store never actually provided. Defensive `Date.parse`, same
30
+ * pattern as `relativeTimeShort` above: an unparsable date reads as not
31
+ * unread rather than throwing.
32
+ */
33
+ export declare function isConversationUnread(conv: Pick<ConversationSummary, 'updatedAt' | 'lastReadAt'>): boolean;
18
34
  /**
19
35
  * The slotted-item shape rendered by `<kai-conversation-item>` — the composed
20
36
  * row of the consumer-owned loop. Distinct from the
@@ -0,0 +1,29 @@
1
+ import { ConversationSummary } from '../types.js';
2
+ export interface ConversationPanelProps {
3
+ conversations: ConversationSummary[];
4
+ activeId?: string;
5
+ onSelect: (id: string) => void;
6
+ onNewChat: () => void;
7
+ /** Wording for the floating new-conversation pill. Defaults to "New conversation". */
8
+ newChatLabel?: string;
9
+ class?: string;
10
+ }
11
+ /**
12
+ * The widget-box list view (owner rework, 2026-08-26 — the earlier retrofit
13
+ * of the desktop `ConversationList` into this box was rejected at the live
14
+ * demo). NOT `ConversationList`, which stays the desktop-sidebar surface
15
+ * unchanged: no search box, no group headers, no per-row menu, no full-width
16
+ * footer bar, no second "+" beside the header toggle. A row is a
17
+ * conversation, full stop — bold title, right-aligned relative time, one
18
+ * truncated line of the last message. The ONE way to start a new
19
+ * conversation is the floating pill near the bottom.
20
+ *
21
+ * Modeled directly on Intercom's Messenger "Messages" tab (first-hand
22
+ * research: `.superpowers/sdd/2026-08-26-conversations/
23
+ * research-intercom-messages-view.md`) — a box this size gets one job at a
24
+ * time: browsing conversations OR having one, never both, and the list
25
+ * replaces the ENTIRE content area (`ChatThread` hides the thread,
26
+ * suggestions and composer while this renders — see its `view() === 'list'`
27
+ * branch).
28
+ */
29
+ export declare function ConversationPanel(props: ConversationPanelProps): import("solid-js").JSX.Element;
@@ -0,0 +1,34 @@
1
+ import { ConversationSummary, HomeLinkEntry } from '../types.js';
2
+ export interface HomePanelProps {
3
+ greeting?: {
4
+ title?: string;
5
+ subtitle?: string;
6
+ };
7
+ /** The most-recent conversation, host-derived. `undefined` hides the card
8
+ * entirely — this component never fetches or picks one itself. */
9
+ recent?: ConversationSummary;
10
+ /** Defaults to `true`. */
11
+ showNewConversation?: boolean;
12
+ /** Defaults to `'Send us a message'`. */
13
+ newChatLabel?: string;
14
+ links?: HomeLinkEntry[];
15
+ onSelectRecent?: (id: string) => void;
16
+ onNewChat: () => void;
17
+ /** Fired only for href-less link entries — an entry with a safe `href`
18
+ * navigates as a real anchor instead. */
19
+ onLink?: (entry: HomeLinkEntry) => void;
20
+ class?: string;
21
+ }
22
+ /**
23
+ * The widget home screen (Intercom-pattern, H-1): greeting, the most-recent
24
+ * conversation, a "start a new conversation" CTA, and a list of host-defined
25
+ * links. Pure props in, events out — no fetching, no routing; a later task
26
+ * wires this behind `ChatThread`'s Home/Messages tab bar.
27
+ *
28
+ * Unsafe-href rule: a `links` entry with an `href` that fails `isSafeUrl`
29
+ * (e.g. `javascript:`) is NOT silently promoted into a button/event-emitter —
30
+ * that would let a host-authored-but-attacker-influenced config still fire a
31
+ * handler off a scheme SAFE_SCHEMES rejects. It renders as a plain,
32
+ * non-interactive row: label visible, no anchor, no button, no click handler.
33
+ */
34
+ export declare function HomePanel(props: HomePanelProps): import("solid-js").JSX.Element;
@@ -0,0 +1,16 @@
1
+ export interface WidgetTabBarProps {
2
+ active: 'home' | 'messages';
3
+ onChange: (tab: 'home' | 'messages') => void;
4
+ /** Whether the Messages tab has unread activity. Reaches BOTH the visible
5
+ * dot and the tab's accessible name (`aria-label`) — a dot alone is
6
+ * invisible to assistive tech, the #336 lesson this test pins. */
7
+ unread?: boolean;
8
+ homeLabel?: string;
9
+ messagesLabel?: string;
10
+ }
11
+ /**
12
+ * The widget's Home/Messages tab bar (Intercom-pattern chrome, H-2/H-6). Real
13
+ * `tablist`/`tab` semantics — this is a persistent view switch within the
14
+ * widget, not page navigation, so it is not `<Nav>`'s `role="page"` dialect.
15
+ */
16
+ export declare function WidgetTabBar(props: WidgetTabBarProps): import("solid-js").JSX.Element;
@@ -1,4 +1,4 @@
1
- import{A as Ye,g as z,w as Je,k as Z,j as de,o as ue,x as De,h as Ze,i as N,u as Ne,a as H,d as O,b as Q,l as ee,c as $,F as Oe,S as G,t as S,O as Qe,e as et}from"./define-CGGX-7Vg.js";import{c as P}from"./cn-DN5AWfiS.js";import{u as tt,c as nt,a as rt}from"./overlay-C1od6LOz.js";function M(n){if(n==null)return[];if(typeof n=="string")return n.length?[{type:"text",text:n}]:[];const l=[];for(const t of n)if(t.type==="text"){if(!t.text)continue;const i=l[l.length-1];i&&i.type==="text"?l[l.length-1]={type:"text",text:i.text+t.text}:l.push({type:"text",text:t.text})}else l.push({type:"entity",entity:t.entity});return l}function te(n,l){let t="";for(const i of n)i.type==="text"?t+=i.text:t+=i.entity.promptText??i.entity.label;return t}function he(n){return n.filter(l=>l.type==="entity").map(l=>l.entity)}function ne(n){return n.every(l=>l.type==="text"&&l.text.length===0)}const C="\u200B",pe="data-kai-entity",fe=new WeakMap;function U(n){return!!n&&n.nodeType===1&&n.hasAttribute(pe)}function re(n){return n.ownerDocument.createTreeWalker(n,NodeFilter.SHOW_TEXT,{acceptNode(l){let t=l.parentElement;for(;t&&t!==n;){if(t.hasAttribute(pe))return NodeFilter.FILTER_REJECT;t=t.parentElement}return NodeFilter.FILTER_ACCEPT}})}function ot(n){switch(n){case"skill":return"/";case"agent":return"@";default:return""}}function Le(n){const l=t=>`<svg viewBox="0 0 24 24" width="1em" height="1em" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`;switch(n){case"agent":return l('<rect x="4" y="8" width="16" height="12" rx="3"/><path d="M12 4.5V8M9.5 13.5v1.5M14.5 13.5v1.5"/><circle cx="12" cy="3" r="1.2"/>');case"plugin":return l('<path d="M9 2v4M15 2v4M6 6h12v5a6 6 0 0 1-12 0zM12 17v5"/>');default:return""}}function Ie(n,l,t){const i=n.createElement("span");i.setAttribute(pe,""),i.setAttribute("contenteditable","false"),i.dataset.kind=l.kind,i.dataset.id=l.id,i.className="kai-composer-pill";const u=ot(l.kind);if(u){const s=n.createElement("span");s.className="kai-composer-pill-sigil",s.setAttribute("aria-hidden","true"),s.textContent=u,i.appendChild(s)}else{const s=l.icon??t?.[l.kind];if(s){const h=n.createElement("img");h.src=s,h.alt="",h.className="kai-composer-pill-icon",i.appendChild(h)}else{const h=Le(l.kind);if(h){const f=n.createElement("span");f.className="kai-composer-pill-icon kai-composer-pill-glyph",f.setAttribute("aria-hidden","true"),f.innerHTML=h,i.appendChild(f)}}}return i.appendChild(n.createTextNode(l.label)),fe.set(i,l),i}function L(n){const l=[],t=n.childNodes;return t.forEach((i,u)=>{if(U(i)){const s=fe.get(i),h=i;l.push({type:"entity",entity:s??{kind:h.dataset.kind??"",id:h.dataset.id??"",label:h.textContent??""}})}else if(i.nodeType===1&&i.tagName==="BR"){if(u===t.length-1)return;l.push({type:"text",text:`
1
+ import{A as Ye,g as z,w as Je,k as Q,j as de,o as ue,x as De,h as Qe,i as N,u as Ne,a as H,d as O,b as Z,l as ee,c as $,F as Oe,S as G,t as S,Q as Ze,e as et}from"./define-By-uL588.js";import{c as P}from"./cn-DN5AWfiS.js";import{u as tt,c as nt,a as rt}from"./overlay-Cb-MkyDa.js";function M(n){if(n==null)return[];if(typeof n=="string")return n.length?[{type:"text",text:n}]:[];const l=[];for(const t of n)if(t.type==="text"){if(!t.text)continue;const i=l[l.length-1];i&&i.type==="text"?l[l.length-1]={type:"text",text:i.text+t.text}:l.push({type:"text",text:t.text})}else l.push({type:"entity",entity:t.entity});return l}function te(n,l){let t="";for(const i of n)i.type==="text"?t+=i.text:t+=i.entity.promptText??i.entity.label;return t}function he(n){return n.filter(l=>l.type==="entity").map(l=>l.entity)}function ne(n){return n.every(l=>l.type==="text"&&l.text.length===0)}const C="\u200B",pe="data-kai-entity",fe=new WeakMap;function U(n){return!!n&&n.nodeType===1&&n.hasAttribute(pe)}function re(n){return n.ownerDocument.createTreeWalker(n,NodeFilter.SHOW_TEXT,{acceptNode(l){let t=l.parentElement;for(;t&&t!==n;){if(t.hasAttribute(pe))return NodeFilter.FILTER_REJECT;t=t.parentElement}return NodeFilter.FILTER_ACCEPT}})}function ot(n){switch(n){case"skill":return"/";case"agent":return"@";default:return""}}function Le(n){const l=t=>`<svg viewBox="0 0 24 24" width="1em" height="1em" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`;switch(n){case"agent":return l('<rect x="4" y="8" width="16" height="12" rx="3"/><path d="M12 4.5V8M9.5 13.5v1.5M14.5 13.5v1.5"/><circle cx="12" cy="3" r="1.2"/>');case"plugin":return l('<path d="M9 2v4M15 2v4M6 6h12v5a6 6 0 0 1-12 0zM12 17v5"/>');default:return""}}function Ie(n,l,t){const i=n.createElement("span");i.setAttribute(pe,""),i.setAttribute("contenteditable","false"),i.dataset.kind=l.kind,i.dataset.id=l.id,i.className="kai-composer-pill";const u=ot(l.kind);if(u){const s=n.createElement("span");s.className="kai-composer-pill-sigil",s.setAttribute("aria-hidden","true"),s.textContent=u,i.appendChild(s)}else{const s=l.icon??t?.[l.kind];if(s){const h=n.createElement("img");h.src=s,h.alt="",h.className="kai-composer-pill-icon",i.appendChild(h)}else{const h=Le(l.kind);if(h){const f=n.createElement("span");f.className="kai-composer-pill-icon kai-composer-pill-glyph",f.setAttribute("aria-hidden","true"),f.innerHTML=h,i.appendChild(f)}}}return i.appendChild(n.createTextNode(l.label)),fe.set(i,l),i}function L(n){const l=[],t=n.childNodes;return t.forEach((i,u)=>{if(U(i)){const s=fe.get(i),h=i;l.push({type:"entity",entity:s??{kind:h.dataset.kind??"",id:h.dataset.id??"",label:h.textContent??""}})}else if(i.nodeType===1&&i.tagName==="BR"){if(u===t.length-1)return;l.push({type:"text",text:`
2
2
  `})}else i.nodeType===3&&l.push({type:"text",text:(i.textContent??"").split(C).join("")})}),M(l)}function oe(n,l,t=document,i){n.textContent="";for(const u of l)u.type==="text"?n.appendChild(t.createTextNode(u.text)):(n.appendChild(Ie(t,u.entity,i)),n.appendChild(t.createTextNode(C)))}function it(n,l,t){if(l<0||l>n.length)return null;for(let i=l-1;i>=0;i--){const u=n[i];if(/\s/.test(u))return null;if(t.includes(u))return i===0||/\s/.test(n[i-1])?{char:u,query:n.slice(i+1,l),start:i}:null}return null}function at(n,l,t){if(!t.length)return null;const i=t.map(h=>h.char),u=it(n,l,i);if(!u)return null;const s=t.find(h=>h.char===u.char);return s?{def:s,query:u.query,start:u.start}:null}function lt(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function st(n,l){const t=[];for(const s of l){let h,f;typeof s=="string"?(h=new RegExp(lt(s),"gi"),f=void 0):(h=new RegExp(s.pattern,s.flags??"gi"),f=s.class),h.lastIndex=0;let k;for(;(k=h.exec(n))!==null;){const x=k.index,w=x+k[0].length;if(w===x){h.lastIndex=x+1;continue}t.push({start:x,end:w,class:f})}}t.sort((s,h)=>s.start-h.start);const i=[];let u=-1;for(const s of t)s.start>=u&&(i.push(s),u=s.end);return i}function ct(){try{return typeof CSS<"u"&&typeof CSS.highlights<"u"&&typeof Highlight<"u"}catch{return!1}}const dt="kai-composer-highlight";function ut(n,l,t,i=dt){if(!ct())return;const u=CSS.highlights;if(l.length===0){u.delete(i);return}const s=[];let h=0;const f=n.ownerDocument,k=re(n);let x=k.nextNode();for(;x;){const v=x.textContent??"",b=[];for(let p=0;p<v.length;p++)v[p]!==t&&b.push(p);if(b.length>0){const p=new Int32Array(b.length);for(let m=0;m<b.length;m++)p[m]=b[m];s.push({node:x,strippedStart:h,strippedToRaw:p}),h+=b.length}x=k.nextNode()}function w(v){let b=0,p=s.length-1;for(;b<=p;){const m=b+p>>1,T=s[m],q=T.strippedStart+T.strippedToRaw.length;if(v<T.strippedStart)p=m-1;else if(v>=q)b=m+1;else{const R=v-T.strippedStart;return{node:T.node,rawOffset:T.strippedToRaw[R]}}}if(s.length>0){const m=s[s.length-1];if(v-m.strippedStart===m.strippedToRaw.length)return{node:m.node,rawOffset:m.strippedToRaw[m.strippedToRaw.length-1]+1}}return null}const y=[];for(const v of l){const b=w(v.start),p=w(v.end);if(!b||!p)continue;const m=f.createRange();m.setStart(b.node,b.rawOffset),m.setEnd(p.node,p.rawOffset),y.push(m)}if(y.length===0){u.delete(i);return}const A=new Highlight(...y);u.set(i,A)}function ht(n,l=200){let t=[n],i=0;return{record(u,s){if(s&&i===t.length-1){t[i]=u;return}t=t.slice(0,i+1),t.push(u),t.length>l?t.shift():i++},undo(){return i===0?null:(i--,t[i])},redo(){return i>=t.length-1?null:(i++,t[i])},reset(u){t=[u],i=0},canUndo(){return i>0},canRedo(){return i<t.length-1},size(){return t.length}}}var pt=S("<style>"),ft=S(`<style>
3
3
  .kai-composer-pill {
4
4
  display: inline-flex; align-items: center; gap: 0.2rem;
@@ -78,7 +78,7 @@ import{A as Ye,g as z,w as Je,k as Z,j as de,o as ue,x as De,h as Ze,i as N,u as
78
78
  color: var(--color-muted-foreground, #9ca3af);
79
79
  pointer-events: none;
80
80
  }
81
- `),gt=S("<div class=relative><div data-kai-composer-editable role=textbox aria-multiline=true>"),mt=S("<div role=listbox aria-label=Suggestions style=position:fixed>"),kt=S('<div class="px-3 pt-2 pb-1 text-xs font-medium text-muted-foreground select-none">'),yt=S('<span class="text-muted-foreground truncate min-w-0">'),vt=S('<button role=option><span class="font-medium whitespace-nowrap shrink-0">'),bt=S('<span class="kai-composer-pill-glyph w-4 h-4 shrink-0"aria-hidden=true>'),xt=S('<img alt class="w-4 h-4 rounded object-cover shrink-0">'),wt=S("<div>");function E(n){var l;const t=n.getRootNode();return typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&typeof t.getSelection=="function"?t.getSelection():((l=n.ownerDocument)==null?void 0:l.getSelection())??null}function $e(n){let l="";const t=re(n);let i=t.nextNode();for(;i;)l+=(i.textContent??"").split(C).join(""),i=t.nextNode();return l}function ge(n){const l=E(n);if(!l||l.rangeCount===0)return 0;const t=l.getRangeAt(0);if(!t.collapsed)return 0;const{startContainer:i,startOffset:u}=t;let s=0;const h=re(n);let f=h.nextNode();for(;f;){if(f===i){const k=(f.textContent??"").slice(0,u);return s+=k.split(C).join("").length,s}s+=(f.textContent??"").split(C).join("").length,f=h.nextNode()}return s}function Ct(n){const l=n.ownerDocument,t=E(n);if(!t||t.rangeCount===0)return null;const i=t.getRangeAt(0).cloneRange();i.collapse(!0);const u=i.getClientRects();if(u.length>0&&(u[0].width>0||u[0].height>0))return u[0];const s=l.createElement("span");s.textContent="\u200B",s.style.position="absolute",s.style.visibility="hidden",i.insertNode(s);const h=s.getBoundingClientRect();return s.remove(),h.width>0||h.height>0?h:null}function Tt(n,l){const t=E(n);if(!t)return;const i=n.ownerDocument.createRange(),u=re(n);let s=l,h=u.nextNode(),f=!1;for(;h;){const k=h.textContent??"",x=k.split(C).join("").length;if(s<=x){let w=0,y=0;for(;w<k.length&&y<s;)k[w]!==C&&y++,w++;for(;w<k.length&&k[w]===C;)w++;i.setStart(h,w),f=!0;break}s-=x,h=u.nextNode()}f?i.collapse(!0):(i.selectNodeContents(n),i.collapse(!1)),t.removeAllRanges(),t.addRange(i)}function Rt(n){const l=Ye();let t;const[i,u]=z(),s=`kai-composer-highlight-${Je()}`,[h,f]=z(ne(M(n.value))),[k,x]=z(null),w=e=>{const r=k();r&&r!==e&&r.removeAttribute("data-selected"),e.setAttribute("data-selected",""),x(e)},y=()=>{const e=k();e&&(e.removeAttribute("data-selected"),x(null))},A=ht({doc:M(n.value),caret:0});let v=0;const b=500,[p,m]=z(null),[T,q]=z(0),R=Z(()=>{const e=p();if(!(e!=null&&e.def.items))return[];const r=new Set(he(L(t)).map(o=>`${o.kind}:${o.id}`)),a=e.query.toLowerCase();return e.def.items.filter(o=>{var c;const d=o.kind??e.def.kind;return r.has(`${d}:${o.id}`)?!1:a===""?!0:o.label.toLowerCase().includes(a)||(((c=o.description)==null?void 0:c.toLowerCase().includes(a))??!1)})}),Me=Z(()=>{const e=[];return R().forEach((r,a)=>{let o=e.find(c=>c.group===r.group);o||(o={group:r.group,items:[]},e.push(o)),o.items.push({item:r,index:a})}),e}),ie=Z(()=>R().length>0),me=e=>{var r;return e.kind??((r=p())==null?void 0:r.def.kind)??""},qe=e=>{var r;return e.icon??((r=n.kindIcons)==null?void 0:r[me(e)])};de(()=>{const e=R().length;T()>=e&&q(Math.max(0,e-1))});const Be=Z(()=>{const e=p();if(!e)return;const r=e.caretRect;return{getBoundingClientRect:()=>r}}),{pos:ke,hidden:Ke}=tt(Be,i,{placement:"bottom-start",gutter:4}),{present:je,state:He,setRef:Fe}=nt(ie);rt({enabled:ie,onDismiss:()=>B(),refs:()=>[t,i()]});function B(){var e;p()&&(m(null),(e=n.onTriggerClose)==null||e.call(n))}const K=()=>{const e=L(t);return{doc:e,text:te(e),entities:he(e)}};function X(){const e=n.highlights,r=e!=null&&e.length?st($e(t),e):[];ut(t,r,C,s)}ue(()=>{oe(t,M(n.value),t.ownerDocument,n.kindIcons),f(ne(L(t))),X(),A.reset({doc:L(t),caret:0})}),de(De(()=>n.value,e=>{te(M(e))!==te(L(t))&&(y(),oe(t,M(e),t.ownerDocument,n.kindIcons),f(ne(L(t))),X(),A.reset({doc:L(t),caret:0}))},{defer:!0})),de(De(()=>n.highlights,()=>X(),{defer:!0}));function ye(){var e;const r=n.triggers;if(!(r!=null&&r.length)){p()&&B();return}const a=$e(t),o=ge(t),c=at(a,o,r);if(c){const d=Ct(t);if(d){const g=p();m({def:c.def,query:c.query,start:c.start,caretRect:d}),(!g||g.def.char!==c.def.char||g.query!==c.query)&&((e=n.onTrigger)==null||e.call(n,{char:c.def.char,query:c.query,rect:d}))}}else p()&&B()}const W=e=>{var r;f(ne(e.doc)),(r=n.onChange)==null||r.call(n,e),ye(),X()},_e=()=>{y();const e=K();W(e);const r=Date.now();A.record({doc:e.doc,caret:ge(t)},r-v<b),v=r},ve=()=>{const e=K();W(e),A.record({doc:e.doc,caret:ge(t)},!1),v=0},be=e=>{y(),oe(t,e.doc,t.ownerDocument,n.kindIcons),Tt(t,e.caret),W(K()),v=0},ze=()=>{const e=A.undo();e&&be(e)},xe=()=>{const e=A.redo();e&&be(e)};let ae=!1;const Ge=e=>{var r;ae=!0,(r=n.onFocus)==null||r.call(n,e)},Pe=e=>{var r;ae=!1,y(),(r=n.onBlur)==null||r.call(n,e)};ue(()=>{const e=t.ownerDocument,r=()=>{ae&&ye()};e.addEventListener("selectionchange",r),Ze(()=>e.removeEventListener("selectionchange",r))}),ue(()=>{var e;(e=n.controllerRef)==null||e.call(n,{focus:r=>t.focus(r),blur:()=>t.blur(),clear:()=>{y(),oe(t,[],t.ownerDocument,n.kindIcons),W(K()),A.reset({doc:L(t),caret:0}),v=0},send:()=>{var r;return(r=n.onSubmit)==null?void 0:r.call(n,K())},insertEntity:r=>Ce(r)})});function we(e){const r=p();if(!r)return;const a={kind:e.kind??r.def.kind,id:e.id,label:e.label,icon:e.icon,promptText:e.promptText,data:e.data};Ce(a,{deleteBefore:1+r.query.length}),B()}const Ce=(e,r)=>{var a;const o=t.ownerDocument,c=E(t);if(!c||c.rangeCount===0)return;const d=c.getRangeAt(0);if(r!=null&&r.deleteBefore&&d.collapsed){let Y=r.deleteBefore,j=d.startContainer,_=d.startOffset;for(;Y>0&&j&&j.nodeType===3;){const Ve=j.textContent??"";for(;_>0&&Y>0;)_--,Ve[_]!==C&&Y--;if(Y>0){const J=j.previousSibling;if(J&&J.nodeType===3)j=J,_=(J.textContent??"").length;else break}}const ce=o.createRange();ce.setStart(j,_),ce.setEnd(d.startContainer,d.startOffset),ce.deleteContents()}const g=c.getRangeAt(0);g.collapsed||g.deleteContents();const I=Ie(o,e,n.kindIcons),D=o.createTextNode(C);g.insertNode(D),g.insertNode(I);const se=o.createRange();se.setStartAfter(D),se.collapse(!0),c.removeAllRanges(),c.addRange(se),(a=n.onEntityAdd)==null||a.call(n,e),ve()},V=e=>(e??"").split("").every(r=>r===C),F=e=>!!e&&e.nodeType===Node.TEXT_NODE&&V(e.textContent),Te=e=>{const{startContainer:r,startOffset:a}=e;if(r===t){let o=a-1;for(;F(t.childNodes[o]);)o--;const c=t.childNodes[o];return U(c)?c:null}if(r.nodeType===Node.TEXT_NODE){if(!V((r.textContent??"").slice(0,a)))return null;let o=r.previousSibling;for(;F(o);)o=o.previousSibling;return U(o)?o:null}return null},Re=e=>{const{startContainer:r,startOffset:a}=e;if(r===t){let o=a;for(;F(t.childNodes[o]);)o++;const c=t.childNodes[o];return U(c)?c:null}if(r.nodeType===Node.TEXT_NODE){if(!V((r.textContent??"").slice(a)))return null;let o=r.nextSibling;for(;F(o);)o=o.nextSibling;return U(o)?o:null}return null},Se=e=>{var r;const a=fe.get(e),o=e.nextSibling;o?.nodeType===Node.TEXT_NODE&&V(o.textContent)&&o.remove(),e.remove(),a&&((r=n.onEntityRemove)==null||r.call(n,a)),ve()},Ue=e=>{const r=E(t);if(!r)return;const a=t.ownerDocument.createRange();a.setStartBefore(e),a.collapse(!0),r.removeAllRanges(),r.addRange(a)},Ae=e=>{const r=E(t);if(!r)return;let a=e;for(;F(a.nextSibling);)a=a.nextSibling;const o=t.ownerDocument.createRange();o.setStartAfter(a),o.collapse(!0),r.removeAllRanges(),r.addRange(o)},Xe=e=>{var r;if((e.metaKey||e.ctrlKey)&&(e.key==="z"||e.key==="Z")){e.preventDefault(),e.shiftKey?xe():ze();return}if((e.metaKey||e.ctrlKey)&&(e.key==="y"||e.key==="Y")){e.preventDefault(),xe();return}if(ie()&&R().length>0){if(e.key==="ArrowDown"){e.preventDefault(),q(o=>(o+1)%R().length);return}if(e.key==="ArrowUp"){e.preventDefault(),q(o=>(o-1+R().length)%R().length);return}if(e.key==="Enter"||e.key==="Tab"){const o=R();if(o.length>0){e.preventDefault(),e.stopPropagation(),we(o[T()]);return}}if(e.key==="Escape"){e.preventDefault(),B();return}}else if(p()&&e.key==="Escape"){e.preventDefault(),B();return}const a=k();if(a&&a.isConnected){if(e.key==="ArrowLeft"){e.preventDefault(),Ue(a),y();return}if(e.key==="ArrowRight"){e.preventDefault(),Ae(a),y();return}if(e.key==="Backspace"||e.key==="Delete"){e.preventDefault();const o=a.previousSibling;y(),Se(a);const c=E(t);if(c){const d=t.ownerDocument.createRange();o&&o.isConnected?d.setStartAfter(o):d.setStart(t,0),d.collapse(!0),c.removeAllRanges(),c.addRange(d)}return}if(e.key==="Escape"){e.preventDefault(),y();return}if(e.key==="Shift"||e.key==="Meta"||e.key==="Control"||e.key==="Alt")return;Ae(a),y()}if(!k()&&(e.key==="ArrowLeft"||e.key==="ArrowRight")&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey){const o=E(t);if(o&&o.rangeCount>0){const c=o.getRangeAt(0);if(c.collapsed){const d=e.key==="ArrowLeft"?Te(c):Re(c);if(d){e.preventDefault(),w(d);return}}}}if(e.key==="Backspace"||e.key==="Delete"){const o=E(t);if(!o||o.rangeCount===0)return;const c=o.getRangeAt(0);if(!c.collapsed)return;const d=e.key==="Backspace"?Te(c):Re(c);if(d){e.preventDefault(),Se(d);return}}if(e.key==="Enter"&&!e.shiftKey&&n.submitOnEnter!==!1){if(e.preventDefault(),n.disabled||n.loading)return;(r=n.onSubmit)==null||r.call(n,K())}},le=()=>n.maxHeight??240,We=()=>n.editableClass??P("text-foreground min-h-[44px] w-full text-start overflow-y-auto whitespace-pre-wrap break-words",Qe(l.proseSize()),n.bare?"kai-focus-inset":"outline-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0"),Ee=[(()=>{var e=pt();return N(e,`
81
+ `),gt=S("<div class=relative><div data-kai-composer-editable role=textbox aria-multiline=true>"),mt=S("<div role=listbox aria-label=Suggestions style=position:fixed>"),kt=S('<div class="px-3 pt-2 pb-1 text-xs font-medium text-muted-foreground select-none">'),yt=S('<span class="text-muted-foreground truncate min-w-0">'),vt=S('<button role=option><span class="font-medium whitespace-nowrap shrink-0">'),bt=S('<span class="kai-composer-pill-glyph w-4 h-4 shrink-0"aria-hidden=true>'),xt=S('<img alt class="w-4 h-4 rounded object-cover shrink-0">'),wt=S("<div>");function E(n){var l;const t=n.getRootNode();return typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&typeof t.getSelection=="function"?t.getSelection():((l=n.ownerDocument)==null?void 0:l.getSelection())??null}function $e(n){let l="";const t=re(n);let i=t.nextNode();for(;i;)l+=(i.textContent??"").split(C).join(""),i=t.nextNode();return l}function ge(n){const l=E(n);if(!l||l.rangeCount===0)return 0;const t=l.getRangeAt(0);if(!t.collapsed)return 0;const{startContainer:i,startOffset:u}=t;let s=0;const h=re(n);let f=h.nextNode();for(;f;){if(f===i){const k=(f.textContent??"").slice(0,u);return s+=k.split(C).join("").length,s}s+=(f.textContent??"").split(C).join("").length,f=h.nextNode()}return s}function Ct(n){const l=n.ownerDocument,t=E(n);if(!t||t.rangeCount===0)return null;const i=t.getRangeAt(0).cloneRange();i.collapse(!0);const u=i.getClientRects();if(u.length>0&&(u[0].width>0||u[0].height>0))return u[0];const s=l.createElement("span");s.textContent="\u200B",s.style.position="absolute",s.style.visibility="hidden",i.insertNode(s);const h=s.getBoundingClientRect();return s.remove(),h.width>0||h.height>0?h:null}function Tt(n,l){const t=E(n);if(!t)return;const i=n.ownerDocument.createRange(),u=re(n);let s=l,h=u.nextNode(),f=!1;for(;h;){const k=h.textContent??"",x=k.split(C).join("").length;if(s<=x){let w=0,y=0;for(;w<k.length&&y<s;)k[w]!==C&&y++,w++;for(;w<k.length&&k[w]===C;)w++;i.setStart(h,w),f=!0;break}s-=x,h=u.nextNode()}f?i.collapse(!0):(i.selectNodeContents(n),i.collapse(!1)),t.removeAllRanges(),t.addRange(i)}function Rt(n){const l=Ye();let t;const[i,u]=z(),s=`kai-composer-highlight-${Je()}`,[h,f]=z(ne(M(n.value))),[k,x]=z(null),w=e=>{const r=k();r&&r!==e&&r.removeAttribute("data-selected"),e.setAttribute("data-selected",""),x(e)},y=()=>{const e=k();e&&(e.removeAttribute("data-selected"),x(null))},A=ht({doc:M(n.value),caret:0});let v=0;const b=500,[p,m]=z(null),[T,q]=z(0),R=Q(()=>{const e=p();if(!(e!=null&&e.def.items))return[];const r=new Set(he(L(t)).map(o=>`${o.kind}:${o.id}`)),a=e.query.toLowerCase();return e.def.items.filter(o=>{var c;const d=o.kind??e.def.kind;return r.has(`${d}:${o.id}`)?!1:a===""?!0:o.label.toLowerCase().includes(a)||(((c=o.description)==null?void 0:c.toLowerCase().includes(a))??!1)})}),Me=Q(()=>{const e=[];return R().forEach((r,a)=>{let o=e.find(c=>c.group===r.group);o||(o={group:r.group,items:[]},e.push(o)),o.items.push({item:r,index:a})}),e}),ie=Q(()=>R().length>0),me=e=>{var r;return e.kind??((r=p())==null?void 0:r.def.kind)??""},qe=e=>{var r;return e.icon??((r=n.kindIcons)==null?void 0:r[me(e)])};de(()=>{const e=R().length;T()>=e&&q(Math.max(0,e-1))});const Be=Q(()=>{const e=p();if(!e)return;const r=e.caretRect;return{getBoundingClientRect:()=>r}}),{pos:ke,hidden:Ke}=tt(Be,i,{placement:"bottom-start",gutter:4}),{present:je,state:He,setRef:Fe}=nt(ie);rt({enabled:ie,onDismiss:()=>B(),refs:()=>[t,i()]});function B(){var e;p()&&(m(null),(e=n.onTriggerClose)==null||e.call(n))}const K=()=>{const e=L(t);return{doc:e,text:te(e),entities:he(e)}};function X(){const e=n.highlights,r=e!=null&&e.length?st($e(t),e):[];ut(t,r,C,s)}ue(()=>{oe(t,M(n.value),t.ownerDocument,n.kindIcons),f(ne(L(t))),X(),A.reset({doc:L(t),caret:0})}),de(De(()=>n.value,e=>{te(M(e))!==te(L(t))&&(y(),oe(t,M(e),t.ownerDocument,n.kindIcons),f(ne(L(t))),X(),A.reset({doc:L(t),caret:0}))},{defer:!0})),de(De(()=>n.highlights,()=>X(),{defer:!0}));function ye(){var e;const r=n.triggers;if(!(r!=null&&r.length)){p()&&B();return}const a=$e(t),o=ge(t),c=at(a,o,r);if(c){const d=Ct(t);if(d){const g=p();m({def:c.def,query:c.query,start:c.start,caretRect:d}),(!g||g.def.char!==c.def.char||g.query!==c.query)&&((e=n.onTrigger)==null||e.call(n,{char:c.def.char,query:c.query,rect:d}))}}else p()&&B()}const W=e=>{var r;f(ne(e.doc)),(r=n.onChange)==null||r.call(n,e),ye(),X()},_e=()=>{y();const e=K();W(e);const r=Date.now();A.record({doc:e.doc,caret:ge(t)},r-v<b),v=r},ve=()=>{const e=K();W(e),A.record({doc:e.doc,caret:ge(t)},!1),v=0},be=e=>{y(),oe(t,e.doc,t.ownerDocument,n.kindIcons),Tt(t,e.caret),W(K()),v=0},ze=()=>{const e=A.undo();e&&be(e)},xe=()=>{const e=A.redo();e&&be(e)};let ae=!1;const Ge=e=>{var r;ae=!0,(r=n.onFocus)==null||r.call(n,e)},Pe=e=>{var r;ae=!1,y(),(r=n.onBlur)==null||r.call(n,e)};ue(()=>{const e=t.ownerDocument,r=()=>{ae&&ye()};e.addEventListener("selectionchange",r),Qe(()=>e.removeEventListener("selectionchange",r))}),ue(()=>{var e;(e=n.controllerRef)==null||e.call(n,{focus:r=>t.focus(r),blur:()=>t.blur(),clear:()=>{y(),oe(t,[],t.ownerDocument,n.kindIcons),W(K()),A.reset({doc:L(t),caret:0}),v=0},send:()=>{var r;return(r=n.onSubmit)==null?void 0:r.call(n,K())},insertEntity:r=>Ce(r)})});function we(e){const r=p();if(!r)return;const a={kind:e.kind??r.def.kind,id:e.id,label:e.label,icon:e.icon,promptText:e.promptText,data:e.data};Ce(a,{deleteBefore:1+r.query.length}),B()}const Ce=(e,r)=>{var a;const o=t.ownerDocument,c=E(t);if(!c||c.rangeCount===0)return;const d=c.getRangeAt(0);if(r!=null&&r.deleteBefore&&d.collapsed){let Y=r.deleteBefore,j=d.startContainer,_=d.startOffset;for(;Y>0&&j&&j.nodeType===3;){const Ve=j.textContent??"";for(;_>0&&Y>0;)_--,Ve[_]!==C&&Y--;if(Y>0){const J=j.previousSibling;if(J&&J.nodeType===3)j=J,_=(J.textContent??"").length;else break}}const ce=o.createRange();ce.setStart(j,_),ce.setEnd(d.startContainer,d.startOffset),ce.deleteContents()}const g=c.getRangeAt(0);g.collapsed||g.deleteContents();const I=Ie(o,e,n.kindIcons),D=o.createTextNode(C);g.insertNode(D),g.insertNode(I);const se=o.createRange();se.setStartAfter(D),se.collapse(!0),c.removeAllRanges(),c.addRange(se),(a=n.onEntityAdd)==null||a.call(n,e),ve()},V=e=>(e??"").split("").every(r=>r===C),F=e=>!!e&&e.nodeType===Node.TEXT_NODE&&V(e.textContent),Te=e=>{const{startContainer:r,startOffset:a}=e;if(r===t){let o=a-1;for(;F(t.childNodes[o]);)o--;const c=t.childNodes[o];return U(c)?c:null}if(r.nodeType===Node.TEXT_NODE){if(!V((r.textContent??"").slice(0,a)))return null;let o=r.previousSibling;for(;F(o);)o=o.previousSibling;return U(o)?o:null}return null},Re=e=>{const{startContainer:r,startOffset:a}=e;if(r===t){let o=a;for(;F(t.childNodes[o]);)o++;const c=t.childNodes[o];return U(c)?c:null}if(r.nodeType===Node.TEXT_NODE){if(!V((r.textContent??"").slice(a)))return null;let o=r.nextSibling;for(;F(o);)o=o.nextSibling;return U(o)?o:null}return null},Se=e=>{var r;const a=fe.get(e),o=e.nextSibling;o?.nodeType===Node.TEXT_NODE&&V(o.textContent)&&o.remove(),e.remove(),a&&((r=n.onEntityRemove)==null||r.call(n,a)),ve()},Ue=e=>{const r=E(t);if(!r)return;const a=t.ownerDocument.createRange();a.setStartBefore(e),a.collapse(!0),r.removeAllRanges(),r.addRange(a)},Ae=e=>{const r=E(t);if(!r)return;let a=e;for(;F(a.nextSibling);)a=a.nextSibling;const o=t.ownerDocument.createRange();o.setStartAfter(a),o.collapse(!0),r.removeAllRanges(),r.addRange(o)},Xe=e=>{var r;if((e.metaKey||e.ctrlKey)&&(e.key==="z"||e.key==="Z")){e.preventDefault(),e.shiftKey?xe():ze();return}if((e.metaKey||e.ctrlKey)&&(e.key==="y"||e.key==="Y")){e.preventDefault(),xe();return}if(ie()&&R().length>0){if(e.key==="ArrowDown"){e.preventDefault(),q(o=>(o+1)%R().length);return}if(e.key==="ArrowUp"){e.preventDefault(),q(o=>(o-1+R().length)%R().length);return}if(e.key==="Enter"||e.key==="Tab"){const o=R();if(o.length>0){e.preventDefault(),e.stopPropagation(),we(o[T()]);return}}if(e.key==="Escape"){e.preventDefault(),B();return}}else if(p()&&e.key==="Escape"){e.preventDefault(),B();return}const a=k();if(a&&a.isConnected){if(e.key==="ArrowLeft"){e.preventDefault(),Ue(a),y();return}if(e.key==="ArrowRight"){e.preventDefault(),Ae(a),y();return}if(e.key==="Backspace"||e.key==="Delete"){e.preventDefault();const o=a.previousSibling;y(),Se(a);const c=E(t);if(c){const d=t.ownerDocument.createRange();o&&o.isConnected?d.setStartAfter(o):d.setStart(t,0),d.collapse(!0),c.removeAllRanges(),c.addRange(d)}return}if(e.key==="Escape"){e.preventDefault(),y();return}if(e.key==="Shift"||e.key==="Meta"||e.key==="Control"||e.key==="Alt")return;Ae(a),y()}if(!k()&&(e.key==="ArrowLeft"||e.key==="ArrowRight")&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey){const o=E(t);if(o&&o.rangeCount>0){const c=o.getRangeAt(0);if(c.collapsed){const d=e.key==="ArrowLeft"?Te(c):Re(c);if(d){e.preventDefault(),w(d);return}}}}if(e.key==="Backspace"||e.key==="Delete"){const o=E(t);if(!o||o.rangeCount===0)return;const c=o.getRangeAt(0);if(!c.collapsed)return;const d=e.key==="Backspace"?Te(c):Re(c);if(d){e.preventDefault(),Se(d);return}}if(e.key==="Enter"&&!e.shiftKey&&n.submitOnEnter!==!1){if(e.preventDefault(),n.disabled||n.loading)return;(r=n.onSubmit)==null||r.call(n,K())}},le=()=>n.maxHeight??240,We=()=>n.editableClass??P("text-foreground min-h-[44px] w-full text-start overflow-y-auto whitespace-pre-wrap break-words",Ze(l.proseSize()),n.bare?"kai-focus-inset":"outline-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0"),Ee=[(()=>{var e=pt();return N(e,`
82
82
  /* MARKED text, not selected text. Reads --color-highlight (overridable via
83
83
  --kai-color-highlight), a warm <mark> yellow. It used to be a 22% tint of
84
84
  --color-primary with a #6366f1 indigo fallback \u2014 but the kit's
@@ -103,4 +103,4 @@ import{A as Ye,g as z,w as Je,k as Z,j as de,o as ue,x as De,h as Ze,i as N,u as
103
103
  light one: an unstyled page is a white page, and guessing from the OS is
104
104
  exactly the failure above. */
105
105
  ::highlight(${s}) { background-color: var(--color-highlight, hsl(45 96% 78%)); }
106
- `),e})(),ft(),(()=>{var e=gt(),r=e.firstChild;return r.addEventListener("blur",Pe),r.addEventListener("focus",Ge),r.$$mousedown=y,r.$$keydown=Xe,r.$$input=_e,Ne(a=>{var o;t=a,(o=n.editableRef)==null||o.call(n,a)},r),H(a=>{var o=k()?"":void 0,c=n.placeholder??"",d=n.disabled?!1:"plaintext-only",g=n.ariaLabel||n.placeholder||"Message input",I=P(We(),h()&&n.placeholder?"kai-composer-empty":""),D=typeof le()=="number"?`${le()}px`:String(le());return o!==a.e&&O(r,"data-pill-selected",a.e=o),c!==a.t&&O(r,"data-placeholder",a.t=c),d!==a.a&&O(r,"contenteditable",a.a=d),g!==a.o&&O(r,"aria-label",a.o=g),I!==a.i&&Q(r,a.i=I),D!==a.n&&ee(r,"max-height",a.n=D),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),e})(),$(G,{get when(){return je()},get children(){var e=mt();return Ne(r=>{u(r),Fe(r)},e),N(e,$(Oe,{get each(){return Me()},children:r=>[$(G,{get when(){return r.group},get children(){var a=kt();return N(a,()=>r.group),a}}),$(Oe,{get each(){return r.items},children:a=>(()=>{var o=vt(),c=o.firstChild;return o.$$click=d=>{d.preventDefault(),we(a.item)},o.$$mousedown=d=>d.preventDefault(),o.addEventListener("mouseenter",()=>q(a.index)),N(o,$(G,{get when(){return qe(a.item)},get fallback(){return $(G,{get when(){return Le(me(a.item))},children:d=>(()=>{var g=bt();return H(()=>g.innerHTML=d()),g})()})},children:d=>(()=>{var g=xt();return H(()=>O(g,"src",d())),g})()}),c),N(c,()=>a.item.label),N(o,$(G,{get when(){return a.item.description},get children(){var d=yt();return N(d,()=>a.item.description),d}}),null),H(d=>{var g=T()===a.index,I=a.index,D=P("w-full flex items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",T()===a.index?"bg-muted text-foreground":"text-foreground hover:bg-muted");return g!==d.e&&O(o,"aria-selected",d.e=g),I!==d.t&&O(o,"data-index",d.t=I),D!==d.a&&Q(o,d.a=D),d},{e:void 0,t:void 0,a:void 0}),o})()})]})),H(r=>{var a=He(),o=P("absolute z-50 min-w-[240px] max-w-[420px] max-h-[320px] overflow-y-auto rounded-lg bg-card shadow-lg py-1","border border-border"),c=`${ke().x}px`,d=`${ke().y}px`,g=Ke()?"hidden":"visible";return a!==r.e&&O(e,"data-state",r.e=a),o!==r.t&&Q(e,r.t=o),c!==r.a&&ee(e,"left",r.a=c),d!==r.o&&ee(e,"top",r.o=d),g!==r.i&&ee(e,"visibility",r.i=g),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}})];return n.bare?Ee:(()=>{var e=wt();return N(e,Ee),H(()=>Q(e,P("kai-composer relative rounded-xl bg-surface p-2","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-0",n.disabled&&"cursor-not-allowed opacity-60"))),e})()}et(["input","keydown","mousedown","click"]);export{Rt as C,he as e,M as n,te as s};
106
+ `),e})(),ft(),(()=>{var e=gt(),r=e.firstChild;return r.addEventListener("blur",Pe),r.addEventListener("focus",Ge),r.$$mousedown=y,r.$$keydown=Xe,r.$$input=_e,Ne(a=>{var o;t=a,(o=n.editableRef)==null||o.call(n,a)},r),H(a=>{var o=k()?"":void 0,c=n.placeholder??"",d=n.disabled?!1:"plaintext-only",g=n.ariaLabel||n.placeholder||"Message input",I=P(We(),h()&&n.placeholder?"kai-composer-empty":""),D=typeof le()=="number"?`${le()}px`:String(le());return o!==a.e&&O(r,"data-pill-selected",a.e=o),c!==a.t&&O(r,"data-placeholder",a.t=c),d!==a.a&&O(r,"contenteditable",a.a=d),g!==a.o&&O(r,"aria-label",a.o=g),I!==a.i&&Z(r,a.i=I),D!==a.n&&ee(r,"max-height",a.n=D),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),e})(),$(G,{get when(){return je()},get children(){var e=mt();return Ne(r=>{u(r),Fe(r)},e),N(e,$(Oe,{get each(){return Me()},children:r=>[$(G,{get when(){return r.group},get children(){var a=kt();return N(a,()=>r.group),a}}),$(Oe,{get each(){return r.items},children:a=>(()=>{var o=vt(),c=o.firstChild;return o.$$click=d=>{d.preventDefault(),we(a.item)},o.$$mousedown=d=>d.preventDefault(),o.addEventListener("mouseenter",()=>q(a.index)),N(o,$(G,{get when(){return qe(a.item)},get fallback(){return $(G,{get when(){return Le(me(a.item))},children:d=>(()=>{var g=bt();return H(()=>g.innerHTML=d()),g})()})},children:d=>(()=>{var g=xt();return H(()=>O(g,"src",d())),g})()}),c),N(c,()=>a.item.label),N(o,$(G,{get when(){return a.item.description},get children(){var d=yt();return N(d,()=>a.item.description),d}}),null),H(d=>{var g=T()===a.index,I=a.index,D=P("w-full flex items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",T()===a.index?"bg-muted text-foreground":"text-foreground hover:bg-muted");return g!==d.e&&O(o,"aria-selected",d.e=g),I!==d.t&&O(o,"data-index",d.t=I),D!==d.a&&Z(o,d.a=D),d},{e:void 0,t:void 0,a:void 0}),o})()})]})),H(r=>{var a=He(),o=P("absolute z-50 min-w-[240px] max-w-[420px] max-h-[320px] overflow-y-auto rounded-lg bg-card shadow-lg py-1","border border-border"),c=`${ke().x}px`,d=`${ke().y}px`,g=Ke()?"hidden":"visible";return a!==r.e&&O(e,"data-state",r.e=a),o!==r.t&&Z(e,r.t=o),c!==r.a&&ee(e,"left",r.a=c),d!==r.o&&ee(e,"top",r.o=d),g!==r.i&&ee(e,"visibility",r.i=g),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}})];return n.bare?Ee:(()=>{var e=wt();return N(e,Ee),H(()=>Z(e,P("kai-composer relative rounded-xl bg-surface p-2","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-0",n.disabled&&"cursor-not-allowed opacity-60"))),e})()}et(["input","keydown","mousedown","click"]);export{Rt as C,he as e,M as n,te as s};
@@ -1 +1 @@
1
- import{q as L,s as N,k as v,j as T,x as O,o as H,c as d,E as U,S as f,i as l,a as $,b as F,d as q,F as G,u as A,t as h,e as J}from"./define-CGGX-7Vg.js";import{c as K}from"./cn-DN5AWfiS.js";import{B as D}from"./button-BH6rN0U-.js";import{u as P,a as Q,C as x,D as V}from"./use-card-resolution-CJW4grFa.js";import{e as W}from"./card-routing-DifQgS7n.js";import{t as X}from"./triangle-alert-DHohDOCy.js";import{c as Y}from"./check-DPeeMUYx.js";var Z=h('<div class="flex items-center gap-2 text-sm font-medium text-destructive dark:text-red-400"><span>Heads up'),_=h('<p class="text-sm font-semibold text-foreground">'),ee=h('<p class="text-sm text-muted-foreground">'),te=h("<div>"),re=h('<div class="flex w-full flex-wrap items-center justify-between gap-2"><div class="ml-auto flex flex-wrap items-center gap-2">'),ae=h('<div class="ml-auto flex items-center gap-2 text-sm font-medium text-foreground"><span>');const ne="confirm",ie=new Set(["primary","default","destructive"]);function de(o){switch(o){case"primary":return"default";case"destructive":return"destructive";case"default":case void 0:return"outline";default:return console.warn(`[kai-confirm] unknown action style "${o}"; using default`),"outline"}}function oe(o){if(!Array.isArray(o)||o.length===0)return{actions:[],error:"This card couldn't be displayed."};const c=new Set,r=[];for(const m of o){if(!m||typeof m!="object")continue;const i=m;if(typeof i.id!="string"||i.id.length===0||typeof i.label!="string"||i.label.length===0)continue;if(c.has(i.id)){console.warn(`[kai-confirm] duplicate action id "${i.id}" ignored`);continue}c.add(i.id);const g=ie.has(i.style)?i.style:void 0;i.style!==void 0&&g===void 0&&console.warn(`[kai-confirm] unknown action style "${String(i.style)}"; using default`),r.push({id:i.id,label:i.label,style:g,payload:i.payload,default:i.default===!0})}return r.length===0?{actions:[],error:"This card couldn't be displayed."}:{actions:r}}function se(o){var c;return(c=o.find(r=>r.default))==null?void 0:c.id}function le(o){const c=L({cardId:"kai-confirm",autofocus:!1},o),[r]=N(c,["data","cardId","heading","host","hostElement","autofocus","class","resolution","controllerRef"]),m=P(),i=e=>{const n=r.host??m;n?n.emit(e):r.hostElement&&W(r.hostElement,e)},g=v(()=>{var e;return oe((e=r.data)==null?void 0:e.actions)}),I=v(()=>g().error===void 0),C=v(()=>g().error??""),p=v(()=>g().actions),j=()=>{var e;return((e=r.data)==null?void 0:e.tone)??"default"},M=()=>j()==="danger",k=v(()=>se(p())),u=Q({prop:()=>r.resolution,data:()=>r.data}),z=v(()=>{const e=u.resolution();if(!e||e.kind!=="action")return;const n=p().find(t=>t.id===e.action);return{label:n?.label??e.action}});T(O(I,e=>{i(e?{kind:"ready",cardId:r.cardId}:{kind:"error",cardId:r.cardId,message:C()})}));const b=e=>{u.isResolved()||(i({kind:"action",cardId:r.cardId,action:e.id,...e.payload!==void 0?{payload:e.payload}:{}}),u.setLocal({kind:"action",action:e.id,...e.payload!==void 0?{payload:e.payload}:{}}))},E=()=>{u.isResolved()||(i({kind:"dismiss",cardId:r.cardId}),u.setLocal({kind:"dismissed"}))},R=()=>i({kind:"reopen",cardId:r.cardId});let S,y;const B=()=>y?y.querySelector('button[data-kai-default="true"]')??y.querySelector("button[data-action-id]"):null;return H(()=>{var e;(e=r.controllerRef)==null||e.call(r,{focus:n=>{var t;return(t=B())==null?void 0:t.focus(n)},confirm:n=>{const t=p(),a=n??k();if(a===void 0)return;const s=t.find(w=>w.id===a);s&&b(s)},dismiss:()=>E(),reopen:()=>R()})}),T(()=>{const e=r.hostElement;if(!e)return;const n=u.resolution();n&&n.kind==="action"?e.setAttribute("data-kai-resolved",n.action):e.removeAttribute("data-kai-resolved")}),d(f,{get when(){return I()},get fallback(){return d(x,{get heading(){return r.heading},get errorMessage(){return C()}})},get children(){return d(U,{fallback:()=>(i({kind:"error",cardId:r.cardId,message:"The card failed to render."}),d(x,{get heading(){return r.heading},errorMessage:"The card failed to render."})),get children(){return d(f,{get when(){return!u.isDeferred()},get fallback(){return d(V,{type:ne,get title(){return r.heading},onReopen:R})},get children(){return d(x,{get heading(){return r.heading},get actions(){return d(f,{get when(){return!u.isResolved()},get fallback(){return(()=>{var e=ae(),n=e.firstChild;return l(e,d(Y,{size:16,"aria-hidden":"true"}),n),l(n,()=>{var t;return(t=z())==null?void 0:t.label}),$(()=>q(e,"role",u.isOptimistic()?"status":void 0)),e})()},get children(){var e=re(),n=e.firstChild;l(e,d(f,{get when(){var a;return((a=r.data)==null?void 0:a.dismissible)===!0},get children(){return d(D,{type:"button",variant:"ghost","aria-label":"Dismiss",onClick:E,children:"Dismiss"})}}),n);var t=y;return typeof t=="function"?A(t,n):y=n,l(n,d(G,{get each(){return p()},children:a=>d(D,{type:"button",get variant(){return de(a.style)},get"data-action-id"(){return a.id},get"data-kai-default"(){return a.default?"true":void 0},ref:s=>{r.autofocus&&a.id===k()&&queueMicrotask(()=>s.focus())},onClick:()=>b(a),get children(){return a.label}})})),e}})},get children(){var e=te();e.$$keydown=t=>{if(t.key!=="Enter"||t.target.tagName==="BUTTON")return;const a=k();if(a===void 0)return;const s=p().find(w=>w.id===a);s&&b(s)};var n=S;return typeof n=="function"?A(n,e):S=e,l(e,d(f,{get when(){return M()},get children(){var t=Z(),a=t.firstChild;return l(t,d(X,{size:16,class:"shrink-0","aria-hidden":"true"}),a),t}}),null),l(e,d(f,{get when(){var t;return(t=r.data)==null?void 0:t.heading},get children(){var t=_();return l(t,()=>{var a;return(a=r.data)==null?void 0:a.heading}),t}}),null),l(e,d(f,{get when(){var t;return(t=r.data)==null?void 0:t.body},get children(){var t=ee();return l(t,()=>{var a;return(a=r.data)==null?void 0:a.body}),t}}),null),$(t=>{var a=K("flex flex-col gap-2",r.class),s=k()!==void 0?0:void 0;return a!==t.e&&F(e,t.e=a),s!==t.t&&q(e,"tabindex",t.t=s),t},{e:void 0,t:void 0}),e}})}})}})}})}J(["keydown"]);export{le as C};
1
+ import{q as L,s as N,k as v,j as T,x as O,o as H,c as d,E as U,S as f,i as l,a as $,b as F,d as q,F as G,u as A,t as h,e as J}from"./define-By-uL588.js";import{c as K}from"./cn-DN5AWfiS.js";import{B as D}from"./button-DkuOnGLy.js";import{u as P,a as Q,C as x,D as V}from"./use-card-resolution-DaZqAdWf.js";import{e as W}from"./card-routing-0YidER_3.js";import{t as X}from"./triangle-alert-DlQ68ppf.js";import{c as Y}from"./check-njkVdZu2.js";var Z=h('<div class="flex items-center gap-2 text-sm font-medium text-destructive dark:text-red-400"><span>Heads up'),_=h('<p class="text-sm font-semibold text-foreground">'),ee=h('<p class="text-sm text-muted-foreground">'),te=h("<div>"),re=h('<div class="flex w-full flex-wrap items-center justify-between gap-2"><div class="ml-auto flex flex-wrap items-center gap-2">'),ae=h('<div class="ml-auto flex items-center gap-2 text-sm font-medium text-foreground"><span>');const ne="confirm",ie=new Set(["primary","default","destructive"]);function de(o){switch(o){case"primary":return"default";case"destructive":return"destructive";case"default":case void 0:return"outline";default:return console.warn(`[kai-confirm] unknown action style "${o}"; using default`),"outline"}}function oe(o){if(!Array.isArray(o)||o.length===0)return{actions:[],error:"This card couldn't be displayed."};const c=new Set,r=[];for(const m of o){if(!m||typeof m!="object")continue;const i=m;if(typeof i.id!="string"||i.id.length===0||typeof i.label!="string"||i.label.length===0)continue;if(c.has(i.id)){console.warn(`[kai-confirm] duplicate action id "${i.id}" ignored`);continue}c.add(i.id);const g=ie.has(i.style)?i.style:void 0;i.style!==void 0&&g===void 0&&console.warn(`[kai-confirm] unknown action style "${String(i.style)}"; using default`),r.push({id:i.id,label:i.label,style:g,payload:i.payload,default:i.default===!0})}return r.length===0?{actions:[],error:"This card couldn't be displayed."}:{actions:r}}function se(o){var c;return(c=o.find(r=>r.default))==null?void 0:c.id}function le(o){const c=L({cardId:"kai-confirm",autofocus:!1},o),[r]=N(c,["data","cardId","heading","host","hostElement","autofocus","class","resolution","controllerRef"]),m=P(),i=e=>{const n=r.host??m;n?n.emit(e):r.hostElement&&W(r.hostElement,e)},g=v(()=>{var e;return oe((e=r.data)==null?void 0:e.actions)}),I=v(()=>g().error===void 0),C=v(()=>g().error??""),p=v(()=>g().actions),j=()=>{var e;return((e=r.data)==null?void 0:e.tone)??"default"},M=()=>j()==="danger",k=v(()=>se(p())),u=Q({prop:()=>r.resolution,data:()=>r.data}),z=v(()=>{const e=u.resolution();if(!e||e.kind!=="action")return;const n=p().find(t=>t.id===e.action);return{label:n?.label??e.action}});T(O(I,e=>{i(e?{kind:"ready",cardId:r.cardId}:{kind:"error",cardId:r.cardId,message:C()})}));const b=e=>{u.isResolved()||(i({kind:"action",cardId:r.cardId,action:e.id,...e.payload!==void 0?{payload:e.payload}:{}}),u.setLocal({kind:"action",action:e.id,...e.payload!==void 0?{payload:e.payload}:{}}))},E=()=>{u.isResolved()||(i({kind:"dismiss",cardId:r.cardId}),u.setLocal({kind:"dismissed"}))},R=()=>i({kind:"reopen",cardId:r.cardId});let S,y;const B=()=>y?y.querySelector('button[data-kai-default="true"]')??y.querySelector("button[data-action-id]"):null;return H(()=>{var e;(e=r.controllerRef)==null||e.call(r,{focus:n=>{var t;return(t=B())==null?void 0:t.focus(n)},confirm:n=>{const t=p(),a=n??k();if(a===void 0)return;const s=t.find(w=>w.id===a);s&&b(s)},dismiss:()=>E(),reopen:()=>R()})}),T(()=>{const e=r.hostElement;if(!e)return;const n=u.resolution();n&&n.kind==="action"?e.setAttribute("data-kai-resolved",n.action):e.removeAttribute("data-kai-resolved")}),d(f,{get when(){return I()},get fallback(){return d(x,{get heading(){return r.heading},get errorMessage(){return C()}})},get children(){return d(U,{fallback:()=>(i({kind:"error",cardId:r.cardId,message:"The card failed to render."}),d(x,{get heading(){return r.heading},errorMessage:"The card failed to render."})),get children(){return d(f,{get when(){return!u.isDeferred()},get fallback(){return d(V,{type:ne,get title(){return r.heading},onReopen:R})},get children(){return d(x,{get heading(){return r.heading},get actions(){return d(f,{get when(){return!u.isResolved()},get fallback(){return(()=>{var e=ae(),n=e.firstChild;return l(e,d(Y,{size:16,"aria-hidden":"true"}),n),l(n,()=>{var t;return(t=z())==null?void 0:t.label}),$(()=>q(e,"role",u.isOptimistic()?"status":void 0)),e})()},get children(){var e=re(),n=e.firstChild;l(e,d(f,{get when(){var a;return((a=r.data)==null?void 0:a.dismissible)===!0},get children(){return d(D,{type:"button",variant:"ghost","aria-label":"Dismiss",onClick:E,children:"Dismiss"})}}),n);var t=y;return typeof t=="function"?A(t,n):y=n,l(n,d(G,{get each(){return p()},children:a=>d(D,{type:"button",get variant(){return de(a.style)},get"data-action-id"(){return a.id},get"data-kai-default"(){return a.default?"true":void 0},ref:s=>{r.autofocus&&a.id===k()&&queueMicrotask(()=>s.focus())},onClick:()=>b(a),get children(){return a.label}})})),e}})},get children(){var e=te();e.$$keydown=t=>{if(t.key!=="Enter"||t.target.tagName==="BUTTON")return;const a=k();if(a===void 0)return;const s=p().find(w=>w.id===a);s&&b(s)};var n=S;return typeof n=="function"?A(n,e):S=e,l(e,d(f,{get when(){return M()},get children(){var t=Z(),a=t.firstChild;return l(t,d(X,{size:16,class:"shrink-0","aria-hidden":"true"}),a),t}}),null),l(e,d(f,{get when(){var t;return(t=r.data)==null?void 0:t.heading},get children(){var t=_();return l(t,()=>{var a;return(a=r.data)==null?void 0:a.heading}),t}}),null),l(e,d(f,{get when(){var t;return(t=r.data)==null?void 0:t.body},get children(){var t=ee();return l(t,()=>{var a;return(a=r.data)==null?void 0:a.body}),t}}),null),$(t=>{var a=K("flex flex-col gap-2",r.class),s=k()!==void 0?0:void 0;return a!==t.e&&F(e,t.e=a),s!==t.t&&q(e,"tabindex",t.t=s),t},{e:void 0,t:void 0}),e}})}})}})}})}J(["keydown"]);export{le as C};