@cossistant/react 0.0.26 → 0.0.28

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 (227) hide show
  1. package/api.d.ts +1 -1
  2. package/api.d.ts.map +1 -1
  3. package/checks.d.ts +1 -1
  4. package/checks.d.ts.map +1 -1
  5. package/clsx.d.ts +1 -1
  6. package/clsx.d.ts.map +1 -1
  7. package/coerce.d.ts +1 -1
  8. package/coerce.d.ts.map +1 -1
  9. package/conversation.d.ts +3 -0
  10. package/conversation.d.ts.map +1 -1
  11. package/core.d.ts +1 -1
  12. package/core.d.ts.map +1 -1
  13. package/errors.d.ts +1 -1
  14. package/errors.d.ts.map +1 -1
  15. package/errors2.d.ts +1 -1
  16. package/errors2.d.ts.map +1 -1
  17. package/hooks/index.d.ts +2 -1
  18. package/hooks/index.js +6 -5
  19. package/hooks/private/store/use-website-store.js +2 -1
  20. package/hooks/private/store/use-website-store.js.map +1 -1
  21. package/hooks/private/use-client-query.d.ts +6 -0
  22. package/hooks/private/use-client-query.d.ts.map +1 -1
  23. package/hooks/private/use-client-query.js +26 -3
  24. package/hooks/private/use-client-query.js.map +1 -1
  25. package/hooks/private/use-multimodal-input.d.ts.map +1 -1
  26. package/hooks/private/use-multimodal-input.js +7 -5
  27. package/hooks/private/use-multimodal-input.js.map +1 -1
  28. package/hooks/private/use-visitor-typing-reporter.d.ts +18 -1
  29. package/hooks/private/use-visitor-typing-reporter.d.ts.map +1 -1
  30. package/hooks/private/use-visitor-typing-reporter.js +34 -4
  31. package/hooks/private/use-visitor-typing-reporter.js.map +1 -1
  32. package/hooks/use-conversation-page.d.ts +1 -0
  33. package/hooks/use-conversation-page.d.ts.map +1 -1
  34. package/hooks/use-conversation-page.js +6 -1
  35. package/hooks/use-conversation-page.js.map +1 -1
  36. package/hooks/use-conversation-preview.d.ts +2 -1
  37. package/hooks/use-conversation-preview.d.ts.map +1 -1
  38. package/hooks/use-conversation-preview.js +1 -1
  39. package/hooks/use-conversation-preview.js.map +1 -1
  40. package/hooks/use-conversation-timeline-items.js +2 -1
  41. package/hooks/use-conversation-timeline-items.js.map +1 -1
  42. package/hooks/use-conversation.js +2 -1
  43. package/hooks/use-conversation.js.map +1 -1
  44. package/hooks/use-conversations.js +1 -0
  45. package/hooks/use-conversations.js.map +1 -1
  46. package/hooks/use-create-conversation.d.ts.map +1 -1
  47. package/hooks/use-file-upload.d.ts +55 -0
  48. package/hooks/use-file-upload.d.ts.map +1 -0
  49. package/hooks/use-file-upload.js +100 -0
  50. package/hooks/use-file-upload.js.map +1 -0
  51. package/hooks/use-message-composer.d.ts +11 -0
  52. package/hooks/use-message-composer.d.ts.map +1 -1
  53. package/hooks/use-message-composer.js +7 -3
  54. package/hooks/use-message-composer.js.map +1 -1
  55. package/hooks/use-send-message.d.ts +1 -0
  56. package/hooks/use-send-message.d.ts.map +1 -1
  57. package/hooks/use-send-message.js +63 -11
  58. package/hooks/use-send-message.js.map +1 -1
  59. package/index.d.ts +6 -3
  60. package/index.js +13 -10
  61. package/openapi30.d.ts +1 -1
  62. package/openapi30.d.ts.map +1 -1
  63. package/openapi31.d.ts +1 -1
  64. package/openapi31.d.ts.map +1 -1
  65. package/package.json +4 -3
  66. package/parse.d.ts +1 -1
  67. package/parse.d.ts.map +1 -1
  68. package/primitives/avatar/image.d.ts +1 -1
  69. package/primitives/conversation-timeline.d.ts.map +1 -1
  70. package/primitives/conversation-timeline.js +10 -5
  71. package/primitives/conversation-timeline.js.map +1 -1
  72. package/primitives/index.d.ts +4 -3
  73. package/primitives/index.js +12 -5
  74. package/primitives/index.parts.d.ts +3 -2
  75. package/primitives/index.parts.js +4 -3
  76. package/primitives/multimodal-input.d.ts +2 -2
  77. package/primitives/multimodal-input.d.ts.map +1 -1
  78. package/primitives/timeline-item-attachments.d.ts +100 -0
  79. package/primitives/timeline-item-attachments.d.ts.map +1 -0
  80. package/primitives/timeline-item-attachments.js +151 -0
  81. package/primitives/timeline-item-attachments.js.map +1 -0
  82. package/primitives/trigger.d.ts +91 -0
  83. package/primitives/trigger.d.ts.map +1 -0
  84. package/primitives/trigger.js +74 -0
  85. package/primitives/trigger.js.map +1 -0
  86. package/primitives/window.d.ts +22 -1
  87. package/primitives/window.d.ts.map +1 -1
  88. package/primitives/window.js +91 -5
  89. package/primitives/window.js.map +1 -1
  90. package/provider.d.ts.map +1 -1
  91. package/provider.js +8 -3
  92. package/provider.js.map +1 -1
  93. package/realtime/index.js +1 -1
  94. package/realtime/provider.js +1 -1
  95. package/realtime/support-provider.js +1 -1
  96. package/realtime/support-provider.js.map +1 -1
  97. package/realtime-events.d.ts +40 -1
  98. package/realtime-events.d.ts.map +1 -1
  99. package/registries.d.ts +1 -1
  100. package/registries.d.ts.map +1 -1
  101. package/schemas.d.ts +1 -1
  102. package/schemas.d.ts.map +1 -1
  103. package/schemas2.d.ts +1 -1
  104. package/schemas2.d.ts.map +1 -1
  105. package/schemas3.d.ts +1 -0
  106. package/schemas3.d.ts.map +1 -1
  107. package/specification-extension.d.ts +1 -1
  108. package/specification-extension.d.ts.map +1 -1
  109. package/standard-schema.d.ts +1 -1
  110. package/standard-schema.d.ts.map +1 -1
  111. package/support/components/content.d.ts +30 -0
  112. package/support/components/content.d.ts.map +1 -0
  113. package/support/components/content.js +282 -0
  114. package/support/components/content.js.map +1 -0
  115. package/support/components/conversation-button-link.js +1 -1
  116. package/support/components/conversation-timeline.js +3 -3
  117. package/support/components/conversation-timeline.js.map +1 -1
  118. package/support/components/header.js +1 -1
  119. package/support/components/image-lightbox.d.ts +49 -0
  120. package/support/components/image-lightbox.d.ts.map +1 -0
  121. package/support/components/image-lightbox.js +142 -0
  122. package/support/components/image-lightbox.js.map +1 -0
  123. package/support/components/index.d.ts +5 -4
  124. package/support/components/index.js +4 -4
  125. package/support/components/multimodal-input.d.ts +4 -1
  126. package/support/components/multimodal-input.d.ts.map +1 -1
  127. package/support/components/multimodal-input.js +71 -45
  128. package/support/components/multimodal-input.js.map +1 -1
  129. package/support/components/navigation-tab.js +1 -1
  130. package/support/components/root.d.ts +23 -0
  131. package/support/components/root.d.ts.map +1 -0
  132. package/support/components/root.js +36 -0
  133. package/support/components/root.js.map +1 -0
  134. package/support/components/timeline-message-item.d.ts.map +1 -1
  135. package/support/components/timeline-message-item.js +82 -18
  136. package/support/components/timeline-message-item.js.map +1 -1
  137. package/support/components/trigger.d.ts +14 -0
  138. package/support/components/trigger.d.ts.map +1 -0
  139. package/support/components/{bubble.js → trigger.js} +16 -12
  140. package/support/components/trigger.js.map +1 -0
  141. package/support/components/typing-indicator.d.ts.map +1 -1
  142. package/support/components/typing-indicator.js +1 -0
  143. package/support/components/typing-indicator.js.map +1 -1
  144. package/support/context/controlled-state.d.ts +46 -0
  145. package/support/context/controlled-state.d.ts.map +1 -0
  146. package/support/context/controlled-state.js +34 -0
  147. package/support/context/controlled-state.js.map +1 -0
  148. package/support/context/events.d.ts +103 -0
  149. package/support/context/events.d.ts.map +1 -0
  150. package/support/context/events.js +139 -0
  151. package/support/context/events.js.map +1 -0
  152. package/support/context/handle.d.ts +90 -0
  153. package/support/context/handle.d.ts.map +1 -0
  154. package/support/context/handle.js +79 -0
  155. package/support/context/handle.js.map +1 -0
  156. package/support/context/positioning.d.ts +17 -0
  157. package/support/context/positioning.d.ts.map +1 -0
  158. package/support/context/positioning.js +26 -0
  159. package/support/context/positioning.js.map +1 -0
  160. package/support/context/slots.d.ts +85 -0
  161. package/support/context/slots.d.ts.map +1 -0
  162. package/support/context/slots.js +115 -0
  163. package/support/context/slots.js.map +1 -0
  164. package/support/context/websocket.d.ts +8 -1
  165. package/support/context/websocket.d.ts.map +1 -1
  166. package/support/context/websocket.js +8 -1
  167. package/support/context/websocket.js.map +1 -1
  168. package/support/index.d.ts +239 -54
  169. package/support/index.d.ts.map +1 -1
  170. package/support/index.js +254 -33
  171. package/support/index.js.map +1 -1
  172. package/support/pages/articles.d.ts.map +1 -1
  173. package/support/pages/articles.js +3 -4
  174. package/support/pages/articles.js.map +1 -1
  175. package/support/pages/conversation-history.js +2 -2
  176. package/support/pages/conversation.js +6 -5
  177. package/support/pages/conversation.js.map +1 -1
  178. package/support/pages/home.js +2 -2
  179. package/support/router.d.ts +52 -12
  180. package/support/router.d.ts.map +1 -1
  181. package/support/router.js +78 -30
  182. package/support/router.js.map +1 -1
  183. package/support/store/index.d.ts +2 -2
  184. package/support/store/support-store.d.ts +26 -20
  185. package/support/store/support-store.d.ts.map +1 -1
  186. package/support/store/support-store.js +47 -6
  187. package/support/store/support-store.js.map +1 -1
  188. package/support/{support-D2EgfIts.css → support-C7Xaw-N6.css} +1 -2
  189. package/support/support-C7Xaw-N6.css.map +1 -0
  190. package/support/text/index.js.map +1 -1
  191. package/support/types.d.ts +75 -12
  192. package/support/types.d.ts.map +1 -1
  193. package/support.css +2 -2
  194. package/tailwind.css +0 -1
  195. package/timeline-item.d.ts +68 -2
  196. package/timeline-item.d.ts.map +1 -1
  197. package/util.d.ts +1 -1
  198. package/util.d.ts.map +1 -1
  199. package/utils/index.d.ts +2 -1
  200. package/utils/index.js +2 -1
  201. package/utils/merge-refs.d.ts +30 -0
  202. package/utils/merge-refs.d.ts.map +1 -0
  203. package/utils/merge-refs.js +46 -0
  204. package/utils/merge-refs.js.map +1 -0
  205. package/utils/use-render-element.d.ts.map +1 -1
  206. package/utils/use-render-element.js +20 -7
  207. package/utils/use-render-element.js.map +1 -1
  208. package/versions.d.ts +1 -1
  209. package/versions.d.ts.map +1 -1
  210. package/zod-extensions.d.ts +1 -1
  211. package/zod-extensions.d.ts.map +1 -1
  212. package/primitives/bubble.d.ts +0 -38
  213. package/primitives/bubble.d.ts.map +0 -1
  214. package/primitives/bubble.js +0 -57
  215. package/primitives/bubble.js.map +0 -1
  216. package/support/components/bubble.d.ts +0 -10
  217. package/support/components/bubble.d.ts.map +0 -1
  218. package/support/components/bubble.js.map +0 -1
  219. package/support/components/container.d.ts +0 -13
  220. package/support/components/container.d.ts.map +0 -1
  221. package/support/components/container.js +0 -109
  222. package/support/components/container.js.map +0 -1
  223. package/support/components/support-content.d.ts +0 -22
  224. package/support/components/support-content.d.ts.map +0 -1
  225. package/support/components/support-content.js +0 -48
  226. package/support/components/support-content.js.map +0 -1
  227. package/support/support-D2EgfIts.css.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"typing-indicator.d.ts","names":[],"sources":["../../../src/support/components/typing-indicator.tsx"],"sourcesContent":[],"mappings":";;;;KAKY,qBAAA;KAEA,iBAAA;EAFA,EAAA,EAAA,MAAA;EAEA,IAAA,EAEL,qBAFsB;AAK7B,CAAA;AAAwD,KAA5C,oBAAA,GAAuB,OAAA,CAAM,cAAe,CAAA,cAAA,CAAA,GAAA;EAArB,YAAM,EAC1B,iBAD0B,EAAA;EAC1B,iBAAA,CAAA,EACM,gBADN,EAAA;EACM,oBAAA,CAAA,EACG,mBADH,EAAA;EACG,WAAA,CAAA,EAAA,OAAA;CAAmB;AAI9B,cAAA,YAAgB,EAAA,CAAA;EAAA;CAIzB,EAAM;EAuBG,SAAA,CAAA,EAAA,MAuDZ;CAvD2B,EAAA,GAvBxB,OAAA,CAAM,YAuBkB;AAAA,cAAf,eAAe,EAAA,OAAA,CAAA,yBAAA,CAAA,OAAA,CAAA,cAAA,CAAA,cAAA,CAAA,GAAA;EAjCb,YAAA,EAAA,iBAAA,EAAA;EACM,iBAAA,CAAA,EAAA,gBAAA,EAAA;EACG,oBAAA,CAAA,EAAA,mBAAA,EAAA"}
