@retrivora-ai/rag-engine 2.4.3 → 2.4.5

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 (139) hide show
  1. package/dist/{BatchProcessor-zbQMaZHm.d.mts → BatchProcessor-Csy_K1qQ.d.mts} +2 -0
  2. package/dist/{BatchProcessor-D42E706a.d.ts → BatchProcessor-Dg18zZGk.d.ts} +2 -0
  3. package/dist/handlers/index.js +27 -4
  4. package/dist/handlers/index.mjs +27 -4
  5. package/dist/index.d.mts +3 -3
  6. package/dist/index.d.ts +3 -3
  7. package/dist/index.js +12 -10
  8. package/dist/index.mjs +12 -10
  9. package/dist/server.d.mts +2 -2
  10. package/dist/server.d.ts +2 -2
  11. package/dist/server.js +28 -4
  12. package/dist/server.mjs +28 -4
  13. package/package.json +1 -3
  14. package/src/LicensedRetrivora.ts +0 -278
  15. package/src/app/api/chat/route.ts +0 -4
  16. package/src/app/api/health/route.ts +0 -5
  17. package/src/app/api/ingest/route.ts +0 -27
  18. package/src/app/api/suggestions/route.ts +0 -5
  19. package/src/app/api/upload/route.ts +0 -5
  20. package/src/app/constants.tsx +0 -270
  21. package/src/app/favicon.ico +0 -0
  22. package/src/app/globals.css +0 -449
  23. package/src/app/layout.tsx +0 -22
  24. package/src/app/page.tsx +0 -64
  25. package/src/app/types.ts +0 -30
  26. package/src/browser.tsx +0 -127
  27. package/src/components/ChatWidget.tsx +0 -393
  28. package/src/components/ChatWindow.tsx +0 -952
  29. package/src/components/CodeViewer.tsx +0 -56
  30. package/src/components/ConfigProvider.tsx +0 -141
  31. package/src/components/DocumentUpload.tsx +0 -354
  32. package/src/components/DynamicChart.tsx +0 -297
  33. package/src/components/HourglassLoader.tsx +0 -87
  34. package/src/components/MarkdownComponents.tsx +0 -186
  35. package/src/components/MessageBubble.tsx +0 -498
  36. package/src/components/ObservabilityPanel.tsx +0 -374
  37. package/src/components/ProductCard.tsx +0 -107
  38. package/src/components/ProductCarousel.tsx +0 -97
  39. package/src/components/SourceCard.tsx +0 -61
  40. package/src/components/ThemeProvider.tsx +0 -8
  41. package/src/components/ThemeToggle.tsx +0 -29
  42. package/src/components/ThinkingBlock.tsx +0 -75
  43. package/src/components/UIDispatcher.tsx +0 -342
  44. package/src/components/VisualizationRenderer.tsx +0 -621
  45. package/src/components/constants.tsx +0 -503
  46. package/src/config/ConfigBuilder.ts +0 -285
  47. package/src/config/EmbeddingStrategy.ts +0 -148
  48. package/src/config/LicenseConfigResolver.ts +0 -298
  49. package/src/config/RagConfig.ts +0 -328
  50. package/src/config/UniversalProfiles.ts +0 -82
  51. package/src/config/constants.ts +0 -64
  52. package/src/config/serverConfig.ts +0 -378
  53. package/src/config/uiConstants.ts +0 -47
  54. package/src/core/BatchProcessor.ts +0 -385
  55. package/src/core/CircuitBreaker.ts +0 -118
  56. package/src/core/ConfigFetcher.ts +0 -220
  57. package/src/core/ConfigResolver.ts +0 -165
  58. package/src/core/ConfigValidator.ts +0 -197
  59. package/src/core/DatabaseStorage.ts +0 -526
  60. package/src/core/FreeTierLimitsGuard.ts +0 -281
  61. package/src/core/LLMRouter.ts +0 -79
  62. package/src/core/LangChainAgent.ts +0 -132
  63. package/src/core/LicenseValidator.ts +0 -284
  64. package/src/core/LicenseVerifier.ts +0 -261
  65. package/src/core/MultiAgentCoordinator.ts +0 -239
  66. package/src/core/Pipeline.ts +0 -1279
  67. package/src/core/PluginManager.ts +0 -277
  68. package/src/core/ProjectSettings.ts +0 -247
  69. package/src/core/ProviderHealthCheck.ts +0 -133
  70. package/src/core/ProviderInterfaces.ts +0 -37
  71. package/src/core/ProviderRegistry.ts +0 -156
  72. package/src/core/QueryProcessor.ts +0 -399
  73. package/src/core/Retrivora.ts +0 -98
  74. package/src/core/VectorPlugin.ts +0 -193
  75. package/src/core/mcp.ts +0 -261
  76. package/src/exceptions/index.ts +0 -131
  77. package/src/handlers/index.ts +0 -1625
  78. package/src/hooks/useHydrated.ts +0 -13
  79. package/src/hooks/useProjectSettings.ts +0 -105
  80. package/src/hooks/useRagChat.ts +0 -436
  81. package/src/hooks/useStoredMessages.ts +0 -64
  82. package/src/index.css +0 -4269
  83. package/src/index.ts +0 -137
  84. package/src/lib/plugin.ts +0 -24
  85. package/src/llm/ILLMProvider.ts +0 -60
  86. package/src/llm/LLMFactory.ts +0 -141
  87. package/src/llm/providers/AnthropicProvider.ts +0 -215
  88. package/src/llm/providers/GeminiProvider.ts +0 -311
  89. package/src/llm/providers/GroqProvider.ts +0 -184
  90. package/src/llm/providers/OllamaProvider.ts +0 -232
  91. package/src/llm/providers/OpenAIProvider.ts +0 -188
  92. package/src/llm/providers/QwenProvider.ts +0 -199
  93. package/src/llm/providers/UniversalLLMAdapter.ts +0 -422
  94. package/src/llm/utils.ts +0 -46
  95. package/src/providers/graphdb/BaseGraphProvider.ts +0 -43
  96. package/src/providers/graphdb/SimpleGraphProvider.ts +0 -66
  97. package/src/providers/vectordb/BaseVectorProvider.ts +0 -98
  98. package/src/providers/vectordb/ChromaDBProvider.ts +0 -130
  99. package/src/providers/vectordb/MilvusProvider.ts +0 -134
  100. package/src/providers/vectordb/MongoDBProvider.ts +0 -250
  101. package/src/providers/vectordb/MultiTablePostgresProvider.ts +0 -461
  102. package/src/providers/vectordb/PineconeProvider.ts +0 -295
  103. package/src/providers/vectordb/PostgreSQLProvider.ts +0 -227
  104. package/src/providers/vectordb/QdrantProvider.ts +0 -294
  105. package/src/providers/vectordb/RedisProvider.ts +0 -105
  106. package/src/providers/vectordb/UniversalVectorProvider.ts +0 -221
  107. package/src/providers/vectordb/WeaviateProvider.ts +0 -172
  108. package/src/rag/DocumentChunker.ts +0 -144
  109. package/src/rag/EntityExtractor.ts +0 -90
  110. package/src/rag/LlamaIndexIngestor.ts +0 -60
  111. package/src/rag/Reranker.ts +0 -106
  112. package/src/rendering/IntentClassifier.ts +0 -167
  113. package/src/rendering/RendererRegistry.ts +0 -164
  114. package/src/rendering/RuleEngine.ts +0 -67
  115. package/src/rendering/VisualizationDecisionEngine.ts +0 -164
  116. package/src/rendering/__tests__/VisualizationDecisionEngine.test.ts +0 -237
  117. package/src/rendering/index.ts +0 -12
  118. package/src/rendering/rules/Rule1SpecificInfoRule.ts +0 -28
  119. package/src/rendering/rules/Rule2ComparisonRule.ts +0 -24
  120. package/src/rendering/rules/Rule3ProductDiscoveryRule.ts +0 -28
  121. package/src/rendering/rules/Rule4AnalyticalRule.ts +0 -38
  122. package/src/rendering/rules/Rule5MixedResponseRule.ts +0 -29
  123. package/src/rendering/rules/Rule6SmallResultSetRule.ts +0 -24
  124. package/src/rendering/rules/Rule7LargeTableRule.ts +0 -35
  125. package/src/rendering/types.ts +0 -96
  126. package/src/server.ts +0 -156
  127. package/src/tailwind.css +0 -194
  128. package/src/telemetry/TelemetryService.ts +0 -330
  129. package/src/types/chat.ts +0 -89
  130. package/src/types/index.ts +0 -278
  131. package/src/types/pdf-parse.d.ts +0 -13
  132. package/src/types/props.ts +0 -169
  133. package/src/utils/DocumentParser.ts +0 -111
  134. package/src/utils/ProductExtractor.ts +0 -350
  135. package/src/utils/SchemaMapper.ts +0 -176
  136. package/src/utils/UITransformer.ts +0 -1812
  137. package/src/utils/synonyms.ts +0 -80
  138. package/src/utils/templateUtils.ts +0 -78
  139. package/src/version.ts +0 -6
