@bikdotai/bik-component-library 0.0.862 → 0.0.863-beta.1

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 (92) hide show
  1. package/dist/cjs/components/bik-copilot/BIKCopilot.js +2 -0
  2. package/dist/cjs/components/bik-copilot/BIKCopilot.js.map +1 -0
  3. package/dist/cjs/components/bik-copilot/ControlledCopilot.js +2 -0
  4. package/dist/cjs/components/bik-copilot/ControlledCopilot.js.map +1 -0
  5. package/dist/cjs/components/bik-copilot/ControlledCopilot.styled.js +27 -0
  6. package/dist/cjs/components/bik-copilot/ControlledCopilot.styled.js.map +1 -0
  7. package/dist/cjs/components/bik-copilot/CopilotBall.js +2 -0
  8. package/dist/cjs/components/bik-copilot/CopilotBall.js.map +1 -0
  9. package/dist/cjs/components/bik-copilot/CopilotBall.styled.js +42 -0
  10. package/dist/cjs/components/bik-copilot/CopilotBall.styled.js.map +1 -0
  11. package/dist/cjs/components/bik-copilot/CopilotPanel.js +2 -0
  12. package/dist/cjs/components/bik-copilot/CopilotPanel.js.map +1 -0
  13. package/dist/cjs/components/bik-copilot/CopilotPanel.styled.js +460 -0
  14. package/dist/cjs/components/bik-copilot/CopilotPanel.styled.js.map +1 -0
  15. package/dist/cjs/components/bik-copilot/copilotPlacement.js +2 -0
  16. package/dist/cjs/components/bik-copilot/copilotPlacement.js.map +1 -0
  17. package/dist/cjs/components/bik-copilot/services/copilotDb.js +2 -0
  18. package/dist/cjs/components/bik-copilot/services/copilotDb.js.map +1 -0
  19. package/dist/cjs/components/bik-copilot/services/copilotIcebreakersClient.js +2 -0
  20. package/dist/cjs/components/bik-copilot/services/copilotIcebreakersClient.js.map +1 -0
  21. package/dist/cjs/components/bik-copilot/services/copilotMessagesClient.js +2 -0
  22. package/dist/cjs/components/bik-copilot/services/copilotMessagesClient.js.map +1 -0
  23. package/dist/cjs/components/bik-copilot/services/copilotPageSession.js +2 -0
  24. package/dist/cjs/components/bik-copilot/services/copilotPageSession.js.map +1 -0
  25. package/dist/cjs/components/bik-copilot/services/copilotSseParser.js +7 -0
  26. package/dist/cjs/components/bik-copilot/services/copilotSseParser.js.map +1 -0
  27. package/dist/cjs/components/bik-copilot/services/copilotStreamClient.js +2 -0
  28. package/dist/cjs/components/bik-copilot/services/copilotStreamClient.js.map +1 -0
  29. package/dist/cjs/components/bik-copilot/useCopilotIcebreakers.js +2 -0
  30. package/dist/cjs/components/bik-copilot/useCopilotIcebreakers.js.map +1 -0
  31. package/dist/cjs/components/bik-copilot/useCopilotStreamChat.js +2 -0
  32. package/dist/cjs/components/bik-copilot/useCopilotStreamChat.js.map +1 -0
  33. package/dist/cjs/components/bik-copilot/useDraggableFloater.js +2 -0
  34. package/dist/cjs/components/bik-copilot/useDraggableFloater.js.map +1 -0
  35. package/dist/cjs/index.js +1 -1
  36. package/dist/esm/components/bik-copilot/BIKCopilot.d.ts +32 -0
  37. package/dist/esm/components/bik-copilot/BIKCopilot.js +114 -0
  38. package/dist/esm/components/bik-copilot/BIKCopilot.js.map +1 -0
  39. package/dist/esm/components/bik-copilot/ControlledCopilot.d.ts +14 -0
  40. package/dist/esm/components/bik-copilot/ControlledCopilot.js +170 -0
  41. package/dist/esm/components/bik-copilot/ControlledCopilot.js.map +1 -0
  42. package/dist/esm/components/bik-copilot/ControlledCopilot.styled.d.ts +7 -0
  43. package/dist/esm/components/bik-copilot/ControlledCopilot.styled.js +31 -0
  44. package/dist/esm/components/bik-copilot/ControlledCopilot.styled.js.map +1 -0
  45. package/dist/esm/components/bik-copilot/CopilotBall.d.ts +13 -0
  46. package/dist/esm/components/bik-copilot/CopilotBall.js +50 -0
  47. package/dist/esm/components/bik-copilot/CopilotBall.js.map +1 -0
  48. package/dist/esm/components/bik-copilot/CopilotBall.styled.d.ts +9 -0
  49. package/dist/esm/components/bik-copilot/CopilotBall.styled.js +46 -0
  50. package/dist/esm/components/bik-copilot/CopilotBall.styled.js.map +1 -0
  51. package/dist/esm/components/bik-copilot/CopilotPanel.d.ts +9 -0
  52. package/dist/esm/components/bik-copilot/CopilotPanel.js +379 -0
  53. package/dist/esm/components/bik-copilot/CopilotPanel.js.map +1 -0
  54. package/dist/esm/components/bik-copilot/CopilotPanel.styled.d.ts +64 -0
  55. package/dist/esm/components/bik-copilot/CopilotPanel.styled.js +496 -0
  56. package/dist/esm/components/bik-copilot/CopilotPanel.styled.js.map +1 -0
  57. package/dist/esm/components/bik-copilot/copilotPlacement.d.ts +24 -0
  58. package/dist/esm/components/bik-copilot/copilotPlacement.js +38 -0
  59. package/dist/esm/components/bik-copilot/copilotPlacement.js.map +1 -0
  60. package/dist/esm/components/bik-copilot/index.d.ts +16 -0
  61. package/dist/esm/components/bik-copilot/model.d.ts +674 -0
  62. package/dist/esm/components/bik-copilot/services/copilotDb.d.ts +90 -0
  63. package/dist/esm/components/bik-copilot/services/copilotDb.js +96 -0
  64. package/dist/esm/components/bik-copilot/services/copilotDb.js.map +1 -0
  65. package/dist/esm/components/bik-copilot/services/copilotIcebreakersClient.d.ts +11 -0
  66. package/dist/esm/components/bik-copilot/services/copilotIcebreakersClient.js +54 -0
  67. package/dist/esm/components/bik-copilot/services/copilotIcebreakersClient.js.map +1 -0
  68. package/dist/esm/components/bik-copilot/services/copilotMessagesClient.d.ts +23 -0
  69. package/dist/esm/components/bik-copilot/services/copilotMessagesClient.js +78 -0
  70. package/dist/esm/components/bik-copilot/services/copilotMessagesClient.js.map +1 -0
  71. package/dist/esm/components/bik-copilot/services/copilotPageSession.d.ts +37 -0
  72. package/dist/esm/components/bik-copilot/services/copilotPageSession.js +35 -0
  73. package/dist/esm/components/bik-copilot/services/copilotPageSession.js.map +1 -0
  74. package/dist/esm/components/bik-copilot/services/copilotSseParser.d.ts +22 -0
  75. package/dist/esm/components/bik-copilot/services/copilotSseParser.js +52 -0
  76. package/dist/esm/components/bik-copilot/services/copilotSseParser.js.map +1 -0
  77. package/dist/esm/components/bik-copilot/services/copilotStreamClient.d.ts +31 -0
  78. package/dist/esm/components/bik-copilot/services/copilotStreamClient.js +103 -0
  79. package/dist/esm/components/bik-copilot/services/copilotStreamClient.js.map +1 -0
  80. package/dist/esm/components/bik-copilot/useCopilotIcebreakers.d.ts +17 -0
  81. package/dist/esm/components/bik-copilot/useCopilotIcebreakers.js +60 -0
  82. package/dist/esm/components/bik-copilot/useCopilotIcebreakers.js.map +1 -0
  83. package/dist/esm/components/bik-copilot/useCopilotStreamChat.d.ts +20 -0
  84. package/dist/esm/components/bik-copilot/useCopilotStreamChat.js +333 -0
  85. package/dist/esm/components/bik-copilot/useCopilotStreamChat.js.map +1 -0
  86. package/dist/esm/components/bik-copilot/useDraggableFloater.d.ts +9 -0
  87. package/dist/esm/components/bik-copilot/useDraggableFloater.js +118 -0
  88. package/dist/esm/components/bik-copilot/useDraggableFloater.js.map +1 -0
  89. package/dist/esm/index.d.ts +1 -0
  90. package/dist/esm/index.js +832 -782
  91. package/dist/esm/index.js.map +1 -1
  92. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BIKCopilot.js","sources":["../../../../src/components/bik-copilot/BIKCopilot.tsx"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport { ControlledCopilot } from './ControlledCopilot';\nimport { BIKCopilotProps } from './model';\nimport { useCopilotIcebreakers } from './useCopilotIcebreakers';\nimport { useCopilotStreamChat } from './useCopilotStreamChat';\n\n/**\n * The copilot ball and panel wired to the streaming `/bik-ai/copilot-chatbot`\n * endpoint, with the transcript persisted in IndexedDB and route-aware ice\n * breakers from `/bik-ai/copilot-icebreakers`.\n *\n * Chunks arrive as `STREAM` events and are appended live; the final `TEXT` event\n * replaces the bubble with the authoritative full message and carries the\n * `responseId` that threads the next turn. A session id is created on first use\n * and restored on reload, so a refresh resumes the same conversation. The\n * header's reset button starts a new session id and a new OpenAI thread.\n *\n * Ice breakers are fetched for the current `agent` + `route` the first time the\n * panel is opened, and refetched when the route changes.\n *\n * ```tsx\n * <BIKCopilot\n * baseUrl={AI_BACKEND_URL}\n * getAuthToken={() => firebaseUser.getIdToken()}\n * headers={{ 'bik-referer': 'dashboard' }}\n * storeId={storeId}\n * email={user.email}\n * route={currentRoute}\n * title=\"Copilot\"\n * badge=\"New\"\n * subtitle=\"Way smarter, wildly more capable\"\n * />\n * ```\n */\nexport const BIKCopilot: React.FC<BIKCopilotProps> = ({\n\t// Transport + turn config\n\tbaseUrl,\n\tendpointPath,\n\ticebreakersPath,\n\theaders,\n\tauthToken,\n\tgetAuthToken,\n\tfetchImpl,\n\tstoreId,\n\tagent,\n\troute,\n\temail,\n\tsystemPrompt,\n\tmodel,\n\tmaxOutputTokens,\n\tsessionId,\n\tpersist,\n\tloadIcebreakers = true,\n\tonError,\n\tonResponseComplete,\n\tonSessionIdChange,\n\t// Shell\n\tsuggestions,\n\tinputDisabled,\n\tonRefresh,\n\topen,\n\tdefaultOpen,\n\tonOpenChange,\n\t...shellProps\n}) => {\n\t// Ice breakers only matter once the panel is visible, so a merchant who never\n\t// opens the copilot costs no request.\n\tconst [hasOpened, setHasOpened] = useState(\n\t\tdefaultOpen === true || open === true,\n\t);\n\n\tconst {\n\t\tmessages,\n\t\tisThinking,\n\t\tisStreaming,\n\t\tisRestoring,\n\t\terror,\n\t\tisLoadingHistory,\n\t\thasMoreHistory,\n\t\tsendMessage,\n\t\tloadOlderMessages,\n\t\tstopStreaming,\n\t\tstartNewConversation,\n\t} = useCopilotStreamChat({\n\t\tbaseUrl,\n\t\tendpointPath,\n\t\theaders,\n\t\tauthToken,\n\t\tgetAuthToken,\n\t\tfetchImpl,\n\t\tstoreId,\n\t\tagent,\n\t\troute,\n\t\temail,\n\t\tsystemPrompt,\n\t\tmodel,\n\t\tmaxOutputTokens,\n\t\tsessionId,\n\t\tpersist,\n\t\tonError,\n\t\tonResponseComplete,\n\t\tonSessionIdChange,\n\t});\n\n\tconst { icebreakers } = useCopilotIcebreakers({\n\t\tbaseUrl,\n\t\ticebreakersPath,\n\t\theaders,\n\t\tauthToken,\n\t\tgetAuthToken,\n\t\tfetchImpl,\n\t\tagent,\n\t\troute,\n\t\tstoreId,\n\t\tenabled: loadIcebreakers && hasOpened,\n\t});\n\n\tconst handleOpenChange = useCallback(\n\t\t(nextOpen: boolean) => {\n\t\t\tif (nextOpen) {\n\t\t\t\tsetHasOpened(true);\n\t\t\t}\n\t\t\tonOpenChange?.(nextOpen);\n\t\t},\n\t\t[onOpenChange],\n\t);\n\n\tconst handleRefresh = useCallback(() => {\n\t\tstartNewConversation();\n\t\tonRefresh?.();\n\t}, [onRefresh, startNewConversation]);\n\n\treturn (\n\t\t<ControlledCopilot\n\t\t\t{...shellProps}\n\t\t\topen={open}\n\t\t\tdefaultOpen={defaultOpen}\n\t\t\tonOpenChange={handleOpenChange}\n\t\t\tmessages={messages}\n\t\t\tonSendMessage={sendMessage}\n\t\t\tisThinking={isThinking}\n\t\t\tisStreaming={isStreaming}\n\t\t\tonStop={stopStreaming}\n\t\t\tisLoadingHistory={isLoadingHistory}\n\t\t\thasMoreHistory={hasMoreHistory}\n\t\t\tonLoadOlderMessages={loadOlderMessages}\n\t\t\terrorMessage={error}\n\t\t\t// An explicit list wins; otherwise the route's fetched prompts show. A\n\t\t\t// failed or empty fetch simply leaves the empty state without chips.\n\t\t\tsuggestions={suggestions ?? icebreakers}\n\t\t\t// A second prompt mid-stream would race the thread's responseId.\n\t\t\tinputDisabled={inputDisabled || isRestoring || isStreaming}\n\t\t\tonRefresh={handleRefresh}\n\t\t/>\n\t);\n};\n\nexport default BIKCopilot;\n"],"names":["BIKCopilot","baseUrl","endpointPath","icebreakersPath","headers","authToken","getAuthToken","fetchImpl","storeId","agent","route","email","systemPrompt","model","maxOutputTokens","sessionId","persist","loadIcebreakers","onError","onResponseComplete","onSessionIdChange","suggestions","inputDisabled","onRefresh","open","defaultOpen","onOpenChange","shellProps","hasOpened","setHasOpened","useState","messages","isThinking","isStreaming","isRestoring","error","isLoadingHistory","hasMoreHistory","sendMessage","loadOlderMessages","stopStreaming","startNewConversation","useCopilotStreamChat","icebreakers","useCopilotIcebreakers","handleOpenChange","useCallback","nextOpen","handleRefresh","jsx","ControlledCopilot"],"mappings":";;;;;AAkCO,MAAMA,KAAwC,CAAC;AAAA;AAAA,EAErD,SAAAC;AAAA,EACA,cAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,OAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,SAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,mBAAAC;AAAA;AAAA,EAEA,aAAAC;AAAA,EACA,eAAAC;AAAA,EACA,WAAAC;AAAA,EACA,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,GAAGC;AACJ,MAAM;AAGL,QAAM,CAACC,GAAWC,CAAY,IAAIC;AAAA,IACjCL,MAAgB,MAAQD,MAAS;AAAA,EAAA,GAG5B;AAAA,IACL,UAAAO;AAAA,IACA,YAAAC;AAAA,IACA,aAAAC;AAAA,IACA,aAAAC;AAAA,IACA,OAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,eAAAC;AAAA,IACA,sBAAAC;AAAA,EAAA,IACGC,EAAqB;AAAA,IACxB,SAAAzC;AAAA,IACA,cAAAC;AAAA,IACA,SAAAE;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,OAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,SAAAE;AAAA,IACA,oBAAAC;AAAA,IACA,mBAAAC;AAAA,EAAA,CACA,GAEK,EAAE,aAAAuB,EAAA,IAAgBC,EAAsB;AAAA,IAC7C,SAAA3C;AAAA,IACA,iBAAAE;AAAA,IACA,SAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAE;AAAA,IACA,OAAAC;AAAA,IACA,SAAAF;AAAA,IACA,SAASS,KAAmBW;AAAA,EAAA,CAC5B,GAEKiB,IAAmBC;AAAA,IACxB,CAACC,MAAsB;AACtB,MAAIA,KACHlB,EAAa,EAAI,GAElBH,IAAeqB,CAAQ;AAAA,IACxB;AAAA,IACA,CAACrB,CAAY;AAAA,EAAA,GAGRsB,IAAgBF,EAAY,MAAM;AACvC,IAAAL,EAAA,GACAlB,IAAA;AAAA,EACD,GAAG,CAACA,GAAWkB,CAAoB,CAAC;AAEpC,SACC,gBAAAQ;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,GAAGvB;AAAA,MACJ,MAAAH;AAAA,MACA,aAAAC;AAAA,MACA,cAAcoB;AAAA,MACd,UAAAd;AAAA,MACA,eAAeO;AAAA,MACf,YAAAN;AAAA,MACA,aAAAC;AAAA,MACA,QAAQO;AAAA,MACR,kBAAAJ;AAAA,MACA,gBAAAC;AAAA,MACA,qBAAqBE;AAAA,MACrB,cAAcJ;AAAA,MAGd,aAAad,KAAesB;AAAA,MAE5B,eAAerB,KAAiBY,KAAeD;AAAA,MAC/C,WAAWe;AAAA,IAAA;AAAA,EAAA;AAGd;"}
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ import { ControlledCopilotProps } from './model';
3
+ /**
4
+ * The presentational half of the copilot: a draggable floating ball that opens a
5
+ * chat panel beside it.
6
+ *
7
+ * Fully controlled — it renders the `messages` it is handed and reports every
8
+ * user action through callbacks, so it carries no backend knowledge. **Use
9
+ * `BIKCopilot` instead** unless you are wiring a backend other than
10
+ * `/bik-ai/copilot-chatbot`; `BIKCopilot` is this component plus the streaming
11
+ * transport, IndexedDB history and route-aware ice breakers.
12
+ */
13
+ export declare const ControlledCopilot: React.FC<ControlledCopilotProps>;
14
+ export default ControlledCopilot;
@@ -0,0 +1,170 @@
1
+ import { jsxs as pe, Fragment as me, jsx as a } from "react/jsx-runtime";
2
+ import { useState as ue, useRef as ge, useCallback as C, useEffect as v } from "react";
3
+ import { COLORS as he } from "../../constants/Theme.js";
4
+ import { PanelPositioner as Ce } from "./ControlledCopilot.styled.js";
5
+ import { CopilotBall as ve, COPILOT_BALL_ATTRIBUTE as we } from "./CopilotBall.js";
6
+ import { CopilotPanel as Le } from "./CopilotPanel.js";
7
+ import { getCopilotPanelPlacement as Pe } from "./copilotPlacement.js";
8
+ import { useDraggableFloater as Ee } from "./useDraggableFloater.js";
9
+ const De = ({
10
+ // Conversation
11
+ messages: w,
12
+ onSendMessage: L,
13
+ isThinking: P = !1,
14
+ thinkingLabel: E,
15
+ isStreaming: k = !1,
16
+ onStop: $,
17
+ interruptedLabel: b,
18
+ followUpsLabel: I,
19
+ hasMoreHistory: O = !1,
20
+ isLoadingHistory: T = !1,
21
+ onLoadOlderMessages: y,
22
+ historyLoadingLabel: B,
23
+ errorMessage: D,
24
+ // Ball
25
+ ballSize: r = 56,
26
+ corner: R = "bottom-right",
27
+ offset: x = 24,
28
+ initialPosition: j,
29
+ draggable: f = !0,
30
+ snapToEdge: A = !0,
31
+ onPositionChange: F,
32
+ ballIcon: U,
33
+ ballOpenIcon: _,
34
+ ballColor: z = he.background.brand,
35
+ zIndex: c = 1200,
36
+ ballAriaLabel: H,
37
+ // Panel
38
+ panelWidth: K = 400,
39
+ panelHeight: S = 700,
40
+ panelGap: q = 12,
41
+ title: G = "Copilot",
42
+ badge: J,
43
+ subtitle: M,
44
+ avatar: N,
45
+ placeholder: Q,
46
+ disclaimer: V,
47
+ emptyStateTitle: W,
48
+ emptyStateSubtitle: X,
49
+ suggestions: Y,
50
+ onSuggestionClick: Z,
51
+ showRefresh: ee = !0,
52
+ onRefresh: oe,
53
+ inputDisabled: te = !1,
54
+ // Open state
55
+ open: d,
56
+ defaultOpen: ne = !1,
57
+ onOpenChange: p,
58
+ closeOnClickOutside: m = !1,
59
+ className: re,
60
+ style: ie
61
+ }) => {
62
+ const [le, se] = ue(ne), u = ge(null), i = d !== void 0, e = i ? d : le, t = C(
63
+ (o) => {
64
+ i || se(o), p?.(o);
65
+ },
66
+ [i, p]
67
+ ), { position: g, isDragging: ae, viewport: fe, dragHandlers: ce, shouldIgnoreClick: h } = Ee({
68
+ size: r,
69
+ corner: R,
70
+ offset: x,
71
+ enabled: f,
72
+ snapToEdge: A,
73
+ initialPosition: j,
74
+ onPositionChange: F
75
+ }), de = C(() => {
76
+ h() || t(!e);
77
+ }, [e, t, h]);
78
+ v(() => {
79
+ if (!e)
80
+ return;
81
+ const o = (l) => {
82
+ l.key === "Escape" && t(!1);
83
+ };
84
+ return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
85
+ }, [e, t]), v(() => {
86
+ if (!e || !m)
87
+ return;
88
+ const o = (l) => {
89
+ const s = l.target;
90
+ s && (u.current?.contains(s) || s.closest(`[${we}]`) || t(!1));
91
+ };
92
+ return document.addEventListener("pointerdown", o), () => document.removeEventListener("pointerdown", o);
93
+ }, [m, e, t]);
94
+ const n = Pe({
95
+ ballPosition: g,
96
+ ballSize: r,
97
+ panelWidth: K,
98
+ panelHeight: S,
99
+ gap: q,
100
+ viewport: fe
101
+ });
102
+ return /* @__PURE__ */ pe(me, { children: [
103
+ e && /* @__PURE__ */ a(
104
+ Ce,
105
+ {
106
+ ref: u,
107
+ $left: n.left,
108
+ $top: n.top,
109
+ $width: n.width,
110
+ $height: n.height,
111
+ $zIndex: c,
112
+ children: /* @__PURE__ */ a(
113
+ Le,
114
+ {
115
+ messages: w,
116
+ onSend: L,
117
+ onClose: () => t(!1),
118
+ title: G,
119
+ badge: J,
120
+ subtitle: M,
121
+ avatar: N,
122
+ placeholder: Q,
123
+ disclaimer: V,
124
+ emptyStateTitle: W,
125
+ emptyStateSubtitle: X,
126
+ suggestions: Y,
127
+ onSuggestionClick: Z,
128
+ showRefresh: ee,
129
+ onRefresh: oe,
130
+ isThinking: P,
131
+ thinkingLabel: E,
132
+ isStreaming: k,
133
+ onStop: $,
134
+ interruptedLabel: b,
135
+ followUpsLabel: I,
136
+ hasMoreHistory: O,
137
+ isLoadingHistory: T,
138
+ onLoadOlderMessages: y,
139
+ historyLoadingLabel: B,
140
+ inputDisabled: te,
141
+ errorMessage: D,
142
+ className: re,
143
+ style: ie
144
+ }
145
+ )
146
+ }
147
+ ),
148
+ /* @__PURE__ */ a(
149
+ ve,
150
+ {
151
+ isOpen: e,
152
+ onToggle: de,
153
+ position: g,
154
+ size: r,
155
+ isDragging: ae,
156
+ draggable: f,
157
+ color: z,
158
+ zIndex: c + 1,
159
+ icon: U,
160
+ openIcon: _,
161
+ ariaLabel: H,
162
+ ...ce
163
+ }
164
+ )
165
+ ] });
166
+ };
167
+ export {
168
+ De as ControlledCopilot
169
+ };
170
+ //# sourceMappingURL=ControlledCopilot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlledCopilot.js","sources":["../../../../src/components/bik-copilot/ControlledCopilot.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { COLORS } from '@src/constants/Theme';\nimport { PanelPositioner } from './ControlledCopilot.styled';\nimport { COPILOT_BALL_ATTRIBUTE, CopilotBall } from './CopilotBall';\nimport { CopilotPanel } from './CopilotPanel';\nimport { getCopilotPanelPlacement } from './copilotPlacement';\nimport { ControlledCopilotProps } from './model';\nimport { useDraggableFloater } from './useDraggableFloater';\n\n/**\n * The presentational half of the copilot: a draggable floating ball that opens a\n * chat panel beside it.\n *\n * Fully controlled — it renders the `messages` it is handed and reports every\n * user action through callbacks, so it carries no backend knowledge. **Use\n * `BIKCopilot` instead** unless you are wiring a backend other than\n * `/bik-ai/copilot-chatbot`; `BIKCopilot` is this component plus the streaming\n * transport, IndexedDB history and route-aware ice breakers.\n */\nexport const ControlledCopilot: React.FC<ControlledCopilotProps> = ({\n\t// Conversation\n\tmessages,\n\tonSendMessage,\n\tisThinking = false,\n\tthinkingLabel,\n\tisStreaming = false,\n\tonStop,\n\tinterruptedLabel,\n\tfollowUpsLabel,\n\thasMoreHistory = false,\n\tisLoadingHistory = false,\n\tonLoadOlderMessages,\n\thistoryLoadingLabel,\n\terrorMessage,\n\t// Ball\n\tballSize = 56,\n\tcorner = 'bottom-right',\n\toffset = 24,\n\tinitialPosition,\n\tdraggable = true,\n\tsnapToEdge = true,\n\tonPositionChange,\n\tballIcon,\n\tballOpenIcon,\n\tballColor = COLORS.background.brand,\n\tzIndex = 1200,\n\tballAriaLabel,\n\t// Panel\n\tpanelWidth = 400,\n\tpanelHeight = 700,\n\tpanelGap = 12,\n\ttitle = 'Copilot',\n\tbadge,\n\tsubtitle,\n\tavatar,\n\tplaceholder,\n\tdisclaimer,\n\temptyStateTitle,\n\temptyStateSubtitle,\n\tsuggestions,\n\tonSuggestionClick,\n\tshowRefresh = true,\n\tonRefresh,\n\tinputDisabled = false,\n\t// Open state\n\topen,\n\tdefaultOpen = false,\n\tonOpenChange,\n\tcloseOnClickOutside = false,\n\tclassName,\n\tstyle,\n}) => {\n\tconst [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n\tconst panelRef = useRef<HTMLDivElement>(null);\n\n\tconst isControlled = open !== undefined;\n\tconst isOpen = isControlled ? open : uncontrolledOpen;\n\n\tconst setOpen = useCallback(\n\t\t(next: boolean) => {\n\t\t\tif (!isControlled) {\n\t\t\t\tsetUncontrolledOpen(next);\n\t\t\t}\n\t\t\tonOpenChange?.(next);\n\t\t},\n\t\t[isControlled, onOpenChange],\n\t);\n\n\tconst { position, isDragging, viewport, dragHandlers, shouldIgnoreClick } =\n\t\tuseDraggableFloater({\n\t\t\tsize: ballSize,\n\t\t\tcorner,\n\t\t\toffset,\n\t\t\tenabled: draggable,\n\t\t\tsnapToEdge,\n\t\t\tinitialPosition,\n\t\t\tonPositionChange,\n\t\t});\n\n\tconst handleBallClick = useCallback(() => {\n\t\t// The click that ends a drag gesture must not toggle the panel.\n\t\tif (shouldIgnoreClick()) {\n\t\t\treturn;\n\t\t}\n\t\tsetOpen(!isOpen);\n\t}, [isOpen, setOpen, shouldIgnoreClick]);\n\n\t// Escape closes the panel.\n\tuseEffect(() => {\n\t\tif (!isOpen) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst handleKeyDown = (event: KeyboardEvent) => {\n\t\t\tif (event.key === 'Escape') {\n\t\t\t\tsetOpen(false);\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener('keydown', handleKeyDown);\n\t\treturn () => document.removeEventListener('keydown', handleKeyDown);\n\t}, [isOpen, setOpen]);\n\n\tuseEffect(() => {\n\t\tif (!isOpen || !closeOnClickOutside) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst handlePointerDown = (event: PointerEvent) => {\n\t\t\tconst target = event.target as HTMLElement | null;\n\t\t\tif (!target) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (panelRef.current?.contains(target)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (target.closest(`[${COPILOT_BALL_ATTRIBUTE}]`)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetOpen(false);\n\t\t};\n\t\tdocument.addEventListener('pointerdown', handlePointerDown);\n\t\treturn () => document.removeEventListener('pointerdown', handlePointerDown);\n\t}, [closeOnClickOutside, isOpen, setOpen]);\n\n\tconst placement = getCopilotPanelPlacement({\n\t\tballPosition: position,\n\t\tballSize,\n\t\tpanelWidth,\n\t\tpanelHeight,\n\t\tgap: panelGap,\n\t\tviewport,\n\t});\n\n\treturn (\n\t\t<>\n\t\t\t{isOpen && (\n\t\t\t\t<PanelPositioner\n\t\t\t\t\tref={panelRef}\n\t\t\t\t\t$left={placement.left}\n\t\t\t\t\t$top={placement.top}\n\t\t\t\t\t$width={placement.width}\n\t\t\t\t\t$height={placement.height}\n\t\t\t\t\t$zIndex={zIndex}\n\t\t\t\t>\n\t\t\t\t\t<CopilotPanel\n\t\t\t\t\t\tmessages={messages}\n\t\t\t\t\t\tonSend={onSendMessage}\n\t\t\t\t\t\tonClose={() => setOpen(false)}\n\t\t\t\t\t\ttitle={title}\n\t\t\t\t\t\tbadge={badge}\n\t\t\t\t\t\tsubtitle={subtitle}\n\t\t\t\t\t\tavatar={avatar}\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\tdisclaimer={disclaimer}\n\t\t\t\t\t\temptyStateTitle={emptyStateTitle}\n\t\t\t\t\t\temptyStateSubtitle={emptyStateSubtitle}\n\t\t\t\t\t\tsuggestions={suggestions}\n\t\t\t\t\t\tonSuggestionClick={onSuggestionClick}\n\t\t\t\t\t\tshowRefresh={showRefresh}\n\t\t\t\t\t\tonRefresh={onRefresh}\n\t\t\t\t\t\tisThinking={isThinking}\n\t\t\t\t\t\tthinkingLabel={thinkingLabel}\n\t\t\t\t\t\tisStreaming={isStreaming}\n\t\t\t\t\t\tonStop={onStop}\n\t\t\t\t\t\tinterruptedLabel={interruptedLabel}\n\t\t\t\t\t\tfollowUpsLabel={followUpsLabel}\n\t\t\t\t\t\thasMoreHistory={hasMoreHistory}\n\t\t\t\t\t\tisLoadingHistory={isLoadingHistory}\n\t\t\t\t\t\tonLoadOlderMessages={onLoadOlderMessages}\n\t\t\t\t\t\thistoryLoadingLabel={historyLoadingLabel}\n\t\t\t\t\t\tinputDisabled={inputDisabled}\n\t\t\t\t\t\terrorMessage={errorMessage}\n\t\t\t\t\t\tclassName={className}\n\t\t\t\t\t\tstyle={style}\n\t\t\t\t\t/>\n\t\t\t\t</PanelPositioner>\n\t\t\t)}\n\n\t\t\t<CopilotBall\n\t\t\t\tisOpen={isOpen}\n\t\t\t\tonToggle={handleBallClick}\n\t\t\t\tposition={position}\n\t\t\t\tsize={ballSize}\n\t\t\t\tisDragging={isDragging}\n\t\t\t\tdraggable={draggable}\n\t\t\t\tcolor={ballColor}\n\t\t\t\tzIndex={zIndex + 1}\n\t\t\t\ticon={ballIcon}\n\t\t\t\topenIcon={ballOpenIcon}\n\t\t\t\tariaLabel={ballAriaLabel}\n\t\t\t\t{...dragHandlers}\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default ControlledCopilot;\n"],"names":["ControlledCopilot","messages","onSendMessage","isThinking","thinkingLabel","isStreaming","onStop","interruptedLabel","followUpsLabel","hasMoreHistory","isLoadingHistory","onLoadOlderMessages","historyLoadingLabel","errorMessage","ballSize","corner","offset","initialPosition","draggable","snapToEdge","onPositionChange","ballIcon","ballOpenIcon","ballColor","COLORS","zIndex","ballAriaLabel","panelWidth","panelHeight","panelGap","title","badge","subtitle","avatar","placeholder","disclaimer","emptyStateTitle","emptyStateSubtitle","suggestions","onSuggestionClick","showRefresh","onRefresh","inputDisabled","open","defaultOpen","onOpenChange","closeOnClickOutside","className","style","uncontrolledOpen","setUncontrolledOpen","useState","panelRef","useRef","isControlled","isOpen","setOpen","useCallback","next","position","isDragging","viewport","dragHandlers","shouldIgnoreClick","useDraggableFloater","handleBallClick","useEffect","handleKeyDown","event","handlePointerDown","target","COPILOT_BALL_ATTRIBUTE","placement","getCopilotPanelPlacement","jsxs","Fragment","jsx","PanelPositioner","CopilotPanel","CopilotBall"],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ export declare const PanelPositioner: import('styled-components').StyledComponent<"div", any, {
2
+ $left: number;
3
+ $top: number;
4
+ $width: number;
5
+ $height: number;
6
+ $zIndex: number;
7
+ }, never>;
@@ -0,0 +1,31 @@
1
+ import e from "styled-components";
2
+ const o = e.div`
3
+ position: fixed;
4
+ left: ${(t) => t.$left}px;
5
+ top: ${(t) => t.$top}px;
6
+ width: ${(t) => t.$width}px;
7
+ height: ${(t) => t.$height}px;
8
+ z-index: ${(t) => t.$zIndex};
9
+ display: flex;
10
+ animation: bikCopilotPanelIn 0.16s ease-out;
11
+
12
+ > * {
13
+ flex: 1;
14
+ min-width: 0;
15
+ }
16
+
17
+ @keyframes bikCopilotPanelIn {
18
+ from {
19
+ opacity: 0;
20
+ transform: translateY(6px) scale(0.98);
21
+ }
22
+ to {
23
+ opacity: 1;
24
+ transform: translateY(0) scale(1);
25
+ }
26
+ }
27
+ `;
28
+ export {
29
+ o as PanelPositioner
30
+ };
31
+ //# sourceMappingURL=ControlledCopilot.styled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlledCopilot.styled.js","sources":["../../../../src/components/bik-copilot/ControlledCopilot.styled.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const PanelPositioner = styled.div<{\n\t$left: number;\n\t$top: number;\n\t$width: number;\n\t$height: number;\n\t$zIndex: number;\n}>`\n\tposition: fixed;\n\tleft: ${(props) => props.$left}px;\n\ttop: ${(props) => props.$top}px;\n\twidth: ${(props) => props.$width}px;\n\theight: ${(props) => props.$height}px;\n\tz-index: ${(props) => props.$zIndex};\n\tdisplay: flex;\n\tanimation: bikCopilotPanelIn 0.16s ease-out;\n\n\t> * {\n\t\tflex: 1;\n\t\tmin-width: 0;\n\t}\n\n\t@keyframes bikCopilotPanelIn {\n\t\tfrom {\n\t\t\topacity: 0;\n\t\t\ttransform: translateY(6px) scale(0.98);\n\t\t}\n\t\tto {\n\t\t\topacity: 1;\n\t\t\ttransform: translateY(0) scale(1);\n\t\t}\n\t}\n`;\n"],"names":["PanelPositioner","styled","props"],"mappings":";AAEO,MAAMA,IAAkBC,EAAO;AAAA;AAAA,SAQ7B,CAACC,MAAUA,EAAM,KAAK;AAAA,QACvB,CAACA,MAAUA,EAAM,IAAI;AAAA,UACnB,CAACA,MAAUA,EAAM,MAAM;AAAA,WACtB,CAACA,MAAUA,EAAM,OAAO;AAAA,YACvB,CAACA,MAAUA,EAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
@@ -0,0 +1,13 @@
1
+ import { default as React } from 'react';
2
+ import { CopilotBallProps } from './model';
3
+ /**
4
+ * Marks the ball in the DOM so an outside-click handler can tell the ball apart
5
+ * from the rest of the page and not fight the ball's own toggle.
6
+ */
7
+ export declare const COPILOT_BALL_ATTRIBUTE = "data-bik-copilot-ball";
8
+ /**
9
+ * The floating ball that opens the copilot panel. Purely presentational — the
10
+ * drag gesture lives in `useDraggableFloater` and is passed in as handlers.
11
+ */
12
+ export declare const CopilotBall: React.FC<CopilotBallProps>;
13
+ export default CopilotBall;
@@ -0,0 +1,50 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import b from "../../assets/icons/bik_ai_stars_icon.svg.js";
3
+ import s from "../../assets/icons/chevronDown.svg.js";
4
+ import { BallButton as x } from "./CopilotBall.styled.js";
5
+ const C = "data-bik-copilot-ball", w = ({
6
+ isOpen: t,
7
+ onToggle: n,
8
+ position: i,
9
+ size: a,
10
+ isDragging: e,
11
+ draggable: c,
12
+ color: d,
13
+ zIndex: g,
14
+ icon: h,
15
+ openIcon: m,
16
+ ariaLabel: p,
17
+ onPointerDown: $,
18
+ onPointerMove: f,
19
+ onPointerUp: u,
20
+ onPointerCancel: B
21
+ }) => {
22
+ const o = Math.round(a * 0.42), l = t ? /* @__PURE__ */ r(s, { width: o, height: o }) : /* @__PURE__ */ r(b, { width: o, height: o }), I = t ? m ?? l : h ?? l;
23
+ return /* @__PURE__ */ r(
24
+ x,
25
+ {
26
+ type: "button",
27
+ [C]: "true",
28
+ $size: a,
29
+ $left: i.x,
30
+ $top: i.y,
31
+ $color: d,
32
+ $zIndex: g,
33
+ $isDragging: e,
34
+ $draggable: c,
35
+ "aria-label": p || "Copilot",
36
+ "aria-expanded": t,
37
+ onClick: n,
38
+ onPointerDown: $,
39
+ onPointerMove: f,
40
+ onPointerUp: u,
41
+ onPointerCancel: B,
42
+ children: I
43
+ }
44
+ );
45
+ };
46
+ export {
47
+ C as COPILOT_BALL_ATTRIBUTE,
48
+ w as CopilotBall
49
+ };
50
+ //# sourceMappingURL=CopilotBall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopilotBall.js","sources":["../../../../src/components/bik-copilot/CopilotBall.tsx"],"sourcesContent":["import AiStarsIcon from '@src/assets/icons/bik_ai_stars_icon.svg';\nimport ChevronDownIcon from '@src/assets/icons/chevronDown.svg';\nimport React from 'react';\nimport { BallButton } from './CopilotBall.styled';\nimport { CopilotBallProps } from './model';\n\n/**\n * Marks the ball in the DOM so an outside-click handler can tell the ball apart\n * from the rest of the page and not fight the ball's own toggle.\n */\nexport const COPILOT_BALL_ATTRIBUTE = 'data-bik-copilot-ball';\n\n/**\n * The floating ball that opens the copilot panel. Purely presentational — the\n * drag gesture lives in `useDraggableFloater` and is passed in as handlers.\n */\nexport const CopilotBall: React.FC<CopilotBallProps> = ({\n\tisOpen,\n\tonToggle,\n\tposition,\n\tsize,\n\tisDragging,\n\tdraggable,\n\tcolor,\n\tzIndex,\n\ticon,\n\topenIcon,\n\tariaLabel,\n\tonPointerDown,\n\tonPointerMove,\n\tonPointerUp,\n\tonPointerCancel,\n}) => {\n\tconst iconSize = Math.round(size * 0.42);\n\tconst defaultIcon = isOpen ? (\n\t\t<ChevronDownIcon width={iconSize} height={iconSize} />\n\t) : (\n\t\t<AiStarsIcon width={iconSize} height={iconSize} />\n\t);\n\tconst activeIcon = isOpen ? openIcon ?? defaultIcon : icon ?? defaultIcon;\n\n\treturn (\n\t\t<BallButton\n\t\t\ttype=\"button\"\n\t\t\t{...{ [COPILOT_BALL_ATTRIBUTE]: 'true' }}\n\t\t\t$size={size}\n\t\t\t$left={position.x}\n\t\t\t$top={position.y}\n\t\t\t$color={color}\n\t\t\t$zIndex={zIndex}\n\t\t\t$isDragging={isDragging}\n\t\t\t$draggable={draggable}\n\t\t\t/* A disclosure button keeps a stable name and reports its state through\n\t\t\t aria-expanded, so this must not become \"Open/Close copilot\" — that\n\t\t\t would also collide with the panel's own close button. */\n\t\t\taria-label={ariaLabel || 'Copilot'}\n\t\t\taria-expanded={isOpen}\n\t\t\tonClick={onToggle}\n\t\t\tonPointerDown={onPointerDown}\n\t\t\tonPointerMove={onPointerMove}\n\t\t\tonPointerUp={onPointerUp}\n\t\t\tonPointerCancel={onPointerCancel}\n\t\t>\n\t\t\t{activeIcon}\n\t\t</BallButton>\n\t);\n};\n\nexport default CopilotBall;\n"],"names":["COPILOT_BALL_ATTRIBUTE","CopilotBall","isOpen","onToggle","position","size","isDragging","draggable","color","zIndex","icon","openIcon","ariaLabel","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","iconSize","defaultIcon","jsx","ChevronDownIcon","AiStarsIcon","activeIcon","BallButton"],"mappings":";;;;AAUO,MAAMA,IAAyB,yBAMzBC,IAA0C,CAAC;AAAA,EACvD,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AACD,MAAM;AACL,QAAMC,IAAW,KAAK,MAAMZ,IAAO,IAAI,GACjCa,IAAchB,IACnB,gBAAAiB,EAACC,GAAA,EAAgB,OAAOH,GAAU,QAAQA,EAAA,CAAU,IAEpD,gBAAAE,EAACE,GAAA,EAAY,OAAOJ,GAAU,QAAQA,GAAU,GAE3CK,IAAapB,IAASS,KAAYO,IAAcR,KAAQQ;AAE9D,SACC,gBAAAC;AAAA,IAACI;AAAA,IAAA;AAAA,MACA,MAAK;AAAA,MACC,CAACvB,CAAsB,GAAG;AAAA,MAChC,OAAOK;AAAA,MACP,OAAOD,EAAS;AAAA,MAChB,MAAMA,EAAS;AAAA,MACf,QAAQI;AAAA,MACR,SAASC;AAAA,MACT,aAAaH;AAAA,MACb,YAAYC;AAAA,MAIZ,cAAYK,KAAa;AAAA,MACzB,iBAAeV;AAAA,MACf,SAASC;AAAA,MACT,eAAAU;AAAA,MACA,eAAAC;AAAA,MACA,aAAAC;AAAA,MACA,iBAAAC;AAAA,MAEC,UAAAM;AAAA,IAAA;AAAA,EAAA;AAGJ;"}
@@ -0,0 +1,9 @@
1
+ export declare const BallButton: import('styled-components').StyledComponent<"button", any, {
2
+ $size: number;
3
+ $left: number;
4
+ $top: number;
5
+ $color: string;
6
+ $zIndex: number;
7
+ $isDragging: boolean;
8
+ $draggable: boolean;
9
+ }, never>;
@@ -0,0 +1,46 @@
1
+ import s from "styled-components";
2
+ const t = s.button`
3
+ position: fixed;
4
+ left: ${(e) => e.$left}px;
5
+ top: ${(e) => e.$top}px;
6
+ width: ${(e) => e.$size}px;
7
+ height: ${(e) => e.$size}px;
8
+ z-index: ${(e) => e.$zIndex};
9
+
10
+ display: flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+ padding: 0;
14
+ border: none;
15
+ border-radius: 50%;
16
+ background: ${(e) => e.$color};
17
+ color: #ffffff;
18
+ box-shadow: ${(e) => e.$isDragging ? "0 12px 32px rgba(40, 3, 78, 0.36)" : "0 6px 20px rgba(40, 3, 78, 0.24)"};
19
+
20
+ cursor: ${(e) => e.$isDragging ? "grabbing" : e.$draggable ? "grab" : "pointer"};
21
+ touch-action: none;
22
+ user-select: none;
23
+ -webkit-user-select: none;
24
+
25
+ /* Position changes animate on release but must track the pointer 1:1 while
26
+ the user is dragging. */
27
+ transition: ${(e) => e.$isDragging ? "box-shadow 0.15s ease, transform 0.15s ease" : "left 0.22s ease, top 0.22s ease, box-shadow 0.15s ease, transform 0.15s ease"};
28
+ transform: ${(e) => e.$isDragging ? "scale(1.06)" : "scale(1)"};
29
+
30
+ &:hover {
31
+ transform: scale(1.06);
32
+ }
33
+
34
+ &:focus-visible {
35
+ outline: 2px solid #ffffff;
36
+ outline-offset: 2px;
37
+ }
38
+
39
+ svg {
40
+ pointer-events: none;
41
+ }
42
+ `;
43
+ export {
44
+ t as BallButton
45
+ };
46
+ //# sourceMappingURL=CopilotBall.styled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopilotBall.styled.js","sources":["../../../../src/components/bik-copilot/CopilotBall.styled.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const BallButton = styled.button<{\n\t$size: number;\n\t$left: number;\n\t$top: number;\n\t$color: string;\n\t$zIndex: number;\n\t$isDragging: boolean;\n\t$draggable: boolean;\n}>`\n\tposition: fixed;\n\tleft: ${(props) => props.$left}px;\n\ttop: ${(props) => props.$top}px;\n\twidth: ${(props) => props.$size}px;\n\theight: ${(props) => props.$size}px;\n\tz-index: ${(props) => props.$zIndex};\n\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: 0;\n\tborder: none;\n\tborder-radius: 50%;\n\tbackground: ${(props) => props.$color};\n\tcolor: #ffffff;\n\tbox-shadow: ${(props) =>\n\t\tprops.$isDragging\n\t\t\t? '0 12px 32px rgba(40, 3, 78, 0.36)'\n\t\t\t: '0 6px 20px rgba(40, 3, 78, 0.24)'};\n\n\tcursor: ${(props) =>\n\t\tprops.$isDragging ? 'grabbing' : props.$draggable ? 'grab' : 'pointer'};\n\ttouch-action: none;\n\tuser-select: none;\n\t-webkit-user-select: none;\n\n\t/* Position changes animate on release but must track the pointer 1:1 while\n\t the user is dragging. */\n\ttransition: ${(props) =>\n\t\tprops.$isDragging\n\t\t\t? 'box-shadow 0.15s ease, transform 0.15s ease'\n\t\t\t: 'left 0.22s ease, top 0.22s ease, box-shadow 0.15s ease, transform 0.15s ease'};\n\ttransform: ${(props) => (props.$isDragging ? 'scale(1.06)' : 'scale(1)')};\n\n\t&:hover {\n\t\ttransform: scale(1.06);\n\t}\n\n\t&:focus-visible {\n\t\toutline: 2px solid #ffffff;\n\t\toutline-offset: 2px;\n\t}\n\n\tsvg {\n\t\tpointer-events: none;\n\t}\n`;\n"],"names":["BallButton","styled","props"],"mappings":";AAEO,MAAMA,IAAaC,EAAO;AAAA;AAAA,SAUxB,CAACC,MAAUA,EAAM,KAAK;AAAA,QACvB,CAACA,MAAUA,EAAM,IAAI;AAAA,UACnB,CAACA,MAAUA,EAAM,KAAK;AAAA,WACrB,CAACA,MAAUA,EAAM,KAAK;AAAA,YACrB,CAACA,MAAUA,EAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAQrB,CAACA,MAAUA,EAAM,MAAM;AAAA;AAAA,eAEvB,CAACA,MACdA,EAAM,cACH,sCACA,kCAAkC;AAAA;AAAA,WAE5B,CAACA,MACVA,EAAM,cAAc,aAAaA,EAAM,aAAa,SAAS,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAOzD,CAACA,MACdA,EAAM,cACH,gDACA,8EAA8E;AAAA,cACrE,CAACA,MAAWA,EAAM,cAAc,gBAAgB,UAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { CopilotPanelProps } from './model';
3
+ /**
4
+ * Chat panel used by the copilot. Fully presentational: it renders the
5
+ * transcript it is given and reports user intent through callbacks, so it works
6
+ * against any backend.
7
+ */
8
+ export declare const CopilotPanel: React.FC<CopilotPanelProps>;
9
+ export default CopilotPanel;