1
+ {"version":3,"file":"typing-indicator.d.ts","names":[],"sources":["../../../src/support/components/typing-indicator.tsx"],"sourcesContent":[],"mappings":";;;;KAKY,qBAAA;KAEA,iBAAA;EAFA,EAAA,EAAA,MAAA;EAEA,IAAA,EAEL,qBAFsB;AAK7B,CAAA;AAAwD,KAA5C,oBAAA,GAAuB,OAAA,CAAM,cAAe,CAAA,cAAA,CAAA,GAAA;EAArB,YAAM,EAC1B,iBAD0B,EAAA;EAC1B,iBAAA,CAAA,EACM,gBADN,EAAA;EACM,oBAAA,CAAA,EACG,mBADH,EAAA;EACG,WAAA,CAAA,EAAA,OAAA;CAAmB;AAI9B,cAAA,YAAgB,EAAA,CAAA;EAAA;CAIzB,EAAM;EAuBG,SAAA,CAAA,EAAA,MAwDZ;CAxD2B,EAAA,GAvBxB,OAAA,CAAM,YAuBkB;AAAA,cAAf,eAAe,EAAA,OAAA,CAAA,yBAAA,CAAA,OAAA,CAAA,cAAA,CAAA,cAAA,CAAA,GAAA;EAjCb,YAAA,EAAA,iBAAA,EAAA;EACM,iBAAA,CAAA,EAAA,gBAAA,EAAA;EACG,oBAAA,CAAA,EAAA,mBAAA,EAAA"}
@@ -24,6 +24,7 @@ const TypingIndicator = React$1.forwardRef(({ participants, availableAIAgents =
24
24
  ...props,
25
25
  children: [withAvatars && /* @__PURE__ */ jsx(AvatarStack, {
26
26
  aiAgents: typingAIAgents,
27
+ hideDefaultAIAgent: typingAIAgents.length === 0,
27
28
  humanAgents: typingHumanAgents,
28
29
  size: 24,
29
30
  spacing: 16
@@ -1 +1 @@
1
- {"version":3,"file":"typing-indicator.js","names":["React"],"sources":["../../../src/support/components/typing-indicator.tsx"],"sourcesContent":["import type { AvailableAIAgent, AvailableHumanAgent } from \"@cossistant/types\";\nimport * as React from \"react\";\nimport { cn } from \"../utils\";\nimport { AvatarStack } from \"./avatar-stack\";\n\nexport type TypingParticipantType = \"visitor\" | \"team_member\" | \"ai\";\n\nexport type TypingParticipant = {\n\tid: string;\n\ttype: TypingParticipantType;\n};\n\nexport type TypingIndicatorProps = React.HTMLAttributes<HTMLDivElement> & {\n\tparticipants: TypingParticipant[];\n\tavailableAIAgents?: AvailableAIAgent[];\n\tavailableHumanAgents?: AvailableHumanAgent[];\n\twithAvatars?: boolean;\n};\n\nexport const BouncingDots = ({\n\tclassName,\n}: {\n\tclassName?: string;\n}): React.ReactElement => (\n\t<div className=\"flex gap-1\">\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-1 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-2 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-3 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t</div>\n);\n\nexport const TypingIndicator = React.forwardRef<\n\tHTMLDivElement,\n\tTypingIndicatorProps\n>(\n\t(\n\t\t{\n\t\t\tparticipants,\n\t\t\tavailableAIAgents = [],\n\t\t\tavailableHumanAgents = [],\n\t\t\twithAvatars = true,\n\t\t\tclassName,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tif (!participants || participants.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Separate AI and human participants\n\t\tconst humanParticipantIds = participants\n\t\t\t.filter((p) => p.type === \"team_member\")\n\t\t\t.map((p) => p.id);\n\n\t\tconst aiParticipantIds = participants\n\t\t\t.filter((p) => p.type === \"ai\")\n\t\t\t.map((p) => p.id);\n\n\t\t// Get matching agents\n\t\tconst typingHumanAgents = availableHumanAgents.filter((agent) =>\n\t\t\thumanParticipantIds.includes(agent.id)\n\t\t);\n\n\t\tconst typingAIAgents = availableAIAgents.filter((agent) =>\n\t\t\taiParticipantIds.includes(agent.id)\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={cn(\"flex items-center gap-6\", className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{withAvatars && (\n\t\t\t\t\t<AvatarStack\n\t\t\t\t\t\taiAgents={typingAIAgents}\n\t\t\t\t\t\thumanAgents={typingHumanAgents}\n\t\t\t\t\t\tsize={24}\n\t\t\t\t\t\tspacing={16}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<BouncingDots />\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nTypingIndicator.displayName = \"TypingIndicator\";\n"],"mappings":";;;;;;AAmBA,MAAa,gBAAgB,EAC5B,gBAIA,qBAAC;CAAI,WAAU;;EACd,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;EACF,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;EACF,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;;EACG;AAGP,MAAa,kBAAkBA,QAAM,YAKnC,EACC,cACA,oBAAoB,EAAE,EACtB,uBAAuB,EAAE,EACzB,cAAc,MACd,UACA,GAAG,SAEJ,QACI;AACJ,KAAI,CAAC,gBAAgB,aAAa,WAAW,EAC5C,QAAO;CAIR,MAAM,sBAAsB,aAC1B,QAAQ,MAAM,EAAE,SAAS,cAAc,CACvC,KAAK,MAAM,EAAE,GAAG;CAElB,MAAM,mBAAmB,aACvB,QAAQ,MAAM,EAAE,SAAS,KAAK,CAC9B,KAAK,MAAM,EAAE,GAAG;CAGlB,MAAM,oBAAoB,qBAAqB,QAAQ,UACtD,oBAAoB,SAAS,MAAM,GAAG,CACtC;CAED,MAAM,iBAAiB,kBAAkB,QAAQ,UAChD,iBAAiB,SAAS,MAAM,GAAG,CACnC;AAED,QACC,qBAAC;EACA,WAAW,GAAG,2BAA2B,UAAU;EAC9C;EACL,GAAI;aAEH,eACA,oBAAC;GACA,UAAU;GACV,aAAa;GACb,MAAM;GACN,SAAS;IACR,EAEH,oBAAC,iBAAe;GACX;EAGR;AAED,gBAAgB,cAAc"}
1
+ {"version":3,"file":"typing-indicator.js","names":["React"],"sources":["../../../src/support/components/typing-indicator.tsx"],"sourcesContent":["import type { AvailableAIAgent, AvailableHumanAgent } from \"@cossistant/types\";\nimport * as React from \"react\";\nimport { cn } from \"../utils\";\nimport { AvatarStack } from \"./avatar-stack\";\n\nexport type TypingParticipantType = \"visitor\" | \"team_member\" | \"ai\";\n\nexport type TypingParticipant = {\n\tid: string;\n\ttype: TypingParticipantType;\n};\n\nexport type TypingIndicatorProps = React.HTMLAttributes<HTMLDivElement> & {\n\tparticipants: TypingParticipant[];\n\tavailableAIAgents?: AvailableAIAgent[];\n\tavailableHumanAgents?: AvailableHumanAgent[];\n\twithAvatars?: boolean;\n};\n\nexport const BouncingDots = ({\n\tclassName,\n}: {\n\tclassName?: string;\n}): React.ReactElement => (\n\t<div className=\"flex gap-1\">\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-1 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-2 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t\t<span\n\t\t\tclassName={cn(\n\t\t\t\t\"dot-bounce-3 size-1 rounded-full bg-co-primary\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t/>\n\t</div>\n);\n\nexport const TypingIndicator = React.forwardRef<\n\tHTMLDivElement,\n\tTypingIndicatorProps\n>(\n\t(\n\t\t{\n\t\t\tparticipants,\n\t\t\tavailableAIAgents = [],\n\t\t\tavailableHumanAgents = [],\n\t\t\twithAvatars = true,\n\t\t\tclassName,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tif (!participants || participants.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Separate AI and human participants\n\t\tconst humanParticipantIds = participants\n\t\t\t.filter((p) => p.type === \"team_member\")\n\t\t\t.map((p) => p.id);\n\n\t\tconst aiParticipantIds = participants\n\t\t\t.filter((p) => p.type === \"ai\")\n\t\t\t.map((p) => p.id);\n\n\t\t// Get matching agents\n\t\tconst typingHumanAgents = availableHumanAgents.filter((agent) =>\n\t\t\thumanParticipantIds.includes(agent.id)\n\t\t);\n\n\t\tconst typingAIAgents = availableAIAgents.filter((agent) =>\n\t\t\taiParticipantIds.includes(agent.id)\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={cn(\"flex items-center gap-6\", className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{withAvatars && (\n\t\t\t\t\t<AvatarStack\n\t\t\t\t\t\taiAgents={typingAIAgents}\n\t\t\t\t\t\thideDefaultAIAgent={typingAIAgents.length === 0}\n\t\t\t\t\t\thumanAgents={typingHumanAgents}\n\t\t\t\t\t\tsize={24}\n\t\t\t\t\t\tspacing={16}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<BouncingDots />\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nTypingIndicator.displayName = \"TypingIndicator\";\n"],"mappings":";;;;;;AAmBA,MAAa,gBAAgB,EAC5B,gBAIA,qBAAC;CAAI,WAAU;;EACd,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;EACF,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;EACF,oBAAC,UACA,WAAW,GACV,kDACA,UACA,GACA;;EACG;AAGP,MAAa,kBAAkBA,QAAM,YAKnC,EACC,cACA,oBAAoB,EAAE,EACtB,uBAAuB,EAAE,EACzB,cAAc,MACd,UACA,GAAG,SAEJ,QACI;AACJ,KAAI,CAAC,gBAAgB,aAAa,WAAW,EAC5C,QAAO;CAIR,MAAM,sBAAsB,aAC1B,QAAQ,MAAM,EAAE,SAAS,cAAc,CACvC,KAAK,MAAM,EAAE,GAAG;CAElB,MAAM,mBAAmB,aACvB,QAAQ,MAAM,EAAE,SAAS,KAAK,CAC9B,KAAK,MAAM,EAAE,GAAG;CAGlB,MAAM,oBAAoB,qBAAqB,QAAQ,UACtD,oBAAoB,SAAS,MAAM,GAAG,CACtC;CAED,MAAM,iBAAiB,kBAAkB,QAAQ,UAChD,iBAAiB,SAAS,MAAM,GAAG,CACnC;AAED,QACC,qBAAC;EACA,WAAW,GAAG,2BAA2B,UAAU;EAC9C;EACL,GAAI;aAEH,eACA,oBAAC;GACA,UAAU;GACV,oBAAoB,eAAe,WAAW;GAC9C,aAAa;GACb,MAAM;GACN,SAAS;IACR,EAEH,oBAAC,iBAAe;GACX;EAGR;AAED,gBAAgB,cAAc"}
@@ -0,0 +1,46 @@
1
+ import * as React$1 from "react";
2
+
3
+ //#region src/support/context/controlled-state.d.ts
4
+
5
+ /**
6
+ * Controlled state context for the Support widget.
7
+ * Allows external control of widget open/close state.
8
+ */
9
+ type ControlledStateContextValue = {
10
+ /**
11
+ * Controlled open state (undefined = uncontrolled)
12
+ */
13
+ open: boolean | undefined;
14
+ /**
15
+ * Callback when open state should change
16
+ */
17
+ onOpenChange: ((open: boolean) => void) | undefined;
18
+ /**
19
+ * Whether the component is in controlled mode
20
+ */
21
+ isControlled: boolean;
22
+ };
23
+ type ControlledStateProviderProps = {
24
+ /**
25
+ * Controlled open state
26
+ */
27
+ open?: boolean;
28
+ /**
29
+ * Callback when open state changes
30
+ */
31
+ onOpenChange?: (open: boolean) => void;
32
+ children: React$1.ReactNode;
33
+ };
34
+ /**
35
+ * Provider for controlled widget state.
36
+ * Wraps the Support component to enable controlled mode.
37
+ */
38
+ declare const ControlledStateProvider: React$1.FC<ControlledStateProviderProps>;
39
+ /**
40
+ * Access controlled state context.
41
+ * Returns null if not inside a ControlledStateProvider.
42
+ */
43
+ declare function useControlledState(): ControlledStateContextValue | null;
44
+ //#endregion
45
+ export { ControlledStateContextValue, ControlledStateProvider, ControlledStateProviderProps, useControlledState };
46
+ //# sourceMappingURL=controlled-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controlled-state.d.ts","names":[],"sources":["../../../src/support/context/controlled-state.tsx"],"sourcesContent":[],"mappings":";;;;;;AAQA;AAkBA;AAgBa,KAlCD,2BAAA,GAmDX;EAMe;;;;;;;;;;;;;KAvCJ,4BAAA;;;;;;;;;YASD,OAAA,CAAM;;;;;;cAOJ,yBAAyB,OAAA,CAAM,GAC3C;;;;;iBAsBe,kBAAA,CAAA,GAAsB"}
@@ -0,0 +1,34 @@
1
+ "use client";
2
+
3
+
4
+ import * as React$1 from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/support/context/controlled-state.tsx
8
+ const ControlledStateContext = React$1.createContext(null);
9
+ /**
10
+ * Provider for controlled widget state.
11
+ * Wraps the Support component to enable controlled mode.
12
+ */
13
+ const ControlledStateProvider = ({ open, onOpenChange, children }) => {
14
+ const value = React$1.useMemo(() => ({
15
+ open,
16
+ onOpenChange,
17
+ isControlled: open !== void 0
18
+ }), [open, onOpenChange]);
19
+ return /* @__PURE__ */ jsx(ControlledStateContext.Provider, {
20
+ value,
21
+ children
22
+ });
23
+ };
24
+ /**
25
+ * Access controlled state context.
26
+ * Returns null if not inside a ControlledStateProvider.
27
+ */
28
+ function useControlledState() {
29
+ return React$1.useContext(ControlledStateContext);
30
+ }
31
+
32
+ //#endregion
33
+ export { ControlledStateProvider, useControlledState };
34
+ //# sourceMappingURL=controlled-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controlled-state.js","names":["React","ControlledStateProvider: React.FC<\n\tControlledStateProviderProps\n>"],"sources":["../../../src/support/context/controlled-state.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * Controlled state context for the Support widget.\n * Allows external control of widget open/close state.\n */\nexport type ControlledStateContextValue = {\n\t/**\n\t * Controlled open state (undefined = uncontrolled)\n\t */\n\topen: boolean | undefined;\n\t/**\n\t * Callback when open state should change\n\t */\n\tonOpenChange: ((open: boolean) => void) | undefined;\n\t/**\n\t * Whether the component is in controlled mode\n\t */\n\tisControlled: boolean;\n};\n\nconst ControlledStateContext =\n\tReact.createContext<ControlledStateContextValue | null>(null);\n\nexport type ControlledStateProviderProps = {\n\t/**\n\t * Controlled open state\n\t */\n\topen?: boolean;\n\t/**\n\t * Callback when open state changes\n\t */\n\tonOpenChange?: (open: boolean) => void;\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider for controlled widget state.\n * Wraps the Support component to enable controlled mode.\n */\nexport const ControlledStateProvider: React.FC<\n\tControlledStateProviderProps\n> = ({ open, onOpenChange, children }) => {\n\tconst value = React.useMemo<ControlledStateContextValue>(\n\t\t() => ({\n\t\t\topen,\n\t\t\tonOpenChange,\n\t\t\tisControlled: open !== undefined,\n\t\t}),\n\t\t[open, onOpenChange]\n\t);\n\n\treturn (\n\t\t<ControlledStateContext.Provider value={value}>\n\t\t\t{children}\n\t\t</ControlledStateContext.Provider>\n\t);\n};\n\n/**\n * Access controlled state context.\n * Returns null if not inside a ControlledStateProvider.\n */\nexport function useControlledState(): ControlledStateContextValue | null {\n\treturn React.useContext(ControlledStateContext);\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,yBACLA,QAAM,cAAkD,KAAK;;;;;AAkB9D,MAAaC,2BAER,EAAE,MAAM,cAAc,eAAe;CACzC,MAAM,QAAQD,QAAM,eACZ;EACN;EACA;EACA,cAAc,SAAS;EACvB,GACD,CAAC,MAAM,aAAa,CACpB;AAED,QACC,oBAAC,uBAAuB;EAAgB;EACtC;GACgC;;;;;;AAQpC,SAAgB,qBAAyD;AACxE,QAAOA,QAAM,WAAW,uBAAuB"}
@@ -0,0 +1,103 @@
1
+ import { TimelineItem } from "../../timeline-item.js";
2
+ import * as React$1 from "react";
3
+ import { Conversation } from "@cossistant/types";
4
+
5
+ //#region src/support/context/events.d.ts
6
+ type SupportEventType = "conversationStart" | "conversationEnd" | "messageSent" | "messageReceived" | "error";
7
+ type ConversationStartEvent = {
8
+ type: "conversationStart";
9
+ conversationId: string;
10
+ conversation?: Conversation;
11
+ };
12
+ type ConversationEndEvent = {
13
+ type: "conversationEnd";
14
+ conversationId: string;
15
+ conversation?: Conversation;
16
+ };
17
+ type MessageSentEvent = {
18
+ type: "messageSent";
19
+ conversationId: string;
20
+ message: TimelineItem;
21
+ };
22
+ type MessageReceivedEvent = {
23
+ type: "messageReceived";
24
+ conversationId: string;
25
+ message: TimelineItem;
26
+ };
27
+ type ErrorEvent = {
28
+ type: "error";
29
+ error: Error;
30
+ context?: string;
31
+ };
32
+ type SupportEvent = ConversationStartEvent | ConversationEndEvent | MessageSentEvent | MessageReceivedEvent | ErrorEvent;
33
+ type SupportEventCallbacks = {
34
+ /**
35
+ * Called when a new conversation is started.
36
+ */
37
+ onConversationStart?: (event: ConversationStartEvent) => void;
38
+ /**
39
+ * Called when a conversation ends (resolved, closed, etc.).
40
+ */
41
+ onConversationEnd?: (event: ConversationEndEvent) => void;
42
+ /**
43
+ * Called when the visitor sends a message.
44
+ */
45
+ onMessageSent?: (event: MessageSentEvent) => void;
46
+ /**
47
+ * Called when a message is received from an agent (human or AI).
48
+ */
49
+ onMessageReceived?: (event: MessageReceivedEvent) => void;
50
+ /**
51
+ * Called when an error occurs.
52
+ */
53
+ onError?: (event: ErrorEvent) => void;
54
+ };
55
+ type SupportEventsContextValue = {
56
+ /**
57
+ * Emit an event to all registered callbacks.
58
+ */
59
+ emit: <T extends SupportEvent>(event: T) => void;
60
+ /**
61
+ * Subscribe to a specific event type.
62
+ * Returns an unsubscribe function.
63
+ */
64
+ subscribe: <T extends SupportEventType>(type: T, callback: (event: Extract<SupportEvent, {
65
+ type: T;
66
+ }>) => void) => () => void;
67
+ };
68
+ type SupportEventsProviderProps = SupportEventCallbacks & {
69
+ children: React$1.ReactNode;
70
+ };
71
+ /**
72
+ * Provider for support widget events.
73
+ * Allows listening to lifecycle events like message sent/received,
74
+ * conversation start/end, and errors.
75
+ *
76
+ * @example
77
+ * <Support
78
+ * onMessageSent={({ message }) => console.log("Sent:", message)}
79
+ * onMessageReceived={({ message }) => console.log("Received:", message)}
80
+ * onConversationStart={({ conversationId }) => console.log("Started:", conversationId)}
81
+ * onError={({ error }) => console.error("Error:", error)}
82
+ * />
83
+ */
84
+ declare const SupportEventsProvider: React$1.FC<SupportEventsProviderProps>;
85
+ /**
86
+ * Access the events context.
87
+ * Returns null if not inside a SupportEventsProvider.
88
+ */
89
+ declare function useSupportEvents(): SupportEventsContextValue | null;
90
+ /**
91
+ * Hook to emit events from within the widget.
92
+ * Safe to use outside of provider (will no-op).
93
+ */
94
+ declare function useSupportEventEmitter(): {
95
+ emitConversationStart: (conversationId: string, conversation?: Conversation) => void;
96
+ emitConversationEnd: (conversationId: string, conversation?: Conversation) => void;
97
+ emitMessageSent: (conversationId: string, message: TimelineItem) => void;
98
+ emitMessageReceived: (conversationId: string, message: TimelineItem) => void;
99
+ emitError: (error: Error, context?: string) => void;
100
+ };
101
+ //#endregion
102
+ export { ConversationEndEvent, ConversationStartEvent, ErrorEvent, MessageReceivedEvent, MessageSentEvent, SupportEvent, SupportEventCallbacks, SupportEventType, SupportEventsContextValue, SupportEventsProvider, SupportEventsProviderProps, useSupportEventEmitter, useSupportEvents };
103
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","names":[],"sources":["../../../src/support/context/events.tsx"],"sourcesContent":[],"mappings":";;;;;KAUY,gBAAA;KAOA,sBAAA;EAPA,IAAA,EAAA,mBAAgB;EAOhB,cAAA,EAAA,MAAA;EAMA,YAAA,CAAA,EAHI,YAGgB;AAMhC,CAAA;AAMY,KAZA,oBAAA,GAYoB;EAMpB,IAAA,EAAA,iBAAU;EAMV,cAAA,EAAY,MAAA;EACrB,YAAA,CAAA,EAtBa,YAsBb;CACA;AACA,KArBS,gBAAA,GAqBT;EACA,IAAA,EAAA,aAAA;EACA,cAAA,EAAA,MAAA;EAAU,OAAA,EApBH,YAoBG;AAMb,CAAA;AAI+B,KA3BnB,oBAAA,GA2BmB;EAIF,IAAA,EAAA,iBAAA;EAIJ,cAAA,EAAA,MAAA;EAII,OAAA,EApCnB,YAoCmB;CAIV;AAAU,KArCjB,UAAA,GAqCiB;EAOjB,IAAA,EAAA,OAAA;EAIM,KAAA,EA9CV,KA8CU;EAAqB,OAAA,CAAA,EAAA,MAAA;CAKhB;AACf,KAhDI,YAAA,GACT,sBA+CK,GA9CL,oBA8CK,GA7CL,gBA6CK,GA5CL,oBA4CK,GA3CL,UA2CK;AACoB,KAtChB,qBAAA,GAsCgB;EAAsB;;;EAOtC,mBAAA,CAAA,EAAA,CAAA,KAAA,EAzCmB,sBAyCU,EAAA,GAAA,IAAA;EAiB5B;AA0Gb;AAQA;EAOmB,iBAAA,CAAA,EAAA,CAAA,KAAA,EA/KU,oBA+KV,EAAA,GAAA,IAAA;EAUA;;;EAsBG,aAAA,CAAA,EAAA,CAAA,KAAA,EA3MG,gBA2MH,EAAA,GAAA,IAAA;EAAK;;;8BAvME;;;;oBAIV;;KAOP,yBAAA;;;;mBAIM,qBAAqB;;;;;wBAKhB,wBACf,qBACY,QAAQ;UAAsB;;;KAOtC,0BAAA,GAA6B;YAC9B,OAAA,CAAM;;;;;;;;;;;;;;;cAgBJ,uBAAuB,OAAA,CAAM,GAAG;;;;;iBA0G7B,gBAAA,CAAA,GAAoB;;;;;iBAQpB,sBAAA,CAAA;iEAOG;+DAUA;qDAQmC;yDAOI;qBAOpC"}
@@ -0,0 +1,139 @@
1
+ "use client";
2
+
3
+
4
+ import * as React$1 from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/support/context/events.tsx
8
+ const SupportEventsContext = React$1.createContext(null);
9
+ /**
10
+ * Provider for support widget events.
11
+ * Allows listening to lifecycle events like message sent/received,
12
+ * conversation start/end, and errors.
13
+ *
14
+ * @example
15
+ * <Support
16
+ * onMessageSent={({ message }) => console.log("Sent:", message)}
17
+ * onMessageReceived={({ message }) => console.log("Received:", message)}
18
+ * onConversationStart={({ conversationId }) => console.log("Started:", conversationId)}
19
+ * onError={({ error }) => console.error("Error:", error)}
20
+ * />
21
+ */
22
+ const SupportEventsProvider = ({ onConversationStart, onConversationEnd, onMessageSent, onMessageReceived, onError, children }) => {
23
+ const callbacksRef = React$1.useRef({
24
+ onConversationStart,
25
+ onConversationEnd,
26
+ onMessageSent,
27
+ onMessageReceived,
28
+ onError
29
+ });
30
+ React$1.useEffect(() => {
31
+ callbacksRef.current = {
32
+ onConversationStart,
33
+ onConversationEnd,
34
+ onMessageSent,
35
+ onMessageReceived,
36
+ onError
37
+ };
38
+ }, [
39
+ onConversationStart,
40
+ onConversationEnd,
41
+ onMessageSent,
42
+ onMessageReceived,
43
+ onError
44
+ ]);
45
+ const subscribersRef = React$1.useRef(/* @__PURE__ */ new Map());
46
+ const emit = React$1.useCallback((event) => {
47
+ switch (event.type) {
48
+ case "conversationStart":
49
+ callbacksRef.current.onConversationStart?.(event);
50
+ break;
51
+ case "conversationEnd":
52
+ callbacksRef.current.onConversationEnd?.(event);
53
+ break;
54
+ case "messageSent":
55
+ callbacksRef.current.onMessageSent?.(event);
56
+ break;
57
+ case "messageReceived":
58
+ callbacksRef.current.onMessageReceived?.(event);
59
+ break;
60
+ case "error":
61
+ callbacksRef.current.onError?.(event);
62
+ break;
63
+ default: break;
64
+ }
65
+ const subscribers = subscribersRef.current.get(event.type);
66
+ if (subscribers) for (const callback of subscribers) callback(event);
67
+ }, []);
68
+ const subscribe = React$1.useCallback((type, callback) => {
69
+ if (!subscribersRef.current.has(type)) subscribersRef.current.set(type, /* @__PURE__ */ new Set());
70
+ const subscribers = subscribersRef.current.get(type);
71
+ subscribers?.add(callback);
72
+ return () => {
73
+ subscribers?.delete(callback);
74
+ };
75
+ }, []);
76
+ const value = React$1.useMemo(() => ({
77
+ emit,
78
+ subscribe
79
+ }), [emit, subscribe]);
80
+ return /* @__PURE__ */ jsx(SupportEventsContext.Provider, {
81
+ value,
82
+ children
83
+ });
84
+ };
85
+ /**
86
+ * Access the events context.
87
+ * Returns null if not inside a SupportEventsProvider.
88
+ */
89
+ function useSupportEvents() {
90
+ return React$1.useContext(SupportEventsContext);
91
+ }
92
+ /**
93
+ * Hook to emit events from within the widget.
94
+ * Safe to use outside of provider (will no-op).
95
+ */
96
+ function useSupportEventEmitter() {
97
+ const events = useSupportEvents();
98
+ return React$1.useMemo(() => ({
99
+ emitConversationStart: (conversationId, conversation) => {
100
+ events?.emit({
101
+ type: "conversationStart",
102
+ conversationId,
103
+ conversation
104
+ });
105
+ },
106
+ emitConversationEnd: (conversationId, conversation) => {
107
+ events?.emit({
108
+ type: "conversationEnd",
109
+ conversationId,
110
+ conversation
111
+ });
112
+ },
113
+ emitMessageSent: (conversationId, message) => {
114
+ events?.emit({
115
+ type: "messageSent",
116
+ conversationId,
117
+ message
118
+ });
119
+ },
120
+ emitMessageReceived: (conversationId, message) => {
121
+ events?.emit({
122
+ type: "messageReceived",
123
+ conversationId,
124
+ message
125
+ });
126
+ },
127
+ emitError: (error, context) => {
128
+ events?.emit({
129
+ type: "error",
130
+ error,
131
+ context
132
+ });
133
+ }
134
+ }), [events]);
135
+ }
136
+
137
+ //#endregion
138
+ export { SupportEventsProvider, useSupportEventEmitter, useSupportEvents };
139
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","names":["React","SupportEventsProvider: React.FC<SupportEventsProviderProps>"],"sources":["../../../src/support/context/events.tsx"],"sourcesContent":["\"use client\";\n\nimport type { Conversation } from \"@cossistant/types\";\nimport type { TimelineItem } from \"@cossistant/types/api/timeline-item\";\nimport * as React from \"react\";\n\n// =============================================================================\n// Event Types\n// =============================================================================\n\nexport type SupportEventType =\n\t| \"conversationStart\"\n\t| \"conversationEnd\"\n\t| \"messageSent\"\n\t| \"messageReceived\"\n\t| \"error\";\n\nexport type ConversationStartEvent = {\n\ttype: \"conversationStart\";\n\tconversationId: string;\n\tconversation?: Conversation;\n};\n\nexport type ConversationEndEvent = {\n\ttype: \"conversationEnd\";\n\tconversationId: string;\n\tconversation?: Conversation;\n};\n\nexport type MessageSentEvent = {\n\ttype: \"messageSent\";\n\tconversationId: string;\n\tmessage: TimelineItem;\n};\n\nexport type MessageReceivedEvent = {\n\ttype: \"messageReceived\";\n\tconversationId: string;\n\tmessage: TimelineItem;\n};\n\nexport type ErrorEvent = {\n\ttype: \"error\";\n\terror: Error;\n\tcontext?: string;\n};\n\nexport type SupportEvent =\n\t| ConversationStartEvent\n\t| ConversationEndEvent\n\t| MessageSentEvent\n\t| MessageReceivedEvent\n\t| ErrorEvent;\n\n// =============================================================================\n// Event Callbacks\n// =============================================================================\n\nexport type SupportEventCallbacks = {\n\t/**\n\t * Called when a new conversation is started.\n\t */\n\tonConversationStart?: (event: ConversationStartEvent) => void;\n\t/**\n\t * Called when a conversation ends (resolved, closed, etc.).\n\t */\n\tonConversationEnd?: (event: ConversationEndEvent) => void;\n\t/**\n\t * Called when the visitor sends a message.\n\t */\n\tonMessageSent?: (event: MessageSentEvent) => void;\n\t/**\n\t * Called when a message is received from an agent (human or AI).\n\t */\n\tonMessageReceived?: (event: MessageReceivedEvent) => void;\n\t/**\n\t * Called when an error occurs.\n\t */\n\tonError?: (event: ErrorEvent) => void;\n};\n\n// =============================================================================\n// Context\n// =============================================================================\n\nexport type SupportEventsContextValue = {\n\t/**\n\t * Emit an event to all registered callbacks.\n\t */\n\temit: <T extends SupportEvent>(event: T) => void;\n\t/**\n\t * Subscribe to a specific event type.\n\t * Returns an unsubscribe function.\n\t */\n\tsubscribe: <T extends SupportEventType>(\n\t\ttype: T,\n\t\tcallback: (event: Extract<SupportEvent, { type: T }>) => void\n\t) => () => void;\n};\n\nconst SupportEventsContext =\n\tReact.createContext<SupportEventsContextValue | null>(null);\n\nexport type SupportEventsProviderProps = SupportEventCallbacks & {\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider for support widget events.\n * Allows listening to lifecycle events like message sent/received,\n * conversation start/end, and errors.\n *\n * @example\n * <Support\n * onMessageSent={({ message }) => console.log(\"Sent:\", message)}\n * onMessageReceived={({ message }) => console.log(\"Received:\", message)}\n * onConversationStart={({ conversationId }) => console.log(\"Started:\", conversationId)}\n * onError={({ error }) => console.error(\"Error:\", error)}\n * />\n */\nexport const SupportEventsProvider: React.FC<SupportEventsProviderProps> = ({\n\tonConversationStart,\n\tonConversationEnd,\n\tonMessageSent,\n\tonMessageReceived,\n\tonError,\n\tchildren,\n}) => {\n\t// Store callbacks in refs to avoid stale closures\n\tconst callbacksRef = React.useRef<SupportEventCallbacks>({\n\t\tonConversationStart,\n\t\tonConversationEnd,\n\t\tonMessageSent,\n\t\tonMessageReceived,\n\t\tonError,\n\t});\n\n\t// Update refs when callbacks change\n\tReact.useEffect(() => {\n\t\tcallbacksRef.current = {\n\t\t\tonConversationStart,\n\t\t\tonConversationEnd,\n\t\t\tonMessageSent,\n\t\t\tonMessageReceived,\n\t\t\tonError,\n\t\t};\n\t}, [\n\t\tonConversationStart,\n\t\tonConversationEnd,\n\t\tonMessageSent,\n\t\tonMessageReceived,\n\t\tonError,\n\t]);\n\n\t// Additional subscribers (for internal use)\n\tconst subscribersRef = React.useRef<\n\t\tMap<SupportEventType, Set<(event: SupportEvent) => void>>\n\t>(new Map());\n\n\tconst emit = React.useCallback(<T extends SupportEvent>(event: T) => {\n\t\t// Call the prop callback\n\t\tswitch (event.type) {\n\t\t\tcase \"conversationStart\":\n\t\t\t\tcallbacksRef.current.onConversationStart?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"conversationEnd\":\n\t\t\t\tcallbacksRef.current.onConversationEnd?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"messageSent\":\n\t\t\t\tcallbacksRef.current.onMessageSent?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"messageReceived\":\n\t\t\t\tcallbacksRef.current.onMessageReceived?.(event);\n\t\t\t\tbreak;\n\t\t\tcase \"error\":\n\t\t\t\tcallbacksRef.current.onError?.(event);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// Unknown event type - no callback to call\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// Call any additional subscribers\n\t\tconst subscribers = subscribersRef.current.get(event.type);\n\t\tif (subscribers) {\n\t\t\tfor (const callback of subscribers) {\n\t\t\t\tcallback(event);\n\t\t\t}\n\t\t}\n\t}, []);\n\n\tconst subscribe = React.useCallback(\n\t\t<T extends SupportEventType>(\n\t\t\ttype: T,\n\t\t\tcallback: (event: Extract<SupportEvent, { type: T }>) => void\n\t\t) => {\n\t\t\tif (!subscribersRef.current.has(type)) {\n\t\t\t\tsubscribersRef.current.set(type, new Set());\n\t\t\t}\n\t\t\tconst subscribers = subscribersRef.current.get(type);\n\t\t\tsubscribers?.add(callback as (event: SupportEvent) => void);\n\n\t\t\t// Return unsubscribe function\n\t\t\treturn () => {\n\t\t\t\tsubscribers?.delete(callback as (event: SupportEvent) => void);\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst value = React.useMemo<SupportEventsContextValue>(\n\t\t() => ({ emit, subscribe }),\n\t\t[emit, subscribe]\n\t);\n\n\treturn (\n\t\t<SupportEventsContext.Provider value={value}>\n\t\t\t{children}\n\t\t</SupportEventsContext.Provider>\n\t);\n};\n\n/**\n * Access the events context.\n * Returns null if not inside a SupportEventsProvider.\n */\nexport function useSupportEvents(): SupportEventsContextValue | null {\n\treturn React.useContext(SupportEventsContext);\n}\n\n/**\n * Hook to emit events from within the widget.\n * Safe to use outside of provider (will no-op).\n */\nexport function useSupportEventEmitter() {\n\tconst events = useSupportEvents();\n\n\treturn React.useMemo(\n\t\t() => ({\n\t\t\temitConversationStart: (\n\t\t\t\tconversationId: string,\n\t\t\t\tconversation?: Conversation\n\t\t\t) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"conversationStart\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tconversation,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitConversationEnd: (\n\t\t\t\tconversationId: string,\n\t\t\t\tconversation?: Conversation\n\t\t\t) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"conversationEnd\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tconversation,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitMessageSent: (conversationId: string, message: TimelineItem) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"messageSent\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitMessageReceived: (conversationId: string, message: TimelineItem) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"messageReceived\",\n\t\t\t\t\tconversationId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t},\n\t\t\temitError: (error: Error, context?: string) => {\n\t\t\t\tevents?.emit({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\terror,\n\t\t\t\t\tcontext,\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t\t[events]\n\t);\n}\n"],"mappings":";;;;;;;AAoGA,MAAM,uBACLA,QAAM,cAAgD,KAAK;;;;;;;;;;;;;;AAmB5D,MAAaC,yBAA+D,EAC3E,qBACA,mBACA,eACA,mBACA,SACA,eACK;CAEL,MAAM,eAAeD,QAAM,OAA8B;EACxD;EACA;EACA;EACA;EACA;EACA,CAAC;AAGF,SAAM,gBAAgB;AACrB,eAAa,UAAU;GACtB;GACA;GACA;GACA;GACA;GACA;IACC;EACF;EACA;EACA;EACA;EACA;EACA,CAAC;CAGF,MAAM,iBAAiBA,QAAM,uBAE3B,IAAI,KAAK,CAAC;CAEZ,MAAM,OAAOA,QAAM,aAAqC,UAAa;AAEpE,UAAQ,MAAM,MAAd;GACC,KAAK;AACJ,iBAAa,QAAQ,sBAAsB,MAAM;AACjD;GACD,KAAK;AACJ,iBAAa,QAAQ,oBAAoB,MAAM;AAC/C;GACD,KAAK;AACJ,iBAAa,QAAQ,gBAAgB,MAAM;AAC3C;GACD,KAAK;AACJ,iBAAa,QAAQ,oBAAoB,MAAM;AAC/C;GACD,KAAK;AACJ,iBAAa,QAAQ,UAAU,MAAM;AACrC;GACD,QAEC;;EAIF,MAAM,cAAc,eAAe,QAAQ,IAAI,MAAM,KAAK;AAC1D,MAAI,YACH,MAAK,MAAM,YAAY,YACtB,UAAS,MAAM;IAGf,EAAE,CAAC;CAEN,MAAM,YAAYA,QAAM,aAEtB,MACA,aACI;AACJ,MAAI,CAAC,eAAe,QAAQ,IAAI,KAAK,CACpC,gBAAe,QAAQ,IAAI,sBAAM,IAAI,KAAK,CAAC;EAE5C,MAAM,cAAc,eAAe,QAAQ,IAAI,KAAK;AACpD,eAAa,IAAI,SAA0C;AAG3D,eAAa;AACZ,gBAAa,OAAO,SAA0C;;IAGhE,EAAE,CACF;CAED,MAAM,QAAQA,QAAM,eACZ;EAAE;EAAM;EAAW,GAC1B,CAAC,MAAM,UAAU,CACjB;AAED,QACC,oBAAC,qBAAqB;EAAgB;EACpC;GAC8B;;;;;;AAQlC,SAAgB,mBAAqD;AACpE,QAAOA,QAAM,WAAW,qBAAqB;;;;;;AAO9C,SAAgB,yBAAyB;CACxC,MAAM,SAAS,kBAAkB;AAEjC,QAAOA,QAAM,eACL;EACN,wBACC,gBACA,iBACI;AACJ,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,sBACC,gBACA,iBACI;AACJ,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,kBAAkB,gBAAwB,YAA0B;AACnE,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,sBAAsB,gBAAwB,YAA0B;AACvE,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,YAAY,OAAc,YAAqB;AAC9C,WAAQ,KAAK;IACZ,MAAM;IACN;IACA;IACA,CAAC;;EAEH,GACD,CAAC,OAAO,CACR"}
@@ -0,0 +1,90 @@
1
+ import * as React$1 from "react";
2
+ import { RouteRegistry } from "@cossistant/core";
3
+
4
+ //#region src/support/context/handle.d.ts
5
+
6
+ /**
7
+ * Imperative handle for programmatic control of the Support widget.
8
+ * Access via ref on the Support component or via useSupportHandle hook.
9
+ *
10
+ * @example
11
+ * const supportRef = useRef<SupportHandle>(null);
12
+ *
13
+ * // Open the widget
14
+ * supportRef.current?.open();
15
+ *
16
+ * // Navigate to a conversation
17
+ * supportRef.current?.openConversation("conv_123");
18
+ *
19
+ * // Start a new conversation with a message
20
+ * supportRef.current?.startConversation("I need help with...");
21
+ *
22
+ * <Support ref={supportRef} />
23
+ */
24
+ type SupportHandle = {
25
+ /**
26
+ * Open the support widget.
27
+ */
28
+ open: () => void;
29
+ /**
30
+ * Close the support widget.
31
+ */
32
+ close: () => void;
33
+ /**
34
+ * Toggle the support widget open/closed.
35
+ */
36
+ toggle: () => void;
37
+ /**
38
+ * Navigate to a specific page with optional params.
39
+ */
40
+ navigate: <K extends keyof RouteRegistry>(options: {
41
+ page: K;
42
+ params?: RouteRegistry[K];
43
+ }) => void;
44
+ /**
45
+ * Go back to the previous page.
46
+ */
47
+ goBack: () => void;
48
+ /**
49
+ * Open a specific conversation.
50
+ */
51
+ openConversation: (conversationId: string) => void;
52
+ /**
53
+ * Start a new conversation, optionally with an initial message.
54
+ */
55
+ startConversation: (initialMessage?: string) => void;
56
+ /**
57
+ * Navigate to the home page.
58
+ */
59
+ goHome: () => void;
60
+ };
61
+ type SupportHandleProviderProps = {
62
+ /**
63
+ * Ref to expose the handle to parent components.
64
+ */
65
+ forwardedRef?: React$1.Ref<SupportHandle>;
66
+ children: React$1.ReactNode;
67
+ };
68
+ /**
69
+ * Provider that creates and exposes the imperative handle.
70
+ */
71
+ declare const SupportHandleProvider: React$1.FC<SupportHandleProviderProps>;
72
+ /**
73
+ * Hook to access the imperative handle from within the widget.
74
+ * Returns null if not inside Support component.
75
+ *
76
+ * @example
77
+ * function MyComponent() {
78
+ * const support = useSupportHandle();
79
+ *
80
+ * return (
81
+ * <button onClick={() => support?.startConversation("Hello!")}>
82
+ * Get Help
83
+ * </button>
84
+ * );
85
+ * }
86
+ */
87
+ declare function useSupportHandle(): SupportHandle | null;
88
+ //#endregion
89
+ export { SupportHandle, SupportHandleProvider, SupportHandleProviderProps, useSupportHandle };
90
+ //# sourceMappingURL=handle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle.d.ts","names":[],"sources":["../../../src/support/context/handle.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA6BA;;;;;;AA4CA;;;;;AAWA;AA2EA;;;;KAlIY,aAAA;;;;;;;;;;;;;;;;6BAgBgB;UACpB;aACG,cAAc;;;;;;;;;;;;;;;;;;;KA0Bb,0BAAA;;;;iBAII,OAAA,CAAM,IAAI;YACf,OAAA,CAAM;;;;;cAMJ,uBAAuB,OAAA,CAAM,GAAG;;;;;;;;;;;;;;;;iBA2E7B,gBAAA,CAAA,GAAoB"}
@@ -0,0 +1,79 @@
1
+ "use client";
2
+
3
+
4
+ import { useSupportConfig, useSupportNavigation } from "../store/support-store.js";
5
+ import { PENDING_CONVERSATION_ID } from "../../utils/id.js";
6
+ import * as React$1 from "react";
7
+ import { jsx } from "react/jsx-runtime";
8
+
9
+ //#region src/support/context/handle.tsx
10
+ const SupportHandleContext = React$1.createContext(null);
11
+ /**
12
+ * Provider that creates and exposes the imperative handle.
13
+ */
14
+ const SupportHandleProvider = ({ forwardedRef, children }) => {
15
+ const { open, close, toggle } = useSupportConfig();
16
+ const { navigate, goBack } = useSupportNavigation();
17
+ const handle = React$1.useMemo(() => ({
18
+ open,
19
+ close,
20
+ toggle,
21
+ navigate: (options) => {
22
+ navigate(options);
23
+ },
24
+ goBack,
25
+ openConversation: (conversationId) => {
26
+ navigate({
27
+ page: "CONVERSATION",
28
+ params: { conversationId }
29
+ });
30
+ open();
31
+ },
32
+ startConversation: (initialMessage) => {
33
+ navigate({
34
+ page: "CONVERSATION",
35
+ params: {
36
+ conversationId: PENDING_CONVERSATION_ID,
37
+ initialMessage
38
+ }
39
+ });
40
+ open();
41
+ },
42
+ goHome: () => {
43
+ navigate({ page: "HOME" });
44
+ }
45
+ }), [
46
+ open,
47
+ close,
48
+ toggle,
49
+ navigate,
50
+ goBack
51
+ ]);
52
+ React$1.useImperativeHandle(forwardedRef, () => handle, [handle]);
53
+ return /* @__PURE__ */ jsx(SupportHandleContext.Provider, {
54
+ value: handle,
55
+ children
56
+ });
57
+ };
58
+ /**
59
+ * Hook to access the imperative handle from within the widget.
60
+ * Returns null if not inside Support component.
61
+ *
62
+ * @example
63
+ * function MyComponent() {
64
+ * const support = useSupportHandle();
65
+ *
66
+ * return (
67
+ * <button onClick={() => support?.startConversation("Hello!")}>
68
+ * Get Help
69
+ * </button>
70
+ * );
71
+ * }
72
+ */
73
+ function useSupportHandle() {
74
+ return React$1.useContext(SupportHandleContext);
75
+ }
76
+
77
+ //#endregion
78
+ export { SupportHandleProvider, useSupportHandle };
79
+ //# sourceMappingURL=handle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle.js","names":["React","SupportHandleProvider: React.FC<SupportHandleProviderProps>"],"sources":["../../../src/support/context/handle.tsx"],"sourcesContent":["\"use client\";\n\nimport type { RouteRegistry } from \"@cossistant/core\";\nimport * as React from \"react\";\nimport { PENDING_CONVERSATION_ID } from \"../../utils/id\";\nimport { useSupportConfig, useSupportNavigation } from \"../store/support-store\";\n\n// =============================================================================\n// Handle Type\n// =============================================================================\n\n/**\n * Imperative handle for programmatic control of the Support widget.\n * Access via ref on the Support component or via useSupportHandle hook.\n *\n * @example\n * const supportRef = useRef<SupportHandle>(null);\n *\n * // Open the widget\n * supportRef.current?.open();\n *\n * // Navigate to a conversation\n * supportRef.current?.openConversation(\"conv_123\");\n *\n * // Start a new conversation with a message\n * supportRef.current?.startConversation(\"I need help with...\");\n *\n * <Support ref={supportRef} />\n */\nexport type SupportHandle = {\n\t/**\n\t * Open the support widget.\n\t */\n\topen: () => void;\n\t/**\n\t * Close the support widget.\n\t */\n\tclose: () => void;\n\t/**\n\t * Toggle the support widget open/closed.\n\t */\n\ttoggle: () => void;\n\t/**\n\t * Navigate to a specific page with optional params.\n\t */\n\tnavigate: <K extends keyof RouteRegistry>(options: {\n\t\tpage: K;\n\t\tparams?: RouteRegistry[K];\n\t}) => void;\n\t/**\n\t * Go back to the previous page.\n\t */\n\tgoBack: () => void;\n\t/**\n\t * Open a specific conversation.\n\t */\n\topenConversation: (conversationId: string) => void;\n\t/**\n\t * Start a new conversation, optionally with an initial message.\n\t */\n\tstartConversation: (initialMessage?: string) => void;\n\t/**\n\t * Navigate to the home page.\n\t */\n\tgoHome: () => void;\n};\n\n// =============================================================================\n// Context\n// =============================================================================\n\nconst SupportHandleContext = React.createContext<SupportHandle | null>(null);\n\nexport type SupportHandleProviderProps = {\n\t/**\n\t * Ref to expose the handle to parent components.\n\t */\n\tforwardedRef?: React.Ref<SupportHandle>;\n\tchildren: React.ReactNode;\n};\n\n/**\n * Provider that creates and exposes the imperative handle.\n */\nexport const SupportHandleProvider: React.FC<SupportHandleProviderProps> = ({\n\tforwardedRef,\n\tchildren,\n}) => {\n\tconst { open, close, toggle } = useSupportConfig();\n\tconst { navigate, goBack } = useSupportNavigation();\n\n\tconst handle = React.useMemo<SupportHandle>(\n\t\t() => ({\n\t\t\topen,\n\t\t\tclose,\n\t\t\ttoggle,\n\t\t\tnavigate: <K extends keyof RouteRegistry>(options: {\n\t\t\t\tpage: K;\n\t\t\t\tparams?: RouteRegistry[K];\n\t\t\t}) => {\n\t\t\t\t// Use type assertion since we know the navigate function accepts these types\n\t\t\t\tnavigate(options as Parameters<typeof navigate>[0]);\n\t\t\t},\n\t\t\tgoBack,\n\t\t\topenConversation: (conversationId: string) => {\n\t\t\t\tnavigate({\n\t\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\t\tparams: { conversationId },\n\t\t\t\t});\n\t\t\t\t// Also open the widget if closed\n\t\t\t\topen();\n\t\t\t},\n\t\t\tstartConversation: (initialMessage?: string) => {\n\t\t\t\tnavigate({\n\t\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tconversationId: PENDING_CONVERSATION_ID,\n\t\t\t\t\t\tinitialMessage,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\t// Also open the widget if closed\n\t\t\t\topen();\n\t\t\t},\n\t\t\tgoHome: () => {\n\t\t\t\tnavigate({ page: \"HOME\" });\n\t\t\t},\n\t\t}),\n\t\t[open, close, toggle, navigate, goBack]\n\t);\n\n\t// Expose handle via ref\n\tReact.useImperativeHandle(forwardedRef, () => handle, [handle]);\n\n\treturn (\n\t\t<SupportHandleContext.Provider value={handle}>\n\t\t\t{children}\n\t\t</SupportHandleContext.Provider>\n\t);\n};\n\n// =============================================================================\n// Hook\n// =============================================================================\n\n/**\n * Hook to access the imperative handle from within the widget.\n * Returns null if not inside Support component.\n *\n * @example\n * function MyComponent() {\n * const support = useSupportHandle();\n *\n * return (\n * <button onClick={() => support?.startConversation(\"Hello!\")}>\n * Get Help\n * </button>\n * );\n * }\n */\nexport function useSupportHandle(): SupportHandle | null {\n\treturn React.useContext(SupportHandleContext);\n}\n"],"mappings":";;;;;;;;;AAuEA,MAAM,uBAAuBA,QAAM,cAAoC,KAAK;;;;AAa5E,MAAaC,yBAA+D,EAC3E,cACA,eACK;CACL,MAAM,EAAE,MAAM,OAAO,WAAW,kBAAkB;CAClD,MAAM,EAAE,UAAU,WAAW,sBAAsB;CAEnD,MAAM,SAASD,QAAM,eACb;EACN;EACA;EACA;EACA,WAA0C,YAGpC;AAEL,YAAS,QAA0C;;EAEpD;EACA,mBAAmB,mBAA2B;AAC7C,YAAS;IACR,MAAM;IACN,QAAQ,EAAE,gBAAgB;IAC1B,CAAC;AAEF,SAAM;;EAEP,oBAAoB,mBAA4B;AAC/C,YAAS;IACR,MAAM;IACN,QAAQ;KACP,gBAAgB;KAChB;KACA;IACD,CAAC;AAEF,SAAM;;EAEP,cAAc;AACb,YAAS,EAAE,MAAM,QAAQ,CAAC;;EAE3B,GACD;EAAC;EAAM;EAAO;EAAQ;EAAU;EAAO,CACvC;AAGD,SAAM,oBAAoB,oBAAoB,QAAQ,CAAC,OAAO,CAAC;AAE/D,QACC,oBAAC,qBAAqB;EAAS,OAAO;EACpC;GAC8B;;;;;;;;;;;;;;;;;AAuBlC,SAAgB,mBAAyC;AACxD,QAAOA,QAAM,WAAW,qBAAqB"}
@@ -0,0 +1,17 @@
1
+ import * as React$1 from "react";
2
+
3
+ //#region src/support/context/positioning.d.ts
4
+ type TriggerRefContextValue = {
5
+ /** The trigger element (state-based for reactivity) */
6
+ triggerElement: HTMLElement | null;
7
+ /** Set the trigger element - triggers re-render when called */
8
+ setTriggerElement: (element: HTMLElement | null) => void;
9
+ };
10
+ type TriggerRefProviderProps = {
11
+ children: React$1.ReactNode;
12
+ };
13
+ declare const TriggerRefProvider: React$1.FC<TriggerRefProviderProps>;
14
+ declare function useTriggerRef(): TriggerRefContextValue | null;
15
+ //#endregion
16
+ export { TriggerRefContextValue, TriggerRefProvider, TriggerRefProviderProps, useTriggerRef };
17
+ //# sourceMappingURL=positioning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positioning.d.ts","names":[],"sources":["../../../src/support/context/positioning.tsx"],"sourcesContent":[],"mappings":";;;KAQY,sBAAA;;EAAA,cAAA,EAEK,WAFiB,GAAA,IAAA;EAmBtB;EAIC,iBAAA,EAAA,CAAA,OAqBZ,EAxC6B,WAmBY,GAAA,IAAA,EAAA,GAAA,IAAA;AA2B1C,CAAA;KA/BY,uBAAA;YACD,OAAA,CAAM;;cAGJ,oBAAoB,OAAA,CAAM,GAAG;iBA2B1B,aAAA,CAAA,GAAiB"}
@@ -0,0 +1,26 @@
1
+ "use client";
2
+
3
+
4
+ import * as React$1 from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/support/context/positioning.tsx
8
+ const TriggerRefContext = React$1.createContext(null);
9
+ const TriggerRefProvider = ({ children }) => {
10
+ const [triggerElement, setTriggerElement] = React$1.useState(null);
11
+ const value = React$1.useMemo(() => ({
12
+ triggerElement,
13
+ setTriggerElement
14
+ }), [triggerElement]);
15
+ return /* @__PURE__ */ jsx(TriggerRefContext.Provider, {
16
+ value,
17
+ children
18
+ });
19
+ };
20
+ function useTriggerRef() {
21
+ return React$1.useContext(TriggerRefContext);
22
+ }
23
+
24
+ //#endregion
25
+ export { TriggerRefProvider, useTriggerRef };
26
+ //# sourceMappingURL=positioning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positioning.js","names":["React","TriggerRefProvider: React.FC<TriggerRefProviderProps>"],"sources":["../../../src/support/context/positioning.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport type TriggerRefContextValue = {\n\t/** The trigger element (state-based for reactivity) */\n\ttriggerElement: HTMLElement | null;\n\t/** Set the trigger element - triggers re-render when called */\n\tsetTriggerElement: (element: HTMLElement | null) => void;\n};\n\n// =============================================================================\n// Context\n// =============================================================================\n\nconst TriggerRefContext = React.createContext<TriggerRefContextValue | null>(\n\tnull\n);\n\n// =============================================================================\n// Provider\n// =============================================================================\n\nexport type TriggerRefProviderProps = {\n\tchildren: React.ReactNode;\n};\n\nexport const TriggerRefProvider: React.FC<TriggerRefProviderProps> = ({\n\tchildren,\n}) => {\n\t// Using state instead of ref to trigger re-renders when trigger mounts\n\t// This ensures Floating UI receives the reference element\n\tconst [triggerElement, setTriggerElement] =\n\t\tReact.useState<HTMLElement | null>(null);\n\n\tconst value = React.useMemo<TriggerRefContextValue>(\n\t\t() => ({\n\t\t\ttriggerElement,\n\t\t\tsetTriggerElement,\n\t\t}),\n\t\t[triggerElement]\n\t);\n\n\treturn (\n\t\t<TriggerRefContext.Provider value={value}>\n\t\t\t{children}\n\t\t</TriggerRefContext.Provider>\n\t);\n};\n\n// =============================================================================\n// Hook\n// =============================================================================\n\nexport function useTriggerRef(): TriggerRefContextValue | null {\n\treturn React.useContext(TriggerRefContext);\n}\n"],"mappings":";;;;;;;AAmBA,MAAM,oBAAoBA,QAAM,cAC/B,KACA;AAUD,MAAaC,sBAAyD,EACrE,eACK;CAGL,MAAM,CAAC,gBAAgB,qBACtBD,QAAM,SAA6B,KAAK;CAEzC,MAAM,QAAQA,QAAM,eACZ;EACN;EACA;EACA,GACD,CAAC,eAAe,CAChB;AAED,QACC,oBAAC,kBAAkB;EAAgB;EACjC;GAC2B;;AAQ/B,SAAgB,gBAA+C;AAC9D,QAAOA,QAAM,WAAW,kBAAkB"}