@@ -1,393 +0,0 @@
1
- import React, { useState, useEffect, useCallback } from 'react';
2
- import { MessageSquare, X, AlertTriangle, Lock } from 'lucide-react';
3
- import { ChatWindow } from './ChatWindow';
4
- import { useConfig } from './ConfigProvider';
5
- import { ChatWidgetProps } from '../types';
6
- import { SDK_VERSION } from '../version';
7
- import { LicenseValidator, LicenseValidationResponse } from '../core/LicenseValidator';
8
-
9
- /**
10
- * Default widget dimensions (width x height) in pixels.
11
- * Applied when the widget first opens and when the user resets sizing.
12
- */
13
- const DEFAULT_DIMENSIONS = { width: 380, height: 600 };
14
-
15
- /**
16
- * Keyframes and CSS custom properties for the Gemini-style
17
- * shape-shifting floating button background.
18
- */
19
- const GEMINI_STYLES = `
20
- @keyframes shapeshift {
21
- 0% { clip-path: var(--circle); rotate: 0turn; }
22
- 25% { clip-path: var(--flower); }
23
- 50% { clip-path: var(--cylinder); }
24
- 75% { clip-path: var(--hexagon); }
25
- 100% { clip-path: var(--circle); rotate: 1turn; }
26
- 200% { clip-path: var(--flower); rotate: 2turn; }
27
-
28
- 220% {
29
- clip-path: var(--cylinder);
30
- }
31
-
32
- 240% {
33
- clip-path: var(--hexagon);
34
- }
35
-
36
- 260% { clip-path: var(--circle); rotate: 1turn; }
37
- }
38
-
39
- @keyframes gradientMove {
40
- 0% { translate: 0 0; }
41
- 100% { translate: -75% -75%; }
42
- }
43
-
44
- :root {
45
- --flower: shape(evenodd from 17.9665% 82.0335%, curve by -12.349% -32.0335% with -13.239% -5.129% / -18.021% -15.402%, curve by -0.0275% -22.203% with -3.1825% -9.331% / -3.074% -16.6605%, curve by 12.3765% -9.8305% with 2.3835% -4.3365% / 6.565% -7.579%, curve by 32.0335% -12.349% with 5.129% -13.239% / 15.402% -18.021%, curve by 20.4535% -0.8665% with 8.3805% -2.858% / 15.1465% -3.062%, curve by 11.58% 13.2155% with 5.225% 2.161% / 9.0355% 6.6475%, curve by 12.349% 32.0335% with 13.239% 5.129% / 18.021% 15.402%, curve by 0.5715% 21.1275% with 2.9805% 8.7395% / 3.0745% 15.723%, curve by -12.9205% 10.906% with -2.26% 4.88% / -6.638% 8.472%, curve by -32.0335% 12.349% with -5.129% 13.239% / -15.402% 18.021%, curve by -21.1215% 0.5745% with -8.736% 2.9795% / -15.718% 3.0745%, curve by -10.912% -12.9235% with -4.883% -2.2595% / -8.477% -6.6385%, close);
46
- --hexagon: shape(evenodd from 6.47% 67.001%, curve by 0% -34.002% with -1.1735% -7.7% / -1.1735% -26.302%, curve by 7.0415% -12.1965% with 0.7075% -4.641% / 3.3765% -9.2635%, curve by 29.447% -17.001% with 6.0815% -4.8665% / 22.192% -14.1675%, curve by 14.083% 0% with 4.3725% -1.708% / 9.7105% -1.708%, curve by 29.447% 17.001% with 7.255% 2.8335% / 23.3655% 12.1345%, curve by 7.0415% 12.1965% with 3.665% 2.933% / 6.334% 7.5555%, curve by 0% 34.002% with 1.1735% 7.7% / 1.1735% 26.302%, curve by -7.0415% 12.1965% with -0.7075% 4.641% / -3.3765% 9.2635%, curve by -29.447% 17.001% with -6.0815% 4.8665% / -22.192% 14.1675%, curve by -14.083% 0% with -4.3725% 1.708% / -9.7105% 1.708%, curve by -29.447% -17.001% with -7.255% -2.8335% / -23.3655% -12.1345%, curve by -7.0415% -12.1965% with -3.665% -2.933% / -6.334% -7.5555%, close);
47
- --cylinder: shape(evenodd from 10.5845% 59.7305%, curve by 0% -19.461% with -0.113% -1.7525% / -0.11% -18.14%, curve by 10.098% -26.213% with 0.837% -10.0375% / 3.821% -19.2625%, curve by 29.3175% -13.0215% with 7.2175% -7.992% / 17.682% -13.0215%, curve by 19.5845% 5.185% with 7.1265% 0% / 13.8135% 1.887%, curve by 9.8595% 7.9775% with 3.7065% 2.1185% / 7.035% 4.8195%, curve by 9.9715% 26.072% with 6.2015% 6.933% / 9.4345% 16.082%, curve by 0% 19.461% with 0.074% 1.384% / 0.0745% 17.7715%, curve by -13.0065% 29.1155% with -0.511% 11.5345% / -5.021% 21.933%, curve by -26.409% 10.119% with -6.991% 6.288% / -16.254% 10.119%, curve by -20.945% -5.9995% with -7.6935% 0% / -14.8755% -2.199%, curve by -8.713% -7.404% with -3.255% -2.0385% / -6.1905% -4.537%, curve by -9.7575% -25.831% with -6.074% -6.9035% / -9.1205% -15.963%, close);
48
- --circle: shape(evenodd from 13.482% 79.505%, curve by -7.1945% -12.47% with -1.4985% -1.8575% / -6.328% -10.225%, curve by 0.0985% -33.8965% with -4.1645% -10.7945% / -4.1685% -23.0235%, curve by 6.9955% -12.101% with 1.72% -4.3825% / 4.0845% -8.458%, curve by 30.125% -17.119% with 7.339% -9.1825% / 18.4775% -15.5135%, curve by 13.4165% 0.095% with 4.432% -0.6105% / 8.9505% -0.5855%, curve by 29.364% 16.9% with 11.6215% 1.77% / 22.102% 7.9015%, curve by 7.176% 12.4145% with 3.002% 3.7195% / 5.453% 7.968%, curve by -0.0475% 33.8925% with 4.168% 10.756% / 4.2305% 22.942%, curve by -7.1135% 12.2825% with -1.74% 4.4535% / -4.1455% 8.592%, curve by -29.404% 16.9075% with -7.202% 8.954% / -18.019% 15.137%, curve by -14.19% -0.018% with -4.6635% 0.7255% / -9.4575% 0.7205%, curve by -29.226% -16.8875% with -11.573% -1.8065% / -21.9955% -7.9235%, close);
49
- }
50
- `;
51
-
52
- /**
53
- * ChatWidget — Floating Action Button (FAB) that toggles the chat window.
54
- *
55
- * Responsibilities:
56
- * - Validates the Retrivora license key BEFORE allowing the chat to open
57
- * - Proactively validates on mount to visually lock the widget when no
58
- * valid license is present (TERMINATED / SUSPENDED / missing)
59
- * - Manages window resize, maximize, and visual positioning
60
- * - Shows an error toast when license validation fails on user attempt
61
- *
62
- * License key resolution order (highest to lowest priority):
63
- * 1. Explicit `licenseKey` prop
64
- * 2. `x-license-key` header (from `headers` prop)
65
- * 3. `Authorization: Bearer <key>` header (from `headers` prop)
66
- * 4. Environment variables `NEXT_PUBLIC_RETRIVORA_LICENSE_KEY` / `RETRIVORA_LICENSE_KEY`
67
- *
68
- * @param props - Widget position, callbacks, API overrides, and license overrides
69
- */
70
- export function ChatWidget({ position, onAddToCart, apiUrl, retrivoraApiBase, licenseKey: licenseKeyProp, headers }: ChatWidgetProps) {
71
- const {
72
- ui,
73
- projectId,
74
- projectSettings,
75
- licenseKey: contextLicenseKey,
76
- headers: contextHeaders,
77
- retrivoraApiBase: contextApiBase,
78
- } = useConfig();
79
- const effectivePosition = position || projectSettings?.widget.position || 'bottom-right';
80
- const effectiveHeaders = headers || contextHeaders;
81
- const effectiveLicenseKey = licenseKeyProp || contextLicenseKey;
82
- const effectiveApiBase = retrivoraApiBase || contextApiBase;
83
- const [isOpen, setIsOpen] = useState(false);
84
- const [hasUnread, setHasUnread] = useState(false);
85
- const [dimensions, setDimensions] = useState(DEFAULT_DIMENSIONS);
86
- const [isResizing, setIsResizing] = useState(false);
87
- const [isMaximized, setIsMaximized] = useState(false);
88
- const [prevDimensions, setPrevDimensions] = useState(DEFAULT_DIMENSIONS);
89
- const [widgetError, setWidgetError] = useState<string | null>(null);
90
- const [isValidating, setIsValidating] = useState(false);
91
- const [hasMountValidationFailed, setHasMountValidationFailed] = useState(false);
92
-
93
- const positionClass =
94
- effectivePosition === 'bottom-left'
95
- ? 'bottom-6 left-6'
96
- : effectivePosition === 'top-left'
97
- ? 'top-6 left-6'
98
- : effectivePosition === 'top-right'
99
- ? 'top-6 right-6'
100
- : 'bottom-6 right-6';
101
-
102
- const windowPositionClass =
103
- effectivePosition === 'bottom-left'
104
- ? 'bottom-20 left-6'
105
- : effectivePosition === 'top-left'
106
- ? 'top-20 left-6'
107
- : effectivePosition === 'top-right'
108
- ? 'top-20 right-6'
109
- : 'bottom-20 right-6';
110
-
111
- /**
112
- * Resolves the active license key from all possible sources
113
- * (explicit prop → headers → environment variables).
114
- */
115
- const resolveLicenseKey = useCallback((): string => {
116
- const getHeader = (name: string) => {
117
- if (!effectiveHeaders) return undefined;
118
- const target = name.toLowerCase();
119
- for (const [k, v] of Object.entries(effectiveHeaders)) {
120
- if (k.toLowerCase() === target) return v;
121
- }
122
- return undefined;
123
- };
124
-
125
- return (
126
- effectiveLicenseKey ||
127
- getHeader('x-license-key') ||
128
- getHeader('authorization')?.replace(/^Bearer\s+/i, '') ||
129
- (typeof process !== 'undefined'
130
- ? (process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY)
131
- : '') ||
132
- ''
133
- );
134
- }, [effectiveLicenseKey, effectiveHeaders]);
135
-
136
- /**
137
- * Proactively validate the license on mount.
138
- * If validation fails, mark the widget locked so the FAB button appears
139
- * disabled and we don't waste a network call on every subsequent click.
140
- */
141
- useEffect(() => {
142
- let isMounted = true;
143
- async function validateOnMount() {
144
- try {
145
- const resolvedLicenseKey = resolveLicenseKey();
146
- await LicenseValidator.getInstance().validate({
147
- licenseKey: resolvedLicenseKey,
148
- projectId,
149
- retrivoraApiBase: effectiveApiBase,
150
- headers: effectiveHeaders,
151
- });
152
- if (isMounted) {
153
- setHasMountValidationFailed(false);
154
- setWidgetError(null);
155
- }
156
- } catch (err: any) {
157
- if (isMounted) {
158
- setHasMountValidationFailed(true);
159
- setWidgetError(err?.message || 'Access denied.');
160
- }
161
- }
162
- }
163
- validateOnMount();
164
- return () => { isMounted = false; };
165
- }, [resolveLicenseKey, projectId, effectiveApiBase, effectiveHeaders]);
166
-
167
- /**
168
- * Validates the license key and opens the chat window.
169
- * If the license was already marked invalid on mount we immediately
170
- * re-display the error toast without re-validating.
171
- */
172
- const handleOpen = useCallback(async () => {
173
- if (hasMountValidationFailed && widgetError) {
174
- setWidgetError(widgetError);
175
- return;
176
- }
177
- setIsValidating(true);
178
- try {
179
- const resolvedLicenseKey = resolveLicenseKey();
180
-
181
- await LicenseValidator.getInstance().validate({
182
- licenseKey: resolvedLicenseKey,
183
- projectId,
184
- retrivoraApiBase: effectiveApiBase,
185
- headers: effectiveHeaders,
186
- });
187
-
188
- setWidgetError(null);
189
- setHasMountValidationFailed(false);
190
- setIsOpen(true);
191
- setHasUnread(false);
192
- } catch (err: any) {
193
- setHasMountValidationFailed(true);
194
- setWidgetError(err?.message || 'Access denied.');
195
- setIsOpen(false);
196
- } finally {
197
- setIsValidating(false);
198
- }
199
- }, [hasMountValidationFailed, widgetError, resolveLicenseKey, projectId, effectiveApiBase, effectiveHeaders]);
200
-
201
- /** True when the license has been proven invalid and the widget must be locked. */
202
- const isWidgetLocked = hasMountValidationFailed || isValidating;
203
-
204
- const handleResizeStart = (e: React.MouseEvent) => {
205
- e.preventDefault();
206
- setIsResizing(true);
207
- const startX = e.clientX;
208
- const startY = e.clientY;
209
- const startWidth = dimensions.width;
210
- const startHeight = dimensions.height;
211
-
212
- const onMouseMove = (moveEvent: MouseEvent) => {
213
- const deltaX = startX - moveEvent.clientX;
214
- const deltaY = startY - moveEvent.clientY;
215
-
216
- setDimensions({
217
- width: Math.max(320, Math.min(startWidth + deltaX, window.innerWidth - 48)),
218
- height: Math.max(400, Math.min(startHeight + deltaY, window.innerHeight - 100)),
219
- });
220
- };
221
-
222
- const onMouseUp = () => {
223
- setIsResizing(false);
224
- window.removeEventListener('mousemove', onMouseMove);
225
- window.removeEventListener('mouseup', onMouseUp);
226
- };
227
-
228
- window.addEventListener('mousemove', onMouseMove);
229
- window.addEventListener('mouseup', onMouseUp);
230
- };
231
-
232
- const handleResetResize = () => {
233
- setDimensions(DEFAULT_DIMENSIONS);
234
- setIsMaximized(false);
235
- };
236
-
237
- const handleMaximize = () => {
238
- if (isMaximized) {
239
- setDimensions(prevDimensions);
240
- setIsMaximized(false);
241
- } else {
242
- setPrevDimensions(dimensions);
243
- setDimensions({
244
- width: Math.min(800, window.innerWidth - 48),
245
- height: Math.min(800, window.innerHeight - 100),
246
- });
247
- setIsMaximized(true);
248
- }
249
- };
250
-
251
- const isResized = dimensions.width !== DEFAULT_DIMENSIONS.width || dimensions.height !== DEFAULT_DIMENSIONS.height;
252
-
253
- if (ui.showWidget === false) return null;
254
-
255
- return (
256
- <>
257
- <style dangerouslySetInnerHTML={{ __html: GEMINI_STYLES }} />
258
- {/* ── Chat Window (slides up) ── */}
259
- <div
260
- className={`fixed z-[9998] max-w-[calc(100vw-3rem)] ease-in-out ${windowPositionClass} ${isOpen
261
- ? 'opacity-100 translate-y-0 pointer-events-auto'
262
- : 'opacity-0 translate-y-4 pointer-events-none'
263
- } ${isResizing ? '' : 'transition-all duration-300'}`}
264
- style={{
265
- width: `${dimensions.width}px`,
266
- height: `${dimensions.height}px`,
267
- maxHeight: 'calc(100vh - 6rem)'
268
- }}
269
- >
270
- <ChatWindow
271
- className="h-full relative z-10"
272
- showClose
273
- onClose={() => setIsOpen(false)}
274
- onResizeStart={ui.allowResize !== false ? handleResizeStart : undefined}
275
- onResetResize={ui.allowResize !== false ? handleResetResize : undefined}
276
- isResized={isResized}
277
- onMaximize={ui.allowResize !== false ? handleMaximize : undefined}
278
- isMaximized={isMaximized}
279
- onAddToCart={onAddToCart}
280
- apiUrl={apiUrl}
281
- retrivoraApiBase={effectiveApiBase}
282
- licenseKey={effectiveLicenseKey}
283
- headers={effectiveHeaders}
284
- />
285
- {/* Pointer (Tail) */}
286
- <div
287
- className={`absolute -bottom-1.5 w-4 h-4 rotate-45 border-r border-b border-slate-200 dark:border-white/10 z-0 ${ui.visualStyle === 'solid' ? 'bg-white dark:bg-[#0f0f1a]' : 'bg-white/90 dark:bg-[#0f0f1a]/90 backdrop-blur-xl'
288
- } ${effectivePosition === 'bottom-left' || effectivePosition === 'top-left' ? 'left-5' : 'right-5'}`}
289
- />
290
- </div>
291
-
292
- {/* ── Widget Error Toast/Pop-over (when opening is blocked) ── */}
293
- {widgetError && !isOpen && (
294
- <div
295
- className={`fixed z-[9999] max-w-sm p-4 rounded-2xl shadow-2xl border border-rose-200 dark:border-rose-900/60 bg-white/95 dark:bg-[#0f0f1a]/95 backdrop-blur-xl transition-all duration-300 animate-in fade-in slide-in-from-bottom-3 ${
296
- effectivePosition === 'bottom-left'
297
- ? 'bottom-24 left-6'
298
- : effectivePosition === 'top-left'
299
- ? 'top-24 left-6'
300
- : effectivePosition === 'top-right'
301
- ? 'top-24 right-6'
302
- : 'bottom-24 right-6'
303
- }`}
304
- >
305
- <div className="flex items-start gap-3">
306
- <div className="w-8 h-8 rounded-xl bg-rose-100 dark:bg-rose-900/40 text-rose-600 dark:text-rose-400 flex items-center justify-center shrink-0 mt-0.5">
307
- <AlertTriangle className="w-4 h-4" />
308
- </div>
309
- <div className="flex-1 space-y-1">
310
- <h5 className="text-xs font-bold text-slate-900 dark:text-white">Access Blocked</h5>
311
- <p className="text-[11px] text-slate-600 dark:text-slate-300 leading-relaxed font-medium">
312
- {widgetError}
313
- </p>
314
- </div>
315
- <button
316
- onClick={() => setWidgetError(null)}
317
- className="text-slate-400 hover:text-slate-600 dark:hover:text-white transition-colors p-1"
318
- >
319
- <X className="w-3.5 h-3.5" />
320
- </button>
321
- </div>
322
- </div>
323
- )}
324
-
325
- {/* ── Floating Action Button ── */}
326
- <button
327
- onClick={isOpen ? () => setIsOpen(false) : handleOpen}
328
- aria-label={isWidgetLocked ? 'Chat unavailable - invalid or missing license key' : (isOpen ? 'Close chat' : 'Open chat')}
329
- aria-disabled={isWidgetLocked && !isOpen}
330
- className={`group fixed z-[9999] w-14 h-14 drop-shadow-2xl flex items-center justify-center transition-all duration-300 ${positionClass} ${
331
- isWidgetLocked && !isOpen
332
- ? 'grayscale opacity-60 cursor-not-allowed'
333
- : 'cursor-pointer hover:scale-110 active:scale-95'
334
- }`}
335
- >
336
- {/* Animated Background (disabled when locked) */}
337
- <div
338
- className={`absolute inset-0 transition-all duration-300 overflow-hidden rounded-full ${
339
- !(isWidgetLocked && !isOpen) && 'group-hover:rounded-none group-hover:animate-[shapeshift_5s_ease-in-out_infinite_forwards]'
340
- }`}
341
- style={{
342
- background: isWidgetLocked && !isOpen
343
- ? 'linear-gradient(135deg, #64748b, #475569)'
344
- : undefined,
345
- }}
346
- >
347
- {!(isWidgetLocked && !isOpen) && (
348
- <div
349
- className="absolute top-0 left-0 w-[400%] h-[400%] transition-transform duration-300 group-hover:animate-[gradientMove_3.5s_ease-in-out_infinite_alternate]"
350
- style={{
351
- background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor}, ${ui.primaryColor}, ${ui.accentColor})`
352
- }}
353
- />
354
- )}
355
- </div>
356
-
357
- {/* Ripple ring (hidden when locked) */}
358
- {!(isWidgetLocked && !isOpen) && (
359
- <span
360
- className="absolute inset-0 rounded-full animate-ping opacity-20 pointer-events-none"
361
- style={{ background: ui.primaryColor }}
362
- />
363
- )}
364
-
365
- {/* Icon Layer */}
366
- <span
367
- className={`relative z-10 transition-transform duration-300 ${
368
- isOpen
369
- ? 'rotate-90 scale-90'
370
- : isWidgetLocked
371
- ? 'scale-90'
372
- : 'rotate-0 scale-100'
373
- }`}
374
- >
375
- {isOpen ? (
376
- <X className="w-6 h-6 text-white" />
377
- ) : isWidgetLocked ? (
378
- <Lock className="w-6 h-6 text-white" />
379
- ) : (
380
- <MessageSquare className="w-6 h-6 text-white" />
381
- )}
382
- </span>
383
-
384
- {/* Unread badge (hidden when locked or open) */}
385
- {hasUnread && !isOpen && !isWidgetLocked && (
386
- <span className="absolute top-0 right-0 w-4 h-4 bg-rose-500 rounded-full border-2 border-white flex items-center justify-center text-[9px] font-bold text-white">
387
- 1
388
- </span>
389
- )}
390
- </button>
391
- </>
392
- );
393
- }